diff options
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/login.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/loginutils/login.c b/loginutils/login.c index 5a75ed2..8732b99 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -139,20 +139,17 @@ static ALWAYS_INLINE void die_if_nologin(void) {} #if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM static int check_securetty(void) { - char *buf; - int ret = 1; + char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */ parser_t *parser = config_open2("/etc/securetty", fopen_for_read); - /* N.B. A missing securetty file is not an error. */ - if (parser) { - while (config_read(parser, &buf, 1, 1, "# \t", 0)) { - if (strcmp(buf, short_tty) == 0) - break; - } - config_close(parser); - // buf != NULL here iff config file was empty (OK) or buf equals short_tty (OK) - ret = buf != NULL; + while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) { + if (strcmp(buf, short_tty) == 0) + break; + buf = NULL; } - return ret; + config_close(parser); + /* buf != NULL here if config file was not found, empty + * or line was found which equals short_tty */ + return buf != NULL; } #else static ALWAYS_INLINE int check_securetty(void) { return 1; } |