1 |
slords |
1.1 |
diff -up e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-create-unix.add-extra-ldap e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-create-unix |
2 |
slords |
1.3 |
--- e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-create-unix.add-extra-ldap 2010-11-04 19:17:44.000000000 -0600 |
3 |
|
|
+++ e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-create-unix 2010-11-04 19:17:55.000000000 -0600 |
4 |
slords |
1.1 |
@@ -27,6 +27,7 @@ use strict; |
5 |
|
|
use Errno; |
6 |
|
|
use esmith::ConfigDB; |
7 |
|
|
use esmith::AccountsDB; |
8 |
|
|
+use File::Temp; |
9 |
|
|
|
10 |
|
|
my $conf = esmith::ConfigDB->open_ro |
11 |
|
|
or die "Could not open Config DB"; |
12 |
|
|
@@ -36,6 +37,10 @@ my $accounts = esmith::AccountsDB->open |
13 |
|
|
my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled'; |
14 |
|
|
my $x = 0; # exit value |
15 |
|
|
|
16 |
|
|
+my $domain = $conf->get('DomainName') |
17 |
|
|
+ || die("Couldn't determine domain name"); |
18 |
|
|
+$domain = $domain->value; |
19 |
|
|
+ |
20 |
|
|
my $event = $ARGV [0]; |
21 |
|
|
my $groupName = $ARGV [1]; |
22 |
|
|
|
23 |
slords |
1.2 |
@@ -93,11 +98,17 @@ if ($ldapauth ne 'enabled') |
24 |
slords |
1.1 |
} |
25 |
|
|
|
26 |
|
|
# Create the user's unique group first (in ldap) |
27 |
|
|
+my $tmpattr = File::Temp->new(); |
28 |
|
|
+print $tmpattr "mail: $groupName\@$domain\n"; |
29 |
|
|
+print $tmpattr "description: $description\n"; |
30 |
slords |
1.2 |
+$tmpattr->flush(); |
31 |
slords |
1.1 |
system( |
32 |
|
|
"/usr/sbin/cpu", "groupadd", |
33 |
|
|
+ "-a", "$tmpattr", |
34 |
|
|
"-g", $gid, |
35 |
|
|
$groupName |
36 |
|
|
) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) group $groupName.\n" ); |
37 |
|
|
+undef $tmpattr; |
38 |
|
|
|
39 |
|
|
# Now create the dummy user account (in ldap) |
40 |
|
|
system( |
41 |
|
|
diff -up e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-modify-unix.add-extra-ldap e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-modify-unix |
42 |
slords |
1.3 |
--- e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-modify-unix.add-extra-ldap 2010-11-04 19:17:44.000000000 -0600 |
43 |
|
|
+++ e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-modify-unix 2010-11-04 19:17:55.000000000 -0600 |
44 |
slords |
1.1 |
@@ -27,6 +27,7 @@ use strict; |
45 |
|
|
use Errno; |
46 |
|
|
use esmith::ConfigDB; |
47 |
|
|
use esmith::AccountsDB; |
48 |
|
|
+use File::Temp; |
49 |
|
|
|
50 |
|
|
my $c = esmith::ConfigDB->open_ro || die "Couldn't open config db\n"; |
51 |
|
|
my $a = esmith::AccountsDB->open_ro || die "Couldn't open accounts db\n"; |
52 |
|
|
@@ -34,6 +35,10 @@ my $a = esmith::AccountsDB->open_ro || d |
53 |
|
|
my $ldapauth = $c->get('ldap')->prop('Authentication') || 'disabled'; |
54 |
|
|
my $x = 0; # exit value |
55 |
|
|
|
56 |
|
|
+my $domain = $c->get('DomainName') |
57 |
|
|
+ || die("Couldn't determine domain name"); |
58 |
|
|
+$domain = $domain->value; |
59 |
|
|
+ |
60 |
|
|
my $event = shift || die "Event name arg missing\n";; |
61 |
|
|
my @groups; |
62 |
|
|
|
63 |
slords |
1.2 |
@@ -76,6 +81,17 @@ foreach my $group (@groups) |
64 |
slords |
1.1 |
system("/usr/sbin/cpu", "-C/etc/cpu-system.conf", "usermod", "-c", "$groupDesc", "$groupName") == 0 |
65 |
|
|
or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify (ldap) group description for $groupName.\n" ); |
66 |
|
|
|
67 |
|
|
+ my $tmpattr = File::Temp->new(); |
68 |
|
|
+ print $tmpattr "mail: $groupName\@$domain\n"; |
69 |
|
|
+ print $tmpattr "description: $groupDesc\n"; |
70 |
slords |
1.2 |
+ $tmpattr->flush(); |
71 |
slords |
1.1 |
+ system( |
72 |
|
|
+ "/usr/sbin/cpu", "-C/etc/cpu-system.conf", "groupmod", |
73 |
|
|
+ "-a", "$tmpattr", |
74 |
|
|
+ "$groupName" |
75 |
|
|
+ ) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify (ldap) group description/email for $groupName.\n" ); |
76 |
|
|
+ undef $tmpattr; |
77 |
|
|
+ |
78 |
|
|
my ($name, $passwd, $gid, $members) = getgrnam ($groupName); |
79 |
|
|
my @oldMembers = split (/\s+/, $members); |
80 |
|
|
my @newMembers = split (/,/, $properties {'Members'}); |
81 |
|
|
diff -up e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-create-unix.add-extra-ldap e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-create-unix |
82 |
slords |
1.3 |
--- e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-create-unix.add-extra-ldap 2010-11-04 19:17:44.000000000 -0600 |
83 |
|
|
+++ e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-create-unix 2010-11-04 19:35:47.000000000 -0600 |
84 |
slords |
1.1 |
@@ -27,6 +27,7 @@ use strict; |
85 |
|
|
use Errno; |
86 |
|
|
use esmith::ConfigDB; |
87 |
|
|
use esmith::AccountsDB; |
88 |
|
|
+use File::Temp; |
89 |
|
|
|
90 |
|
|
my $conf = esmith::ConfigDB->open_ro; |
91 |
|
|
my $accounts = esmith::AccountsDB->open; |
92 |
|
|
@@ -34,6 +35,10 @@ my $accounts = esmith::AccountsDB->open; |
93 |
|
|
my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled'; |
94 |
|
|
my $x = 0; # exit value |
95 |
|
|
|
96 |
|
|
+my $domain = $conf->get('DomainName') |
97 |
|
|
+ || die("Couldn't determine domain name"); |
98 |
|
|
+$domain = $domain->value; |
99 |
|
|
+ |
100 |
|
|
my $event = $ARGV [0]; |
101 |
|
|
my $userName = $ARGV [1]; |
102 |
|
|
|
103 |
|
|
@@ -62,9 +67,13 @@ unless ($uid = $acct->prop('Uid')) |
104 |
|
|
my $gid = $acct->prop('Gid') || $uid; |
105 |
|
|
my $first = $acct->prop('FirstName') || ''; |
106 |
|
|
my $last = $acct->prop('LastName') || ''; |
107 |
|
|
+my $phone = $acct->prop('Phone') || ''; |
108 |
|
|
+my $company = $acct->prop('Company') || ''; |
109 |
slords |
1.2 |
+my $dept = $acct->prop('Dept') || ''; |
110 |
slords |
1.1 |
+my $city = $acct->prop('City') || ''; |
111 |
|
|
+my $street = $acct->prop('Street') || ''; |
112 |
|
|
my $shell = $acct->prop('Shell') || '/usr/bin/rssh'; |
113 |
|
|
|
114 |
|
|
- |
115 |
|
|
if ($ldapauth ne 'enabled') |
116 |
|
|
{ |
117 |
|
|
# Create the user's unique group first |
118 |
slords |
1.3 |
@@ -99,6 +108,15 @@ system( |
119 |
slords |
1.1 |
) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) group $userName.\n" ); |
120 |
|
|
|
121 |
|
|
# Now create the user account (in ldap) |
122 |
slords |
1.3 |
+my @attrs; |
123 |
slords |
1.1 |
+my $tmpattr = File::Temp->new(); |
124 |
slords |
1.3 |
+print $tmpattr "telephoneNumber: $phone\n" if $phone; |
125 |
|
|
+print $tmpattr "o: $company\n" if $company; |
126 |
|
|
+print $tmpattr "ou: $dept\n" if $dept; |
127 |
|
|
+print $tmpattr "l: $city\n" if $city; |
128 |
|
|
+print $tmpattr "street: $street\n" if $street; |
129 |
slords |
1.2 |
+$tmpattr->flush(); |
130 |
slords |
1.3 |
+push @attrs, ('-a', "$tmpattr") if -s $tmpattr; |
131 |
slords |
1.1 |
system( |
132 |
|
|
"/usr/sbin/cpu", "useradd", |
133 |
|
|
"-u", $uid, |
134 |
slords |
1.3 |
@@ -106,6 +124,8 @@ system( |
135 |
slords |
1.1 |
"-c", "$first $last", |
136 |
|
|
"-f", "$first", |
137 |
|
|
"-E", "$last", |
138 |
|
|
+ "-e", "$userName\@$domain", |
139 |
slords |
1.3 |
+ $attrs, |
140 |
slords |
1.1 |
"-d", "/home/e-smith/files/users/$userName", |
141 |
|
|
"-G", "shared", |
142 |
|
|
"-m", |
143 |
slords |
1.3 |
@@ -113,6 +133,7 @@ system( |
144 |
slords |
1.1 |
"-s", "$shell", |
145 |
|
|
$userName |
146 |
|
|
) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) account $userName.\n" ); |
147 |
|
|
+undef $tmpattr; |
148 |
|
|
|
149 |
|
|
|
150 |
|
|
# Release lock if we have one |
151 |
|
|
diff -up e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-modify-unix.add-extra-ldap e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-modify-unix |
152 |
slords |
1.3 |
--- e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-modify-unix.add-extra-ldap 2010-11-04 19:17:44.000000000 -0600 |
153 |
|
|
+++ e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-modify-unix 2010-11-04 19:17:55.000000000 -0600 |
154 |
slords |
1.1 |
@@ -22,12 +22,17 @@ use strict; |
155 |
|
|
use Errno; |
156 |
|
|
use esmith::AccountsDB; |
157 |
|
|
use esmith::ConfigDB; |
158 |
|
|
+use File::Temp; |
159 |
|
|
|
160 |
|
|
my $conf = esmith::ConfigDB->open or die "Could not open configuration db"; |
161 |
|
|
|
162 |
|
|
my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled'; |
163 |
|
|
my $x = 0; # exit value |
164 |
|
|
|
165 |
|
|
+my $domain = $conf->get('DomainName') |
166 |
|
|
+ || die("Couldn't determine domain name"); |
167 |
|
|
+$domain = $domain->value; |
168 |
|
|
+ |
169 |
|
|
my $event = $ARGV [0]; |
170 |
|
|
my $userName = $ARGV [1]; |
171 |
|
|
|
172 |
slords |
1.2 |
@@ -115,9 +120,28 @@ foreach my $u (@users) |
173 |
slords |
1.1 |
or ( $x = 255, warn "Failed to modify comment of (unix) account $userName.\n" ); |
174 |
|
|
} |
175 |
|
|
|
176 |
|
|
- system("/usr/sbin/cpu", "usermod", "-c", "$first $last", "-G", "$groups", $userName) == 0 |
177 |
|
|
- or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify comment of (ldap) account $userName.\n" ); |
178 |
|
|
+ system("/usr/sbin/cpu", "usermod", "-c", "$first $last", "-f", "$first", "-E", "$last", "-G", "$groups", $userName) == 0 |
179 |
|
|
+ or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify comment/name of (ldap) account $userName.\n" ); |
180 |
|
|
} |
181 |
|
|
+ |
182 |
|
|
+ my $new_phone = $u->prop('Phone') || ''; |
183 |
|
|
+ my $new_company = $u->prop('Company') || ''; |
184 |
slords |
1.2 |
+ my $new_dept = $u->prop('Dept') || ''; |
185 |
slords |
1.1 |
+ my $new_city = $u->prop('City') || ''; |
186 |
|
|
+ my $new_street = $u->prop('Street') || ''; |
187 |
|
|
+ |
188 |
slords |
1.2 |
+ my @attrs; |
189 |
slords |
1.1 |
+ my $tmpattr = File::Temp->new(); |
190 |
|
|
+ print $tmpattr "telephoneNumber: $new_phone\n" if $new_phone; |
191 |
|
|
+ print $tmpattr "o: $new_company\n" if $new_company; |
192 |
|
|
+ print $tmpattr "ou: $new_dept\n" if $new_dept; |
193 |
|
|
+ print $tmpattr "l: $new_city\n" if $new_city; |
194 |
slords |
1.2 |
+ print $tmpattr "street: $new_street\n" if $new_street; |
195 |
|
|
+ $tmpattr->flush(); |
196 |
|
|
+ push @attrs, ('-a', "$tmpattr") if -s $tmpattr; |
197 |
|
|
+ system("/usr/sbin/cpu", "usermod", @attrs, "-e", "$userName\@$domain", "-G", "$groups", $userName) == 0 |
198 |
slords |
1.1 |
+ or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify email of (ldap) account $userName.\n" ); |
199 |
|
|
+ undef $tmpattr; |
200 |
|
|
} |
201 |
|
|
|
202 |
|
|
exit ($x); |