1 |
slords |
1.1 |
diff -up e-smith-samba-2.2.0/root/etc/e-smith/events/actions/create-machine-account.enable-cpu e-smith-samba-2.2.0/root/etc/e-smith/events/actions/create-machine-account |
2 |
|
|
--- e-smith-samba-2.2.0/root/etc/e-smith/events/actions/create-machine-account.enable-cpu 2005-04-19 08:19:17.000000000 -0600 |
3 |
|
|
+++ e-smith-samba-2.2.0/root/etc/e-smith/events/actions/create-machine-account 2010-11-01 11:57:31.000000000 -0600 |
4 |
|
|
@@ -28,6 +28,11 @@ use esmith::AccountsDB; |
5 |
|
|
use esmith::util; |
6 |
|
|
|
7 |
|
|
my $a = esmith::AccountsDB->open || die "Couldn't open accounts db\n"; |
8 |
|
|
+my $c = esmith::ConfigDB->open_ro || die "Could not open Config DB"; |
9 |
|
|
+ |
10 |
|
|
+my $ldapauth = $c->get('ldap')->prop('Authentication') || 'disabled'; |
11 |
|
|
+my $domain = $c->get('DomainName')->value(); |
12 |
|
|
+my $base = esmith::util::ldapBase ($domain); |
13 |
|
|
|
14 |
|
|
my $event = $ARGV [0]; |
15 |
|
|
my $machineName = $ARGV [1]; |
16 |
|
|
@@ -55,19 +60,43 @@ esmith::util::setRealToEffective(); |
17 |
|
|
|
18 |
|
|
warn "create-machine-account $machineName: Creating Unix user and group\n"; |
19 |
|
|
|
20 |
|
|
-system( |
21 |
|
|
- "/usr/sbin/useradd", |
22 |
|
|
- "-c", "Hostname account for $machineName", |
23 |
|
|
- "-M", |
24 |
|
|
- "-d", "/noexistingpath", |
25 |
|
|
- "-s", "/bin/false", |
26 |
|
|
- "$machineName" |
27 |
|
|
- ) == 0 or die "Failed to create account $machineName.\n"; |
28 |
slords |
1.2 |
+if ($ldapauth eq 'enabled') |
29 |
slords |
1.1 |
+{ |
30 |
|
|
+ system( |
31 |
|
|
+ "/usr/sbin/cpu", "-C/etc/cpu-system.conf", "useradd", |
32 |
vip-ire |
1.3 |
+ "--userbase=ou=Computers,$base", |
33 |
slords |
1.1 |
+ "-c", "Hostname account for $machineName", |
34 |
|
|
+ "-o", |
35 |
|
|
+ "-d", "/noexistingpath", |
36 |
|
|
+ "-s", "/bin/false", |
37 |
|
|
+ "$machineName" |
38 |
|
|
+ ) == 0 or die "Failed to create account $machineName.\n"; |
39 |
|
|
+ |
40 |
|
|
+ warn "create-machine-account $machineName: Locking account\n"; |
41 |
|
|
+ |
42 |
|
|
+ system("/usr/sbin/cpu", "-C/etc/cpu-system.conf", "usermod", |
43 |
vip-ire |
1.3 |
+ "--userbase=ou=Computers,$base", |
44 |
slords |
1.1 |
+ "-o", |
45 |
|
|
+ "-L", |
46 |
|
|
+ "$machineName" |
47 |
|
|
+ ) == 0 or warn("Could not lock password for $machineName\n"); |
48 |
|
|
+} |
49 |
|
|
+else |
50 |
|
|
+{ |
51 |
|
|
+ system( |
52 |
|
|
+ "/usr/sbin/useradd", |
53 |
|
|
+ "-c", "Hostname account for $machineName", |
54 |
|
|
+ "-M", |
55 |
|
|
+ "-d", "/noexistingpath", |
56 |
|
|
+ "-s", "/bin/false", |
57 |
|
|
+ "$machineName" |
58 |
|
|
+ ) == 0 or die "Failed to create account $machineName.\n"; |
59 |
|
|
|
60 |
|
|
-warn "create-machine-account $machineName: Locking account\n"; |
61 |
|
|
+ warn "create-machine-account $machineName: Locking account\n"; |
62 |
|
|
|
63 |
|
|
-system("/usr/bin/passwd", "-l", "$machineName") == 0 |
64 |
|
|
- or warn("Could not lock password for $machineName\n"); |
65 |
|
|
+ system("/usr/bin/passwd", "-l", "$machineName") == 0 |
66 |
|
|
+ or warn("Could not lock password for $machineName\n"); |
67 |
|
|
+} |
68 |
|
|
|
69 |
|
|
# warn "create-machine-account $machineName: Creating smbpasswd account\n"; |
70 |
|
|
# |