aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-04 19:16:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-04 19:16:01 +0200
commit6514785f95878911b3ec88e2367234df74c14cd4 (patch)
treed5212cbe1de8c0fe15cb42e0c83c00ea6d77403c /util-linux
parent947b2391c07f8a11f7bd4658f77cd03172fc221a (diff)
downloadbusybox-6514785f95878911b3ec88e2367234df74c14cd4.tar.gz
mesg: make in NOFORK
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/mesg.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/util-linux/mesg.c b/util-linux/mesg.c
index c4371eb24..91c05317e 100644
--- a/util-linux/mesg.c
+++ b/util-linux/mesg.c
@@ -26,7 +26,7 @@
//config: If you set this option to N, "mesg y" will enable writing
//config: by anybody at all. This is not recommended.
-//applet:IF_MESG(APPLET(mesg, BB_DIR_USR_BIN, BB_SUID_DROP))
+//applet:IF_MESG(APPLET_NOFORK(mesg, mesg, BB_DIR_USR_BIN, BB_SUID_DROP, mesg))
//kbuild:lib-$(CONFIG_MESG) += mesg.o
@@ -60,10 +60,15 @@ int mesg_main(int argc UNUSED_PARAM, char **argv)
bb_show_usage();
}
+ /* We are a NOFORK applet.
+ * (Not that it's very useful, but code is trivially NOFORK-safe).
+ * Play nice. Do not leak anything.
+ */
+
if (!isatty(STDIN_FILENO))
bb_error_msg_and_die("not a tty");
- xfstat(STDIN_FILENO, &sb, "stderr");
+ xfstat(STDIN_FILENO, &sb, "stdin");
if (c == 0) {
puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
return EXIT_SUCCESS;