Last change
on this file since 2838 was 2725, checked in by Bruno Cornec, 13 years ago |
- Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
|
-
Property svn:eol-style
set to
native
|
File size:
829 bytes
|
Rev | Line | |
---|
[2725] | 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 source tree.
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | #include "libbb.h"
|
---|
| 10 | #include <utmp.h>
|
---|
| 11 |
|
---|
| 12 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
| 13 | int 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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.