[Dbconfig-common-changes] [dbconfig-common] r314 - in trunk: debian dpkg internal

Matt Brown mattb-guest at costa.debian.org
Tue Aug 22 12:30:47 CEST 2006


Author: mattb-guest
Date: 2006-08-22 10:30:46 +0000 (Tue, 22 Aug 2006)
New Revision: 314

Modified:
   trunk/debian/changelog
   trunk/dpkg/common
   trunk/internal/sqlite
Log:
The directory containing a sqlite database file must be writeable by the
same users that have access to the dbfile itself as sqlite creates 
journal files next to the dbfile. 

Add support for setting the permissions on the basepath holding the dbfile
to dbconfig-common.


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-08-21 21:31:05 UTC (rev 313)
+++ trunk/debian/changelog	2006-08-22 10:30:46 UTC (rev 314)
@@ -6,6 +6,12 @@
   * make sure all sh references to /dev/stderr go to &2 instead.  thanks
     to Aidas Kasparas for finding this (closes: #383988).
 
+  [Matt Brown]
+  * Default to creating sqlite databases in
+    /var/lib/dbconfig-common/sqlite/<pkgname>
+  * Set the permissions on /var/lib/dbconfig-common/sqlite/<pkgname> to
+    match those of the database file.
+
  -- sean finney <seanius at debian.org>  Mon, 21 Aug 2006 23:30:03 +0200
 
 dbconfig-common (1.8.20) unstable; urgency=low

Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common	2006-08-21 21:31:05 UTC (rev 313)
+++ trunk/dpkg/common	2006-08-22 10:30:46 UTC (rev 314)
@@ -130,7 +130,7 @@
 		dbc_register_templates="$dbc_standard_templates $dbc_sqlite_templates"
 		dbc_default_admin=""
 		dbc_default_dbuser="";
-		dbc_default_basepath="/var/lib/dbconfig-common"
+		dbc_default_basepath="/var/lib/dbconfig-common/sqlite/$dbc_package"
 		dbc_use_dbuser="false"
 		dbc_dbvendor="SQLite"
 	;;

Modified: trunk/internal/sqlite
===================================================================
--- trunk/internal/sqlite	2006-08-21 21:31:05 UTC (rev 313)
+++ trunk/internal/sqlite	2006-08-22 10:30:46 UTC (rev 314)
@@ -10,6 +10,15 @@
 # get some common functions
 . /usr/share/dbconfig-common/internal/common
 
+check_basepath_permissions(){
+	local line
+	if dpkg-statoverride --list "$dbc_basepath" >/dev/null; then
+		line=`dpkg-statoverride --list "$dbc_basepath"`
+		c_owner=`echo $line | cut -d' ' -f1,2 | tr ' ' ':'`
+		c_perms=`echo $line | cut -d' ' -f3`
+	fi
+}
+
 ##
 ## execute a file with sqlite commands
 ##
@@ -86,7 +95,22 @@
 		dbc_status=nothing
 	else
 		ret=0
-		mkdir -p "${dbc_basepath}"
+		if [ ! -d "${dbc_basepath}" ]; then
+			# Create the base directory
+			mkdir -p "${dbc_basepath}"
+		fi
+		# Setup permissions on the base directory to match dbfile
+		check_basepath_permissions
+		# Don't set permissions if admin has overriden them
+		if [ ! -n "$c_owner" ]; then
+			chown "$l_owner" "$dbc_basepath"
+		fi
+		if [ ! -n "$c_perms" ]; then 
+			chmod "$l_perms" "$dbc_basepath"
+			# Always set execute bits on directories
+			chmod u+x,g+x "$dbc_basepath"
+		fi
+		# Create the database and setup permissions
 		dbc_sqlite_exec_command ".schema" && \
 		chown "$l_owner" "$l_dbfile" && \
 		chmod "$l_perms" "$l_dbfile" || ret=$?




More information about the Dbconfig-common-changes mailing list