]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Properly guard calls to sigaction
authoruyjulian <uyjulian@gmail.com>
Sat, 27 May 2023 06:36:55 +0000 (01:36 -0500)
committerMartin Matuška <martin@matuska.de>
Thu, 13 Jul 2023 22:21:13 +0000 (00:21 +0200)
libarchive_fe/passphrase.c

index edf72d147182470d5d4373d34a61f5ccce09be67..1cae6a7bc80a84eaa2342ad2d1dbb428e6ff53dc 100644 (file)
@@ -171,8 +171,10 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
        int input, output, save_errno, i, need_restart;
        char ch, *p, *end;
        struct termios term, oterm;
+#ifdef HAVE_SIGACTION
        struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm;
        struct sigaction savetstp, savettin, savettou, savepipe;
+#endif
 
        /* I suppose we could alloc on demand in this case (XXX). */
        if (bufsiz == 0) {
@@ -221,6 +223,7 @@ restart:
                oterm.c_lflag |= ECHO;
        }
 
+#ifdef HAVE_SIGACTION
        /*
         * Catch signals that would otherwise cause the user to end
         * up with echo turned off in the shell.  Don't worry about
@@ -239,6 +242,7 @@ restart:
        (void)sigaction(SIGTSTP, &sa, &savetstp);
        (void)sigaction(SIGTTIN, &sa, &savettin);
        (void)sigaction(SIGTTOU, &sa, &savettou);
+#endif
 
        if (!(flags & RPP_STDIN)) {
                int r = write(output, prompt, strlen(prompt));
@@ -276,6 +280,7 @@ restart:
                        continue;
                signo[SIGTTOU] = sigttou;
        }
+#ifdef HAVE_SIGACTION
        (void)sigaction(SIGALRM, &savealrm, NULL);
        (void)sigaction(SIGHUP, &savehup, NULL);
        (void)sigaction(SIGINT, &saveint, NULL);
@@ -285,6 +290,7 @@ restart:
        (void)sigaction(SIGTSTP, &savetstp, NULL);
        (void)sigaction(SIGTTIN, &savettin, NULL);
        (void)sigaction(SIGTTOU, &savettou, NULL);
+#endif
        if (input != STDIN_FILENO)
                (void)close(input);