aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-08 17:26:20 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-08 17:26:20 +0000
commit6bbd174593d1e116351a9402b5bd237afbe3cb89 (patch)
tree6c64442dcf798d22ca4508f5d09cd8be72a3de00
parent942e4291fee9266dee2795e0f2628878b4f757e0 (diff)
downloadbusybox-w32-6bbd174593d1e116351a9402b5bd237afbe3cb89.tar.gz
busybox-w32-6bbd174593d1e116351a9402b5bd237afbe3cb89.tar.bz2
busybox-w32-6bbd174593d1e116351a9402b5bd237afbe3cb89.zip
login: small fixes like \n removal, bb_error_msg'ification, etc.
-rw-r--r--loginutils/login.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index 82be87eb3..c05ec066a 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -58,7 +58,7 @@ static void motd(void);
58 58
59static void alarm_handler(int sig ATTRIBUTE_UNUSED) 59static void alarm_handler(int sig ATTRIBUTE_UNUSED)
60{ 60{
61 fprintf(stderr, "\nLogin timed out after %d seconds.\n", TIMEOUT); 61 fprintf(stderr, "\r\nLogin timed out after %s seconds\r\n", TIMEOUT);
62 exit(EXIT_SUCCESS); 62 exit(EXIT_SUCCESS);
63} 63}
64 64
@@ -146,14 +146,15 @@ int login_main(int argc, char **argv)
146#ifdef CONFIG_FEATURE_UTMP 146#ifdef CONFIG_FEATURE_UTMP
147 safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host)); 147 safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host));
148#endif 148#endif
149 snprintf(fromhost, sizeof(fromhost)-1, " on `%.100s' from `%.200s'", tty, opt_host); 149 snprintf(fromhost, sizeof(fromhost)-1, " on `%.100s' from "
150 "`%.200s'", tty, opt_host);
150 } 151 }
151 else 152 else
152 snprintf(fromhost, sizeof(fromhost)-1, " on `%.100s'", tty); 153 snprintf(fromhost, sizeof(fromhost)-1, " on `%.100s'", tty);
153 154
154 bb_setpgrp; 155 bb_setpgrp;
155 156
156 openlog("login", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); 157 openlog(bb_applet_name, LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
157 158
158 while (1) { 159 while (1) {
159 failed = 0; 160 failed = 0;
@@ -207,7 +208,7 @@ auth_ok:
207 puts("Login incorrect"); 208 puts("Login incorrect");
208 username[0] = 0; 209 username[0] = 0;
209 if (++count == 3) { 210 if (++count == 3) {
210 syslog(LOG_WARNING, "invalid password for `%s'%s'\n", pw->pw_name, fromhost); 211 syslog(LOG_WARNING, "invalid password for `%s'%s", pw->pw_name, fromhost);
211 return EXIT_FAILURE; 212 return EXIT_FAILURE;
212 } 213 }
213 } 214 }
@@ -230,29 +231,26 @@ auth_ok:
230 security_context_t old_tty_sid, new_tty_sid; 231 security_context_t old_tty_sid, new_tty_sid;
231 232
232 if (get_default_context(username, NULL, &user_sid)) { 233 if (get_default_context(username, NULL, &user_sid)) {
233 fprintf(stderr, "Unable to get SID for %s\n", username); 234 bb_error_msg_and_die("unable to get SID for %s",
234 exit(1); 235 username);
235 } 236 }
236 if (getfilecon(full_tty, &old_tty_sid) < 0) { 237 if (getfilecon(full_tty, &old_tty_sid) < 0) {
237 fprintf(stderr, "getfilecon(%.100s) failed: " 238 bb_perror_msg_and_die("getfilecon(%.100s) failed",
238 "%.100s\n", full_tty, strerror(errno)); 239 full_tty);
239 return EXIT_FAILURE;
240 } 240 }
241 if (security_compute_relabel(user_sid, old_tty_sid, SECCLASS_CHR_FILE, 241 if (security_compute_relabel(user_sid, old_tty_sid,
242 &new_tty_sid) != 0) { 242 SECCLASS_CHR_FILE, &new_tty_sid) != 0) {
243 fprintf(stderr, "security_change_sid(%.100s) failed: " 243 bb_perror_msg_and_die("security_change_sid(%.100s) failed",
244 "%.100s\n", full_tty, strerror(errno)); 244 full_tty);
245 return EXIT_FAILURE;
246 } 245 }
247 if (setfilecon(full_tty, new_tty_sid) != 0) { 246 if (setfilecon(full_tty, new_tty_sid) != 0) {
248 fprintf(stderr, "chsid(%.100s, %s) failed: " 247 bb_perror_msg_and_die("chsid(%.100s, %s) failed",
249 "%.100s\n", full_tty, new_tty_sid, strerror(errno)); 248 full_tty, new_tty_sid);
250 return EXIT_FAILURE;
251 } 249 }
252 } 250 }
253#endif 251#endif
254 if (!is_my_tty(full_tty)) 252 if (!is_my_tty(full_tty))
255 syslog(LOG_ERR, "unable to determine TTY name, got %s\n", full_tty); 253 syslog(LOG_ERR, "unable to determine TTY name, got %s", full_tty);
256 254
257 /* Try these, but don't complain if they fail 255 /* Try these, but don't complain if they fail
258 * (for example when the root fs is read only) */ 256 * (for example when the root fs is read only) */
@@ -290,7 +288,7 @@ auth_ok:
290 signal(SIGALRM, SIG_DFL); /* default alarm signal */ 288 signal(SIGALRM, SIG_DFL); /* default alarm signal */
291 289
292 if (pw->pw_uid == 0) 290 if (pw->pw_uid == 0)
293 syslog(LOG_INFO, "root login %s\n", fromhost); 291 syslog(LOG_INFO, "root login %s", fromhost);
294#ifdef CONFIG_SELINUX 292#ifdef CONFIG_SELINUX
295 /* well, a simple setexeccon() here would do the job as well, 293 /* well, a simple setexeccon() here would do the job as well,
296 * but let's play the game for now */ 294 * but let's play the game for now */