1 |
slords |
1.1 |
diff -up e-smith-ibays-2.2.0/root/etc/e-smith/events/actions/ibay-delete.better-ldap e-smith-ibays-2.2.0/root/etc/e-smith/events/actions/ibay-delete |
2 |
|
|
--- e-smith-ibays-2.2.0/root/etc/e-smith/events/actions/ibay-delete.better-ldap 2010-11-02 13:37:55.000000000 -0600 |
3 |
|
|
+++ e-smith-ibays-2.2.0/root/etc/e-smith/events/actions/ibay-delete 2010-11-02 13:38:04.000000000 -0600 |
4 |
|
|
@@ -25,6 +25,7 @@ |
5 |
|
|
|
6 |
|
|
event=$1 |
7 |
|
|
ibay=$2 |
8 |
|
|
+ |
9 |
|
|
if [ -z "$ibay" ] |
10 |
|
|
then |
11 |
|
|
echo ibayName argument missing |
12 |
slords |
1.2 |
@@ -32,12 +33,17 @@ |
13 |
slords |
1.1 |
fi |
14 |
|
|
|
15 |
|
|
ldapauth=$(/sbin/e-smith/config getprop ldap Authentication || echo disabled) |
16 |
|
|
+x=0 # exit value |
17 |
|
|
|
18 |
|
|
/bin/rm -rf /home/e-smith/files/ibays/$ibay |
19 |
|
|
-if [ "$ldapauth" == "enabled" ] |
20 |
|
|
+if [ "$ldapauth" != "enabled" ] |
21 |
|
|
then |
22 |
slords |
1.2 |
+ /usr/sbin/userdel "$ibay" || x=1 |
23 |
|
|
/usr/sbin/cpu userdel "$ibay" |
24 |
|
|
/usr/sbin/cpu -C/etc/cpu-system.conf groupdel "$ibay" |
25 |
|
|
else |
26 |
slords |
1.1 |
- exec /usr/sbin/userdel "$ibay" |
27 |
slords |
1.2 |
+ /usr/sbin/cpu userdel "$ibay" || x=1 |
28 |
|
|
+ /usr/sbin/cpu -C/etc/cpu-system.conf groupdel "$ibay" || x=1 |
29 |
slords |
1.1 |
fi |
30 |
|
|
+ |
31 |
|
|
+exit $x |
32 |
|
|
diff -up e-smith-ibays-2.2.0/root/etc/e-smith/events/actions/ibay-modify.better-ldap e-smith-ibays-2.2.0/root/etc/e-smith/events/actions/ibay-modify |
33 |
|
|
--- e-smith-ibays-2.2.0/root/etc/e-smith/events/actions/ibay-modify.better-ldap 2010-11-02 13:37:55.000000000 -0600 |
34 |
|
|
+++ e-smith-ibays-2.2.0/root/etc/e-smith/events/actions/ibay-modify 2010-11-02 13:38:56.000000000 -0600 |
35 |
|
|
@@ -32,6 +32,7 @@ my $conf = esmith::ConfigDB->open_ro |
36 |
|
|
or die "Could not open Config DB"; |
37 |
|
|
|
38 |
|
|
my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled'; |
39 |
|
|
+my $x = 0; # exit value |
40 |
|
|
|
41 |
|
|
$ENV{'PATH'} = "/bin"; |
42 |
|
|
|
43 |
|
|
@@ -55,41 +56,14 @@ if ($event eq 'ibay-create') |
44 |
|
|
|
45 |
|
|
# Create the ibay's unique group first |
46 |
|
|
|
47 |
|
|
- if ($ldapauth eq 'enabled') |
48 |
|
|
- { |
49 |
|
|
- system( |
50 |
|
|
- "/usr/sbin/cpu", "-C/etc/cpu-system.conf", "groupadd", |
51 |
|
|
- "-g", |
52 |
|
|
- $ibay->prop("Gid"), |
53 |
|
|
- $ibayName |
54 |
|
|
- ) == 0 or die "Failed to create group $ibayName.\n"; |
55 |
|
|
- |
56 |
|
|
- system( |
57 |
|
|
- "/usr/sbin/cpu", "useradd", |
58 |
|
|
- "-u", |
59 |
|
|
- $ibay->prop("Uid"), |
60 |
|
|
- "-g", |
61 |
|
|
- $ibay->prop("Gid"), |
62 |
|
|
- "-c", |
63 |
|
|
- $ibay->prop("Name"), |
64 |
|
|
- "-d", |
65 |
|
|
- "/home/e-smith/files/ibays/$ibayName/files", |
66 |
|
|
- "-G", |
67 |
|
|
- "shared," |
68 |
|
|
- . $ibay->prop("Group"), |
69 |
|
|
- "-s", |
70 |
|
|
- "/bin/false", |
71 |
|
|
- "$ibayName" |
72 |
|
|
- ) == 0 or die "Failed to create account $ibayName.\n"; |
73 |
|
|
- } |
74 |
|
|
- else |
75 |
|
|
+ if ($ldapauth ne 'enabled') |
76 |
|
|
{ |
77 |
|
|
system( |
78 |
|
|
"/usr/sbin/groupadd", |
79 |
|
|
"-g", |
80 |
|
|
$ibay->prop("Gid"), |
81 |
|
|
$ibayName |
82 |
|
|
- ) == 0 or die "Failed to create group $ibayName.\n"; |
83 |
|
|
+ ) == 0 or ( $x = 255, warn "Failed to create (unix) group $ibayName.\n" ); |
84 |
|
|
|
85 |
|
|
system( |
86 |
|
|
"/usr/sbin/useradd", |
87 |
|
|
@@ -108,16 +82,41 @@ if ($event eq 'ibay-create') |
88 |
|
|
"-s", |
89 |
|
|
"/bin/false", |
90 |
|
|
"$ibayName" |
91 |
|
|
- ) == 0 or die "Failed to create account $ibayName.\n"; |
92 |
slords |
1.4 |
+ ) == 0 or ( $x = 255, warn "Failed to create (unix) account $ibayName.\n" ); |
93 |
slords |
1.1 |
} |
94 |
|
|
|
95 |
|
|
+ system( |
96 |
|
|
+ "/usr/sbin/cpu", "-C/etc/cpu-system.conf", "groupadd", |
97 |
|
|
+ "-g", |
98 |
|
|
+ $ibay->prop("Gid"), |
99 |
|
|
+ $ibayName |
100 |
slords |
1.3 |
+ ) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) group $ibayName.\n" ); |
101 |
slords |
1.1 |
+ |
102 |
|
|
+ system( |
103 |
|
|
+ "/usr/sbin/cpu", "useradd", |
104 |
|
|
+ "-u", |
105 |
|
|
+ $ibay->prop("Uid"), |
106 |
|
|
+ "-g", |
107 |
|
|
+ $ibay->prop("Gid"), |
108 |
|
|
+ "-c", |
109 |
|
|
+ $ibay->prop("Name"), |
110 |
|
|
+ "-d", |
111 |
|
|
+ "/home/e-smith/files/ibays/$ibayName/files", |
112 |
|
|
+ "-G", |
113 |
|
|
+ "shared," |
114 |
|
|
+ . $ibay->prop("Group"), |
115 |
|
|
+ "-s", |
116 |
|
|
+ "/bin/false", |
117 |
|
|
+ "$ibayName" |
118 |
slords |
1.3 |
+ ) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) account $ibayName.\n" ); |
119 |
slords |
1.1 |
+ |
120 |
|
|
#------------------------------------------------------------ |
121 |
|
|
# Create the ibay files and set the password. |
122 |
|
|
#------------------------------------------------------------ |
123 |
|
|
|
124 |
|
|
system("/bin/cp", "-Rp", "/etc/e-smith/skel/ibay", |
125 |
|
|
"/home/e-smith/files/ibays/$ibayName") == 0 |
126 |
|
|
- or die "Error copying ibay skeletal files"; |
127 |
|
|
+ or ( $x = 255, warn "Error copying ibay skeletal files" ); |
128 |
|
|
|
129 |
|
|
processTemplate( { |
130 |
|
|
TEMPLATE_PATH=>"/home/e-smith/files/ibays/html/index.html", |
131 |
|
|
@@ -125,16 +124,14 @@ if ($event eq 'ibay-create') |
132 |
|
|
MORE_DATA=>{IBAY_NAME=>$ibayName}, |
133 |
|
|
} ); |
134 |
|
|
|
135 |
|
|
- if ($ldapauth eq 'enabled') |
136 |
|
|
- { |
137 |
|
|
- system("/usr/sbin/cpu", "usermod", "-L", $ibayName) == 0 |
138 |
|
|
- or die "Error running /usr/sbin/cpu usermod -L command to lock account $ibayName"; |
139 |
|
|
- } |
140 |
|
|
- else |
141 |
|
|
+ if ($ldapauth ne 'enabled') |
142 |
|
|
{ |
143 |
|
|
system("/usr/bin/passwd", "-l", $ibayName) == 0 |
144 |
|
|
- or die "Error running /usr/bin/passwd command to lock account $ibayName"; |
145 |
|
|
+ or ( $x = 255, warn "Error locking (unix) account $ibayName" ); |
146 |
|
|
} |
147 |
|
|
+ |
148 |
|
|
+ system("/usr/sbin/cpu", "usermod", "-L", $ibayName) == 0 |
149 |
slords |
1.3 |
+ or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Error locking (ldap) account $ibayName" ); |
150 |
slords |
1.1 |
} |
151 |
|
|
elsif ($event eq 'ibay-modify') |
152 |
|
|
{ |
153 |
|
|
@@ -142,19 +139,16 @@ elsif ($event eq 'ibay-modify') |
154 |
|
|
# Modify ibay description in /etc/passwd using "usermod" |
155 |
|
|
#------------------------------------------------------------ |
156 |
|
|
|
157 |
|
|
- if ($ldapauth eq 'enabled') |
158 |
|
|
- { |
159 |
|
|
- system("/usr/sbin/cpu", "usermod", "-c", $ibay->prop("Name"), |
160 |
|
|
- "-G", "shared," . $ibay->prop("Group"), "$ibayName") == 0 |
161 |
|
|
- or die "Failed to modify account $ibayName.\n"; |
162 |
|
|
- } |
163 |
|
|
- else |
164 |
|
|
+ if ($ldapauth ne 'enabled') |
165 |
|
|
{ |
166 |
|
|
system("/usr/sbin/usermod", "-c", $ibay->prop("Name"), |
167 |
|
|
"-G", "shared," . $ibay->prop("Group"), "$ibayName") == 0 |
168 |
|
|
- or die "Failed to modify account $ibayName.\n"; |
169 |
|
|
+ or ( $x = 255, warn "Failed to modify (unix) account $ibayName.\n" ); |
170 |
|
|
} |
171 |
|
|
|
172 |
|
|
+ system("/usr/sbin/cpu", "usermod", "-c", $ibay->prop("Name"), |
173 |
|
|
+ "-G", "shared," . $ibay->prop("Group"), "$ibayName") == 0 |
174 |
slords |
1.3 |
+ or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify (ldap) account $ibayName.\n" ); |
175 |
slords |
1.1 |
} |
176 |
|
|
|
177 |
|
|
#------------------------------------------------------------ |
178 |
|
|
@@ -166,7 +160,7 @@ elsif ($event eq 'ibay-modify') |
179 |
|
|
#-------------------------------------------------- |
180 |
|
|
|
181 |
|
|
chdir "/home/e-smith/files/ibays/$ibayName" |
182 |
|
|
- or die "Could not chdir to /home/e-smith/files/ibays/$ibayName"; |
183 |
|
|
+ or ( $x = 255, warn "Could not chdir to /home/e-smith/files/ibays/$ibayName" ); |
184 |
|
|
|
185 |
|
|
mkdir '.AppleDesktop' unless (-d '.AppleDesktop'); |
186 |
|
|
|
187 |
|
|
@@ -237,3 +231,5 @@ sub process |
188 |
|
|
} |
189 |
|
|
|
190 |
|
|
find(\&process, glob("* .AppleDesktop")); |
191 |
|
|
+ |
192 |
|
|
+exit ($x); |