r1038 - trunk

archaic at linuxfromscratch.org archaic at linuxfromscratch.org
Thu Jul 27 20:52:06 PDT 2006


Author: archaic
Date: 2006-07-27 21:52:05 -0600 (Thu, 27 Jul 2006)
New Revision: 1038

Modified:
   trunk/starting-and-stopping-dbus-with-kdm.txt
Log:
Updated: starting-and-stopping-dbus-with-kdm.txt

Modified: trunk/starting-and-stopping-dbus-with-kdm.txt
===================================================================
--- trunk/starting-and-stopping-dbus-with-kdm.txt	2006-07-28 03:51:34 UTC (rev 1037)
+++ trunk/starting-and-stopping-dbus-with-kdm.txt	2006-07-28 03:52:05 UTC (rev 1038)
@@ -1,6 +1,6 @@
 AUTHOR: Stef Bon <stef at bononline dot nl>
 
-DATE: 2006-01-16
+DATE: 2006-07-18
 
 LICENSE: GNU Free Documentation License Version 1.2
 
@@ -45,7 +45,8 @@
 and stopped when the session ends.
 
 The construction with kdm I'm using here is ideal for this. One script in the startup directory to
-start the sessiondaemon for a user, running with the privileges of that user, and one in the reset directory an other script has to stop that daemon.
+start the sessiondaemon for a user, running with the privileges of that user, and one in the reset 
+directory an other script has to stop that daemon.
 
 But is not so simple as that. Some variables (DBUS_SESSION_BUS_ADDRESS and DBUS_SESSION_BUS_PID) have to 
 be available in the environment to every application which works with dbus. 
@@ -64,47 +65,28 @@
 When bash is started by "login" as an interactive login shell, it reads /etc/profile and ~/.bash_profile.
 Bash is also started by "kdm", and the files /etc/profile and ~/.bash_profile are sourced.
 
-How should the dbus environmentvariables should be made available, or where should the file containing
-the dbusvariables be sourced? Let's call this file dbus-bash.sh.
+My idea is to store the output of the command
 
-The dbus-bash.sh can't go in the /etc/profile.d directory and the /etc/profile file, because it differs for every user.
-It should go in the ~/.bash_profile file, by appending or something simular. That is not only 
-complicated at startup, but also at reset. Then it has to be removed again.
+dbus-launch --auto-syntax 
 
-There is no other place in BLFS/LFS at this moment to put this file.
-That's why I suggest the creating of a new directory (~/.profile.d) containing files which are 
-sourced when a BASH session is starts for that user.
-These files are exactly equivalent to those in /etc/profile.d, but contain variables that are not the same 
-for every user.
+in the file
 
+$HOME/.dbus-session
 
-                     global             user
-		 ------------------------------
+This file is "sourced" when bash start. This happens not automatically, but you will have to add the following script to /etc/profile.d :
 
-		 /etc/bashrc          ~/.bashrc
-		 /etc/profile         ~/.bash_profile
-		 /etc/profile.d       ~/.profile.d
+cat >> dbus-session.sh << "EOF"
 
+if [ -f $HOME/.dbus-session ]; then
 
-By adding the following code to the $HOME/.bash_profile at the end of it any script with the .sh extension
-will be sourced for this user only:
+	. $HOME/.dbus-session
 
--- snip --
+fi;
+EOF
 
-for script in $HOME/.profile.d/*.sh ; do
-        if [ -x $script ]; then
-                . $script
-        fi
-done
+This way, the environment variables are made available when Bash starts.
 
--- snip --
 
-Now create as a user in his/her homedirectory:
-
-mkdir $HOME/.profile.d
-
-
-
 1.2  Starting the sessionbus part of dbus
 -----------------------------------------
 
@@ -123,23 +105,25 @@
 retcode=0;
 
 userid=$1
-userproperties=$(getent passwd | grep -E "^$userid")
+userproperties=$(getent passwd | grep -m 1 -E "^$userid")
 homedir=$(echo $userproperties | cut -d ":" -f 6);
 gidnr=$(echo $userproperties | cut -d ":" -f 4);
 uidnr=$(echo $userproperties | cut -d ":" -f 3);
 
 
-if [ -d $homedir/.profile.d ]; then
+if [ -d $homedir ]; then
 	
+	# should there be a check dbus-launch is already running for this user?
+
 	if [ $(id -u) -eq 0 ]; then
- 	    sudo -u $userid -H /bin/sh -c "dbus-launch --auto-syntax > $homedir/.profile.d/dbus-bash.sh"
+ 	    sudo -u $userid -H /bin/sh -c "dbus-launch --auto-syntax > $homedir/.dbus-session"
 	    retcode=$?
-	    chown $uidnr:$gidnr $homedir/.profile.d/dbus-bash.sh
-	    chmod u+x $homedir/.profile.d/dbus-bash.sh
+	    chown $uidnr:$gidnr $homedir/.dbus-session
+	    chmod u+x $homedir/.dbus-session
 	elif [ $(id -u) -eq $uidnr ]; then 
-    	    dbus-launch --auto-syntax > $homedir/.profile.d/dbus-bash.sh
+    	    dbus-launch --auto-syntax > $homedir/.dbus-session
 	    retcode=$?
-	    chmod u+x $homedir/.profile.d/dbus-bash.sh
+	    chmod u+x $homedir/.dbus-session
 	fi
 
 fi;
@@ -152,14 +136,14 @@
 EOF
 
 This script, executed by KDM at startup will start the dbus session daemon for this user, 
-and will create a dbus-bash.sh script in the .profile.d directory of this user containing 
+and will create the .dbus-session file in the homedirectory of this user, containing
 all the dbusvariables.
 
 Now when bash starts at login, it reads (sources) this file.
 
 As you can see, I've split the start of dbus up into two parts:
 - dbus-kdm.sh, started when a (kdm)session starts, should be run once
-- dbus-bash.sh, sourced when a (bash)session starts, could be sourced multiple times
+- .dbus-session, sourced when a (bash)session starts, could be sourced multiple times
 
 Futher, I use the --auto-syntax parameter, where I assume Bash is used. So I could
 use here --sh-syntax, but it works.
@@ -186,24 +170,24 @@
 retcode=0;
 
 userid=$1
-userproperties=$(getent passwd | grep -E "^$userid")
+userproperties=$(getent passwd | grep -m 1 -E "^$userid")
 homedir=$(echo $userproperties | cut -d ":" -f 6);
 gidnr=$(echo $userproperties | cut -d ":" -f 4);
 uidnr=$(echo $userproperties | cut -d ":" -f 3);
 	
-if [ -f $homedir/.profile.d/dbus-bash.sh ]; then
+if [ -f $homedir/.dbus-session ]; then
 	
-	. $homedir/.profile.d/dbus-bash.sh
+	. $homedir/.dbus-session
 	
 	if [ -n "$DBUS_SESSION_BUS_PID" ]; then
 		if [ $(id -u) -eq 0 ]; then
 		    sudo -u $userid -H /bin/sh -c "kill $DBUS_SESSION_BUS_PID"
 		    retcode=$?
-		    rm $homedir/.profile.d/dbus-bash.sh
+		    rm $homedir/.dbus-session
 		elif [ $(id -u) -eq $uidnr ]; then
 		    kill $DBUS_SESSION_BUS_PID
 		    retcode=$?
-		    rm $homedir/.profile.d/dbus-bash.sh
+		    rm $homedir/.dbus-session
 		fi
 	
 	fi
@@ -222,30 +206,20 @@
 
 
 
-1.4 Installation of Sudo 1.6.8p7
---------------------------------
+1.4 Installation of Sudo 1.6.8p12
+---------------------------------
 
 With sudo it's possible to execute a script or command as a normal user,
-being root. I use version 1.6.8p7. You can get a recent version from:
+being root. 
 
-http://www.sudo.ws/sudo
-
-Unpack and change to the source:
-
-tar -xvzf sudo-1.6.8p7.tar.gz
-cd sudo-1.6.8p7
-
-./configure --prefix=/usr --libexecdir=/usr/sbin --mandir=/usr/share/man --sysconfdir=/etc
-make
-make install
-
+Since some time now sudo is in the BLFS book. Install it as described there.
 Notes:
 
 - documentation you'll find only in the basedirectory of the source:
 README, README.LDAP, PORTING, RUNSON, BUGS, INSTALL, CHANGES and so on.
 If you want you can copy this to the usual directory in:
 
-/usr/share/doc/sudo-1.6.8p7
+/usr/share/doc/sudo-1.6.8p12
 
 - Authentication can be done via PAM. This is not needed here, because the default
 behaviour of sudo allows root to run any script and command.
@@ -274,3 +248,7 @@
 CHANGELOG:
 [2006-01-18]
   * Initial hint.
+[2006-07-18]
+  * Changed the bash scripts
+  * changed from sudo-1.6.8p7 to sudo-1.6.8p12
+




More information about the hints mailing list