aboutsummaryrefslogtreecommitdiff
path: root/libbb/login.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/login.c')
-rw-r--r--libbb/login.c119
1 files changed, 53 insertions, 66 deletions
diff --git a/libbb/login.c b/libbb/login.c
index 646995b0b..6ebb9a6a0 100644
--- a/libbb/login.c
+++ b/libbb/login.c
@@ -36,83 +36,70 @@ void print_login_issue(const char *issue_file, const char *tty)
puts("\r"); /* start a new line */
- if ((fd = fopen(issue_file, "r"))) {
- while ((c = fgetc(fd)) != EOF) {
- outbuf = buf;
- buf[0] = c;
- if(c == '\n') {
- buf[1] = '\r';
- buf[2] = 0;
- } else {
- buf[1] = 0;
- }
- if (c == '\\' || c == '%') {
- c = fgetc(fd);
- switch (c) {
- case 's':
- outbuf = uts.sysname;
- break;
-
- case 'n':
- outbuf = uts.nodename;
- break;
-
- case 'r':
- outbuf = uts.release;
- break;
-
- case 'v':
- outbuf = uts.version;
- break;
-
- case 'm':
- outbuf = uts.machine;
- break;
-
- case 'D':
- case 'o':
- c = getdomainname(buf, sizeof(buf) - 1);
- buf[c >= 0 ? c : 0] = '\0';
- break;
-
- case 'd':
- strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
- break;
-
- case 't':
- strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
- break;
-
- case 'h':
- gethostname(buf, sizeof(buf) - 1);
- buf[sizeof(buf) - 1] = '\0';
- break;
-
- case 'l':
- outbuf = tty;
- break;
-
- default:
- buf[0] = c;
- }
+ fd = fopen(issue_file, "r");
+ if (!fd)
+ return;
+ while ((c = fgetc(fd)) != EOF) {
+ outbuf = buf;
+ buf[0] = c;
+ buf[1] = '\0';
+ if(c == '\n') {
+ buf[1] = '\r';
+ buf[2] = '\0';
+ }
+ if (c == '\\' || c == '%') {
+ c = fgetc(fd);
+ switch (c) {
+ case 's':
+ outbuf = uts.sysname;
+ break;
+ case 'n':
+ outbuf = uts.nodename;
+ break;
+ case 'r':
+ outbuf = uts.release;
+ break;
+ case 'v':
+ outbuf = uts.version;
+ break;
+ case 'm':
+ outbuf = uts.machine;
+ break;
+ case 'D':
+ case 'o':
+ c = getdomainname(buf, sizeof(buf) - 1);
+ buf[c >= 0 ? c : 0] = '\0';
+ break;
+ case 'd':
+ strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
+ break;
+ case 't':
+ strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
+ break;
+ case 'h':
+ gethostname(buf, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
+ break;
+ case 'l':
+ outbuf = tty;
+ break;
+ default:
+ buf[0] = c;
}
- fputs(outbuf, stdout);
}
-
- fclose(fd);
-
- fflush(stdout);
+ fputs(outbuf, stdout);
}
+ fclose(fd);
+ fflush(stdout);
}
void print_login_prompt(void)
{
char buf[MAXHOSTNAMELEN+1];
- if(gethostname(buf, MAXHOSTNAMELEN) == 0)
+ if (gethostname(buf, MAXHOSTNAMELEN) == 0)
fputs(buf, stdout);
fputs(LOGIN, stdout);
fflush(stdout);
}
-