summaryrefslogtreecommitdiff
path: root/src/shutdown/hpr_wall.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-02-12 18:17:50 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-02-12 18:17:50 +0000
commitf94e976efbdfdd885ecc81745542bedf315768fd (patch)
tree79ebb144d9a3cc62ab851c753414adb94b168438 /src/shutdown/hpr_wall.c
parent355a75e08bbc8af8af97576bad07471dd1b431d8 (diff)
downloads6-linux-init-f94e976efbdfdd885ecc81745542bedf315768fd.tar.xz
bugfix: wall message on non-immediate shutdown(8)
Diffstat (limited to 'src/shutdown/hpr_wall.c')
-rw-r--r--src/shutdown/hpr_wall.c35
1 files changed, 3 insertions, 32 deletions
diff --git a/src/shutdown/hpr_wall.c b/src/shutdown/hpr_wall.c
index 2ce3dce..9810a94 100644
--- a/src/shutdown/hpr_wall.c
+++ b/src/shutdown/hpr_wall.c
@@ -1,41 +1,12 @@
/* ISC license. */
#include <string.h>
-#include <utmpx.h>
-
-#include <skalibs/allreadwrite.h>
-#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
-#include <skalibs/posixishard.h>
+#include <sys/uio.h>
#include "hpr.h"
-#ifndef UT_LINESIZE
-#define UT_LINESIZE 32
-#endif
-
void hpr_wall (char const *s)
{
- size_t n = strlen(s) ;
- char tty[10 + UT_LINESIZE] = "/dev/" ;
- char msg[n+1] ;
- memcpy(msg, s, n) ;
- msg[n++] = '\n' ;
- setutxent() ;
- for (;;)
- {
- size_t linelen ;
- int fd ;
- struct utmpx *utx = getutxent() ;
- if (!utx) break ;
- if (utx->ut_type != USER_PROCESS) continue ;
- linelen = strnlen(utx->ut_line, UT_LINESIZE) ;
- memcpy(tty + 5, utx->ut_line, linelen) ;
- tty[5 + linelen] = 0 ;
- fd = open_append(tty) ;
- if (fd == -1) continue ;
- allwrite(fd, msg, n) ;
- fd_close(fd) ;
- }
- endutxent() ;
+ struct iovec v[2] = { { .iov_base = (char *)s, .iov_len = strlen(s) }, { .iov_base = "\n", .iov_len = 1 } } ;
+ hpr_wallv(v, 2) ;
}