aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-13 13:01:14 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-13 13:01:14 +0000
commit5df955fce2fbdc5b2acc365a120327ff943403da (patch)
tree41763239e81807259b7532aeef540ebc4804ce3d
parentc9c893d4f59418c50c8eb42bd80390026e123dd8 (diff)
downloadbusybox-w32-5df955fce2fbdc5b2acc365a120327ff943403da.tar.gz
busybox-w32-5df955fce2fbdc5b2acc365a120327ff943403da.tar.bz2
busybox-w32-5df955fce2fbdc5b2acc365a120327ff943403da.zip
Do not fail password check if shadow password does not exist -
fall back to ordinary one Reduced usage of functions returning datain static buffers. (mostly passwd/group/shadow related): function old new delta correct_password 143 193 +50 sulogin_main 490 533 +43 adduser_main 732 774 +42 passwd_main 1875 1915 +40 addgroup_main 330 365 +35 bb_internal_getspnam 38 - -38 bb_internal_fgetpwent 38 - -38 bb_internal_fgetgrent 38 - -38 static.resultbuf 168 88 -80 static.buffer 1872 1104 -768 ------------------------------------------------------------------------------ (add/remove: 0/3 grow/shrink: 5/2 up/down: 210/-962) Total: -752 bytes
-rw-r--r--libbb/correct_password.c27
-rw-r--r--libbb/lineedit.c13
-rw-r--r--libpwdgrp/pwd_grp.c20
-rw-r--r--loginutils/addgroup.c45
-rw-r--r--loginutils/adduser.c35
-rw-r--r--loginutils/passwd.c26
-rw-r--r--loginutils/sulogin.c15
-rwxr-xr-xscripts/objsizes17
8 files changed, 120 insertions, 78 deletions
diff --git a/libbb/correct_password.c b/libbb/correct_password.c
index d031b2109..c515b26af 100644
--- a/libbb/correct_password.c
+++ b/libbb/correct_password.c
@@ -37,19 +37,24 @@
37 37
38int correct_password(const struct passwd *pw) 38int correct_password(const struct passwd *pw)
39{ 39{
40 char *unencrypted, *encrypted, *correct; 40 char *unencrypted, *encrypted;
41 const char *correct;
42#if ENABLE_FEATURE_SHADOWPASSWDS
43 /* Using _r function to avoid pulling in static buffers */
44 struct spwd spw;
45 struct spwd *result;
46 char buffer[256];
47#endif
41 48
42#ifdef CONFIG_FEATURE_SHADOWPASSWDS 49 correct = pw->pw_passwd;
50#if ENABLE_FEATURE_SHADOWPASSWDS
43 if (LONE_CHAR(pw->pw_passwd, 'x') || LONE_CHAR(pw->pw_passwd, '*')) { 51 if (LONE_CHAR(pw->pw_passwd, 'x') || LONE_CHAR(pw->pw_passwd, '*')) {
44 struct spwd *sp = getspnam(pw->pw_name); 52 if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result))
45 53 bb_error_msg("no valid shadow password, checking ordinary one");
46 if (!sp) 54 else
47 bb_error_msg_and_die("no valid shadow password"); 55 correct = spw.sp_pwdp;
48 56 }
49 correct = sp->sp_pwdp;
50 } else
51#endif 57#endif
52 correct = pw->pw_passwd;
53 58
54 if (!correct || correct[0] == '\0') 59 if (!correct || correct[0] == '\0')
55 return 1; 60 return 1;
@@ -60,5 +65,5 @@ int correct_password(const struct passwd *pw)
60 } 65 }
61 encrypted = crypt(unencrypted, correct); 66 encrypted = crypt(unencrypted, correct);
62 memset(unencrypted, 0, strlen(unencrypted)); 67 memset(unencrypted, 0, strlen(unencrypted));
63 return (!strcmp(encrypted, correct)) ? 1 : 0; 68 return strcmp(encrypted, correct) == 0;
64} 69}
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 16256f726..61b88fdc8 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -342,15 +342,18 @@ static void username_tab_completion(char *ud, char *with_shash_flg)
342 } 342 }
343 } else { 343 } else {
344 /* "~[^/]*" */ 344 /* "~[^/]*" */
345 setpwent(); 345 /* Using _r function to avoid pulling in static buffers */
346 char line_buff[PWD_BUFFER_SIZE];
347 struct passwd pwd;
348 struct passwd *result;
346 349
347 while ((entry = getpwent()) != NULL) { 350 setpwent();
351 while (!getpwent_r(&pwd, line_buff, sizeof(line_buff), &result)) {
348 /* Null usernames should result in all users as possible completions. */ 352 /* Null usernames should result in all users as possible completions. */
349 if ( /*!userlen || */ !strncmp(ud, entry->pw_name, userlen)) { 353 if (/*!userlen || */ strncmp(ud, pwd.pw_name, userlen) == 0) {
350 add_match(xasprintf("~%s/", entry->pw_name)); 354 add_match(xasprintf("~%s/", pwd.pw_name));
351 } 355 }
352 } 356 }
353
354 endpwent(); 357 endpwent();
355 } 358 }
356} 359}
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c
index 7aed265b9..7a8a23745 100644
--- a/libpwdgrp/pwd_grp.c
+++ b/libpwdgrp/pwd_grp.c
@@ -121,9 +121,10 @@ int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
121/**********************************************************************/ 121/**********************************************************************/
122/* For the various fget??ent funcs, return NULL on failure and a 122/* For the various fget??ent funcs, return NULL on failure and a
123 * pointer to the appropriate struct (statically allocated) on success. 123 * pointer to the appropriate struct (statically allocated) on success.
124 */ 124 * TODO: audit & stop using these in bbox, they pull in static buffers */
125/**********************************************************************/ 125/**********************************************************************/
126 126
127#if 0
127struct passwd *fgetpwent(FILE *stream) 128struct passwd *fgetpwent(FILE *stream)
128{ 129{
129 static char buffer[PWD_BUFFER_SIZE]; 130 static char buffer[PWD_BUFFER_SIZE];
@@ -143,8 +144,10 @@ struct group *fgetgrent(FILE *stream)
143 fgetgrent_r(stream, &resultbuf, buffer, sizeof(buffer), &result); 144 fgetgrent_r(stream, &resultbuf, buffer, sizeof(buffer), &result);
144 return result; 145 return result;
145} 146}
147#endif
146 148
147#if ENABLE_USE_BB_SHADOW 149#if ENABLE_USE_BB_SHADOW
150#if 0
148struct spwd *fgetspent(FILE *stream) 151struct spwd *fgetspent(FILE *stream)
149{ 152{
150 static char buffer[PWD_BUFFER_SIZE]; 153 static char buffer[PWD_BUFFER_SIZE];
@@ -154,6 +157,7 @@ struct spwd *fgetspent(FILE *stream)
154 fgetspent_r(stream, &resultbuf, buffer, sizeof(buffer), &result); 157 fgetspent_r(stream, &resultbuf, buffer, sizeof(buffer), &result);
155 return result; 158 return result;
156} 159}
160#endif
157 161
158int sgetspent_r(const char *string, struct spwd *result_buf, 162int sgetspent_r(const char *string, struct spwd *result_buf,
159 char *buffer, size_t buflen, struct spwd **result) 163 char *buffer, size_t buflen, struct spwd **result)
@@ -230,7 +234,9 @@ int sgetspent_r(const char *string, struct spwd *result_buf,
230#include "pwd_grp_internal.c" 234#include "pwd_grp_internal.c"
231 235
232/**********************************************************************/ 236/**********************************************************************/
237/* TODO: audit & stop using these in bbox, they pull in static buffers */
233 238
239/* This one has many users */
234struct passwd *getpwuid(uid_t uid) 240struct passwd *getpwuid(uid_t uid)
235{ 241{
236 static char buffer[PWD_BUFFER_SIZE]; 242 static char buffer[PWD_BUFFER_SIZE];
@@ -241,6 +247,7 @@ struct passwd *getpwuid(uid_t uid)
241 return result; 247 return result;
242} 248}
243 249
250/* This one has many users */
244struct group *getgrgid(gid_t gid) 251struct group *getgrgid(gid_t gid)
245{ 252{
246 static char buffer[GRP_BUFFER_SIZE]; 253 static char buffer[GRP_BUFFER_SIZE];
@@ -286,6 +293,7 @@ struct spwd *getspuid(uid_t uid)
286} 293}
287#endif 294#endif
288 295
296/* This one has many users */
289struct passwd *getpwnam(const char *name) 297struct passwd *getpwnam(const char *name)
290{ 298{
291 static char buffer[PWD_BUFFER_SIZE]; 299 static char buffer[PWD_BUFFER_SIZE];
@@ -296,6 +304,7 @@ struct passwd *getpwnam(const char *name)
296 return result; 304 return result;
297} 305}
298 306
307/* This one has many users */
299struct group *getgrnam(const char *name) 308struct group *getgrnam(const char *name)
300{ 309{
301 static char buffer[GRP_BUFFER_SIZE]; 310 static char buffer[GRP_BUFFER_SIZE];
@@ -306,7 +315,7 @@ struct group *getgrnam(const char *name)
306 return result; 315 return result;
307} 316}
308 317
309#if ENABLE_USE_BB_SHADOW 318#if 0 //ENABLE_USE_BB_SHADOW
310struct spwd *getspnam(const char *name) 319struct spwd *getspnam(const char *name)
311{ 320{
312 static char buffer[PWD_BUFFER_SIZE]; 321 static char buffer[PWD_BUFFER_SIZE];
@@ -318,6 +327,7 @@ struct spwd *getspnam(const char *name)
318} 327}
319#endif 328#endif
320 329
330/* This one doesn't use static buffers */
321int getpw(uid_t uid, char *buf) 331int getpw(uid_t uid, char *buf)
322{ 332{
323 struct passwd resultbuf; 333 struct passwd resultbuf;
@@ -325,7 +335,7 @@ int getpw(uid_t uid, char *buf)
325 char buffer[PWD_BUFFER_SIZE]; 335 char buffer[PWD_BUFFER_SIZE];
326 336
327 if (!buf) { 337 if (!buf) {
328 errno=EINVAL; 338 errno = EINVAL;
329 } else if (!getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result)) { 339 } else if (!getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result)) {
330 if (sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n", 340 if (sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n",
331 resultbuf.pw_name, resultbuf.pw_passwd, 341 resultbuf.pw_name, resultbuf.pw_passwd,
@@ -497,6 +507,7 @@ int getspent_r(struct spwd *resultbuf, char *buffer,
497} 507}
498#endif 508#endif
499 509
510#if 0
500struct passwd *getpwent(void) 511struct passwd *getpwent(void)
501{ 512{
502 static char line_buff[PWD_BUFFER_SIZE]; 513 static char line_buff[PWD_BUFFER_SIZE];
@@ -516,8 +527,9 @@ struct group *getgrent(void)
516 getgrent_r(&gr, line_buff, sizeof(line_buff), &result); 527 getgrent_r(&gr, line_buff, sizeof(line_buff), &result);
517 return result; 528 return result;
518} 529}
530#endif
519 531
520#if ENABLE_USE_BB_SHADOW 532#if 0 //ENABLE_USE_BB_SHADOW
521struct spwd *getspent(void) 533struct spwd *getspent(void)
522{ 534{
523 static char line_buff[PWD_BUFFER_SIZE]; 535 static char line_buff[PWD_BUFFER_SIZE];
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 768d2c061..78250a418 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -15,35 +15,37 @@
15 * return 1 on failure */ 15 * return 1 on failure */
16static int group_study(struct group *g) 16static int group_study(struct group *g)
17{ 17{
18 enum { max = 65000 };
18 FILE *etc_group; 19 FILE *etc_group;
19 gid_t desired; 20 gid_t desired;
20 21 /* Using _r function to avoid static buffers pulled in */
21 struct group *grp; 22 char buffer[256];
22 const int max = 65000; 23 struct group grp;
24 struct group *result;
23 25
24 etc_group = xfopen(bb_path_group_file, "r"); 26 etc_group = xfopen(bb_path_group_file, "r");
25 27
26 /* make sure gr_name isn't taken, make sure gid is kosher */ 28 /* make sure gr_name isn't taken, make sure gid is kosher */
27 desired = g->gr_gid; 29 desired = g->gr_gid;
28 while ((grp = fgetgrent(etc_group))) { 30 while (!fgetgrent_r(etc_group, &grp, buffer, sizeof(buffer), &result)) {
29 if ((strcmp(grp->gr_name, g->gr_name)) == 0) { 31 if ((strcmp(grp.gr_name, g->gr_name)) == 0) {
30 bb_error_msg_and_die("%s: group already in use", g->gr_name); 32 bb_error_msg_and_die("%s: group already in use", g->gr_name);
31 } 33 }
32 if ((desired) && grp->gr_gid == desired) { 34 if ((desired) && grp.gr_gid == desired) {
33 bb_error_msg_and_die("%d: gid already in use", 35 bb_error_msg_and_die("%d: gid already in use",
34 desired); 36 desired);
35 } 37 }
36 if ((grp->gr_gid > g->gr_gid) && (grp->gr_gid < max)) { 38 if ((grp.gr_gid > g->gr_gid) && (grp.gr_gid < max)) {
37 g->gr_gid = grp->gr_gid; 39 g->gr_gid = grp.gr_gid;
38 } 40 }
39 } 41 }
40 fclose(etc_group); 42 if (ENABLE_FEATURE_CLEAN_UP)
43 fclose(etc_group);
41 44
42 /* gid */ 45 /* gid */
46 g->gr_gid++;
43 if (desired) { 47 if (desired) {
44 g->gr_gid = desired; 48 g->gr_gid = desired;
45 } else {
46 g->gr_gid++;
47 } 49 }
48 /* return 1; */ 50 /* return 1; */
49 return 0; 51 return 0;
@@ -65,12 +67,16 @@ static int addgroup(char *group, gid_t gid, const char *user)
65 file = xfopen(bb_path_group_file, "a"); 67 file = xfopen(bb_path_group_file, "a");
66 /* group:passwd:gid:userlist */ 68 /* group:passwd:gid:userlist */
67 fprintf(file, "%s:%s:%d:%s\n", group, "x", gr.gr_gid, user); 69 fprintf(file, "%s:%s:%d:%s\n", group, "x", gr.gr_gid, user);
68 fclose(file); 70 if (ENABLE_FEATURE_CLEAN_UP)
71 fclose(file);
69 72
70#if ENABLE_FEATURE_SHADOWPASSWDS 73#if ENABLE_FEATURE_SHADOWPASSWDS
71 file = xfopen(bb_path_gshadow_file, "a"); 74 file = fopen_or_warn(bb_path_gshadow_file, "a");
72 fprintf(file, "%s:!::\n", group); 75 if (file) {
73 fclose(file); 76 fprintf(file, "%s:!::\n", group);
77 if (ENABLE_FEATURE_CLEAN_UP)
78 fclose(file);
79 }
74#endif 80#endif
75 81
76 /* return 1; */ 82 /* return 1; */
@@ -80,10 +86,8 @@ static int addgroup(char *group, gid_t gid, const char *user)
80/* 86/*
81 * addgroup will take a login_name as its first parameter. 87 * addgroup will take a login_name as its first parameter.
82 * 88 *
83 * gid 89 * gid can be customized via command-line parameters.
84 * 90 */
85 * can be customized via command-line parameters.
86 * ________________________________________________________________________ */
87int addgroup_main(int argc, char **argv); 91int addgroup_main(int argc, char **argv);
88int addgroup_main(int argc, char **argv) 92int addgroup_main(int argc, char **argv)
89{ 93{
@@ -103,6 +107,5 @@ int addgroup_main(int argc, char **argv)
103 bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); 107 bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
104 } 108 }
105 109
106 /* werk */ 110 return addgroup(argv[0], gid, argv[1] ? argv[1] : "");
107 return addgroup(argv[0], gid, (argv[1]) ? argv[1] : "");
108} 111}
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index e0cdd1ced..4c03790d8 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -10,19 +10,21 @@
10 10
11#include "busybox.h" 11#include "busybox.h"
12 12
13#define DONT_SET_PASS (1 << 4) 13#define OPT_DONT_SET_PASS (1 << 4)
14#define DONT_MAKE_HOME (1 << 6) 14#define OPT_DONT_MAKE_HOME (1 << 6)
15 15
16 16
17/* remix */ 17/* remix */
18/* EDR recoded such that the uid may be passed in *p */ 18/* EDR recoded such that the uid may be passed in *p */
19static int passwd_study(const char *filename, struct passwd *p) 19static int passwd_study(const char *filename, struct passwd *p)
20{ 20{
21 struct passwd *pw; 21 enum { min = 500, max = 65000 };
22 FILE *passwd; 22 FILE *passwd;
23 23 /* We are using reentrant fgetpwent_r() in order to avoid
24 const int min = 500; 24 * pulling in static buffers from libc (think static build here) */
25 const int max = 65000; 25 char buffer[256];
26 struct passwd pw;
27 struct passwd *result;
26 28
27 passwd = xfopen(filename, "r"); 29 passwd = xfopen(filename, "r");
28 30
@@ -34,14 +36,14 @@ static int passwd_study(const char *filename, struct passwd *p)
34 * make sure login isn't taken; 36 * make sure login isn't taken;
35 * find free uid and gid; 37 * find free uid and gid;
36 */ 38 */
37 while ((pw = fgetpwent(passwd))) { 39 while (!fgetpwent_r(passwd, &pw, buffer, sizeof(buffer), &result)) {
38 if (strcmp(pw->pw_name, p->pw_name) == 0) { 40 if (strcmp(pw.pw_name, p->pw_name) == 0) {
39 /* return 0; */ 41 /* return 0; */
40 return 1; 42 return 1;
41 } 43 }
42 if ((pw->pw_uid >= p->pw_uid) && (pw->pw_uid < max) 44 if ((pw.pw_uid >= p->pw_uid) && (pw.pw_uid < max)
43 && (pw->pw_uid >= min)) { 45 && (pw.pw_uid >= min)) {
44 p->pw_uid = pw->pw_uid + 1; 46 p->pw_uid = pw.pw_uid + 1;
45 } 47 }
46 } 48 }
47 49
@@ -85,7 +87,7 @@ static void passwd_wrapper(const char *login)
85} 87}
86 88
87/* putpwent(3) remix */ 89/* putpwent(3) remix */
88static int adduser(struct passwd *p, unsigned long flags) 90static int adduser(struct passwd *p)
89{ 91{
90 FILE *file; 92 FILE *file;
91 int addgroup = !p->pw_gid; 93 int addgroup = !p->pw_gid;
@@ -130,7 +132,7 @@ static int adduser(struct passwd *p, unsigned long flags)
130 /* Clear the umask for this process so it doesn't 132 /* Clear the umask for this process so it doesn't
131 * * screw up the permissions on the mkdir and chown. */ 133 * * screw up the permissions on the mkdir and chown. */
132 umask(0); 134 umask(0);
133 if (!(flags & DONT_MAKE_HOME)) { 135 if (!(option_mask32 & OPT_DONT_MAKE_HOME)) {
134 /* Set the owner and group so it is owned by the new user, 136 /* Set the owner and group so it is owned by the new user,
135 then fix up the permissions to 2755. Can't do it before 137 then fix up the permissions to 2755. Can't do it before
136 since chown will clear the setgid bit */ 138 since chown will clear the setgid bit */
@@ -141,7 +143,7 @@ static int adduser(struct passwd *p, unsigned long flags)
141 } 143 }
142 } 144 }
143 145
144 if (!(flags & DONT_SET_PASS)) { 146 if (!(option_mask32 & OPT_DONT_SET_PASS)) {
145 /* interactively set passwd */ 147 /* interactively set passwd */
146 passwd_wrapper(p->pw_name); 148 passwd_wrapper(p->pw_name);
147 } 149 }
@@ -163,7 +165,6 @@ int adduser_main(int argc, char **argv)
163{ 165{
164 struct passwd pw; 166 struct passwd pw;
165 const char *usegroup = NULL; 167 const char *usegroup = NULL;
166 unsigned long flags;
167 168
168 /* got root? */ 169 /* got root? */
169 if (geteuid()) { 170 if (geteuid()) {
@@ -176,7 +177,7 @@ int adduser_main(int argc, char **argv)
176 177
177 /* check for min, max and missing args and exit on error */ 178 /* check for min, max and missing args and exit on error */
178 opt_complementary = "-1:?1:?"; 179 opt_complementary = "-1:?1:?";
179 flags = getopt32(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup); 180 getopt32(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup);
180 181
181 /* create string for $HOME if not specified already */ 182 /* create string for $HOME if not specified already */
182 if (!pw.pw_dir) { 183 if (!pw.pw_dir) {
@@ -191,5 +192,5 @@ int adduser_main(int argc, char **argv)
191 pw.pw_gid = usegroup ? xgroup2gid(usegroup) : 0; /* exits on failure */ 192 pw.pw_gid = usegroup ? xgroup2gid(usegroup) : 0; /* exits on failure */
192 193
193 /* grand finale */ 194 /* grand finale */
194 return adduser(&pw, flags); 195 return adduser(&pw);
195} 196}
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 4531e63a6..b937ce45e 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -252,6 +252,13 @@ int passwd_main(int argc, char **argv)
252 struct rlimit rlimit_fsize; 252 struct rlimit rlimit_fsize;
253 char c; 253 char c;
254 254
255#if ENABLE_FEATURE_SHADOWPASSWDS
256 /* Using _r function to avoid pulling in static buffers */
257 struct spwd spw;
258 struct spwd *result;
259 char buffer[256];
260#endif
261
255 logmode = LOGMODE_BOTH; 262 logmode = LOGMODE_BOTH;
256 openlog(applet_name, LOG_NOWAIT, LOG_AUTH); 263 openlog(applet_name, LOG_NOWAIT, LOG_AUTH);
257 opt = getopt32(argc, argv, "a:lud", &opt_a); 264 opt = getopt32(argc, argv, "a:lud", &opt_a);
@@ -278,17 +285,14 @@ int passwd_main(int argc, char **argv)
278 285
279 filename = bb_path_passwd_file; 286 filename = bb_path_passwd_file;
280#if ENABLE_FEATURE_SHADOWPASSWDS 287#if ENABLE_FEATURE_SHADOWPASSWDS
281 { 288 if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result)) {
282 struct spwd *sp = getspnam(name); 289 /* LOGMODE_BOTH */
283 if (!sp) { 290 bb_error_msg("no record of %s in %s, using %s",
284 /* LOGMODE_BOTH */ 291 name, bb_path_shadow_file,
285 bb_error_msg("no record of %s in %s, using %s", 292 bb_path_passwd_file);
286 name, bb_path_shadow_file, 293 } else {
287 bb_path_passwd_file); 294 filename = bb_path_shadow_file;
288 } else { 295 pw->pw_passwd = spw.sp_pwdp;
289 filename = bb_path_shadow_file;
290 pw->pw_passwd = sp->sp_pwdp;
291 }
292 } 296 }
293#endif 297#endif
294 298
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 8e3095c87..38503f7b1 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -43,6 +43,12 @@ int sulogin_main(int argc, char **argv)
43 const char * const *p; 43 const char * const *p;
44 struct passwd *pwd; 44 struct passwd *pwd;
45 const char *shell; 45 const char *shell;
46#if ENABLE_FEATURE_SHADOWPASSWDS
47 /* Using _r function to avoid pulling in static buffers */
48 char buffer[256];
49 struct spwd spw;
50 struct spwd *result;
51#endif
46 52
47 logmode = LOGMODE_BOTH; 53 logmode = LOGMODE_BOTH;
48 openlog(applet_name, 0, LOG_AUTH); 54 openlog(applet_name, 0, LOG_AUTH);
@@ -76,13 +82,10 @@ int sulogin_main(int argc, char **argv)
76 } 82 }
77 83
78#if ENABLE_FEATURE_SHADOWPASSWDS 84#if ENABLE_FEATURE_SHADOWPASSWDS
79 { 85 if (getspnam_r(pwd->pw_name, &spw, buffer, sizeof(buffer), &result)) {
80 struct spwd *spwd = getspnam(pwd->pw_name); 86 goto auth_error;
81 if (!spwd) {
82 goto auth_error;
83 }
84 pwd->pw_passwd = spwd->sp_pwdp;
85 } 87 }
88 pwd->pw_passwd = spw.sp_pwdp;
86#endif 89#endif
87 90
88 while (1) { 91 while (1) {
diff --git a/scripts/objsizes b/scripts/objsizes
index 44fbce1aa..09de11407 100755
--- a/scripts/objsizes
+++ b/scripts/objsizes
@@ -1,8 +1,19 @@
1#!/bin/sh 1#!/bin/sh
2 2
3printf "%9s %11s %9s %9s %s\n" "text+data" text+rodata rwdata bss filename 3t_text=0
4t_data=0
5t_bss=0
6
7printf "%9s %11s %9s %9s %s\n" "text+data" "text+rodata" rwdata bss filename
8
4find -name '*.o' | grep -v '^\./scripts/' | grep -vF built-in.o \ 9find -name '*.o' | grep -v '^\./scripts/' | grep -vF built-in.o \
5| sed 's:^\./::' | xargs "${CROSS_COMPILE}size" | grep '^ *[0-9]' \ 10| sed 's:^\./::' | xargs "${CROSS_COMPILE}size" | grep '^ *[0-9]' \
6| while read text data bss dec hex filename; do 11| {
12while read text data bss dec hex filename; do
13 t_text=$((t_text+text))
14 t_data=$((t_data+data))
15 t_bss=$((t_bss+bss))
7 printf "%9d %11d %9d %9d %s\n" $((text+data)) $text $data $bss "$filename" 16 printf "%9d %11d %9d %9d %s\n" $((text+data)) $text $data $bss "$filename"
8done | sort -r 17done
18printf "%9d %11d %9d %9d %s\n" $((t_text+t_data)) $t_text $t_data $t_bss "TOTAL"
19} | sort -r