[BusyBox] id argument addition
BRENT PRIDDY
brent.priddy at adtran.com
Mon Nov 20 16:27:32 UTC 2000
I added the -n "print the name instead of the number, for -ug" to id.c and
updated the usage.c file with the new argument type
used for "id -un" when you want to get the user's name (I am using this in a
login script)
Brent
I have enclosed the 2 diff's for id.c and usage.c
<start diff of id.c>
Index: id.c
===================================================================
RCS file: /var/cvs/busybox/id.c,v
retrieving revision 1.11
diff -u -r1.11 id.c
--- id.c 2000/09/25 21:45:57 1.11
+++ id.c 2000/11/20 16:14:20
@@ -31,6 +31,7 @@
extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
+ int name_not_number = 0;
char *cp, *user, *group;
long gid;
long pwnam, grnam;
@@ -39,7 +40,7 @@
cp = user = group = NULL;
gid = 0;
- while ((opt = getopt(argc, argv, "ugr")) > 0) {
+ while ((opt = getopt(argc, argv, "ugrn")) > 0) {
switch (opt) {
case 'u':
no_group++;
@@ -50,6 +51,9 @@
case 'r':
print_real++;
break;
+ case 'n':
+ name_not_number++;
+ break;
default:
usage(id_usage);
}
@@ -80,11 +84,17 @@
if (gid == -1 || pwnam==-1 || grnam==-1) {
fatalError("%s: No such user\n", user);
}
- if (no_group)
- printf("%ld\n", pwnam);
- else if (no_user)
- printf("%ld\n", grnam);
- else
+ if (no_group) {
+ if(name_not_number && user)
+ printf("%s\n",user);
+ else
+ printf("%ld\n", pwnam);
+ } else if (no_user) {
+ if(name_not_number && group)
+ printf("%s\n", group);
+ else
+ printf("%ld\n", grnam);
+ } else
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam,
group);
return(0);
}
<end of id.c diff>
<start of usage.c diff>
Index: usage.c
===================================================================
RCS file: /var/cvs/busybox/usage.c,v
retrieving revision 1.31
diff -u -r1.31 usage.c
--- usage.c 2000/11/17 18:13:09 1.31
+++ usage.c 2000/11/20 16:14:29
@@ -489,6 +489,7 @@
"Options:\n"
"\t-g\tprints only the group ID\n"
"\t-u\tprints only the user ID\n"
+ "\t-n\tprint a name instead of a number (with for -ug)\n"
"\t-r\tprints the real user ID instead of the effective ID (with
-ug)\n\n"
#endif
;
<end of usage.c diff>
-----Original Message-----
From: Erik Andersen [mailto:andersen at lineo.com]
Sent: Friday, November 17, 2000 2:13 PM
To: Gennady Feldman
Cc: BusyBox
Subject: [BusyBox] Re: Net-utils
On Fri Nov 17, 2000 at 01:10:45PM -0500, Gennady Feldman wrote:
> Hello Erik.
>
> I was just curious if you are still thinking of creating networking
> utilities package. I know that this issue was mentioned in the readme
> files. Some of the possible things that it could contain include:
> - inetd
> - telnetd
> - arp
> - route
> - ifconfig
> - and others....
Hope you don't mind my CCing the busybox list...
<offtopic>
As an aside, it really is best to always send such mail to the mailing list
rather then me directly. I just got back from being out of the country for
two
weeks, and found my mailbox full of patches and requests for help, 90% of
which
really should have gone to the mailing list where they would have gotten
immediate attention from the other folks while I was away... I work hard,
and
try to do my best to answer everyone, but I get a _lot_ of email. Some
people
have assumed that I am their personal full time embedded systems
consultant...
These people are well meaning, but it can easily become overwhelming.
Sending
questions to the mailing list helps balance the load a bit.
</offtopic>
Moving back to the topic at hand... I've been intending to get netkit-tiny
going since about February, but never actually gotten around to it. I have
some preliminary route and ifconfig code, I still have a telnetd patch, and
a
mini inetd waiting as well.
One piece needed to get netkit-tiny going I just finished doing in tinylogin
--
a sane method of dropping permissions. In tinylogin, every applet now has a
field that specifies if it requires elevated permissions, and if it isn't
TRUE,
it drops permissions before calling the applet. This should probably also
go
into busybox (in case some poor benighted fool sets /bin/busybox setuid root
to
make ping work for normal users).
So, yes! I do still want to do this. But between work projects (I recently
completed an arm7tdmi uclinux kernel port with user space only partway
done), a
few consulting gigs, debian work which I am behind on, busybox, tinylogin,
uClibc, and my family I havn't had the bandwidth to get it out there yet. I
am
hoping to finish up a few more things and (finally!) get the tinylogin 0.80
release out the door, and then I should have a little more time for new
projects... I hope...
Of course, if someone on the list has the personal bandwidth and ability, I
can
happily supply some code (some of which would be transfered out of busybox),
a
CVS repository, bug tracking, web pages, mailing lists, and patches as time
permits and problems bug me.
Any volunteers to become the maintainer for the not-yet-existant
netkit-tiny?
-Erik
--
Erik B. Andersen email: andersen at lineo.com
--This message was written using 73% post-consumer electrons--
_______________________________________________
busybox mailing list
busybox at busybox.net
http://busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list