summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2003-08-25 01:16:21 +0000
committerBen Lindstrom <mouring@eviladmin.org>2003-08-25 01:16:21 +0000
commit5ade9abc37df3dacacbe20104877ca6dab61082a (patch)
treeb3a521b87d93ecc0f1f17f4e659c1d4bf90f86f5
parentaf4a6c3a5619299a16cfbb545cde110849596204 (diff)
- (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@
-rw-r--r--ChangeLog7
-rw-r--r--entropy.c6
-rw-r--r--misc.c26
-rw-r--r--misc.h4
-rw-r--r--openbsd-compat/bsd-misc.c28
-rw-r--r--openbsd-compat/bsd-misc.h8
-rw-r--r--progressmeter.c4
-rw-r--r--sshd.c4
-rw-r--r--sshpty.c12
9 files changed, 52 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index 956a5e3a8..6ea448a37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,10 @@
2 - (djm) Bug #621: Select OpenSC keys by usage attributes. Patch from 2 - (djm) Bug #621: Select OpenSC keys by usage attributes. Patch from
3 larsch@trustcenter.de 3 larsch@trustcenter.de
4 - (bal) openbsd-compat/ OpenBSD updates. Mostly licensing, ansifications 4 - (bal) openbsd-compat/ OpenBSD updates. Mostly licensing, ansifications
5 and minor fixes. 5 and minor fixes. OK djm@
6 - (bal) redo how we handle 'mysignal()'. Move it to
7 openbsd-compat/bsd-misc.c, s/mysignal/signal/ and #define signal to
8 be our 'mysignal' by default. OK djm@
6 9
720030822 1020030822
8 - (djm) s/get_progname/ssh_get_progname/g to avoid conflict with Heimdal 11 - (djm) s/get_progname/ssh_get_progname/g to avoid conflict with Heimdal
@@ -857,4 +860,4 @@
857 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. 860 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
858 Report from murple@murple.net, diagnosis from dtucker@zip.com.au 861 Report from murple@murple.net, diagnosis from dtucker@zip.com.au
859 862
860$Id: ChangeLog,v 1.2900 2003/08/25 01:10:51 mouring Exp $ 863$Id: ChangeLog,v 1.2901 2003/08/25 01:16:21 mouring Exp $
diff --git a/entropy.c b/entropy.c
index a16ea10b3..216879786 100644
--- a/entropy.c
+++ b/entropy.c
@@ -45,7 +45,7 @@
45 * XXX: we should tell the child how many bytes we need. 45 * XXX: we should tell the child how many bytes we need.
46 */ 46 */
47 47
48RCSID("$Id: entropy.c,v 1.45 2003/05/16 05:51:45 djm Exp $"); 48RCSID("$Id: entropy.c,v 1.46 2003/08/25 01:16:21 mouring Exp $");
49 49
50#ifndef OPENSSL_PRNG_ONLY 50#ifndef OPENSSL_PRNG_ONLY
51#define RANDOM_SEED_SIZE 48 51#define RANDOM_SEED_SIZE 48
@@ -75,7 +75,7 @@ seed_rng(void)
75 if (pipe(p) == -1) 75 if (pipe(p) == -1)
76 fatal("pipe: %s", strerror(errno)); 76 fatal("pipe: %s", strerror(errno));
77 77
78 old_sigchld = mysignal(SIGCHLD, SIG_DFL); 78 old_sigchld = signal(SIGCHLD, SIG_DFL);
79 if ((pid = fork()) == -1) 79 if ((pid = fork()) == -1)
80 fatal("Couldn't fork: %s", strerror(errno)); 80 fatal("Couldn't fork: %s", strerror(errno));
81 if (pid == 0) { 81 if (pid == 0) {
@@ -116,7 +116,7 @@ seed_rng(void)
116 if (waitpid(pid, &ret, 0) == -1) 116 if (waitpid(pid, &ret, 0) == -1)
117 fatal("Couldn't wait for ssh-rand-helper completion: %s", 117 fatal("Couldn't wait for ssh-rand-helper completion: %s",
118 strerror(errno)); 118 strerror(errno));
119 mysignal(SIGCHLD, old_sigchld); 119 signal(SIGCHLD, old_sigchld);
120 120
121 /* We don't mind if the child exits upon a SIGPIPE */ 121 /* We don't mind if the child exits upon a SIGPIPE */
122 if (!WIFEXITED(ret) && 122 if (!WIFEXITED(ret) &&
diff --git a/misc.c b/misc.c
index ff1966192..c457a952c 100644
--- a/misc.c
+++ b/misc.c
@@ -323,29 +323,3 @@ addargs(arglist *args, char *fmt, ...)
323 args->list[args->num++] = xstrdup(buf); 323 args->list[args->num++] = xstrdup(buf);
324 args->list[args->num] = NULL; 324 args->list[args->num] = NULL;
325} 325}
326
327mysig_t
328mysignal(int sig, mysig_t act)
329{
330#ifdef HAVE_SIGACTION
331 struct sigaction sa, osa;
332
333 if (sigaction(sig, NULL, &osa) == -1)
334 return (mysig_t) -1;
335 if (osa.sa_handler != act) {
336 memset(&sa, 0, sizeof(sa));
337 sigemptyset(&sa.sa_mask);
338 sa.sa_flags = 0;
339#if defined(SA_INTERRUPT)
340 if (sig == SIGALRM)
341 sa.sa_flags |= SA_INTERRUPT;
342#endif
343 sa.sa_handler = act;
344 if (sigaction(sig, &sa, NULL) == -1)
345 return (mysig_t) -1;
346 }
347 return (osa.sa_handler);
348#else
349 return (signal(sig, act));
350#endif
351}
diff --git a/misc.h b/misc.h
index 3b4b87967..6d2869b36 100644
--- a/misc.h
+++ b/misc.h
@@ -31,7 +31,3 @@ struct arglist {
31 int nalloc; 31 int nalloc;
32}; 32};
33void addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3))); 33void addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3)));
34
35/* wrapper for signal interface */
36typedef void (*mysig_t)(int);
37mysig_t mysignal(int sig, mysig_t act);
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 56cb45ade..08b089bdc 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -25,7 +25,7 @@
25#include "includes.h" 25#include "includes.h"
26#include "xmalloc.h" 26#include "xmalloc.h"
27 27
28RCSID("$Id: bsd-misc.c,v 1.18 2003/08/21 23:34:42 djm Exp $"); 28RCSID("$Id: bsd-misc.c,v 1.19 2003/08/25 01:16:21 mouring Exp $");
29 29
30/* 30/*
31 * NB. duplicate __progname in case it is an alias for argv[0] 31 * NB. duplicate __progname in case it is an alias for argv[0]
@@ -200,3 +200,29 @@ tcsendbreak(int fd, int duration)
200# endif 200# endif
201} 201}
202#endif /* HAVE_TCSENDBREAK */ 202#endif /* HAVE_TCSENDBREAK */
203
204mysig_t
205mysignal(int sig, mysig_t act)
206{
207#ifdef HAVE_SIGACTION
208 struct sigaction sa, osa;
209
210 if (sigaction(sig, NULL, &osa) == -1)
211 return (mysig_t) -1;
212 if (osa.sa_handler != act) {
213 memset(&sa, 0, sizeof(sa));
214 sigemptyset(&sa.sa_mask);
215 sa.sa_flags = 0;
216#ifdef SA_INTERRUPT
217 if (sig == SIGALRM)
218 sa.sa_flags |= SA_INTERRUPT;
219#endif
220 sa.sa_handler = act;
221 if (sigaction(sig, &sa, NULL) == -1)
222 return (mysig_t) -1;
223 }
224 return (osa.sa_handler);
225#else
226 return (signal(sig, act));
227#endif
228}
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 2857de59b..0d6076ab0 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25/* $Id: bsd-misc.h,v 1.11 2003/08/21 23:34:42 djm Exp $ */ 25/* $Id: bsd-misc.h,v 1.12 2003/08/25 01:16:22 mouring Exp $ */
26 26
27#ifndef _BSD_MISC_H 27#ifndef _BSD_MISC_H
28#define _BSD_MISC_H 28#define _BSD_MISC_H
@@ -97,4 +97,10 @@ pid_t tcgetpgrp(int);
97int tcsendbreak(int, int); 97int tcsendbreak(int, int);
98#endif 98#endif
99 99
100/* wrapper for signal interface */
101typedef void (*mysig_t)(int);
102mysig_t mysignal(int sig, mysig_t act);
103
104#define signal(a,b) mysignal(a,b)
105
100#endif /* _BSD_MISC_H */ 106#endif /* _BSD_MISC_H */
diff --git a/progressmeter.c b/progressmeter.c
index 170d869f4..9fe8cfa41 100644
--- a/progressmeter.c
+++ b/progressmeter.c
@@ -212,7 +212,7 @@ update_progress_meter(int ignore)
212 if (can_output()) 212 if (can_output())
213 refresh_progress_meter(); 213 refresh_progress_meter();
214 214
215 mysignal(SIGALRM, update_progress_meter); 215 signal(SIGALRM, update_progress_meter);
216 alarm(UPDATE_INTERVAL); 216 alarm(UPDATE_INTERVAL);
217 errno = save_errno; 217 errno = save_errno;
218} 218}
@@ -243,7 +243,7 @@ start_progress_meter(char *f, off_t filesize, off_t *stat)
243 if (can_output()) 243 if (can_output())
244 refresh_progress_meter(); 244 refresh_progress_meter();
245 245
246 mysignal(SIGALRM, update_progress_meter); 246 signal(SIGALRM, update_progress_meter);
247 alarm(UPDATE_INTERVAL); 247 alarm(UPDATE_INTERVAL);
248} 248}
249 249
diff --git a/sshd.c b/sshd.c
index 0e1bde3a3..8d04f6a74 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1368,7 +1368,7 @@ main(int ac, char **av)
1368 if ((options.protocol & SSH_PROTO_1) && 1368 if ((options.protocol & SSH_PROTO_1) &&
1369 key_used == 0) { 1369 key_used == 0) {
1370 /* Schedule server key regeneration alarm. */ 1370 /* Schedule server key regeneration alarm. */
1371 mysignal(SIGALRM, key_regeneration_alarm); 1371 signal(SIGALRM, key_regeneration_alarm);
1372 alarm(options.key_regeneration_time); 1372 alarm(options.key_regeneration_time);
1373 key_used = 1; 1373 key_used = 1;
1374 } 1374 }
@@ -1457,7 +1457,7 @@ main(int ac, char **av)
1457 * mode; it is just annoying to have the server exit just when you 1457 * mode; it is just annoying to have the server exit just when you
1458 * are about to discover the bug. 1458 * are about to discover the bug.
1459 */ 1459 */
1460 mysignal(SIGALRM, grace_alarm_handler); 1460 signal(SIGALRM, grace_alarm_handler);
1461 if (!debug_flag) 1461 if (!debug_flag)
1462 alarm(options.login_grace_time); 1462 alarm(options.login_grace_time);
1463 1463
diff --git a/sshpty.c b/sshpty.c
index 109fc96ac..4747ceaf4 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -101,12 +101,12 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
101 error("/dev/ptmx: %.100s", strerror(errno)); 101 error("/dev/ptmx: %.100s", strerror(errno));
102 return 0; 102 return 0;
103 } 103 }
104 old_signal = mysignal(SIGCHLD, SIG_DFL); 104 old_signal = signal(SIGCHLD, SIG_DFL);
105 if (grantpt(ptm) < 0) { 105 if (grantpt(ptm) < 0) {
106 error("grantpt: %.100s", strerror(errno)); 106 error("grantpt: %.100s", strerror(errno));
107 return 0; 107 return 0;
108 } 108 }
109 mysignal(SIGCHLD, old_signal); 109 signal(SIGCHLD, old_signal);
110 if (unlockpt(ptm) < 0) { 110 if (unlockpt(ptm) < 0) {
111 error("unlockpt: %.100s", strerror(errno)); 111 error("unlockpt: %.100s", strerror(errno));
112 return 0; 112 return 0;
@@ -274,9 +274,9 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
274 274
275 fd = open(ttyname, O_RDWR|O_NOCTTY); 275 fd = open(ttyname, O_RDWR|O_NOCTTY);
276 if (fd != -1) { 276 if (fd != -1) {
277 mysignal(SIGHUP, SIG_IGN); 277 signal(SIGHUP, SIG_IGN);
278 ioctl(fd, TCVHUP, (char *)NULL); 278 ioctl(fd, TCVHUP, (char *)NULL);
279 mysignal(SIGHUP, SIG_DFL); 279 signal(SIGHUP, SIG_DFL);
280 setpgid(0, 0); 280 setpgid(0, 0);
281 close(fd); 281 close(fd);
282 } else { 282 } else {
@@ -323,9 +323,9 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
323 error("SETPGRP %s",strerror(errno)); 323 error("SETPGRP %s",strerror(errno));
324#endif /* HAVE_NEWS4 */ 324#endif /* HAVE_NEWS4 */
325#ifdef USE_VHANGUP 325#ifdef USE_VHANGUP
326 old = mysignal(SIGHUP, SIG_IGN); 326 old = signal(SIGHUP, SIG_IGN);
327 vhangup(); 327 vhangup();
328 mysignal(SIGHUP, old); 328 signal(SIGHUP, old);
329#endif /* USE_VHANGUP */ 329#endif /* USE_VHANGUP */
330 fd = open(ttyname, O_RDWR); 330 fd = open(ttyname, O_RDWR);
331 if (fd < 0) { 331 if (fd < 0) {