aboutsummaryrefslogtreecommitdiff
path: root/libbb/securetty.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-05-29 14:20:10 +0100
committerRon Yorston <rmy@pobox.com>2017-05-29 14:34:28 +0100
commitda4f331955bed8afda670afcd58d524a04a0faa9 (patch)
treef6a3879aefdd714240f8c022375f687b512d2238 /libbb/securetty.c
parent74163a535fd21f5fcca4c052d2e7c192d3e264fa (diff)
parent6683d1cbb44859f549f87f882545b84b9369585c (diff)
downloadbusybox-w32-da4f331955bed8afda670afcd58d524a04a0faa9.tar.gz
busybox-w32-da4f331955bed8afda670afcd58d524a04a0faa9.tar.bz2
busybox-w32-da4f331955bed8afda670afcd58d524a04a0faa9.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/securetty.c')
-rw-r--r--libbb/securetty.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libbb/securetty.c b/libbb/securetty.c
new file mode 100644
index 000000000..21354e2fa
--- /dev/null
+++ b/libbb/securetty.c
@@ -0,0 +1,26 @@
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
9#if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM
10int FAST_FUNC is_tty_secure(const char *short_tty)
11{
12 char *buf = (char*)"/etc/securetty"; /* any non-NULL is ok */
13 parser_t *parser = config_open2("/etc/securetty", fopen_for_read);
14 while (config_read(parser, &buf, 1, 1, "# \t", PARSE_NORMAL)) {
15 if (strcmp(buf, short_tty) == 0)
16 break;
17 buf = NULL;
18 }
19 config_close(parser);
20 /* buf != NULL here if config file was not found, empty
21 * or line was found which equals short_tty.
22 * In all these cases, we report "this tty is secure".
23 */
24 return buf != NULL;
25}
26#endif