Package: smbldap-tools
Version: 0.9.4-1
Severity: normal
Tags: patch

Hi there!

`man smbldap-useradd` states that if a default UID exists it can be
anyway used specifying the -o option:

--8<---------------cut here---------------start------------->8---
SYNOPSIS
       smbldap-useradd [-o user_ou] [-c comment] [-d home_dir] [-g ini‐
       tial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-s shell] [-u uid
       [ -o]] [-P] [-A canchange] [-B mustchange] [-C smbhome] [-D homedrive]
       [-E scriptpath] [-F profilepath] [-H acctflags] login

DESCRIPTION
[...]
       -o node
          The user’s account will be created in the specified organazional
       unit. It is relative to the user suffix dn ($usersdn) defined in the
       configuration file.  Ex: ’ou=admin,ou=all’
[...]
       -u uid
          The numerical value of  the  user’s  ID.   This  value  must  be
       unique,  unless  the  -o option is used.  The value must be nonnega‐
       tive.  The default is to use the smallest ID  value  greater than 1000
       and greater than every other user.
[...]
perl v5.8.8                       2007-09-24                SMBLDAP-USERADD(8)
--8<---------------cut here---------------end--------------->8---

However, this conflicts with the "-o node" option:
=====
mantissa:~# smbldap-useradd -a -c "Luca Capello" -d /home/luca -m \
 -u 1000 -o -P -N Luca -S Capello luca.capello
ou=-P,ou=Users,dc=pca,dc=it does not exist. Creating it (Y/[N]) ? n
exiting.
mantissa:~#
=====

This is in contrast with the behavior of smbldap-usermod:
=====
mantissa:~# smbldap-useradd -a -c "Luca Capello" -d /home/luca -m \
 -P -N Luca -S Capello luca.capello
Changing UNIX and samba passwords for luca.capello
New password:
Retype new password:
mantissa:~# smbldap-usermod -u 1000 luca.capello
/usr/sbin/smbldap-usermod: uid number 1000 exists
mantissa:~# smbldap-usermod -u 1000 -o luca.capello
mantissa:~#
=====

The attached patch add a new option, -r (for "reuse"), which substitutes
the UID -o option.  However, this is suboptimal and I would prefer the
OU -o option to be changed instead.

Thx, bye,
Gismo / Luca

-- System Information:
Debian Release: 5.0.4
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.30-bpo.1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages smbldap-tools depends on:
ii  libcrypt-smbhash-perl    0.12-2          generate LM/NT hash of a password 
ii  libdigest-sha1-perl      2.11-2+b1       NIST SHA-1 message digest algorith
ii  libio-socket-ssl-perl    1.16-1+lenny1   Perl module implementing object or
ii  libnet-ldap-perl         1:0.36-1        A Client interface to LDAP servers
ii  libunicode-maputf8-perl  1.11-2          Perl module for conversing between
ii  perl                     5.10.0-19lenny2 Larry Wall's Practical Extraction 

smbldap-tools recommends no packages.

smbldap-tools suggests no packages.

-- no debconf information

--- smbldap-useradd_v0.9.4	2007-09-24 12:18:51.000000000 +0200
+++ smbldap-useradd	2010-03-05 21:49:29.000000000 +0100
@@ -35,7 +35,7 @@
 use Getopt::Std;
 my %Options;
 
-my $ok = getopts('o:abnmwiPG:u:g:d:s:c:k:t:A:B:C:D:E:F:H:M:N:S:T:?', \%Options);
+my $ok = getopts('o:abnmwiPG:u:r:g:d:s:c:k:t:A:B:C:D:E:F:H:M:N:S:T:?', \%Options);
 
 if ( (!$ok) || (@ARGV < 1) || ($Options{'?'}) ) {
     print_banner;
@@ -50,6 +50,7 @@
     print "  -m	creates home directory and copies /etc/skel\n";
     print "  -n	do not create a group\n";
     print "  -o	add the user in the organizational unit (relative to the user suffix. Ex: 'ou=admin,ou=all')\n";
+    print "  -r	uid can be non unique\n";
     print "  -u	uid\n";
     print "  -s	shell\n";
     print "  -t	time. Wait 'time' seconds before exiting (when adding Windows Workstation)\n";
@@ -155,7 +156,7 @@
 my $userUidNumber = $Options{'u'};
 if (!defined($userUidNumber)) { 
     $userUidNumber=get_next_id($config{usersdn},"uidNumber");
-} elsif (getpwuid($userUidNumber)) {
+} elsif (!defined($Options{'r'}) && getpwuid($userUidNumber)) {
     die "Uid already exists.\n";
 }
 
@@ -551,7 +552,7 @@
 
 =head1 SYNOPSIS
 
-smbldap-useradd [-o user_ou] [-c comment] [-d home_dir] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-s shell] [-u uid [ -o]] [-P] [-A canchange] [-B mustchange] [-C smbhome] [-D homedrive] [-E scriptpath] [-F profilepath] [-H acctflags] login
+smbldap-useradd [-o user_ou] [-c comment] [-d home_dir] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-s shell] [-u uid [ -r]] [-P] [-A canchange] [-B mustchange] [-C smbhome] [-D homedrive] [-E scriptpath] [-F profilepath] [-H acctflags] login
 
 =head1 DESCRIPTION
 
@@ -602,7 +603,7 @@
    Wait <time> seconds before exiting script when adding computer's account. This is useful when Master/PDC and Slaves/BDCs are connected through the internet (replication is not real time)
 
 -u uid
-   The numerical value of  the  user's  ID.   This  value  must  be unique,  unless  the  -o option is used.  The value must be nonnegative.  The default is to use the smallest ID  value  greater than 1000 and greater than every other user.
+   The numerical value of  the  user's  ID.   This  value  must  be unique,  unless  the  -r option is used.  The value must be nonnegative.  The default is to use the smallest ID  value  greater than 1000 and greater than every other user.
 
 -P
    ends by invoking smbldap-passwd

Diff finished.  Fri Mar  5 21:52:29 2010

Attachment: pgpDzWdosccUi.pgp
Description: PGP signature

Reply via email to