[BusyBox] [PATCH] id minor bugfix and code clean up for my_getpwuid and my_getgrgid
Tito
farmatito at tiscali.it
Sat Sep 4 00:46:00 UTC 2004
Hi, to all
This patch fixes a corner case in which id applet doesn't produce the same output
as GNU id:
user: pippo, uid 502, gid 504, default group pippo:504 in /etc/group deleted
./busybox id -g pippo
id: unknown gid 504
GNU:
id -g pippo
504
The patch also cleans up code formatting and removes
some not needed includes.
-------------- next part --------------
--- libbb/my_getpwuid_orig.c 2004-09-02 22:21:40.000000000 +0000
+++ libbb/my_getpwuid.c 2004-09-03 23:19:56.306987136 +0000
@@ -38,7 +38,6 @@
#include <assert.h>
#include "libbb.h"
#include "pwd_.h"
-#include "grp_.h"
@@ -58,8 +57,7 @@
}
return NULL;
} else {
- if(bufsize > 0 )
- {
+ if(bufsize > 0 ) {
assert(name != NULL);
return safe_strncpy(name, myuser->pw_name, bufsize);
}
--- libbb/my_getgrgid_orig.c 2004-09-02 22:21:40.000000000 +0000
+++ libbb/my_getgrgid.c 2004-09-03 23:19:43.351956600 +0000
@@ -37,7 +37,6 @@
#include <string.h>
#include <assert.h>
#include "libbb.h"
-#include "pwd_.h"
#include "grp_.h"
@@ -57,8 +56,7 @@
}
return NULL;
} else {
- if(bufsize > 0)
- {
+ if(bufsize > 0) {
assert(group != NULL);
return safe_strncpy(group, mygroup->gr_name, bufsize);
}
--- coreutils/id_orig.c 2004-09-03 23:14:06.000000000 +0000
+++ coreutils/id.c 2004-09-04 00:33:46.222537608 +0000
@@ -26,7 +26,6 @@
*/
#include "busybox.h"
-#include "grp_.h"
#include "pwd_.h"
#include <stdio.h>
#include <unistd.h>
@@ -46,7 +45,7 @@
void printf_full(unsigned int id, char *arg, char prefix)
{
- printf("%cid=%u",prefix, id);
+ printf("%cid=%u", prefix, id);
if(arg)
printf("(%s) ", arg);
}
@@ -80,9 +79,7 @@
gid = getgid();
}
- if(argv[optind])
- {
-
+ if(argv[optind]) {
p=getpwnam(argv[optind]);
/* this is needed because it exits on failure */
uid = my_getpwnam(argv[optind]);
@@ -90,21 +87,19 @@
/* in this case PRINT_REAL is the same */
}
- user=my_getpwuid(NULL, uid, (flags & JUST_USER) ? -1 : 0);
+ user=my_getpwuid(NULL, uid, (flags & NAME_NOT_NUMBER) ? -1 : 0);
- if(flags & JUST_USER)
- {
+ if(flags & JUST_USER) {
gid=uid;
group=user;
goto PRINT;
}
- group=my_getgrgid(NULL, gid, (flags & JUST_GROUP) ? -1 : 0);
+ group=my_getgrgid(NULL, gid, (flags & NAME_NOT_NUMBER) ? -1 : 0);
- if(flags & JUST_GROUP)
- {
+ if(flags & JUST_GROUP) {
PRINT:
- if(flags & NAME_NOT_NUMBER)
+ if((flags & NAME_NOT_NUMBER) && group)
puts(group);
else
printf ("%u\n", gid);
@@ -115,8 +110,7 @@
printf_full(uid, user, 'u');
printf_full(gid, group, 'g');
#ifdef CONFIG_SELINUX
- if(is_flask_enabled_flag)
- {
+ if(is_flask_enabled_flag) {
security_id_t mysid = getsecsid();
char context[80];
int len = sizeof(context);
More information about the busybox
mailing list