1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include "libbb.h"
- int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
- int wall_main(int argc UNUSED_PARAM, char **argv)
- {
- struct utmpx *ut;
- char *msg;
- int fd;
- fd = STDIN_FILENO;
- if (argv[1]) {
-
- fd = xopen_as_uid_gid(argv[1], O_RDONLY, getuid(), getgid());
- }
- msg = xmalloc_read(fd, NULL);
- if (ENABLE_FEATURE_CLEAN_UP && argv[1])
- close(fd);
- setutxent();
- while ((ut = getutxent()) != NULL) {
- char *line;
- if (ut->ut_type != USER_PROCESS)
- continue;
- line = concat_path_file("/dev", ut->ut_line);
- xopen_xwrite_close(line, msg);
- free(line);
- }
- if (ENABLE_FEATURE_CLEAN_UP) {
- endutxent();
- free(msg);
- }
- return EXIT_SUCCESS;
- }
|