[PATCH] nologin: new applet.

Natanael Copa natanael.copa at gmail.com
Fri Nov 4 11:41:13 UTC 2011


Displays a message that an account is not available and
exits non-zero. It is intended as a replacement shell field
for accounts that have been disabled.

If the file /etc/nologin.txt exists, displays its contents
to the user instead of the default message.

login_main                                           -     108    +108
.rodata                                           101552  101625     +73
packed_usage                                       23057   23072     +15
applet_names                                        1882    1890      +8
applet_main                                         1140    1144      +4
bbconfig_config_bz2                                 5214    5217      +3
applet_nameofs                                       570     572      +2
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 6/0 up/down: 213/0)             Total: 213 bytes
   text    data     bss     dec     hex filename
 888199    6311    4712  899222   db896 busybox_old
 888436    6315    4712  899463   db987 busybox_unstripped

Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
---
 loginutils/nologin.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
 create mode 100644 loginutils/nologin.c

diff --git a/loginutils/nologin.c b/loginutils/nologin.c
new file mode 100644
index 0000000..521538e
--- /dev/null
+++ b/loginutils/nologin.c
@@ -0,0 +1,41 @@
+/* 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:	  displays a message that an account is not available and
+//config:	  exits non-zero. It is intended as a replacement shell field
+//config:	  for accounts that have been disabled.
+//config:	  
+//config:	  If the file /etc/nologin.txt exists, displays its contents
+//config:	  to the user instead of the default message.
+
+//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>
+
+int nologin_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int nologin_main(int argc UNUSED_PARAM, char **argv)
+{
+	int fd;
+	fd = open("/etc/nologin.txt", O_RDONLY);
+	if (bb_copyfd_eof(fd, STDOUT_FILENO) == -1)
+		bb_error_msg_and_die("this account is not available");
+	if (ENABLE_FEATURE_CLEAN_UP)
+		close(fd);
+	return 1;
+}
+
-- 
1.7.7.2



More information about the busybox mailing list