2016-01-02 03:50:39 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
|
|
|
* /etc/securetty checking.
|
|
|
|
*
|
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
|
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
|
|
|
2017-04-13 21:25:05 +05:30
|
|
|
#if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM
|
2017-04-13 16:34:05 +05:30
|
|
|
int FAST_FUNC is_tty_secure(const char *short_tty)
|
2016-01-02 03:50:39 +05:30
|
|
|
{
|
|
|
|
char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */
|
|
|
|
parser_t *parser = config_open2("/etc/securetty", fopen_for_read);
|
|
|
|
while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) {
|
|
|
|
if (strcmp(buf, short_tty) == 0)
|
|
|
|
break;
|
|
|
|
buf = NULL;
|
|
|
|
}
|
|
|
|
config_close(parser);
|
|
|
|
/* buf != NULL here if config file was not found, empty
|
2017-04-13 16:34:05 +05:30
|
|
|
* or line was found which equals short_tty.
|
|
|
|
* In all these cases, we report "this tty is secure".
|
|
|
|
*/
|
2016-01-02 03:50:39 +05:30
|
|
|
return buf != NULL;
|
|
|
|
}
|
2017-04-13 21:25:05 +05:30
|
|
|
#endif
|