[Fwd: [PATCH] support to add a username consists of only digitals]

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

 



If anyone cares enough to follow up on this...

-------- Original Message --------
Subject: [PATCH] support to add a username consists of only digitals
Date: Wed, 18 Feb 2009 11:18:12 +0800
From: 潘卫平 <wppan@xxxxxxxxxxxxxxxxx>
To: fedora-devel-list-owner@xxxxxxxxxx

Hi all,

I found a BUG in libuser-0.56.9.
<https://fedorahosted.org/libuser/attachment/wiki/LibuserDownloads/libuser-0.56.9.tar.bz2>
When I add a username consists of only digitals, like "1234", error happens.

Reproduce steps:
1 luseradd 1234
2 Group 1234 does not exist

But when I use "useradd 1234" command, no error happens.

I find the reason that luseradd converts "1234" from string to a long
int, and uses it as gid.
But when luseradd uses lu_group_lookup_id(ctx, gidNumber, groupEnt,
&error) to find the group,
error happens, because there is not such a group.

Regards!

Pan Weiping


--- libuser-0.56.9_bak/apps/luseradd.c	2009-02-17 14:33:31.000000000 +0800
+++ libuser-0.56.9/apps/luseradd.c	2009-02-17 16:32:47.000000000 +0800
@@ -143,8 +143,16 @@
 	groupEnt = lu_ent_new();
 	errno = 0;
 	imax = strtoimax(gid, &p, 10);
-	if (errno == 0 && *p == 0 && p != gid && (gid_t)imax == imax)
-		gidNumber = imax;
+	if (errno == 0 && *p == 0 && p != gid && (gid_t)imax == imax) {
+		if (lu_group_lookup_id(ctx, imax, groupEnt, &error)) 
+			gidNumber = imax;
+		else
+			gidNumber = LU_VALUE_INVALID_ID;
+		
+		/* lu_group_lookup_id may fail, but it doesn't matter.
+ 		 * reset error */
+		error = NULL;
+	}
 	else
 		/* It's not a number, so it's a group name. */
 		gidNumber = LU_VALUE_INVALID_ID;

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux