From 517a82c5b6b5e279f3e96a6774445a2952ca312b Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Sat, 2 Jan 2016 00:20:39 +0200 Subject: login: move check_securetty to libbb Signed-off-by: Kaarle Ritvanen Signed-off-by: Denys Vlasenko --- libbb/securetty.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 libbb/securetty.c (limited to 'libbb/securetty.c') diff --git a/libbb/securetty.c b/libbb/securetty.c new file mode 100644 index 000000000..176cee129 --- /dev/null +++ b/libbb/securetty.c @@ -0,0 +1,22 @@ +/* vi: set sw=4 ts=4: */ +/* + * /etc/securetty checking. + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ +#include "libbb.h" + +int FAST_FUNC check_securetty(const char *short_tty) +{ + 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 + * or line was found which equals short_tty */ + return buf != NULL; +} -- cgit v1.2.3