]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
su: Drop unneeded char buffers
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 9 Jan 2026 16:28:53 +0000 (17:28 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Sun, 11 Jan 2026 14:46:59 +0000 (15:46 +0100)
Since kill_child is no signal handler any longer, it is safe to call the
gettext macros directly and only when needed.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Ruihan Li <lrh2000@pku.edu.cn>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/su.c

index 9f32733ee2d0b3888a79d60be56f8c9b83952e32..6268f50fae3f09a53559e0dcf86780eca8b5333e 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -60,7 +60,6 @@
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "string/sprintf/aprintf.h"
-#include "string/sprintf/snprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strcpy/strtcpy.h"
@@ -94,8 +93,6 @@ static char caller_name[BUFSIZ];
 static bool change_environment = true;
 
 #ifdef USE_PAM
-static char kill_msg[256];
-static char wait_msg[256];
 static pam_handle_t *pamh = NULL;
 static volatile sig_atomic_t caught = 0;
 static volatile sig_atomic_t timeout = 0;
@@ -176,9 +173,9 @@ kill_child(int)
 {
        if (0 != pid_child) {
                (void) kill (-pid_child, SIGKILL);
-               (void) write_full(STDERR_FILENO, kill_msg, strlen(kill_msg));
+               fputs(_(" ...killed.\n"), stderr);
        } else {
-               (void) write_full(STDERR_FILENO, wait_msg, strlen(wait_msg));
+               fputs(_(" ...waiting for child to terminate.\n"), stderr);
        }
        _exit (255);
 }
@@ -403,9 +400,6 @@ static void prepare_pam_close_session (void)
                              stderr);
                (void) kill (-pid_child, caught);
 
-               stprintf_a(kill_msg, _(" ...killed.\n"));
-               stprintf_a(wait_msg, _(" ...waiting for child to terminate.\n"));
-
                /* Any signals other than SIGCHLD and SIGALRM will no longer have any effect,
                 * so it's time to block all of them. */
                sigfillset (&ourset);