[Adduser-devel] sigh

Marc Haber mh+adduser-devel at zugschlus.de
Wed Apr 26 09:28:09 UTC 2006


On Sat, Apr 22, 2006 at 12:33:10PM +0100, Stephen Gran wrote:
> No problem.  Here is the patch for die -> dief/warnf cleanup, that fixes
> the problem in #351968.  I am attaching it inline this time.

It doesn't seem to apply cleanly, and after applying it manually
(resulting in the attachment), the testsuite complains about a
truckload of uninitialized values and "printf (...) interpreted as
function".

I am afraid the patch is not suitable for inclusion at this time.

Greetings
Marc

-- 
-----------------------------------------------------------------------------
Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
Mannheim, Germany  |  lose things."    Winona Ryder | Fon: *49 621 72739834
Nordisch by Nature |  How to make an American Quilt | Fax: *49 621 72739835
-------------- next part --------------
Index: adduser
===================================================================
--- adduser	(revision 550)
+++ adduser	(working copy)
@@ -126,7 +126,7 @@
 	    "debug" => sub { $verbose = 2 } );
 
 # everyone can issue "--help" and "--version", but only root can go on
-dief ("$0: ",gtx("Only root may add a user or group to the system.\n")) if ($> != 0);
+dief (gtx("Only root may add a user or group to the system.\n")) if ($> != 0);
 
 if( defined($configfile) ) { @defaults = ($configfile); }
 
@@ -149,12 +149,12 @@
 }
 
 if ( (! defined $names[0]) || length($names[0]) == 0 || @names > 2) {
-    dief ("$0: ",gtx("Only one or two names allowed.\n"));
+    dief (gtx("Only one or two names allowed.\n"));
 }
 	    
 
 if (@names == 2) {	# must be addusertogroup
-    dief ("$0: ",gtx("Specify only one name in this mode.\n"))
+    dief (gtx("Specify only one name in this mode.\n"))
 	if ($action eq "addsysuser" || $found_group_opt);
     $action = "addusertogroup";
     $existing_user = shift (@names);
@@ -170,18 +170,18 @@
 
 if ($action ne "addgroup" &&
     defined($found_group_opt) +defined($ingroup_name) +defined($new_gid) > 1 ) {
-    dief ("$0: ",gtx("The --group, --ingroup, and --gid options are mutually exclusive.\n"));
+    dief (gtx("The --group, --ingroup, and --gid options are mutually exclusive.\n"));
 }
 
 
 if ((defined($special_home)) && ($special_home !~ m+^/+ )) {
-  (dief "$0: ",gtx("The home dir must be an absolute path.\n"))
+  dief (gtx("The home dir must be an absolute path.\n"))
 }
 	   
 if (defined($special_home) && $verbose) {
-    print "$0: ",gtx("Warning: The home dir you specified already exists.\n")
+    warnf (gtx("Warning: The home dir you specified already exists.\n"))
       if (!defined($no_create_home) && -d $special_home);
-    print "$0: ",gtx("Warning: The home dir you specified does not exist.\n")
+    warnf (gtx("Warning: The home dir you specified does not exist.\n"))
       if (defined($no_create_home) && ! -d $special_home);
 }
 
@@ -239,11 +239,11 @@
 if ($action eq "addsysgroup") {
     # Check if requested group already exists and we can exit safely
     if (existing_group_ok($new_name, $new_gid) == 1) {
-	printf (gtx("The group `%s' already exists as a system group. Exiting...\n"), $new_name) if $verbose;
+	warnf (gtx("The group `%s' already exists as a system group. Exiting...\n"), $new_name) if $verbose;
 	exit 0;
     }
     if (existing_group_ok($new_name, $new_gid) == 2) {
-	printf (gtx("The group `%s' already exists, but has a different gid, aborting...\n"), $new_name) if $verbose;
+	warnf (gtx("The group `%s' already exists, but has a different gid, aborting...\n"), $new_name) if $verbose;
 	exit 1;
     }
 
@@ -256,8 +256,7 @@
 				   $config{"last_system_gid"});
 
         if ($new_gid == -1) {
-	    print STDERR "$0: ";
-	    printf STDERR gtx("No GID is available in the range %d-%d (FIRST_SYS_GID - LAST_SYS_GID).\n"),$config{"first_system_gid"},$config{"last_system_gid"};
+	    warnf (gtx("No GID is available in the range %d-%d (FIRST_SYS_GID - LAST_SYS_GID).\n"),$config{"first_system_gid"},$config{"last_system_gid"});
             dief (gtx("The group `%s' was not created.\n"),$new_name);
         }
     }
@@ -284,8 +283,7 @@
 				   $config{"last_gid"});
 
         if ($new_gid == -1) {
-	    print STDERR "$0: ";
-	    printf STDERR gtx("No GID is available in the range %d-%d (FIRST_GID - LAST_GID).\n"),$config{"first_gid"},$config{"last_gid"};
+	    warnf (gtx("No GID is available in the range %d-%d (FIRST_GID - LAST_GID).\n"),$config{"first_gid"},$config{"last_gid"});
             dief (gtx("The group `%s' was not created.\n"),$new_name);
         }
     }
@@ -308,8 +306,8 @@
     dief (gtx("The group `%s' does not exist.\n"),$existing_group)
 	if (!defined getgrnam($existing_group));
     if (&user_is_member($existing_user, $existing_group)) {
-	printf gtx("The user `%s' is already a member of `%s'.\n"),
-                $existing_user,$existing_group if $verbose;
+	printf (gtx("The user `%s' is already a member of `%s'.\n"),
+                $existing_user,$existing_group) if $verbose;
 	exit 0;			# not really an error
     }
 
@@ -335,11 +333,11 @@
 ################
 if ($action eq "addsysuser") {
     if (existing_user_ok($new_name, $new_uid) == 1) {
-	printf (gtx("The user `%s' already exists as a system user. Exiting...\n"), $new_name) if $verbose;
+	warnf (gtx("The user `%s' already exists as a system user. Exiting...\n"), $new_name) if $verbose;
 	exit 0;
     }
     if (existing_user_ok($new_name, $new_uid) == 2) {
-	printf (gtx("The user `%s' already exists with a different uid. Aborting\n"), $new_name) if $verbose;
+	warnf (gtx("The user `%s' already exists with a different uid. Aborting\n"), $new_name) if $verbose;
 	exit 1;
     }
 
@@ -352,8 +350,7 @@
 	$new_uid = &first_avail_uid($config{"first_system_uid"},
 				   $config{"last_system_uid"});
         if ($new_uid == -1) {
-	    print STDERR "$0: ";
-	    printf STDERR gtx("No UID/GID pair is available in the range %d-%d (FIRST_SYS_UID - LAST_SYS_UID).\n"),$config{"first_system_uid"},$config{"last_system_uid"};
+	    warnf (gtx("No UID/GID pair is available in the range %d-%d (FIRST_SYS_UID - LAST_SYS_UID).\n"),$config{"first_system_uid"},$config{"last_system_uid"});
             dief (gtx("The user `%s' was not created.\n"),$new_name);
         }
         $new_gid = &first_avail_gid($config{"first_system_gid"},
@@ -364,8 +361,7 @@
 	$new_uid = &first_avail_uid($config{"first_system_uid"},
 				   $config{"last_system_uid"});
         if ($new_uid == -1) {
-	    print STDERR "$0: ";
-	    printf STDERR gtx("No UID is available in the range %d-%d (FIRST_SYS_UID - LAST_SYS_UID).\n"),$config{"first_system_uid"},$config{"last_system_uid"};
+	    warnf (gtx("No UID is available in the range %d-%d (FIRST_SYS_UID - LAST_SYS_UID).\n"),$config{"first_system_uid"},$config{"last_system_uid"});
 	    dief (gtx("The user `%s' was not created.\n"),$new_name);
         }
         if (defined($new_gid)) { $ingroup_name = getgrgid($new_gid); }
@@ -389,7 +385,7 @@
 	&invalidate_nscd("group");
     }
 
-    printf gtx("Adding new user `%s' (%s) with group `%s'.\n"),$new_name,$new_uid,$ingroup_name
+    printf (gtx("Adding new user `%s' (%s) with group `%s'.\n")),$new_name,$new_uid,$ingroup_name
 	if $verbose;
     $home_dir = $special_home || &homedir($new_name, $ingroup_name);
 	$shell = $special_shell || '/bin/false';
@@ -438,8 +434,7 @@
 				   $last_uid);
 				
         if ($new_uid == -1) {
-	    print STDERR "$0: ";
-            printf STDERR gtx("No UID/GID pair is available in the range %d-%d (FIRST_UID - LAST_UID).\n"),$first_uid,$last_uid;
+            warnf (gtx("No UID/GID pair is available in the range %d-%d (FIRST_UID - LAST_UID).\n"),$first_uid,$last_uid);
 	    dief (gtx("The user `%s' was not created.\n"),$new_name);
         }
 	$new_gid = &first_avail_gid($config{"first_gid"}, 
@@ -450,8 +445,7 @@
 	$new_uid = &first_avail_uid($first_uid,
 				   $last_uid);
 	if ($new_uid == -1) {
-	    print STDERR "$0: ";
-	    printf STDERR gtx("No UID is available in the range %d-%d (FIRST_UID - LAST_UID).\n"),$config{"first_uid"},$config{"last_uid"};
+	    warnf (gtx("No UID is available in the range %d-%d (FIRST_UID - LAST_UID).\n"),$config{"first_uid"},$config{"last_uid"});
             dief (gtx("The user `%s' was not created.\n"),$new_name);
         }
 	if (defined($new_gid)) { $ingroup_name = getgrgid($new_gid); }
@@ -473,7 +467,7 @@
 	&invalidate_nscd();
     }
 
-    printf gtx("Adding new user `%s' (%s) with group `%s'.\n"),$new_name,$new_uid,$ingroup_name
+    printf (gtx("Adding new user `%s' (%s) with group `%s'.\n"),$new_name,$new_uid,$ingroup_name)
 	if $verbose;
     $home_dir = $special_home || &homedir($new_name, $ingroup_name);
 	$shell = $special_shell || $config{"dshell"};
@@ -567,21 +561,21 @@
   my ($copy_skeleton) = @_;
 
   if ($no_create_home) {
-      printf gtx("Not creating home directory `%s'.\n"), $home_dir if $verbose;
+      printf (gtx("Not creating home directory `%s'.\n"), $home_dir) if $verbose;
   }
   elsif (-e $home_dir) {
-      printf gtx("The home directory `%s' already exists.  Not copying from `%s'\n"),
-      $home_dir,$config{skel} if $verbose && !$no_create_home;
+      printf (gtx("The home directory `%s' already exists.  Not copying from `%s'\n"),
+      $home_dir,$config{skel}) if $verbose && !$no_create_home;
       my @homedir_stat = stat($home_dir);
       my $home_uid = $homedir_stat[4];
       my $home_gid = $homedir_stat[5];
       if (($home_uid != $new_uid) || ($home_gid != $new_gid)) {
-          warnf gtx("Warning: that home directory does not belong to the user you are currently creating\n");
+          warnf (gtx("Warning: that home directory does not belong to the user you are currently creating\n"));
       }
       undef @homedir_stat; undef $home_uid; undef $home_gid;
   }
   else {
-      printf gtx("Creating home directory `%s'.\n"),$home_dir if $verbose;
+      printf (gtx("Creating home directory `%s'.\n"),$home_dir) if $verbose;
       $undohome = $home_dir;
       &mktree($home_dir) || &cleanup("Couldn't create $home_dir: $!.\n");
       chown($new_uid, $new_gid, $home_dir)
@@ -591,7 +585,7 @@
 	  &cleanup("chmod $dir_mode $home_dir: $!\n");
 
       if ($config{"skel"} && $copy_skeleton) {
-	  printf gtx("Copying files from `%s'\n"),$config{skel} if $verbose;
+	  printf (gtx("Copying files from `%s'\n"),$config{skel}) if $verbose;
 	  open(FIND, "cd $config{skel}; find .  -print |")
 	      || &cleanup("fork for find: $!\n");
 	  while (<FIND>) {
@@ -745,8 +739,8 @@
 sub checkname {
     my ($name) = @_;
     if ($name !~ /^[_.A-Za-z0-9][-_.A-Za-z0-9]*\$?$/) {
-	print STDERR
-("$0: ",gtx("To avoid problems, the username should consist of
+	warnf
+(gtx("To avoid problems, the username should consist of
 letters, digits, underscores, periods and dashes, and not start with a
 dash (as defined by IEEE Std 1003.1-2001). For compatibility with Samba
 machine accounts \$ is also supported at the end of the username\n"));
@@ -757,8 +751,8 @@
 	print (gtx("Allowing use of questionable username.\n")) if ($verbose);
       }
       else {
-        print STDERR
-("$0: ",gtx("Please enter a username matching the regular expression configured
+        warnf
+(gtx("Please enter a username matching the regular expression configured
 via the name_regex configuration variable.  Use the `--force-badname'
 option to relax this check or reconfigure name_regex.\n"));
         exit 1;
@@ -869,7 +863,7 @@
 }
 
 sub usage {
-    printf gtx(
+    printf (gtx(
 "adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID]
 [--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup GROUP | --gid ID]
 [--disabled-password] [--disabled-login] user
@@ -892,7 +886,7 @@
 
 Other options are [--quiet] [--force-badname] [--help] [--version] [--conf
 FILE].
-");
+"));
 }
 
 sub get_dir_mode


More information about the Adduser-devel mailing list