Changeset 1038
- Timestamp:
- 07/27/06 21:52:05 (2 years ago)
- Files:
-
- trunk/starting-and-stopping-dbus-with-kdm.txt (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/starting-and-stopping-dbus-with-kdm.txt
r1017 r1038 1 1 AUTHOR: Stef Bon <stef at bononline dot nl> 2 2 3 DATE: 2006-0 1-163 DATE: 2006-07-18 4 4 5 5 LICENSE: GNU Free Documentation License Version 1.2 … … 46 46 47 47 The construction with kdm I'm using here is ideal for this. One script in the startup directory to 48 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. 48 start the sessiondaemon for a user, running with the privileges of that user, and one in the reset 49 directory an other script has to stop that daemon. 49 50 50 51 But is not so simple as that. Some variables (DBUS_SESSION_BUS_ADDRESS and DBUS_SESSION_BUS_PID) have to … … 65 66 Bash is also started by "kdm", and the files /etc/profile and ~/.bash_profile are sourced. 66 67 67 How should the dbus environmentvariables should be made available, or where should the file containing 68 the dbusvariables be sourced? Let's call this file dbus-bash.sh. 69 70 The dbus-bash.sh can't go in the /etc/profile.d directory and the /etc/profile file, because it differs for every user. 71 It should go in the ~/.bash_profile file, by appending or something simular. That is not only 72 complicated at startup, but also at reset. Then it has to be removed again. 73 74 There is no other place in BLFS/LFS at this moment to put this file. 75 That's why I suggest the creating of a new directory (~/.profile.d) containing files which are 76 sourced when a BASH session is starts for that user. 77 These files are exactly equivalent to those in /etc/profile.d, but contain variables that are not the same 78 for every user. 79 80 81 global user 82 ------------------------------ 83 84 /etc/bashrc ~/.bashrc 85 /etc/profile ~/.bash_profile 86 /etc/profile.d ~/.profile.d 87 88 89 By adding the following code to the $HOME/.bash_profile at the end of it any script with the .sh extension 90 will be sourced for this user only: 91 92 -- snip -- 93 94 for script in $HOME/.profile.d/*.sh ; do 95 if [ -x $script ]; then 96 . $script 97 fi 98 done 99 100 -- snip -- 101 102 Now create as a user in his/her homedirectory: 103 104 mkdir $HOME/.profile.d 105 68 My idea is to store the output of the command 69 70 dbus-launch --auto-syntax 71 72 in the file 73 74 $HOME/.dbus-session 75 76 This file is "sourced" when bash start. This happens not automatically, but you will have to add the following script to /etc/profile.d : 77 78 cat >> dbus-session.sh << "EOF" 79 80 if [ -f $HOME/.dbus-session ]; then 81 82 . $HOME/.dbus-session 83 84 fi; 85 EOF 86 87 This way, the environment variables are made available when Bash starts. 106 88 107 89 … … 124 106 125 107 userid=$1 126 userproperties=$(getent passwd | grep - E "^$userid")108 userproperties=$(getent passwd | grep -m 1 -E "^$userid") 127 109 homedir=$(echo $userproperties | cut -d ":" -f 6); 128 110 gidnr=$(echo $userproperties | cut -d ":" -f 4); … … 130 112 131 113 132 if [ -d $homedir/.profile.d ]; then 133 114 if [ -d $homedir ]; then 115 116 # should there be a check dbus-launch is already running for this user? 117 134 118 if [ $(id -u) -eq 0 ]; then 135 sudo -u $userid -H /bin/sh -c "dbus-launch --auto-syntax > $homedir/. profile.d/dbus-bash.sh"119 sudo -u $userid -H /bin/sh -c "dbus-launch --auto-syntax > $homedir/.dbus-session" 136 120 retcode=$? 137 chown $uidnr:$gidnr $homedir/. profile.d/dbus-bash.sh138 chmod u+x $homedir/. profile.d/dbus-bash.sh121 chown $uidnr:$gidnr $homedir/.dbus-session 122 chmod u+x $homedir/.dbus-session 139 123 elif [ $(id -u) -eq $uidnr ]; then 140 dbus-launch --auto-syntax > $homedir/. profile.d/dbus-bash.sh124 dbus-launch --auto-syntax > $homedir/.dbus-session 141 125 retcode=$? 142 chmod u+x $homedir/. profile.d/dbus-bash.sh126 chmod u+x $homedir/.dbus-session 143 127 fi 144 128 … … 153 137 154 138 This script, executed by KDM at startup will start the dbus session daemon for this user, 155 and will create a dbus-bash.sh script in the .profile.d directory of this user containing139 and will create the .dbus-session file in the homedirectory of this user, containing 156 140 all the dbusvariables. 157 141 … … 160 144 As you can see, I've split the start of dbus up into two parts: 161 145 - dbus-kdm.sh, started when a (kdm)session starts, should be run once 162 - dbus-bash.sh, sourced when a (bash)session starts, could be sourced multiple times146 - .dbus-session, sourced when a (bash)session starts, could be sourced multiple times 163 147 164 148 Futher, I use the --auto-syntax parameter, where I assume Bash is used. So I could … … 187 171 188 172 userid=$1 189 userproperties=$(getent passwd | grep - E "^$userid")173 userproperties=$(getent passwd | grep -m 1 -E "^$userid") 190 174 homedir=$(echo $userproperties | cut -d ":" -f 6); 191 175 gidnr=$(echo $userproperties | cut -d ":" -f 4); 192 176 uidnr=$(echo $userproperties | cut -d ":" -f 3); 193 177 194 if [ -f $homedir/. profile.d/dbus-bash.sh]; then195 196 . $homedir/. profile.d/dbus-bash.sh178 if [ -f $homedir/.dbus-session ]; then 179 180 . $homedir/.dbus-session 197 181 198 182 if [ -n "$DBUS_SESSION_BUS_PID" ]; then … … 200 184 sudo -u $userid -H /bin/sh -c "kill $DBUS_SESSION_BUS_PID" 201 185 retcode=$? 202 rm $homedir/. profile.d/dbus-bash.sh186 rm $homedir/.dbus-session 203 187 elif [ $(id -u) -eq $uidnr ]; then 204 188 kill $DBUS_SESSION_BUS_PID 205 189 retcode=$? 206 rm $homedir/. profile.d/dbus-bash.sh190 rm $homedir/.dbus-session 207 191 fi 208 192 … … 223 207 224 208 225 1.4 Installation of Sudo 1.6.8p 7226 -------------------------------- 209 1.4 Installation of Sudo 1.6.8p12 210 --------------------------------- 227 211 228 212 With sudo it's possible to execute a script or command as a normal user, 229 being root. I use version 1.6.8p7. You can get a recent version from: 230 231 http://www.sudo.ws/sudo 232 233 Unpack and change to the source: 234 235 tar -xvzf sudo-1.6.8p7.tar.gz 236 cd sudo-1.6.8p7 237 238 ./configure --prefix=/usr --libexecdir=/usr/sbin --mandir=/usr/share/man --sysconfdir=/etc 239 make 240 make install 241 213 being root. 214 215 Since some time now sudo is in the BLFS book. Install it as described there. 242 216 Notes: 243 217 … … 246 220 If you want you can copy this to the usual directory in: 247 221 248 /usr/share/doc/sudo-1.6.8p 7222 /usr/share/doc/sudo-1.6.8p12 249 223 250 224 - Authentication can be done via PAM. This is not needed here, because the default … … 275 249 [2006-01-18] 276 250 * Initial hint. 251 [2006-07-18] 252 * Changed the bash scripts 253 * changed from sudo-1.6.8p7 to sudo-1.6.8p12 254
