[gdm] data: change the way we do dconf



commit 25004e4d11bbd2e8a22d5bcf49f294e9f63d2ce5
Author: Ray Strode <rstrode redhat com>
Date:   Tue Oct 18 17:34:56 2011 -0400

    data: change the way we do dconf
    
    We currently generate a complete, binary dconf database
    as part of the install process.
    
    In general, system administrators can change dconf
    settings system-wide using a mechanism described here:
    
    https://live.gnome.org/dconf/SystemAdministrators
    
    Unfortunately, because of the way we generate our database,
    any administrator overrides will get discarded during
    package upgrade, and likewise, our carefully vetted database
    will get destroyed on any site administrator updates.
    
    Rather than step on each others toes, this commit changes
    GDM to use the same mechanism described above.  This should
    make upstream defaults and system defaults coexist much
    better.
    
    Note, the mechanism used isn't quite as featureful as we
    would really like.  It doesn't support wildcards or changing
    whole subtrees at a time.  That means, in theory, if a new
    plugin gets added to settings daemon it could be marked active
    at the login screen without being vetted first.
    
    To circumvent this, we add a layer of indirection in and some
    gross shell scripting to give us the features we need.
    
    Distributions should probably run
    
    /usr/libexec/gdm-update-dconf-db \
    	gdm \
    	/usr/share/gdm/upstream-settings \
    	00-upstream-settings
    
    In there post transaction hooks, but at a minimum need to run
    dconf update.

 autogen.sh                     |    5 -
 data/Makefile.am               |   28 ++++---
 data/gdm-update-dconf-db       |  167 ++++++++++++++++++++++++++++++++++++++++
 data/make-dconf-override-db.sh |   64 ---------------
 data/upstream-settings         |   40 ++++++++++
 5 files changed, 225 insertions(+), 79 deletions(-)
---
diff --git a/autogen.sh b/autogen.sh
index eb1894a..f857474 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -17,11 +17,6 @@ PKG_NAME="GDM"
     exit 1
 }
 
-(cd $srcdir/data/ ; ./make-dconf-override-db.sh) || {
-    echo "**Error**: Script "\`$srcdir/data/make-dconf-override-db.sh\'" failed"
-    exit 1
-}
-
 which gnome-autogen.sh || {
     echo "You need to install gnome-common from the GNOME SVN"
     exit 1
diff --git a/data/Makefile.am b/data/Makefile.am
index 3175436..c9b2d74 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -88,6 +88,12 @@ localealias_DATA = locale.alias
 sessiondir = $(datadir)/gnome-session/sessions
 session_DATA = gdm-fallback.session gdm-shell.session
 
+settingsdir = $(datadir)/gdm
+settings_DATA = $(srcdir)/upstream-settings
+
+dconfthingdir = $(libexecdir)
+dconfthing_SCRIPTS = $(srcdir)/gdm-update-dconf-db
+
 EXTRA_DIST =			\
 	$(schemas_in_files)	\
 	$(schemas_DATA)		\
@@ -107,8 +113,9 @@ EXTRA_DIST =			\
 	gconf.path		\
 	session-setup.entries	\
 	gdm-shell.session.in    \
-	make-dconf-override-db.sh \
+	gdm-update-dconf-db \
 	dconf-profile \
+	upstream-settings \
 	org.gnome.login-screen.gschema.xml.in \
 	$(NULL)
 
@@ -118,7 +125,6 @@ CLEANFILES = 				\
 	Init				\
 	PreSession			\
 	PostSession			\
-	dconf-override-db		\
 	$(gsettings_SCHEMAS)		\
 	$(NULL)
 
@@ -126,19 +132,18 @@ DISTCLEANFILES =			\
 	$(dbusconf_DATA)		\
 	gdm-shell.session		\
 	gdm.schemas			\
-	dconf-override-db		\
 	$(NULL)
 
 MAINTAINERCLEANFILES =			\
 	*~				\
-	dconf-override-db		\
 	Makefile.in
 
-dconf-override-db: $(srcdir)/make-dconf-override-db.sh
-	$(srcdir)/make-dconf-override-db.sh
+00-upstream-settings 00-upstream-settings-locks: $(srcdir)/gdm-update-dconf-db
+	$(srcdir)/gdm-update-dconf-db $(srcdir)/upstream-settings 00-upstream-settings
 
-dist-hook: $(srcdir)/dconf-override-db
-	cp $(srcdir)/dconf-override-db $(distdir)
+dist-hook:
+	cp $(srcdir)/00-upstream-settings $(distdir)
+	cp $(srcdir)/00-upstream-settings-locks $(distdir)
 
 uninstall-hook:
 	rm -f \
@@ -155,6 +160,7 @@ uninstall-hook:
 	$(DESTDIR)$(sysconfdir)/dconf/db/gdm \
 	$(DESTDIR)$(sysconfdir)/dconf/profile/gdm \
 	-rf \
+	$(DESTDIR)$(sysconfdir)/dconf/db/gdm.d \
 	$(DESTDIR)$(workingdir)/.gconf.mandatory \
 	$(DESTDIR)$(workingdir)/.config/dconf \
 	$(DESTDIR)$(screenshotdir) \
@@ -166,7 +172,7 @@ uninstall-hook:
 	$(DESTDIR)$(sysconfdir)/dconf/db \
 	$(DESTDIR)$(sysconfdir)/dconf
 
-install-data-hook: gdm.conf-custom Xsession Init PostSession PreSession gconf.path dconf-override-db
+install-data-hook: gdm.conf-custom Xsession Init PostSession PreSession gconf.path 00-upstream-settings 00-upstream-settings-locks
 	if test '!' -d $(DESTDIR)$(gdmconfdir); then \
 		$(mkinstalldirs) $(DESTDIR)$(gdmconfdir); \
 		chmod 755 $(DESTDIR)$(gdmconfdir); \
@@ -310,5 +316,7 @@ install-data-hook: gdm.conf-custom Xsession Init PostSession PreSession gconf.pa
 	chmod 1750 $(DESTDIR)$(workingdir)/.gconf.mandatory
 	chmod 1640 $(DESTDIR)$(workingdir)/.gconf.mandatory/*.xml
 
-	$(INSTALL_DATA) $(srcdir)/dconf-override-db $(DESTDIR)$(sysconfdir)/dconf/db/gdm
 	$(INSTALL_DATA) $(srcdir)/dconf-profile $(DESTDIR)$(sysconfdir)/dconf/profile/gdm
+	$(INSTALL_DATA) $(srcdir)/00-upstream-settings $(DESTDIR)$(sysconfdir)/dconf/db/gdm.d
+	$(INSTALL_DATA) $(srcdir)/00-upstream-settings-locks $(DESTDIR)$(sysconfdir)/dconf/db/gdm.d/locks
+	dconf update || :
diff --git a/data/gdm-update-dconf-db b/data/gdm-update-dconf-db
new file mode 100755
index 0000000..9525794
--- /dev/null
+++ b/data/gdm-update-dconf-db
@@ -0,0 +1,167 @@
+#!/bin/bash
+DCONFDIR="/etc/dconf"
+set -e
+
+if [ $# -ne 2 ] && [ $# -ne 3 ]; then
+  echo "$0 [profile] input-filename output-name" > /dev/stderr
+  exit 1
+fi
+
+if [ $# -eq 3 ]; then
+    PROFILE="$1"
+    shift
+fi
+
+INPUT_FILENAME="$1"
+OUTPUT_NAME="$2"
+
+if [ -n $PROFILE ] && [ ! -e ${DCONFDIR}/profile/$PROFILE ]; then
+  echo "'$PROFILE' is not valid dconf profile" > /dev/stderr
+  exit 1
+fi
+
+eval `dbus-launch --sh-syntax`
+
+trap 'kill $DBUS_SESSION_BUS_PID' ERR
+
+declare -A ENTRIES
+declare -a UNMATCHED_LINES
+OLD_IFS="$IFS"
+IFS="
+"
+FILE=( $(cat "$INPUT_FILENAME") )
+IFS=$OLD_IFS
+
+for line in "${FILE[ ]}"
+do
+    echo "$line" | egrep -q '^#' && continue
+    SCHEMA_PATTERN=$(echo "$line" | awk '{ print $1 }')
+    KEY_PATTERN=$(echo "$line" | awk '{ print $2 }' | awk -F= '{print $1}')
+    VALUE=$(echo "$line" | awk '{ print $2 }' | awk -F= '{print $2}')
+    SCHEMAS=( $(gsettings list-schemas | egrep -x "$SCHEMA_PATTERN"; true ) )
+
+    [ "${#SCHEMAS}" -eq 0 ] && continue;
+
+    NUM_ENTRIES=0
+    IS_STRING=0
+    IS_BOOL=0
+    IS_NUMBER=0
+    case "${VALUE:0:1}" in
+       '"'|"'")
+       IS_STRING=1
+       ;;
+       t|T|f|F)
+       IS_BOOL=1
+       ;;
+       *)
+       IS_NUMBER=1
+       ;;
+    esac
+
+    for schema in "${SCHEMAS[ ]}"
+    do
+        KEYS=( $(gsettings list-keys "$schema" | egrep -x "$KEY_PATTERN"; true) )
+
+        for key in "${KEYS[ ]}"
+        do
+OLD_IFS="$IFS"
+IFS="
+"
+            KEY_TYPE=( $(gsettings range $schema $key) )
+IFS="$OLD_IFS"
+            if [ "${KEY_TYPE[0]}" = 'enum' ]; then
+                continue;
+            fi
+            TYPE="${KEY_TYPE[0]#type }"
+            case "$TYPE" in
+                b)
+                    if [ $IS_BOOL -eq 1 ]; then
+                        ENTRIES["$schema $key"]="$VALUE"
+                        NUM_ENTRIES=$(($NUM_ENTRIES + 1))
+                    fi
+                ;;
+                s|ay)
+                    if [ $IS_STRING -eq 1 ]; then
+                        ENTRIES["$schema $key"]="$VALUE"
+                        NUM_ENTRIES=$(($NUM_ENTRIES + 1))
+                    fi
+                ;;
+                i|u|q|d|t)
+                    if [ $IS_NUMBER -eq 1 ]; then
+                        ENTRIES["$schema $key"]="$VALUE"
+                        NUM_ENTRIES=$(($NUM_ENTRIES + 1))
+                    fi
+                ;;
+                *)
+                ;;
+            esac
+        done
+    done
+
+    if [ $NUM_ENTRIES -lt 1 ]; then
+        UNMATCHED_LINES[${#UNMATCHED_LINES[ ]}]="$line"
+    fi
+done
+
+OLD_IFS="$IFS"
+IFS="
+"
+ENTRY_KEYS=( $(for entry in "${!ENTRIES[ ]}"; do echo "$entry" ; done | sort ) )
+IFS="$OLD_IFS"
+
+TMPFILE="$(mktemp)"
+TMPLOCKFILE="$(mktemp)"
+
+cat << EOF > $TMPFILE
+# This file is auto-generated from a file called '$(basename $INPUT_FILENAME)'.
+#
+# Please don't modify this file directly. Instead create your own file next
+# to it with a higher numbered prefix.
+$(if [ "${#UNMATCHED_LINES[ ]}" -gt 0 ]; then
+    echo "#"
+    echo "# Note, the following lines could not be matched to any known"
+    echo "# settings:"
+    echo "#"
+    for line in "${UNMATCHED_LINES[ ]}"
+    do
+        echo "#      $line"
+    done
+    echo "#"
+fi)
+$(OLD_SCHEMA=""
+for entry in "${ENTRY_KEYS[ ]}"
+do
+    SCHEMA="$(echo $entry | awk '{print $1}')"
+    KEY="$(echo $entry | awk '{print $2}')"
+    VALUE="${ENTRIES[$entry]}"
+
+    if [ "$OLD_SCHEMA" != "$SCHEMA" ]; then
+        echo
+        echo "[$(echo $SCHEMA | sed 's \ @/@g')]"
+        OLD_SCHEMA="$SCHEMA"
+    fi
+    echo "$KEY=$VALUE"
+done)
+
+EOF
+
+for entry in "${ENTRY_KEYS[ ]}"
+do
+    SCHEMA="$(echo $entry | awk '{print $1}')"
+    KEY="$(echo $entry | awk '{print $2}')"
+    echo "/$(echo $SCHEMA | sed 's \ @/@g')/$KEY" >> $TMPLOCKFILE
+done
+
+if [ -n "${PROFILE}" ]; then
+    mkdir -p ${DCONFDIR}/db/${PROFILE}.d/locks
+    install -m 644 $TMPLOCKFILE ${DCONFDIR}/db/${PROFILE}.d/locks/${OUTPUT_NAME}-locks
+    install -m 644 $TMPFILE ${DCONFDIR}/db/${PROFILE}.d/${OUTPUT_NAME}
+    rm -f $TMPLOCKFILE $TMPFILE
+    dconf update
+else
+    chmod 644 $TMPLOCKFILE $TMPFILE
+    mv $TMPLOCKFILE ${OUTPUT_NAME}-locks
+    mv $TMPFILE ${OUTPUT_NAME}
+fi
+
+kill $DBUS_SESSION_BUS_PID
diff --git a/data/upstream-settings b/data/upstream-settings
new file mode 100644
index 0000000..623f80d
--- /dev/null
+++ b/data/upstream-settings
@@ -0,0 +1,40 @@
+# Accessibility
+org.gnome.desktop.a11y.keyboard enable=true
+org.gnome.desktop.interface toolkit-accessibility=true
+org.gnome.desktop.sound event-sounds=true
+
+# Session (needs to be gdm-shell or gdm-fallback)
+org.gnome.desktop.session session-name='gdm-shell'
+
+# Lockdown
+org.gnome.desktop.default-applications.terminal exec='/bin/true'
+org.gnome.desktop.lockdown .*=true
+org.gnome.desktop.lockdown disable-log-out=false
+org.gnome.settings-daemon.plugins.media-keys eject=''
+org.gnome.settings-daemon.plugins.media-keys calculator=''
+org.gnome.settings-daemon.plugins.media-keys email=''
+org.gnome.settings-daemon.plugins.media-keys help=''
+org.gnome.settings-daemon.plugins.media-keys home=''
+org.gnome.settings-daemon.plugins.media-keys media=''
+org.gnome.settings-daemon.plugins.media-keys next=''
+org.gnome.settings-daemon.plugins.media-keys pause=''
+org.gnome.settings-daemon.plugins.media-keys play=''
+org.gnome.settings-daemon.plugins.media-keys previous=''
+org.gnome.settings-daemon.plugins.media-keys screensaver=''
+org.gnome.settings-daemon.plugins.media-keys search=''
+org.gnome.settings-daemon.plugins.media-keys stop=''
+org.gnome.settings-daemon.plugins.media-keys www=''
+org.gnome.settings-daemon.plugins..* active=false
+org.gnome.settings-daemon.plugins.a11y-keyboard active=true
+org.gnome.settings-daemon.plugins.background active=true
+org.gnome.settings-daemon.plugins.cursor active=true
+org.gnome.settings-daemon.plugins.media-keys active=true
+org.gnome.settings-daemon.plugins.orientation active=true
+org.gnome.settings-daemon.plugins.power active=true
+org.gnome.settings-daemon.plugins.sound active=true
+org.gnome.settings-daemon.plugins.xrandr active=true
+org.gnome.settings-daemon.plugins.xsettings active=true
+
+# Legacy
+org.gnome.desktop.background show-desktop-icons=false
+org.gnome.power-manager show-actions=false



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]