1 /* vi: set sw=4 ts=4: */
3 * wall - write a message to all logged-in users
4 * Copyright (c) 2009 Bernhard Reutner-Fischer
6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 //config: bool "wall (2.5 kb)"
11 //config: depends on FEATURE_UTMP
13 //config: Write a message to all users that are logged in.
15 /* Needs to be run by root or be suid root - needs to write to /dev/TTY: */
16 //applet:IF_WALL(APPLET(wall, BB_DIR_USR_BIN, BB_SUID_REQUIRE))
18 //kbuild:lib-$(CONFIG_WALL) += wall.o
20 //usage:#define wall_trivial_usage
22 //usage:#define wall_full_usage "\n\n"
23 //usage: "Write content of FILE or stdin to all logged-in users"
25 //usage:#define wall_sample_usage
26 //usage: "echo foo | wall\n"
27 //usage: "wall ./mymessage"
31 int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
32 int wall_main(int argc UNUSED_PARAM, char **argv)
40 /* The applet is setuid.
41 * Access to the file must be under user's uid/gid.
43 fd = xopen_as_uid_gid(argv[1], O_RDONLY, getuid(), getgid());
45 msg = xmalloc_read(fd, NULL);
46 if (ENABLE_FEATURE_CLEAN_UP && argv[1])
49 while ((ut = getutxent()) != NULL) {
51 if (ut->ut_type != USER_PROCESS)
53 line = concat_path_file("/dev", ut->ut_line);
54 xopen_xwrite_close(line, msg);
57 if (ENABLE_FEATURE_CLEAN_UP) {