busybox current status

Luciano Miguel Ferreira Rocha strange at nsk.no-ip.org
Wed Nov 29 17:23:33 PST 2006


On Thu, Nov 30, 2006 at 12:56:02AM +0100, Bernhard Fischer wrote:
> On Wed, Nov 29, 2006 at 11:44:38PM +0000, Luciano Miguel Ferreira Rocha wrote:
> >
> >Is this the state of the public svn?
> 
> yes.
> >                                     I can update my cpio hardlink fix
> >and httpd cgi output to syslog if you want.
> 
> Please do so if you want them to be integrated. I managed to miss these
> patches of your the first time round, so let me ask to resend the
> problem description they were solving.
> 

Another one in my queue. This one does two things to chown:

1. Search first for ':' and only if it fails for '.', instead of the
current behaviour of preferring '.'. ('.' is a valid part of a username,
it seems.)

2. Allow an empty specification of the new group (like 'user:'), in
which case the gid associated to the specified user is used.

-- 
lfr
0/0
-------------- next part --------------
Index: coreutils/chown.c
===================================================================
--- coreutils/chown.c	(revision 16736)
+++ coreutils/chown.c	(working copy)
@@ -65,18 +65,31 @@
 	argv += optind;
 
 	/* First, check if there is a group name here */
-	groupName = strchr(*argv, '.');
+	groupName = strchr(*argv, ':');
 	if (!groupName) {
-		groupName = strchr(*argv, ':');
+		groupName = strchr(*argv, '.');
 	}
 
-	/* Check for the username and groupname */
+	/* Check for groupname */
 	if (groupName) {
 		*groupName++ = '\0';
-		gid = get_ug_id(groupName, bb_xgetgrnam);
+		if (*groupName)
+			gid = get_ug_id(groupName, bb_xgetgrnam);
 	}
-	if (--groupName != *argv)
+
+	/* Check for username */
+	if (**argv) {
 		uid = get_ug_id(*argv, bb_xgetpwnam);
+		if (groupName && *groupName == '\0') {
+			/* groupname defined but empty, use username's default gid */
+			struct passwd *pwe = getpwuid(uid);
+
+			if (!pwe)
+				bb_error_msg_and_die("unknown uid: %s", *argv);
+			gid = pwe->pw_gid;
+		}
+	}
+
 	++argv;
 
 	/* Ok, ready to do the deed now */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20061130/a5f37c12/attachment.pgp 


More information about the busybox mailing list