summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2003-06-06 14:36:41 +0000
committeryar <yar@FreeBSD.org>2003-06-06 14:36:41 +0000
commited74f4db3db61d7cc5afd1308077a87a2781331c (patch)
tree8dc44c3986f4a3e3ad40a3a2986dba5618a4bf7e /libexec
parenta2c945daf3d8e8bc56ea90992166d151d38a9215 (diff)
downloadFreeBSD-src-ed74f4db3db61d7cc5afd1308077a87a2781331c.zip
FreeBSD-src-ed74f4db3db61d7cc5afd1308077a87a2781331c.tar.gz
Fix some minor bugs, namely:
- Initialize "rval", which would be used uninitialized if al or pl options were set. - Don't pass an empty string to login(1) as a user name (this could be triggered by entering a name and then killing it with backspace or ^U.) - Don't loop endlessly if the al option specifies a bogus (i.e., not alphanumeric) auto-login name. - Don't pass a bogus user name to login(1) if a good name were entered and then killed with ^U. - Exit with status 0, not 1, on receiving an EOF character, since it's not a error condition. MFC after: 1 week
Diffstat (limited to 'libexec')
-rw-r--r--libexec/getty/main.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index aaff70c..5410ef7 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -344,6 +344,8 @@ main(int argc, char *argv[])
signal(SIGALRM, dingdong);
alarm(TO);
}
+
+ rval = 0;
if (AL) {
const char *p = AL;
char *q = name;
@@ -374,12 +376,20 @@ main(int argc, char *argv[])
oflush();
alarm(0);
signal(SIGALRM, SIG_DFL);
+ if (name[0] == '\0')
+ continue;
if (name[0] == '-') {
puts("user names may not start with '-'.");
continue;
}
- if (!(upper || lower || digit))
- continue;
+ if (!(upper || lower || digit)) {
+ if (AL) {
+ syslog(LOG_ERR,
+ "invalid auto-login name: %s", AL);
+ exit(1);
+ } else
+ continue;
+ }
set_flags(2);
if (crmod) {
tmode.c_iflag |= ICRNL;
@@ -564,7 +574,7 @@ getname(void)
}
if (c == EOT || c == CTRL('d'))
- exit(1);
+ exit(0);
if (c == '\r' || c == '\n' || np >= &name[sizeof name-1]) {
putf("\r\n");
break;
@@ -590,6 +600,7 @@ getname(void)
else if (np > name)
puts(" \r");
prompt();
+ digit = lower = upper = 0;
np = name;
continue;
} else if (isdigit(c))
OpenPOWER on IntegriCloud