aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2009-10-26 23:29:03 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-27 17:34:36 +0100
commite039e689e3c4baefb4b62703429aaf86eef1bd99 (patch)
tree41d75770e7e1bb36a2662fa9c273ab4c806dc3c3
parenta48308701a4d89d7cc0d0557cfabaec94a0bb3b0 (diff)
downloadbusybox-w32-e039e689e3c4baefb4b62703429aaf86eef1bd99.tar.gz
busybox-w32-e039e689e3c4baefb4b62703429aaf86eef1bd99.tar.bz2
busybox-w32-e039e689e3c4baefb4b62703429aaf86eef1bd99.zip
wall: new applet
text data bss dec hex filename 81 0 0 81 51 miscutils/wall.o Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/applets.h1
-rw-r--r--include/usage.h8
-rw-r--r--miscutils/Config.in6
-rw-r--r--miscutils/Kbuild1
-rw-r--r--miscutils/wall.c36
-rw-r--r--scripts/defconfig1
6 files changed, 53 insertions, 0 deletions
diff --git a/include/applets.h b/include/applets.h
index 134f21e2f..9683f1ec8 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -417,6 +417,7 @@ IF_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_DROP))
417IF_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_DROP)) 417IF_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_DROP))
418IF_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) 418IF_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE))
419IF_VOLNAME(APPLET(volname, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 419IF_VOLNAME(APPLET(volname, _BB_DIR_USR_BIN, _BB_SUID_DROP))
420IF_WALL(APPLET(wall, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE))
420IF_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_DROP)) 421IF_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_DROP))
421IF_WATCHDOG(APPLET(watchdog, _BB_DIR_SBIN, _BB_SUID_DROP)) 422IF_WATCHDOG(APPLET(watchdog, _BB_DIR_SBIN, _BB_SUID_DROP))
422IF_WC(APPLET(wc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 423IF_WC(APPLET(wc, _BB_DIR_USR_BIN, _BB_SUID_DROP))
diff --git a/include/usage.h b/include/usage.h
index 93eb2f6ba..72b6acc47 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -4950,6 +4950,14 @@
4950#define volname_full_usage "\n\n" \ 4950#define volname_full_usage "\n\n" \
4951 "Show CD volume name of the DEVICE (default /dev/cdrom)" 4951 "Show CD volume name of the DEVICE (default /dev/cdrom)"
4952 4952
4953#define wall_trivial_usage \
4954 "[file]"
4955#define wall_full_usage "\n\n" \
4956 "Write content of file or standard-input to all logged-in users"
4957#define wall_sample_usage \
4958 "echo foo | wall\n" \
4959 "wall ./mymessage"
4960
4953#define watch_trivial_usage \ 4961#define watch_trivial_usage \
4954 "[-n seconds] [-t] PROG [ARGS]" 4962 "[-n seconds] [-t] PROG [ARGS]"
4955#define watch_full_usage "\n\n" \ 4963#define watch_full_usage "\n\n" \
diff --git a/miscutils/Config.in b/miscutils/Config.in
index 9b804889b..842f7f9d2 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -612,6 +612,12 @@ config VOLNAME
612 help 612 help
613 Prints a CD-ROM volume name. 613 Prints a CD-ROM volume name.
614 614
615config WALL
616 bool "wall"
617 default n
618 help
619 Write a message to all users that are logged in.
620
615config WATCHDOG 621config WATCHDOG
616 bool "watchdog" 622 bool "watchdog"
617 default n 623 default n
diff --git a/miscutils/Kbuild b/miscutils/Kbuild
index d88cb39ac..22a9adb34 100644
--- a/miscutils/Kbuild
+++ b/miscutils/Kbuild
@@ -42,4 +42,5 @@ lib-$(CONFIG_TIME) += time.o
42lib-$(CONFIG_TIMEOUT) += timeout.o 42lib-$(CONFIG_TIMEOUT) += timeout.o
43lib-$(CONFIG_TTYSIZE) += ttysize.o 43lib-$(CONFIG_TTYSIZE) += ttysize.o
44lib-$(CONFIG_VOLNAME) += volname.o 44lib-$(CONFIG_VOLNAME) += volname.o
45lib-$(CONFIG_WALL) += wall.o
45lib-$(CONFIG_WATCHDOG) += watchdog.o 46lib-$(CONFIG_WATCHDOG) += watchdog.o
diff --git a/miscutils/wall.c b/miscutils/wall.c
new file mode 100644
index 000000000..2dbab60b4
--- /dev/null
+++ b/miscutils/wall.c
@@ -0,0 +1,36 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * wall - write a message to all logged-in users
4 * Copyright (c) 2009 Bernhard Reutner-Fischer
5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
7 */
8
9#include "libbb.h"
10#include <utmp.h>
11
12int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
13int wall_main(int argc UNUSED_PARAM, char **argv)
14{
15 struct utmp *ut;
16 char *msg;
17 int fd = argv[1] ? xopen(argv[1], O_RDONLY) : STDIN_FILENO;
18
19 msg = xmalloc_read(fd, NULL);
20 if (ENABLE_FEATURE_CLEAN_UP && argv[1])
21 close(fd);
22 setutent();
23 while ((ut = getutent()) != NULL) {
24 char *line;
25 if (ut->ut_type != USER_PROCESS)
26 continue;
27 line = concat_path_file("/dev", ut->ut_line);
28 xopen_xwrite_close(line, msg);
29 free(line);
30 }
31 if (ENABLE_FEATURE_CLEAN_UP) {
32 endutent();
33 free(msg);
34 }
35 return EXIT_SUCCESS;
36}
diff --git a/scripts/defconfig b/scripts/defconfig
index 797f275d1..f8a92d4c3 100644
--- a/scripts/defconfig
+++ b/scripts/defconfig
@@ -638,6 +638,7 @@ CONFIG_TIME=y
638CONFIG_TIMEOUT=y 638CONFIG_TIMEOUT=y
639CONFIG_TTYSIZE=y 639CONFIG_TTYSIZE=y
640CONFIG_VOLNAME=y 640CONFIG_VOLNAME=y
641CONFIG_WALL=y
641CONFIG_WATCHDOG=y 642CONFIG_WATCHDOG=y
642 643
643# 644#