[Samba] Bugfix for idealx smbldap-tools

Alexander Skwar lists.ASkwar at DigitalProjects.com
Tue May 14 01:27:02 GMT 2002


Hi.

When I tried to setup my LDAP I used the smbldap-tools from idealx.  I
discovered some errors which made the tools unusable for me.

Here's a fix for the bugs I discovered:

a) I decided to use a suffix in the LDAP which contains spaces, ie. I
used something like "o=My Org,c=DE".  Because the suffix wasn't quoted
in the various calls in the tools, this didn't work.
b) It used "sprint" to convert dec->hex.  My perl doesn't know sprint,
but knows sprintf.  Now the tools use sprintf.
c) When creating a new Samba user with smbldap-useradd.pl -a, the first
LDAP invocation missed the required rid attribute.
d) The GECOS entry just contained "user" or "group" as a default.  I
didn't like this and changed it so that the default is the "userName".
e) It no longer uses a logon script called "username.cmd" but uses a
default.

Attached is a patch against the 0.6 version.

Alexander Skwar
-- 
How to quote:	http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:	http://www.iso-top.de      |    Jabber: askwar at a-message.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
                       Uptime: 3 hours 17 minutes
-------------- next part --------------
Binary files sbin/mkntpwd and modified/mkntpwd differ
diff -ur sbin/smbldap_conf.pm modified/smbldap_conf.pm
--- sbin/smbldap_conf.pm	2002-05-14 08:05:54.000000000 +0000
+++ modified/smbldap_conf.pm	2002-05-14 08:13:54.000000000 +0000
@@ -117,13 +117,13 @@
 # Samba defs
 #
 #$_userSmbHome = q(\\\\PDC-SRV\\homes);
-$_userSmbHome = q(\\\\_PDCNAME_\\homes);
+$_userSmbHome = q(\\\\_PDCNAME_\\%u);
 $_userProfile = q(\\\\_PDCNAME_\\profiles\\);
 $_userHomeDrive = q(H:);
 
 # not used; current script name is $_userName.cmd
 #$_userScript = q(startup.cmd); # make sure script file is edited under dos
-
+$_userScript = q(logon.bat);
 
 $smbpasswd = "/usr/bin/smbpasswd";
 $mk_ntpasswd = "/usr/local/sbin/mkntpwd";
diff -ur sbin/smbldap-passwd.pl modified/smbldap-passwd.pl
--- sbin/smbldap-passwd.pl	2002-05-14 08:05:54.000000000 +0000
+++ modified/smbldap-passwd.pl	2002-05-14 08:14:29.000000000 +0000
@@ -166,7 +166,7 @@
     }
 }
 # change unix password
-$ret = system "$ldappasswd $dn -s $pass > /dev/null";
+$ret = system "$ldappasswd '$dn' -s '$pass' > /dev/null";
 if ($ret == 0) {
     print "all authentication tokens updated successfully\n";
 } else {
diff -ur sbin/smbldap_tools.pm modified/smbldap_tools.pm
--- sbin/smbldap_tools.pm	2002-05-14 08:05:54.000000000 +0000
+++ modified/smbldap_tools.pm	2002-05-14 08:15:01.000000000 +0000
@@ -337,7 +337,7 @@
     }
 
     my $dn = get_dn_from_line($dn_line);
-    system "$ldapdelete $dn >/dev/null";
+    system "$ldapdelete '$dn'";
 }
 
 # $success = group_add($groupname, $group_gid, $force_using_existing_gid)
diff -ur sbin/smbldap-useradd.pl modified/smbldap-useradd.pl
--- sbin/smbldap-useradd.pl	2002-05-14 08:05:54.000000000 +0000
+++ modified/smbldap-useradd.pl	2002-05-14 08:15:52.000000000 +0000
@@ -54,7 +54,7 @@
 	print "  -n	do not create a group\n";
 	print "  -d	home\n";
 	print "  -s	shell\n";
-	print "  -c	gecos\n";
+	print "  -c	Comment/gecos\n";
 	print "  -m	creates home directory and copies /etc/skel\n";
 	print "  -k	skeleton dir (with -m)\n";
 	print "  -P     ends by invoking smbldap-passwd.pl\n";
@@ -95,7 +95,7 @@
 # as rid we use 2 * uid + 1000
 my $userRid = 2 * $userUidNumber + 1000;
 if (defined($Options{'x'})) {
-    $userRid= sprint("%x", $userRid);
+    $userRid= sprintf("%x", $userRid);
 }
 
 my $createGroup = 0;
@@ -131,7 +131,7 @@
 # as grouprid we use 2 * gid + 1001
 my $userGroupRid = 2 * $userGidNumber + 1001;
 if (defined($Options{'x'})) {
-    $userGroupRid = sprint("%x", $userGroupRid);
+    $userGroupRid = sprintf("%x", $userGroupRid);
 }
 # Read only first @ARGV
 my $userName = $ARGV[0];
@@ -153,6 +153,9 @@
     $userHomeDirectory = $_userHomePrefix.$userName;
 }
 $_userLoginShell = $tmp if (defined($tmp = $Options{'s'}));
+# ASkwar:
+# Use a more meaningful default GECOS entry
+$_userGecos = $userName;
 $_userGecos = $tmp if (defined($tmp = $Options{'c'}));
 $_skeletonDir = $tmp if (defined($tmp = $Options{'k'}));
 
@@ -289,6 +292,7 @@
 pwdMustChange: $valpwdmustchange
 displayName: $_userGecos
 acctFlags: $valacctflags
+rid: $userRid
 
 ";
 	
@@ -311,7 +315,8 @@
 	}
     } # with_smbpasswd
 
-    my $valscriptpath = "$userName.cmd";
+    #my $valscriptpath = "$userName.cmd";
+    my $valscriptpath = $_userScript;
     my $valprofilepath = "$_userProfile$userName";
     my $valsmbhome = "$_userSmbHome";
     my $valhomedrive = "$_userHomeDrive";
diff -ur sbin/smbldap-usermod.pl modified/smbldap-usermod.pl
--- sbin/smbldap-usermod.pl	2002-05-14 08:05:54.000000000 +0000
+++ modified/smbldap-usermod.pl	2002-05-11 14:26:50.000000000 +0000
@@ -129,7 +129,7 @@
     # as rid we use 2 * uid + 1000
     my $_userRid = 2 * $_userUidNumber + 1000;
     if (defined($Options{'x'})) {
-	$_userRid= sprint("%x", $_userRid);
+	$_userRid= sprintf("%x", $_userRid);
     }
     $mods .= "uidNumber: $_userUidNumber\n";
     if ($samba) {
@@ -150,7 +150,7 @@
 # as grouprid we use 2 * gid + 1001
     my $_userGroupRid = 2 * $_userGidNumber + 1001;
     if (defined($Options{'x'})) {
-	$_userGroupRid = sprint("%x", $_userGroupRid);
+	$_userGroupRid = sprintf("%x", $_userGroupRid);
     }
     $mods .= "gidNumber: $_userGidNumber\n";
     if ($samba) {


More information about the samba mailing list