[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#718865: Update and minimize /etc/samba/smbldap-machineadd-gosa



I fetched version 0.9.5 of the smbldap-tools source, and ran diff
between smbldap-tools-0.9.5/smbldap-useradd and
smbldap-machineadd-gosa to see what was changed:

--- smbldap-tools-0.9.5/smbldap-useradd	2008-04-22 10:13:29.000000000 +0200
+++ smbldap-machineadd-gosa	2013-07-03 23:37:42.000000000 +0200
@@ -1,5 +1,17 @@
 #!/usr/bin/perl -w
 
+# This script has been taken von smbldap-tools 0.9.5, its original name
+# is smbldap-useradd. It has been modified so that machine accounts can 
+# be created and so that they will be compliant to the pre-requisites of 
+# GOsa as in Debian Edu squeeze.
+#
+# This script depends on package smbldap-tools (i.e. on its
+# smbldap_tool.pm).
+#
+# Modifcations have been done by several people, initially by
+#    Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
+#
+
 #  This code was developped by Jerome Tournier (jtournier@gmail.com) and
 #  contributors (their names can be found in the CONTRIBUTORS file).
 
@@ -34,8 +46,42 @@
 use Getopt::Std;
 my %Options;
 
+# success = add_posix_machine($user, $uid, $gid)
+sub add_posix_machine_gosa {
+    my ( $user, $uid, $gid, $wait ) = @_;
+    if ( !defined $wait ) {
+        $wait = 0;
+    }
+
+    # bind to a directory with dn and password
+    my $add = $smbldap_tools::ldap->add(
+        "uid=$user,$config{computersdn}",
+        attr => [
+
+            'objectclass' => ['top', 'person', 'organizationalPerson', 'inetOrgPerson', 'posixAccount', 'gotoWorkstation'],
+            #'objectclass' => [ 'top', 'account', 'posixAccount' ],
+            'cn'          => "$user",
+
+            'sn'   => "$user",
+            'uid'           => "$user",
+            'uidNumber'     => "$uid",
+            'gidNumber'     => "$gid",
+            'homeDirectory' => '/dev/null',
+            'loginShell'    => '/bin/false',
+            'description'   => 'Computer',
+            'gecos'         => 'Computer',
+	    'sn'	    => 'Computer',
+        ]
+    );
+
+    $add->code && warn "failed to add entry: ", $add->error;
+    sleep($wait);
+    return 1;
+}
+
+
 my $ok =
-  getopts( 'o:abnmwWiPG:u:g:d:s:c:k:t:A:B:C:D:E:F:H:L:M:N:S:T:?', \%Options );
+  getopts( 'o:abnmwWiPG:u:g:d:s:c:k:t:A:B:C:D:E:F:H:L:M:N:S:T:Z:?', \%Options );
 
 if ( ( !$ok ) || ( @ARGV < 1 ) || ( $Options{'?'} ) ) {
     print_banner;
@@ -304,7 +350,7 @@
     }
 
     if (
-        !add_posix_machine(
+        !add_posix_machine_gosa(
             $userName, $userUidNumber, $userGidNumber, $Options{'t'}
         )
       )
@@ -342,8 +388,9 @@
             changes => [
                 replace => [
                     objectClass =>
-                      [ 'posixAccount', 'account', 'sambaSAMAccount' ]
+                      [ 'top', 'posixAccount', 'person', 'organizationalPerson', 'inetOrgPerson', 'gosaAccount', 'sambaSamAccount', 'shadowAccount' ]
                 ],
+                add => [ sn       => 'Computer' ],
                 add => [ sambaLogonTime       => '0' ],
                 add => [ sambaLogoffTime      => '2147483647' ],
                 add => [ sambaKickoffTime     => '2147483647' ],
@@ -367,8 +414,9 @@
             changes => [
                 replace => [
                     objectClass =>
-                      [ 'posixAccount', 'account', 'sambaSAMAccount' ]
+                      [ 'top', 'posixAccount', 'person', 'organizationalPerson', 'inetOrgPerson', 'gosaAccount', 'sambaSamAccount', 'shadowAccount' ]
                 ],
+                add => [ sn       => 'Computer' ],
                 add => [ sambaLogonTime       => '0' ],
                 add => [ sambaLogoffTime      => '2147483647' ],
                 add => [ sambaKickoffTime     => '2147483647' ],

Quite a lot has changed in the original since the fork, and our script
no longer work because the /usr/share/perl5/smbldap_tools.pm library
no longer provide the get_next_id() function, as reported in
<URL: http://lists.debian.org/debian-edu/2013/08/msg00059.html >.

-- 
Happy hacking
Petter Reinholdtsen


Reply to: