aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
commitcad5364599eb5062d59e0c397ed638ddd61a8d5d (patch)
treea318d0f03aa076c74b576ea45dc543a5669e8e91 /loginutils
parente01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff)
downloadbusybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip
Major coreutils update.
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/addgroup.c23
-rw-r--r--loginutils/adduser.c38
-rw-r--r--loginutils/deluser.c38
-rw-r--r--loginutils/getty.c23
-rw-r--r--loginutils/login.c16
-rw-r--r--loginutils/passwd.c26
-rw-r--r--loginutils/su.c14
-rw-r--r--loginutils/sulogin.c6
-rw-r--r--loginutils/vlock.c15
9 files changed, 105 insertions, 94 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 1d754af8e..2e8188dec 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -54,16 +54,16 @@ static int group_study(const char *filename, struct group *g)
54 struct group *grp; 54 struct group *grp;
55 const int max = 65000; 55 const int max = 65000;
56 56
57 etc_group = xfopen(filename, "r"); 57 etc_group = bb_xfopen(filename, "r");
58 58
59 /* make sure gr_name isn't taken, make sure gid is kosher */ 59 /* make sure gr_name isn't taken, make sure gid is kosher */
60 desired = g->gr_gid; 60 desired = g->gr_gid;
61 while ((grp = fgetgrent(etc_group))) { 61 while ((grp = fgetgrent(etc_group))) {
62 if ((strcmp(grp->gr_name, g->gr_name)) == 0) { 62 if ((strcmp(grp->gr_name, g->gr_name)) == 0) {
63 error_msg_and_die("%s: group already in use\n", g->gr_name); 63 bb_error_msg_and_die("%s: group already in use\n", g->gr_name);
64 } 64 }
65 if ((desired) && grp->gr_gid == desired) { 65 if ((desired) && grp->gr_gid == desired) {
66 error_msg_and_die("%d: gid has already been allocated\n", 66 bb_error_msg_and_die("%d: gid has already been allocated\n",
67 desired); 67 desired);
68 } 68 }
69 if ((grp->gr_gid > g->gr_gid) && (grp->gr_gid < max)) { 69 if ((grp->gr_gid > g->gr_gid) && (grp->gr_gid < max)) {
@@ -89,7 +89,6 @@ static int addgroup(const char *filename, char *group, gid_t gid, const char *us
89 89
90#ifdef CONFIG_FEATURE_SHADOWPASSWDS 90#ifdef CONFIG_FEATURE_SHADOWPASSWDS
91 FILE *etc_gshadow; 91 FILE *etc_gshadow;
92 const char *gshadow = gshadow_file;
93#endif 92#endif
94 93
95 struct group gr; 94 struct group gr;
@@ -104,7 +103,7 @@ static int addgroup(const char *filename, char *group, gid_t gid, const char *us
104 return 1; 103 return 1;
105 104
106 /* add entry to group */ 105 /* add entry to group */
107 etc_group = xfopen(filename, "a"); 106 etc_group = bb_xfopen(filename, "a");
108 107
109 fprintf(etc_group, entryfmt, group, default_passwd, gr.gr_gid, user); 108 fprintf(etc_group, entryfmt, group, default_passwd, gr.gr_gid, user);
110 fclose(etc_group); 109 fclose(etc_group);
@@ -112,8 +111,8 @@ static int addgroup(const char *filename, char *group, gid_t gid, const char *us
112 111
113#ifdef CONFIG_FEATURE_SHADOWPASSWDS 112#ifdef CONFIG_FEATURE_SHADOWPASSWDS
114 /* add entry to gshadow if necessary */ 113 /* add entry to gshadow if necessary */
115 if (access(gshadow, F_OK|W_OK) == 0) { 114 if (access(bb_path_gshadow_file, F_OK|W_OK) == 0) {
116 etc_gshadow = xfopen(gshadow, "a"); 115 etc_gshadow = bb_xfopen(bb_path_gshadow_file, "a");
117 fprintf(etc_gshadow, "%s:!::\n", group); 116 fprintf(etc_gshadow, "%s:!::\n", group);
118 fclose(etc_gshadow); 117 fclose(etc_gshadow);
119 } 118 }
@@ -144,7 +143,7 @@ int addgroup_main(int argc, char **argv)
144 gid = strtol(optarg, NULL, 10); 143 gid = strtol(optarg, NULL, 10);
145 break; 144 break;
146 default: 145 default:
147 show_usage(); 146 bb_show_usage();
148 break; 147 break;
149 } 148 }
150 } 149 }
@@ -153,7 +152,7 @@ int addgroup_main(int argc, char **argv)
153 group = argv[optind]; 152 group = argv[optind];
154 optind++; 153 optind++;
155 } else { 154 } else {
156 show_usage(); 155 bb_show_usage();
157 } 156 }
158 157
159 if (optind < argc) { 158 if (optind < argc) {
@@ -164,12 +163,12 @@ int addgroup_main(int argc, char **argv)
164 } 163 }
165 164
166 if (geteuid() != 0) { 165 if (geteuid() != 0) {
167 error_msg_and_die 166 bb_error_msg_and_die
168 ("Only root may add a group to the system."); 167 ("Only root may add a group to the system.");
169 } 168 }
170 169
171 /* werk */ 170 /* werk */
172 return addgroup(group_file, group, gid, user); 171 return addgroup(bb_path_group_file, group, gid, user);
173} 172}
174 173
175/* $Id: addgroup.c,v 1.9 2003/01/09 18:53:53 andersen Exp $ */ 174/* $Id: addgroup.c,v 1.10 2003/03/19 09:12:20 mjn3 Exp $ */
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 3485611cc..cfaf860e0 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -66,7 +66,7 @@ static int passwd_study(const char *filename, struct passwd *p)
66 const int min = 500; 66 const int min = 500;
67 const int max = 65000; 67 const int max = 65000;
68 68
69 passwd = wfopen(filename, "r"); 69 passwd = bb_wfopen(filename, "r");
70 if (!passwd) 70 if (!passwd)
71 return 4; 71 return 4;
72 72
@@ -112,7 +112,7 @@ static void addgroup_wrapper(const char *login, gid_t gid)
112{ 112{
113 char *cmd; 113 char *cmd;
114 114
115 bb_asprintf(&cmd, "addgroup -g %d %s", gid, login); 115 bb_xasprintf(&cmd, "addgroup -g %d %s", gid, login);
116 system(cmd); 116 system(cmd);
117 free(cmd); 117 free(cmd);
118} 118}
@@ -123,7 +123,7 @@ static void passwd_wrapper(const char *login)
123{ 123{
124 static const char prog[] = "passwd"; 124 static const char prog[] = "passwd";
125 execlp(prog, prog, login, NULL); 125 execlp(prog, prog, login, NULL);
126 error_msg_and_die("Failed to execute '%s', you must set the password for '%s' manually", prog, login); 126 bb_error_msg_and_die("Failed to execute '%s', you must set the password for '%s' manually", prog, login);
127} 127}
128 128
129/* putpwent(3) remix */ 129/* putpwent(3) remix */
@@ -137,7 +137,7 @@ static int adduser(const char *filename, struct passwd *p)
137#endif 137#endif
138 138
139 /* make sure everything is kosher and setup uid && gid */ 139 /* make sure everything is kosher and setup uid && gid */
140 passwd = wfopen(filename, "a"); 140 passwd = bb_wfopen(filename, "a");
141 if (passwd == NULL) { 141 if (passwd == NULL) {
142 return 1; 142 return 1;
143 } 143 }
@@ -147,13 +147,13 @@ static int adduser(const char *filename, struct passwd *p)
147 r = passwd_study(filename, p); 147 r = passwd_study(filename, p);
148 if (r) { 148 if (r) {
149 if (r == 1) 149 if (r == 1)
150 error_msg("%s: login already in use", p->pw_name); 150 bb_error_msg("%s: login already in use", p->pw_name);
151 else if (r == 2) 151 else if (r == 2)
152 error_msg("illegal uid or no uids left"); 152 bb_error_msg("illegal uid or no uids left");
153 else if (r == 3) 153 else if (r == 3)
154 error_msg("group name %s already in use", p->pw_name); 154 bb_error_msg("group name %s already in use", p->pw_name);
155 else 155 else
156 error_msg("generic error."); 156 bb_error_msg("generic error.");
157 return 1; 157 return 1;
158 } 158 }
159 159
@@ -166,7 +166,7 @@ static int adduser(const char *filename, struct passwd *p)
166#ifdef CONFIG_FEATURE_SHADOWPASSWDS 166#ifdef CONFIG_FEATURE_SHADOWPASSWDS
167 /* add to shadow if necessary */ 167 /* add to shadow if necessary */
168 if (shadow_enabled) { 168 if (shadow_enabled) {
169 shadow = wfopen(shadow_file, "a"); 169 shadow = bb_wfopen(bb_path_shadow_file, "a");
170 if (shadow == NULL) { 170 if (shadow == NULL) {
171 return 1; 171 return 1;
172 } 172 }
@@ -191,16 +191,16 @@ static int adduser(const char *filename, struct passwd *p)
191 191
192 /* mkdir */ 192 /* mkdir */
193 if (mkdir(p->pw_dir, 0755)) { 193 if (mkdir(p->pw_dir, 0755)) {
194 perror_msg("%s", p->pw_dir); 194 bb_perror_msg("%s", p->pw_dir);
195 } 195 }
196 /* Set the owner and group so it is owned by the new user. */ 196 /* Set the owner and group so it is owned by the new user. */
197 if (chown(p->pw_dir, p->pw_uid, p->pw_gid)) { 197 if (chown(p->pw_dir, p->pw_uid, p->pw_gid)) {
198 perror_msg("%s", p->pw_dir); 198 bb_perror_msg("%s", p->pw_dir);
199 } 199 }
200 /* Now fix up the permissions to 2755. Can't do it before now 200 /* Now fix up the permissions to 2755. Can't do it before now
201 * since chown will clear the setgid bit */ 201 * since chown will clear the setgid bit */
202 if (chmod(p->pw_dir, 02755)) { 202 if (chmod(p->pw_dir, 02755)) {
203 perror_msg("%s", p->pw_dir); 203 bb_perror_msg("%s", p->pw_dir);
204 } 204 }
205 /* interactively set passwd */ 205 /* interactively set passwd */
206 passwd_wrapper(p->pw_name); 206 passwd_wrapper(p->pw_name);
@@ -234,7 +234,7 @@ int adduser_main(int argc, char **argv)
234 234
235 /* init */ 235 /* init */
236 if (argc < 2) { 236 if (argc < 2) {
237 show_usage(); 237 bb_show_usage();
238 } 238 }
239 gecos = default_gecos; 239 gecos = default_gecos;
240 shell = default_shell; 240 shell = default_shell;
@@ -252,18 +252,18 @@ int adduser_main(int argc, char **argv)
252 shell = optarg; 252 shell = optarg;
253 break; 253 break;
254 default: 254 default:
255 show_usage (); 255 bb_show_usage();
256 break; 256 break;
257 } 257 }
258 258
259 /* got root? */ 259 /* got root? */
260 if (i_am_not_root()) { 260 if (i_am_not_root()) {
261 error_msg_and_die( "Only root may add a user or group to the system."); 261 bb_error_msg_and_die( "Only root may add a user or group to the system.");
262 } 262 }
263 263
264 /* get login */ 264 /* get login */
265 if (optind >= argc) { 265 if (optind >= argc) {
266 error_msg_and_die( "no user specified"); 266 bb_error_msg_and_die( "no user specified");
267 } 267 }
268 login = argv[optind]; 268 login = argv[optind];
269 269
@@ -273,7 +273,7 @@ int adduser_main(int argc, char **argv)
273 } 273 }
274#ifdef CONFIG_FEATURE_SHADOWPASSWDS 274#ifdef CONFIG_FEATURE_SHADOWPASSWDS
275 /* is /etc/shadow in use? */ 275 /* is /etc/shadow in use? */
276 shadow_enabled = (0 == access(shadow_file, F_OK)); 276 shadow_enabled = (0 == access(bb_path_shadow_file, F_OK));
277#endif 277#endif
278 278
279 /* create a passwd struct */ 279 /* create a passwd struct */
@@ -286,7 +286,7 @@ int adduser_main(int argc, char **argv)
286 pw.pw_shell = (char *)shell; 286 pw.pw_shell = (char *)shell;
287 287
288 /* grand finale */ 288 /* grand finale */
289 return adduser(passwd_file, &pw); 289 return adduser(bb_path_passwd_file, &pw);
290} 290}
291 291
292/* $Id: adduser.c,v 1.4 2002/09/16 06:22:24 andersen Exp $ */ 292/* $Id: adduser.c,v 1.5 2003/03/19 09:12:20 mjn3 Exp $ */
diff --git a/loginutils/deluser.c b/loginutils/deluser.c
index c7d6ece64..ad62d41e0 100644
--- a/loginutils/deluser.c
+++ b/loginutils/deluser.c
@@ -116,19 +116,19 @@ int delgroup_main(int argc, char **argv)
116 int failure; 116 int failure;
117 117
118 if (argc != 2) { 118 if (argc != 2) {
119 show_usage(); 119 bb_show_usage();
120 } else { 120 } else {
121 121
122 failure = del_line_matching(argv[1], group_file); 122 failure = del_line_matching(argv[1], bb_path_group_file);
123#ifdef CONFIG_FEATURE_SHADOWPASSWDS 123#ifdef CONFIG_FEATURE_SHADOWPASSWDS
124 if (access(gshadow_file, W_OK) == 0) { 124 if (access(bb_path_gshadow_file, W_OK) == 0) {
125 /* EDR the |= works if the error is not 0, so he had it wrong */ 125 /* EDR the |= works if the error is not 0, so he had it wrong */
126 failure |= del_line_matching(argv[1], gshadow_file); 126 failure |= del_line_matching(argv[1], bb_path_gshadow_file);
127 } 127 }
128#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ 128#endif /* CONFIG_FEATURE_SHADOWPASSWDS */
129 /* if (!successful) { */ 129 /* if (!successful) { */
130 if (failure) { 130 if (failure) {
131 error_msg_and_die("%s: Group could not be removed\n", argv[1]); 131 bb_error_msg_and_die("%s: Group could not be removed\n", argv[1]);
132 } 132 }
133 133
134 } 134 }
@@ -142,38 +142,38 @@ int deluser_main(int argc, char **argv)
142 int failure; 142 int failure;
143 143
144 if (argc != 2) { 144 if (argc != 2) {
145 show_usage(); 145 bb_show_usage();
146 } else { 146 } else {
147 147
148 failure = del_line_matching(argv[1], passwd_file); 148 failure = del_line_matching(argv[1], bb_path_passwd_file);
149 /* if (!successful) { */ 149 /* if (!successful) { */
150 if (failure) { 150 if (failure) {
151 error_msg_and_die("%s: User could not be removed from %s\n", 151 bb_error_msg_and_die("%s: User could not be removed from %s\n",
152 argv[1], passwd_file); 152 argv[1], bb_path_passwd_file);
153 } 153 }
154#ifdef CONFIG_FEATURE_SHADOWPASSWDS 154#ifdef CONFIG_FEATURE_SHADOWPASSWDS
155 failure = del_line_matching(argv[1], shadow_file); 155 failure = del_line_matching(argv[1], bb_path_shadow_file);
156 /* if (!successful) { */ 156 /* if (!successful) { */
157 if (failure) { 157 if (failure) {
158 error_msg_and_die("%s: User could not be removed from %s\n", 158 bb_error_msg_and_die("%s: User could not be removed from %s\n",
159 argv[1], shadow_file); 159 argv[1], bb_path_shadow_file);
160 } 160 }
161 failure = del_line_matching(argv[1], gshadow_file); 161 failure = del_line_matching(argv[1], bb_path_gshadow_file);
162 /* if (!successful) { */ 162 /* if (!successful) { */
163 if (failure) { 163 if (failure) {
164 error_msg_and_die("%s: User could not be removed from %s\n", 164 bb_error_msg_and_die("%s: User could not be removed from %s\n",
165 argv[1], gshadow_file); 165 argv[1], bb_path_gshadow_file);
166 } 166 }
167#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ 167#endif /* CONFIG_FEATURE_SHADOWPASSWDS */
168 failure = del_line_matching(argv[1], group_file); 168 failure = del_line_matching(argv[1], bb_path_group_file);
169 /* if (!successful) { */ 169 /* if (!successful) { */
170 if (failure) { 170 if (failure) {
171 error_msg_and_die("%s: User could not be removed from %s\n", 171 bb_error_msg_and_die("%s: User could not be removed from %s\n",
172 argv[1], group_file); 172 argv[1], bb_path_group_file);
173 } 173 }
174 174
175 } 175 }
176 return (EXIT_SUCCESS); 176 return (EXIT_SUCCESS);
177} 177}
178 178
179/* $Id: deluser.c,v 1.2 2002/06/23 04:24:24 andersen Exp $ */ 179/* $Id: deluser.c,v 1.3 2003/03/19 09:12:20 mjn3 Exp $ */
diff --git a/loginutils/getty.c b/loginutils/getty.c
index b8be8b603..4219ff821 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -169,6 +169,7 @@ struct chardata init_chardata = {
169 0, /* no capslock */ 169 0, /* no capslock */
170}; 170};
171 171
172#if 0
172struct Speedtab { 173struct Speedtab {
173 long speed; 174 long speed;
174 int code; 175 int code;
@@ -211,6 +212,7 @@ static struct Speedtab speedtab[] = {
211#endif 212#endif
212 {0, 0}, 213 {0, 0},
213}; 214};
215#endif
214 216
215static void parse_args(int argc, char **argv, struct options *op); 217static void parse_args(int argc, char **argv, struct options *op);
216static void parse_speeds(struct options *op, char *arg); 218static void parse_speeds(struct options *op, char *arg);
@@ -263,7 +265,7 @@ int getty_main(int argc, char **argv)
263 }; 265 };
264 266
265#ifdef DEBUGGING 267#ifdef DEBUGGING
266 dbf = xfopen(DEBUGTERM, "w"); 268 dbf = bb_xfopen(DEBUGTERM, "w");
267 269
268 { 270 {
269 int i; 271 int i;
@@ -383,7 +385,7 @@ static void parse_args(int argc, char **argv, struct options *op)
383 switch (c) { 385 switch (c) {
384 case 'I': 386 case 'I':
385 if (!(op->initstring = strdup(optarg))) 387 if (!(op->initstring = strdup(optarg)))
386 error(memory_exhausted); 388 error(bb_msg_memory_exhausted);
387 389
388 { 390 {
389 const char *p; 391 const char *p;
@@ -396,7 +398,7 @@ static void parse_args(int argc, char **argv, struct options *op)
396 while (*p) { 398 while (*p) {
397 if (*p == '\\') { 399 if (*p == '\\') {
398 p++; 400 p++;
399 *q++ = process_escape_sequence(&p); 401 *q++ = bb_process_escape_sequence(&p);
400 } else { 402 } else {
401 *q++ = *p++; 403 *q++ = *p++;
402 } 404 }
@@ -439,12 +441,12 @@ static void parse_args(int argc, char **argv, struct options *op)
439 op->flags |= F_WAITCRLF; 441 op->flags |= F_WAITCRLF;
440 break; 442 break;
441 default: 443 default:
442 show_usage(); 444 bb_show_usage();
443 } 445 }
444 } 446 }
445 debug("after getopt loop\n"); 447 debug("after getopt loop\n");
446 if (argc < optind + 2) /* check parameter count */ 448 if (argc < optind + 2) /* check parameter count */
447 show_usage(); 449 bb_show_usage();
448 450
449 /* we loosen up a bit and accept both "baudrate tty" and "tty baudrate" */ 451 /* we loosen up a bit and accept both "baudrate tty" and "tty baudrate" */
450 if ('0' <= argv[optind][0] && argv[optind][0] <= '9') { 452 if ('0' <= argv[optind][0] && argv[optind][0] <= '9') {
@@ -953,6 +955,7 @@ static int caps_lock(const char *s)
953/* bcode - convert speed string to speed code; return 0 on failure */ 955/* bcode - convert speed string to speed code; return 0 on failure */
954static int bcode(const char *s) 956static int bcode(const char *s)
955{ 957{
958#if 0
956 struct Speedtab *sp; 959 struct Speedtab *sp;
957 long speed = atol(s); 960 long speed = atol(s);
958 961
@@ -960,6 +963,14 @@ static int bcode(const char *s)
960 if (sp->speed == speed) 963 if (sp->speed == speed)
961 return (sp->code); 964 return (sp->code);
962 return (0); 965 return (0);
966#else
967 int r;
968
969 if ((r = bb_value_to_baud(atol(s))) > 0) {
970 return r;
971 }
972 return 0;
973#endif
963} 974}
964 975
965/* error - report errors to console or syslog; only understands %s and %m */ 976/* error - report errors to console or syslog; only understands %s and %m */
@@ -982,7 +993,7 @@ static void error(const char *fmt, ...)
982 buf[0] = '\0'; 993 buf[0] = '\0';
983 bp = buf; 994 bp = buf;
984#else 995#else
985 strncpy(buf, applet_name, 256); 996 strncpy(buf, bb_applet_name, 256);
986 strncat(buf, ": ", 256); 997 strncat(buf, ": ", 256);
987 buf[255] = 0; 998 buf[255] = 0;
988 bp = buf + strlen(buf); 999 bp = buf + strlen(buf);
diff --git a/loginutils/login.c b/loginutils/login.c
index c1ea165c8..e239f421c 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -94,10 +94,10 @@ extern int login_main(int argc, char **argv)
94 * (-f root, *NOT* -froot). --marekm 94 * (-f root, *NOT* -froot). --marekm
95 */ 95 */
96 if ( optarg != argv[optind-1] ) 96 if ( optarg != argv[optind-1] )
97 show_usage ( ); 97 bb_show_usage( );
98 98
99 if ( !amroot ) /* Auth bypass only if real UID is zero */ 99 if ( !amroot ) /* Auth bypass only if real UID is zero */
100 error_msg_and_die ( "-f permission denied" ); 100 bb_error_msg_and_die ( "-f permission denied" );
101 101
102 safe_strncpy(username, optarg, USERNAME_SIZE); 102 safe_strncpy(username, optarg, USERNAME_SIZE);
103 opt_fflag = 1; 103 opt_fflag = 1;
@@ -106,7 +106,7 @@ extern int login_main(int argc, char **argv)
106 opt_host = optarg; 106 opt_host = optarg;
107 break; 107 break;
108 default: 108 default:
109 show_usage ( ); 109 bb_show_usage( );
110 } 110 }
111 } 111 }
112 112
@@ -275,11 +275,11 @@ static int login_prompt ( char *buf_name )
275 275
276static int check_nologin ( int amroot ) 276static int check_nologin ( int amroot )
277{ 277{
278 if ( access ( nologin_file, F_OK ) == 0 ) { 278 if ( access ( bb_path_nologin_file, F_OK ) == 0 ) {
279 FILE *fp; 279 FILE *fp;
280 int c; 280 int c;
281 281
282 if (( fp = fopen ( nologin_file, "r" ))) { 282 if (( fp = fopen ( bb_path_nologin_file, "r" ))) {
283 while (( c = getc ( fp )) != EOF ) 283 while (( c = getc ( fp )) != EOF )
284 putchar (( c == '\n' ) ? '\r' : c ); 284 putchar (( c == '\n' ) ? '\r' : c );
285 285
@@ -304,9 +304,9 @@ static int check_tty ( const char *tty )
304 int i; 304 int i;
305 char buf[BUFSIZ]; 305 char buf[BUFSIZ];
306 306
307 if (( fp = fopen ( securetty_file, "r" ))) { 307 if (( fp = fopen ( bb_path_securetty_file, "r" ))) {
308 while ( fgets ( buf, sizeof( buf ) - 1, fp )) { 308 while ( fgets ( buf, sizeof( buf ) - 1, fp )) {
309 for ( i = xstrlen( buf ) - 1; i >= 0; --i ) { 309 for ( i = bb_strlen( buf ) - 1; i >= 0; --i ) {
310 if ( !isspace ( buf[i] )) 310 if ( !isspace ( buf[i] ))
311 break; 311 break;
312 } 312 }
@@ -348,7 +348,7 @@ static void motd ( )
348 FILE *fp; 348 FILE *fp;
349 register int c; 349 register int c;
350 350
351 if (( fp = fopen ( motd_file, "r" ))) { 351 if (( fp = fopen ( bb_path_motd_file, "r" ))) {
352 while (( c = getc ( fp )) != EOF ) 352 while (( c = getc ( fp )) != EOF )
353 putchar ( c ); 353 putchar ( c );
354 fclose ( fp ); 354 fclose ( fp );
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index e02cc4b81..e8577066a 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -46,13 +46,13 @@ extern int update_passwd(const struct passwd *pw, char *crypt_pw)
46 struct stat sb; 46 struct stat sb;
47 struct flock lock; 47 struct flock lock;
48 48
49 if (access(shadow_file, F_OK) == 0) { 49 if (access(bb_path_shadow_file, F_OK) == 0) {
50 has_shadow = 1; 50 has_shadow = 1;
51 } 51 }
52 if (has_shadow) { 52 if (has_shadow) {
53 snprintf(filename, sizeof filename, "%s", shadow_file); 53 snprintf(filename, sizeof filename, "%s", bb_path_shadow_file);
54 } else { 54 } else {
55 snprintf(filename, sizeof filename, "%s", passwd_file); 55 snprintf(filename, sizeof filename, "%s", bb_path_passwd_file);
56 } 56 }
57 57
58 if (((fp = fopen(filename, "r+")) == 0) || (fstat(fileno(fp), &sb))) { 58 if (((fp = fopen(filename, "r+")) == 0) || (fstat(fileno(fp), &sb))) {
@@ -167,30 +167,30 @@ extern int passwd_main(int argc, char **argv)
167 uflg++; 167 uflg++;
168 break; 168 break;
169 default: 169 default:
170 show_usage(); 170 bb_show_usage();
171 } 171 }
172 } 172 }
173 ruid = getuid(); 173 ruid = getuid();
174 pw = (struct passwd *) getpwuid(ruid); 174 pw = (struct passwd *) getpwuid(ruid);
175 if (!pw) { 175 if (!pw) {
176 error_msg_and_die("Cannot determine your user name."); 176 bb_error_msg_and_die("Cannot determine your user name.");
177 } 177 }
178 myname = (char *) xstrdup(pw->pw_name); 178 myname = (char *) bb_xstrdup(pw->pw_name);
179 if (optind < argc) { 179 if (optind < argc) {
180 name = argv[optind]; 180 name = argv[optind];
181 } else { 181 } else {
182 name = myname; 182 name = myname;
183 } 183 }
184 if ((lflg || uflg || dflg) && (optind >= argc || !amroot)) { 184 if ((lflg || uflg || dflg) && (optind >= argc || !amroot)) {
185 show_usage(); 185 bb_show_usage();
186 } 186 }
187 pw = getpwnam(name); 187 pw = getpwnam(name);
188 if (!pw) { 188 if (!pw) {
189 error_msg_and_die("Unknown user %s\n", name); 189 bb_error_msg_and_die("Unknown user %s\n", name);
190 } 190 }
191 if (!amroot && pw->pw_uid != getuid()) { 191 if (!amroot && pw->pw_uid != getuid()) {
192 syslog(LOG_WARNING, "can't change pwd for `%s'", name); 192 syslog(LOG_WARNING, "can't change pwd for `%s'", name);
193 error_msg_and_die("Permission denied.\n"); 193 bb_error_msg_and_die("Permission denied.\n");
194 } 194 }
195#ifdef CONFIG_FEATURE_SHADOWPASSWDS 195#ifdef CONFIG_FEATURE_SHADOWPASSWDS
196 sp = getspnam(name); 196 sp = getspnam(name);
@@ -209,12 +209,12 @@ extern int passwd_main(int argc, char **argv)
209 if (!amroot) { 209 if (!amroot) {
210 if (cp[0] == '!') { 210 if (cp[0] == '!') {
211 syslog(LOG_WARNING, "password locked for `%s'", np); 211 syslog(LOG_WARNING, "password locked for `%s'", np);
212 error_msg_and_die( "The password for `%s' cannot be changed.\n", np); 212 bb_error_msg_and_die( "The password for `%s' cannot be changed.\n", np);
213 } 213 }
214 } 214 }
215 printf("Changing password for %s\n", name); 215 printf("Changing password for %s\n", name);
216 if (new_password(pw, amroot, algo)) { 216 if (new_password(pw, amroot, algo)) {
217 error_msg_and_die( "The password for %s is unchanged.\n", name); 217 bb_error_msg_and_die( "The password for %s is unchanged.\n", name);
218 } 218 }
219 } else if (lflg) { 219 } else if (lflg) {
220 if (crypt_passwd[0] != '!') { 220 if (crypt_passwd[0] != '!') {
@@ -238,7 +238,7 @@ extern int passwd_main(int argc, char **argv)
238 umask(077); 238 umask(077);
239 if (setuid(0)) { 239 if (setuid(0)) {
240 syslog(LOG_ERR, "can't setuid(0)"); 240 syslog(LOG_ERR, "can't setuid(0)");
241 error_msg_and_die( "Cannot change ID to root.\n"); 241 bb_error_msg_and_die( "Cannot change ID to root.\n");
242 } 242 }
243 if (!update_passwd(pw, crypt_passwd)) { 243 if (!update_passwd(pw, crypt_passwd)) {
244 syslog(LOG_INFO, "password for `%s' changed by user `%s'", name, 244 syslog(LOG_INFO, "password for `%s' changed by user `%s'", name,
@@ -246,7 +246,7 @@ extern int passwd_main(int argc, char **argv)
246 printf("Password changed.\n"); 246 printf("Password changed.\n");
247 } else { 247 } else {
248 syslog(LOG_WARNING, "an error occurred updating the password file"); 248 syslog(LOG_WARNING, "an error occurred updating the password file");
249 error_msg_and_die("An error occurred updating the password file.\n"); 249 bb_error_msg_and_die("An error occurred updating the password file.\n");
250 } 250 }
251 return (0); 251 return (0);
252} 252}
diff --git a/loginutils/su.c b/loginutils/su.c
index 6d427262e..5e40cf2e4 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -94,7 +94,7 @@ int su_main ( int argc, char **argv )
94 opt_loginshell = 1; 94 opt_loginshell = 1;
95 break; 95 break;
96 default: 96 default:
97 show_usage ( ); 97 bb_show_usage( );
98 break; 98 break;
99 } 99 }
100 } 100 }
@@ -114,7 +114,7 @@ int su_main ( int argc, char **argv )
114 114
115 pw = getpwnam ( opt_username ); 115 pw = getpwnam ( opt_username );
116 if ( !pw ) 116 if ( !pw )
117 error_msg_and_die ( "user %s does not exist", opt_username ); 117 bb_error_msg_and_die ( "user %s does not exist", opt_username );
118 118
119 /* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER 119 /* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER
120 is a username that is retrieved via NIS (YP), but that doesn't have 120 is a username that is retrieved via NIS (YP), but that doesn't have
@@ -127,15 +127,15 @@ int su_main ( int argc, char **argv )
127 the static data through the getlogin call from log_su. */ 127 the static data through the getlogin call from log_su. */
128 pw_copy = *pw; 128 pw_copy = *pw;
129 pw = &pw_copy; 129 pw = &pw_copy;
130 pw-> pw_name = xstrdup ( pw-> pw_name ); 130 pw-> pw_name = bb_xstrdup ( pw-> pw_name );
131 pw-> pw_dir = xstrdup ( pw-> pw_dir ); 131 pw-> pw_dir = bb_xstrdup ( pw-> pw_dir );
132 pw-> pw_shell = xstrdup ( pw-> pw_shell ); 132 pw-> pw_shell = bb_xstrdup ( pw-> pw_shell );
133 133
134 if (( getuid ( ) == 0 ) || correct_password ( pw )) 134 if (( getuid ( ) == 0 ) || correct_password ( pw ))
135 log_su ( pw, 1 ); 135 log_su ( pw, 1 );
136 else { 136 else {
137 log_su ( pw, 0 ); 137 log_su ( pw, 0 );
138 error_msg_and_die ( "incorrect password" ); 138 bb_error_msg_and_die ( "incorrect password" );
139 } 139 }
140 140
141 if ( !opt_shell && opt_preserve ) 141 if ( !opt_shell && opt_preserve )
@@ -152,7 +152,7 @@ int su_main ( int argc, char **argv )
152 } 152 }
153 153
154 if ( !opt_shell ) 154 if ( !opt_shell )
155 opt_shell = xstrdup ( pw-> pw_shell ); 155 opt_shell = bb_xstrdup ( pw-> pw_shell );
156 156
157 change_identity ( pw ); 157 change_identity ( pw );
158 setup_environment ( opt_shell, opt_loginshell, !opt_preserve, pw ); 158 setup_environment ( opt_shell, opt_loginshell, !opt_preserve, pw );
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index a654ffb89..bb4716e0d 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -117,9 +117,9 @@ extern int sulogin_main(int argc, char **argv)
117 } 117 }
118 } 118 }
119 } 119 }
120 if (access(passwd_file, 0) == -1) { 120 if (access(bb_path_passwd_file, 0) == -1) {
121 syslog(LOG_WARNING, "No password file\n"); 121 syslog(LOG_WARNING, "No password file\n");
122 error_msg_and_die("No password file\n"); 122 bb_error_msg_and_die("No password file\n");
123 } 123 }
124 if (!isatty(0) || !isatty(1) || !isatty(2)) { 124 if (!isatty(0) || !isatty(1) || !isatty(2)) {
125 exit(EXIT_FAILURE); 125 exit(EXIT_FAILURE);
@@ -135,7 +135,7 @@ extern int sulogin_main(int argc, char **argv)
135 alarm(timeout); 135 alarm(timeout);
136 if (!(pwd = getpwnam(name))) { 136 if (!(pwd = getpwnam(name))) {
137 syslog(LOG_WARNING, "No password entry for `root'\n"); 137 syslog(LOG_WARNING, "No password entry for `root'\n");
138 error_msg_and_die("No password entry for `root'\n"); 138 bb_error_msg_and_die("No password entry for `root'\n");
139 } 139 }
140 pwent = *pwd; 140 pwent = *pwd;
141#ifdef CONFIG_FEATURE_SHADOWPASSWDS 141#ifdef CONFIG_FEATURE_SHADOWPASSWDS
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 18f4b9407..7abf120d9 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -29,6 +29,7 @@
29 * It now works with md5, sha1, etc passwords. */ 29 * It now works with md5, sha1, etc passwords. */
30 30
31#include <stdio.h> 31#include <stdio.h>
32#include <stdlib.h>
32#include <sys/vt.h> 33#include <sys/vt.h>
33#include <signal.h> 34#include <signal.h>
34#include <string.h> 35#include <string.h>
@@ -96,26 +97,26 @@ extern int vlock_main(int argc, char **argv)
96 struct termios term; 97 struct termios term;
97 98
98 if (argc > 2) { 99 if (argc > 2) {
99 show_usage(); 100 bb_show_usage();
100 } 101 }
101 102
102 if (argc == 2) { 103 if (argc == 2) {
103 if (strncmp(argv[1], "-a", 2)) { 104 if (strncmp(argv[1], "-a", 2)) {
104 show_usage(); 105 bb_show_usage();
105 } else { 106 } else {
106 o_lock_all = 1; 107 o_lock_all = 1;
107 } 108 }
108 } 109 }
109 110
110 if ((pw = getpwuid(getuid())) == NULL) { 111 if ((pw = getpwuid(getuid())) == NULL) {
111 error_msg_and_die("no password for uid %d\n", getuid()); 112 bb_error_msg_and_die("no password for uid %d\n", getuid());
112 } 113 }
113#ifdef CONFIG_FEATURE_SHADOWPASSWDS 114#ifdef CONFIG_FEATURE_SHADOWPASSWDS
114 if ((strcmp(pw->pw_passwd, "x") == 0) 115 if ((strcmp(pw->pw_passwd, "x") == 0)
115 || (strcmp(pw->pw_passwd, "*") == 0)) { 116 || (strcmp(pw->pw_passwd, "*") == 0)) {
116 117
117 if ((spw = getspuid(getuid())) == NULL) { 118 if ((spw = getspuid(getuid())) == NULL) {
118 error_msg_and_die("could not read shadow password for uid %d: %s\n", 119 bb_error_msg_and_die("could not read shadow password for uid %d: %s\n",
119 getuid(), strerror(errno)); 120 getuid(), strerror(errno));
120 } 121 }
121 if (spw->sp_pwdp) { 122 if (spw->sp_pwdp) {
@@ -124,7 +125,7 @@ extern int vlock_main(int argc, char **argv)
124 } 125 }
125#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ 126#endif /* CONFIG_FEATURE_SHADOWPASSWDS */
126 if (pw->pw_passwd[0] == '!' || pw->pw_passwd[0] == '*') { 127 if (pw->pw_passwd[0] == '!' || pw->pw_passwd[0] == '*') {
127 error_msg_and_die("Account disabled for uid %d\n", getuid()); 128 bb_error_msg_and_die("Account disabled for uid %d\n", getuid());
128 } 129 }
129 130
130 /* we no longer need root privs */ 131 /* we no longer need root privs */
@@ -132,11 +133,11 @@ extern int vlock_main(int argc, char **argv)
132 setgid(getgid()); 133 setgid(getgid());
133 134
134 if ((vfd = open("/dev/tty", O_RDWR)) < 0) { 135 if ((vfd = open("/dev/tty", O_RDWR)) < 0) {
135 error_msg_and_die("/dev/tty"); 136 bb_error_msg_and_die("/dev/tty");
136 }; 137 };
137 138
138 if (ioctl(vfd, VT_GETMODE, &vtm) < 0) { 139 if (ioctl(vfd, VT_GETMODE, &vtm) < 0) {
139 error_msg_and_die("/dev/tty"); 140 bb_error_msg_and_die("/dev/tty");
140 }; 141 };
141 142
142 /* mask a bunch of signals */ 143 /* mask a bunch of signals */