1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## localapps-edit-group-directly.dpatch by Vagrant Cascadian <vagrant@freegeek.org>
4
## All lines beginning with `## DP:' are a description of the patch.
6
## DP: edit /etc/group directly, as usermod relies on /etc/ being writeable,
7
## DP: and in the default Debian ltsp client environment /etc/ is a read-only
8
## DP: NFS mount and /etc/group is a bind-mounted writeable file.
11
diff -urNad ltsp-5.1.47~20090109~/localapps/ldm-rc.d/X01-localapps ltsp-5.1.47~20090109/localapps/ldm-rc.d/X01-localapps
12
--- ltsp-5.1.47~20090109~/localapps/ldm-rc.d/X01-localapps 2009-01-09 16:11:18.000000000 -0800
13
+++ ltsp-5.1.47~20090109/localapps/ldm-rc.d/X01-localapps 2009-01-09 16:13:31.000000000 -0800
16
# concatenate groups from different sources, stripping off prefixed and
18
- myGroups=$(echo ${myGroups},${myGroups1} | sed -e 's/^,//g' -e 's/,$//g')
19
+ myGroups=$(echo ${myGroups},${myGroups1} | tr ',' '\n' | sort -u | tr '\n' ',' | sed -e 's/^,//g' -e 's/,$//g')
21
if [ -n "$myGroups" ]; then
22
- usermod -G "$myGroups" "${LDM_USERNAME}" 2>/dev/null
25
+ cp /etc/group $TMPGROUP
26
+ for group in $myGroups ; do
27
+ # add user to each group manually
28
+ line="$(egrep ^${group}: $TMPGROUP | egrep -v [:,]${LDM_USERNAME}'(,|$)' )"
29
+ if [ -n "$line" ]; then
30
+ # add the user to the group
31
+ sed -i -e "s/^$line/$line,${LDM_USERNAME}/g" -e 's/:,/:/g' $TMPGROUP
34
+ cp $TMPGROUP /etc/group
36
+ test -n "$OLDIFS" && IFS="$OLDIFS"
39
# Now, let's mount the home directory