diff options
Diffstat (limited to 'openbsd-compat')
44 files changed, 259 insertions, 304 deletions
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index aca9eba75..d51eacf65 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in | |||
@@ -16,9 +16,9 @@ RANLIB=@RANLIB@ | |||
16 | INSTALL=@INSTALL@ | 16 | INSTALL=@INSTALL@ |
17 | LDFLAGS=-L. @LDFLAGS@ | 17 | LDFLAGS=-L. @LDFLAGS@ |
18 | 18 | ||
19 | OPENBSD=base64.o basename.o bcrypt_pbkdf.o bindresvport.o blowfish.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt_long.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o reallocarray.o realpath.o rresvport.o setenv.o setproctitle.o sha1.o sha2.o rmd160.o md5.o sigact.o strlcat.o strlcpy.o strmode.o strnlen.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o strtoull.o timingsafe_bcmp.o vis.o blowfish.o bcrypt_pbkdf.o explicit_bzero.o | 19 | OPENBSD=base64.o basename.o bcrypt_pbkdf.o bindresvport.o blowfish.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt_long.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o reallocarray.o realpath.o rresvport.o setenv.o setproctitle.o sha1.o sha2.o rmd160.o md5.o sigact.o strcasestr.o strlcat.o strlcpy.o strmode.o strnlen.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o strtoull.o timingsafe_bcmp.o vis.o blowfish.o bcrypt_pbkdf.o explicit_bzero.o |
20 | 20 | ||
21 | COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-err.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-setres_id.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o kludge-fd_set.o | 21 | COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-err.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-setres_id.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xcrypt.o kludge-fd_set.o |
22 | 22 | ||
23 | PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o | 23 | PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o |
24 | 24 | ||
@@ -36,7 +36,7 @@ libopenbsd-compat.a: $(COMPAT) $(OPENBSD) $(PORTS) | |||
36 | $(RANLIB) $@ | 36 | $(RANLIB) $@ |
37 | 37 | ||
38 | clean: | 38 | clean: |
39 | rm -f *.o *.a core | 39 | rm -f *.o *.a core |
40 | 40 | ||
41 | distclean: clean | 41 | distclean: clean |
42 | rm -f Makefile *~ | 42 | rm -f Makefile *~ |
diff --git a/openbsd-compat/base64.h b/openbsd-compat/base64.h index 732c6b3f8..bd772931b 100644 --- a/openbsd-compat/base64.h +++ b/openbsd-compat/base64.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: base64.h,v 1.6 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 1996 by Internet Software Consortium. | 2 | * Copyright (c) 1996 by Internet Software Consortium. |
5 | * | 3 | * |
@@ -49,7 +47,7 @@ | |||
49 | 47 | ||
50 | #ifndef HAVE___B64_NTOP | 48 | #ifndef HAVE___B64_NTOP |
51 | # ifndef HAVE_B64_NTOP | 49 | # ifndef HAVE_B64_NTOP |
52 | int b64_ntop(u_char const *src, size_t srclength, char *target, | 50 | int b64_ntop(u_char const *src, size_t srclength, char *target, |
53 | size_t targsize); | 51 | size_t targsize); |
54 | # endif /* !HAVE_B64_NTOP */ | 52 | # endif /* !HAVE_B64_NTOP */ |
55 | # define __b64_ntop(a,b,c,d) b64_ntop(a,b,c,d) | 53 | # define __b64_ntop(a,b,c,d) b64_ntop(a,b,c,d) |
diff --git a/openbsd-compat/bsd-asprintf.c b/openbsd-compat/bsd-asprintf.c index 7b83448ca..822367154 100644 --- a/openbsd-compat/bsd-asprintf.c +++ b/openbsd-compat/bsd-asprintf.c | |||
@@ -78,7 +78,7 @@ int asprintf(char **str, const char *fmt, ...) | |||
78 | { | 78 | { |
79 | va_list ap; | 79 | va_list ap; |
80 | int ret; | 80 | int ret; |
81 | 81 | ||
82 | *str = NULL; | 82 | *str = NULL; |
83 | va_start(ap, fmt); | 83 | va_start(ap, fmt); |
84 | ret = vasprintf(str, fmt, ap); | 84 | ret = vasprintf(str, fmt, ap); |
diff --git a/openbsd-compat/bsd-cray.c b/openbsd-compat/bsd-cray.c index f1bbd7dec..c02e63261 100644 --- a/openbsd-compat/bsd-cray.c +++ b/openbsd-compat/bsd-cray.c | |||
@@ -1,10 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: bsd-cray.c,v 1.17 2007/08/15 09:17:43 dtucker Exp $ | ||
3 | * | 2 | * |
4 | * bsd-cray.c | 3 | * bsd-cray.c |
5 | * | 4 | * |
6 | * Copyright (c) 2002, Cray Inc. (Wendy Palm <wendyp@cray.com>) | 5 | * Copyright (c) 2002, Cray Inc. (Wendy Palm <wendyp@cray.com>) |
7 | * Significant portions provided by | 6 | * Significant portions provided by |
8 | * Wayne Schroeder, SDSC <schroeder@sdsc.edu> | 7 | * Wayne Schroeder, SDSC <schroeder@sdsc.edu> |
9 | * William Jones, UTexas <jones@tacc.utexas.edu> | 8 | * William Jones, UTexas <jones@tacc.utexas.edu> |
10 | * | 9 | * |
@@ -268,7 +267,7 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
268 | usent.uname = username; | 267 | usent.uname = username; |
269 | usent.host = hostname; | 268 | usent.host = hostname; |
270 | usent.ttyn = ttyn; | 269 | usent.ttyn = ttyn; |
271 | usent.caller = IA_SSHD; | 270 | usent.caller = IA_SSHD; |
272 | usent.pswdlist = &pwdacm; | 271 | usent.pswdlist = &pwdacm; |
273 | usent.ueptr = &ue; | 272 | usent.ueptr = &ue; |
274 | usent.flags = IA_INTERACTIVE | IA_FFLAG; | 273 | usent.flags = IA_INTERACTIVE | IA_FFLAG; |
@@ -352,7 +351,7 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
352 | /* | 351 | /* |
353 | * These are failed return codes from ia_user() | 352 | * These are failed return codes from ia_user() |
354 | */ | 353 | */ |
355 | switch (ia_rcode) | 354 | switch (ia_rcode) |
356 | { | 355 | { |
357 | case IA_BADAUTH: | 356 | case IA_BADAUTH: |
358 | printf("Bad authorization, access denied.\n"); | 357 | printf("Bad authorization, access denied.\n"); |
@@ -407,7 +406,7 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
407 | */ | 406 | */ |
408 | ia_failure(&fsent, &fret); | 407 | ia_failure(&fsent, &fret); |
409 | 408 | ||
410 | exit(1); | 409 | exit(1); |
411 | } | 410 | } |
412 | 411 | ||
413 | ia_mlsrcode = IA_NORMAL; | 412 | ia_mlsrcode = IA_NORMAL; |
@@ -441,7 +440,7 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
441 | * There is no return because ia_failure exits. | 440 | * There is no return because ia_failure exits. |
442 | */ | 441 | */ |
443 | ia_failure(&fsent,&fret); | 442 | ia_failure(&fsent,&fret); |
444 | exit(1); | 443 | exit(1); |
445 | } | 444 | } |
446 | 445 | ||
447 | /* Provide login status information */ | 446 | /* Provide login status information */ |
@@ -526,7 +525,7 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
526 | break; | 525 | break; |
527 | default: | 526 | default: |
528 | valid_acct = nam2acid(acct_name); | 527 | valid_acct = nam2acid(acct_name); |
529 | if (valid_acct == -1) | 528 | if (valid_acct == -1) |
530 | printf( | 529 | printf( |
531 | "Account id not found for" | 530 | "Account id not found for" |
532 | " account name \"%s\"\n\n", | 531 | " account name \"%s\"\n\n", |
@@ -576,9 +575,9 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
576 | exit(1); | 575 | exit(1); |
577 | } | 576 | } |
578 | 577 | ||
579 | /* | 578 | /* |
580 | * Now set shares, quotas, limits, including CPU time for the | 579 | * Now set shares, quotas, limits, including CPU time for the |
581 | * (interactive) job and process, and set up permissions | 580 | * (interactive) job and process, and set up permissions |
582 | * (for chown etc), etc. | 581 | * (for chown etc), etc. |
583 | */ | 582 | */ |
584 | if (setshares(ue.ue_uid, valid_acct, printf, 0, 0)) { | 583 | if (setshares(ue.ue_uid, valid_acct, printf, 0, 0)) { |
@@ -656,7 +655,7 @@ drop_cray_privs() | |||
656 | usrv.sv_minlvl = sysv.sy_minlvl; | 655 | usrv.sv_minlvl = sysv.sy_minlvl; |
657 | usrv.sv_actlvl = sysv.sy_minlvl; | 656 | usrv.sv_actlvl = sysv.sy_minlvl; |
658 | usrv.sv_maxlvl = sysv.sy_maxlvl; | 657 | usrv.sv_maxlvl = sysv.sy_maxlvl; |
659 | } | 658 | } |
660 | usrv.sv_actcmp = 0; | 659 | usrv.sv_actcmp = 0; |
661 | usrv.sv_valcmp = sysv.sy_valcmp; | 660 | usrv.sv_valcmp = sysv.sy_valcmp; |
662 | 661 | ||
diff --git a/openbsd-compat/bsd-cray.h b/openbsd-compat/bsd-cray.h index 774eceb5a..ca626a021 100644 --- a/openbsd-compat/bsd-cray.h +++ b/openbsd-compat/bsd-cray.h | |||
@@ -1,8 +1,6 @@ | |||
1 | /* $Id: bsd-cray.h,v 1.12 2005/02/02 06:10:11 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2002, Cray Inc. (Wendy Palm <wendyp@cray.com>) | 2 | * Copyright (c) 2002, Cray Inc. (Wendy Palm <wendyp@cray.com>) |
5 | * Significant portions provided by | 3 | * Significant portions provided by |
6 | * Wayne Schroeder, SDSC <schroeder@sdsc.edu> | 4 | * Wayne Schroeder, SDSC <schroeder@sdsc.edu> |
7 | * William Jones, UTexas <jones@tacc.utexas.edu> | 5 | * William Jones, UTexas <jones@tacc.utexas.edu> |
8 | * | 6 | * |
diff --git a/openbsd-compat/bsd-cygwin_util.c b/openbsd-compat/bsd-cygwin_util.c index 8672ccf7f..398a5f617 100644 --- a/openbsd-compat/bsd-cygwin_util.c +++ b/openbsd-compat/bsd-cygwin_util.c | |||
@@ -39,12 +39,12 @@ | |||
39 | 39 | ||
40 | #include "xmalloc.h" | 40 | #include "xmalloc.h" |
41 | 41 | ||
42 | int | 42 | int |
43 | binary_open(const char *filename, int flags, ...) | 43 | binary_open(const char *filename, int flags, ...) |
44 | { | 44 | { |
45 | va_list ap; | 45 | va_list ap; |
46 | mode_t mode; | 46 | mode_t mode; |
47 | 47 | ||
48 | va_start(ap, flags); | 48 | va_start(ap, flags); |
49 | mode = va_arg(ap, mode_t); | 49 | mode = va_arg(ap, mode_t); |
50 | va_end(ap); | 50 | va_end(ap); |
diff --git a/openbsd-compat/bsd-cygwin_util.h b/openbsd-compat/bsd-cygwin_util.h index 79cb2a197..9cef694b9 100644 --- a/openbsd-compat/bsd-cygwin_util.h +++ b/openbsd-compat/bsd-cygwin_util.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-cygwin_util.h,v 1.18 2014/05/27 04:34:43 djm Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2000, 2001, 2011, 2013 Corinna Vinschen <vinschen@redhat.com> | 2 | * Copyright (c) 2000, 2001, 2011, 2013 Corinna Vinschen <vinschen@redhat.com> |
5 | * | 3 | * |
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index 18bf62dd8..6f3bc8f1d 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c | |||
@@ -70,8 +70,8 @@ int setlogin(const char *name) | |||
70 | #endif /* !HAVE_SETLOGIN */ | 70 | #endif /* !HAVE_SETLOGIN */ |
71 | 71 | ||
72 | #ifndef HAVE_INNETGR | 72 | #ifndef HAVE_INNETGR |
73 | int innetgr(const char *netgroup, const char *host, | 73 | int innetgr(const char *netgroup, const char *host, |
74 | const char *user, const char *domain) | 74 | const char *user, const char *domain) |
75 | { | 75 | { |
76 | return (0); | 76 | return (0); |
77 | } | 77 | } |
@@ -96,7 +96,7 @@ const char *strerror(int e) | |||
96 | { | 96 | { |
97 | extern int sys_nerr; | 97 | extern int sys_nerr; |
98 | extern char *sys_errlist[]; | 98 | extern char *sys_errlist[]; |
99 | 99 | ||
100 | if ((e >= 0) && (e < sys_nerr)) | 100 | if ((e >= 0) && (e < sys_nerr)) |
101 | return (sys_errlist[e]); | 101 | return (sys_errlist[e]); |
102 | 102 | ||
@@ -111,10 +111,10 @@ int utimes(char *filename, struct timeval *tvp) | |||
111 | 111 | ||
112 | ub.actime = tvp[0].tv_sec; | 112 | ub.actime = tvp[0].tv_sec; |
113 | ub.modtime = tvp[1].tv_sec; | 113 | ub.modtime = tvp[1].tv_sec; |
114 | 114 | ||
115 | return (utime(filename, &ub)); | 115 | return (utime(filename, &ub)); |
116 | } | 116 | } |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | #ifndef HAVE_TRUNCATE | 119 | #ifndef HAVE_TRUNCATE |
120 | int truncate(const char *path, off_t length) | 120 | int truncate(const char *path, off_t length) |
@@ -149,9 +149,9 @@ int nanosleep(const struct timespec *req, struct timespec *rem) | |||
149 | saverrno = errno; | 149 | saverrno = errno; |
150 | (void) gettimeofday (&tstop, NULL); | 150 | (void) gettimeofday (&tstop, NULL); |
151 | errno = saverrno; | 151 | errno = saverrno; |
152 | tremain.tv_sec = time2wait.tv_sec - | 152 | tremain.tv_sec = time2wait.tv_sec - |
153 | (tstop.tv_sec - tstart.tv_sec); | 153 | (tstop.tv_sec - tstart.tv_sec); |
154 | tremain.tv_usec = time2wait.tv_usec - | 154 | tremain.tv_usec = time2wait.tv_usec - |
155 | (tstop.tv_usec - tstart.tv_usec); | 155 | (tstop.tv_usec - tstart.tv_usec); |
156 | tremain.tv_sec += tremain.tv_usec / 1000000L; | 156 | tremain.tv_sec += tremain.tv_usec / 1000000L; |
157 | tremain.tv_usec %= 1000000L; | 157 | tremain.tv_usec %= 1000000L; |
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index 27abb2e92..6f08b09fa 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-misc.h,v 1.25 2013/08/04 11:48:41 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org> | 2 | * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org> |
5 | * | 3 | * |
@@ -49,7 +47,7 @@ int setegid(uid_t); | |||
49 | 47 | ||
50 | #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) | 48 | #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) |
51 | const char *strerror(int); | 49 | const char *strerror(int); |
52 | #endif | 50 | #endif |
53 | 51 | ||
54 | #if !defined(HAVE_SETLINEBUF) | 52 | #if !defined(HAVE_SETLINEBUF) |
55 | #define setlinebuf(a) (setvbuf((a), NULL, _IOLBF, 0)) | 53 | #define setlinebuf(a) (setvbuf((a), NULL, _IOLBF, 0)) |
diff --git a/openbsd-compat/bsd-nextstep.c b/openbsd-compat/bsd-nextstep.c index 8195af88a..d52443f6d 100644 --- a/openbsd-compat/bsd-nextstep.c +++ b/openbsd-compat/bsd-nextstep.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <sys/wait.h> | 29 | #include <sys/wait.h> |
30 | #include "bsd-nextstep.h" | 30 | #include "bsd-nextstep.h" |
31 | 31 | ||
32 | pid_t | 32 | pid_t |
33 | posix_wait(int *status) | 33 | posix_wait(int *status) |
34 | { | 34 | { |
35 | union wait statusp; | 35 | union wait statusp; |
diff --git a/openbsd-compat/bsd-nextstep.h b/openbsd-compat/bsd-nextstep.h index ca5b4b54a..610f9e381 100644 --- a/openbsd-compat/bsd-nextstep.h +++ b/openbsd-compat/bsd-nextstep.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-nextstep.h,v 1.9 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2000,2001 Ben Lindstrom. All rights reserved. | 2 | * Copyright (c) 2000,2001 Ben Lindstrom. All rights reserved. |
5 | * | 3 | * |
diff --git a/openbsd-compat/bsd-openpty.c b/openbsd-compat/bsd-openpty.c index 9777eb556..b28235860 100644 --- a/openbsd-compat/bsd-openpty.c +++ b/openbsd-compat/bsd-openpty.c | |||
@@ -122,7 +122,7 @@ openpty(int *amaster, int *aslave, char *name, struct termios *termp, | |||
122 | } | 122 | } |
123 | 123 | ||
124 | /* | 124 | /* |
125 | * Try to push the appropriate streams modules, as described | 125 | * Try to push the appropriate streams modules, as described |
126 | * in Solaris pts(7). | 126 | * in Solaris pts(7). |
127 | */ | 127 | */ |
128 | ioctl(*aslave, I_PUSH, "ptem"); | 128 | ioctl(*aslave, I_PUSH, "ptem"); |
@@ -184,7 +184,7 @@ openpty(int *amaster, int *aslave, char *name, struct termios *termp, | |||
184 | struct termios tio; | 184 | struct termios tio; |
185 | 185 | ||
186 | for (i = 0; i < num_ptys; i++) { | 186 | for (i = 0; i < num_ptys; i++) { |
187 | snprintf(ptbuf, sizeof(ptbuf), "/dev/pty%c%c", | 187 | snprintf(ptbuf, sizeof(ptbuf), "/dev/pty%c%c", |
188 | ptymajors[i / num_minors], ptyminors[i % num_minors]); | 188 | ptymajors[i / num_minors], ptyminors[i % num_minors]); |
189 | snprintf(ttbuf, sizeof(ttbuf), "/dev/tty%c%c", | 189 | snprintf(ttbuf, sizeof(ttbuf), "/dev/tty%c%c", |
190 | ptymajors[i / num_minors], ptyminors[i % num_minors]); | 190 | ptymajors[i / num_minors], ptyminors[i % num_minors]); |
diff --git a/openbsd-compat/bsd-poll.c b/openbsd-compat/bsd-poll.c index 73a852480..c8e6222c0 100644 --- a/openbsd-compat/bsd-poll.c +++ b/openbsd-compat/bsd-poll.c | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-poll.c,v 1.6 2014/02/05 23:44:13 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2004, 2005, 2007 Darren Tucker (dtucker at zip com au). | 2 | * Copyright (c) 2004, 2005, 2007 Darren Tucker (dtucker at zip com au). |
5 | * | 3 | * |
diff --git a/openbsd-compat/bsd-setres_id.c b/openbsd-compat/bsd-setres_id.c index 018bde8c7..696ae7b28 100644 --- a/openbsd-compat/bsd-setres_id.c +++ b/openbsd-compat/bsd-setres_id.c | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-setres_id.c,v 1.2 2013/12/07 21:23:09 djm Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2012 Darren Tucker (dtucker at zip com au). | 2 | * Copyright (c) 2012 Darren Tucker (dtucker at zip com au). |
5 | * | 3 | * |
diff --git a/openbsd-compat/bsd-setres_id.h b/openbsd-compat/bsd-setres_id.h index 6c269e0b9..0350a596e 100644 --- a/openbsd-compat/bsd-setres_id.h +++ b/openbsd-compat/bsd-setres_id.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-setres_id.h,v 1.1 2012/11/05 06:04:37 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2012 Darren Tucker (dtucker at zip com au). | 2 | * Copyright (c) 2012 Darren Tucker (dtucker at zip com au). |
5 | * | 3 | * |
diff --git a/openbsd-compat/bsd-statvfs.c b/openbsd-compat/bsd-statvfs.c index 2b1da80ec..458dbe89c 100644 --- a/openbsd-compat/bsd-statvfs.c +++ b/openbsd-compat/bsd-statvfs.c | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-statvfs.c,v 1.2 2014/01/17 07:10:59 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au> | 2 | * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au> |
5 | * | 3 | * |
diff --git a/openbsd-compat/bsd-statvfs.h b/openbsd-compat/bsd-statvfs.h index dfd609974..815ec03b2 100644 --- a/openbsd-compat/bsd-statvfs.h +++ b/openbsd-compat/bsd-statvfs.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-statvfs.h,v 1.3 2014/01/17 07:48:22 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au> | 2 | * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au> |
5 | * | 3 | * |
diff --git a/openbsd-compat/bsd-waitpid.c b/openbsd-compat/bsd-waitpid.c index 40e6ffaa8..113fb1ea9 100644 --- a/openbsd-compat/bsd-waitpid.c +++ b/openbsd-compat/bsd-waitpid.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | 26 | ||
27 | #ifndef HAVE_WAITPID | 27 | #ifndef HAVE_WAITPID |
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | #include <sys/wait.h> | 29 | #include <sys/wait.h> |
30 | #include "bsd-waitpid.h" | 30 | #include "bsd-waitpid.h" |
@@ -43,11 +43,11 @@ waitpid(int pid, int *stat_loc, int options) | |||
43 | /* wait4() wants pid=0 for indiscriminate wait. */ | 43 | /* wait4() wants pid=0 for indiscriminate wait. */ |
44 | pid = 0; | 44 | pid = 0; |
45 | } | 45 | } |
46 | wait_pid = wait4(pid, &statusp, options, NULL); | 46 | wait_pid = wait4(pid, &statusp, options, NULL); |
47 | if (stat_loc) | 47 | if (stat_loc) |
48 | *stat_loc = (int) statusp.w_status; | 48 | *stat_loc = (int) statusp.w_status; |
49 | 49 | ||
50 | return (wait_pid); | 50 | return (wait_pid); |
51 | } | 51 | } |
52 | 52 | ||
53 | #endif /* !HAVE_WAITPID */ | 53 | #endif /* !HAVE_WAITPID */ |
diff --git a/openbsd-compat/bsd-waitpid.h b/openbsd-compat/bsd-waitpid.h index 2d853db61..5ce3ee4b5 100644 --- a/openbsd-compat/bsd-waitpid.h +++ b/openbsd-compat/bsd-waitpid.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: bsd-waitpid.h,v 1.5 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2000 Ben Lindstrom. All rights reserved. | 2 | * Copyright (c) 2000 Ben Lindstrom. All rights reserved. |
5 | * | 3 | * |
diff --git a/openbsd-compat/explicit_bzero.c b/openbsd-compat/explicit_bzero.c index 3c85a4843..5078134d1 100644 --- a/openbsd-compat/explicit_bzero.c +++ b/openbsd-compat/explicit_bzero.c | |||
@@ -7,6 +7,8 @@ | |||
7 | 7 | ||
8 | #include "includes.h" | 8 | #include "includes.h" |
9 | 9 | ||
10 | #include <string.h> | ||
11 | |||
10 | /* | 12 | /* |
11 | * explicit_bzero - don't let the compiler optimize away bzero | 13 | * explicit_bzero - don't let the compiler optimize away bzero |
12 | */ | 14 | */ |
@@ -32,6 +34,17 @@ static void (* volatile ssh_bzero)(void *, size_t) = bzero; | |||
32 | void | 34 | void |
33 | explicit_bzero(void *p, size_t n) | 35 | explicit_bzero(void *p, size_t n) |
34 | { | 36 | { |
37 | /* | ||
38 | * clang -fsanitize=memory needs to intercept memset-like functions | ||
39 | * to correctly detect memory initialisation. Make sure one is called | ||
40 | * directly since our indirection trick above sucessfully confuses it. | ||
41 | */ | ||
42 | #if defined(__has_feature) | ||
43 | # if __has_feature(memory_sanitizer) | ||
44 | memset(p, 0, n); | ||
45 | # endif | ||
46 | #endif | ||
47 | |||
35 | ssh_bzero(p, n); | 48 | ssh_bzero(p, n); |
36 | } | 49 | } |
37 | 50 | ||
diff --git a/openbsd-compat/fake-rfc2553.c b/openbsd-compat/fake-rfc2553.c index 096d9e092..d5a62975a 100644 --- a/openbsd-compat/fake-rfc2553.c +++ b/openbsd-compat/fake-rfc2553.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000-2003 Damien Miller. All rights reserved. | 2 | * Copyright (C) 2000-2003 Damien Miller. All rights reserved. |
3 | * Copyright (C) 1999 WIDE Project. All rights reserved. | 3 | * Copyright (C) 1999 WIDE Project. All rights reserved. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
7 | * are met: | 7 | * are met: |
@@ -13,7 +13,7 @@ | |||
13 | * 3. Neither the name of the project nor the names of its contributors | 13 | * 3. Neither the name of the project nor the names of its contributors |
14 | * may be used to endorse or promote products derived from this software | 14 | * may be used to endorse or promote products derived from this software |
15 | * without specific prior written permission. | 15 | * without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -44,8 +44,8 @@ | |||
44 | #include <arpa/inet.h> | 44 | #include <arpa/inet.h> |
45 | 45 | ||
46 | #ifndef HAVE_GETNAMEINFO | 46 | #ifndef HAVE_GETNAMEINFO |
47 | int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | 47 | int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, |
48 | size_t hostlen, char *serv, size_t servlen, int flags) | 48 | size_t hostlen, char *serv, size_t servlen, int flags) |
49 | { | 49 | { |
50 | struct sockaddr_in *sin = (struct sockaddr_in *)sa; | 50 | struct sockaddr_in *sin = (struct sockaddr_in *)sa; |
51 | struct hostent *hp; | 51 | struct hostent *hp; |
@@ -67,11 +67,11 @@ int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | |||
67 | else | 67 | else |
68 | return (0); | 68 | return (0); |
69 | } else { | 69 | } else { |
70 | hp = gethostbyaddr((char *)&sin->sin_addr, | 70 | hp = gethostbyaddr((char *)&sin->sin_addr, |
71 | sizeof(struct in_addr), AF_INET); | 71 | sizeof(struct in_addr), AF_INET); |
72 | if (hp == NULL) | 72 | if (hp == NULL) |
73 | return (EAI_NODATA); | 73 | return (EAI_NODATA); |
74 | 74 | ||
75 | if (strlcpy(host, hp->h_name, hostlen) >= hostlen) | 75 | if (strlcpy(host, hp->h_name, hostlen) >= hostlen) |
76 | return (EAI_MEMORY); | 76 | return (EAI_MEMORY); |
77 | else | 77 | else |
@@ -102,7 +102,7 @@ gai_strerror(int err) | |||
102 | default: | 102 | default: |
103 | return ("unknown/invalid error."); | 103 | return ("unknown/invalid error."); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | #endif /* !HAVE_GAI_STRERROR */ | 106 | #endif /* !HAVE_GAI_STRERROR */ |
107 | 107 | ||
108 | #ifndef HAVE_FREEADDRINFO | 108 | #ifndef HAVE_FREEADDRINFO |
@@ -128,9 +128,9 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) | |||
128 | ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in)); | 128 | ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in)); |
129 | if (ai == NULL) | 129 | if (ai == NULL) |
130 | return (NULL); | 130 | return (NULL); |
131 | 131 | ||
132 | memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); | 132 | memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); |
133 | 133 | ||
134 | ai->ai_addr = (struct sockaddr *)(ai + 1); | 134 | ai->ai_addr = (struct sockaddr *)(ai + 1); |
135 | /* XXX -- ssh doesn't use sa_len */ | 135 | /* XXX -- ssh doesn't use sa_len */ |
136 | ai->ai_addrlen = sizeof(struct sockaddr_in); | 136 | ai->ai_addrlen = sizeof(struct sockaddr_in); |
@@ -138,7 +138,7 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) | |||
138 | 138 | ||
139 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; | 139 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; |
140 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; | 140 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; |
141 | 141 | ||
142 | /* XXX: the following is not generally correct, but does what we want */ | 142 | /* XXX: the following is not generally correct, but does what we want */ |
143 | if (hints->ai_socktype) | 143 | if (hints->ai_socktype) |
144 | ai->ai_socktype = hints->ai_socktype; | 144 | ai->ai_socktype = hints->ai_socktype; |
@@ -152,7 +152,7 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) | |||
152 | } | 152 | } |
153 | 153 | ||
154 | int | 154 | int |
155 | getaddrinfo(const char *hostname, const char *servname, | 155 | getaddrinfo(const char *hostname, const char *servname, |
156 | const struct addrinfo *hints, struct addrinfo **res) | 156 | const struct addrinfo *hints, struct addrinfo **res) |
157 | { | 157 | { |
158 | struct hostent *hp; | 158 | struct hostent *hp; |
@@ -183,29 +183,29 @@ getaddrinfo(const char *hostname, const char *servname, | |||
183 | if (hostname && inet_aton(hostname, &in) != 0) | 183 | if (hostname && inet_aton(hostname, &in) != 0) |
184 | addr = in.s_addr; | 184 | addr = in.s_addr; |
185 | *res = malloc_ai(port, addr, hints); | 185 | *res = malloc_ai(port, addr, hints); |
186 | if (*res == NULL) | 186 | if (*res == NULL) |
187 | return (EAI_MEMORY); | 187 | return (EAI_MEMORY); |
188 | return (0); | 188 | return (0); |
189 | } | 189 | } |
190 | 190 | ||
191 | if (!hostname) { | 191 | if (!hostname) { |
192 | *res = malloc_ai(port, htonl(0x7f000001), hints); | 192 | *res = malloc_ai(port, htonl(0x7f000001), hints); |
193 | if (*res == NULL) | 193 | if (*res == NULL) |
194 | return (EAI_MEMORY); | 194 | return (EAI_MEMORY); |
195 | return (0); | 195 | return (0); |
196 | } | 196 | } |
197 | 197 | ||
198 | if (inet_aton(hostname, &in)) { | 198 | if (inet_aton(hostname, &in)) { |
199 | *res = malloc_ai(port, in.s_addr, hints); | 199 | *res = malloc_ai(port, in.s_addr, hints); |
200 | if (*res == NULL) | 200 | if (*res == NULL) |
201 | return (EAI_MEMORY); | 201 | return (EAI_MEMORY); |
202 | return (0); | 202 | return (0); |
203 | } | 203 | } |
204 | 204 | ||
205 | /* Don't try DNS if AI_NUMERICHOST is set */ | 205 | /* Don't try DNS if AI_NUMERICHOST is set */ |
206 | if (hints && hints->ai_flags & AI_NUMERICHOST) | 206 | if (hints && hints->ai_flags & AI_NUMERICHOST) |
207 | return (EAI_NONAME); | 207 | return (EAI_NONAME); |
208 | 208 | ||
209 | hp = gethostbyname(hostname); | 209 | hp = gethostbyname(hostname); |
210 | if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { | 210 | if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { |
211 | struct addrinfo *cur, *prev; | 211 | struct addrinfo *cur, *prev; |
@@ -229,7 +229,7 @@ getaddrinfo(const char *hostname, const char *servname, | |||
229 | } | 229 | } |
230 | return (0); | 230 | return (0); |
231 | } | 231 | } |
232 | 232 | ||
233 | return (EAI_NODATA); | 233 | return (EAI_NODATA); |
234 | } | 234 | } |
235 | #endif /* !HAVE_GETADDRINFO */ | 235 | #endif /* !HAVE_GETADDRINFO */ |
diff --git a/openbsd-compat/fake-rfc2553.h b/openbsd-compat/fake-rfc2553.h index 6426f7bf6..f913617fe 100644 --- a/openbsd-compat/fake-rfc2553.h +++ b/openbsd-compat/fake-rfc2553.h | |||
@@ -1,9 +1,7 @@ | |||
1 | /* $Id: fake-rfc2553.h,v 1.16 2008/07/14 11:37:37 djm Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (C) 2000-2003 Damien Miller. All rights reserved. | 2 | * Copyright (C) 2000-2003 Damien Miller. All rights reserved. |
5 | * Copyright (C) 1999 WIDE Project. All rights reserved. | 3 | * Copyright (C) 1999 WIDE Project. All rights reserved. |
6 | * | 4 | * |
7 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
9 | * are met: | 7 | * are met: |
@@ -15,7 +13,7 @@ | |||
15 | * 3. Neither the name of the project nor the names of its contributors | 13 | * 3. Neither the name of the project nor the names of its contributors |
16 | * may be used to endorse or promote products derived from this software | 14 | * may be used to endorse or promote products derived from this software |
17 | * without specific prior written permission. | 15 | * without specific prior written permission. |
18 | * | 16 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -47,7 +45,7 @@ | |||
47 | #endif | 45 | #endif |
48 | 46 | ||
49 | /* | 47 | /* |
50 | * First, socket and INET6 related definitions | 48 | * First, socket and INET6 related definitions |
51 | */ | 49 | */ |
52 | #ifndef HAVE_STRUCT_SOCKADDR_STORAGE | 50 | #ifndef HAVE_STRUCT_SOCKADDR_STORAGE |
53 | # define _SS_MAXSIZE 128 /* Implementation specific max size */ | 51 | # define _SS_MAXSIZE 128 /* Implementation specific max size */ |
@@ -154,7 +152,7 @@ struct addrinfo { | |||
154 | # undef getaddrinfo | 152 | # undef getaddrinfo |
155 | #endif | 153 | #endif |
156 | #define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d)) | 154 | #define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d)) |
157 | int getaddrinfo(const char *, const char *, | 155 | int getaddrinfo(const char *, const char *, |
158 | const struct addrinfo *, struct addrinfo **); | 156 | const struct addrinfo *, struct addrinfo **); |
159 | #endif /* !HAVE_GETADDRINFO */ | 157 | #endif /* !HAVE_GETADDRINFO */ |
160 | 158 | ||
@@ -170,7 +168,7 @@ void freeaddrinfo(struct addrinfo *); | |||
170 | 168 | ||
171 | #ifndef HAVE_GETNAMEINFO | 169 | #ifndef HAVE_GETNAMEINFO |
172 | #define getnameinfo(a,b,c,d,e,f,g) (ssh_getnameinfo(a,b,c,d,e,f,g)) | 170 | #define getnameinfo(a,b,c,d,e,f,g) (ssh_getnameinfo(a,b,c,d,e,f,g)) |
173 | int getnameinfo(const struct sockaddr *, size_t, char *, size_t, | 171 | int getnameinfo(const struct sockaddr *, size_t, char *, size_t, |
174 | char *, size_t, int); | 172 | char *, size_t, int); |
175 | #endif /* !HAVE_GETNAMEINFO */ | 173 | #endif /* !HAVE_GETNAMEINFO */ |
176 | 174 | ||
diff --git a/openbsd-compat/getcwd.c b/openbsd-compat/getcwd.c index 3edbb9cba..e4f7f5a3d 100644 --- a/openbsd-compat/getcwd.c +++ b/openbsd-compat/getcwd.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* from OpenBSD: getcwd.c,v 1.14 2005/08/08 08:05:34 espie Exp */ | 1 | /* $OpenBSD: getcwd.c,v 1.14 2005/08/08 08:05:34 espie Exp */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1989, 1991, 1993 | 3 | * Copyright (c) 1989, 1991, 1993 |
4 | * The Regents of the University of California. All rights reserved. | 4 | * The Regents of the University of California. All rights reserved. |
diff --git a/openbsd-compat/getgrouplist.c b/openbsd-compat/getgrouplist.c index 3afcb9281..3906cd629 100644 --- a/openbsd-compat/getgrouplist.c +++ b/openbsd-compat/getgrouplist.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* from OpenBSD: getgrouplist.c,v 1.12 2005/08/08 08:05:34 espie Exp */ | 1 | /* $OpenBSD: getgrouplist.c,v 1.12 2005/08/08 08:05:34 espie Exp */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1991, 1993 | 3 | * Copyright (c) 1991, 1993 |
4 | * The Regents of the University of California. All rights reserved. | 4 | * The Regents of the University of California. All rights reserved. |
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index 37d2064cd..cff547745 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: openbsd-compat.h,v 1.62 2014/09/30 23:43:08 djm Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. | 2 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
5 | * Copyright (c) 2003 Ben Lindstrom. All rights reserved. | 3 | * Copyright (c) 2003 Ben Lindstrom. All rights reserved. |
@@ -64,7 +62,7 @@ void closefrom(int); | |||
64 | 62 | ||
65 | #ifndef HAVE_GETCWD | 63 | #ifndef HAVE_GETCWD |
66 | char *getcwd(char *pt, size_t size); | 64 | char *getcwd(char *pt, size_t size); |
67 | #endif | 65 | #endif |
68 | 66 | ||
69 | #ifndef HAVE_REALLOCARRAY | 67 | #ifndef HAVE_REALLOCARRAY |
70 | void *reallocarray(void *, size_t, size_t); | 68 | void *reallocarray(void *, size_t, size_t); |
@@ -87,14 +85,16 @@ int rresvport_af(int *alport, sa_family_t af); | |||
87 | #endif | 85 | #endif |
88 | 86 | ||
89 | #ifndef HAVE_STRLCPY | 87 | #ifndef HAVE_STRLCPY |
90 | /* #include <sys/types.h> XXX Still needed? */ | ||
91 | size_t strlcpy(char *dst, const char *src, size_t siz); | 88 | size_t strlcpy(char *dst, const char *src, size_t siz); |
92 | #endif | 89 | #endif |
93 | 90 | ||
94 | #ifndef HAVE_STRLCAT | 91 | #ifndef HAVE_STRLCAT |
95 | /* #include <sys/types.h> XXX Still needed? */ | ||
96 | size_t strlcat(char *dst, const char *src, size_t siz); | 92 | size_t strlcat(char *dst, const char *src, size_t siz); |
97 | #endif | 93 | #endif |
94 | |||
95 | #ifndef HAVE_STRCASESTR | ||
96 | char *strcasestr(const char *, const char *); | ||
97 | #endif | ||
98 | 98 | ||
99 | #ifndef HAVE_SETENV | 99 | #ifndef HAVE_SETENV |
100 | int setenv(register const char *name, register const char *value, int rewrite); | 100 | int setenv(register const char *name, register const char *value, int rewrite); |
@@ -113,11 +113,11 @@ char *strptime(const char *buf, const char *fmt, struct tm *tm); | |||
113 | int mkstemps(char *path, int slen); | 113 | int mkstemps(char *path, int slen); |
114 | int mkstemp(char *path); | 114 | int mkstemp(char *path); |
115 | char *mkdtemp(char *path); | 115 | char *mkdtemp(char *path); |
116 | #endif | 116 | #endif |
117 | 117 | ||
118 | #ifndef HAVE_DAEMON | 118 | #ifndef HAVE_DAEMON |
119 | int daemon(int nochdir, int noclose); | 119 | int daemon(int nochdir, int noclose); |
120 | #endif | 120 | #endif |
121 | 121 | ||
122 | #ifndef HAVE_DIRNAME | 122 | #ifndef HAVE_DIRNAME |
123 | char *dirname(const char *path); | 123 | char *dirname(const char *path); |
@@ -142,7 +142,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); | |||
142 | 142 | ||
143 | #ifndef HAVE_INET_ATON | 143 | #ifndef HAVE_INET_ATON |
144 | int inet_aton(const char *cp, struct in_addr *addr); | 144 | int inet_aton(const char *cp, struct in_addr *addr); |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | #ifndef HAVE_STRSEP | 147 | #ifndef HAVE_STRSEP |
148 | char *strsep(char **stringp, const char *delim); | 148 | char *strsep(char **stringp, const char *delim); |
@@ -154,7 +154,6 @@ void compat_init_setproctitle(int argc, char *argv[]); | |||
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | #ifndef HAVE_GETGROUPLIST | 156 | #ifndef HAVE_GETGROUPLIST |
157 | /* #include <grp.h> XXXX Still needed ? */ | ||
158 | int getgrouplist(const char *, gid_t, gid_t *, int *); | 157 | int getgrouplist(const char *, gid_t, gid_t *, int *); |
159 | #endif | 158 | #endif |
160 | 159 | ||
@@ -199,18 +198,16 @@ u_int32_t arc4random_uniform(u_int32_t); | |||
199 | 198 | ||
200 | #ifndef HAVE_ASPRINTF | 199 | #ifndef HAVE_ASPRINTF |
201 | int asprintf(char **, const char *, ...); | 200 | int asprintf(char **, const char *, ...); |
202 | #endif | 201 | #endif |
203 | 202 | ||
204 | #ifndef HAVE_OPENPTY | 203 | #ifndef HAVE_OPENPTY |
205 | # include <sys/ioctl.h> /* for struct winsize */ | 204 | # include <sys/ioctl.h> /* for struct winsize */ |
206 | int openpty(int *, int *, char *, struct termios *, struct winsize *); | 205 | int openpty(int *, int *, char *, struct termios *, struct winsize *); |
207 | #endif /* HAVE_OPENPTY */ | 206 | #endif /* HAVE_OPENPTY */ |
208 | 207 | ||
209 | /* #include <sys/types.h> XXX needed? For size_t */ | ||
210 | |||
211 | #ifndef HAVE_SNPRINTF | 208 | #ifndef HAVE_SNPRINTF |
212 | int snprintf(char *, size_t, SNPRINTF_CONST char *, ...); | 209 | int snprintf(char *, size_t, SNPRINTF_CONST char *, ...); |
213 | #endif | 210 | #endif |
214 | 211 | ||
215 | #ifndef HAVE_STRTOLL | 212 | #ifndef HAVE_STRTOLL |
216 | long long strtoll(const char *, char **, int); | 213 | long long strtoll(const char *, char **, int); |
@@ -299,7 +296,6 @@ int bcrypt_pbkdf(const char *, size_t, const u_int8_t *, size_t, | |||
299 | void explicit_bzero(void *p, size_t n); | 296 | void explicit_bzero(void *p, size_t n); |
300 | #endif | 297 | #endif |
301 | 298 | ||
302 | void *xmmap(size_t size); | ||
303 | char *xcrypt(const char *password, const char *salt); | 299 | char *xcrypt(const char *password, const char *salt); |
304 | char *shadow_pw(struct passwd *pw); | 300 | char *shadow_pw(struct passwd *pw); |
305 | 301 | ||
diff --git a/openbsd-compat/openssl-compat.c b/openbsd-compat/openssl-compat.c index 63a660c7a..259fccbec 100644 --- a/openbsd-compat/openssl-compat.c +++ b/openbsd-compat/openssl-compat.c | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: openssl-compat.c,v 1.19 2014/07/02 05:28:07 djm Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> | 2 | * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> |
5 | * | 3 | * |
@@ -55,7 +53,7 @@ ssh_compatible_openssl(long headerver, long libver) | |||
55 | mask = 0xfffff00fL; /* major,minor,fix,status */ | 53 | mask = 0xfffff00fL; /* major,minor,fix,status */ |
56 | return (headerver & mask) == (libver & mask); | 54 | return (headerver & mask) == (libver & mask); |
57 | } | 55 | } |
58 | 56 | ||
59 | /* | 57 | /* |
60 | * For versions >= 1.0.0, major,minor,status must match and library | 58 | * For versions >= 1.0.0, major,minor,status must match and library |
61 | * fix version must be equal to or newer than the header. | 59 | * fix version must be equal to or newer than the header. |
diff --git a/openbsd-compat/openssl-compat.h b/openbsd-compat/openssl-compat.h index 8917551d3..2ae42bacf 100644 --- a/openbsd-compat/openssl-compat.h +++ b/openbsd-compat/openssl-compat.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: openssl-compat.h,v 1.31 2014/08/29 18:18:29 djm Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> | 2 | * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> |
5 | * | 3 | * |
@@ -71,6 +69,12 @@ void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, size_t); | |||
71 | # endif | 69 | # endif |
72 | #endif | 70 | #endif |
73 | 71 | ||
72 | #if defined(HAVE_EVP_RIPEMD160) | ||
73 | # if defined(OPENSSL_NO_RIPEMD) || defined(OPENSSL_NO_RMD160) | ||
74 | # undef HAVE_EVP_RIPEMD160 | ||
75 | # endif | ||
76 | #endif | ||
77 | |||
74 | /* | 78 | /* |
75 | * We overload some of the OpenSSL crypto functions with ssh_* equivalents | 79 | * We overload some of the OpenSSL crypto functions with ssh_* equivalents |
76 | * to automatically handle OpenSSL engine initialisation. | 80 | * to automatically handle OpenSSL engine initialisation. |
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c index 8da367d48..c2970c4db 100644 --- a/openbsd-compat/port-aix.c +++ b/openbsd-compat/port-aix.c | |||
@@ -179,7 +179,7 @@ sys_auth_passwd(Authctxt *ctxt, const char *password) | |||
179 | do { | 179 | do { |
180 | result = authenticate((char *)name, (char *)password, &reenter, | 180 | result = authenticate((char *)name, (char *)password, &reenter, |
181 | &authmsg); | 181 | &authmsg); |
182 | aix_remove_embedded_newlines(authmsg); | 182 | aix_remove_embedded_newlines(authmsg); |
183 | debug3("AIX/authenticate result %d, authmsg %.100s", result, | 183 | debug3("AIX/authenticate result %d, authmsg %.100s", result, |
184 | authmsg); | 184 | authmsg); |
185 | } while (reenter); | 185 | } while (reenter); |
@@ -337,11 +337,11 @@ aix_setauthdb(const char *user) | |||
337 | debug3("%s: Could not open userdb to read", __func__); | 337 | debug3("%s: Could not open userdb to read", __func__); |
338 | return; | 338 | return; |
339 | } | 339 | } |
340 | 340 | ||
341 | if (getuserattr((char *)user, S_REGISTRY, ®istry, SEC_CHAR) == 0) { | 341 | if (getuserattr((char *)user, S_REGISTRY, ®istry, SEC_CHAR) == 0) { |
342 | if (setauthdb(registry, old_registry) == 0) | 342 | if (setauthdb(registry, old_registry) == 0) |
343 | debug3("AIX/setauthdb set registry '%s'", registry); | 343 | debug3("AIX/setauthdb set registry '%s'", registry); |
344 | else | 344 | else |
345 | debug3("AIX/setauthdb set registry '%s' failed: %s", | 345 | debug3("AIX/setauthdb set registry '%s' failed: %s", |
346 | registry, strerror(errno)); | 346 | registry, strerror(errno)); |
347 | } else | 347 | } else |
diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h index 53e4e88a0..9c0a4dd3e 100644 --- a/openbsd-compat/port-aix.h +++ b/openbsd-compat/port-aix.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: port-aix.h,v 1.32 2009/12/20 23:49:22 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * | 2 | * |
5 | * Copyright (c) 2001 Gert Doering. All rights reserved. | 3 | * Copyright (c) 2001 Gert Doering. All rights reserved. |
diff --git a/openbsd-compat/port-irix.c b/openbsd-compat/port-irix.c index ba751a538..525b02909 100644 --- a/openbsd-compat/port-irix.c +++ b/openbsd-compat/port-irix.c | |||
@@ -47,42 +47,42 @@ void | |||
47 | irix_setusercontext(struct passwd *pw) | 47 | irix_setusercontext(struct passwd *pw) |
48 | { | 48 | { |
49 | #ifdef WITH_IRIX_PROJECT | 49 | #ifdef WITH_IRIX_PROJECT |
50 | prid_t projid; | 50 | prid_t projid; |
51 | #endif | 51 | #endif |
52 | #ifdef WITH_IRIX_JOBS | 52 | #ifdef WITH_IRIX_JOBS |
53 | jid_t jid = 0; | 53 | jid_t jid = 0; |
54 | #elif defined(WITH_IRIX_ARRAY) | 54 | #elif defined(WITH_IRIX_ARRAY) |
55 | int jid = 0; | 55 | int jid = 0; |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #ifdef WITH_IRIX_JOBS | 58 | #ifdef WITH_IRIX_JOBS |
59 | jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); | 59 | jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); |
60 | if (jid == -1) | 60 | if (jid == -1) |
61 | fatal("Failed to create job container: %.100s", | 61 | fatal("Failed to create job container: %.100s", |
62 | strerror(errno)); | 62 | strerror(errno)); |
63 | #endif /* WITH_IRIX_JOBS */ | 63 | #endif /* WITH_IRIX_JOBS */ |
64 | #ifdef WITH_IRIX_ARRAY | 64 | #ifdef WITH_IRIX_ARRAY |
65 | /* initialize array session */ | 65 | /* initialize array session */ |
66 | if (jid == 0 && newarraysess() != 0) | 66 | if (jid == 0 && newarraysess() != 0) |
67 | fatal("Failed to set up new array session: %.100s", | 67 | fatal("Failed to set up new array session: %.100s", |
68 | strerror(errno)); | 68 | strerror(errno)); |
69 | #endif /* WITH_IRIX_ARRAY */ | 69 | #endif /* WITH_IRIX_ARRAY */ |
70 | #ifdef WITH_IRIX_PROJECT | 70 | #ifdef WITH_IRIX_PROJECT |
71 | /* initialize irix project info */ | 71 | /* initialize irix project info */ |
72 | if ((projid = getdfltprojuser(pw->pw_name)) == -1) { | 72 | if ((projid = getdfltprojuser(pw->pw_name)) == -1) { |
73 | debug("Failed to get project id, using projid 0"); | 73 | debug("Failed to get project id, using projid 0"); |
74 | projid = 0; | 74 | projid = 0; |
75 | } | 75 | } |
76 | if (setprid(projid)) | 76 | if (setprid(projid)) |
77 | fatal("Failed to initialize project %d for %s: %.100s", | 77 | fatal("Failed to initialize project %d for %s: %.100s", |
78 | (int)projid, pw->pw_name, strerror(errno)); | 78 | (int)projid, pw->pw_name, strerror(errno)); |
79 | #endif /* WITH_IRIX_PROJECT */ | 79 | #endif /* WITH_IRIX_PROJECT */ |
80 | #ifdef WITH_IRIX_AUDIT | 80 | #ifdef WITH_IRIX_AUDIT |
81 | if (sysconf(_SC_AUDIT)) { | 81 | if (sysconf(_SC_AUDIT)) { |
82 | debug("Setting sat id to %d", (int) pw->pw_uid); | 82 | debug("Setting sat id to %d", (int) pw->pw_uid); |
83 | if (satsetid(pw->pw_uid)) | 83 | if (satsetid(pw->pw_uid)) |
84 | debug("error setting satid: %.100s", strerror(errno)); | 84 | debug("error setting satid: %.100s", strerror(errno)); |
85 | } | 85 | } |
86 | #endif /* WITH_IRIX_AUDIT */ | 86 | #endif /* WITH_IRIX_AUDIT */ |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/openbsd-compat/port-irix.h b/openbsd-compat/port-irix.h index 67c486307..bc8cc44ac 100644 --- a/openbsd-compat/port-irix.h +++ b/openbsd-compat/port-irix.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: port-irix.h,v 1.4 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2000 Denis Parker. All rights reserved. | 2 | * Copyright (c) 2000 Denis Parker. All rights reserved. |
5 | * Copyright (c) 2000 Michael Stone. All rights reserved. | 3 | * Copyright (c) 2000 Michael Stone. All rights reserved. |
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c index f36999d7a..e4c5d1b7c 100644 --- a/openbsd-compat/port-linux.c +++ b/openbsd-compat/port-linux.c | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: port-linux.c,v 1.18 2013/06/01 22:07:32 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com> | 2 | * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com> |
5 | * Copyright (c) 2006 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2006 Damien Miller <djm@openbsd.org> |
diff --git a/openbsd-compat/port-linux.h b/openbsd-compat/port-linux.h index e3d1004aa..3c22a854d 100644 --- a/openbsd-compat/port-linux.h +++ b/openbsd-compat/port-linux.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: port-linux.h,v 1.5 2011/01/25 01:16:18 djm Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2006 Damien Miller <djm@openbsd.org> | 2 | * Copyright (c) 2006 Damien Miller <djm@openbsd.org> |
5 | * | 3 | * |
diff --git a/openbsd-compat/port-solaris.c b/openbsd-compat/port-solaris.c index e36e412d7..0e89dc326 100644 --- a/openbsd-compat/port-solaris.c +++ b/openbsd-compat/port-solaris.c | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: port-solaris.c,v 1.4 2010/11/05 01:03:05 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2006 Chad Mynhier. | 2 | * Copyright (c) 2006 Chad Mynhier. |
5 | * | 3 | * |
@@ -215,7 +213,7 @@ solaris_set_default_project(struct passwd *pw) | |||
215 | 213 | ||
216 | /* get default project, if we fail just return gracefully */ | 214 | /* get default project, if we fail just return gracefully */ |
217 | if ((defaultproject = getdefaultproj(pw->pw_name, &tempproject, &buf, | 215 | if ((defaultproject = getdefaultproj(pw->pw_name, &tempproject, &buf, |
218 | sizeof(buf))) > 0) { | 216 | sizeof(buf))) != NULL) { |
219 | /* set default project */ | 217 | /* set default project */ |
220 | if (setproject(defaultproject->pj_name, pw->pw_name, | 218 | if (setproject(defaultproject->pj_name, pw->pw_name, |
221 | TASK_NORMAL) != 0) | 219 | TASK_NORMAL) != 0) |
diff --git a/openbsd-compat/port-solaris.h b/openbsd-compat/port-solaris.h index a7cb5eb30..dde1a5b8b 100644 --- a/openbsd-compat/port-solaris.h +++ b/openbsd-compat/port-solaris.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* $Id: port-solaris.h,v 1.2 2010/11/05 01:03:05 dtucker Exp $ */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * Copyright (c) 2006 Chad Mynhier. | 2 | * Copyright (c) 2006 Chad Mynhier. |
5 | * | 3 | * |
diff --git a/openbsd-compat/port-tun.c b/openbsd-compat/port-tun.c index 49e7b4d99..a444adf1d 100644 --- a/openbsd-compat/port-tun.c +++ b/openbsd-compat/port-tun.c | |||
@@ -68,7 +68,7 @@ sys_tun_open(int tun, int mode) | |||
68 | return (-1); | 68 | return (-1); |
69 | } | 69 | } |
70 | 70 | ||
71 | bzero(&ifr, sizeof(ifr)); | 71 | bzero(&ifr, sizeof(ifr)); |
72 | 72 | ||
73 | if (mode == SSH_TUNMODE_ETHERNET) { | 73 | if (mode == SSH_TUNMODE_ETHERNET) { |
74 | ifr.ifr_flags = IFF_TAP; | 74 | ifr.ifr_flags = IFF_TAP; |
diff --git a/openbsd-compat/readpassphrase.c b/openbsd-compat/readpassphrase.c index d63cdf2f0..24aed6e46 100644 --- a/openbsd-compat/readpassphrase.c +++ b/openbsd-compat/readpassphrase.c | |||
@@ -1,7 +1,8 @@ | |||
1 | /* $OpenBSD: readpassphrase.c,v 1.22 2010/01/13 10:20:54 dtucker Exp $ */ | 1 | /* $OpenBSD: readpassphrase.c,v 1.26 2016/10/18 12:47:18 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2000-2002, 2007 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 2000-2002, 2007, 2010 |
5 | * Todd C. Miller <Todd.Miller@courtesan.com> | ||
5 | * | 6 | * |
6 | * Permission to use, copy, modify, and distribute this software for any | 7 | * Permission to use, copy, modify, and distribute this software for any |
7 | * purpose with or without fee is hereby granted, provided that the above | 8 | * purpose with or without fee is hereby granted, provided that the above |
@@ -35,10 +36,9 @@ | |||
35 | #include <string.h> | 36 | #include <string.h> |
36 | #include <unistd.h> | 37 | #include <unistd.h> |
37 | 38 | ||
38 | #ifdef TCSASOFT | 39 | #ifndef TCSASOFT |
39 | # define _T_FLUSH (TCSAFLUSH|TCSASOFT) | 40 | /* If we don't have TCSASOFT define it so that ORing it it below is a no-op. */ |
40 | #else | 41 | # define TCSASOFT 0 |
41 | # define _T_FLUSH (TCSAFLUSH) | ||
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | /* SunOS 4.x which lacks _POSIX_VDISABLE, but has VDISABLE */ | 44 | /* SunOS 4.x which lacks _POSIX_VDISABLE, but has VDISABLE */ |
@@ -95,6 +95,27 @@ restart: | |||
95 | } | 95 | } |
96 | 96 | ||
97 | /* | 97 | /* |
98 | * Turn off echo if possible. | ||
99 | * If we are using a tty but are not the foreground pgrp this will | ||
100 | * generate SIGTTOU, so do it *before* installing the signal handlers. | ||
101 | */ | ||
102 | if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) { | ||
103 | memcpy(&term, &oterm, sizeof(term)); | ||
104 | if (!(flags & RPP_ECHO_ON)) | ||
105 | term.c_lflag &= ~(ECHO | ECHONL); | ||
106 | #ifdef VSTATUS | ||
107 | if (term.c_cc[VSTATUS] != _POSIX_VDISABLE) | ||
108 | term.c_cc[VSTATUS] = _POSIX_VDISABLE; | ||
109 | #endif | ||
110 | (void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &term); | ||
111 | } else { | ||
112 | memset(&term, 0, sizeof(term)); | ||
113 | term.c_lflag |= ECHO; | ||
114 | memset(&oterm, 0, sizeof(oterm)); | ||
115 | oterm.c_lflag |= ECHO; | ||
116 | } | ||
117 | |||
118 | /* | ||
98 | * Catch signals that would otherwise cause the user to end | 119 | * Catch signals that would otherwise cause the user to end |
99 | * up with echo turned off in the shell. Don't worry about | 120 | * up with echo turned off in the shell. Don't worry about |
100 | * things like SIGXCPU and SIGVTALRM for now. | 121 | * things like SIGXCPU and SIGVTALRM for now. |
@@ -112,53 +133,37 @@ restart: | |||
112 | (void)sigaction(SIGTTIN, &sa, &savettin); | 133 | (void)sigaction(SIGTTIN, &sa, &savettin); |
113 | (void)sigaction(SIGTTOU, &sa, &savettou); | 134 | (void)sigaction(SIGTTOU, &sa, &savettou); |
114 | 135 | ||
115 | /* Turn off echo if possible. */ | 136 | if (!(flags & RPP_STDIN)) |
116 | if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) { | 137 | (void)write(output, prompt, strlen(prompt)); |
117 | memcpy(&term, &oterm, sizeof(term)); | 138 | end = buf + bufsiz - 1; |
118 | if (!(flags & RPP_ECHO_ON)) | 139 | p = buf; |
119 | term.c_lflag &= ~(ECHO | ECHONL); | 140 | while ((nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r') { |
120 | #ifdef VSTATUS | 141 | if (p < end) { |
121 | if (term.c_cc[VSTATUS] != _POSIX_VDISABLE) | 142 | if ((flags & RPP_SEVENBIT)) |
122 | term.c_cc[VSTATUS] = _POSIX_VDISABLE; | 143 | ch &= 0x7f; |
123 | #endif | 144 | if (isalpha((unsigned char)ch)) { |
124 | (void)tcsetattr(input, _T_FLUSH, &term); | 145 | if ((flags & RPP_FORCELOWER)) |
125 | } else { | 146 | ch = (char)tolower((unsigned char)ch); |
126 | memset(&term, 0, sizeof(term)); | 147 | if ((flags & RPP_FORCEUPPER)) |
127 | term.c_lflag |= ECHO; | 148 | ch = (char)toupper((unsigned char)ch); |
128 | memset(&oterm, 0, sizeof(oterm)); | ||
129 | oterm.c_lflag |= ECHO; | ||
130 | } | ||
131 | |||
132 | /* No I/O if we are already backgrounded. */ | ||
133 | if (signo[SIGTTOU] != 1 && signo[SIGTTIN] != 1) { | ||
134 | if (!(flags & RPP_STDIN)) | ||
135 | (void)write(output, prompt, strlen(prompt)); | ||
136 | end = buf + bufsiz - 1; | ||
137 | p = buf; | ||
138 | while ((nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r') { | ||
139 | if (p < end) { | ||
140 | if ((flags & RPP_SEVENBIT)) | ||
141 | ch &= 0x7f; | ||
142 | if (isalpha(ch)) { | ||
143 | if ((flags & RPP_FORCELOWER)) | ||
144 | ch = (char)tolower(ch); | ||
145 | if ((flags & RPP_FORCEUPPER)) | ||
146 | ch = (char)toupper(ch); | ||
147 | } | ||
148 | *p++ = ch; | ||
149 | } | 149 | } |
150 | *p++ = ch; | ||
150 | } | 151 | } |
151 | *p = '\0'; | ||
152 | save_errno = errno; | ||
153 | if (!(term.c_lflag & ECHO)) | ||
154 | (void)write(output, "\n", 1); | ||
155 | } | 152 | } |
153 | *p = '\0'; | ||
154 | save_errno = errno; | ||
155 | if (!(term.c_lflag & ECHO)) | ||
156 | (void)write(output, "\n", 1); | ||
156 | 157 | ||
157 | /* Restore old terminal settings and signals. */ | 158 | /* Restore old terminal settings and signals. */ |
158 | if (memcmp(&term, &oterm, sizeof(term)) != 0) { | 159 | if (memcmp(&term, &oterm, sizeof(term)) != 0) { |
159 | while (tcsetattr(input, _T_FLUSH, &oterm) == -1 && | 160 | const int sigttou = signo[SIGTTOU]; |
160 | errno == EINTR) | 161 | |
162 | /* Ignore SIGTTOU generated when we are not the fg pgrp. */ | ||
163 | while (tcsetattr(input, TCSAFLUSH|TCSASOFT, &oterm) == -1 && | ||
164 | errno == EINTR && !signo[SIGTTOU]) | ||
161 | continue; | 165 | continue; |
166 | signo[SIGTTOU] = sigttou; | ||
162 | } | 167 | } |
163 | (void)sigaction(SIGALRM, &savealrm, NULL); | 168 | (void)sigaction(SIGALRM, &savealrm, NULL); |
164 | (void)sigaction(SIGHUP, &savehup, NULL); | 169 | (void)sigaction(SIGHUP, &savehup, NULL); |
@@ -194,6 +199,7 @@ restart: | |||
194 | errno = save_errno; | 199 | errno = save_errno; |
195 | return(nr == -1 ? NULL : buf); | 200 | return(nr == -1 ? NULL : buf); |
196 | } | 201 | } |
202 | DEF_WEAK(readpassphrase); | ||
197 | 203 | ||
198 | #if 0 | 204 | #if 0 |
199 | char * | 205 | char * |
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c index 9f7ca14c2..2b15c6e00 100644 --- a/openbsd-compat/setproctitle.c +++ b/openbsd-compat/setproctitle.c | |||
@@ -76,7 +76,7 @@ compat_init_setproctitle(int argc, char *argv[]) | |||
76 | 76 | ||
77 | /* | 77 | /* |
78 | * NB: This assumes that argv has already been copied out of the | 78 | * NB: This assumes that argv has already been copied out of the |
79 | * way. This is true for sshd, but may not be true for other | 79 | * way. This is true for sshd, but may not be true for other |
80 | * programs. Beware. | 80 | * programs. Beware. |
81 | */ | 81 | */ |
82 | 82 | ||
@@ -92,7 +92,7 @@ compat_init_setproctitle(int argc, char *argv[]) | |||
92 | } | 92 | } |
93 | 93 | ||
94 | /* | 94 | /* |
95 | * Find the last argv string or environment variable within | 95 | * Find the last argv string or environment variable within |
96 | * our process memory area. | 96 | * our process memory area. |
97 | */ | 97 | */ |
98 | for (i = 0; i < argc; i++) { | 98 | for (i = 0; i < argc; i++) { |
@@ -108,8 +108,8 @@ compat_init_setproctitle(int argc, char *argv[]) | |||
108 | argv_start = argv[0]; | 108 | argv_start = argv[0]; |
109 | argv_env_len = lastargv - argv[0] - 1; | 109 | argv_env_len = lastargv - argv[0] - 1; |
110 | 110 | ||
111 | /* | 111 | /* |
112 | * Copy environment | 112 | * Copy environment |
113 | * XXX - will truncate env on strdup fail | 113 | * XXX - will truncate env on strdup fail |
114 | */ | 114 | */ |
115 | for (i = 0; envp[i] != NULL; i++) | 115 | for (i = 0; envp[i] != NULL; i++) |
@@ -156,7 +156,7 @@ setproctitle(const char *fmt, ...) | |||
156 | pst.pst_command = ptitle; | 156 | pst.pst_command = ptitle; |
157 | pstat(PSTAT_SETCMD, pst, strlen(ptitle), 0, 0); | 157 | pstat(PSTAT_SETCMD, pst, strlen(ptitle), 0, 0); |
158 | #elif SPT_TYPE == SPT_REUSEARGV | 158 | #elif SPT_TYPE == SPT_REUSEARGV |
159 | /* debug("setproctitle: copy \"%s\" into len %d", | 159 | /* debug("setproctitle: copy \"%s\" into len %d", |
160 | buf, argv_env_len); */ | 160 | buf, argv_env_len); */ |
161 | len = strlcpy(argv_start, ptitle, argv_env_len); | 161 | len = strlcpy(argv_start, ptitle, argv_env_len); |
162 | for(; len < argv_env_len; len++) | 162 | for(; len < argv_env_len; len++) |
diff --git a/openbsd-compat/sha2.c b/openbsd-compat/sha2.c index 737935d46..a22099bbe 100644 --- a/openbsd-compat/sha2.c +++ b/openbsd-compat/sha2.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* from OpenBSD: sha2.c,v 1.11 2005/08/08 08:05:35 espie Exp */ | 1 | /* $OpenBSD: sha2.c,v 1.11 2005/08/08 08:05:35 espie Exp */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * FILE: sha2.c | 4 | * FILE: sha2.c |
diff --git a/openbsd-compat/sha2.h b/openbsd-compat/sha2.h index c8bfc3cd1..c6e6c97a5 100644 --- a/openbsd-compat/sha2.h +++ b/openbsd-compat/sha2.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* OpenBSD: sha2.h,v 1.6 2004/06/22 01:57:30 jfb Exp */ | 1 | /* $OpenBSD: sha2.h,v 1.6 2004/06/22 01:57:30 jfb Exp */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * FILE: sha2.h | 4 | * FILE: sha2.h |
diff --git a/openbsd-compat/strcasestr.c b/openbsd-compat/strcasestr.c new file mode 100644 index 000000000..4c4d1475a --- /dev/null +++ b/openbsd-compat/strcasestr.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* $OpenBSD: strcasestr.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /* $NetBSD: strcasestr.c,v 1.2 2005/02/09 21:35:47 kleink Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c) 1990, 1993 | ||
6 | * The Regents of the University of California. All rights reserved. | ||
7 | * | ||
8 | * This code is derived from software contributed to Berkeley by | ||
9 | * Chris Torek. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer. | ||
16 | * 2. Redistributions in binary form must reproduce the above copyright | ||
17 | * notice, this list of conditions and the following disclaimer in the | ||
18 | * documentation and/or other materials provided with the distribution. | ||
19 | * 3. Neither the name of the University nor the names of its contributors | ||
20 | * may be used to endorse or promote products derived from this software | ||
21 | * without specific prior written permission. | ||
22 | * | ||
23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | * SUCH DAMAGE. | ||
34 | */ | ||
35 | |||
36 | /* OPENBSD ORIGINAL: lib/libc/string/strcasestr.c */ | ||
37 | |||
38 | #include "includes.h" | ||
39 | |||
40 | #ifndef HAVE_STRCASESTR | ||
41 | |||
42 | #include <ctype.h> | ||
43 | #include <string.h> | ||
44 | |||
45 | /* | ||
46 | * Find the first occurrence of find in s, ignore case. | ||
47 | */ | ||
48 | char * | ||
49 | strcasestr(const char *s, const char *find) | ||
50 | { | ||
51 | char c, sc; | ||
52 | size_t len; | ||
53 | |||
54 | if ((c = *find++) != 0) { | ||
55 | c = (char)tolower((unsigned char)c); | ||
56 | len = strlen(find); | ||
57 | do { | ||
58 | do { | ||
59 | if ((sc = *s++) == 0) | ||
60 | return (NULL); | ||
61 | } while ((char)tolower((unsigned char)sc) != c); | ||
62 | } while (strncasecmp(s, find, len) != 0); | ||
63 | s--; | ||
64 | } | ||
65 | return ((char *)s); | ||
66 | } | ||
67 | DEF_WEAK(strcasestr); | ||
68 | |||
69 | #endif | ||
diff --git a/openbsd-compat/vis.c b/openbsd-compat/vis.c index 3cef6bafd..0e04ed025 100644 --- a/openbsd-compat/vis.c +++ b/openbsd-compat/vis.c | |||
@@ -33,12 +33,6 @@ | |||
33 | #include "includes.h" | 33 | #include "includes.h" |
34 | #if !defined(HAVE_STRNVIS) || defined(BROKEN_STRNVIS) | 34 | #if !defined(HAVE_STRNVIS) || defined(BROKEN_STRNVIS) |
35 | 35 | ||
36 | /* | ||
37 | * We want these to override in the BROKEN_STRNVIS case. TO avoid future sync | ||
38 | * problems no-op out the weak symbol definition rather than remove it. | ||
39 | */ | ||
40 | #define DEF_WEAK(x) | ||
41 | |||
42 | #include <sys/types.h> | 36 | #include <sys/types.h> |
43 | #include <errno.h> | 37 | #include <errno.h> |
44 | #include <ctype.h> | 38 | #include <ctype.h> |
diff --git a/openbsd-compat/xcrypt.c b/openbsd-compat/xcrypt.c index cf6a9b99f..c9c6283cc 100644 --- a/openbsd-compat/xcrypt.c +++ b/openbsd-compat/xcrypt.c | |||
@@ -42,7 +42,7 @@ | |||
42 | # include <sys/security.h> | 42 | # include <sys/security.h> |
43 | # include <sys/audit.h> | 43 | # include <sys/audit.h> |
44 | # include <prot.h> | 44 | # include <prot.h> |
45 | # endif | 45 | # endif |
46 | 46 | ||
47 | # if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) | 47 | # if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) |
48 | # include <shadow.h> | 48 | # include <shadow.h> |
@@ -108,20 +108,20 @@ xcrypt(const char *password, const char *salt) | |||
108 | salt = pick_salt(); | 108 | salt = pick_salt(); |
109 | 109 | ||
110 | # ifdef HAVE_MD5_PASSWORDS | 110 | # ifdef HAVE_MD5_PASSWORDS |
111 | if (is_md5_salt(salt)) | 111 | if (is_md5_salt(salt)) |
112 | crypted = md5_crypt(password, salt); | 112 | crypted = md5_crypt(password, salt); |
113 | else | 113 | else |
114 | crypted = crypt(password, salt); | 114 | crypted = crypt(password, salt); |
115 | # elif defined(__hpux) && !defined(HAVE_SECUREWARE) | 115 | # elif defined(__hpux) && !defined(HAVE_SECUREWARE) |
116 | if (iscomsec()) | 116 | if (iscomsec()) |
117 | crypted = bigcrypt(password, salt); | 117 | crypted = bigcrypt(password, salt); |
118 | else | 118 | else |
119 | crypted = crypt(password, salt); | 119 | crypted = crypt(password, salt); |
120 | # elif defined(HAVE_SECUREWARE) | 120 | # elif defined(HAVE_SECUREWARE) |
121 | crypted = bigcrypt(password, salt); | 121 | crypted = bigcrypt(password, salt); |
122 | # else | 122 | # else |
123 | crypted = crypt(password, salt); | 123 | crypted = crypt(password, salt); |
124 | # endif | 124 | # endif |
125 | 125 | ||
126 | return crypted; | 126 | return crypted; |
127 | } | 127 | } |
diff --git a/openbsd-compat/xmmap.c b/openbsd-compat/xmmap.c deleted file mode 100644 index 04c6babc2..000000000 --- a/openbsd-compat/xmmap.c +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2002 Tim Rice. All rights reserved. | ||
3 | * MAP_FAILED code by Solar Designer. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | */ | ||
25 | |||
26 | /* $Id: xmmap.c,v 1.15 2009/02/16 04:21:40 djm Exp $ */ | ||
27 | |||
28 | #include "includes.h" | ||
29 | |||
30 | #include <sys/types.h> | ||
31 | #ifdef HAVE_SYS_MMAN_H | ||
32 | #include <sys/mman.h> | ||
33 | #endif | ||
34 | #include <sys/stat.h> | ||
35 | |||
36 | #ifdef HAVE_FCNTL_H | ||
37 | # include <fcntl.h> | ||
38 | #endif | ||
39 | #include <errno.h> | ||
40 | #include <stdarg.h> | ||
41 | #include <stdlib.h> | ||
42 | #include <string.h> | ||
43 | #include <unistd.h> | ||
44 | |||
45 | #include "log.h" | ||
46 | |||
47 | void * | ||
48 | xmmap(size_t size) | ||
49 | { | ||
50 | #ifdef HAVE_MMAP | ||
51 | void *address; | ||
52 | |||
53 | # ifdef MAP_ANON | ||
54 | address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED, | ||
55 | -1, (off_t)0); | ||
56 | # else | ||
57 | address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED, | ||
58 | open("/dev/zero", O_RDWR), (off_t)0); | ||
59 | # endif | ||
60 | |||
61 | #define MM_SWAP_TEMPLATE "/var/run/sshd.mm.XXXXXXXX" | ||
62 | if (address == (void *)MAP_FAILED) { | ||
63 | char tmpname[sizeof(MM_SWAP_TEMPLATE)] = MM_SWAP_TEMPLATE; | ||
64 | int tmpfd; | ||
65 | mode_t old_umask; | ||
66 | |||
67 | old_umask = umask(0177); | ||
68 | tmpfd = mkstemp(tmpname); | ||
69 | umask(old_umask); | ||
70 | if (tmpfd == -1) | ||
71 | fatal("mkstemp(\"%s\"): %s", | ||
72 | MM_SWAP_TEMPLATE, strerror(errno)); | ||
73 | unlink(tmpname); | ||
74 | if (ftruncate(tmpfd, size) != 0) | ||
75 | fatal("%s: ftruncate: %s", __func__, strerror(errno)); | ||
76 | address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED, | ||
77 | tmpfd, (off_t)0); | ||
78 | close(tmpfd); | ||
79 | } | ||
80 | |||
81 | return (address); | ||
82 | #else | ||
83 | fatal("%s: UsePrivilegeSeparation=yes and Compression=yes not supported", | ||
84 | __func__); | ||
85 | #endif /* HAVE_MMAP */ | ||
86 | |||
87 | } | ||
88 | |||