aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Kbuild.src1
-rw-r--r--libbb/securetty.c22
2 files changed, 23 insertions, 0 deletions
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index 898a51a89..49493c501 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -83,6 +83,7 @@ lib-y += safe_gethostname.o
83lib-y += safe_poll.o 83lib-y += safe_poll.o
84lib-y += safe_strncpy.o 84lib-y += safe_strncpy.o
85lib-y += safe_write.o 85lib-y += safe_write.o
86lib-y += securetty.o
86lib-y += setup_environment.o 87lib-y += setup_environment.o
87lib-y += signals.o 88lib-y += signals.o
88lib-y += simplify_path.o 89lib-y += simplify_path.o
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 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * /etc/securetty checking.
4 *
5 * Licensed under GPLv2, see file LICENSE in this source tree.
6 */
7#include "libbb.h"
8
9int FAST_FUNC check_securetty(const char *short_tty)
10{
11 char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */
12 parser_t *parser = config_open2("/etc/securetty", fopen_for_read);
13 while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) {
14 if (strcmp(buf, short_tty) == 0)
15 break;
16 buf = NULL;
17 }
18 config_close(parser);
19 /* buf != NULL here if config file was not found, empty
20 * or line was found which equals short_tty */
21 return buf != NULL;
22}