aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/nologin.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-02-02 15:16:30 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-02-02 15:16:30 +0000
commit1a7dacd2b946f0fce327179a2eec84c4aaeb60d3 (patch)
treedcbeedab30ec9ab0b64ebff7d7d2edba447c01f9 /main/busybox/nologin.c
parent13155070b8b08528e1344453ef825c654d5d8c13 (diff)
downloadaports-1a7dacd2b946f0fce327179a2eec84c4aaeb60d3.tar.gz
aports-1a7dacd2b946f0fce327179a2eec84c4aaeb60d3.tar.bz2
aports-1a7dacd2b946f0fce327179a2eec84c4aaeb60d3.tar.xz
main/busybox: add support for nologin applet
This will never be upstreamed, I have tried. It is fairly simple to maintain separately so I think we will try that.
Diffstat (limited to 'main/busybox/nologin.c')
-rw-r--r--main/busybox/nologin.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/main/busybox/nologin.c b/main/busybox/nologin.c
new file mode 100644
index 0000000000..e0a4c56c77
--- /dev/null
+++ b/main/busybox/nologin.c
@@ -0,0 +1,38 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * nologin implementation for busybox
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+//config:config NOLOGIN
+//config: bool "nologin"
+//config: default n
+//config: help
+//config: nologin is a tool that is supposed to be the shell for user accounts
+//config: that are not supposed to login.
+
+//applet:IF_NOLOGIN(APPLET(nologin, BB_DIR_SBIN, BB_SUID_DROP))
+//kbuild:lib-$(CONFIG_NOLOGIN) += nologin.o
+
+//usage:#define nologin_trivial_usage
+//usage: ""
+//usage:#define nologin_full_usage "\n\n"
+//usage: "politely refuse a login\n"
+
+#include "libbb.h"
+#include <syslog.h>
+
+#define _NOLOGIN_TXT "/etc/nologin.txt"
+
+int nologin_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int nologin_main(int argc UNUSED_PARAM, char **argv)
+{
+ int fd;
+ fd = open(_NOLOGIN_TXT, O_RDONLY);
+ if (bb_copyfd_eof(fd, STDOUT_FILENO) == -1)
+ bb_error_msg_and_die("this account is not available");
+ close(fd);
+ return 1;
+}
+