aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-09-02 22:21:41 +0000
committerEric Andersen <andersen@codepoet.org>2004-09-02 22:21:41 +0000
commit7eb79fff10915afc4d561a65e54851efa869db89 (patch)
treededb5229f5b92441ba10aa00667463ef100ccd6f /loginutils
parentb225e2a76bcd2b1f3f919a09dba1e186c0d4fa65 (diff)
downloadbusybox-w32-7eb79fff10915afc4d561a65e54851efa869db89.tar.gz
busybox-w32-7eb79fff10915afc4d561a65e54851efa869db89.tar.bz2
busybox-w32-7eb79fff10915afc4d561a65e54851efa869db89.zip
Tito writes:
Hi Erik, Hi to all, This is part five of the my_get*id story. I've tweaked a bit this two functions to make them more flexible, but this changes will not affect existing code. Now they work so: 1) my_getpwuid( char *user, uid_t uid, int bufsize) if bufsize is > 0 char *user cannot be set to NULL on success username is written on static allocated buffer on failure uid as string is written to buffer and NULL is returned if bufsize is = 0 char *user can be set to NULL on success username is returned on failure NULL is returned if bufsize is < 0 char *user can be set to NULL on success username is returned on failure an error message is printed and the program exits 2) 1) my_getgrgid( char *group, uid_t uid, int bufsize) if bufsize is > 0 char *group cannot be set to NULL on success groupname is written on static allocated buffer on failure gid as string is written to buffer and NULL is returned if bufsize is = 0 char *group can be set to NULL on success groupname is returned on failure NULL is returned if bufsize is < 0 char *group can be set to nULL on success groupname is returned on failure an error message is printed and the program exits This changes were needed mainly for my new id applet. It is somewhat bigger then the previous but matches the behaviour of GNU id and is capable to handle usernames of whatever length. BTW: at a first look it seems to me that it will integrate well (with just a few changes) with the pending patch in patches/id_groups_alias.patch. The increase in size is balanced by the removal of my_getpwnamegid.c from libbb as this was used only in previous id applet and by size optimizations made possible in whoami.c and in passwd.c. I know that we are in feature freeze but I think that i've tested it enough (at least I hope so.......).
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/passwd.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index d0b2afc19..400ddb9a5 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -145,7 +145,6 @@ extern int passwd_main(int argc, char **argv)
145 int uflg = 0; /* -u - unlock account */ 145 int uflg = 0; /* -u - unlock account */
146 int dflg = 0; /* -d - delete password */ 146 int dflg = 0; /* -d - delete password */
147 const struct passwd *pw; 147 const struct passwd *pw;
148 unsigned short ruid;
149 148
150#ifdef CONFIG_FEATURE_SHADOWPASSWDS 149#ifdef CONFIG_FEATURE_SHADOWPASSWDS
151 const struct spwd *sp; 150 const struct spwd *sp;
@@ -170,12 +169,8 @@ extern int passwd_main(int argc, char **argv)
170 bb_show_usage(); 169 bb_show_usage();
171 } 170 }
172 } 171 }
173 ruid = getuid(); 172 myname = (char *) bb_xstrdup(my_getpwuid(NULL, getuid(), -1));
174 pw = (struct passwd *) getpwuid(ruid); 173 /* exits on error */
175 if (!pw) {
176 bb_error_msg_and_die("Cannot determine your user name.");
177 }
178 myname = (char *) bb_xstrdup(pw->pw_name);
179 if (optind < argc) { 174 if (optind < argc) {
180 name = argv[optind]; 175 name = argv[optind];
181 } else { 176 } else {