1 |
slords |
1.1 |
diff -up e-smith-samba-2.2.0/root/etc/e-smith/events/actions/create-machine-account.better-ldap 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.better-ldap 2010-11-02 13:25:37.000000000 -0600 |
3 |
|
|
+++ e-smith-samba-2.2.0/root/etc/e-smith/events/actions/create-machine-account 2010-11-02 13:31:21.000000000 -0600 |
4 |
|
|
@@ -31,6 +31,8 @@ my $a = esmith::AccountsDB->open || die |
5 |
|
|
my $c = esmith::ConfigDB->open_ro || die "Could not open Config DB"; |
6 |
|
|
|
7 |
|
|
my $ldapauth = $c->get('ldap')->prop('Authentication') || 'disabled'; |
8 |
|
|
+my $x = 0; # exit value |
9 |
|
|
+ |
10 |
|
|
my $domain = $c->get('DomainName')->value(); |
11 |
|
|
my $base = esmith::util::ldapBase ($domain); |
12 |
|
|
|
13 |
|
|
@@ -60,27 +62,7 @@ esmith::util::setRealToEffective(); |
14 |
|
|
|
15 |
|
|
warn "create-machine-account $machineName: Creating Unix user and group\n"; |
16 |
|
|
|
17 |
|
|
-if ($ldapauth eq 'enabled') |
18 |
|
|
-{ |
19 |
|
|
- system( |
20 |
|
|
- "/usr/sbin/cpu", "-C/etc/cpu-system.conf", "useradd", |
21 |
|
|
- "--userbase=ou=Computers,$base", |
22 |
|
|
- "-c", "Hostname account for $machineName", |
23 |
|
|
- "-o", |
24 |
|
|
- "-d", "/noexistingpath", |
25 |
|
|
- "-s", "/bin/false", |
26 |
|
|
- "$machineName" |
27 |
|
|
- ) == 0 or die "Failed to create account $machineName.\n"; |
28 |
|
|
- |
29 |
|
|
- warn "create-machine-account $machineName: Locking account\n"; |
30 |
|
|
- |
31 |
|
|
- system("/usr/sbin/cpu", "-C/etc/cpu-system.conf", "usermod", |
32 |
|
|
- "--userbase=ou=Computers,$base", |
33 |
|
|
- "-o", |
34 |
|
|
- "-L", |
35 |
|
|
- "$machineName" |
36 |
|
|
- ) == 0 or warn("Could not lock password for $machineName\n"); |
37 |
|
|
-} |
38 |
|
|
+if ($ldapauth ne 'enabled') |
39 |
|
|
else |
40 |
|
|
{ |
41 |
|
|
system( |
42 |
|
|
@@ -90,20 +72,37 @@ else |
43 |
|
|
"-d", "/noexistingpath", |
44 |
|
|
"-s", "/bin/false", |
45 |
|
|
"$machineName" |
46 |
|
|
- ) == 0 or die "Failed to create account $machineName.\n"; |
47 |
|
|
- |
48 |
|
|
- warn "create-machine-account $machineName: Locking account\n"; |
49 |
|
|
+ ) == 0 or ( $x = 255, warn "Failed to create (unix) account $machineName.\n" ); |
50 |
|
|
|
51 |
|
|
system("/usr/bin/passwd", "-l", "$machineName") == 0 |
52 |
|
|
- or warn("Could not lock password for $machineName\n"); |
53 |
|
|
+ or ( $x = 255, warn "Failed locking (unix) password for $machineName\n" ); |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
+system( |
57 |
|
|
+ "/usr/sbin/cpu", "-C/etc/cpu-system.conf", "useradd", |
58 |
|
|
+ "--userbase=ou=Computers,$base", |
59 |
|
|
+ "-c", "Hostname account for $machineName", |
60 |
|
|
+ "-o", |
61 |
|
|
+ "-d", "/noexistingpath", |
62 |
|
|
+ "-s", "/bin/false", |
63 |
|
|
+ "$machineName" |
64 |
slords |
1.3 |
+ ) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) account $machineName.\n" ); |
65 |
slords |
1.1 |
+ |
66 |
|
|
+system("/usr/sbin/cpu", "-C/etc/cpu-system.conf", "usermod", |
67 |
|
|
+ "--userbase=ou=Computers,$base", |
68 |
|
|
+ "-o", |
69 |
|
|
+ "-L", |
70 |
|
|
+ "$machineName" |
71 |
slords |
1.3 |
+) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed locking (ldap) password for $machineName\n" ); |
72 |
slords |
1.1 |
+ |
73 |
|
|
+warn "create-machine-account $machineName: Locking account\n"; |
74 |
|
|
+ |
75 |
|
|
# warn "create-machine-account $machineName: Creating smbpasswd account\n"; |
76 |
|
|
# |
77 |
|
|
# Samba adds the smbpasswd account after it calls this script. |
78 |
|
|
# However, we may want to do this if we call this script directly |
79 |
|
|
# |
80 |
|
|
# system("/usr/bin/smbpasswd", "-a", "-m", "$machineName") == 0 |
81 |
|
|
-# or warn("Could not create smb password entry for $machineName\n");; |
82 |
|
|
+# or warn "Could not create smb password entry for $machineName\n"; |
83 |
|
|
|
84 |
|
|
-exit (0); |
85 |
|
|
+exit ($x); |