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 --- 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 +++ e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-create-unix 2010-11-04 19:17:55.000000000 -0600 @@ -27,6 +27,7 @@ use strict; use Errno; use esmith::ConfigDB; use esmith::AccountsDB; +use File::Temp; my $conf = esmith::ConfigDB->open_ro or die "Could not open Config DB"; @@ -36,6 +37,10 @@ my $accounts = esmith::AccountsDB->open my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled'; my $x = 0; # exit value +my $domain = $conf->get('DomainName') + || die("Couldn't determine domain name"); +$domain = $domain->value; + my $event = $ARGV [0]; my $groupName = $ARGV [1]; @@ -93,11 +98,17 @@ if ($ldapauth ne 'enabled') } # Create the user's unique group first (in ldap) +my $tmpattr = File::Temp->new(); +print $tmpattr "mail: $groupName\@$domain\n"; +print $tmpattr "description: $description\n"; +$tmpattr->flush(); system( "/usr/sbin/cpu", "groupadd", + "-a", "$tmpattr", "-g", $gid, $groupName ) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) group $groupName.\n" ); +undef $tmpattr; # Now create the dummy user account (in ldap) system( 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 --- 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 +++ e-smith-base-5.2.0/root/etc/e-smith/events/actions/group-modify-unix 2010-11-04 19:17:55.000000000 -0600 @@ -27,6 +27,7 @@ use strict; use Errno; use esmith::ConfigDB; use esmith::AccountsDB; +use File::Temp; my $c = esmith::ConfigDB->open_ro || die "Couldn't open config db\n"; my $a = esmith::AccountsDB->open_ro || die "Couldn't open accounts db\n"; @@ -34,6 +35,10 @@ my $a = esmith::AccountsDB->open_ro || d my $ldapauth = $c->get('ldap')->prop('Authentication') || 'disabled'; my $x = 0; # exit value +my $domain = $c->get('DomainName') + || die("Couldn't determine domain name"); +$domain = $domain->value; + my $event = shift || die "Event name arg missing\n";; my @groups; @@ -76,6 +81,17 @@ foreach my $group (@groups) system("/usr/sbin/cpu", "-C/etc/cpu-system.conf", "usermod", "-c", "$groupDesc", "$groupName") == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify (ldap) group description for $groupName.\n" ); + my $tmpattr = File::Temp->new(); + print $tmpattr "mail: $groupName\@$domain\n"; + print $tmpattr "description: $groupDesc\n"; + $tmpattr->flush(); + system( + "/usr/sbin/cpu", "-C/etc/cpu-system.conf", "groupmod", + "-a", "$tmpattr", + "$groupName" + ) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify (ldap) group description/email for $groupName.\n" ); + undef $tmpattr; + my ($name, $passwd, $gid, $members) = getgrnam ($groupName); my @oldMembers = split (/\s+/, $members); my @newMembers = split (/,/, $properties {'Members'}); 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 --- 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 +++ e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-create-unix 2010-11-04 19:35:47.000000000 -0600 @@ -27,6 +27,7 @@ use strict; use Errno; use esmith::ConfigDB; use esmith::AccountsDB; +use File::Temp; my $conf = esmith::ConfigDB->open_ro; my $accounts = esmith::AccountsDB->open; @@ -34,6 +35,10 @@ my $accounts = esmith::AccountsDB->open; my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled'; my $x = 0; # exit value +my $domain = $conf->get('DomainName') + || die("Couldn't determine domain name"); +$domain = $domain->value; + my $event = $ARGV [0]; my $userName = $ARGV [1]; @@ -62,9 +67,13 @@ unless ($uid = $acct->prop('Uid')) my $gid = $acct->prop('Gid') || $uid; my $first = $acct->prop('FirstName') || ''; my $last = $acct->prop('LastName') || ''; +my $phone = $acct->prop('Phone') || ''; +my $company = $acct->prop('Company') || ''; +my $dept = $acct->prop('Dept') || ''; +my $city = $acct->prop('City') || ''; +my $street = $acct->prop('Street') || ''; my $shell = $acct->prop('Shell') || '/usr/bin/rssh'; - if ($ldapauth ne 'enabled') { # Create the user's unique group first @@ -99,6 +108,15 @@ system( ) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) group $userName.\n" ); # Now create the user account (in ldap) +my @attrs; +my $tmpattr = File::Temp->new(); +print $tmpattr "telephoneNumber: $phone\n" if $phone; +print $tmpattr "o: $company\n" if $company; +print $tmpattr "ou: $dept\n" if $dept; +print $tmpattr "l: $city\n" if $city; +print $tmpattr "street: $street\n" if $street; +$tmpattr->flush(); +push @attrs, ('-a', "$tmpattr") if -s $tmpattr; system( "/usr/sbin/cpu", "useradd", "-u", $uid, @@ -106,6 +124,8 @@ system( "-c", "$first $last", "-f", "$first", "-E", "$last", + "-e", "$userName\@$domain", + @attrs, "-d", "/home/e-smith/files/users/$userName", "-G", "shared", "-m", @@ -113,6 +133,7 @@ system( "-s", "$shell", $userName ) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) account $userName.\n" ); +undef $tmpattr; # Release lock if we have one 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 --- 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 +++ e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-modify-unix 2010-11-04 19:17:55.000000000 -0600 @@ -22,12 +22,17 @@ use strict; use Errno; use esmith::AccountsDB; use esmith::ConfigDB; +use File::Temp; my $conf = esmith::ConfigDB->open or die "Could not open configuration db"; my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled'; my $x = 0; # exit value +my $domain = $conf->get('DomainName') + || die("Couldn't determine domain name"); +$domain = $domain->value; + my $event = $ARGV [0]; my $userName = $ARGV [1]; @@ -115,9 +120,28 @@ foreach my $u (@users) or ( $x = 255, warn "Failed to modify comment of (unix) account $userName.\n" ); } - system("/usr/sbin/cpu", "usermod", "-c", "$first $last", "-G", "$groups", $userName) == 0 - or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify comment of (ldap) account $userName.\n" ); + system("/usr/sbin/cpu", "usermod", "-c", "$first $last", "-f", "$first", "-E", "$last", "-G", "$groups", $userName) == 0 + or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify comment/name of (ldap) account $userName.\n" ); } + + my $new_phone = $u->prop('Phone') || ''; + my $new_company = $u->prop('Company') || ''; + my $new_dept = $u->prop('Dept') || ''; + my $new_city = $u->prop('City') || ''; + my $new_street = $u->prop('Street') || ''; + + my @attrs; + my $tmpattr = File::Temp->new(); + print $tmpattr "telephoneNumber: $new_phone\n" if $new_phone; + print $tmpattr "o: $new_company\n" if $new_company; + print $tmpattr "ou: $new_dept\n" if $new_dept; + print $tmpattr "l: $new_city\n" if $new_city; + print $tmpattr "street: $new_street\n" if $new_street; + $tmpattr->flush(); + push @attrs, ('-a', "$tmpattr") if -s $tmpattr; + system("/usr/sbin/cpu", "usermod", @attrs, "-e", "$userName\@$domain", "-G", "$groups", $userName) == 0 + or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify email of (ldap) account $userName.\n" ); + undef $tmpattr; } exit ($x);