| 44 | | |
|---|
| 45 | | Pam_script has the ability (from version 0.1.5) to get the password provided at login, and provide this via an evironmentvariable PAM_AUTHTOK to scripts. A script for fusesmb can write this value to the configurationfile of fusesmb (~/.smb/fusesmb.conf) to browse the network with the credentials provided at login. |
|---|
| 46 | | |
|---|
| 47 | | warning: |
|---|
| 48 | | |
|---|
| 49 | | This looks a little bit like Single Sign On, but it isn't!! The credentials are stored in |
|---|
| 50 | | a subdirectory of the homedir (~/.smb/fusesmb.conf), with enough security at runtime. |
|---|
| 51 | | But somebody can still find them being root, or with a LiveCD. The credentials are stored |
|---|
| 52 | | plaintext, no encryption!! |
|---|
| 53 | | |
|---|
| 54 | | So, this should never be used in an environment where you can't trust your users! |
|---|
| 55 | | |
|---|
| 206 | | ------------------------------------------------------ |
|---|
| 207 | | 1.4 Storing credentials in personal configurationfile. |
|---|
| 208 | | ------------------------------------------------------ |
|---|
| 209 | | |
|---|
| 210 | | With files above you could already get a working sollution. |
|---|
| 211 | | To access the SMB servers where a username and a password are |
|---|
| 212 | | required, FuseSMB allows you to give credentials in the |
|---|
| 213 | | ~/.smb/fusesmb.conf file. Look for these and more options |
|---|
| 214 | | in the manpage of fusesmb.conf. |
|---|
| 215 | | |
|---|
| 216 | | With PAM and the module pam_script it is possible to use the |
|---|
| 217 | | credentials provided at login. In my network the sambaservers |
|---|
| 218 | | use the same credentials as my normal login (via OPENLDAP). |
|---|
| 219 | | |
|---|
| 220 | | cat >> /etc/session.d/pam/onauth/fusesmb.sh << "EOF" |
|---|
| 221 | | #!/bin/bash |
|---|
| 222 | | |
|---|
| 223 | | retcode=0; |
|---|
| 224 | | |
|---|
| 225 | | userid=$1 |
|---|
| 226 | | service=$2 |
|---|
| 227 | | authtok=$3 |
|---|
| 228 | | |
|---|
| 229 | | userproperties=$(getent passwd | grep -E "^$userid") |
|---|
| 230 | | homedir=$(echo $userproperties | cut -d ":" -f 6); |
|---|
| 231 | | gidnr=$(echo $userproperties | cut -d ":" -f 4); |
|---|
| 232 | | uidnr=$(echo $userproperties | cut -d ":" -f 3); |
|---|
| 233 | | |
|---|
| 234 | | if [ -d $homedir ]; then |
|---|
| 235 | | |
|---|
| 236 | | |
|---|
| 237 | | if [ ! -d $homedir/.smb ]; then |
|---|
| 238 | | |
|---|
| 239 | | mkdir -p $homedir/.smb |
|---|
| 240 | | chown $uidnr:$gidnr $homedir/.smb |
|---|
| 241 | | chmod 755 $homedir/.smb |
|---|
| 242 | | |
|---|
| 243 | | fi |
|---|
| 244 | | |
|---|
| 245 | | if [ -n "$authtok" ]; then |
|---|
| 246 | | |
|---|
| 247 | | rm -f $homedir/.smb/fusesmb.conf |
|---|
| 248 | | |
|---|
| 249 | | touch $homedir/.smb/fusesmb.conf |
|---|
| 250 | | chown $uidnr:$gidnr $homedir/.smb/fusesmb.conf |
|---|
| 251 | | chmod 600 $homedir/.smb/fusesmb.conf |
|---|
| 252 | | |
|---|
| 253 | | echo "[global]" > $homedir/.smb/fusesmb.conf |
|---|
| 254 | | echo "username = $userid" >> $homedir/.smb/fusesmb.conf |
|---|
| 255 | | echo "password = $authtok" >> $homedir/.smb/fusesmb.conf |
|---|
| 256 | | |
|---|
| 257 | | fi; |
|---|
| 258 | | |
|---|
| 259 | | fi; |
|---|
| 260 | | |
|---|
| 261 | | |
|---|
| 262 | | if [ $retcode -ne 0 ]; then |
|---|
| 263 | | echo "An error with fusesmb ($retcode)." |
|---|
| 264 | | fi; |
|---|
| 265 | | |
|---|
| 266 | | exit $retcode |
|---|
| 267 | | EOF |
|---|
| 268 | | |
|---|
| 269 | | |
|---|
| 270 | | Notes: |
|---|
| 271 | | |
|---|
| 272 | | - The fusesmb script in the onauth directory overwrites any existing fusesmb.conf in the ~/.smb |
|---|
| 273 | | directory. I do not have any simple sollution to do otherwise. One way to do that is the use of |
|---|
| 274 | | a template. In this template the variables username and password get inserted with 'sed'. |
|---|
| 275 | | - this script is executed before(!) any script started by KDM. So when fusesmb starts, it reads |
|---|
| 276 | | this new configuration file. |
|---|