]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
- (bal) redo how we handle 'mysignal()'. Move it to
authorBen Lindstrom <mouring@eviladmin.org>
Mon, 25 Aug 2003 01:16:21 +0000 (01:16 +0000)
committerBen Lindstrom <mouring@eviladmin.org>
Mon, 25 Aug 2003 01:16:21 +0000 (01:16 +0000)
   openbsd-compat/bsd-misc.c, s/mysignal/signal/ and #define signal to
   be our 'mysignal' by default.  OK djm@

ChangeLog
entropy.c
misc.c
misc.h
openbsd-compat/bsd-misc.c
openbsd-compat/bsd-misc.h
progressmeter.c
sshd.c
sshpty.c

index 956a5e3a834e12947566dfdef934ea8b37649364..6ea448a37b99fd6d452f4b5ec71991bdf93e025a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,10 @@
  - (djm) Bug #621: Select OpenSC keys by usage attributes. Patch from 
    larsch@trustcenter.de
  - (bal) openbsd-compat/ OpenBSD updates.  Mostly licensing, ansifications
-   and minor fixes.
+   and minor fixes. OK djm@
+ - (bal) redo how we handle 'mysignal()'.  Move it to 
+   openbsd-compat/bsd-misc.c, s/mysignal/signal/ and #define signal to
+   be our 'mysignal' by default.  OK djm@
 
 20030822
  - (djm) s/get_progname/ssh_get_progname/g to avoid conflict with Heimdal 
  - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
    Report from murple@murple.net, diagnosis from dtucker@zip.com.au
 
-$Id: ChangeLog,v 1.2900 2003/08/25 01:10:51 mouring Exp $
+$Id: ChangeLog,v 1.2901 2003/08/25 01:16:21 mouring Exp $
index a16ea10b3848d732073b59ed5c4d4df7fa609bb9..216879786e3a2df228f66bde4647f07465f3322a 100644 (file)
--- a/entropy.c
+++ b/entropy.c
@@ -45,7 +45,7 @@
  * XXX: we should tell the child how many bytes we need.
  */
 
-RCSID("$Id: entropy.c,v 1.45 2003/05/16 05:51:45 djm Exp $");
+RCSID("$Id: entropy.c,v 1.46 2003/08/25 01:16:21 mouring Exp $");
 
 #ifndef OPENSSL_PRNG_ONLY
 #define RANDOM_SEED_SIZE 48
@@ -75,7 +75,7 @@ seed_rng(void)
        if (pipe(p) == -1)
                fatal("pipe: %s", strerror(errno));
 
-       old_sigchld = mysignal(SIGCHLD, SIG_DFL);
+       old_sigchld = signal(SIGCHLD, SIG_DFL);
        if ((pid = fork()) == -1)
                fatal("Couldn't fork: %s", strerror(errno));
        if (pid == 0) {
@@ -116,7 +116,7 @@ seed_rng(void)
        if (waitpid(pid, &ret, 0) == -1)
               fatal("Couldn't wait for ssh-rand-helper completion: %s", 
                   strerror(errno));
-       mysignal(SIGCHLD, old_sigchld);
+       signal(SIGCHLD, old_sigchld);
 
        /* We don't mind if the child exits upon a SIGPIPE */
        if (!WIFEXITED(ret) && 
diff --git a/misc.c b/misc.c
index ff196619270abcd6788637244fe135be1b6e6d4a..c457a952c5b3ffcd5c3335f55dba7869966b805c 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -323,29 +323,3 @@ addargs(arglist *args, char *fmt, ...)
        args->list[args->num++] = xstrdup(buf);
        args->list[args->num] = NULL;
 }
-
-mysig_t
-mysignal(int sig, mysig_t act)
-{
-#ifdef HAVE_SIGACTION
-       struct sigaction sa, osa;
-
-       if (sigaction(sig, NULL, &osa) == -1)
-               return (mysig_t) -1;
-       if (osa.sa_handler != act) {
-               memset(&sa, 0, sizeof(sa));
-               sigemptyset(&sa.sa_mask);
-               sa.sa_flags = 0;
-#if defined(SA_INTERRUPT)
-               if (sig == SIGALRM)
-                       sa.sa_flags |= SA_INTERRUPT;
-#endif
-               sa.sa_handler = act;
-               if (sigaction(sig, &sa, NULL) == -1)
-                       return (mysig_t) -1;
-       }
-       return (osa.sa_handler);
-#else
-       return (signal(sig, act));
-#endif
-}
diff --git a/misc.h b/misc.h
index 3b4b879676f497b3b2d322af55b8ac66f57a0fef..6d2869b3612246729660b97163e112ee20dafa00 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -31,7 +31,3 @@ struct arglist {
        int     nalloc;
 };
 void    addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3)));
-
-/* wrapper for signal interface */
-typedef void (*mysig_t)(int);
-mysig_t mysignal(int sig, mysig_t act);
index 56cb45ade6aeb7242ab61a34e6f9114bd2d0bd70..08b089bdc66d03a6410f622d480db4653dd65fcc 100644 (file)
@@ -25,7 +25,7 @@
 #include "includes.h"
 #include "xmalloc.h"
 
-RCSID("$Id: bsd-misc.c,v 1.18 2003/08/21 23:34:42 djm Exp $");
+RCSID("$Id: bsd-misc.c,v 1.19 2003/08/25 01:16:21 mouring Exp $");
 
 /*
  * NB. duplicate __progname in case it is an alias for argv[0]
@@ -200,3 +200,29 @@ tcsendbreak(int fd, int duration)
 # endif
 }
 #endif /* HAVE_TCSENDBREAK */
+
+mysig_t
+mysignal(int sig, mysig_t act)
+{
+#ifdef HAVE_SIGACTION
+       struct sigaction sa, osa;
+
+       if (sigaction(sig, NULL, &osa) == -1)
+               return (mysig_t) -1;
+       if (osa.sa_handler != act) {
+               memset(&sa, 0, sizeof(sa));
+               sigemptyset(&sa.sa_mask);
+               sa.sa_flags = 0;
+#ifdef SA_INTERRUPT
+               if (sig == SIGALRM)
+                       sa.sa_flags |= SA_INTERRUPT;
+#endif
+               sa.sa_handler = act;
+               if (sigaction(sig, &sa, NULL) == -1)
+                       return (mysig_t) -1;
+       }
+       return (osa.sa_handler);
+#else
+       return (signal(sig, act));
+#endif
+}
index 2857de59bda4fe807e19779762f1620698306ba4..0d6076ab09a203b7a758059b96bd5452a835f705 100644 (file)
@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* $Id: bsd-misc.h,v 1.11 2003/08/21 23:34:42 djm Exp $ */
+/* $Id: bsd-misc.h,v 1.12 2003/08/25 01:16:22 mouring Exp $ */
 
 #ifndef _BSD_MISC_H
 #define _BSD_MISC_H
@@ -97,4 +97,10 @@ pid_t tcgetpgrp(int);
 int tcsendbreak(int, int);
 #endif
 
+/* wrapper for signal interface */
+typedef void (*mysig_t)(int);
+mysig_t mysignal(int sig, mysig_t act);
+
+#define signal(a,b) mysignal(a,b)
+
 #endif /* _BSD_MISC_H */
index 170d869f4d233f498c668ac48b61a3e02ca63b5a..9fe8cfa41f32fc8f4ad6fc5932f7bbc6d14740b1 100644 (file)
@@ -212,7 +212,7 @@ update_progress_meter(int ignore)
        if (can_output())
                refresh_progress_meter();
 
-       mysignal(SIGALRM, update_progress_meter);
+       signal(SIGALRM, update_progress_meter);
        alarm(UPDATE_INTERVAL);
        errno = save_errno;
 }
@@ -243,7 +243,7 @@ start_progress_meter(char *f, off_t filesize, off_t *stat)
        if (can_output())
                refresh_progress_meter();
 
-       mysignal(SIGALRM, update_progress_meter);
+       signal(SIGALRM, update_progress_meter);
        alarm(UPDATE_INTERVAL);
 }
 
diff --git a/sshd.c b/sshd.c
index 0e1bde3a3003055dbcf8d2059e4c2d8e59aefd83..8d04f6a7477b4812f6ec3513e879066ed2a24ab3 100644 (file)
--- a/sshd.c
+++ b/sshd.c
@@ -1368,7 +1368,7 @@ main(int ac, char **av)
                                if ((options.protocol & SSH_PROTO_1) &&
                                    key_used == 0) {
                                        /* Schedule server key regeneration alarm. */
-                                       mysignal(SIGALRM, key_regeneration_alarm);
+                                       signal(SIGALRM, key_regeneration_alarm);
                                        alarm(options.key_regeneration_time);
                                        key_used = 1;
                                }
@@ -1457,7 +1457,7 @@ main(int ac, char **av)
         * mode; it is just annoying to have the server exit just when you
         * are about to discover the bug.
         */
-       mysignal(SIGALRM, grace_alarm_handler);
+       signal(SIGALRM, grace_alarm_handler);
        if (!debug_flag)
                alarm(options.login_grace_time);
 
index 109fc96acd972d4a23c4bf5b9eeb0777d5ebbb47..4747ceaf4d097f48961fcfa127335846f30de4bd 100644 (file)
--- a/sshpty.c
+++ b/sshpty.c
@@ -101,12 +101,12 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
                error("/dev/ptmx: %.100s", strerror(errno));
                return 0;
        }
-       old_signal = mysignal(SIGCHLD, SIG_DFL);
+       old_signal = signal(SIGCHLD, SIG_DFL);
        if (grantpt(ptm) < 0) {
                error("grantpt: %.100s", strerror(errno));
                return 0;
        }
-       mysignal(SIGCHLD, old_signal);
+       signal(SIGCHLD, old_signal);
        if (unlockpt(ptm) < 0) {
                error("unlockpt: %.100s", strerror(errno));
                return 0;
@@ -274,9 +274,9 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
 
        fd = open(ttyname, O_RDWR|O_NOCTTY);
        if (fd != -1) {
-               mysignal(SIGHUP, SIG_IGN);
+               signal(SIGHUP, SIG_IGN);
                ioctl(fd, TCVHUP, (char *)NULL);
-               mysignal(SIGHUP, SIG_DFL);
+               signal(SIGHUP, SIG_DFL);
                setpgid(0, 0);
                close(fd);
        } else {
@@ -323,9 +323,9 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
                error("SETPGRP %s",strerror(errno));
 #endif /* HAVE_NEWS4 */
 #ifdef USE_VHANGUP
-       old = mysignal(SIGHUP, SIG_IGN);
+       old = signal(SIGHUP, SIG_IGN);
        vhangup();
-       mysignal(SIGHUP, old);
+       signal(SIGHUP, old);
 #endif /* USE_VHANGUP */
        fd = open(ttyname, O_RDWR);
        if (fd < 0) {