diff options
author | Colin Watson <cjwatson@debian.org> | 2003-09-23 18:08:35 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2003-09-23 18:08:35 +0000 |
commit | d59fd3e421aa81b8e5e118f3f806081df2aca879 (patch) | |
tree | 356a4e607edc979c625bb33db63c656d771478bd /openbsd-compat | |
parent | 7505658c58e96b8d270f1928a0e1fa7f3e0c266b (diff) | |
parent | 45431c9b4677608680cd071768cbf156b316a7e8 (diff) |
Merge 3.7.1p2 to the trunk. I have absolutely no idea yet whether this will
work.
Diffstat (limited to 'openbsd-compat')
79 files changed, 2681 insertions, 2046 deletions
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index 8615e3633..c48593f7b 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: Makefile.in,v 1.25 2003/02/24 01:55:56 djm Exp $ | 1 | # $Id: Makefile.in,v 1.28 2003/07/24 06:52:14 mouring Exp $ |
2 | 2 | ||
3 | sysconfdir=@sysconfdir@ | 3 | sysconfdir=@sysconfdir@ |
4 | piddir=@piddir@ | 4 | piddir=@piddir@ |
@@ -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 bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o vis.o | 19 | OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o vis.o |
20 | 20 | ||
21 | COMPAT=bsd-arc4random.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-snprintf.o bsd-waitpid.o fake-getaddrinfo.o fake-getnameinfo.o xmmap.o | 21 | COMPAT=bsd-arc4random.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o xmmap.o xcrypt.o |
22 | 22 | ||
23 | PORTS=port-irix.o port-aix.o | 23 | PORTS=port-irix.o port-aix.o |
24 | 24 | ||
diff --git a/openbsd-compat/base64.h b/openbsd-compat/base64.h index 72db3ffc7..732c6b3f8 100644 --- a/openbsd-compat/base64.h +++ b/openbsd-compat/base64.h | |||
@@ -1,23 +1,65 @@ | |||
1 | /* $Id: base64.h,v 1.4 2003/02/24 04:45:43 djm Exp $ */ | 1 | /* $Id: base64.h,v 1.6 2003/08/29 16:59:52 mouring Exp $ */ |
2 | |||
3 | /* | ||
4 | * Copyright (c) 1996 by Internet Software Consortium. | ||
5 | * | ||
6 | * 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 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS | ||
11 | * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | ||
12 | * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE | ||
13 | * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | ||
14 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | ||
15 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | ||
16 | * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | ||
17 | * SOFTWARE. | ||
18 | */ | ||
19 | |||
20 | /* | ||
21 | * Portions Copyright (c) 1995 by International Business Machines, Inc. | ||
22 | * | ||
23 | * International Business Machines, Inc. (hereinafter called IBM) grants | ||
24 | * permission under its copyrights to use, copy, modify, and distribute this | ||
25 | * Software with or without fee, provided that the above copyright notice and | ||
26 | * all paragraphs of this notice appear in all copies, and that the name of IBM | ||
27 | * not be used in connection with the marketing of any product incorporating | ||
28 | * the Software or modifications thereof, without specific, written prior | ||
29 | * permission. | ||
30 | * | ||
31 | * To the extent it has a right to do so, IBM grants an immunity from suit | ||
32 | * under its patents, if any, for the use, sale or manufacture of products to | ||
33 | * the extent that such products are used for performing Domain Name System | ||
34 | * dynamic updates in TCP/IP networks by means of the Software. No immunity is | ||
35 | * granted for any product per se or for any other function of any product. | ||
36 | * | ||
37 | * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, | ||
38 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
39 | * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, | ||
40 | * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING | ||
41 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN | ||
42 | * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. | ||
43 | */ | ||
2 | 44 | ||
3 | #ifndef _BSD_BASE64_H | 45 | #ifndef _BSD_BASE64_H |
4 | #define _BSD_BASE64_H | 46 | #define _BSD_BASE64_H |
5 | 47 | ||
6 | #include "config.h" | 48 | #include "includes.h" |
7 | 49 | ||
8 | #ifndef HAVE___B64_NTOP | 50 | #ifndef HAVE___B64_NTOP |
9 | # ifndef HAVE_B64_NTOP | 51 | # ifndef HAVE_B64_NTOP |
10 | int b64_ntop(u_char const *src, size_t srclength, char *target, | 52 | int b64_ntop(u_char const *src, size_t srclength, char *target, |
11 | size_t targsize); | 53 | size_t targsize); |
12 | # endif /* !HAVE_B64_NTOP */ | 54 | # endif /* !HAVE_B64_NTOP */ |
13 | # define __b64_ntop b64_ntop | 55 | # define __b64_ntop(a,b,c,d) b64_ntop(a,b,c,d) |
14 | #endif /* HAVE___B64_NTOP */ | 56 | #endif /* HAVE___B64_NTOP */ |
15 | 57 | ||
16 | #ifndef HAVE___B64_PTON | 58 | #ifndef HAVE___B64_PTON |
17 | # ifndef HAVE_B64_PTON | 59 | # ifndef HAVE_B64_PTON |
18 | int b64_pton(char const *src, u_char *target, size_t targsize); | 60 | int b64_pton(char const *src, u_char *target, size_t targsize); |
19 | # endif /* !HAVE_B64_PTON */ | 61 | # endif /* !HAVE_B64_PTON */ |
20 | # define __b64_pton b64_pton | 62 | # define __b64_pton(a,b,c) b64_pton(a,b,c) |
21 | #endif /* HAVE___B64_PTON */ | 63 | #endif /* HAVE___B64_PTON */ |
22 | 64 | ||
23 | #endif /* _BSD_BASE64_H */ | 65 | #endif /* _BSD_BASE64_H */ |
diff --git a/openbsd-compat/basename.c b/openbsd-compat/basename.c index 5a3823bc5..2054c8068 100644 --- a/openbsd-compat/basename.c +++ b/openbsd-compat/basename.c | |||
@@ -1,37 +1,26 @@ | |||
1 | /* $OpenBSD: basename.c,v 1.8 2002/06/09 05:03:59 deraadt Exp $ */ | 1 | /* $OpenBSD: basename.c,v 1.11 2003/06/17 21:56:23 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> |
5 | * All rights reserved. | ||
6 | * | 5 | * |
7 | * Redistribution and use in source and binary forms, with or without | 6 | * Permission to use, copy, modify, and distribute this software for any |
8 | * modification, are permitted provided that the following conditions | 7 | * purpose with or without fee is hereby granted, provided that the above |
9 | * are met: | 8 | * copyright notice and this permission notice appear in all copies. |
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of the author may not be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | 9 | * |
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | 17 | */ |
29 | #include "includes.h" | ||
30 | 18 | ||
31 | #if !defined(HAVE_BASENAME) | 19 | #include "includes.h" |
20 | #ifndef HAVE_BASENAME | ||
32 | 21 | ||
33 | #ifndef lint | 22 | #ifndef lint |
34 | static char rcsid[] = "$OpenBSD: basename.c,v 1.8 2002/06/09 05:03:59 deraadt Exp $"; | 23 | static char rcsid[] = "$OpenBSD: basename.c,v 1.11 2003/06/17 21:56:23 millert Exp $"; |
35 | #endif /* not lint */ | 24 | #endif /* not lint */ |
36 | 25 | ||
37 | char * | 26 | char * |
diff --git a/openbsd-compat/basename.h b/openbsd-compat/basename.h deleted file mode 100644 index a8bd6c17c..000000000 --- a/openbsd-compat/basename.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: basename.h,v 1.3 2003/02/25 03:32:16 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BASENAME_H | ||
4 | #define _BASENAME_H | ||
5 | #include "config.h" | ||
6 | |||
7 | #if !defined(HAVE_BASENAME) | ||
8 | |||
9 | char *basename(const char *path); | ||
10 | |||
11 | #endif /* !defined(HAVE_BASENAME) */ | ||
12 | #endif /* _BASENAME_H */ | ||
diff --git a/openbsd-compat/bindresvport.c b/openbsd-compat/bindresvport.c index 620f980ed..8a273f9b5 100644 --- a/openbsd-compat/bindresvport.c +++ b/openbsd-compat/bindresvport.c | |||
@@ -1,48 +1,37 @@ | |||
1 | /* This file has be modified from the original OpenBSD source */ | 1 | /* This file has be substantially modified from the original OpenBSD source */ |
2 | |||
3 | /* $OpenBSD: bindresvport.c,v 1.15 2003/05/20 22:42:35 deraadt Exp $ */ | ||
2 | 4 | ||
3 | /* | 5 | /* |
4 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for | 6 | * Copyright 1996, Jason Downs. All rights reserved. |
5 | * unrestricted use provided that this legend is included on all tape | 7 | * Copyright 1998, Theo de Raadt. All rights reserved. |
6 | * media and as a part of the software program in whole or part. Users | 8 | * Copyright 2000, Damien Miller. All rights reserved. |
7 | * may copy or modify Sun RPC without charge, but are not authorized | 9 | * |
8 | * to license or distribute it to anyone else except as part of a product or | 10 | * Redistribution and use in source and binary forms, with or without |
9 | * program developed by the user. | 11 | * modification, are permitted provided that the following conditions |
10 | * | 12 | * are met: |
11 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE | 13 | * 1. Redistributions of source code must retain the above copyright |
12 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR | 14 | * notice, this list of conditions and the following disclaimer. |
13 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * | 16 | * notice, this list of conditions and the following disclaimer in the |
15 | * Sun RPC is provided with no support and without any obligation on the | 17 | * documentation and/or other materials provided with the distribution. |
16 | * part of Sun Microsystems, Inc. to assist in its use, correction, | 18 | * |
17 | * modification or enhancement. | 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * | 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE | 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC | 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * OR ANY PART THEREOF. | 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * | 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue | 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * or profits or other special, indirect and consequential damages, even if | 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * Sun has been advised of the possibility of such damages. | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * | 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | * Sun Microsystems, Inc. | ||
28 | * 2550 Garcia Avenue | ||
29 | * Mountain View, California 94043 | ||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #include "includes.h" | 31 | #include "includes.h" |
33 | 32 | ||
34 | #ifndef HAVE_BINDRESVPORT_SA | 33 | #ifndef HAVE_BINDRESVPORT_SA |
35 | 34 | ||
36 | #if defined(LIBC_SCCS) && !defined(lint) | ||
37 | static char *rcsid = "$OpenBSD: bindresvport.c,v 1.13 2000/01/26 03:43:21 deraadt Exp $"; | ||
38 | #endif /* LIBC_SCCS and not lint */ | ||
39 | |||
40 | /* | ||
41 | * Copyright (c) 1987 by Sun Microsystems, Inc. | ||
42 | * | ||
43 | * Portions Copyright(C) 1996, Jason Downs. All rights reserved. | ||
44 | */ | ||
45 | |||
46 | #include "includes.h" | 35 | #include "includes.h" |
47 | 36 | ||
48 | #define STARTPORT 600 | 37 | #define STARTPORT 600 |
diff --git a/openbsd-compat/bindresvport.h b/openbsd-compat/bindresvport.h deleted file mode 100644 index b42f46983..000000000 --- a/openbsd-compat/bindresvport.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: bindresvport.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_BINDRESVPORT_H | ||
4 | #define _BSD_BINDRESVPORT_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_BINDRESVPORT_SA | ||
9 | int bindresvport_sa(int sd, struct sockaddr *sa); | ||
10 | #endif /* !HAVE_BINDRESVPORT_SA */ | ||
11 | |||
12 | #endif /* _BSD_BINDRESVPORT_H */ | ||
diff --git a/openbsd-compat/bsd-arc4random.c b/openbsd-compat/bsd-arc4random.c index dd08130d5..5f890968e 100644 --- a/openbsd-compat/bsd-arc4random.c +++ b/openbsd-compat/bsd-arc4random.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | #include "log.h" | 26 | #include "log.h" |
27 | 27 | ||
28 | RCSID("$Id: bsd-arc4random.c,v 1.6 2003/03/17 05:13:53 djm Exp $"); | 28 | RCSID("$Id: bsd-arc4random.c,v 1.7 2003/05/18 14:13:38 djm Exp $"); |
29 | 29 | ||
30 | #ifndef HAVE_ARC4RANDOM | 30 | #ifndef HAVE_ARC4RANDOM |
31 | 31 | ||
@@ -70,6 +70,7 @@ void arc4random_stir(void) | |||
70 | fatal("Couldn't obtain random bytes (error %ld)", | 70 | fatal("Couldn't obtain random bytes (error %ld)", |
71 | ERR_get_error()); | 71 | ERR_get_error()); |
72 | RC4_set_key(&rc4, sizeof(rand_buf), rand_buf); | 72 | RC4_set_key(&rc4, sizeof(rand_buf), rand_buf); |
73 | RC4(&rc4, sizeof(rand_buf), rand_buf, rand_buf); | ||
73 | memset(rand_buf, 0, sizeof(rand_buf)); | 74 | memset(rand_buf, 0, sizeof(rand_buf)); |
74 | 75 | ||
75 | rc4_ready = REKEY_BYTES; | 76 | rc4_ready = REKEY_BYTES; |
diff --git a/openbsd-compat/bsd-arc4random.h b/openbsd-compat/bsd-arc4random.h deleted file mode 100644 index 7af757b2d..000000000 --- a/openbsd-compat/bsd-arc4random.h +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1999-2000 Damien Miller. All rights reserved. | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * 1. Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * 2. Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * | ||
13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
14 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
15 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
16 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
19 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
20 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | |||
25 | /* $Id: bsd-arc4random.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
26 | |||
27 | #ifndef _BSD_ARC4RANDOM_H | ||
28 | #define _BSD_ARC4RANDOM_H | ||
29 | |||
30 | #include "config.h" | ||
31 | |||
32 | #ifndef HAVE_ARC4RANDOM | ||
33 | unsigned int arc4random(void); | ||
34 | void arc4random_stir(void); | ||
35 | #endif /* !HAVE_ARC4RANDOM */ | ||
36 | |||
37 | #endif /* _BSD_ARC4RANDOM_H */ | ||
diff --git a/openbsd-compat/bsd-cray.c b/openbsd-compat/bsd-cray.c index edb3112b3..f2ac428cc 100644 --- a/openbsd-compat/bsd-cray.c +++ b/openbsd-compat/bsd-cray.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: bsd-cray.c,v 1.8 2002/09/26 00:38:51 tim Exp $ | 2 | * $Id: bsd-cray.c,v 1.12 2003/06/03 02:45:27 dtucker Exp $ |
3 | * | 3 | * |
4 | * bsd-cray.c | 4 | * bsd-cray.c |
5 | * | 5 | * |
@@ -67,10 +67,10 @@ | |||
67 | 67 | ||
68 | extern ServerOptions options; | 68 | extern ServerOptions options; |
69 | 69 | ||
70 | char cray_tmpdir[TPATHSIZ+1]; /* job TMPDIR path */ | 70 | char cray_tmpdir[TPATHSIZ + 1]; /* job TMPDIR path */ |
71 | 71 | ||
72 | struct sysv sysv; /* system security structure */ | 72 | struct sysv sysv; /* system security structure */ |
73 | struct usrv usrv; /* user security structure */ | 73 | struct usrv usrv; /* user security structure */ |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * Functions. | 76 | * Functions. |
@@ -86,39 +86,40 @@ int cray_access_denied(char *); | |||
86 | void | 86 | void |
87 | cray_login_failure(char *username, int errcode) | 87 | cray_login_failure(char *username, int errcode) |
88 | { | 88 | { |
89 | struct udb *ueptr; /* UDB pointer for username */ | 89 | struct udb *ueptr; /* UDB pointer for username */ |
90 | ia_failure_t fsent; /* ia_failure structure */ | 90 | ia_failure_t fsent; /* ia_failure structure */ |
91 | ia_failure_ret_t fret; /* ia_failure return stuff */ | 91 | ia_failure_ret_t fret; /* ia_failure return stuff */ |
92 | struct jtab jtab; /* job table structure */ | 92 | struct jtab jtab; /* job table structure */ |
93 | int jid = 0; /* job id */ | 93 | int jid = 0; /* job id */ |
94 | 94 | ||
95 | if ((jid = getjtab(&jtab)) < 0) { | 95 | if ((jid = getjtab(&jtab)) < 0) |
96 | debug("cray_login_failure(): getjtab error"); | 96 | debug("cray_login_failure(): getjtab error"); |
97 | } | 97 | |
98 | getsysudb(); | 98 | getsysudb(); |
99 | if ((ueptr = getudbnam(username)) == UDB_NULL) { | 99 | if ((ueptr = getudbnam(username)) == UDB_NULL) |
100 | debug("cray_login_failure(): getudbname() returned NULL"); | 100 | debug("cray_login_failure(): getudbname() returned NULL"); |
101 | } | ||
102 | endudb(); | 101 | endudb(); |
103 | fsent.revision = 0; | 102 | |
104 | fsent.uname = username; | 103 | memset(&fsent, '\0', sizeof(fsent)); |
105 | fsent.host = (char *)get_canonical_hostname(options.verify_reverse_mapping); | 104 | fsent.revision = 0; |
106 | fsent.ttyn = "sshd"; | 105 | fsent.uname = username; |
107 | fsent.caller = IA_SSHD; | 106 | fsent.host = (char *)get_canonical_hostname(options.use_dns); |
108 | fsent.flags = IA_INTERACTIVE; | 107 | fsent.ttyn = "sshd"; |
109 | fsent.ueptr = ueptr; | 108 | fsent.caller = IA_SSHD; |
110 | fsent.jid = jid; | 109 | fsent.flags = IA_INTERACTIVE; |
111 | fsent.errcode = errcode; | 110 | fsent.ueptr = ueptr; |
112 | fsent.pwdp = NULL; | 111 | fsent.jid = jid; |
113 | fsent.exitcode = 0; /* dont exit in ia_failure() */ | 112 | fsent.errcode = errcode; |
114 | 113 | fsent.pwdp = NULL; | |
115 | fret.revision = 0; | 114 | fsent.exitcode = 0; /* dont exit in ia_failure() */ |
116 | fret.normal = 0; | 115 | |
116 | fret.revision = 0; | ||
117 | fret.normal = 0; | ||
117 | 118 | ||
118 | /* | 119 | /* |
119 | * Call ia_failure because of an login failure. | 120 | * Call ia_failure because of an login failure. |
120 | */ | 121 | */ |
121 | ia_failure(&fsent,&fret); | 122 | ia_failure(&fsent, &fret); |
122 | } | 123 | } |
123 | 124 | ||
124 | /* | 125 | /* |
@@ -127,338 +128,316 @@ cray_login_failure(char *username, int errcode) | |||
127 | int | 128 | int |
128 | cray_access_denied(char *username) | 129 | cray_access_denied(char *username) |
129 | { | 130 | { |
130 | struct udb *ueptr; /* UDB pointer for username */ | 131 | struct udb *ueptr; /* UDB pointer for username */ |
131 | int errcode; /* IA errorcode */ | 132 | int errcode; /* IA errorcode */ |
132 | 133 | ||
133 | errcode = 0; | 134 | errcode = 0; |
134 | getsysudb(); | 135 | getsysudb(); |
135 | if ((ueptr = getudbnam(username)) == UDB_NULL) { | 136 | if ((ueptr = getudbnam(username)) == UDB_NULL) |
136 | debug("cray_login_failure(): getudbname() returned NULL"); | 137 | debug("cray_login_failure(): getudbname() returned NULL"); |
137 | } | ||
138 | endudb(); | 138 | endudb(); |
139 | if (ueptr && ueptr->ue_disabled) | 139 | |
140 | if (ueptr != NULL && ueptr->ue_disabled) | ||
140 | errcode = IA_DISABLED; | 141 | errcode = IA_DISABLED; |
141 | if (errcode) | 142 | if (errcode) |
142 | cray_login_failure(username, errcode); | 143 | cray_login_failure(username, errcode); |
144 | |||
143 | return (errcode); | 145 | return (errcode); |
144 | } | 146 | } |
145 | 147 | ||
148 | /* | ||
149 | * record_failed_login: generic "login failed" interface function | ||
150 | */ | ||
151 | void | ||
152 | record_failed_login(const char *user, const char *ttyname) | ||
153 | { | ||
154 | cray_login_failure((char *)user, IA_UDBERR); | ||
155 | } | ||
156 | |||
146 | int | 157 | int |
147 | cray_setup (uid_t uid, char *username, const char *command) | 158 | cray_setup (uid_t uid, char *username, const char *command) |
148 | { | 159 | { |
149 | extern struct udb *getudb(); | 160 | extern struct udb *getudb(); |
150 | extern char *setlimits(); | 161 | extern char *setlimits(); |
151 | 162 | ||
152 | int err; /* error return */ | 163 | int err; /* error return */ |
153 | time_t system_time; /* current system clock */ | 164 | time_t system_time; /* current system clock */ |
154 | time_t expiration_time; /* password expiration time */ | 165 | time_t expiration_time; /* password expiration time */ |
155 | int maxattempts; /* maximum no. of failed login attempts */ | 166 | int maxattempts; /* maximum no. of failed login attempts */ |
156 | int SecureSys; /* unicos security flag */ | 167 | int SecureSys; /* unicos security flag */ |
157 | int minslevel = 0; /* system minimum security level */ | 168 | int minslevel = 0; /* system minimum security level */ |
158 | int i, j; | 169 | int i, j; |
159 | int valid_acct = -1; /* flag for reading valid acct */ | 170 | int valid_acct = -1; /* flag for reading valid acct */ |
160 | char acct_name[MAXACID] = { "" }; /* used to read acct name */ | 171 | char acct_name[MAXACID] = { "" }; /* used to read acct name */ |
161 | struct jtab jtab; /* Job table struct */ | 172 | struct jtab jtab; /* Job table struct */ |
162 | struct udb ue; /* udb entry for logging-in user */ | 173 | struct udb ue; /* udb entry for logging-in user */ |
163 | struct udb *up; /* pointer to UDB entry */ | 174 | struct udb *up; /* pointer to UDB entry */ |
164 | struct secstat secinfo; /* file security attributes */ | 175 | struct secstat secinfo; /* file security attributes */ |
165 | struct servprov init_info; /* used for sesscntl() call */ | 176 | struct servprov init_info; /* used for sesscntl() call */ |
166 | int jid; /* job ID */ | 177 | int jid; /* job ID */ |
167 | int pid; /* process ID */ | 178 | int pid; /* process ID */ |
168 | char *sr; /* status return from setlimits() */ | 179 | char *sr; /* status return from setlimits() */ |
169 | char *ttyn = NULL; /* ttyname or command name*/ | 180 | char *ttyn = NULL; /* ttyname or command name*/ |
170 | char hostname[MAXHOSTNAMELEN]; | 181 | char hostname[MAXHOSTNAMELEN]; |
171 | passwd_t pwdacm, | 182 | /* passwd stuff for ia_user */ |
172 | pwddialup, | 183 | passwd_t pwdacm, pwddialup, pwdudb, pwdwal, pwddce; |
173 | pwdudb, | 184 | ia_user_ret_t uret; /* stuff returned from ia_user */ |
174 | pwdwal, | 185 | ia_user_t usent /* ia_user main structure */ |
175 | pwddce; /* passwd stuff for ia_user */ | 186 | int ia_rcode; /* ia_user return code */ |
176 | ia_user_ret_t uret; /* stuff returned from ia_user */ | 187 | ia_failure_t fsent; /* ia_failure structure */ |
177 | ia_user_t usent; /* ia_user main structure */ | ||
178 | int ia_rcode; /* ia_user return code */ | ||
179 | ia_failure_t fsent; /* ia_failure structure */ | ||
180 | ia_failure_ret_t fret; /* ia_failure return stuff */ | 188 | ia_failure_ret_t fret; /* ia_failure return stuff */ |
181 | ia_success_t ssent; /* ia_success structure */ | 189 | ia_success_t ssent; /* ia_success structure */ |
182 | ia_success_ret_t sret; /* ia_success return stuff */ | 190 | ia_success_ret_t sret; /* ia_success return stuff */ |
183 | int ia_mlsrcode; /* ia_mlsuser return code */ | 191 | int ia_mlsrcode; /* ia_mlsuser return code */ |
184 | int secstatrc; /* [f]secstat return code */ | 192 | int secstatrc; /* [f]secstat return code */ |
185 | 193 | ||
186 | if (SecureSys = (int)sysconf(_SC_CRAY_SECURE_SYS)) { | 194 | if (SecureSys = (int)sysconf(_SC_CRAY_SECURE_SYS)) { |
187 | getsysv(&sysv, sizeof(struct sysv)); | 195 | getsysv(&sysv, sizeof(struct sysv)); |
188 | minslevel = sysv.sy_minlvl; | 196 | minslevel = sysv.sy_minlvl; |
189 | if (getusrv(&usrv) < 0) { | 197 | if (getusrv(&usrv) < 0) |
190 | debug("getusrv() failed, errno = %d",errno); | 198 | fatal("getusrv() failed, errno = %d", errno); |
191 | exit(1); | ||
192 | } | ||
193 | } | 199 | } |
194 | hostname[0] = '\0'; | 200 | hostname[0] = '\0'; |
195 | strncpy(hostname, | 201 | strlcpy(hostname, |
196 | (char *)get_canonical_hostname(options.verify_reverse_mapping), | 202 | (char *)get_canonical_hostname(options.use_dns), |
197 | MAXHOSTNAMELEN); | 203 | MAXHOSTNAMELEN); |
198 | /* | 204 | /* |
199 | * Fetch user's UDB entry. | 205 | * Fetch user's UDB entry. |
200 | */ | 206 | */ |
201 | getsysudb(); | 207 | getsysudb(); |
202 | if ((up = getudbnam(username)) == UDB_NULL) { | 208 | if ((up = getudbnam(username)) == UDB_NULL) |
203 | debug("cannot fetch user's UDB entry"); | 209 | fatal("cannot fetch user's UDB entry"); |
204 | exit(1); | 210 | |
205 | } | 211 | /* |
206 | 212 | * Prevent any possible fudging so perform a data | |
207 | /* | 213 | * safety check and compare the supplied uid against |
208 | * Prevent any possible fudging so perform a data | 214 | * the udb's uid. |
209 | * safety check and compare the supplied uid against | 215 | */ |
210 | * the udb's uid. | 216 | if (up->ue_uid != uid) |
211 | */ | 217 | fatal("IA uid missmatch"); |
212 | if (up->ue_uid != uid) { | ||
213 | debug("IA uid missmatch"); | ||
214 | exit(1); | ||
215 | } | ||
216 | endudb(); | 218 | endudb(); |
217 | 219 | ||
218 | if ((jid = getjtab (&jtab)) < 0) { | 220 | if ((jid = getjtab(&jtab)) < 0) { |
219 | debug("getjtab"); | 221 | debug("getjtab"); |
220 | return -1; | 222 | return(-1); |
221 | } | 223 | } |
222 | pid = getpid(); | 224 | pid = getpid(); |
223 | ttyn = ttyname(0); | 225 | ttyn = ttyname(0); |
224 | if (SecureSys) { | 226 | if (SecureSys) { |
225 | if (ttyn) { | 227 | if (ttyn != NULL) |
226 | secstatrc = secstat(ttyn, &secinfo); | 228 | secstatrc = secstat(ttyn, &secinfo); |
227 | } else { | 229 | else |
228 | secstatrc = fsecstat(1, &secinfo); | 230 | secstatrc = fsecstat(1, &secinfo); |
229 | } | 231 | |
230 | if (secstatrc == 0) { | 232 | if (secstatrc == 0) |
231 | debug("[f]secstat() successful"); | 233 | debug("[f]secstat() successful"); |
232 | } else { | 234 | else |
233 | debug("[f]secstat() error, rc = %d", secstatrc); | 235 | fatal("[f]secstat() error, rc = %d", secstatrc); |
234 | exit(1); | ||
235 | } | ||
236 | } | 236 | } |
237 | if ((ttyn == NULL) && ((char *)command != NULL)) | 237 | if ((ttyn == NULL) && ((char *)command != NULL)) |
238 | ttyn = (char *)command; | 238 | ttyn = (char *)command; |
239 | /* | 239 | /* |
240 | * Initialize all structures to call ia_user | 240 | * Initialize all structures to call ia_user |
241 | */ | 241 | */ |
242 | usent.revision = 0; | 242 | usent.revision = 0; |
243 | usent.uname = username; | 243 | usent.uname = username; |
244 | usent.host = hostname; | 244 | usent.host = hostname; |
245 | usent.ttyn = ttyn; | 245 | usent.ttyn = ttyn; |
246 | usent.caller = IA_SSHD; | 246 | usent.caller = IA_SSHD; |
247 | usent.pswdlist = &pwdacm; | 247 | usent.pswdlist = &pwdacm; |
248 | usent.ueptr = &ue; | 248 | usent.ueptr = &ue; |
249 | usent.flags = IA_INTERACTIVE | IA_FFLAG; | 249 | usent.flags = IA_INTERACTIVE | IA_FFLAG; |
250 | pwdacm.atype = IA_SECURID; | 250 | pwdacm.atype = IA_SECURID; |
251 | pwdacm.pwdp = NULL; | 251 | pwdacm.pwdp = NULL; |
252 | pwdacm.next = &pwdudb; | 252 | pwdacm.next = &pwdudb; |
253 | 253 | ||
254 | pwdudb.atype = IA_UDB; | 254 | pwdudb.atype = IA_UDB; |
255 | pwdudb.pwdp = NULL; | 255 | pwdudb.pwdp = NULL; |
256 | pwdudb.next = &pwddce; | 256 | pwdudb.next = &pwddce; |
257 | 257 | ||
258 | pwddce.atype = IA_DCE; | 258 | pwddce.atype = IA_DCE; |
259 | pwddce.pwdp = NULL; | 259 | pwddce.pwdp = NULL; |
260 | pwddce.next = &pwddialup; | 260 | pwddce.next = &pwddialup; |
261 | 261 | ||
262 | pwddialup.atype = IA_DIALUP; | 262 | pwddialup.atype = IA_DIALUP; |
263 | pwddialup.pwdp = NULL; | 263 | pwddialup.pwdp = NULL; |
264 | /* pwddialup.next = &pwdwal; */ | 264 | /* pwddialup.next = &pwdwal; */ |
265 | pwddialup.next = NULL; | 265 | pwddialup.next = NULL; |
266 | 266 | ||
267 | pwdwal.atype = IA_WAL; | 267 | pwdwal.atype = IA_WAL; |
268 | pwdwal.pwdp = NULL; | 268 | pwdwal.pwdp = NULL; |
269 | pwdwal.next = NULL; | 269 | pwdwal.next = NULL; |
270 | 270 | ||
271 | uret.revision = 0; | 271 | uret.revision = 0; |
272 | uret.pswd = NULL; | 272 | uret.pswd = NULL; |
273 | uret.normal = 0; | 273 | uret.normal = 0; |
274 | 274 | ||
275 | ia_rcode = ia_user(&usent, &uret); | 275 | ia_rcode = ia_user(&usent, &uret); |
276 | 276 | switch (ia_rcode) { | |
277 | switch (ia_rcode) { | 277 | /* |
278 | /* | 278 | * These are acceptable return codes from ia_user() |
279 | * These are acceptable return codes from ia_user() | 279 | */ |
280 | */ | 280 | case IA_UDBWEEK: /* Password Expires in 1 week */ |
281 | case IA_UDBWEEK: /* Password Expires in 1 week */ | 281 | expiration_time = ue.ue_pwage.time + ue.ue_pwage.maxage; |
282 | expiration_time = ue.ue_pwage.time + ue.ue_pwage.maxage; | 282 | printf ("WARNING - your current password will expire %s\n", |
283 | printf ("WARNING - your current password will expire %s\n", | 283 | ctime((const time_t *)&expiration_time)); |
284 | ctime((const time_t *)&expiration_time)); | 284 | break; |
285 | break; | 285 | case IA_UDBEXPIRED: |
286 | case IA_UDBEXPIRED: | 286 | if (ttyname(0) != NULL) { |
287 | if (ttyname(0) != NULL) { | 287 | /* Force a password change */ |
288 | /* Force a password change */ | 288 | printf("Your password has expired; Choose a new one.\n"); |
289 | printf("Your password has expired; Choose a new one.\n"); | 289 | execl("/bin/passwd", "passwd", username, 0); |
290 | execl("/bin/passwd", "passwd", username, 0); | 290 | exit(9); |
291 | exit(9); | 291 | } |
292 | } | 292 | break; |
293 | 293 | case IA_NORMAL: /* Normal Return Code */ | |
294 | break; | 294 | break; |
295 | case IA_NORMAL: /* Normal Return Code */ | 295 | case IA_BACKDOOR: |
296 | break; | 296 | /* XXX: can we memset it to zero here so save some of this */ |
297 | case IA_BACKDOOR: | 297 | strlcpy(ue.ue_name, "root", sizeof(ue.ue_name)); |
298 | strcpy(ue.ue_name, "root"); | 298 | strlcpy(ue.ue_dir, "/", sizeof(ue.ue_dir)); |
299 | strcpy(ue.ue_passwd, ""); | 299 | strlcpy(ue.ue_shell, "/bin/sh", sizeof(ue.ue_shell)); |
300 | strcpy(ue.ue_dir, "/"); | 300 | |
301 | strcpy(ue.ue_shell, "/bin/sh"); | 301 | ue.ue_passwd[0] = '\0'; |
302 | strcpy(ue.ue_age, ""); | 302 | ue.ue_age[0] = '\0'; |
303 | strcpy(ue.ue_comment, ""); | 303 | ue.ue_comment[0] = '\0'; |
304 | strcpy(ue.ue_loghost, ""); | 304 | ue.ue_loghost[0] = '\0'; |
305 | strcpy(ue.ue_logline, ""); | 305 | ue.ue_logline[0] = '\0'; |
306 | ue.ue_uid=-1; | 306 | |
307 | ue.ue_nice[UDBRC_INTER]=0; | 307 | ue.ue_uid = -1; |
308 | for (i=0;i<MAXVIDS;i++) | 308 | ue.ue_nice[UDBRC_INTER] = 0; |
309 | ue.ue_gids[i]=0; | 309 | |
310 | ue.ue_logfails=0; | 310 | for (i = 0; i < MAXVIDS; i++) |
311 | ue.ue_minlvl=minslevel; | 311 | ue.ue_gids[i] = 0; |
312 | ue.ue_maxlvl=minslevel; | 312 | |
313 | ue.ue_deflvl=minslevel; | 313 | ue.ue_logfails = 0; |
314 | ue.ue_defcomps=0; | 314 | ue.ue_minlvl = ue.ue_maxlvl = ue.ue_deflvl = minslevel; |
315 | ue.ue_comparts=0; | 315 | ue.ue_defcomps = 0; |
316 | ue.ue_permits=0; | 316 | ue.ue_comparts = 0; |
317 | ue.ue_trap=0; | 317 | ue.ue_permits = 0; |
318 | ue.ue_disabled=0; | 318 | ue.ue_trap = 0; |
319 | ue.ue_logtime=0; | 319 | ue.ue_disabled = 0; |
320 | break; | 320 | ue.ue_logtime = 0; |
321 | case IA_CONSOLE: /* Superuser not from Console */ | 321 | break; |
322 | case IA_TRUSTED: /* Trusted user */ | 322 | case IA_CONSOLE: /* Superuser not from Console */ |
323 | if (options.permit_root_login > PERMIT_NO) | 323 | case IA_TRUSTED: /* Trusted user */ |
324 | break; /* Accept root login */ | 324 | if (options.permit_root_login > PERMIT_NO) |
325 | default: | 325 | break; /* Accept root login */ |
326 | /* | 326 | default: |
327 | * These are failed return codes from ia_user() | 327 | /* |
328 | */ | 328 | * These are failed return codes from ia_user() |
329 | switch (ia_rcode) | 329 | */ |
330 | { | 330 | switch (ia_rcode) |
331 | case IA_BADAUTH: | 331 | { |
332 | printf ("Bad authorization, access denied.\n"); | 332 | case IA_BADAUTH: |
333 | break; | 333 | printf("Bad authorization, access denied.\n"); |
334 | case IA_DIALUPERR: | 334 | break; |
335 | break; | 335 | case IA_DISABLED: |
336 | case IA_DISABLED: | 336 | printf("Your login has been disabled. Contact the system "); |
337 | printf ("Your login has been disabled. Contact the system "); | 337 | printf("administrator for assistance.\n"); |
338 | printf ("administrator for assistance.\n"); | 338 | break; |
339 | break; | 339 | case IA_GETSYSV: |
340 | case IA_GETSYSV: | 340 | printf("getsysv() failed - errno = %d\n", errno); |
341 | printf ("getsysv() failed - errno = %d\n", errno); | 341 | break; |
342 | break; | 342 | case IA_MAXLOGS: |
343 | case IA_LOCALHOST: | 343 | printf("Maximum number of failed login attempts exceeded.\n"); |
344 | break; | 344 | printf("Access denied.\n"); |
345 | case IA_MAXLOGS: | 345 | break; |
346 | printf ("Maximum number of failed login attempts exceeded.\n"); | 346 | case IA_UDBPWDNULL: |
347 | printf ("Access denied.\n"); | 347 | if (SecureSys) |
348 | break; | 348 | printf("NULL Password not allowed on MLS systems.\n"); |
349 | case IA_NOPASS: | 349 | break; |
350 | break; | 350 | default: |
351 | case IA_PUBLIC: | 351 | break; |
352 | break; | 352 | } |
353 | case IA_SECURIDERR: | 353 | |
354 | break; | 354 | /* |
355 | case IA_CONSOLE: | 355 | * Authentication failed. |
356 | break; | 356 | */ |
357 | case IA_TRUSTED: | 357 | printf("sshd: Login incorrect, (0%o)\n", |
358 | break; | 358 | ia_rcode-IA_ERRORCODE); |
359 | case IA_UDBERR: | 359 | |
360 | break; | 360 | /* |
361 | case IA_UDBPWDNULL: | 361 | * Initialize structure for ia_failure |
362 | /* | 362 | * which will exit. |
363 | * NULL password not allowed on MLS systems | 363 | */ |
364 | */ | 364 | fsent.revision = 0; |
365 | if (SecureSys) { | 365 | fsent.uname = username; |
366 | printf("NULL Password not allowed on MLS systems.\n"); | 366 | fsent.host = hostname; |
367 | } | 367 | fsent.ttyn = ttyn; |
368 | break; | 368 | fsent.caller = IA_SSHD; |
369 | case IA_UNKNOWN: | 369 | fsent.flags = IA_INTERACTIVE; |
370 | break; | 370 | fsent.ueptr = &ue; |
371 | case IA_UNKNOWNYP: | 371 | fsent.jid = jid; |
372 | break; | 372 | fsent.errcode = ia_rcode; |
373 | case IA_WALERR: | 373 | fsent.pwdp = uret.pswd; |
374 | break; | 374 | fsent.exitcode = 1; |
375 | default: | 375 | |
376 | /* nothing special */ | 376 | fret.revision = 0; |
377 | ; | 377 | fret.normal = 0; |
378 | } /* 2. switch (ia_rcode) */ | 378 | |
379 | /* | 379 | /* |
380 | * Authentication failed. | 380 | * Call ia_failure because of an IA failure. |
381 | */ | 381 | * There is no return because ia_failure exits. |
382 | printf("sshd: Login incorrect, (0%o)\n", | 382 | */ |
383 | ia_rcode-IA_ERRORCODE); | 383 | ia_failure(&fsent, &fret); |
384 | 384 | ||
385 | /* | 385 | exit(1); |
386 | * Initialize structure for ia_failure | 386 | } |
387 | * which will exit. | 387 | |
388 | */ | ||
389 | fsent.revision = 0; | ||
390 | fsent.uname = username; | ||
391 | fsent.host = hostname; | ||
392 | fsent.ttyn = ttyn; | ||
393 | fsent.caller = IA_SSHD; | ||
394 | fsent.flags = IA_INTERACTIVE; | ||
395 | fsent.ueptr = &ue; | ||
396 | fsent.jid = jid; | ||
397 | fsent.errcode = ia_rcode; | ||
398 | fsent.pwdp = uret.pswd; | ||
399 | fsent.exitcode = 1; | ||
400 | |||
401 | fret.revision = 0; | ||
402 | fret.normal = 0; | ||
403 | |||
404 | /* | ||
405 | * Call ia_failure because of an IA failure. | ||
406 | * There is no return because ia_failure exits. | ||
407 | */ | ||
408 | |||
409 | ia_failure(&fsent,&fret); | ||
410 | |||
411 | exit(1); | ||
412 | } /* 1. switch (ia_rcode) */ | ||
413 | ia_mlsrcode = IA_NORMAL; | 388 | ia_mlsrcode = IA_NORMAL; |
414 | if (SecureSys) { | 389 | if (SecureSys) { |
415 | debug("calling ia_mlsuser()"); | 390 | debug("calling ia_mlsuser()"); |
416 | ia_mlsrcode = ia_mlsuser (&ue, &secinfo, &usrv, NULL, 0); | 391 | ia_mlsrcode = ia_mlsuser(&ue, &secinfo, &usrv, NULL, 0); |
417 | } | 392 | } |
418 | if (ia_mlsrcode != IA_NORMAL) { | 393 | if (ia_mlsrcode != IA_NORMAL) { |
419 | printf("sshd: Login incorrect, (0%o)\n", | 394 | printf("sshd: Login incorrect, (0%o)\n", |
420 | ia_mlsrcode-IA_ERRORCODE); | 395 | ia_mlsrcode-IA_ERRORCODE); |
421 | /* | 396 | /* |
422 | * Initialize structure for ia_failure | 397 | * Initialize structure for ia_failure |
423 | * which will exit. | 398 | * which will exit. |
424 | */ | 399 | */ |
425 | fsent.revision = 0; | 400 | fsent.revision = 0; |
426 | fsent.uname = username; | 401 | fsent.uname = username; |
427 | fsent.host = hostname; | 402 | fsent.host = hostname; |
428 | fsent.ttyn = ttyn; | 403 | fsent.ttyn = ttyn; |
429 | fsent.caller = IA_SSHD; | 404 | fsent.caller = IA_SSHD; |
430 | fsent.flags = IA_INTERACTIVE; | 405 | fsent.flags = IA_INTERACTIVE; |
431 | fsent.ueptr = &ue; | 406 | fsent.ueptr = &ue; |
432 | fsent.jid = jid; | 407 | fsent.jid = jid; |
433 | fsent.errcode = ia_mlsrcode; | 408 | fsent.errcode = ia_mlsrcode; |
434 | fsent.pwdp = uret.pswd; | 409 | fsent.pwdp = uret.pswd; |
435 | fsent.exitcode = 1; | 410 | fsent.exitcode = 1; |
436 | fret.revision = 0; | 411 | fret.revision = 0; |
437 | fret.normal = 0; | 412 | fret.normal = 0; |
438 | 413 | ||
439 | /* | 414 | /* |
440 | * Call ia_failure because of an IA failure. | 415 | * Call ia_failure because of an IA failure. |
441 | * There is no return because ia_failure exits. | 416 | * There is no return because ia_failure exits. |
442 | */ | 417 | */ |
443 | ia_failure(&fsent,&fret); | 418 | ia_failure(&fsent,&fret); |
444 | exit(1); | 419 | exit(1); |
445 | } | 420 | } |
446 | 421 | ||
447 | /* Provide login status information */ | 422 | /* Provide login status information */ |
448 | if (options.print_lastlog && ue.ue_logtime != 0) { | 423 | if (options.print_lastlog && ue.ue_logtime != 0) { |
449 | printf("Last successful login was : %.*s ", | 424 | printf("Last successful login was : %.*s ", 19, |
450 | 19, (char *)ctime(&ue.ue_logtime)); | 425 | (char *)ctime(&ue.ue_logtime)); |
451 | 426 | ||
452 | if (*ue.ue_loghost != '\0') | 427 | if (*ue.ue_loghost != '\0') { |
453 | printf("from %.*s\n", sizeof(ue.ue_loghost), ue.ue_loghost); | 428 | printf("from %.*s\n", sizeof(ue.ue_loghost), |
454 | 429 | ue.ue_loghost); | |
455 | else printf("on %.*s\n", sizeof(ue.ue_logline), ue.ue_logline); | 430 | } else { |
456 | 431 | printf("on %.*s\n", sizeof(ue.ue_logline), | |
457 | if ( SecureSys && (ue.ue_logfails != 0)) | 432 | ue.ue_logline); |
458 | printf(" followed by %d failed attempts\n", ue.ue_logfails); | 433 | } |
459 | } | 434 | |
460 | 435 | if (SecureSys && (ue.ue_logfails != 0)) { | |
461 | 436 | printf(" followed by %d failed attempts\n", | |
437 | ue.ue_logfails); | ||
438 | } | ||
439 | } | ||
440 | |||
462 | /* | 441 | /* |
463 | * Call ia_success to process successful I/A. | 442 | * Call ia_success to process successful I/A. |
464 | */ | 443 | */ |
@@ -472,109 +451,116 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
472 | ssent.jid = jid; | 451 | ssent.jid = jid; |
473 | ssent.errcode = ia_rcode; | 452 | ssent.errcode = ia_rcode; |
474 | ssent.us = NULL; | 453 | ssent.us = NULL; |
475 | ssent.time = 1; /* Set ue_logtime */ | 454 | ssent.time = 1; /* Set ue_logtime */ |
476 | 455 | ||
477 | sret.revision = 0; | 456 | sret.revision = 0; |
478 | sret.normal = 0; | 457 | sret.normal = 0; |
479 | 458 | ||
480 | ia_success(&ssent,&sret); | 459 | ia_success(&ssent, &sret); |
481 | 460 | ||
482 | /* | 461 | /* |
483 | * Query for account, iff > 1 valid acid & askacid permbit | 462 | * Query for account, iff > 1 valid acid & askacid permbit |
484 | */ | 463 | */ |
485 | if (((ue.ue_permbits & PERMBITS_ACCTID) || | 464 | if (((ue.ue_permbits & PERMBITS_ACCTID) || |
486 | (ue.ue_acids[0] >= 0) && (ue.ue_acids[1] >= 0)) && | 465 | (ue.ue_acids[0] >= 0) && (ue.ue_acids[1] >= 0)) && |
487 | ue.ue_permbits & PERMBITS_ASKACID) { | 466 | ue.ue_permbits & PERMBITS_ASKACID) { |
488 | if (ttyname(0) != NULL) { | 467 | if (ttyname(0) != NULL) { |
489 | debug("cray_setup: ttyname true case, %.100s", ttyname); | 468 | debug("cray_setup: ttyname true case, %.100s", ttyname); |
490 | while (valid_acct == -1) { | 469 | while (valid_acct == -1) { |
491 | printf("Account (? for available accounts)" | 470 | printf("Account (? for available accounts)" |
492 | " [%s]: ", acid2nam(ue.ue_acids[0])); | 471 | " [%s]: ", acid2nam(ue.ue_acids[0])); |
493 | gets(acct_name); | 472 | fgets(acct_name, MAXACID, stdin); |
494 | switch (acct_name[0]) { | 473 | switch (acct_name[0]) { |
495 | case EOF: | 474 | case EOF: |
496 | exit(0); | 475 | exit(0); |
497 | break; | 476 | break; |
498 | case '\0': | 477 | case '\0': |
499 | valid_acct = ue.ue_acids[0]; | 478 | valid_acct = ue.ue_acids[0]; |
500 | strcpy(acct_name, acid2nam(valid_acct)); | 479 | strlcpy(acct_name, acid2nam(valid_acct), MAXACID); |
501 | break; | 480 | break; |
502 | case '?': | 481 | case '?': |
503 | /* Print the list 3 wide */ | 482 | /* Print the list 3 wide */ |
504 | for (i = 0, j = 0; i < MAXVIDS; i++) { | 483 | for (i = 0, j = 0; i < MAXVIDS; i++) { |
505 | if (ue.ue_acids[i] == -1) { | 484 | if (ue.ue_acids[i] == -1) { |
506 | printf("\n"); | 485 | printf("\n"); |
507 | break; | 486 | break; |
508 | } | 487 | } |
509 | if (++j == 4) { | 488 | if (++j == 4) { |
510 | j = 1; | 489 | j = 1; |
511 | printf("\n"); | 490 | printf("\n"); |
512 | } | 491 | } |
513 | printf(" %s", | 492 | printf(" %s", |
514 | acid2nam(ue.ue_acids[i])); | 493 | acid2nam(ue.ue_acids[i])); |
515 | } | 494 | } |
516 | if (ue.ue_permbits & PERMBITS_ACCTID) | 495 | if (ue.ue_permbits & PERMBITS_ACCTID) { |
517 | printf("\"acctid\" permbit also allows" | 496 | printf("\"acctid\" permbit also allows" |
518 | " you to select any valid " | 497 | " you to select any valid " |
519 | "account name.\n"); | 498 | "account name.\n"); |
520 | printf("\n"); | 499 | } |
521 | break; | 500 | printf("\n"); |
522 | default: | 501 | break; |
523 | if ((valid_acct = nam2acid(acct_name)) == -1) printf("Account id not found for" | 502 | default: |
524 | " account name \"%s\"\n\n", | 503 | valid_acct = nam2acid(acct_name); |
525 | acct_name); | 504 | if (valid_acct == -1) { |
526 | break; | 505 | printf( |
527 | } | 506 | "Account id not found for" |
528 | /* | 507 | " account name \"%s\"\n\n", |
529 | * If an account was given, search the user's | 508 | acct_name); |
530 | * acids array to verify they can use this account. | 509 | break; |
531 | */ | 510 | } |
532 | if ((valid_acct != -1) && | 511 | /* |
533 | !(ue.ue_permbits & PERMBITS_ACCTID)) { | 512 | * If an account was given, search the user's |
534 | for (i = 0; i < MAXVIDS; i++) { | 513 | * acids array to verify they can use this account. |
535 | if (ue.ue_acids[i] == -1) | 514 | */ |
536 | break; | 515 | if ((valid_acct != -1) && |
537 | if (valid_acct == ue.ue_acids[i]) | 516 | !(ue.ue_permbits & PERMBITS_ACCTID)) { |
538 | break; | 517 | for (i = 0; i < MAXVIDS; i++) { |
539 | } | 518 | if (ue.ue_acids[i] == -1) |
540 | if (i == MAXVIDS || | 519 | break; |
541 | ue.ue_acids[i] == -1) { | 520 | if (valid_acct == ue.ue_acids[i]) |
542 | fprintf(stderr, "Cannot set" | 521 | break; |
543 | " account name to " | 522 | } |
544 | "\"%s\", permission " | 523 | if (i == MAXVIDS || |
545 | "denied\n\n", acct_name); | 524 | ue.ue_acids[i] == -1) { |
546 | valid_acct = -1; | 525 | fprintf(stderr, "Cannot set" |
547 | } | 526 | " account name to " |
548 | } | 527 | "\"%s\", permission " |
549 | } | 528 | "denied\n\n", acct_name); |
529 | valid_acct = -1; | ||
530 | } | ||
531 | } | ||
532 | } | ||
533 | } else { | ||
534 | /* | ||
535 | * The client isn't connected to a terminal and can't | ||
536 | * respond to an acid prompt. Use default acid. | ||
537 | */ | ||
538 | debug("cray_setup: ttyname false case, %.100s", | ||
539 | ttyname); | ||
540 | valid_acct = ue.ue_acids[0]; | ||
541 | } | ||
550 | } else { | 542 | } else { |
551 | /* | 543 | /* |
552 | * The client isn't connected to a terminal and can't | 544 | * The user doesn't have the askacid permbit set or |
553 | * respond to an acid prompt. Use default acid. | 545 | * only has one valid account to use. |
554 | */ | 546 | */ |
555 | debug("cray_setup: ttyname false case, %.100s", ttyname); | ||
556 | valid_acct = ue.ue_acids[0]; | 547 | valid_acct = ue.ue_acids[0]; |
557 | } | 548 | } |
558 | } else { | 549 | if (acctid(0, valid_acct) < 0) { |
559 | /* | 550 | printf ("Bad account id: %d\n", valid_acct); |
560 | * The user doesn't have the askacid permbit set or | 551 | exit(1); |
561 | * only has one valid account to use. | 552 | } |
562 | */ | 553 | |
563 | valid_acct = ue.ue_acids[0]; | 554 | /* |
564 | } | 555 | * Now set shares, quotas, limits, including CPU time for the |
565 | if (acctid(0, valid_acct) < 0) { | 556 | * (interactive) job and process, and set up permissions |
566 | printf ("Bad account id: %d\n", valid_acct); | 557 | * (for chown etc), etc. |
567 | exit(1); | 558 | */ |
568 | } | ||
569 | |||
570 | /* set up shares and quotas */ | ||
571 | /* Now set shares, quotas, limits, including CPU time for the (interactive) | ||
572 | * job and process, and set up permissions (for chown etc), etc. | ||
573 | */ | ||
574 | if (setshares(ue.ue_uid, valid_acct, printf, 0, 0)) { | 559 | if (setshares(ue.ue_uid, valid_acct, printf, 0, 0)) { |
575 | printf("Unable to give %d shares to <%s>(%d/%d)\n", ue.ue_shares, ue.ue_name, ue.ue_uid, valid_acct); | 560 | printf("Unable to give %d shares to <%s>(%d/%d)\n", |
561 | ue.ue_shares, ue.ue_name, ue.ue_uid, valid_acct); | ||
576 | exit(1); | 562 | exit(1); |
577 | } | 563 | } |
578 | 564 | ||
579 | sr = setlimits(username, C_PROC, pid, UDBRC_INTER); | 565 | sr = setlimits(username, C_PROC, pid, UDBRC_INTER); |
580 | if (sr != NULL) { | 566 | if (sr != NULL) { |
@@ -587,17 +573,15 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
587 | exit(1); | 573 | exit(1); |
588 | } | 574 | } |
589 | /* | 575 | /* |
590 | * Place the service provider information into | 576 | * Place the service provider information into |
591 | * the session table (Unicos) or job table (Unicos/mk). | 577 | * the session table (Unicos) or job table (Unicos/mk). |
592 | * There exist double defines for the job/session table in | 578 | * There exist double defines for the job/session table in |
593 | * unicos/mk (jtab.h) so no need for a compile time switch. | 579 | * unicos/mk (jtab.h) so no need for a compile time switch. |
594 | */ | 580 | */ |
595 | bzero((char *)&init_info, sizeof(struct servprov)); | 581 | memset(&init_info, '\0', sizeof(init_info)); |
596 | init_info.s_sessinit.si_id = URM_SPT_LOGIN; | 582 | init_info.s_sessinit.si_id = URM_SPT_LOGIN; |
597 | init_info.s_sessinit.si_pid = getpid(); | 583 | init_info.s_sessinit.si_pid = getpid(); |
598 | init_info.s_sessinit.si_sid = jid; | 584 | init_info.s_sessinit.si_sid = jid; |
599 | init_info.s_routing.seqno = 0; | ||
600 | init_info.s_routing.iadrs = 0; | ||
601 | sesscntl(0, S_SETSERVPO, (int)&init_info); | 585 | sesscntl(0, S_SETSERVPO, (int)&init_info); |
602 | 586 | ||
603 | /* | 587 | /* |
@@ -610,7 +594,7 @@ cray_setup (uid_t uid, char *username, const char *command) | |||
610 | } | 594 | } |
611 | } | 595 | } |
612 | 596 | ||
613 | return(0); | 597 | return (0); |
614 | } | 598 | } |
615 | 599 | ||
616 | /* | 600 | /* |
@@ -623,10 +607,10 @@ void | |||
623 | drop_cray_privs() | 607 | drop_cray_privs() |
624 | { | 608 | { |
625 | #if defined(_SC_CRAY_PRIV_SU) | 609 | #if defined(_SC_CRAY_PRIV_SU) |
626 | priv_proc_t* privstate; | 610 | priv_proc_t *privstate; |
627 | int result; | 611 | int result; |
628 | extern int priv_set_proc(); | 612 | extern int priv_set_proc(); |
629 | extern priv_proc_t* priv_init_proc(); | 613 | extern priv_proc_t *priv_init_proc(); |
630 | 614 | ||
631 | /* | 615 | /* |
632 | * If ether of theses two flags are not set | 616 | * If ether of theses two flags are not set |
@@ -654,15 +638,17 @@ drop_cray_privs() | |||
654 | usrv.sv_intcat = TFM_SYSTEM; | 638 | usrv.sv_intcat = TFM_SYSTEM; |
655 | usrv.sv_valcat |= (TFM_SYSTEM | TFM_SYSFILE); | 639 | usrv.sv_valcat |= (TFM_SYSTEM | TFM_SYSFILE); |
656 | 640 | ||
657 | if (setusrv(&usrv) < 0) | 641 | if (setusrv(&usrv) < 0) { |
658 | fatal("%s(%d): setusrv(): %s", __FILE__, __LINE__, | 642 | fatal("%s(%d): setusrv(): %s", __FILE__, __LINE__, |
659 | strerror(errno)); | 643 | strerror(errno)); |
644 | } | ||
660 | 645 | ||
661 | if ((privstate = priv_init_proc()) != NULL) { | 646 | if ((privstate = priv_init_proc()) != NULL) { |
662 | result = priv_set_proc(privstate); | 647 | result = priv_set_proc(privstate); |
663 | if (result != 0 ) | 648 | if (result != 0 ) { |
664 | fatal("%s(%d): priv_set_proc(): %s", | 649 | fatal("%s(%d): priv_set_proc(): %s", |
665 | __FILE__, __LINE__, strerror(errno)); | 650 | __FILE__, __LINE__, strerror(errno)); |
651 | } | ||
666 | priv_free_proc(privstate); | 652 | priv_free_proc(privstate); |
667 | } | 653 | } |
668 | debug ("Privileges should be cleared..."); | 654 | debug ("Privileges should be cleared..."); |
@@ -683,6 +669,7 @@ cray_retain_utmp(struct utmp *ut, int pid) | |||
683 | struct utmp utmp; | 669 | struct utmp utmp; |
684 | 670 | ||
685 | if ((fd = open(UTMP_FILE, O_RDONLY)) != -1) { | 671 | if ((fd = open(UTMP_FILE, O_RDONLY)) != -1) { |
672 | /* XXX use atomicio */ | ||
686 | while (read(fd, (char *)&utmp, sizeof(utmp)) == sizeof(utmp)) { | 673 | while (read(fd, (char *)&utmp, sizeof(utmp)) == sizeof(utmp)) { |
687 | if (pid == utmp.ut_pid) { | 674 | if (pid == utmp.ut_pid) { |
688 | ut->ut_jid = utmp.ut_jid; | 675 | ut->ut_jid = utmp.ut_jid; |
@@ -693,9 +680,8 @@ cray_retain_utmp(struct utmp *ut, int pid) | |||
693 | } | 680 | } |
694 | } | 681 | } |
695 | close(fd); | 682 | close(fd); |
696 | } | 683 | } else |
697 | else | 684 | fatal("Unable to open utmp file"); |
698 | fatal("Unable to open utmp file"); | ||
699 | } | 685 | } |
700 | 686 | ||
701 | /* | 687 | /* |
@@ -708,11 +694,9 @@ cray_retain_utmp(struct utmp *ut, int pid) | |||
708 | void | 694 | void |
709 | cray_delete_tmpdir(char *login, int jid, uid_t uid) | 695 | cray_delete_tmpdir(char *login, int jid, uid_t uid) |
710 | { | 696 | { |
711 | int child; | ||
712 | static char jtmp[TPATHSIZ]; | 697 | static char jtmp[TPATHSIZ]; |
713 | struct stat statbuf; | 698 | struct stat statbuf; |
714 | int c; | 699 | int child, c, wstat; |
715 | int wstat; | ||
716 | 700 | ||
717 | for (c = 'a'; c <= 'z'; c++) { | 701 | for (c = 'a'; c <= 'z'; c++) { |
718 | snprintf(jtmp, TPATHSIZ, "%s/jtmp.%06d%c", JTMPDIR, jid, c); | 702 | snprintf(jtmp, TPATHSIZ, "%s/jtmp.%06d%c", JTMPDIR, jid, c); |
diff --git a/openbsd-compat/bsd-cray.h b/openbsd-compat/bsd-cray.h index a09954f2f..a121ea152 100644 --- a/openbsd-compat/bsd-cray.h +++ b/openbsd-compat/bsd-cray.h | |||
@@ -1,8 +1,6 @@ | |||
1 | /* | 1 | /* $Id: bsd-cray.h,v 1.10 2003/08/29 16:59:52 mouring Exp $ */ |
2 | * $Id: bsd-cray.h,v 1.7 2003/03/21 01:05:38 mouring Exp $ | 2 | |
3 | * | 3 | /* |
4 | * bsd-cray.h | ||
5 | * | ||
6 | * Copyright (c) 2002, Cray Inc. (Wendy Palm <wendyp@cray.com>) | 4 | * Copyright (c) 2002, Cray Inc. (Wendy Palm <wendyp@cray.com>) |
7 | * Significant portions provided by | 5 | * Significant portions provided by |
8 | * Wayne Schroeder, SDSC <schroeder@sdsc.edu> | 6 | * Wayne Schroeder, SDSC <schroeder@sdsc.edu> |
@@ -34,25 +32,31 @@ | |||
34 | * on UNICOS systems. | 32 | * on UNICOS systems. |
35 | * | 33 | * |
36 | */ | 34 | */ |
35 | |||
37 | #ifndef _BSD_CRAY_H | 36 | #ifndef _BSD_CRAY_H |
38 | #define _BSD_CRAY_H | 37 | #define _BSD_CRAY_H |
39 | 38 | ||
40 | #ifdef _UNICOS | 39 | #ifdef _UNICOS |
41 | void cray_init_job(struct passwd *); /* init cray job */ | 40 | |
42 | void cray_job_termination_handler(int); /* process end of job signal */ | 41 | void cray_init_job(struct passwd *); |
43 | void cray_login_failure(char *username, int errcode); | 42 | void cray_job_termination_handler(int); |
44 | int cray_access_denied(char *username); | 43 | void cray_login_failure(char *, int ); |
45 | extern char cray_tmpdir[]; /* cray tmpdir */ | 44 | int cray_access_denied(char *); |
45 | #define CUSTOM_FAILED_LOGIN 1 | ||
46 | void record_failed_login(const char *, const char *); | ||
47 | extern char cray_tmpdir[]; | ||
48 | |||
46 | #ifndef IA_SSHD | 49 | #ifndef IA_SSHD |
47 | #define IA_SSHD IA_LOGIN | 50 | # define IA_SSHD IA_LOGIN |
48 | #endif | 51 | #endif |
49 | #ifndef MAXHOSTNAMELEN | 52 | #ifndef MAXHOSTNAMELEN |
50 | #define MAXHOSTNAMELEN 64 | 53 | # define MAXHOSTNAMELEN 64 |
51 | #endif | 54 | #endif |
52 | #ifndef _CRAYT3E | 55 | #ifndef _CRAYT3E |
53 | #include <sys/ttold.h> | 56 | # include <sys/ttold.h> |
54 | #define TIOCGPGRP (tIOC|20) | 57 | # define TIOCGPGRP (tIOC|20) |
55 | #endif | ||
56 | #endif | 58 | #endif |
57 | 59 | ||
60 | #endif /* UNICOS */ | ||
61 | |||
58 | #endif /* _BSD_CRAY_H */ | 62 | #endif /* _BSD_CRAY_H */ |
diff --git a/openbsd-compat/bsd-cygwin_util.c b/openbsd-compat/bsd-cygwin_util.c index 0fa5964bc..a87cf3c97 100644 --- a/openbsd-compat/bsd-cygwin_util.c +++ b/openbsd-compat/bsd-cygwin_util.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * cygwin_util.c | ||
3 | * | ||
4 | * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> | 2 | * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> |
5 | * | 3 | * |
6 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
@@ -31,7 +29,7 @@ | |||
31 | 29 | ||
32 | #include "includes.h" | 30 | #include "includes.h" |
33 | 31 | ||
34 | RCSID("$Id: bsd-cygwin_util.c,v 1.9 2002/11/09 15:59:29 mouring Exp $"); | 32 | RCSID("$Id: bsd-cygwin_util.c,v 1.11 2003/08/07 06:23:43 dtucker Exp $"); |
35 | 33 | ||
36 | #ifdef HAVE_CYGWIN | 34 | #ifdef HAVE_CYGWIN |
37 | 35 | ||
@@ -53,7 +51,8 @@ RCSID("$Id: bsd-cygwin_util.c,v 1.9 2002/11/09 15:59:29 mouring Exp $"); | |||
53 | # undef pipe | 51 | # undef pipe |
54 | #endif | 52 | #endif |
55 | 53 | ||
56 | int binary_open(const char *filename, int flags, ...) | 54 | int |
55 | binary_open(const char *filename, int flags, ...) | ||
57 | { | 56 | { |
58 | va_list ap; | 57 | va_list ap; |
59 | mode_t mode; | 58 | mode_t mode; |
@@ -61,55 +60,56 @@ int binary_open(const char *filename, int flags, ...) | |||
61 | va_start(ap, flags); | 60 | va_start(ap, flags); |
62 | mode = va_arg(ap, mode_t); | 61 | mode = va_arg(ap, mode_t); |
63 | va_end(ap); | 62 | va_end(ap); |
64 | return open(filename, flags | O_BINARY, mode); | 63 | return (open(filename, flags | O_BINARY, mode)); |
65 | } | 64 | } |
66 | 65 | ||
67 | int binary_pipe(int fd[2]) | 66 | int |
67 | binary_pipe(int fd[2]) | ||
68 | { | 68 | { |
69 | int ret = pipe(fd); | 69 | int ret = pipe(fd); |
70 | 70 | ||
71 | if (!ret) { | 71 | if (!ret) { |
72 | setmode (fd[0], O_BINARY); | 72 | setmode(fd[0], O_BINARY); |
73 | setmode (fd[1], O_BINARY); | 73 | setmode(fd[1], O_BINARY); |
74 | } | 74 | } |
75 | return ret; | 75 | return (ret); |
76 | } | 76 | } |
77 | 77 | ||
78 | #define HAS_CREATE_TOKEN 1 | 78 | #define HAS_CREATE_TOKEN 1 |
79 | #define HAS_NTSEC_BY_DEFAULT 2 | 79 | #define HAS_NTSEC_BY_DEFAULT 2 |
80 | 80 | ||
81 | static int has_capability(int what) | 81 | static int |
82 | has_capability(int what) | ||
82 | { | 83 | { |
83 | /* has_capability() basically calls uname() and checks if | ||
84 | specific capabilities of Cygwin can be evaluated from that. | ||
85 | This simplifies the calling functions which only have to ask | ||
86 | for a capability using has_capability() instead of having | ||
87 | to figure that out by themselves. */ | ||
88 | static int inited; | 84 | static int inited; |
89 | static int has_create_token; | 85 | static int has_create_token; |
90 | static int has_ntsec_by_default; | 86 | static int has_ntsec_by_default; |
91 | 87 | ||
88 | /* | ||
89 | * has_capability() basically calls uname() and checks if | ||
90 | * specific capabilities of Cygwin can be evaluated from that. | ||
91 | * This simplifies the calling functions which only have to ask | ||
92 | * for a capability using has_capability() instead of having | ||
93 | * to figure that out by themselves. | ||
94 | */ | ||
92 | if (!inited) { | 95 | if (!inited) { |
93 | struct utsname uts; | 96 | struct utsname uts; |
94 | char *c; | 97 | char *c; |
95 | 98 | ||
96 | if (!uname(&uts)) { | 99 | if (!uname(&uts)) { |
97 | int major_high = 0; | 100 | int major_high = 0, major_low = 0, minor = 0; |
98 | int major_low = 0; | 101 | int api_major_version = 0, api_minor_version = 0; |
99 | int minor = 0; | ||
100 | int api_major_version = 0; | ||
101 | int api_minor_version = 0; | ||
102 | char *c; | 102 | char *c; |
103 | 103 | ||
104 | sscanf(uts.release, "%d.%d.%d", &major_high, | 104 | sscanf(uts.release, "%d.%d.%d", &major_high, |
105 | &major_low, &minor); | 105 | &major_low, &minor); |
106 | c = strchr(uts.release, '('); | 106 | if ((c = strchr(uts.release, '(')) != NULL) { |
107 | if (c) | ||
108 | sscanf(c + 1, "%d.%d", &api_major_version, | 107 | sscanf(c + 1, "%d.%d", &api_major_version, |
109 | &api_minor_version); | 108 | &api_minor_version); |
109 | } | ||
110 | if (major_high > 1 || | 110 | if (major_high > 1 || |
111 | (major_high == 1 && (major_low > 3 || | 111 | (major_high == 1 && (major_low > 3 || |
112 | (major_low == 3 && minor >= 2)))) | 112 | (major_low == 3 && minor >= 2)))) |
113 | has_create_token = 1; | 113 | has_create_token = 1; |
114 | if (api_major_version > 0 || api_minor_version >= 56) | 114 | if (api_major_version > 0 || api_minor_version >= 56) |
115 | has_ntsec_by_default = 1; | 115 | has_ntsec_by_default = 1; |
@@ -118,14 +118,15 @@ static int has_capability(int what) | |||
118 | } | 118 | } |
119 | switch (what) { | 119 | switch (what) { |
120 | case HAS_CREATE_TOKEN: | 120 | case HAS_CREATE_TOKEN: |
121 | return has_create_token; | 121 | return (has_create_token); |
122 | case HAS_NTSEC_BY_DEFAULT: | 122 | case HAS_NTSEC_BY_DEFAULT: |
123 | return has_ntsec_by_default; | 123 | return (has_ntsec_by_default); |
124 | } | 124 | } |
125 | return 0; | 125 | return (0); |
126 | } | 126 | } |
127 | 127 | ||
128 | int check_nt_auth(int pwd_authenticated, struct passwd *pw) | 128 | int |
129 | check_nt_auth(int pwd_authenticated, struct passwd *pw) | ||
129 | { | 130 | { |
130 | /* | 131 | /* |
131 | * The only authentication which is able to change the user | 132 | * The only authentication which is able to change the user |
@@ -149,34 +150,33 @@ int check_nt_auth(int pwd_authenticated, struct passwd *pw) | |||
149 | has_create_token = 0; | 150 | has_create_token = 0; |
150 | if (has_capability(HAS_CREATE_TOKEN) && | 151 | if (has_capability(HAS_CREATE_TOKEN) && |
151 | (ntsec_on(cygwin) || | 152 | (ntsec_on(cygwin) || |
152 | (has_capability(HAS_NTSEC_BY_DEFAULT) && | 153 | (has_capability(HAS_NTSEC_BY_DEFAULT) && |
153 | !ntsec_off(cygwin)))) | 154 | !ntsec_off(cygwin)))) |
154 | has_create_token = 1; | 155 | has_create_token = 1; |
155 | } | 156 | } |
156 | if (has_create_token < 1 && | 157 | if (has_create_token < 1 && |
157 | !pwd_authenticated && geteuid() != pw->pw_uid) | 158 | !pwd_authenticated && geteuid() != pw->pw_uid) |
158 | return 0; | 159 | return (0); |
159 | } | 160 | } |
160 | return 1; | 161 | return (1); |
161 | } | 162 | } |
162 | 163 | ||
163 | int check_ntsec(const char *filename) | 164 | int |
165 | check_ntsec(const char *filename) | ||
164 | { | 166 | { |
165 | char *cygwin; | 167 | char *cygwin; |
166 | int allow_ntea = 0; | 168 | int allow_ntea = 0, allow_ntsec = 0; |
167 | int allow_ntsec = 0; | ||
168 | struct statfs fsstat; | 169 | struct statfs fsstat; |
169 | 170 | ||
170 | /* Windows 95/98/ME don't support file system security at all. */ | 171 | /* Windows 95/98/ME don't support file system security at all. */ |
171 | if (!is_winnt) | 172 | if (!is_winnt) |
172 | return 0; | 173 | return (0); |
173 | 174 | ||
174 | /* Evaluate current CYGWIN settings. */ | 175 | /* Evaluate current CYGWIN settings. */ |
175 | cygwin = getenv("CYGWIN"); | 176 | cygwin = getenv("CYGWIN"); |
176 | allow_ntea = ntea_on(cygwin); | 177 | allow_ntea = ntea_on(cygwin); |
177 | allow_ntsec = ntsec_on(cygwin) || | 178 | allow_ntsec = ntsec_on(cygwin) || |
178 | (has_capability(HAS_NTSEC_BY_DEFAULT) && | 179 | (has_capability(HAS_NTSEC_BY_DEFAULT) && !ntsec_off(cygwin)); |
179 | !ntsec_off(cygwin)); | ||
180 | 180 | ||
181 | /* | 181 | /* |
182 | * `ntea' is an emulation of POSIX attributes. It doesn't support | 182 | * `ntea' is an emulation of POSIX attributes. It doesn't support |
@@ -185,14 +185,14 @@ int check_ntsec(const char *filename) | |||
185 | * for security checks. | 185 | * for security checks. |
186 | */ | 186 | */ |
187 | if (allow_ntea) | 187 | if (allow_ntea) |
188 | return 1; | 188 | return (1); |
189 | 189 | ||
190 | /* | 190 | /* |
191 | * Retrieve file system flags. In Cygwin, file system flags are | 191 | * Retrieve file system flags. In Cygwin, file system flags are |
192 | * copied to f_type which has no meaning in Win32 itself. | 192 | * copied to f_type which has no meaning in Win32 itself. |
193 | */ | 193 | */ |
194 | if (statfs(filename, &fsstat)) | 194 | if (statfs(filename, &fsstat)) |
195 | return 1; | 195 | return (1); |
196 | 196 | ||
197 | /* | 197 | /* |
198 | * Only file systems supporting ACLs are able to set permissions. | 198 | * Only file systems supporting ACLs are able to set permissions. |
@@ -200,12 +200,13 @@ int check_ntsec(const char *filename) | |||
200 | * ACLs to support POSIX permissions on files. | 200 | * ACLs to support POSIX permissions on files. |
201 | */ | 201 | */ |
202 | if (fsstat.f_type & FS_PERSISTENT_ACLS) | 202 | if (fsstat.f_type & FS_PERSISTENT_ACLS) |
203 | return allow_ntsec; | 203 | return (allow_ntsec); |
204 | 204 | ||
205 | return 0; | 205 | return (0); |
206 | } | 206 | } |
207 | 207 | ||
208 | void register_9x_service(void) | 208 | void |
209 | register_9x_service(void) | ||
209 | { | 210 | { |
210 | HINSTANCE kerneldll; | 211 | HINSTANCE kerneldll; |
211 | DWORD (*RegisterServiceProcess)(DWORD, DWORD); | 212 | DWORD (*RegisterServiceProcess)(DWORD, DWORD); |
@@ -219,10 +220,10 @@ void register_9x_service(void) | |||
219 | */ | 220 | */ |
220 | if (is_winnt) | 221 | if (is_winnt) |
221 | return; | 222 | return; |
222 | if (! (kerneldll = LoadLibrary("KERNEL32.DLL"))) | 223 | if (!(kerneldll = LoadLibrary("KERNEL32.DLL"))) |
223 | return; | 224 | return; |
224 | if (! (RegisterServiceProcess = (DWORD (*)(DWORD, DWORD)) | 225 | if (!(RegisterServiceProcess = (DWORD (*)(DWORD, DWORD)) |
225 | GetProcAddress(kerneldll, "RegisterServiceProcess"))) | 226 | GetProcAddress(kerneldll, "RegisterServiceProcess"))) |
226 | return; | 227 | return; |
227 | RegisterServiceProcess(0, 1); | 228 | RegisterServiceProcess(0, 1); |
228 | } | 229 | } |
diff --git a/openbsd-compat/bsd-cygwin_util.h b/openbsd-compat/bsd-cygwin_util.h index af470bdd8..5ccb0fba2 100644 --- a/openbsd-compat/bsd-cygwin_util.h +++ b/openbsd-compat/bsd-cygwin_util.h | |||
@@ -1,8 +1,6 @@ | |||
1 | /* $Id: bsd-cygwin_util.h,v 1.7 2002/04/15 22:00:52 stevesk Exp $ */ | 1 | /* $Id: bsd-cygwin_util.h,v 1.10 2003/08/07 06:28:16 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * cygwin_util.c | ||
5 | * | ||
6 | * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> | 4 | * Copyright (c) 2000, 2001, Corinna Vinschen <vinschen@cygnus.com> |
7 | * | 5 | * |
8 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
@@ -36,12 +34,17 @@ | |||
36 | 34 | ||
37 | #ifdef HAVE_CYGWIN | 35 | #ifdef HAVE_CYGWIN |
38 | 36 | ||
37 | #undef ERROR | ||
38 | #define is_winnt (GetVersion() < 0x80000000) | ||
39 | |||
40 | #include <windows.h> | ||
41 | #include <sys/cygwin.h> | ||
39 | #include <io.h> | 42 | #include <io.h> |
40 | 43 | ||
41 | int binary_open(const char *filename, int flags, ...); | 44 | int binary_open(const char *, int , ...); |
42 | int binary_pipe(int fd[2]); | 45 | int binary_pipe(int fd[2]); |
43 | int check_nt_auth(int pwd_authenticated, struct passwd *pw); | 46 | int check_nt_auth(int, struct passwd *); |
44 | int check_ntsec(const char *filename); | 47 | int check_ntsec(const char *); |
45 | void register_9x_service(void); | 48 | void register_9x_service(void); |
46 | 49 | ||
47 | #define open binary_open | 50 | #define open binary_open |
diff --git a/openbsd-compat/bsd-getpeereid.h b/openbsd-compat/bsd-getpeereid.h deleted file mode 100644 index 2e9f077f9..000000000 --- a/openbsd-compat/bsd-getpeereid.h +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | /* $Id: bsd-getpeereid.h,v 1.1 2002/09/12 00:33:02 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_GETPEEREID_H | ||
4 | #define _BSD_GETPEEREID_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #include <sys/types.h> /* For uid_t, gid_t */ | ||
9 | |||
10 | #ifndef HAVE_GETPEEREID | ||
11 | int getpeereid(int , uid_t *, gid_t *); | ||
12 | #endif /* HAVE_GETPEEREID */ | ||
13 | |||
14 | #endif /* _BSD_GETPEEREID_H */ | ||
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index b8e9996d5..08b089bdc 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 1999-2000 Damien Miller. All rights reserved. | 2 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
3 | * | 3 | * |
4 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
@@ -25,13 +25,13 @@ | |||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | #include "xmalloc.h" | 26 | #include "xmalloc.h" |
27 | 27 | ||
28 | RCSID("$Id: bsd-misc.c,v 1.12 2003/03/18 18:21:41 tim Exp $"); | 28 | RCSID("$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] |
32 | * Otherwise it may get clobbered by setproctitle() | 32 | * Otherwise it may get clobbered by setproctitle() |
33 | */ | 33 | */ |
34 | char *get_progname(char *argv0) | 34 | char *ssh_get_progname(char *argv0) |
35 | { | 35 | { |
36 | #ifdef HAVE___PROGNAME | 36 | #ifdef HAVE___PROGNAME |
37 | extern char *__progname; | 37 | extern char *__progname; |
@@ -41,21 +41,21 @@ char *get_progname(char *argv0) | |||
41 | char *p; | 41 | char *p; |
42 | 42 | ||
43 | if (argv0 == NULL) | 43 | if (argv0 == NULL) |
44 | return "unknown"; /* XXX */ | 44 | return ("unknown"); /* XXX */ |
45 | p = strrchr(argv0, '/'); | 45 | p = strrchr(argv0, '/'); |
46 | if (p == NULL) | 46 | if (p == NULL) |
47 | p = argv0; | 47 | p = argv0; |
48 | else | 48 | else |
49 | p++; | 49 | p++; |
50 | 50 | ||
51 | return xstrdup(p); | 51 | return (xstrdup(p)); |
52 | #endif | 52 | #endif |
53 | } | 53 | } |
54 | 54 | ||
55 | #ifndef HAVE_SETLOGIN | 55 | #ifndef HAVE_SETLOGIN |
56 | int setlogin(const char *name) | 56 | int setlogin(const char *name) |
57 | { | 57 | { |
58 | return(0); | 58 | return (0); |
59 | } | 59 | } |
60 | #endif /* !HAVE_SETLOGIN */ | 60 | #endif /* !HAVE_SETLOGIN */ |
61 | 61 | ||
@@ -63,21 +63,21 @@ int setlogin(const char *name) | |||
63 | int innetgr(const char *netgroup, const char *host, | 63 | int innetgr(const char *netgroup, const char *host, |
64 | const char *user, const char *domain) | 64 | const char *user, const char *domain) |
65 | { | 65 | { |
66 | return(0); | 66 | return (0); |
67 | } | 67 | } |
68 | #endif /* HAVE_INNETGR */ | 68 | #endif /* HAVE_INNETGR */ |
69 | 69 | ||
70 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) | 70 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
71 | int seteuid(uid_t euid) | 71 | int seteuid(uid_t euid) |
72 | { | 72 | { |
73 | return(setreuid(-1,euid)); | 73 | return (setreuid(-1, euid)); |
74 | } | 74 | } |
75 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ | 75 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ |
76 | 76 | ||
77 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) | 77 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) |
78 | int setegid(uid_t egid) | 78 | int setegid(uid_t egid) |
79 | { | 79 | { |
80 | return(setresgid(-1,egid,-1)); | 80 | return(setresgid(-1, egid, -1)); |
81 | } | 81 | } |
82 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ | 82 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ |
83 | 83 | ||
@@ -88,9 +88,9 @@ const char *strerror(int e) | |||
88 | extern char *sys_errlist[]; | 88 | extern char *sys_errlist[]; |
89 | 89 | ||
90 | if ((e >= 0) && (e < sys_nerr)) | 90 | if ((e >= 0) && (e < sys_nerr)) |
91 | return(sys_errlist[e]); | 91 | return (sys_errlist[e]); |
92 | else | 92 | |
93 | return("unlisted error"); | 93 | return ("unlisted error"); |
94 | } | 94 | } |
95 | #endif | 95 | #endif |
96 | 96 | ||
@@ -102,24 +102,25 @@ int utimes(char *filename, struct timeval *tvp) | |||
102 | ub.actime = tvp[0].tv_sec; | 102 | ub.actime = tvp[0].tv_sec; |
103 | ub.modtime = tvp[1].tv_sec; | 103 | ub.modtime = tvp[1].tv_sec; |
104 | 104 | ||
105 | return(utime(filename, &ub)); | 105 | return (utime(filename, &ub)); |
106 | } | 106 | } |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | #ifndef HAVE_TRUNCATE | 109 | #ifndef HAVE_TRUNCATE |
110 | int truncate (const char *path, off_t length) | 110 | int truncate(const char *path, off_t length) |
111 | { | 111 | { |
112 | int fd, ret, saverrno; | 112 | int fd, ret, saverrno; |
113 | 113 | ||
114 | fd = open(path, O_WRONLY); | 114 | fd = open(path, O_WRONLY); |
115 | if (fd < 0) | 115 | if (fd < 0) |
116 | return -1; | 116 | return (-1); |
117 | 117 | ||
118 | ret = ftruncate(fd, length); | 118 | ret = ftruncate(fd, length); |
119 | saverrno = errno; | 119 | saverrno = errno; |
120 | (void) close (fd); | 120 | close(fd); |
121 | if (ret == -1) | 121 | if (ret == -1) |
122 | errno = saverrno; | 122 | errno = saverrno; |
123 | |||
123 | return(ret); | 124 | return(ret); |
124 | } | 125 | } |
125 | #endif /* HAVE_TRUNCATE */ | 126 | #endif /* HAVE_TRUNCATE */ |
@@ -131,7 +132,7 @@ int truncate (const char *path, off_t length) | |||
131 | int | 132 | int |
132 | setgroups(size_t size, const gid_t *list) | 133 | setgroups(size_t size, const gid_t *list) |
133 | { | 134 | { |
134 | return 0; | 135 | return (0); |
135 | } | 136 | } |
136 | #endif | 137 | #endif |
137 | 138 | ||
@@ -166,3 +167,62 @@ int nanosleep(const struct timespec *req, struct timespec *rem) | |||
166 | 167 | ||
167 | #endif | 168 | #endif |
168 | 169 | ||
170 | #ifndef HAVE_TCGETPGRP | ||
171 | pid_t | ||
172 | tcgetpgrp(int fd) | ||
173 | { | ||
174 | int ctty_pgrp; | ||
175 | |||
176 | if (ioctl(fd, TIOCGPGRP, &ctty_pgrp) == -1) | ||
177 | return(-1); | ||
178 | else | ||
179 | return(ctty_pgrp); | ||
180 | } | ||
181 | #endif /* HAVE_TCGETPGRP */ | ||
182 | |||
183 | #ifndef HAVE_TCSENDBREAK | ||
184 | int | ||
185 | tcsendbreak(int fd, int duration) | ||
186 | { | ||
187 | # if defined(TIOCSBRK) && defined(TIOCCBRK) | ||
188 | struct timeval sleepytime; | ||
189 | |||
190 | sleepytime.tv_sec = 0; | ||
191 | sleepytime.tv_usec = 400000; | ||
192 | if (ioctl(fd, TIOCSBRK, 0) == -1) | ||
193 | return (-1); | ||
194 | (void)select(0, 0, 0, 0, &sleepytime); | ||
195 | if (ioctl(fd, TIOCCBRK, 0) == -1) | ||
196 | return (-1); | ||
197 | return (0); | ||
198 | # else | ||
199 | return -1; | ||
200 | # endif | ||
201 | } | ||
202 | #endif /* HAVE_TCSENDBREAK */ | ||
203 | |||
204 | mysig_t | ||
205 | mysignal(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 78d9ccdd4..6b70473f3 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h | |||
@@ -1,5 +1,7 @@ | |||
1 | /* $Id: bsd-misc.h,v 1.13 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
1 | /* | 3 | /* |
2 | * Copyright (c) 1999-2000 Damien Miller. All rights reserved. | 4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
3 | * | 5 | * |
4 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions |
@@ -22,42 +24,39 @@ | |||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ | 25 | */ |
24 | 26 | ||
25 | /* $Id: bsd-misc.h,v 1.7 2003/03/18 18:21:41 tim Exp $ */ | ||
26 | |||
27 | #ifndef _BSD_MISC_H | 27 | #ifndef _BSD_MISC_H |
28 | #define _BSD_MISC_H | 28 | #define _BSD_MISC_H |
29 | 29 | ||
30 | #include "config.h" | 30 | #include "includes.h" |
31 | 31 | ||
32 | char *get_progname(char *argv0); | 32 | char *ssh_get_progname(char *); |
33 | 33 | ||
34 | #ifndef HAVE_SETSID | 34 | #ifndef HAVE_SETSID |
35 | #define setsid() setpgrp(0, getpid()) | 35 | #define setsid() setpgrp(0, getpid()) |
36 | #endif /* !HAVE_SETSID */ | 36 | #endif /* !HAVE_SETSID */ |
37 | 37 | ||
38 | #ifndef HAVE_SETENV | 38 | #ifndef HAVE_SETENV |
39 | int setenv(const char *name, const char *value, int overwrite); | 39 | int setenv(const char *, const char *, int); |
40 | #endif /* !HAVE_SETENV */ | 40 | #endif /* !HAVE_SETENV */ |
41 | 41 | ||
42 | #ifndef HAVE_SETLOGIN | 42 | #ifndef HAVE_SETLOGIN |
43 | int setlogin(const char *name); | 43 | int setlogin(const char *); |
44 | #endif /* !HAVE_SETLOGIN */ | 44 | #endif /* !HAVE_SETLOGIN */ |
45 | 45 | ||
46 | #ifndef HAVE_INNETGR | 46 | #ifndef HAVE_INNETGR |
47 | int innetgr(const char *netgroup, const char *host, | 47 | int innetgr(const char *, const char *, const char *, const char *); |
48 | const char *user, const char *domain); | ||
49 | #endif /* HAVE_INNETGR */ | 48 | #endif /* HAVE_INNETGR */ |
50 | 49 | ||
51 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) | 50 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
52 | int seteuid(uid_t euid); | 51 | int seteuid(uid_t); |
53 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ | 52 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ |
54 | 53 | ||
55 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) | 54 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) |
56 | int setegid(uid_t egid); | 55 | int setegid(uid_t); |
57 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ | 56 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ |
58 | 57 | ||
59 | #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) | 58 | #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) |
60 | const char *strerror(int e); | 59 | const char *strerror(int); |
61 | #endif | 60 | #endif |
62 | 61 | ||
63 | 62 | ||
@@ -69,15 +68,15 @@ struct timeval { | |||
69 | } | 68 | } |
70 | #endif /* HAVE_STRUCT_TIMEVAL */ | 69 | #endif /* HAVE_STRUCT_TIMEVAL */ |
71 | 70 | ||
72 | int utimes(char *filename, struct timeval *tvp); | 71 | int utimes(char *, struct timeval *); |
73 | #endif /* HAVE_UTIMES */ | 72 | #endif /* HAVE_UTIMES */ |
74 | 73 | ||
75 | #ifndef HAVE_TRUNCATE | 74 | #ifndef HAVE_TRUNCATE |
76 | int truncate (const char *path, off_t length); | 75 | int truncate (const char *, off_t); |
77 | #endif /* HAVE_TRUNCATE */ | 76 | #endif /* HAVE_TRUNCATE */ |
78 | 77 | ||
79 | #if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP) | 78 | #if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP) |
80 | int setgroups(size_t size, const gid_t *list); | 79 | int setgroups(size_t, const gid_t *); |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) | 82 | #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) |
@@ -87,7 +86,21 @@ struct timespec { | |||
87 | long tv_nsec; | 86 | long tv_nsec; |
88 | }; | 87 | }; |
89 | #endif | 88 | #endif |
90 | int nanosleep(const struct timespec *req, struct timespec *rem); | 89 | int nanosleep(const struct timespec *, struct timespec *); |
90 | #endif | ||
91 | |||
92 | #ifndef HAVE_TCGETPGRP | ||
93 | pid_t tcgetpgrp(int); | ||
94 | #endif | ||
95 | |||
96 | #ifndef HAVE_TCSENDBREAK | ||
97 | int tcsendbreak(int, int); | ||
91 | #endif | 98 | #endif |
92 | 99 | ||
100 | /* wrapper for signal interface */ | ||
101 | typedef void (*mysig_t)(int); | ||
102 | mysig_t mysignal(int sig, mysig_t act); | ||
103 | |||
104 | #define signal(a,b) mysignal(a,b) | ||
105 | |||
93 | #endif /* _BSD_MISC_H */ | 106 | #endif /* _BSD_MISC_H */ |
diff --git a/openbsd-compat/bsd-nextstep.c b/openbsd-compat/bsd-nextstep.c index 85b298a48..bd35a3afc 100644 --- a/openbsd-compat/bsd-nextstep.c +++ b/openbsd-compat/bsd-nextstep.c | |||
@@ -1,4 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000,2001 Ben Lindstrom. All rights reserved. | ||
3 | * | ||
2 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
3 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
4 | * are met: | 6 | * are met: |
@@ -22,7 +24,7 @@ | |||
22 | 24 | ||
23 | #include "includes.h" | 25 | #include "includes.h" |
24 | 26 | ||
25 | RCSID("$Id: bsd-nextstep.c,v 1.4 2001/03/26 05:35:34 mouring Exp $"); | 27 | RCSID("$Id: bsd-nextstep.c,v 1.6 2003/06/01 03:23:57 mouring Exp $"); |
26 | 28 | ||
27 | #ifdef HAVE_NEXT | 29 | #ifdef HAVE_NEXT |
28 | #include <errno.h> | 30 | #include <errno.h> |
@@ -40,7 +42,7 @@ posix_wait(int *status) | |||
40 | if (status) | 42 | if (status) |
41 | *status = (int) statusp.w_status; | 43 | *status = (int) statusp.w_status; |
42 | 44 | ||
43 | return wait_pid; | 45 | return (wait_pid); |
44 | } | 46 | } |
45 | 47 | ||
46 | int | 48 | int |
diff --git a/openbsd-compat/bsd-nextstep.h b/openbsd-compat/bsd-nextstep.h index c6a7019c6..ca5b4b54a 100644 --- a/openbsd-compat/bsd-nextstep.h +++ b/openbsd-compat/bsd-nextstep.h | |||
@@ -1,4 +1,8 @@ | |||
1 | /* $Id: bsd-nextstep.h,v 1.9 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
1 | /* | 3 | /* |
4 | * Copyright (c) 2000,2001 Ben Lindstrom. All rights reserved. | ||
5 | * | ||
2 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
3 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions |
4 | * are met: | 8 | * are met: |
@@ -21,8 +25,6 @@ | |||
21 | * | 25 | * |
22 | */ | 26 | */ |
23 | 27 | ||
24 | /* $Id: bsd-nextstep.h,v 1.6 2001/03/19 13:42:22 mouring Exp $ */ | ||
25 | |||
26 | #ifndef _NEXT_POSIX_H | 28 | #ifndef _NEXT_POSIX_H |
27 | #define _NEXT_POSIX_H | 29 | #define _NEXT_POSIX_H |
28 | 30 | ||
@@ -37,22 +39,21 @@ | |||
37 | #define dirent direct | 39 | #define dirent direct |
38 | 40 | ||
39 | /* Swap out NeXT's BSD wait() for a more POSIX complient one */ | 41 | /* Swap out NeXT's BSD wait() for a more POSIX complient one */ |
40 | pid_t posix_wait(int *status); | 42 | pid_t posix_wait(int *); |
41 | #define wait(a) posix_wait(a) | 43 | #define wait(a) posix_wait(a) |
42 | 44 | ||
43 | /* #ifdef wrapped functions that need defining for clean compiling */ | 45 | /* #ifdef wrapped functions that need defining for clean compiling */ |
44 | pid_t getppid(void); | 46 | pid_t getppid(void); |
45 | void vhangup(void); | 47 | void vhangup(void); |
46 | int innetgr(const char *netgroup, const char *host, const char *user, | 48 | int innetgr(const char *, const char *, const char *, const char *); |
47 | const char *domain); | ||
48 | 49 | ||
49 | /* TERMCAP */ | 50 | /* TERMCAP */ |
50 | int tcgetattr(int fd, struct termios *t); | 51 | int tcgetattr(int, struct termios *); |
51 | int tcsetattr(int fd, int opt, const struct termios *t); | 52 | int tcsetattr(int, int, const struct termios *); |
52 | int tcsetpgrp(int fd, pid_t pgrp); | 53 | int tcsetpgrp(int, pid_t); |
53 | speed_t cfgetospeed(const struct termios *t); | 54 | speed_t cfgetospeed(const struct termios *); |
54 | speed_t cfgetispeed(const struct termios *t); | 55 | speed_t cfgetispeed(const struct termios *); |
55 | int cfsetospeed(struct termios *t, int speed); | 56 | int cfsetospeed(struct termios *, int); |
56 | int cfsetispeed(struct termios *t, int speed); | 57 | int cfsetispeed(struct termios *, int); |
57 | #endif /* HAVE_NEXT */ | 58 | #endif /* HAVE_NEXT */ |
58 | #endif /* _NEXT_POSIX_H */ | 59 | #endif /* _NEXT_POSIX_H */ |
diff --git a/openbsd-compat/bsd-snprintf.c b/openbsd-compat/bsd-snprintf.c index 2f82180d1..e4d8a439a 100644 --- a/openbsd-compat/bsd-snprintf.c +++ b/openbsd-compat/bsd-snprintf.c | |||
@@ -58,7 +58,7 @@ | |||
58 | 58 | ||
59 | #include "includes.h" | 59 | #include "includes.h" |
60 | 60 | ||
61 | RCSID("$Id: bsd-snprintf.c,v 1.6 2003/04/01 11:31:56 djm Exp $"); | 61 | RCSID("$Id: bsd-snprintf.c,v 1.7 2003/05/18 14:13:39 djm Exp $"); |
62 | 62 | ||
63 | #if defined(BROKEN_SNPRINTF) /* For those with broken snprintf() */ | 63 | #if defined(BROKEN_SNPRINTF) /* For those with broken snprintf() */ |
64 | # undef HAVE_SNPRINTF | 64 | # undef HAVE_SNPRINTF |
@@ -72,15 +72,15 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args); | |||
72 | 72 | ||
73 | static void | 73 | static void |
74 | fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, | 74 | fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, |
75 | int min, int max); | 75 | int min, int max); |
76 | 76 | ||
77 | static void | 77 | static void |
78 | fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, | 78 | fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, |
79 | int min, int max, int flags); | 79 | int min, int max, int flags); |
80 | 80 | ||
81 | static void | 81 | static void |
82 | fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | 82 | fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, |
83 | int min, int max, int flags); | 83 | int min, int max, int flags); |
84 | 84 | ||
85 | static void | 85 | static void |
86 | dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); | 86 | dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); |
@@ -121,15 +121,10 @@ dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); | |||
121 | static void | 121 | static void |
122 | dopr(char *buffer, size_t maxlen, const char *format, va_list args) | 122 | dopr(char *buffer, size_t maxlen, const char *format, va_list args) |
123 | { | 123 | { |
124 | char *strvalue; | 124 | char *strvalue, ch; |
125 | char ch; | ||
126 | long value; | 125 | long value; |
127 | long double fvalue; | 126 | long double fvalue; |
128 | int min = 0; | 127 | int min = 0, max = -1, state = DP_S_DEFAULT, flags = 0, cflags = 0; |
129 | int max = -1; | ||
130 | int state = DP_S_DEFAULT; | ||
131 | int flags = 0; | ||
132 | int cflags = 0; | ||
133 | size_t currlen = 0; | 128 | size_t currlen = 0; |
134 | 129 | ||
135 | ch = *format++; | 130 | ch = *format++; |
@@ -139,224 +134,224 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args) | |||
139 | state = DP_S_DONE; | 134 | state = DP_S_DONE; |
140 | 135 | ||
141 | switch(state) { | 136 | switch(state) { |
142 | case DP_S_DEFAULT: | 137 | case DP_S_DEFAULT: |
143 | if (ch == '%') | 138 | if (ch == '%') |
144 | state = DP_S_FLAGS; | 139 | state = DP_S_FLAGS; |
145 | else | 140 | else |
146 | dopr_outch(buffer, &currlen, maxlen, ch); | 141 | dopr_outch(buffer, &currlen, maxlen, ch); |
142 | ch = *format++; | ||
143 | break; | ||
144 | case DP_S_FLAGS: | ||
145 | switch (ch) { | ||
146 | case '-': | ||
147 | flags |= DP_F_MINUS; | ||
147 | ch = *format++; | 148 | ch = *format++; |
148 | break; | 149 | break; |
149 | case DP_S_FLAGS: | 150 | case '+': |
150 | switch (ch) { | 151 | flags |= DP_F_PLUS; |
151 | case '-': | 152 | ch = *format++; |
152 | flags |= DP_F_MINUS; | ||
153 | ch = *format++; | ||
154 | break; | ||
155 | case '+': | ||
156 | flags |= DP_F_PLUS; | ||
157 | ch = *format++; | ||
158 | break; | ||
159 | case ' ': | ||
160 | flags |= DP_F_SPACE; | ||
161 | ch = *format++; | ||
162 | break; | ||
163 | case '#': | ||
164 | flags |= DP_F_NUM; | ||
165 | ch = *format++; | ||
166 | break; | ||
167 | case '0': | ||
168 | flags |= DP_F_ZERO; | ||
169 | ch = *format++; | ||
170 | break; | ||
171 | default: | ||
172 | state = DP_S_MIN; | ||
173 | break; | ||
174 | } | ||
175 | break; | 153 | break; |
176 | case DP_S_MIN: | 154 | case ' ': |
177 | if (isdigit((unsigned char)ch)) { | 155 | flags |= DP_F_SPACE; |
178 | min = 10*min + char_to_int (ch); | 156 | ch = *format++; |
179 | ch = *format++; | ||
180 | } else if (ch == '*') { | ||
181 | min = va_arg (args, int); | ||
182 | ch = *format++; | ||
183 | state = DP_S_DOT; | ||
184 | } else | ||
185 | state = DP_S_DOT; | ||
186 | break; | 157 | break; |
187 | case DP_S_DOT: | 158 | case '#': |
188 | if (ch == '.') { | 159 | flags |= DP_F_NUM; |
189 | state = DP_S_MAX; | 160 | ch = *format++; |
190 | ch = *format++; | ||
191 | } else | ||
192 | state = DP_S_MOD; | ||
193 | break; | 161 | break; |
194 | case DP_S_MAX: | 162 | case '0': |
195 | if (isdigit((unsigned char)ch)) { | 163 | flags |= DP_F_ZERO; |
196 | if (max < 0) | 164 | ch = *format++; |
197 | max = 0; | ||
198 | max = 10*max + char_to_int(ch); | ||
199 | ch = *format++; | ||
200 | } else if (ch == '*') { | ||
201 | max = va_arg (args, int); | ||
202 | ch = *format++; | ||
203 | state = DP_S_MOD; | ||
204 | } else | ||
205 | state = DP_S_MOD; | ||
206 | break; | 165 | break; |
207 | case DP_S_MOD: | 166 | default: |
208 | switch (ch) { | 167 | state = DP_S_MIN; |
209 | case 'h': | ||
210 | cflags = DP_C_SHORT; | ||
211 | ch = *format++; | ||
212 | break; | ||
213 | case 'l': | ||
214 | cflags = DP_C_LONG; | ||
215 | ch = *format++; | ||
216 | if (ch == 'l') { | ||
217 | cflags = DP_C_LONG_LONG; | ||
218 | ch = *format++; | ||
219 | } | ||
220 | break; | ||
221 | case 'q': | ||
222 | cflags = DP_C_LONG_LONG; | ||
223 | ch = *format++; | ||
224 | break; | ||
225 | case 'L': | ||
226 | cflags = DP_C_LDOUBLE; | ||
227 | ch = *format++; | ||
228 | break; | ||
229 | default: | ||
230 | break; | ||
231 | } | ||
232 | state = DP_S_CONV; | ||
233 | break; | 168 | break; |
234 | case DP_S_CONV: | 169 | } |
235 | switch (ch) { | 170 | break; |
236 | case 'd': | 171 | case DP_S_MIN: |
237 | case 'i': | 172 | if (isdigit((unsigned char)ch)) { |
238 | if (cflags == DP_C_SHORT) | 173 | min = 10 * min + char_to_int (ch); |
239 | value = va_arg(args, int); | 174 | ch = *format++; |
240 | else if (cflags == DP_C_LONG) | 175 | } else if (ch == '*') { |
241 | value = va_arg(args, long int); | 176 | min = va_arg (args, int); |
242 | else if (cflags == DP_C_LONG_LONG) | 177 | ch = *format++; |
243 | value = va_arg (args, long long); | 178 | state = DP_S_DOT; |
244 | else | 179 | } else |
245 | value = va_arg (args, int); | 180 | state = DP_S_DOT; |
246 | fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags); | 181 | break; |
247 | break; | 182 | case DP_S_DOT: |
248 | case 'o': | 183 | if (ch == '.') { |
249 | flags |= DP_F_UNSIGNED; | 184 | state = DP_S_MAX; |
250 | if (cflags == DP_C_SHORT) | 185 | ch = *format++; |
251 | value = va_arg(args, unsigned int); | 186 | } else |
252 | else if (cflags == DP_C_LONG) | 187 | state = DP_S_MOD; |
253 | value = va_arg(args, unsigned long int); | 188 | break; |
254 | else if (cflags == DP_C_LONG_LONG) | 189 | case DP_S_MAX: |
255 | value = va_arg(args, unsigned long long); | 190 | if (isdigit((unsigned char)ch)) { |
256 | else | 191 | if (max < 0) |
257 | value = va_arg(args, unsigned int); | 192 | max = 0; |
258 | fmtint(buffer, &currlen, maxlen, value, 8, min, max, flags); | 193 | max = 10 * max + char_to_int(ch); |
259 | break; | 194 | ch = *format++; |
260 | case 'u': | 195 | } else if (ch == '*') { |
261 | flags |= DP_F_UNSIGNED; | 196 | max = va_arg (args, int); |
262 | if (cflags == DP_C_SHORT) | 197 | ch = *format++; |
263 | value = va_arg(args, unsigned int); | 198 | state = DP_S_MOD; |
264 | else if (cflags == DP_C_LONG) | 199 | } else |
265 | value = va_arg(args, unsigned long int); | 200 | state = DP_S_MOD; |
266 | else if (cflags == DP_C_LONG_LONG) | 201 | break; |
267 | value = va_arg(args, unsigned long long); | 202 | case DP_S_MOD: |
268 | else | 203 | switch (ch) { |
269 | value = va_arg(args, unsigned int); | 204 | case 'h': |
270 | fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); | 205 | cflags = DP_C_SHORT; |
271 | break; | 206 | ch = *format++; |
272 | case 'X': | 207 | break; |
273 | flags |= DP_F_UP; | 208 | case 'l': |
274 | case 'x': | 209 | cflags = DP_C_LONG; |
275 | flags |= DP_F_UNSIGNED; | 210 | ch = *format++; |
276 | if (cflags == DP_C_SHORT) | 211 | if (ch == 'l') { |
277 | value = va_arg(args, unsigned int); | 212 | cflags = DP_C_LONG_LONG; |
278 | else if (cflags == DP_C_LONG) | 213 | ch = *format++; |
279 | value = va_arg(args, unsigned long int); | ||
280 | else if (cflags == DP_C_LONG_LONG) | ||
281 | value = va_arg(args, unsigned long long); | ||
282 | else | ||
283 | value = va_arg(args, unsigned int); | ||
284 | fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags); | ||
285 | break; | ||
286 | case 'f': | ||
287 | if (cflags == DP_C_LDOUBLE) | ||
288 | fvalue = va_arg(args, long double); | ||
289 | else | ||
290 | fvalue = va_arg(args, double); | ||
291 | /* um, floating point? */ | ||
292 | fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags); | ||
293 | break; | ||
294 | case 'E': | ||
295 | flags |= DP_F_UP; | ||
296 | case 'e': | ||
297 | if (cflags == DP_C_LDOUBLE) | ||
298 | fvalue = va_arg(args, long double); | ||
299 | else | ||
300 | fvalue = va_arg(args, double); | ||
301 | break; | ||
302 | case 'G': | ||
303 | flags |= DP_F_UP; | ||
304 | case 'g': | ||
305 | if (cflags == DP_C_LDOUBLE) | ||
306 | fvalue = va_arg(args, long double); | ||
307 | else | ||
308 | fvalue = va_arg(args, double); | ||
309 | break; | ||
310 | case 'c': | ||
311 | dopr_outch(buffer, &currlen, maxlen, va_arg(args, int)); | ||
312 | break; | ||
313 | case 's': | ||
314 | strvalue = va_arg(args, char *); | ||
315 | if (max < 0) | ||
316 | max = maxlen; /* ie, no max */ | ||
317 | fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max); | ||
318 | break; | ||
319 | case 'p': | ||
320 | strvalue = va_arg(args, void *); | ||
321 | fmtint(buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); | ||
322 | break; | ||
323 | case 'n': | ||
324 | if (cflags == DP_C_SHORT) { | ||
325 | short int *num; | ||
326 | num = va_arg(args, short int *); | ||
327 | *num = currlen; | ||
328 | } else if (cflags == DP_C_LONG) { | ||
329 | long int *num; | ||
330 | num = va_arg(args, long int *); | ||
331 | *num = currlen; | ||
332 | } else if (cflags == DP_C_LONG_LONG) { | ||
333 | long long *num; | ||
334 | num = va_arg(args, long long *); | ||
335 | *num = currlen; | ||
336 | } else { | ||
337 | int *num; | ||
338 | num = va_arg(args, int *); | ||
339 | *num = currlen; | ||
340 | } | ||
341 | break; | ||
342 | case '%': | ||
343 | dopr_outch(buffer, &currlen, maxlen, ch); | ||
344 | break; | ||
345 | case 'w': /* not supported yet, treat as next char */ | ||
346 | ch = *format++; | ||
347 | break; | ||
348 | default: /* Unknown, skip */ | ||
349 | break; | ||
350 | } | 214 | } |
215 | break; | ||
216 | case 'q': | ||
217 | cflags = DP_C_LONG_LONG; | ||
218 | ch = *format++; | ||
219 | break; | ||
220 | case 'L': | ||
221 | cflags = DP_C_LDOUBLE; | ||
351 | ch = *format++; | 222 | ch = *format++; |
352 | state = DP_S_DEFAULT; | ||
353 | flags = cflags = min = 0; | ||
354 | max = -1; | ||
355 | break; | 223 | break; |
356 | case DP_S_DONE: | 224 | default: |
225 | break; | ||
226 | } | ||
227 | state = DP_S_CONV; | ||
228 | break; | ||
229 | case DP_S_CONV: | ||
230 | switch (ch) { | ||
231 | case 'd': | ||
232 | case 'i': | ||
233 | if (cflags == DP_C_SHORT) | ||
234 | value = va_arg(args, int); | ||
235 | else if (cflags == DP_C_LONG) | ||
236 | value = va_arg(args, long int); | ||
237 | else if (cflags == DP_C_LONG_LONG) | ||
238 | value = va_arg (args, long long); | ||
239 | else | ||
240 | value = va_arg (args, int); | ||
241 | fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags); | ||
242 | break; | ||
243 | case 'o': | ||
244 | flags |= DP_F_UNSIGNED; | ||
245 | if (cflags == DP_C_SHORT) | ||
246 | value = va_arg(args, unsigned int); | ||
247 | else if (cflags == DP_C_LONG) | ||
248 | value = va_arg(args, unsigned long int); | ||
249 | else if (cflags == DP_C_LONG_LONG) | ||
250 | value = va_arg(args, unsigned long long); | ||
251 | else | ||
252 | value = va_arg(args, unsigned int); | ||
253 | fmtint(buffer, &currlen, maxlen, value, 8, min, max, flags); | ||
357 | break; | 254 | break; |
358 | default: /* hmm? */ | 255 | case 'u': |
359 | break; /* some picky compilers need this */ | 256 | flags |= DP_F_UNSIGNED; |
257 | if (cflags == DP_C_SHORT) | ||
258 | value = va_arg(args, unsigned int); | ||
259 | else if (cflags == DP_C_LONG) | ||
260 | value = va_arg(args, unsigned long int); | ||
261 | else if (cflags == DP_C_LONG_LONG) | ||
262 | value = va_arg(args, unsigned long long); | ||
263 | else | ||
264 | value = va_arg(args, unsigned int); | ||
265 | fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); | ||
266 | break; | ||
267 | case 'X': | ||
268 | flags |= DP_F_UP; | ||
269 | case 'x': | ||
270 | flags |= DP_F_UNSIGNED; | ||
271 | if (cflags == DP_C_SHORT) | ||
272 | value = va_arg(args, unsigned int); | ||
273 | else if (cflags == DP_C_LONG) | ||
274 | value = va_arg(args, unsigned long int); | ||
275 | else if (cflags == DP_C_LONG_LONG) | ||
276 | value = va_arg(args, unsigned long long); | ||
277 | else | ||
278 | value = va_arg(args, unsigned int); | ||
279 | fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags); | ||
280 | break; | ||
281 | case 'f': | ||
282 | if (cflags == DP_C_LDOUBLE) | ||
283 | fvalue = va_arg(args, long double); | ||
284 | else | ||
285 | fvalue = va_arg(args, double); | ||
286 | /* um, floating point? */ | ||
287 | fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags); | ||
288 | break; | ||
289 | case 'E': | ||
290 | flags |= DP_F_UP; | ||
291 | case 'e': | ||
292 | if (cflags == DP_C_LDOUBLE) | ||
293 | fvalue = va_arg(args, long double); | ||
294 | else | ||
295 | fvalue = va_arg(args, double); | ||
296 | break; | ||
297 | case 'G': | ||
298 | flags |= DP_F_UP; | ||
299 | case 'g': | ||
300 | if (cflags == DP_C_LDOUBLE) | ||
301 | fvalue = va_arg(args, long double); | ||
302 | else | ||
303 | fvalue = va_arg(args, double); | ||
304 | break; | ||
305 | case 'c': | ||
306 | dopr_outch(buffer, &currlen, maxlen, va_arg(args, int)); | ||
307 | break; | ||
308 | case 's': | ||
309 | strvalue = va_arg(args, char *); | ||
310 | if (max < 0) | ||
311 | max = maxlen; /* ie, no max */ | ||
312 | fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max); | ||
313 | break; | ||
314 | case 'p': | ||
315 | strvalue = va_arg(args, void *); | ||
316 | fmtint(buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); | ||
317 | break; | ||
318 | case 'n': | ||
319 | if (cflags == DP_C_SHORT) { | ||
320 | short int *num; | ||
321 | num = va_arg(args, short int *); | ||
322 | *num = currlen; | ||
323 | } else if (cflags == DP_C_LONG) { | ||
324 | long int *num; | ||
325 | num = va_arg(args, long int *); | ||
326 | *num = currlen; | ||
327 | } else if (cflags == DP_C_LONG_LONG) { | ||
328 | long long *num; | ||
329 | num = va_arg(args, long long *); | ||
330 | *num = currlen; | ||
331 | } else { | ||
332 | int *num; | ||
333 | num = va_arg(args, int *); | ||
334 | *num = currlen; | ||
335 | } | ||
336 | break; | ||
337 | case '%': | ||
338 | dopr_outch(buffer, &currlen, maxlen, ch); | ||
339 | break; | ||
340 | case 'w': /* not supported yet, treat as next char */ | ||
341 | ch = *format++; | ||
342 | break; | ||
343 | default: /* Unknown, skip */ | ||
344 | break; | ||
345 | } | ||
346 | ch = *format++; | ||
347 | state = DP_S_DEFAULT; | ||
348 | flags = cflags = min = 0; | ||
349 | max = -1; | ||
350 | break; | ||
351 | case DP_S_DONE: | ||
352 | break; | ||
353 | default: /* hmm? */ | ||
354 | break; /* some picky compilers need this */ | ||
360 | } | 355 | } |
361 | } | 356 | } |
362 | if (currlen < maxlen - 1) | 357 | if (currlen < maxlen - 1) |
@@ -367,10 +362,9 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args) | |||
367 | 362 | ||
368 | static void | 363 | static void |
369 | fmtstr(char *buffer, size_t *currlen, size_t maxlen, | 364 | fmtstr(char *buffer, size_t *currlen, size_t maxlen, |
370 | char *value, int flags, int min, int max) | 365 | char *value, int flags, int min, int max) |
371 | { | 366 | { |
372 | int padlen, strln; /* amount to pad */ | 367 | int cnt = 0, padlen, strln; /* amount to pad */ |
373 | int cnt = 0; | ||
374 | 368 | ||
375 | if (value == 0) | 369 | if (value == 0) |
376 | value = "<NULL>"; | 370 | value = "<NULL>"; |
@@ -402,15 +396,13 @@ fmtstr(char *buffer, size_t *currlen, size_t maxlen, | |||
402 | 396 | ||
403 | static void | 397 | static void |
404 | fmtint(char *buffer, size_t *currlen, size_t maxlen, | 398 | fmtint(char *buffer, size_t *currlen, size_t maxlen, |
405 | long value, int base, int min, int max, int flags) | 399 | long value, int base, int min, int max, int flags) |
406 | { | 400 | { |
407 | unsigned long uvalue; | 401 | unsigned long uvalue; |
408 | char convert[20]; | 402 | char convert[20]; |
409 | int signvalue = 0; | 403 | int signvalue = 0, place = 0, caps = 0; |
410 | int place = 0; | ||
411 | int spadlen = 0; /* amount to space pad */ | 404 | int spadlen = 0; /* amount to space pad */ |
412 | int zpadlen = 0; /* amount to zero pad */ | 405 | int zpadlen = 0; /* amount to zero pad */ |
413 | int caps = 0; | ||
414 | 406 | ||
415 | if (max < 0) | 407 | if (max < 0) |
416 | max = 0; | 408 | max = 0; |
@@ -429,11 +421,10 @@ fmtint(char *buffer, size_t *currlen, size_t maxlen, | |||
429 | 421 | ||
430 | if (flags & DP_F_UP) | 422 | if (flags & DP_F_UP) |
431 | caps = 1; /* Should characters be upper case? */ | 423 | caps = 1; /* Should characters be upper case? */ |
432 | |||
433 | do { | 424 | do { |
434 | convert[place++] = | 425 | convert[place++] = |
435 | (caps? "0123456789ABCDEF":"0123456789abcdef") | 426 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
436 | [uvalue % (unsigned)base]; | 427 | [uvalue % (unsigned)base]; |
437 | uvalue = (uvalue / (unsigned)base ); | 428 | uvalue = (uvalue / (unsigned)base ); |
438 | } while (uvalue && (place < 20)); | 429 | } while (uvalue && (place < 20)); |
439 | if (place == 20) | 430 | if (place == 20) |
@@ -453,7 +444,6 @@ fmtint(char *buffer, size_t *currlen, size_t maxlen, | |||
453 | if (flags & DP_F_MINUS) | 444 | if (flags & DP_F_MINUS) |
454 | spadlen = -spadlen; /* Left Justifty */ | 445 | spadlen = -spadlen; /* Left Justifty */ |
455 | 446 | ||
456 | |||
457 | /* Spaces */ | 447 | /* Spaces */ |
458 | while (spadlen > 0) { | 448 | while (spadlen > 0) { |
459 | dopr_outch(buffer, currlen, maxlen, ' '); | 449 | dopr_outch(buffer, currlen, maxlen, ' '); |
@@ -512,16 +502,11 @@ static void | |||
512 | fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | 502 | fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, |
513 | int min, int max, int flags) | 503 | int min, int max, int flags) |
514 | { | 504 | { |
515 | char iconvert[20]; | 505 | char iconvert[20], fconvert[20]; |
516 | char fconvert[20]; | 506 | int signvalue = 0, iplace = 0, fplace = 0; |
517 | int signvalue = 0; | ||
518 | int iplace = 0; | ||
519 | int fplace = 0; | ||
520 | int padlen = 0; /* amount to pad */ | 507 | int padlen = 0; /* amount to pad */ |
521 | int zpadlen = 0; | 508 | int zpadlen = 0, caps = 0; |
522 | int caps = 0; | 509 | long intpart, fracpart; |
523 | long intpart; | ||
524 | long fracpart; | ||
525 | long double ufvalue; | 510 | long double ufvalue; |
526 | 511 | ||
527 | /* | 512 | /* |
@@ -562,7 +547,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | |||
562 | /* Convert integer part */ | 547 | /* Convert integer part */ |
563 | do { | 548 | do { |
564 | iconvert[iplace++] = | 549 | iconvert[iplace++] = |
565 | (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10]; | 550 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
551 | [intpart % 10]; | ||
566 | intpart = (intpart / 10); | 552 | intpart = (intpart / 10); |
567 | } while(intpart && (iplace < 20)); | 553 | } while(intpart && (iplace < 20)); |
568 | if (iplace == 20) | 554 | if (iplace == 20) |
@@ -572,7 +558,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | |||
572 | /* Convert fractional part */ | 558 | /* Convert fractional part */ |
573 | do { | 559 | do { |
574 | fconvert[fplace++] = | 560 | fconvert[fplace++] = |
575 | (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; | 561 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
562 | [fracpart % 10]; | ||
576 | fracpart = (fracpart / 10); | 563 | fracpart = (fracpart / 10); |
577 | } while(fracpart && (fplace < 20)); | 564 | } while(fracpart && (fplace < 20)); |
578 | if (fplace == 20) | 565 | if (fplace == 20) |
@@ -611,8 +598,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, | |||
611 | dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]); | 598 | dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]); |
612 | 599 | ||
613 | /* | 600 | /* |
614 | * Decimal point. This should probably use locale to find the correct | 601 | * Decimal point. This should probably use locale to find the |
615 | * char to print out. | 602 | * correct char to print out. |
616 | */ | 603 | */ |
617 | dopr_outch(buffer, currlen, maxlen, '.'); | 604 | dopr_outch(buffer, currlen, maxlen, '.'); |
618 | 605 | ||
@@ -662,90 +649,4 @@ snprintf(char *str,size_t count,const char *fmt,...) | |||
662 | return(strlen(str)); | 649 | return(strlen(str)); |
663 | } | 650 | } |
664 | 651 | ||
665 | #ifdef TEST_SNPRINTF | ||
666 | int | ||
667 | main(void) | ||
668 | { | ||
669 | #define LONG_STRING 1024 | ||
670 | char buf1[LONG_STRING]; | ||
671 | char buf2[LONG_STRING]; | ||
672 | char *fp_fmt[] = { | ||
673 | "%-1.5f", | ||
674 | "%1.5f", | ||
675 | "%123.9f", | ||
676 | "%10.5f", | ||
677 | "% 10.5f", | ||
678 | "%+22.9f", | ||
679 | "%+4.9f", | ||
680 | "%01.3f", | ||
681 | "%4f", | ||
682 | "%3.1f", | ||
683 | "%3.2f", | ||
684 | NULL | ||
685 | }; | ||
686 | double fp_nums[] = { | ||
687 | -1.5, | ||
688 | 134.21, | ||
689 | 91340.2, | ||
690 | 341.1234, | ||
691 | 0203.9, | ||
692 | 0.96, | ||
693 | 0.996, | ||
694 | 0.9996, | ||
695 | 1.996, | ||
696 | 4.136, | ||
697 | 0 | ||
698 | }; | ||
699 | char *int_fmt[] = { | ||
700 | "%-1.5d", | ||
701 | "%1.5d", | ||
702 | "%123.9d", | ||
703 | "%5.5d", | ||
704 | "%10.5d", | ||
705 | "% 10.5d", | ||
706 | "%+22.33d", | ||
707 | "%01.3d", | ||
708 | "%4d", | ||
709 | "%lld", | ||
710 | "%qd", | ||
711 | NULL | ||
712 | }; | ||
713 | long long int_nums[] = { -1, 134, 91340, 341, 0203, 0, 9999999 }; | ||
714 | int x, y; | ||
715 | int fail = 0; | ||
716 | int num = 0; | ||
717 | |||
718 | printf("Testing snprintf format codes against system sprintf...\n"); | ||
719 | |||
720 | for (x = 0; fp_fmt[x] != NULL ; x++) { | ||
721 | for (y = 0; fp_nums[y] != 0 ; y++) { | ||
722 | snprintf(buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]); | ||
723 | sprintf (buf2, fp_fmt[x], fp_nums[y]); | ||
724 | if (strcmp (buf1, buf2)) { | ||
725 | printf("snprintf doesn't match Format: %s\n\t" | ||
726 | "snprintf = %s\n\tsprintf = %s\n", | ||
727 | fp_fmt[x], buf1, buf2); | ||
728 | fail++; | ||
729 | } | ||
730 | num++; | ||
731 | } | ||
732 | } | ||
733 | for (x = 0; int_fmt[x] != NULL ; x++) { | ||
734 | for (y = 0; int_nums[y] != 0 ; y++) { | ||
735 | snprintf(buf1, sizeof (buf1), int_fmt[x], int_nums[y]); | ||
736 | sprintf(buf2, int_fmt[x], int_nums[y]); | ||
737 | if (strcmp (buf1, buf2)) { | ||
738 | printf("snprintf doesn't match Format: %s\n\t" | ||
739 | "snprintf = %s\n\tsprintf = %s\n", | ||
740 | int_fmt[x], buf1, buf2); | ||
741 | fail++; | ||
742 | } | ||
743 | num++; | ||
744 | } | ||
745 | } | ||
746 | printf("%d tests failed out of %d.\n", fail, num); | ||
747 | return(0); | ||
748 | } | ||
749 | #endif /* SNPRINTF_TEST */ | ||
750 | |||
751 | #endif /* !HAVE_SNPRINTF */ | 652 | #endif /* !HAVE_SNPRINTF */ |
diff --git a/openbsd-compat/bsd-snprintf.h b/openbsd-compat/bsd-snprintf.h deleted file mode 100644 index 002b764e3..000000000 --- a/openbsd-compat/bsd-snprintf.h +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | /* $Id: bsd-snprintf.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_SNPRINTF_H | ||
4 | #define _BSD_SNPRINTF_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #include <sys/types.h> /* For size_t */ | ||
9 | |||
10 | #ifndef HAVE_SNPRINTF | ||
11 | int snprintf(char *str, size_t count, const char *fmt, ...); | ||
12 | #endif /* !HAVE_SNPRINTF */ | ||
13 | |||
14 | #ifndef HAVE_VSNPRINTF | ||
15 | int vsnprintf(char *str, size_t count, const char *fmt, va_list args); | ||
16 | #endif /* !HAVE_SNPRINTF */ | ||
17 | |||
18 | |||
19 | #endif /* _BSD_SNPRINTF_H */ | ||
diff --git a/openbsd-compat/bsd-waitpid.c b/openbsd-compat/bsd-waitpid.c index 47b4446dc..93c9ec35e 100644 --- a/openbsd-compat/bsd-waitpid.c +++ b/openbsd-compat/bsd-waitpid.c | |||
@@ -1,4 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Ben Lindstrom. All rights reserved. | ||
3 | * | ||
2 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
3 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
4 | * are met: | 6 | * are met: |
@@ -22,7 +24,7 @@ | |||
22 | 24 | ||
23 | #include "includes.h" | 25 | #include "includes.h" |
24 | 26 | ||
25 | RCSID("$Id: bsd-waitpid.c,v 1.3 2001/03/26 05:35:34 mouring Exp $"); | 27 | RCSID("$Id: bsd-waitpid.c,v 1.5 2003/06/01 03:23:57 mouring Exp $"); |
26 | 28 | ||
27 | #ifndef HAVE_WAITPID | 29 | #ifndef HAVE_WAITPID |
28 | #include <errno.h> | 30 | #include <errno.h> |
@@ -38,15 +40,16 @@ waitpid(int pid, int *stat_loc, int options) | |||
38 | if (pid <= 0) { | 40 | if (pid <= 0) { |
39 | if (pid != -1) { | 41 | if (pid != -1) { |
40 | errno = EINVAL; | 42 | errno = EINVAL; |
41 | return -1; | 43 | return (-1); |
42 | } | 44 | } |
43 | pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */ | 45 | /* wait4() wants pid=0 for indiscriminate wait. */ |
46 | pid = 0; | ||
44 | } | 47 | } |
45 | wait_pid = wait4(pid, &statusp, options, NULL); | 48 | wait_pid = wait4(pid, &statusp, options, NULL); |
46 | if (stat_loc) | 49 | if (stat_loc) |
47 | *stat_loc = (int) statusp.w_status; | 50 | *stat_loc = (int) statusp.w_status; |
48 | 51 | ||
49 | return wait_pid; | 52 | return (wait_pid); |
50 | } | 53 | } |
51 | 54 | ||
52 | #endif /* !HAVE_WAITPID */ | 55 | #endif /* !HAVE_WAITPID */ |
diff --git a/openbsd-compat/bsd-waitpid.h b/openbsd-compat/bsd-waitpid.h index e24edd791..2d853db61 100644 --- a/openbsd-compat/bsd-waitpid.h +++ b/openbsd-compat/bsd-waitpid.h | |||
@@ -1,4 +1,8 @@ | |||
1 | /* $Id: bsd-waitpid.h,v 1.5 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
1 | /* | 3 | /* |
4 | * Copyright (c) 2000 Ben Lindstrom. All rights reserved. | ||
5 | * | ||
2 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
3 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions |
4 | * are met: | 8 | * are met: |
@@ -21,8 +25,6 @@ | |||
21 | * | 25 | * |
22 | */ | 26 | */ |
23 | 27 | ||
24 | /* $Id: bsd-waitpid.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
25 | |||
26 | #ifndef _BSD_WAITPID_H | 28 | #ifndef _BSD_WAITPID_H |
27 | #define _BSD_WAITPID_H | 29 | #define _BSD_WAITPID_H |
28 | 30 | ||
@@ -43,7 +45,7 @@ | |||
43 | #define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) | 45 | #define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) |
44 | 46 | ||
45 | /* Prototype */ | 47 | /* Prototype */ |
46 | pid_t waitpid(int pid, int *stat_loc, int options); | 48 | pid_t waitpid(int, int *, int); |
47 | 49 | ||
48 | #endif /* !HAVE_WAITPID */ | 50 | #endif /* !HAVE_WAITPID */ |
49 | #endif /* _BSD_WAITPID_H */ | 51 | #endif /* _BSD_WAITPID_H */ |
diff --git a/openbsd-compat/daemon.c b/openbsd-compat/daemon.c index 7d23b2467..6dd45f6a7 100644 --- a/openbsd-compat/daemon.c +++ b/openbsd-compat/daemon.c | |||
@@ -10,11 +10,7 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
14 | * must display the following acknowledgement: | ||
15 | * This product includes software developed by the University of | ||
16 | * California, Berkeley and its contributors. | ||
17 | * 4. Neither the name of the University nor the names of its contributors | ||
18 | * 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 |
19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
20 | * | 16 | * |
@@ -36,12 +32,11 @@ | |||
36 | #ifndef HAVE_DAEMON | 32 | #ifndef HAVE_DAEMON |
37 | 33 | ||
38 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
39 | static char rcsid[] = "$OpenBSD: daemon.c,v 1.2 1996/08/19 08:22:13 tholo Exp $"; | 35 | static char rcsid[] = "$OpenBSD: daemon.c,v 1.5 2003/07/15 17:32:41 deraadt Exp $"; |
40 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
41 | 37 | ||
42 | int | 38 | int |
43 | daemon(nochdir, noclose) | 39 | daemon(int nochdir, int noclose) |
44 | int nochdir, noclose; | ||
45 | { | 40 | { |
46 | int fd; | 41 | int fd; |
47 | 42 | ||
diff --git a/openbsd-compat/daemon.h b/openbsd-compat/daemon.h deleted file mode 100644 index 95a077359..000000000 --- a/openbsd-compat/daemon.h +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | /* $Id: daemon.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_DAEMON_H | ||
4 | #define _BSD_DAEMON_H | ||
5 | |||
6 | #include "config.h" | ||
7 | #ifndef HAVE_DAEMON | ||
8 | int daemon(int nochdir, int noclose); | ||
9 | #endif /* !HAVE_DAEMON */ | ||
10 | |||
11 | #endif /* _BSD_DAEMON_H */ | ||
diff --git a/openbsd-compat/dirname.c b/openbsd-compat/dirname.c index 35c7d8ec7..1ab7516d8 100644 --- a/openbsd-compat/dirname.c +++ b/openbsd-compat/dirname.c | |||
@@ -1,46 +1,34 @@ | |||
1 | /* $OpenBSD: dirname.c,v 1.7 2002/05/24 21:22:37 deraadt Exp $ */ | 1 | /* $OpenBSD: dirname.c,v 1.10 2003/06/17 21:56:23 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> |
5 | * All rights reserved. | ||
6 | * | 5 | * |
7 | * Redistribution and use in source and binary forms, with or without | 6 | * Permission to use, copy, modify, and distribute this software for any |
8 | * modification, are permitted provided that the following conditions | 7 | * purpose with or without fee is hereby granted, provided that the above |
9 | * are met: | 8 | * copyright notice and this permission notice appear in all copies. |
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of the author may not be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | 9 | * |
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | 17 | */ |
29 | 18 | ||
30 | #include "includes.h" | 19 | #include "includes.h" |
31 | #ifndef HAVE_DIRNAME | 20 | #ifndef HAVE_DIRNAME |
32 | 21 | ||
33 | #if defined(LIBC_SCCS) && !defined(lint) | 22 | #ifndef lint |
34 | static char rcsid[] = "$OpenBSD: dirname.c,v 1.7 2002/05/24 21:22:37 deraadt Exp $"; | 23 | static char rcsid[] = "$OpenBSD: dirname.c,v 1.10 2003/06/17 21:56:23 millert Exp $"; |
35 | #endif /* LIBC_SCCS and not lint */ | 24 | #endif /* not lint */ |
36 | 25 | ||
37 | #include <errno.h> | 26 | #include <errno.h> |
38 | #include <string.h> | 27 | #include <string.h> |
39 | #include <sys/param.h> | 28 | #include <sys/param.h> |
40 | 29 | ||
41 | char * | 30 | char * |
42 | dirname(path) | 31 | dirname(const char *path) |
43 | const char *path; | ||
44 | { | 32 | { |
45 | static char bname[MAXPATHLEN]; | 33 | static char bname[MAXPATHLEN]; |
46 | register const char *endp; | 34 | register const char *endp; |
diff --git a/openbsd-compat/dirname.h b/openbsd-compat/dirname.h deleted file mode 100644 index 1d61dd06c..000000000 --- a/openbsd-compat/dirname.h +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | #ifndef HAVE_DIRNAME | ||
2 | |||
3 | char *dirname(const char *path); | ||
4 | |||
5 | #endif | ||
diff --git a/openbsd-compat/fake-gai-errnos.h b/openbsd-compat/fake-gai-errnos.h deleted file mode 100644 index 5edc31b59..000000000 --- a/openbsd-compat/fake-gai-errnos.h +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | /* | ||
2 | * fake library for ssh | ||
3 | * | ||
4 | * This file is included in getaddrinfo.c and getnameinfo.c. | ||
5 | * See getaddrinfo.c and getnameinfo.c. | ||
6 | */ | ||
7 | |||
8 | /* $Id: fake-gai-errnos.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
9 | |||
10 | /* for old netdb.h */ | ||
11 | #ifndef EAI_NODATA | ||
12 | #define EAI_NODATA 1 | ||
13 | #define EAI_MEMORY 2 | ||
14 | #endif | ||
diff --git a/openbsd-compat/fake-getaddrinfo.c b/openbsd-compat/fake-getaddrinfo.c deleted file mode 100644 index e63bda970..000000000 --- a/openbsd-compat/fake-getaddrinfo.c +++ /dev/null | |||
@@ -1,135 +0,0 @@ | |||
1 | /* | ||
2 | * fake library for ssh | ||
3 | * | ||
4 | * This file includes getaddrinfo(), freeaddrinfo() and gai_strerror(). | ||
5 | * These funtions are defined in rfc2133. | ||
6 | * | ||
7 | * But these functions are not implemented correctly. The minimum subset | ||
8 | * is implemented for ssh use only. For exapmle, this routine assumes | ||
9 | * that ai_family is AF_INET. Don't use it for another purpose. | ||
10 | */ | ||
11 | |||
12 | #include "includes.h" | ||
13 | #include "ssh.h" | ||
14 | |||
15 | RCSID("$Id: fake-getaddrinfo.c,v 1.5 2003/03/24 02:35:59 djm Exp $"); | ||
16 | |||
17 | #ifndef HAVE_GAI_STRERROR | ||
18 | char *gai_strerror(int ecode) | ||
19 | { | ||
20 | switch (ecode) { | ||
21 | case EAI_NODATA: | ||
22 | return "no address associated with hostname."; | ||
23 | case EAI_MEMORY: | ||
24 | return "memory allocation failure."; | ||
25 | default: | ||
26 | return "unknown error."; | ||
27 | } | ||
28 | } | ||
29 | #endif /* !HAVE_GAI_STRERROR */ | ||
30 | |||
31 | #ifndef HAVE_FREEADDRINFO | ||
32 | void freeaddrinfo(struct addrinfo *ai) | ||
33 | { | ||
34 | struct addrinfo *next; | ||
35 | |||
36 | do { | ||
37 | next = ai->ai_next; | ||
38 | free(ai); | ||
39 | } while (NULL != (ai = next)); | ||
40 | } | ||
41 | #endif /* !HAVE_FREEADDRINFO */ | ||
42 | |||
43 | #ifndef HAVE_GETADDRINFO | ||
44 | static struct addrinfo *malloc_ai(int port, u_long addr) | ||
45 | { | ||
46 | struct addrinfo *ai; | ||
47 | |||
48 | ai = malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); | ||
49 | if (ai == NULL) | ||
50 | return(NULL); | ||
51 | |||
52 | memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); | ||
53 | |||
54 | ai->ai_addr = (struct sockaddr *)(ai + 1); | ||
55 | /* XXX -- ssh doesn't use sa_len */ | ||
56 | ai->ai_addrlen = sizeof(struct sockaddr_in); | ||
57 | ai->ai_addr->sa_family = ai->ai_family = AF_INET; | ||
58 | |||
59 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; | ||
60 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; | ||
61 | |||
62 | return(ai); | ||
63 | } | ||
64 | |||
65 | int getaddrinfo(const char *hostname, const char *servname, | ||
66 | const struct addrinfo *hints, struct addrinfo **res) | ||
67 | { | ||
68 | struct addrinfo *cur, *prev = NULL; | ||
69 | struct hostent *hp; | ||
70 | struct servent *sp; | ||
71 | struct in_addr in; | ||
72 | int i; | ||
73 | long int port; | ||
74 | u_long addr; | ||
75 | |||
76 | port = 0; | ||
77 | if (servname != NULL) { | ||
78 | char *cp; | ||
79 | |||
80 | port = strtol(servname, &cp, 10); | ||
81 | if (port > 0 && port <= 65535 && *cp == '\0') | ||
82 | port = htons(port); | ||
83 | else if ((sp = getservbyname(servname, NULL)) != NULL) | ||
84 | port = sp->s_port; | ||
85 | else | ||
86 | port = 0; | ||
87 | } | ||
88 | |||
89 | if (hints && hints->ai_flags & AI_PASSIVE) { | ||
90 | addr = htonl(0x00000000); | ||
91 | if (hostname && inet_aton(hostname, &in) != 0) | ||
92 | addr = in.s_addr; | ||
93 | if (NULL != (*res = malloc_ai(port, addr))) | ||
94 | return 0; | ||
95 | else | ||
96 | return EAI_MEMORY; | ||
97 | } | ||
98 | |||
99 | if (!hostname) { | ||
100 | if (NULL != (*res = malloc_ai(port, htonl(0x7f000001)))) | ||
101 | return 0; | ||
102 | else | ||
103 | return EAI_MEMORY; | ||
104 | } | ||
105 | |||
106 | if (inet_aton(hostname, &in)) { | ||
107 | if (NULL != (*res = malloc_ai(port, in.s_addr))) | ||
108 | return 0; | ||
109 | else | ||
110 | return EAI_MEMORY; | ||
111 | } | ||
112 | |||
113 | hp = gethostbyname(hostname); | ||
114 | if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { | ||
115 | for (i = 0; hp->h_addr_list[i]; i++) { | ||
116 | cur = malloc_ai(port, ((struct in_addr *)hp->h_addr_list[i])->s_addr); | ||
117 | if (cur == NULL) { | ||
118 | if (*res) | ||
119 | freeaddrinfo(*res); | ||
120 | return EAI_MEMORY; | ||
121 | } | ||
122 | |||
123 | if (prev) | ||
124 | prev->ai_next = cur; | ||
125 | else | ||
126 | *res = cur; | ||
127 | |||
128 | prev = cur; | ||
129 | } | ||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | return EAI_NODATA; | ||
134 | } | ||
135 | #endif /* !HAVE_GETADDRINFO */ | ||
diff --git a/openbsd-compat/fake-getaddrinfo.h b/openbsd-compat/fake-getaddrinfo.h deleted file mode 100644 index 6943378e9..000000000 --- a/openbsd-compat/fake-getaddrinfo.h +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* $Id: fake-getaddrinfo.h,v 1.4 2003/02/24 01:35:09 djm Exp $ */ | ||
2 | |||
3 | #ifndef _FAKE_GETADDRINFO_H | ||
4 | #define _FAKE_GETADDRINFO_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #include "fake-gai-errnos.h" | ||
9 | |||
10 | #ifndef AI_PASSIVE | ||
11 | # define AI_PASSIVE 1 | ||
12 | # define AI_CANONNAME 2 | ||
13 | #endif | ||
14 | |||
15 | #ifndef NI_NUMERICHOST | ||
16 | # define NI_NUMERICHOST 2 | ||
17 | # define NI_NAMEREQD 4 | ||
18 | # define NI_NUMERICSERV 8 | ||
19 | #endif | ||
20 | |||
21 | #ifndef HAVE_STRUCT_ADDRINFO | ||
22 | struct addrinfo { | ||
23 | int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ | ||
24 | int ai_family; /* PF_xxx */ | ||
25 | int ai_socktype; /* SOCK_xxx */ | ||
26 | int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ | ||
27 | size_t ai_addrlen; /* length of ai_addr */ | ||
28 | char *ai_canonname; /* canonical name for hostname */ | ||
29 | struct sockaddr *ai_addr; /* binary address */ | ||
30 | struct addrinfo *ai_next; /* next structure in linked list */ | ||
31 | }; | ||
32 | #endif /* !HAVE_STRUCT_ADDRINFO */ | ||
33 | |||
34 | #ifndef HAVE_GETADDRINFO | ||
35 | int getaddrinfo(const char *hostname, const char *servname, | ||
36 | const struct addrinfo *hints, struct addrinfo **res); | ||
37 | #endif /* !HAVE_GETADDRINFO */ | ||
38 | |||
39 | #ifndef HAVE_GAI_STRERROR | ||
40 | char *gai_strerror(int ecode); | ||
41 | #endif /* !HAVE_GAI_STRERROR */ | ||
42 | |||
43 | #ifndef HAVE_FREEADDRINFO | ||
44 | void freeaddrinfo(struct addrinfo *ai); | ||
45 | #endif /* !HAVE_FREEADDRINFO */ | ||
46 | |||
47 | #endif /* _FAKE_GETADDRINFO_H */ | ||
diff --git a/openbsd-compat/fake-getnameinfo.c b/openbsd-compat/fake-getnameinfo.c deleted file mode 100644 index e255ed333..000000000 --- a/openbsd-compat/fake-getnameinfo.c +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /* | ||
2 | * fake library for ssh | ||
3 | * | ||
4 | * This file includes getnameinfo(). | ||
5 | * These funtions are defined in rfc2133. | ||
6 | * | ||
7 | * But these functions are not implemented correctly. The minimum subset | ||
8 | * is implemented for ssh use only. For exapmle, this routine assumes | ||
9 | * that ai_family is AF_INET. Don't use it for another purpose. | ||
10 | */ | ||
11 | |||
12 | #include "includes.h" | ||
13 | #include "ssh.h" | ||
14 | |||
15 | RCSID("$Id: fake-getnameinfo.c,v 1.2 2001/02/09 01:55:36 djm Exp $"); | ||
16 | |||
17 | #ifndef HAVE_GETNAMEINFO | ||
18 | int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | ||
19 | size_t hostlen, char *serv, size_t servlen, int flags) | ||
20 | { | ||
21 | struct sockaddr_in *sin = (struct sockaddr_in *)sa; | ||
22 | struct hostent *hp; | ||
23 | char tmpserv[16]; | ||
24 | |||
25 | if (serv) { | ||
26 | snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port)); | ||
27 | if (strlen(tmpserv) >= servlen) | ||
28 | return EAI_MEMORY; | ||
29 | else | ||
30 | strcpy(serv, tmpserv); | ||
31 | } | ||
32 | |||
33 | if (host) { | ||
34 | if (flags & NI_NUMERICHOST) { | ||
35 | if (strlen(inet_ntoa(sin->sin_addr)) >= hostlen) | ||
36 | return EAI_MEMORY; | ||
37 | |||
38 | strcpy(host, inet_ntoa(sin->sin_addr)); | ||
39 | return 0; | ||
40 | } else { | ||
41 | hp = gethostbyaddr((char *)&sin->sin_addr, | ||
42 | sizeof(struct in_addr), AF_INET); | ||
43 | if (hp == NULL) | ||
44 | return EAI_NODATA; | ||
45 | |||
46 | if (strlen(hp->h_name) >= hostlen) | ||
47 | return EAI_MEMORY; | ||
48 | |||
49 | strcpy(host, hp->h_name); | ||
50 | return 0; | ||
51 | } | ||
52 | } | ||
53 | return 0; | ||
54 | } | ||
55 | #endif /* !HAVE_GETNAMEINFO */ | ||
diff --git a/openbsd-compat/fake-getnameinfo.h b/openbsd-compat/fake-getnameinfo.h deleted file mode 100644 index c9b7908aa..000000000 --- a/openbsd-compat/fake-getnameinfo.h +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | /* $Id: fake-getnameinfo.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _FAKE_GETNAMEINFO_H | ||
4 | #define _FAKE_GETNAMEINFO_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_GETNAMEINFO | ||
9 | int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | ||
10 | size_t hostlen, char *serv, size_t servlen, int flags); | ||
11 | #endif /* !HAVE_GETNAMEINFO */ | ||
12 | |||
13 | #ifndef NI_MAXSERV | ||
14 | # define NI_MAXSERV 32 | ||
15 | #endif /* !NI_MAXSERV */ | ||
16 | #ifndef NI_MAXHOST | ||
17 | # define NI_MAXHOST 1025 | ||
18 | #endif /* !NI_MAXHOST */ | ||
19 | |||
20 | #endif /* _FAKE_GETNAMEINFO_H */ | ||
diff --git a/openbsd-compat/fake-rfc2553.c b/openbsd-compat/fake-rfc2553.c new file mode 100644 index 000000000..f44924836 --- /dev/null +++ b/openbsd-compat/fake-rfc2553.c | |||
@@ -0,0 +1,220 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000-2003 Damien Miller. All rights reserved. | ||
3 | * Copyright (C) 1999 WIDE Project. All rights reserved. | ||
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 | * 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 | ||
15 | * without specific prior written permission. | ||
16 | * | ||
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 | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | /* | ||
31 | * Pseudo-implementation of RFC2553 name / address resolution functions | ||
32 | * | ||
33 | * But these functions are not implemented correctly. The minimum subset | ||
34 | * is implemented for ssh use only. For example, this routine assumes | ||
35 | * that ai_family is AF_INET. Don't use it for another purpose. | ||
36 | */ | ||
37 | |||
38 | #include "includes.h" | ||
39 | |||
40 | RCSID("$Id: fake-rfc2553.c,v 1.4 2003/06/13 22:43:23 djm Exp $"); | ||
41 | |||
42 | #ifndef HAVE_GETNAMEINFO | ||
43 | int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, | ||
44 | size_t hostlen, char *serv, size_t servlen, int flags) | ||
45 | { | ||
46 | struct sockaddr_in *sin = (struct sockaddr_in *)sa; | ||
47 | struct hostent *hp; | ||
48 | char tmpserv[16]; | ||
49 | |||
50 | if (serv != NULL) { | ||
51 | snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port)); | ||
52 | if (strlcpy(serv, tmpserv, servlen) >= servlen) | ||
53 | return (EAI_MEMORY); | ||
54 | } | ||
55 | |||
56 | if (host != NULL) { | ||
57 | if (flags & NI_NUMERICHOST) { | ||
58 | if (strlcpy(host, inet_ntoa(sin->sin_addr), | ||
59 | hostlen) >= hostlen) | ||
60 | return (EAI_MEMORY); | ||
61 | else | ||
62 | return (0); | ||
63 | } else { | ||
64 | hp = gethostbyaddr((char *)&sin->sin_addr, | ||
65 | sizeof(struct in_addr), AF_INET); | ||
66 | if (hp == NULL) | ||
67 | return (EAI_NODATA); | ||
68 | |||
69 | if (strlcpy(host, hp->h_name, hostlen) >= hostlen) | ||
70 | return (EAI_MEMORY); | ||
71 | else | ||
72 | return (0); | ||
73 | } | ||
74 | } | ||
75 | return (0); | ||
76 | } | ||
77 | #endif /* !HAVE_GETNAMEINFO */ | ||
78 | |||
79 | #ifndef HAVE_GAI_STRERROR | ||
80 | char * | ||
81 | gai_strerror(int err) | ||
82 | { | ||
83 | switch (err) { | ||
84 | case EAI_NODATA: | ||
85 | return ("no address associated with name"); | ||
86 | case EAI_MEMORY: | ||
87 | return ("memory allocation failure."); | ||
88 | case EAI_NONAME: | ||
89 | return ("nodename nor servname provided, or not known"); | ||
90 | default: | ||
91 | return ("unknown/invalid error."); | ||
92 | } | ||
93 | } | ||
94 | #endif /* !HAVE_GAI_STRERROR */ | ||
95 | |||
96 | #ifndef HAVE_FREEADDRINFO | ||
97 | void | ||
98 | freeaddrinfo(struct addrinfo *ai) | ||
99 | { | ||
100 | struct addrinfo *next; | ||
101 | |||
102 | for(; ai != NULL;) { | ||
103 | next = ai->ai_next; | ||
104 | free(ai); | ||
105 | ai = next; | ||
106 | } | ||
107 | } | ||
108 | #endif /* !HAVE_FREEADDRINFO */ | ||
109 | |||
110 | #ifndef HAVE_GETADDRINFO | ||
111 | static struct | ||
112 | addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) | ||
113 | { | ||
114 | struct addrinfo *ai; | ||
115 | |||
116 | ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in)); | ||
117 | if (ai == NULL) | ||
118 | return (NULL); | ||
119 | |||
120 | memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); | ||
121 | |||
122 | ai->ai_addr = (struct sockaddr *)(ai + 1); | ||
123 | /* XXX -- ssh doesn't use sa_len */ | ||
124 | ai->ai_addrlen = sizeof(struct sockaddr_in); | ||
125 | ai->ai_addr->sa_family = ai->ai_family = AF_INET; | ||
126 | |||
127 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; | ||
128 | ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; | ||
129 | |||
130 | /* XXX: the following is not generally correct, but does what we want */ | ||
131 | if (hints->ai_socktype) | ||
132 | ai->ai_socktype = hints->ai_socktype; | ||
133 | else | ||
134 | ai->ai_socktype = SOCK_STREAM; | ||
135 | |||
136 | if (hints->ai_protocol) | ||
137 | ai->ai_protocol = hints->ai_protocol; | ||
138 | |||
139 | return (ai); | ||
140 | } | ||
141 | |||
142 | int | ||
143 | getaddrinfo(const char *hostname, const char *servname, | ||
144 | const struct addrinfo *hints, struct addrinfo **res) | ||
145 | { | ||
146 | struct hostent *hp; | ||
147 | struct servent *sp; | ||
148 | struct in_addr in; | ||
149 | int i; | ||
150 | long int port; | ||
151 | u_long addr; | ||
152 | |||
153 | port = 0; | ||
154 | if (servname != NULL) { | ||
155 | char *cp; | ||
156 | |||
157 | port = strtol(servname, &cp, 10); | ||
158 | if (port > 0 && port <= 65535 && *cp == '\0') | ||
159 | port = htons(port); | ||
160 | else if ((sp = getservbyname(servname, NULL)) != NULL) | ||
161 | port = sp->s_port; | ||
162 | else | ||
163 | port = 0; | ||
164 | } | ||
165 | |||
166 | if (hints && hints->ai_flags & AI_PASSIVE) { | ||
167 | addr = htonl(0x00000000); | ||
168 | if (hostname && inet_aton(hostname, &in) != 0) | ||
169 | addr = in.s_addr; | ||
170 | *res = malloc_ai(port, addr, hints); | ||
171 | if (*res == NULL) | ||
172 | return (EAI_MEMORY); | ||
173 | return (0); | ||
174 | } | ||
175 | |||
176 | if (!hostname) { | ||
177 | *res = malloc_ai(port, htonl(0x7f000001), hints); | ||
178 | if (*res == NULL) | ||
179 | return (EAI_MEMORY); | ||
180 | return (0); | ||
181 | } | ||
182 | |||
183 | if (inet_aton(hostname, &in)) { | ||
184 | *res = malloc_ai(port, in.s_addr, hints); | ||
185 | if (*res == NULL) | ||
186 | return (EAI_MEMORY); | ||
187 | return (0); | ||
188 | } | ||
189 | |||
190 | /* Don't try DNS if AI_NUMERICHOST is set */ | ||
191 | if (hints && hints->ai_flags & AI_NUMERICHOST) | ||
192 | return (EAI_NONAME); | ||
193 | |||
194 | hp = gethostbyname(hostname); | ||
195 | if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { | ||
196 | struct addrinfo *cur, *prev; | ||
197 | |||
198 | cur = prev = *res = NULL; | ||
199 | for (i = 0; hp->h_addr_list[i]; i++) { | ||
200 | struct in_addr *in = (struct in_addr *)hp->h_addr_list[i]; | ||
201 | |||
202 | cur = malloc_ai(port, in->s_addr, hints); | ||
203 | if (cur == NULL) { | ||
204 | if (*res != NULL) | ||
205 | freeaddrinfo(*res); | ||
206 | return (EAI_MEMORY); | ||
207 | } | ||
208 | if (prev) | ||
209 | prev->ai_next = cur; | ||
210 | else | ||
211 | *res = cur; | ||
212 | |||
213 | prev = cur; | ||
214 | } | ||
215 | return (0); | ||
216 | } | ||
217 | |||
218 | return (EAI_NODATA); | ||
219 | } | ||
220 | #endif /* !HAVE_GETADDRINFO */ | ||
diff --git a/openbsd-compat/fake-rfc2553.h b/openbsd-compat/fake-rfc2553.h new file mode 100644 index 000000000..b70b928f8 --- /dev/null +++ b/openbsd-compat/fake-rfc2553.h | |||
@@ -0,0 +1,154 @@ | |||
1 | /* $Id: fake-rfc2553.h,v 1.6 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (C) 2000-2003 Damien Miller. All rights reserved. | ||
5 | * Copyright (C) 1999 WIDE Project. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 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 | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | /* | ||
33 | * Pseudo-implementation of RFC2553 name / address resolution functions | ||
34 | * | ||
35 | * But these functions are not implemented correctly. The minimum subset | ||
36 | * is implemented for ssh use only. For example, this routine assumes | ||
37 | * that ai_family is AF_INET. Don't use it for another purpose. | ||
38 | */ | ||
39 | |||
40 | #ifndef _FAKE_RFC2553_H | ||
41 | #define _FAKE_RFC2553_H | ||
42 | |||
43 | #include "includes.h" | ||
44 | #include "sys/types.h" | ||
45 | |||
46 | /* | ||
47 | * First, socket and INET6 related definitions | ||
48 | */ | ||
49 | #ifndef HAVE_STRUCT_SOCKADDR_STORAGE | ||
50 | # define _SS_MAXSIZE 128 /* Implementation specific max size */ | ||
51 | # define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr)) | ||
52 | struct sockaddr_storage { | ||
53 | struct sockaddr ss_sa; | ||
54 | char __ss_pad2[_SS_PADSIZE]; | ||
55 | }; | ||
56 | # define ss_family ss_sa.sa_family | ||
57 | #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ | ||
58 | |||
59 | #ifndef IN6_IS_ADDR_LOOPBACK | ||
60 | # define IN6_IS_ADDR_LOOPBACK(a) \ | ||
61 | (((u_int32_t *)(a))[0] == 0 && ((u_int32_t *)(a))[1] == 0 && \ | ||
62 | ((u_int32_t *)(a))[2] == 0 && ((u_int32_t *)(a))[3] == htonl(1)) | ||
63 | #endif /* !IN6_IS_ADDR_LOOPBACK */ | ||
64 | |||
65 | #ifndef HAVE_STRUCT_IN6_ADDR | ||
66 | struct in6_addr { | ||
67 | u_int8_t s6_addr[16]; | ||
68 | }; | ||
69 | #endif /* !HAVE_STRUCT_IN6_ADDR */ | ||
70 | |||
71 | #ifndef HAVE_STRUCT_SOCKADDR_IN6 | ||
72 | struct sockaddr_in6 { | ||
73 | unsigned short sin6_family; | ||
74 | u_int16_t sin6_port; | ||
75 | u_int32_t sin6_flowinfo; | ||
76 | struct in6_addr sin6_addr; | ||
77 | }; | ||
78 | #endif /* !HAVE_STRUCT_SOCKADDR_IN6 */ | ||
79 | |||
80 | #ifndef AF_INET6 | ||
81 | /* Define it to something that should never appear */ | ||
82 | #define AF_INET6 AF_MAX | ||
83 | #endif | ||
84 | |||
85 | /* | ||
86 | * Next, RFC2553 name / address resolution API | ||
87 | */ | ||
88 | |||
89 | #ifndef NI_NUMERICHOST | ||
90 | # define NI_NUMERICHOST (1) | ||
91 | #endif | ||
92 | #ifndef NI_NAMEREQD | ||
93 | # define NI_NAMEREQD (1<<1) | ||
94 | #endif | ||
95 | #ifndef NI_NUMERICSERV | ||
96 | # define NI_NUMERICSERV (1<<2) | ||
97 | #endif | ||
98 | |||
99 | #ifndef AI_PASSIVE | ||
100 | # define AI_PASSIVE (1) | ||
101 | #endif | ||
102 | #ifndef AI_CANONNAME | ||
103 | # define AI_CANONNAME (1<<1) | ||
104 | #endif | ||
105 | #ifndef AI_NUMERICHOST | ||
106 | # define AI_NUMERICHOST (1<<2) | ||
107 | #endif | ||
108 | |||
109 | #ifndef NI_MAXSERV | ||
110 | # define NI_MAXSERV 32 | ||
111 | #endif /* !NI_MAXSERV */ | ||
112 | #ifndef NI_MAXHOST | ||
113 | # define NI_MAXHOST 1025 | ||
114 | #endif /* !NI_MAXHOST */ | ||
115 | |||
116 | #ifndef EAI_NODATA | ||
117 | # define EAI_NODATA 1 | ||
118 | # define EAI_MEMORY 2 | ||
119 | # define EAI_NONAME 3 | ||
120 | #endif | ||
121 | |||
122 | #ifndef HAVE_STRUCT_ADDRINFO | ||
123 | struct addrinfo { | ||
124 | int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ | ||
125 | int ai_family; /* PF_xxx */ | ||
126 | int ai_socktype; /* SOCK_xxx */ | ||
127 | int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ | ||
128 | size_t ai_addrlen; /* length of ai_addr */ | ||
129 | char *ai_canonname; /* canonical name for hostname */ | ||
130 | struct sockaddr *ai_addr; /* binary address */ | ||
131 | struct addrinfo *ai_next; /* next structure in linked list */ | ||
132 | }; | ||
133 | #endif /* !HAVE_STRUCT_ADDRINFO */ | ||
134 | |||
135 | #ifndef HAVE_GETADDRINFO | ||
136 | int getaddrinfo(const char *, const char *, | ||
137 | const struct addrinfo *, struct addrinfo **); | ||
138 | #endif /* !HAVE_GETADDRINFO */ | ||
139 | |||
140 | #ifndef HAVE_GAI_STRERROR | ||
141 | char *gai_strerror(int); | ||
142 | #endif /* !HAVE_GAI_STRERROR */ | ||
143 | |||
144 | #ifndef HAVE_FREEADDRINFO | ||
145 | void freeaddrinfo(struct addrinfo *); | ||
146 | #endif /* !HAVE_FREEADDRINFO */ | ||
147 | |||
148 | #ifndef HAVE_GETNAMEINFO | ||
149 | int getnameinfo(const struct sockaddr *, size_t, char *, size_t, | ||
150 | char *, size_t, int); | ||
151 | #endif /* !HAVE_GETNAMEINFO */ | ||
152 | |||
153 | #endif /* !_FAKE_RFC2553_H */ | ||
154 | |||
diff --git a/openbsd-compat/fake-socket.h b/openbsd-compat/fake-socket.h deleted file mode 100644 index f364797fa..000000000 --- a/openbsd-compat/fake-socket.h +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* $Id: fake-socket.h,v 1.3 2002/04/12 03:35:40 tim Exp $ */ | ||
2 | |||
3 | #ifndef _FAKE_SOCKET_H | ||
4 | #define _FAKE_SOCKET_H | ||
5 | |||
6 | #include "includes.h" | ||
7 | #include "sys/types.h" | ||
8 | |||
9 | #ifndef HAVE_STRUCT_SOCKADDR_STORAGE | ||
10 | # define _SS_MAXSIZE 128 /* Implementation specific max size */ | ||
11 | # define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr)) | ||
12 | |||
13 | struct sockaddr_storage { | ||
14 | struct sockaddr ss_sa; | ||
15 | char __ss_pad2[_SS_PADSIZE]; | ||
16 | }; | ||
17 | # define ss_family ss_sa.sa_family | ||
18 | #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ | ||
19 | |||
20 | #ifndef IN6_IS_ADDR_LOOPBACK | ||
21 | # define IN6_IS_ADDR_LOOPBACK(a) \ | ||
22 | (((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \ | ||
23 | ((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1)) | ||
24 | #endif /* !IN6_IS_ADDR_LOOPBACK */ | ||
25 | |||
26 | #ifndef HAVE_STRUCT_IN6_ADDR | ||
27 | struct in6_addr { | ||
28 | u_int8_t s6_addr[16]; | ||
29 | }; | ||
30 | #endif /* !HAVE_STRUCT_IN6_ADDR */ | ||
31 | |||
32 | #ifndef HAVE_STRUCT_SOCKADDR_IN6 | ||
33 | struct sockaddr_in6 { | ||
34 | unsigned short sin6_family; | ||
35 | u_int16_t sin6_port; | ||
36 | u_int32_t sin6_flowinfo; | ||
37 | struct in6_addr sin6_addr; | ||
38 | }; | ||
39 | #endif /* !HAVE_STRUCT_SOCKADDR_IN6 */ | ||
40 | |||
41 | #ifndef AF_INET6 | ||
42 | /* Define it to something that should never appear */ | ||
43 | #define AF_INET6 AF_MAX | ||
44 | #endif | ||
45 | |||
46 | #endif /* !_FAKE_SOCKET_H */ | ||
47 | |||
diff --git a/openbsd-compat/getcwd.c b/openbsd-compat/getcwd.c index f4b98e824..31d1cfe93 100644 --- a/openbsd-compat/getcwd.c +++ b/openbsd-compat/getcwd.c | |||
@@ -10,6 +10,9 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. Neither the name of the University nor the names of its contributors | ||
14 | * may be used to endorse or promote products derived from this software | ||
15 | * without specific prior written permission. | ||
13 | * | 16 | * |
14 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
@@ -29,7 +32,7 @@ | |||
29 | #if !defined(HAVE_GETCWD) | 32 | #if !defined(HAVE_GETCWD) |
30 | 33 | ||
31 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
32 | static char rcsid[] = "$OpenBSD: getcwd.c,v 1.7 2002/11/24 01:52:27 cloder Exp $"; | 35 | static char rcsid[] = "$OpenBSD: getcwd.c,v 1.9 2003/06/11 21:03:10 deraadt Exp $"; |
33 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
34 | 37 | ||
35 | #include <sys/param.h> | 38 | #include <sys/param.h> |
@@ -47,7 +50,7 @@ static char rcsid[] = "$OpenBSD: getcwd.c,v 1.7 2002/11/24 01:52:27 cloder Exp $ | |||
47 | (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) | 50 | (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) |
48 | 51 | ||
49 | char * | 52 | char * |
50 | getcwd(char *pt,size_t size) | 53 | getcwd(char *pt, size_t size) |
51 | { | 54 | { |
52 | register struct dirent *dp; | 55 | register struct dirent *dp; |
53 | register DIR *dir = NULL; | 56 | register DIR *dir = NULL; |
diff --git a/openbsd-compat/getcwd.h b/openbsd-compat/getcwd.h deleted file mode 100644 index 1137b3ed5..000000000 --- a/openbsd-compat/getcwd.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: getcwd.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_GETCWD_H | ||
4 | #define _BSD_GETCWD_H | ||
5 | #include "config.h" | ||
6 | |||
7 | #if !defined(HAVE_GETCWD) | ||
8 | |||
9 | char *getcwd(char *pt, size_t size); | ||
10 | |||
11 | #endif /* !defined(HAVE_GETCWD) */ | ||
12 | #endif /* _BSD_GETCWD_H */ | ||
diff --git a/openbsd-compat/getgrouplist.c b/openbsd-compat/getgrouplist.c index f7a27c339..085cda8c3 100644 --- a/openbsd-compat/getgrouplist.c +++ b/openbsd-compat/getgrouplist.c | |||
@@ -10,11 +10,7 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
14 | * must display the following acknowledgement: | ||
15 | * This product includes software developed by the University of | ||
16 | * California, Berkeley and its contributors. | ||
17 | * 4. Neither the name of the University nor the names of its contributors | ||
18 | * 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 |
19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
20 | * | 16 | * |
@@ -36,7 +32,7 @@ | |||
36 | #ifndef HAVE_GETGROUPLIST | 32 | #ifndef HAVE_GETGROUPLIST |
37 | 33 | ||
38 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
39 | static char rcsid[] = "$OpenBSD: getgrouplist.c,v 1.7 1997/08/19 19:13:27 deraadt Exp $"; | 35 | static char rcsid[] = "$OpenBSD: getgrouplist.c,v 1.9 2003/06/25 21:16:47 deraadt Exp $"; |
40 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
41 | 37 | ||
42 | /* | 38 | /* |
@@ -44,6 +40,7 @@ static char rcsid[] = "$OpenBSD: getgrouplist.c,v 1.7 1997/08/19 19:13:27 deraad | |||
44 | */ | 40 | */ |
45 | #include <sys/types.h> | 41 | #include <sys/types.h> |
46 | #include <string.h> | 42 | #include <string.h> |
43 | #include <unistd.h> | ||
47 | #include <grp.h> | 44 | #include <grp.h> |
48 | 45 | ||
49 | int | 46 | int |
diff --git a/openbsd-compat/getgrouplist.h b/openbsd-compat/getgrouplist.h deleted file mode 100644 index 27a9703f2..000000000 --- a/openbsd-compat/getgrouplist.h +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /* $Id: getgrouplist.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_GETGROUPLIST_H | ||
4 | #define _BSD_GETGROUPLIST_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_GETGROUPLIST | ||
9 | |||
10 | #include <grp.h> | ||
11 | |||
12 | int getgrouplist(const char *, gid_t, gid_t *, int *); | ||
13 | |||
14 | #endif | ||
15 | |||
16 | #endif | ||
diff --git a/openbsd-compat/getopt.c b/openbsd-compat/getopt.c index a3fe807ee..2136fbfcc 100644 --- a/openbsd-compat/getopt.c +++ b/openbsd-compat/getopt.c | |||
@@ -10,11 +10,7 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
14 | * must display the following acknowledgement: | ||
15 | * This product includes software developed by the University of | ||
16 | * California, Berkeley and its contributors. | ||
17 | * 4. Neither the name of the University nor the names of its contributors | ||
18 | * 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 |
19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
20 | * | 16 | * |
@@ -35,7 +31,7 @@ | |||
35 | #if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) | 31 | #if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) |
36 | 32 | ||
37 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | static char *rcsid = "$OpenBSD: getopt.c,v 1.4 2002/12/08 22:57:14 millert Exp $"; | 34 | static char *rcsid = "$OpenBSD: getopt.c,v 1.5 2003/06/02 20:18:37 millert Exp $"; |
39 | #endif /* LIBC_SCCS and not lint */ | 35 | #endif /* LIBC_SCCS and not lint */ |
40 | 36 | ||
41 | #include <stdio.h> | 37 | #include <stdio.h> |
diff --git a/openbsd-compat/getopt.h b/openbsd-compat/getopt.h deleted file mode 100644 index 9abdae8e9..000000000 --- a/openbsd-compat/getopt.h +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | /* $Id: getopt.h,v 1.4 2001/09/18 05:05:21 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSDGETOPT_H | ||
4 | #define _BSDGETOPT_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) | ||
9 | |||
10 | int BSDgetopt(int argc, char * const *argv, const char *opts); | ||
11 | |||
12 | #endif | ||
13 | |||
14 | #endif /* _BSDGETOPT_H */ | ||
diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c new file mode 100644 index 000000000..44fa2755b --- /dev/null +++ b/openbsd-compat/getrrsetbyname.c | |||
@@ -0,0 +1,578 @@ | |||
1 | /* $OpenBSD: getrrsetbyname.c,v 1.7 2003/03/07 07:34:14 itojun Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2001 Jakob Schlyter. All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | * Portions Copyright (c) 1999-2001 Internet Software Consortium. | ||
31 | * | ||
32 | * Permission to use, copy, modify, and distribute this software for any | ||
33 | * purpose with or without fee is hereby granted, provided that the above | ||
34 | * copyright notice and this permission notice appear in all copies. | ||
35 | * | ||
36 | * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM | ||
37 | * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL | ||
38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL | ||
39 | * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
40 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING | ||
41 | * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
42 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
43 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
44 | */ | ||
45 | |||
46 | #include "includes.h" | ||
47 | |||
48 | #if defined(DNS) && !defined(HAVE_GETRRSETBYNAME) | ||
49 | |||
50 | #include "getrrsetbyname.h" | ||
51 | |||
52 | /* #include "thread_private.h" */ | ||
53 | |||
54 | #define ANSWER_BUFFER_SIZE 1024*64 | ||
55 | |||
56 | struct dns_query { | ||
57 | char *name; | ||
58 | u_int16_t type; | ||
59 | u_int16_t class; | ||
60 | struct dns_query *next; | ||
61 | }; | ||
62 | |||
63 | struct dns_rr { | ||
64 | char *name; | ||
65 | u_int16_t type; | ||
66 | u_int16_t class; | ||
67 | u_int16_t ttl; | ||
68 | u_int16_t size; | ||
69 | void *rdata; | ||
70 | struct dns_rr *next; | ||
71 | }; | ||
72 | |||
73 | struct dns_response { | ||
74 | HEADER header; | ||
75 | struct dns_query *query; | ||
76 | struct dns_rr *answer; | ||
77 | struct dns_rr *authority; | ||
78 | struct dns_rr *additional; | ||
79 | }; | ||
80 | |||
81 | static struct dns_response *parse_dns_response(const u_char *, int); | ||
82 | static struct dns_query *parse_dns_qsection(const u_char *, int, | ||
83 | const u_char **, int); | ||
84 | static struct dns_rr *parse_dns_rrsection(const u_char *, int, const u_char **, | ||
85 | int); | ||
86 | |||
87 | static void free_dns_query(struct dns_query *); | ||
88 | static void free_dns_rr(struct dns_rr *); | ||
89 | static void free_dns_response(struct dns_response *); | ||
90 | |||
91 | static int count_dns_rr(struct dns_rr *, u_int16_t, u_int16_t); | ||
92 | |||
93 | /* | ||
94 | * Inline versions of get/put short/long. Pointer is advanced. | ||
95 | * | ||
96 | * These macros demonstrate the property of C whereby it can be | ||
97 | * portable or it can be elegant but rarely both. | ||
98 | */ | ||
99 | |||
100 | #ifndef INT32SZ | ||
101 | # define INT32SZ 4 | ||
102 | #endif | ||
103 | #ifndef INT16SZ | ||
104 | # define INT16SZ 2 | ||
105 | #endif | ||
106 | |||
107 | #ifndef GETSHORT | ||
108 | #define GETSHORT(s, cp) { \ | ||
109 | register u_char *t_cp = (u_char *)(cp); \ | ||
110 | (s) = ((u_int16_t)t_cp[0] << 8) \ | ||
111 | | ((u_int16_t)t_cp[1]) \ | ||
112 | ; \ | ||
113 | (cp) += INT16SZ; \ | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | #ifndef GETLONG | ||
118 | #define GETLONG(l, cp) { \ | ||
119 | register u_char *t_cp = (u_char *)(cp); \ | ||
120 | (l) = ((u_int32_t)t_cp[0] << 24) \ | ||
121 | | ((u_int32_t)t_cp[1] << 16) \ | ||
122 | | ((u_int32_t)t_cp[2] << 8) \ | ||
123 | | ((u_int32_t)t_cp[3]) \ | ||
124 | ; \ | ||
125 | (cp) += INT32SZ; \ | ||
126 | } | ||
127 | #endif | ||
128 | |||
129 | /* | ||
130 | * Routines to insert/extract short/long's. | ||
131 | */ | ||
132 | |||
133 | #ifndef HAVE__GETSHORT | ||
134 | static u_int16_t | ||
135 | _getshort(msgp) | ||
136 | register const u_char *msgp; | ||
137 | { | ||
138 | register u_int16_t u; | ||
139 | |||
140 | GETSHORT(u, msgp); | ||
141 | return (u); | ||
142 | } | ||
143 | #endif | ||
144 | |||
145 | #ifndef HAVE__GETLONG | ||
146 | static u_int32_t | ||
147 | _getlong(msgp) | ||
148 | register const u_char *msgp; | ||
149 | { | ||
150 | register u_int32_t u; | ||
151 | |||
152 | GETLONG(u, msgp); | ||
153 | return (u); | ||
154 | } | ||
155 | #endif | ||
156 | |||
157 | int | ||
158 | getrrsetbyname(const char *hostname, unsigned int rdclass, | ||
159 | unsigned int rdtype, unsigned int flags, | ||
160 | struct rrsetinfo **res) | ||
161 | { | ||
162 | struct __res_state *_resp = &_res; | ||
163 | int result; | ||
164 | struct rrsetinfo *rrset = NULL; | ||
165 | struct dns_response *response; | ||
166 | struct dns_rr *rr; | ||
167 | struct rdatainfo *rdata; | ||
168 | int length; | ||
169 | unsigned int index_ans, index_sig; | ||
170 | u_char answer[ANSWER_BUFFER_SIZE]; | ||
171 | |||
172 | /* check for invalid class and type */ | ||
173 | if (rdclass > 0xffff || rdtype > 0xffff) { | ||
174 | result = ERRSET_INVAL; | ||
175 | goto fail; | ||
176 | } | ||
177 | |||
178 | /* don't allow queries of class or type ANY */ | ||
179 | if (rdclass == 0xff || rdtype == 0xff) { | ||
180 | result = ERRSET_INVAL; | ||
181 | goto fail; | ||
182 | } | ||
183 | |||
184 | /* don't allow flags yet, unimplemented */ | ||
185 | if (flags) { | ||
186 | result = ERRSET_INVAL; | ||
187 | goto fail; | ||
188 | } | ||
189 | |||
190 | /* initialize resolver */ | ||
191 | if ((_resp->options & RES_INIT) == 0 && res_init() == -1) { | ||
192 | result = ERRSET_FAIL; | ||
193 | goto fail; | ||
194 | } | ||
195 | |||
196 | #ifdef DEBUG | ||
197 | _resp->options |= RES_DEBUG; | ||
198 | #endif /* DEBUG */ | ||
199 | |||
200 | #ifdef RES_USE_DNSSEC | ||
201 | /* turn on DNSSEC if EDNS0 is configured */ | ||
202 | if (_resp->options & RES_USE_EDNS0) | ||
203 | _resp->options |= RES_USE_DNSSEC; | ||
204 | #endif /* RES_USE_DNSEC */ | ||
205 | |||
206 | /* make query */ | ||
207 | length = res_query(hostname, (signed int) rdclass, (signed int) rdtype, | ||
208 | answer, sizeof(answer)); | ||
209 | if (length < 0) { | ||
210 | switch(h_errno) { | ||
211 | case HOST_NOT_FOUND: | ||
212 | result = ERRSET_NONAME; | ||
213 | goto fail; | ||
214 | case NO_DATA: | ||
215 | result = ERRSET_NODATA; | ||
216 | goto fail; | ||
217 | default: | ||
218 | result = ERRSET_FAIL; | ||
219 | goto fail; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | /* parse result */ | ||
224 | response = parse_dns_response(answer, length); | ||
225 | if (response == NULL) { | ||
226 | result = ERRSET_FAIL; | ||
227 | goto fail; | ||
228 | } | ||
229 | |||
230 | if (response->header.qdcount != 1) { | ||
231 | result = ERRSET_FAIL; | ||
232 | goto fail; | ||
233 | } | ||
234 | |||
235 | /* initialize rrset */ | ||
236 | rrset = calloc(1, sizeof(struct rrsetinfo)); | ||
237 | if (rrset == NULL) { | ||
238 | result = ERRSET_NOMEMORY; | ||
239 | goto fail; | ||
240 | } | ||
241 | rrset->rri_rdclass = response->query->class; | ||
242 | rrset->rri_rdtype = response->query->type; | ||
243 | rrset->rri_ttl = response->answer->ttl; | ||
244 | rrset->rri_nrdatas = response->header.ancount; | ||
245 | |||
246 | #ifdef HAVE_HEADER_AD | ||
247 | /* check for authenticated data */ | ||
248 | if (response->header.ad == 1) | ||
249 | rrset->rri_flags |= RRSET_VALIDATED; | ||
250 | #endif | ||
251 | |||
252 | /* copy name from answer section */ | ||
253 | length = strlen(response->answer->name); | ||
254 | rrset->rri_name = malloc(length + 1); | ||
255 | if (rrset->rri_name == NULL) { | ||
256 | result = ERRSET_NOMEMORY; | ||
257 | goto fail; | ||
258 | } | ||
259 | strlcpy(rrset->rri_name, response->answer->name, length + 1); | ||
260 | |||
261 | /* count answers */ | ||
262 | rrset->rri_nrdatas = count_dns_rr(response->answer, rrset->rri_rdclass, | ||
263 | rrset->rri_rdtype); | ||
264 | rrset->rri_nsigs = count_dns_rr(response->answer, rrset->rri_rdclass, | ||
265 | T_SIG); | ||
266 | |||
267 | /* allocate memory for answers */ | ||
268 | rrset->rri_rdatas = calloc(rrset->rri_nrdatas, | ||
269 | sizeof(struct rdatainfo)); | ||
270 | if (rrset->rri_rdatas == NULL) { | ||
271 | result = ERRSET_NOMEMORY; | ||
272 | goto fail; | ||
273 | } | ||
274 | |||
275 | /* allocate memory for signatures */ | ||
276 | rrset->rri_sigs = calloc(rrset->rri_nsigs, sizeof(struct rdatainfo)); | ||
277 | if (rrset->rri_sigs == NULL) { | ||
278 | result = ERRSET_NOMEMORY; | ||
279 | goto fail; | ||
280 | } | ||
281 | |||
282 | /* copy answers & signatures */ | ||
283 | for (rr = response->answer, index_ans = 0, index_sig = 0; | ||
284 | rr; rr = rr->next) { | ||
285 | |||
286 | rdata = NULL; | ||
287 | |||
288 | if (rr->class == rrset->rri_rdclass && | ||
289 | rr->type == rrset->rri_rdtype) | ||
290 | rdata = &rrset->rri_rdatas[index_ans++]; | ||
291 | |||
292 | if (rr->class == rrset->rri_rdclass && | ||
293 | rr->type == T_SIG) | ||
294 | rdata = &rrset->rri_sigs[index_sig++]; | ||
295 | |||
296 | if (rdata) { | ||
297 | rdata->rdi_length = rr->size; | ||
298 | rdata->rdi_data = malloc(rr->size); | ||
299 | |||
300 | if (rdata->rdi_data == NULL) { | ||
301 | result = ERRSET_NOMEMORY; | ||
302 | goto fail; | ||
303 | } | ||
304 | memcpy(rdata->rdi_data, rr->rdata, rr->size); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | *res = rrset; | ||
309 | return (ERRSET_SUCCESS); | ||
310 | |||
311 | fail: | ||
312 | if (rrset != NULL) | ||
313 | freerrset(rrset); | ||
314 | return (result); | ||
315 | } | ||
316 | |||
317 | void | ||
318 | freerrset(struct rrsetinfo *rrset) | ||
319 | { | ||
320 | u_int16_t i; | ||
321 | |||
322 | if (rrset == NULL) | ||
323 | return; | ||
324 | |||
325 | if (rrset->rri_rdatas) { | ||
326 | for (i = 0; i < rrset->rri_nrdatas; i++) { | ||
327 | if (rrset->rri_rdatas[i].rdi_data == NULL) | ||
328 | break; | ||
329 | free(rrset->rri_rdatas[i].rdi_data); | ||
330 | } | ||
331 | free(rrset->rri_rdatas); | ||
332 | } | ||
333 | |||
334 | if (rrset->rri_sigs) { | ||
335 | for (i = 0; i < rrset->rri_nsigs; i++) { | ||
336 | if (rrset->rri_sigs[i].rdi_data == NULL) | ||
337 | break; | ||
338 | free(rrset->rri_sigs[i].rdi_data); | ||
339 | } | ||
340 | free(rrset->rri_sigs); | ||
341 | } | ||
342 | |||
343 | if (rrset->rri_name) | ||
344 | free(rrset->rri_name); | ||
345 | free(rrset); | ||
346 | } | ||
347 | |||
348 | /* | ||
349 | * DNS response parsing routines | ||
350 | */ | ||
351 | static struct dns_response * | ||
352 | parse_dns_response(const u_char *answer, int size) | ||
353 | { | ||
354 | struct dns_response *resp; | ||
355 | const u_char *cp; | ||
356 | |||
357 | /* allocate memory for the response */ | ||
358 | resp = calloc(1, sizeof(*resp)); | ||
359 | if (resp == NULL) | ||
360 | return (NULL); | ||
361 | |||
362 | /* initialize current pointer */ | ||
363 | cp = answer; | ||
364 | |||
365 | /* copy header */ | ||
366 | memcpy(&resp->header, cp, HFIXEDSZ); | ||
367 | cp += HFIXEDSZ; | ||
368 | |||
369 | /* fix header byte order */ | ||
370 | resp->header.qdcount = ntohs(resp->header.qdcount); | ||
371 | resp->header.ancount = ntohs(resp->header.ancount); | ||
372 | resp->header.nscount = ntohs(resp->header.nscount); | ||
373 | resp->header.arcount = ntohs(resp->header.arcount); | ||
374 | |||
375 | /* there must be at least one query */ | ||
376 | if (resp->header.qdcount < 1) { | ||
377 | free_dns_response(resp); | ||
378 | return (NULL); | ||
379 | } | ||
380 | |||
381 | /* parse query section */ | ||
382 | resp->query = parse_dns_qsection(answer, size, &cp, | ||
383 | resp->header.qdcount); | ||
384 | if (resp->header.qdcount && resp->query == NULL) { | ||
385 | free_dns_response(resp); | ||
386 | return (NULL); | ||
387 | } | ||
388 | |||
389 | /* parse answer section */ | ||
390 | resp->answer = parse_dns_rrsection(answer, size, &cp, | ||
391 | resp->header.ancount); | ||
392 | if (resp->header.ancount && resp->answer == NULL) { | ||
393 | free_dns_response(resp); | ||
394 | return (NULL); | ||
395 | } | ||
396 | |||
397 | /* parse authority section */ | ||
398 | resp->authority = parse_dns_rrsection(answer, size, &cp, | ||
399 | resp->header.nscount); | ||
400 | if (resp->header.nscount && resp->authority == NULL) { | ||
401 | free_dns_response(resp); | ||
402 | return (NULL); | ||
403 | } | ||
404 | |||
405 | /* parse additional section */ | ||
406 | resp->additional = parse_dns_rrsection(answer, size, &cp, | ||
407 | resp->header.arcount); | ||
408 | if (resp->header.arcount && resp->additional == NULL) { | ||
409 | free_dns_response(resp); | ||
410 | return (NULL); | ||
411 | } | ||
412 | |||
413 | return (resp); | ||
414 | } | ||
415 | |||
416 | static struct dns_query * | ||
417 | parse_dns_qsection(const u_char *answer, int size, const u_char **cp, int count) | ||
418 | { | ||
419 | struct dns_query *head, *curr, *prev; | ||
420 | int i, length; | ||
421 | char name[MAXDNAME]; | ||
422 | |||
423 | for (i = 1, head = NULL, prev = NULL; i <= count; i++, prev = curr) { | ||
424 | |||
425 | /* allocate and initialize struct */ | ||
426 | curr = calloc(1, sizeof(struct dns_query)); | ||
427 | if (curr == NULL) { | ||
428 | free_dns_query(head); | ||
429 | return (NULL); | ||
430 | } | ||
431 | if (head == NULL) | ||
432 | head = curr; | ||
433 | if (prev != NULL) | ||
434 | prev->next = curr; | ||
435 | |||
436 | /* name */ | ||
437 | length = dn_expand(answer, answer + size, *cp, name, | ||
438 | sizeof(name)); | ||
439 | if (length < 0) { | ||
440 | free_dns_query(head); | ||
441 | return (NULL); | ||
442 | } | ||
443 | curr->name = strdup(name); | ||
444 | if (curr->name == NULL) { | ||
445 | free_dns_query(head); | ||
446 | return (NULL); | ||
447 | } | ||
448 | *cp += length; | ||
449 | |||
450 | /* type */ | ||
451 | curr->type = _getshort(*cp); | ||
452 | *cp += INT16SZ; | ||
453 | |||
454 | /* class */ | ||
455 | curr->class = _getshort(*cp); | ||
456 | *cp += INT16SZ; | ||
457 | } | ||
458 | |||
459 | return (head); | ||
460 | } | ||
461 | |||
462 | static struct dns_rr * | ||
463 | parse_dns_rrsection(const u_char *answer, int size, const u_char **cp, int count) | ||
464 | { | ||
465 | struct dns_rr *head, *curr, *prev; | ||
466 | int i, length; | ||
467 | char name[MAXDNAME]; | ||
468 | |||
469 | for (i = 1, head = NULL, prev = NULL; i <= count; i++, prev = curr) { | ||
470 | |||
471 | /* allocate and initialize struct */ | ||
472 | curr = calloc(1, sizeof(struct dns_rr)); | ||
473 | if (curr == NULL) { | ||
474 | free_dns_rr(head); | ||
475 | return (NULL); | ||
476 | } | ||
477 | if (head == NULL) | ||
478 | head = curr; | ||
479 | if (prev != NULL) | ||
480 | prev->next = curr; | ||
481 | |||
482 | /* name */ | ||
483 | length = dn_expand(answer, answer + size, *cp, name, | ||
484 | sizeof(name)); | ||
485 | if (length < 0) { | ||
486 | free_dns_rr(head); | ||
487 | return (NULL); | ||
488 | } | ||
489 | curr->name = strdup(name); | ||
490 | if (curr->name == NULL) { | ||
491 | free_dns_rr(head); | ||
492 | return (NULL); | ||
493 | } | ||
494 | *cp += length; | ||
495 | |||
496 | /* type */ | ||
497 | curr->type = _getshort(*cp); | ||
498 | *cp += INT16SZ; | ||
499 | |||
500 | /* class */ | ||
501 | curr->class = _getshort(*cp); | ||
502 | *cp += INT16SZ; | ||
503 | |||
504 | /* ttl */ | ||
505 | curr->ttl = _getlong(*cp); | ||
506 | *cp += INT32SZ; | ||
507 | |||
508 | /* rdata size */ | ||
509 | curr->size = _getshort(*cp); | ||
510 | *cp += INT16SZ; | ||
511 | |||
512 | /* rdata itself */ | ||
513 | curr->rdata = malloc(curr->size); | ||
514 | if (curr->rdata == NULL) { | ||
515 | free_dns_rr(head); | ||
516 | return (NULL); | ||
517 | } | ||
518 | memcpy(curr->rdata, *cp, curr->size); | ||
519 | *cp += curr->size; | ||
520 | } | ||
521 | |||
522 | return (head); | ||
523 | } | ||
524 | |||
525 | static void | ||
526 | free_dns_query(struct dns_query *p) | ||
527 | { | ||
528 | if (p == NULL) | ||
529 | return; | ||
530 | |||
531 | if (p->name) | ||
532 | free(p->name); | ||
533 | free_dns_query(p->next); | ||
534 | free(p); | ||
535 | } | ||
536 | |||
537 | static void | ||
538 | free_dns_rr(struct dns_rr *p) | ||
539 | { | ||
540 | if (p == NULL) | ||
541 | return; | ||
542 | |||
543 | if (p->name) | ||
544 | free(p->name); | ||
545 | if (p->rdata) | ||
546 | free(p->rdata); | ||
547 | free_dns_rr(p->next); | ||
548 | free(p); | ||
549 | } | ||
550 | |||
551 | static void | ||
552 | free_dns_response(struct dns_response *p) | ||
553 | { | ||
554 | if (p == NULL) | ||
555 | return; | ||
556 | |||
557 | free_dns_query(p->query); | ||
558 | free_dns_rr(p->answer); | ||
559 | free_dns_rr(p->authority); | ||
560 | free_dns_rr(p->additional); | ||
561 | free(p); | ||
562 | } | ||
563 | |||
564 | static int | ||
565 | count_dns_rr(struct dns_rr *p, u_int16_t class, u_int16_t type) | ||
566 | { | ||
567 | int n = 0; | ||
568 | |||
569 | while(p) { | ||
570 | if (p->class == class && p->type == type) | ||
571 | n++; | ||
572 | p = p->next; | ||
573 | } | ||
574 | |||
575 | return (n); | ||
576 | } | ||
577 | |||
578 | #endif /* defined(DNS) && !defined(HAVE_GETRRSETBYNAME) */ | ||
diff --git a/openbsd-compat/getrrsetbyname.h b/openbsd-compat/getrrsetbyname.h new file mode 100644 index 000000000..6466a54d6 --- /dev/null +++ b/openbsd-compat/getrrsetbyname.h | |||
@@ -0,0 +1,100 @@ | |||
1 | /* $OpenBSD: getrrsetbyname.c,v 1.4 2001/08/16 18:16:43 ho Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2001 Jakob Schlyter. All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | * Portions Copyright (c) 1999-2001 Internet Software Consortium. | ||
31 | * | ||
32 | * Permission to use, copy, modify, and distribute this software for any | ||
33 | * purpose with or without fee is hereby granted, provided that the above | ||
34 | * copyright notice and this permission notice appear in all copies. | ||
35 | * | ||
36 | * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM | ||
37 | * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL | ||
38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL | ||
39 | * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
40 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING | ||
41 | * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
42 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
43 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
44 | */ | ||
45 | |||
46 | #ifndef _GETRRSETBYNAME_H | ||
47 | #define _GETRRSETBYNAME_H | ||
48 | |||
49 | #include "includes.h" | ||
50 | |||
51 | #if defined(DNS) && !defined(HAVE_GETRRSETBYNAME) | ||
52 | |||
53 | #include <sys/types.h> | ||
54 | #include <netinet/in.h> | ||
55 | #include <arpa/nameser.h> | ||
56 | #include <netdb.h> | ||
57 | #include <resolv.h> | ||
58 | |||
59 | /* | ||
60 | * Flags for getrrsetbyname() | ||
61 | */ | ||
62 | #ifndef RRSET_VALIDATED | ||
63 | # define RRSET_VALIDATED 1 | ||
64 | #endif | ||
65 | |||
66 | /* | ||
67 | * Return codes for getrrsetbyname() | ||
68 | */ | ||
69 | #ifndef ERRSET_SUCCESS | ||
70 | # define ERRSET_SUCCESS 0 | ||
71 | # define ERRSET_NOMEMORY 1 | ||
72 | # define ERRSET_FAIL 2 | ||
73 | # define ERRSET_INVAL 3 | ||
74 | # define ERRSET_NONAME 4 | ||
75 | # define ERRSET_NODATA 5 | ||
76 | #endif | ||
77 | |||
78 | struct rdatainfo { | ||
79 | unsigned int rdi_length; /* length of data */ | ||
80 | unsigned char *rdi_data; /* record data */ | ||
81 | }; | ||
82 | |||
83 | struct rrsetinfo { | ||
84 | unsigned int rri_flags; /* RRSET_VALIDATED ... */ | ||
85 | unsigned int rri_rdclass; /* class number */ | ||
86 | unsigned int rri_rdtype; /* RR type number */ | ||
87 | unsigned int rri_ttl; /* time to live */ | ||
88 | unsigned int rri_nrdatas; /* size of rdatas array */ | ||
89 | unsigned int rri_nsigs; /* size of sigs array */ | ||
90 | char *rri_name; /* canonical name */ | ||
91 | struct rdatainfo *rri_rdatas; /* individual records */ | ||
92 | struct rdatainfo *rri_sigs; /* individual signatures */ | ||
93 | }; | ||
94 | |||
95 | int getrrsetbyname(const char *, unsigned int, unsigned int, unsigned int, struct rrsetinfo **); | ||
96 | void freerrset(struct rrsetinfo *); | ||
97 | |||
98 | #endif /* defined(DNS) && !defined(HAVE_GETRRSETBYNAME) */ | ||
99 | |||
100 | #endif /* _GETRRSETBYNAME_H */ | ||
diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c index e928a2272..50f35c304 100644 --- a/openbsd-compat/glob.c +++ b/openbsd-compat/glob.c | |||
@@ -13,11 +13,7 @@ | |||
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. |
16 | * 3. All advertising materials mentioning features or use of this software | 16 | * 3. Neither the name of the University nor the names of its contributors |
17 | * must display the following acknowledgement: | ||
18 | * This product includes software developed by the University of | ||
19 | * California, Berkeley and its contributors. | ||
20 | * 4. Neither the name of the University nor the names of its contributors | ||
21 | * may be used to endorse or promote products derived from this software | 17 | * may be used to endorse or promote products derived from this software |
22 | * without specific prior written permission. | 18 | * without specific prior written permission. |
23 | * | 19 | * |
@@ -56,7 +52,7 @@ get_arg_max(void) | |||
56 | #if 0 | 52 | #if 0 |
57 | static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; | 53 | static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; |
58 | #else | 54 | #else |
59 | static char rcsid[] = "$OpenBSD: glob.c,v 1.20 2002/06/14 21:34:58 todd Exp $"; | 55 | static char rcsid[] = "$OpenBSD: glob.c,v 1.22 2003/06/25 21:16:47 deraadt Exp $"; |
60 | #endif | 56 | #endif |
61 | #endif /* LIBC_SCCS and not lint */ | 57 | #endif /* LIBC_SCCS and not lint */ |
62 | 58 | ||
@@ -615,7 +611,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last, | |||
615 | * and dirent.h as taking pointers to differently typed opaque | 611 | * and dirent.h as taking pointers to differently typed opaque |
616 | * structures. | 612 | * structures. |
617 | */ | 613 | */ |
618 | struct dirent *(*readdirfunc)(); | 614 | struct dirent *(*readdirfunc)(void *); |
619 | 615 | ||
620 | if (pathend > pathend_last) | 616 | if (pathend > pathend_last) |
621 | return (1); | 617 | return (1); |
@@ -640,7 +636,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last, | |||
640 | if (pglob->gl_flags & GLOB_ALTDIRFUNC) | 636 | if (pglob->gl_flags & GLOB_ALTDIRFUNC) |
641 | readdirfunc = pglob->gl_readdir; | 637 | readdirfunc = pglob->gl_readdir; |
642 | else | 638 | else |
643 | readdirfunc = readdir; | 639 | readdirfunc = (struct dirent *(*)(void *))readdir; |
644 | while ((dp = (*readdirfunc)(dirp))) { | 640 | while ((dp = (*readdirfunc)(dirp))) { |
645 | register u_char *sc; | 641 | register u_char *sc; |
646 | register Char *dc; | 642 | register Char *dc; |
diff --git a/openbsd-compat/glob.h b/openbsd-compat/glob.h index 6421f7049..aceddbc48 100644 --- a/openbsd-compat/glob.h +++ b/openbsd-compat/glob.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: glob.h,v 1.7 2002/02/17 19:42:21 millert Exp $ */ | 1 | /* $OpenBSD: glob.h,v 1.8 2003/06/02 19:34:12 millert Exp $ */ |
2 | /* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */ | 2 | /* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */ |
3 | 3 | ||
4 | /* | 4 | /* |
@@ -16,11 +16,7 @@ | |||
16 | * 2. Redistributions in binary form must reproduce the above copyright | 16 | * 2. Redistributions in binary form must reproduce the above copyright |
17 | * notice, this list of conditions and the following disclaimer in the | 17 | * notice, this list of conditions and the following disclaimer in the |
18 | * documentation and/or other materials provided with the distribution. | 18 | * documentation and/or other materials provided with the distribution. |
19 | * 3. All advertising materials mentioning features or use of this software | 19 | * 3. Neither the name of the University nor the names of its contributors |
20 | * must display the following acknowledgement: | ||
21 | * This product includes software developed by the University of | ||
22 | * California, Berkeley and its contributors. | ||
23 | * 4. Neither the name of the University nor the names of its contributors | ||
24 | * may be used to endorse or promote products derived from this software | 20 | * may be used to endorse or promote products derived from this software |
25 | * without specific prior written permission. | 21 | * without specific prior written permission. |
26 | * | 22 | * |
diff --git a/openbsd-compat/inet_aton.c b/openbsd-compat/inet_aton.c index 1fc001da6..5de49868d 100644 --- a/openbsd-compat/inet_aton.c +++ b/openbsd-compat/inet_aton.c | |||
@@ -1,8 +1,6 @@ | |||
1 | /* $OpenBSD: inet_addr.c,v 1.6 1999/05/03 22:31:14 yanick Exp $ */ | 1 | /* $OpenBSD: inet_addr.c,v 1.7 2003/06/02 20:18:35 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * ++Copyright++ 1983, 1990, 1993 | ||
5 | * - | ||
6 | * Copyright (c) 1983, 1990, 1993 | 4 | * Copyright (c) 1983, 1990, 1993 |
7 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. |
8 | * | 6 | * |
@@ -14,11 +12,7 @@ | |||
14 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
15 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the |
16 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. |
17 | * 3. All advertising materials mentioning features or use of this software | 15 | * 3. Neither the name of the University nor the names of its contributors |
18 | * must display the following acknowledgement: | ||
19 | * This product includes software developed by the University of | ||
20 | * California, Berkeley and its contributors. | ||
21 | * 4. Neither the name of the University nor the names of its contributors | ||
22 | * may be used to endorse or promote products derived from this software | 16 | * may be used to endorse or promote products derived from this software |
23 | * without specific prior written permission. | 17 | * without specific prior written permission. |
24 | * | 18 | * |
@@ -64,7 +58,7 @@ | |||
64 | static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; | 58 | static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; |
65 | static char rcsid[] = "$From: inet_addr.c,v 8.5 1996/08/05 08:31:35 vixie Exp $"; | 59 | static char rcsid[] = "$From: inet_addr.c,v 8.5 1996/08/05 08:31:35 vixie Exp $"; |
66 | #else | 60 | #else |
67 | static char rcsid[] = "$OpenBSD: inet_addr.c,v 1.6 1999/05/03 22:31:14 yanick Exp $"; | 61 | static char rcsid[] = "$OpenBSD: inet_addr.c,v 1.7 2003/06/02 20:18:35 millert Exp $"; |
68 | #endif | 62 | #endif |
69 | #endif /* LIBC_SCCS and not lint */ | 63 | #endif /* LIBC_SCCS and not lint */ |
70 | 64 | ||
diff --git a/openbsd-compat/inet_aton.h b/openbsd-compat/inet_aton.h deleted file mode 100644 index 9b59cb908..000000000 --- a/openbsd-compat/inet_aton.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: inet_aton.h,v 1.4 2001/07/16 02:07:51 tim Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_INET_ATON_H | ||
4 | #define _BSD_INET_ATON_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_INET_ATON | ||
9 | int inet_aton(const char *cp, struct in_addr *addr); | ||
10 | #endif /* HAVE_INET_ATON */ | ||
11 | |||
12 | #endif /* _BSD_INET_ATON_H */ | ||
diff --git a/openbsd-compat/inet_ntoa.c b/openbsd-compat/inet_ntoa.c index ac5f56708..e0384491d 100644 --- a/openbsd-compat/inet_ntoa.c +++ b/openbsd-compat/inet_ntoa.c | |||
@@ -10,11 +10,7 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
14 | * must display the following acknowledgement: | ||
15 | * This product includes software developed by the University of | ||
16 | * California, Berkeley and its contributors. | ||
17 | * 4. Neither the name of the University nor the names of its contributors | ||
18 | * 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 |
19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
20 | * | 16 | * |
@@ -36,7 +32,7 @@ | |||
36 | #if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) | 32 | #if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) |
37 | 33 | ||
38 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
39 | static char rcsid[] = "$OpenBSD: inet_ntoa.c,v 1.3 2002/06/27 10:14:01 itojun Exp $"; | 35 | static char rcsid[] = "$OpenBSD: inet_ntoa.c,v 1.4 2003/06/02 20:18:35 millert Exp $"; |
40 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
41 | 37 | ||
42 | /* | 38 | /* |
diff --git a/openbsd-compat/inet_ntoa.h b/openbsd-compat/inet_ntoa.h deleted file mode 100644 index 85bc3d6fe..000000000 --- a/openbsd-compat/inet_ntoa.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: inet_ntoa.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_INET_NTOA_H | ||
4 | #define _BSD_INET_NTOA_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) | ||
9 | char *inet_ntoa(struct in_addr in); | ||
10 | #endif /* defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) */ | ||
11 | |||
12 | #endif /* _BSD_INET_NTOA_H */ | ||
diff --git a/openbsd-compat/inet_ntop.c b/openbsd-compat/inet_ntop.c index 3bea519af..075eac44f 100644 --- a/openbsd-compat/inet_ntop.c +++ b/openbsd-compat/inet_ntop.c | |||
@@ -31,7 +31,6 @@ static char rcsid[] = "$OpenBSD: inet_ntop.c,v 1.5 2002/08/23 16:27:31 itojun Ex | |||
31 | #include <sys/param.h> | 31 | #include <sys/param.h> |
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | #include <sys/socket.h> | 33 | #include <sys/socket.h> |
34 | #include "openbsd-compat/fake-socket.h" | ||
35 | #include <netinet/in.h> | 34 | #include <netinet/in.h> |
36 | #include <arpa/inet.h> | 35 | #include <arpa/inet.h> |
37 | #ifndef HAVE_CYGWIN | 36 | #ifndef HAVE_CYGWIN |
diff --git a/openbsd-compat/inet_ntop.h b/openbsd-compat/inet_ntop.h deleted file mode 100644 index c774df95c..000000000 --- a/openbsd-compat/inet_ntop.h +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | /* $Id: inet_ntop.h,v 1.4 2001/08/09 00:56:53 mouring Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_INET_NTOP_H | ||
4 | #define _BSD_INET_NTOP_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_INET_NTOP | ||
9 | const char * | ||
10 | inet_ntop(int af, const void *src, char *dst, size_t size); | ||
11 | #endif /* !HAVE_INET_NTOP */ | ||
12 | |||
13 | #endif /* _BSD_INET_NTOP_H */ | ||
diff --git a/openbsd-compat/mktemp.c b/openbsd-compat/mktemp.c index c951050c0..2cd747835 100644 --- a/openbsd-compat/mktemp.c +++ b/openbsd-compat/mktemp.c | |||
@@ -13,11 +13,7 @@ | |||
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. |
16 | * 3. All advertising materials mentioning features or use of this software | 16 | * 3. Neither the name of the University nor the names of its contributors |
17 | * must display the following acknowledgement: | ||
18 | * This product includes software developed by the University of | ||
19 | * California, Berkeley and its contributors. | ||
20 | * 4. Neither the name of the University nor the names of its contributors | ||
21 | * may be used to endorse or promote products derived from this software | 17 | * may be used to endorse or promote products derived from this software |
22 | * without specific prior written permission. | 18 | * without specific prior written permission. |
23 | * | 19 | * |
@@ -39,7 +35,7 @@ | |||
39 | #if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) | 35 | #if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) |
40 | 36 | ||
41 | #if defined(LIBC_SCCS) && !defined(lint) | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
42 | static char rcsid[] = "$OpenBSD: mktemp.c,v 1.16 2002/05/27 18:20:45 millert Exp $"; | 38 | static char rcsid[] = "$OpenBSD: mktemp.c,v 1.17 2003/06/02 20:18:37 millert Exp $"; |
43 | #endif /* LIBC_SCCS and not lint */ | 39 | #endif /* LIBC_SCCS and not lint */ |
44 | 40 | ||
45 | #ifdef HAVE_CYGWIN | 41 | #ifdef HAVE_CYGWIN |
diff --git a/openbsd-compat/mktemp.h b/openbsd-compat/mktemp.h deleted file mode 100644 index 505ca6a1f..000000000 --- a/openbsd-compat/mktemp.h +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | /* $Id: mktemp.h,v 1.3 2003/01/07 04:18:33 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_MKTEMP_H | ||
4 | #define _BSD_MKTEMP_H | ||
5 | |||
6 | #include "config.h" | ||
7 | #if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) | ||
8 | int mkstemps(char *path, int slen); | ||
9 | int mkstemp(char *path); | ||
10 | char *mkdtemp(char *path); | ||
11 | #endif /* !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) */ | ||
12 | |||
13 | #endif /* _BSD_MKTEMP_H */ | ||
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index c3e19b9cb..852948c54 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h | |||
@@ -1,49 +1,168 @@ | |||
1 | /* $Id: openbsd-compat.h,v 1.19 2003/02/24 01:55:56 djm Exp $ */ | 1 | /* $Id: openbsd-compat.h,v 1.24 2003/08/29 16:59:52 mouring Exp $ */ |
2 | 2 | ||
3 | #ifndef _OPENBSD_H | 3 | /* |
4 | #define _OPENBSD_H | 4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
5 | * Copyright (c) 2003 Ben Lindstrom. All rights reserved. | ||
6 | * Copyright (c) 2002 Tim Rice. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | */ | ||
5 | 28 | ||
6 | #include "config.h" | 29 | #ifndef _OPENBSD_COMPAT_H |
30 | #define _OPENBSD_COMPAT_H | ||
31 | |||
32 | #include "includes.h" | ||
7 | 33 | ||
8 | /* OpenBSD function replacements */ | 34 | /* OpenBSD function replacements */ |
9 | #include "basename.h" | ||
10 | #include "bindresvport.h" | ||
11 | #include "getcwd.h" | ||
12 | #include "realpath.h" | ||
13 | #include "rresvport.h" | ||
14 | #include "strlcpy.h" | ||
15 | #include "strlcat.h" | ||
16 | #include "strmode.h" | ||
17 | #include "mktemp.h" | ||
18 | #include "daemon.h" | ||
19 | #include "dirname.h" | ||
20 | #include "base64.h" | 35 | #include "base64.h" |
21 | #include "sigact.h" | 36 | #include "sigact.h" |
22 | #include "inet_ntoa.h" | ||
23 | #include "inet_ntop.h" | ||
24 | #include "strsep.h" | ||
25 | #include "setproctitle.h" | ||
26 | #include "getgrouplist.h" | ||
27 | #include "glob.h" | 37 | #include "glob.h" |
28 | #include "readpassphrase.h" | 38 | #include "readpassphrase.h" |
29 | #include "getopt.h" | ||
30 | #include "vis.h" | 39 | #include "vis.h" |
40 | #include "getrrsetbyname.h" | ||
41 | |||
42 | |||
43 | #ifndef HAVE_BASENAME | ||
44 | char *basename(const char *path); | ||
45 | #endif | ||
46 | |||
47 | #ifndef HAVE_BINDRESVPORT_SA | ||
48 | int bindresvport_sa(int sd, struct sockaddr *sa); | ||
49 | #endif | ||
50 | |||
51 | #ifndef HAVE_GETCWD | ||
52 | char *getcwd(char *pt, size_t size); | ||
53 | #endif | ||
54 | |||
55 | #if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) | ||
56 | char *realpath(const char *path, char *resolved); | ||
57 | #endif | ||
58 | |||
59 | #ifndef HAVE_RRESVPORT_AF | ||
60 | int rresvport_af(int *alport, sa_family_t af); | ||
61 | #endif | ||
62 | |||
63 | #ifndef HAVE_STRLCPY | ||
64 | /* #include <sys/types.h> XXX Still needed? */ | ||
65 | size_t strlcpy(char *dst, const char *src, size_t siz); | ||
66 | #endif | ||
67 | |||
68 | #ifndef HAVE_STRLCAT | ||
69 | /* #include <sys/types.h> XXX Still needed? */ | ||
70 | size_t strlcat(char *dst, const char *src, size_t siz); | ||
71 | #endif | ||
72 | |||
73 | #ifndef HAVE_SETENV | ||
74 | int setenv(register const char *name, register const char *value, int rewrite); | ||
75 | #endif | ||
76 | |||
77 | #ifndef HAVE_STRMODE | ||
78 | void strmode(int mode, char *p); | ||
79 | #endif | ||
80 | |||
81 | #if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) | ||
82 | int mkstemps(char *path, int slen); | ||
83 | int mkstemp(char *path); | ||
84 | char *mkdtemp(char *path); | ||
85 | #endif | ||
86 | |||
87 | #ifndef HAVE_DAEMON | ||
88 | int daemon(int nochdir, int noclose); | ||
89 | #endif | ||
90 | |||
91 | #ifndef HAVE_DIRNAME | ||
92 | char *dirname(const char *path); | ||
93 | #endif | ||
94 | |||
95 | #if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) | ||
96 | char *inet_ntoa(struct in_addr in); | ||
97 | #endif | ||
98 | |||
99 | #ifndef HAVE_INET_NTOP | ||
100 | const char *inet_ntop(int af, const void *src, char *dst, size_t size); | ||
101 | #endif | ||
102 | |||
103 | #ifndef HAVE_INET_ATON | ||
104 | int inet_aton(const char *cp, struct in_addr *addr); | ||
105 | #endif | ||
106 | |||
107 | #ifndef HAVE_STRSEP | ||
108 | char *strsep(char **stringp, const char *delim); | ||
109 | #endif | ||
110 | |||
111 | #ifndef HAVE_SETPROCTITLE | ||
112 | void setproctitle(const char *fmt, ...); | ||
113 | void compat_init_setproctitle(int argc, char *argv[]); | ||
114 | #endif | ||
115 | |||
116 | #ifndef HAVE_GETGROUPLIST | ||
117 | /* #include <grp.h> XXXX Still needed ? */ | ||
118 | int getgrouplist(const char *, gid_t, gid_t *, int *); | ||
119 | #endif | ||
120 | |||
121 | #if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) | ||
122 | int BSDgetopt(int argc, char * const *argv, const char *opts); | ||
123 | #endif | ||
124 | |||
31 | 125 | ||
32 | /* Home grown routines */ | 126 | /* Home grown routines */ |
33 | #include "bsd-arc4random.h" | ||
34 | #include "bsd-getpeereid.h" | ||
35 | #include "bsd-misc.h" | 127 | #include "bsd-misc.h" |
36 | #include "bsd-snprintf.h" | ||
37 | #include "bsd-waitpid.h" | 128 | #include "bsd-waitpid.h" |
38 | 129 | ||
130 | /*#include <sys/types.h> XXX Still needed? * For uid_t, gid_t * */ | ||
131 | |||
132 | #ifndef HAVE_GETPEEREID | ||
133 | int getpeereid(int , uid_t *, gid_t *); | ||
134 | #endif | ||
135 | |||
136 | #ifndef HAVE_ARC4RANDOM | ||
137 | unsigned int arc4random(void); | ||
138 | void arc4random_stir(void); | ||
139 | #endif /* !HAVE_ARC4RANDOM */ | ||
140 | |||
141 | |||
142 | |||
143 | |||
144 | /* #include <sys/types.h> XXX needed? For size_t */ | ||
145 | |||
146 | #ifndef HAVE_SNPRINTF | ||
147 | int snprintf(char *, size_t, const char *, ...); | ||
148 | #endif | ||
149 | |||
150 | #ifndef HAVE_VSNPRINTF | ||
151 | int vsnprintf(char *, size_t, const char *, va_list); | ||
152 | #endif | ||
153 | |||
154 | void *xmmap(size_t size); | ||
155 | char *xcrypt(const char *password, const char *salt); | ||
156 | char *shadow_pw(struct passwd *pw); | ||
157 | |||
158 | |||
39 | /* rfc2553 socket API replacements */ | 159 | /* rfc2553 socket API replacements */ |
40 | #include "fake-getaddrinfo.h" | 160 | #include "fake-rfc2553.h" |
41 | #include "fake-getnameinfo.h" | ||
42 | #include "fake-socket.h" | ||
43 | 161 | ||
44 | /* Routines for a single OS platform */ | 162 | /* Routines for a single OS platform */ |
45 | #include "bsd-cray.h" | 163 | #include "bsd-cray.h" |
164 | #include "bsd-cygwin_util.h" | ||
46 | #include "port-irix.h" | 165 | #include "port-irix.h" |
47 | #include "port-aix.h" | 166 | #include "port-aix.h" |
48 | 167 | ||
49 | #endif /* _OPENBSD_H */ | 168 | #endif /* _OPENBSD_COMPAT_H */ |
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c index 4c96a3171..7a981634b 100644 --- a/openbsd-compat/port-aix.c +++ b/openbsd-compat/port-aix.c | |||
@@ -24,11 +24,17 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | #include "includes.h" | 26 | #include "includes.h" |
27 | #include "ssh.h" | ||
28 | #include "log.h" | ||
29 | #include "servconf.h" | ||
27 | 30 | ||
28 | #ifdef _AIX | 31 | #ifdef _AIX |
29 | 32 | ||
30 | #include <uinfo.h> | 33 | #include <uinfo.h> |
31 | #include <../xmalloc.h> | 34 | #include <../xmalloc.h> |
35 | #include "port-aix.h" | ||
36 | |||
37 | extern ServerOptions options; | ||
32 | 38 | ||
33 | /* | 39 | /* |
34 | * AIX has a "usrinfo" area where logname and other stuff is stored - | 40 | * AIX has a "usrinfo" area where logname and other stuff is stored - |
@@ -41,16 +47,95 @@ void | |||
41 | aix_usrinfo(struct passwd *pw) | 47 | aix_usrinfo(struct passwd *pw) |
42 | { | 48 | { |
43 | u_int i; | 49 | u_int i; |
50 | size_t len; | ||
44 | char *cp; | 51 | char *cp; |
45 | 52 | ||
46 | cp = xmalloc(16 + 2 * strlen(pw->pw_name)); | 53 | len = sizeof("LOGNAME= NAME= ") + (2 * strlen(pw->pw_name)); |
47 | i = sprintf(cp, "LOGNAME=%s%cNAME=%s%c", pw->pw_name, 0, | 54 | cp = xmalloc(len); |
48 | pw->pw_name, 0); | 55 | |
56 | i = snprintf(cp, len, "LOGNAME=%s%cNAME=%s%c", pw->pw_name, '\0', | ||
57 | pw->pw_name, '\0'); | ||
49 | if (usrinfo(SETUINFO, cp, i) == -1) | 58 | if (usrinfo(SETUINFO, cp, i) == -1) |
50 | fatal("Couldn't set usrinfo: %s", strerror(errno)); | 59 | fatal("Couldn't set usrinfo: %s", strerror(errno)); |
51 | debug3("AIX/UsrInfo: set len %d", i); | 60 | debug3("AIX/UsrInfo: set len %d", i); |
61 | |||
52 | xfree(cp); | 62 | xfree(cp); |
53 | } | 63 | } |
54 | 64 | ||
65 | #ifdef WITH_AIXAUTHENTICATE | ||
66 | /* | ||
67 | * Remove embedded newlines in string (if any). | ||
68 | * Used before logging messages returned by AIX authentication functions | ||
69 | * so the message is logged on one line. | ||
70 | */ | ||
71 | void | ||
72 | aix_remove_embedded_newlines(char *p) | ||
73 | { | ||
74 | if (p == NULL) | ||
75 | return; | ||
76 | |||
77 | for (; *p; p++) { | ||
78 | if (*p == '\n') | ||
79 | *p = ' '; | ||
80 | } | ||
81 | /* Remove trailing whitespace */ | ||
82 | if (*--p == ' ') | ||
83 | *p = '\0'; | ||
84 | } | ||
85 | #endif /* WITH_AIXAUTHENTICATE */ | ||
86 | |||
87 | # ifdef CUSTOM_FAILED_LOGIN | ||
88 | /* | ||
89 | * record_failed_login: generic "login failed" interface function | ||
90 | */ | ||
91 | void | ||
92 | record_failed_login(const char *user, const char *ttyname) | ||
93 | { | ||
94 | char *hostname = get_canonical_hostname(options.use_dns); | ||
95 | |||
96 | if (geteuid() != 0) | ||
97 | return; | ||
98 | |||
99 | aix_setauthdb(user); | ||
100 | # ifdef AIX_LOGINFAILED_4ARG | ||
101 | loginfailed((char *)user, hostname, (char *)ttyname, AUDIT_FAIL_AUTH); | ||
102 | # else | ||
103 | loginfailed((char *)user, hostname, (char *)ttyname); | ||
104 | # endif | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * If we have setauthdb, retrieve the password registry for the user's | ||
109 | * account then feed it to setauthdb. This may load registry-specific method | ||
110 | * code. If we don't have setauthdb or have already called it this is a no-op. | ||
111 | */ | ||
112 | void | ||
113 | aix_setauthdb(const char *user) | ||
114 | { | ||
115 | # ifdef HAVE_SETAUTHDB | ||
116 | static char *registry = NULL; | ||
117 | |||
118 | if (registry != NULL) /* have already done setauthdb */ | ||
119 | return; | ||
120 | |||
121 | if (setuserdb(S_READ) == -1) { | ||
122 | debug3("%s: Could not open userdb to read", __func__); | ||
123 | return; | ||
124 | } | ||
125 | |||
126 | if (getuserattr((char *)user, S_REGISTRY, ®istry, SEC_CHAR) == 0) { | ||
127 | if (setauthdb(registry, NULL) == 0) | ||
128 | debug3("%s: AIX/setauthdb set registry %s", __func__, | ||
129 | registry); | ||
130 | else | ||
131 | debug3("%s: AIX/setauthdb set registry %s failed: %s", | ||
132 | __func__, registry, strerror(errno)); | ||
133 | } else | ||
134 | debug3("%s: Could not read S_REGISTRY for user: %s", __func__, | ||
135 | strerror(errno)); | ||
136 | enduserdb(); | ||
137 | # endif | ||
138 | } | ||
139 | # endif /* CUSTOM_FAILED_LOGIN */ | ||
55 | #endif /* _AIX */ | 140 | #endif /* _AIX */ |
56 | 141 | ||
diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h index 4abe00316..09e7f9e97 100644 --- a/openbsd-compat/port-aix.h +++ b/openbsd-compat/port-aix.h | |||
@@ -1,3 +1,5 @@ | |||
1 | /* $Id: port-aix.h,v 1.14 2003/08/29 16:59:52 mouring Exp $ */ | ||
2 | |||
1 | /* | 3 | /* |
2 | * | 4 | * |
3 | * Copyright (c) 2001 Gert Doering. All rights reserved. | 5 | * Copyright (c) 2001 Gert Doering. All rights reserved. |
@@ -21,11 +23,24 @@ | |||
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (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. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | * | ||
25 | */ | 26 | */ |
26 | 27 | ||
27 | #ifdef _AIX | 28 | #ifdef _AIX |
28 | 29 | ||
30 | #ifdef WITH_AIXAUTHENTICATE | ||
31 | # include <login.h> | ||
32 | # include <userpw.h> | ||
33 | # include <usersec.h> | ||
34 | # ifdef HAVE_SYS_AUDIT_H | ||
35 | # include <sys/audit.h> | ||
36 | # endif | ||
37 | #endif | ||
38 | |||
39 | /* Some versions define r_type in the above headers, which causes a conflict */ | ||
40 | #ifdef r_type | ||
41 | # undef r_type | ||
42 | #endif | ||
43 | |||
29 | /* AIX 4.2.x doesn't have nanosleep but does have nsleep which is equivalent */ | 44 | /* AIX 4.2.x doesn't have nanosleep but does have nsleep which is equivalent */ |
30 | #if !defined(HAVE_NANOSLEEP) && defined(HAVE_NSLEEP) | 45 | #if !defined(HAVE_NANOSLEEP) && defined(HAVE_NSLEEP) |
31 | # define nanosleep(a,b) nsleep(a,b) | 46 | # define nanosleep(a,b) nsleep(a,b) |
@@ -36,5 +51,12 @@ | |||
36 | # include <sys/timers.h> | 51 | # include <sys/timers.h> |
37 | #endif | 52 | #endif |
38 | 53 | ||
39 | void aix_usrinfo(struct passwd *pw); | 54 | #ifdef WITH_AIXAUTHENTICATE |
55 | # define CUSTOM_FAILED_LOGIN 1 | ||
56 | void record_failed_login(const char *, const char *); | ||
57 | void aix_setauthdb(const char *); | ||
58 | #endif | ||
59 | |||
60 | void aix_usrinfo(struct passwd *); | ||
61 | void aix_remove_embedded_newlines(char *); | ||
40 | #endif /* _AIX */ | 62 | #endif /* _AIX */ |
diff --git a/openbsd-compat/port-irix.c b/openbsd-compat/port-irix.c index a63ec429a..aa6db1cf8 100644 --- a/openbsd-compat/port-irix.c +++ b/openbsd-compat/port-irix.c | |||
@@ -1,15 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000 Denis Parker. All rights reserved. | ||
3 | * Copyright (c) 2000 Michael Stone. All rights reserved. | ||
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 | |||
1 | #include "includes.h" | 26 | #include "includes.h" |
2 | 27 | ||
3 | #if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) | 28 | #if defined(WITH_IRIX_PROJECT) || \ |
29 | defined(WITH_IRIX_JOBS) || \ | ||
30 | defined(WITH_IRIX_ARRAY) | ||
4 | 31 | ||
5 | #ifdef WITH_IRIX_PROJECT | 32 | #ifdef WITH_IRIX_PROJECT |
6 | #include <proj.h> | 33 | # include <proj.h> |
7 | #endif /* WITH_IRIX_PROJECT */ | 34 | #endif /* WITH_IRIX_PROJECT */ |
8 | #ifdef WITH_IRIX_JOBS | 35 | #ifdef WITH_IRIX_JOBS |
9 | #include <sys/resource.h> | 36 | # include <sys/resource.h> |
10 | #endif | 37 | #endif |
11 | #ifdef WITH_IRIX_AUDIT | 38 | #ifdef WITH_IRIX_AUDIT |
12 | #include <sat.h> | 39 | # include <sat.h> |
13 | #endif /* WITH_IRIX_AUDIT */ | 40 | #endif /* WITH_IRIX_AUDIT */ |
14 | 41 | ||
15 | void | 42 | void |
@@ -17,14 +44,12 @@ irix_setusercontext(struct passwd *pw) | |||
17 | { | 44 | { |
18 | #ifdef WITH_IRIX_PROJECT | 45 | #ifdef WITH_IRIX_PROJECT |
19 | prid_t projid; | 46 | prid_t projid; |
20 | #endif /* WITH_IRIX_PROJECT */ | 47 | #endif |
21 | #ifdef WITH_IRIX_JOBS | 48 | #ifdef WITH_IRIX_JOBS |
22 | jid_t jid = 0; | 49 | jid_t jid = 0; |
23 | #else | 50 | #elif defined(WITH_IRIX_ARRAY) |
24 | # ifdef WITH_IRIX_ARRAY | ||
25 | int jid = 0; | 51 | int jid = 0; |
26 | # endif /* WITH_IRIX_ARRAY */ | 52 | #endif |
27 | #endif /* WITH_IRIX_JOBS */ | ||
28 | 53 | ||
29 | #ifdef WITH_IRIX_JOBS | 54 | #ifdef WITH_IRIX_JOBS |
30 | jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); | 55 | jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); |
diff --git a/openbsd-compat/port-irix.h b/openbsd-compat/port-irix.h index 2dd3c2e25..67c486307 100644 --- a/openbsd-compat/port-irix.h +++ b/openbsd-compat/port-irix.h | |||
@@ -1,5 +1,39 @@ | |||
1 | #if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) | 1 | /* $Id: port-irix.h,v 1.4 2003/08/29 16:59:52 mouring Exp $ */ |
2 | |||
3 | /* | ||
4 | * Copyright (c) 2000 Denis Parker. All rights reserved. | ||
5 | * Copyright (c) 2000 Michael Stone. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | #ifndef _PORT_IRIX_H | ||
29 | #define _PORT_IRIX_H | ||
30 | |||
31 | #if defined(WITH_IRIX_PROJECT) || \ | ||
32 | defined(WITH_IRIX_JOBS) || \ | ||
33 | defined(WITH_IRIX_ARRAY) | ||
2 | 34 | ||
3 | void irix_setusercontext(struct passwd *pw); | 35 | void irix_setusercontext(struct passwd *pw); |
4 | 36 | ||
5 | #endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ | 37 | #endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ |
38 | |||
39 | #endif /* ! _PORT_IRIX_H */ | ||
diff --git a/openbsd-compat/readpassphrase.c b/openbsd-compat/readpassphrase.c index 4e549b62b..0d0baf569 100644 --- a/openbsd-compat/readpassphrase.c +++ b/openbsd-compat/readpassphrase.c | |||
@@ -1,34 +1,27 @@ | |||
1 | /* $OpenBSD: readpassphrase.c,v 1.14 2002/06/28 01:43:58 millert Exp $ */ | 1 | /* $OpenBSD: readpassphrase.c,v 1.16 2003/06/17 21:56:23 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2000-2002 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 2000-2002 Todd C. Miller <Todd.Miller@courtesan.com> |
5 | * All rights reserved. | ||
6 | * | 5 | * |
7 | * Redistribution and use in source and binary forms, with or without | 6 | * Permission to use, copy, modify, and distribute this software for any |
8 | * modification, are permitted provided that the following conditions | 7 | * purpose with or without fee is hereby granted, provided that the above |
9 | * are met: | 8 | * copyright notice and this permission notice appear in all copies. |
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of the author may not be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | 9 | * |
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 17 | * |
26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 18 | * Sponsored in part by the Defense Advanced Research Projects |
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 19 | * Agency (DARPA) and Air Force Research Laboratory, Air Force |
20 | * Materiel Command, USAF, under agreement number F39502-99-1-0512. | ||
28 | */ | 21 | */ |
29 | 22 | ||
30 | #if defined(LIBC_SCCS) && !defined(lint) | 23 | #if defined(LIBC_SCCS) && !defined(lint) |
31 | static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.14 2002/06/28 01:43:58 millert Exp $"; | 24 | static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.16 2003/06/17 21:56:23 millert Exp $"; |
32 | #endif /* LIBC_SCCS and not lint */ | 25 | #endif /* LIBC_SCCS and not lint */ |
33 | 26 | ||
34 | #include "includes.h" | 27 | #include "includes.h" |
@@ -185,6 +178,7 @@ getpass(const char *prompt) | |||
185 | 178 | ||
186 | static void handler(int s) | 179 | static void handler(int s) |
187 | { | 180 | { |
181 | |||
188 | signo = s; | 182 | signo = s; |
189 | } | 183 | } |
190 | #endif /* HAVE_READPASSPHRASE */ | 184 | #endif /* HAVE_READPASSPHRASE */ |
diff --git a/openbsd-compat/realpath.c b/openbsd-compat/realpath.c index b9035ca22..77da14e7c 100644 --- a/openbsd-compat/realpath.c +++ b/openbsd-compat/realpath.c | |||
@@ -13,6 +13,9 @@ | |||
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. |
16 | * 3. Neither the name of the University nor the names of its contributors | ||
17 | * may be used to endorse or promote products derived from this software | ||
18 | * without specific prior written permission. | ||
16 | * | 19 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
@@ -32,7 +35,7 @@ | |||
32 | #if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) | 35 | #if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) |
33 | 36 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char *rcsid = "$OpenBSD: realpath.c,v 1.7 2002/05/24 21:22:37 deraadt Exp $"; | 38 | static char *rcsid = "$OpenBSD: realpath.c,v 1.10 2003/08/01 21:04:59 millert Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 39 | #endif /* LIBC_SCCS and not lint */ |
37 | 40 | ||
38 | #include <sys/param.h> | 41 | #include <sys/param.h> |
@@ -62,7 +65,7 @@ char * | |||
62 | realpath(const char *path, char *resolved) | 65 | realpath(const char *path, char *resolved) |
63 | { | 66 | { |
64 | struct stat sb; | 67 | struct stat sb; |
65 | int fd, n, rootd, serrno = 0; | 68 | int fd, n, needslash, serrno = 0; |
66 | char *p, *q, wbuf[MAXPATHLEN], start[MAXPATHLEN]; | 69 | char *p, *q, wbuf[MAXPATHLEN], start[MAXPATHLEN]; |
67 | int symlinks = 0; | 70 | int symlinks = 0; |
68 | 71 | ||
@@ -138,18 +141,18 @@ loop: | |||
138 | * happens if the last component is empty, or the dirname is root. | 141 | * happens if the last component is empty, or the dirname is root. |
139 | */ | 142 | */ |
140 | if (resolved[0] == '/' && resolved[1] == '\0') | 143 | if (resolved[0] == '/' && resolved[1] == '\0') |
141 | rootd = 1; | 144 | needslash = 0; |
142 | else | 145 | else |
143 | rootd = 0; | 146 | needslash = 1; |
144 | 147 | ||
145 | if (*wbuf) { | 148 | if (*wbuf) { |
146 | if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) { | 149 | if (strlen(resolved) + strlen(wbuf) + needslash >= MAXPATHLEN) { |
147 | serrno = ENAMETOOLONG; | 150 | serrno = ENAMETOOLONG; |
148 | goto err1; | 151 | goto err1; |
149 | } | 152 | } |
150 | if (rootd == 0) | 153 | if (needslash == 0) |
151 | (void)strcat(resolved, "/"); | 154 | strlcat(resolved, "/", MAXPATHLEN); |
152 | (void)strcat(resolved, wbuf); | 155 | strlcat(resolved, wbuf, MAXPATHLEN); |
153 | } | 156 | } |
154 | 157 | ||
155 | /* Go back to where we came from. */ | 158 | /* Go back to where we came from. */ |
diff --git a/openbsd-compat/realpath.h b/openbsd-compat/realpath.h deleted file mode 100644 index 25e4075d7..000000000 --- a/openbsd-compat/realpath.h +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | /* $Id: realpath.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_REALPATH_H | ||
4 | #define _BSD_REALPATH_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) | ||
9 | |||
10 | char *realpath(const char *path, char *resolved); | ||
11 | |||
12 | #endif /* !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) */ | ||
13 | #endif /* _BSD_REALPATH_H */ | ||
diff --git a/openbsd-compat/rresvport.c b/openbsd-compat/rresvport.c index 9f058961d..608a3b184 100644 --- a/openbsd-compat/rresvport.c +++ b/openbsd-compat/rresvport.c | |||
@@ -11,12 +11,7 @@ | |||
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * 3. All advertising materials mentioning features or use of this software | 14 | * 3. Neither the name of the University nor the names of its contributors |
15 | * must display the following acknowledgement: | ||
16 | * This product includes software developed by the University of | ||
17 | * California, Berkeley and its contributors. | ||
18 | * This product includes software developed by Theo de Raadt. | ||
19 | * 4. 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 | 15 | * may be used to endorse or promote products derived from this software |
21 | * without specific prior written permission. | 16 | * without specific prior written permission. |
22 | * | 17 | * |
@@ -38,7 +33,7 @@ | |||
38 | #ifndef HAVE_RRESVPORT_AF | 33 | #ifndef HAVE_RRESVPORT_AF |
39 | 34 | ||
40 | #if defined(LIBC_SCCS) && !defined(lint) | 35 | #if defined(LIBC_SCCS) && !defined(lint) |
41 | static char *rcsid = "$OpenBSD: rresvport.c,v 1.5 2000/01/26 03:43:20 deraadt Exp $"; | 36 | static char *rcsid = "$OpenBSD: rresvport.c,v 1.6 2003/06/03 02:11:35 deraadt Exp $"; |
42 | #endif /* LIBC_SCCS and not lint */ | 37 | #endif /* LIBC_SCCS and not lint */ |
43 | 38 | ||
44 | #include "includes.h" | 39 | #include "includes.h" |
diff --git a/openbsd-compat/rresvport.h b/openbsd-compat/rresvport.h deleted file mode 100644 index a52e4515b..000000000 --- a/openbsd-compat/rresvport.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: rresvport.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_RRESVPORT_H | ||
4 | #define _BSD_RRESVPORT_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_RRESVPORT_AF | ||
9 | int rresvport_af(int *alport, sa_family_t af); | ||
10 | #endif /* !HAVE_RRESVPORT_AF */ | ||
11 | |||
12 | #endif /* _BSD_RRESVPORT_H */ | ||
diff --git a/openbsd-compat/setenv.c b/openbsd-compat/setenv.c index e5c5de62e..c9941c195 100644 --- a/openbsd-compat/setenv.c +++ b/openbsd-compat/setenv.c | |||
@@ -10,11 +10,7 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
14 | * must display the following acknowledgement: | ||
15 | * This product includes software developed by the University of | ||
16 | * California, Berkeley and its contributors. | ||
17 | * 4. Neither the name of the University nor the names of its contributors | ||
18 | * 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 |
19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
20 | * | 16 | * |
@@ -35,7 +31,7 @@ | |||
35 | #ifndef HAVE_SETENV | 31 | #ifndef HAVE_SETENV |
36 | 32 | ||
37 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | static char *rcsid = "$OpenBSD: setenv.c,v 1.5 2002/12/10 22:44:13 mickey Exp $"; | 34 | static char *rcsid = "$OpenBSD: setenv.c,v 1.6 2003/06/02 20:18:38 millert Exp $"; |
39 | #endif /* LIBC_SCCS and not lint */ | 35 | #endif /* LIBC_SCCS and not lint */ |
40 | 36 | ||
41 | #include <stdlib.h> | 37 | #include <stdlib.h> |
diff --git a/openbsd-compat/setenv.h b/openbsd-compat/setenv.h deleted file mode 100644 index 77256d802..000000000 --- a/openbsd-compat/setenv.h +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | /* $Id: setenv.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_SETENV_H | ||
4 | #define _BSD_SETENV_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_SETENV | ||
9 | |||
10 | int setenv(register const char *name, register const char *value, int rewrite); | ||
11 | |||
12 | #endif /* !HAVE_SETENV */ | ||
13 | |||
14 | #endif /* _BSD_SETENV_H */ | ||
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c index 07af7e9c0..b41100fc6 100644 --- a/openbsd-compat/setproctitle.c +++ b/openbsd-compat/setproctitle.c | |||
@@ -1,41 +1,34 @@ | |||
1 | /* | 1 | /* Based on conf.c from UCB sendmail 8.8.8 */ |
2 | * Based on src/backend/utils/misc/pg_status.c from | ||
3 | * PostgreSQL Database Management System | ||
4 | * | ||
5 | * Portions Copyright (c) 1996-2001, The PostgreSQL Global Development Group | ||
6 | * | ||
7 | * Portions Copyright (c) 1994, The Regents of the University of California | ||
8 | * | ||
9 | * Permission to use, copy, modify, and distribute this software and its | ||
10 | * documentation for any purpose, without fee, and without a written agreement | ||
11 | * is hereby granted, provided that the above copyright notice and this | ||
12 | * paragraph and the following two paragraphs appear in all copies. | ||
13 | * | ||
14 | * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR | ||
15 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING | ||
16 | * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS | ||
17 | * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE | ||
18 | * POSSIBILITY OF SUCH DAMAGE. | ||
19 | * | ||
20 | * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, | ||
21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
22 | * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS | ||
23 | * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO | ||
24 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | ||
25 | */ | ||
26 | 2 | ||
27 | /*-------------------------------------------------------------------- | 3 | /* |
28 | * ps_status.c | 4 | * Copyright 2003 Damien Miller |
29 | * | 5 | * Copyright (c) 1983, 1995-1997 Eric P. Allman |
30 | * Routines to support changing the ps display of PostgreSQL backends | 6 | * Copyright (c) 1988, 1993 |
31 | * to contain some useful information. Mechanism differs wildly across | 7 | * The Regents of the University of California. All rights reserved. |
32 | * platforms. | ||
33 | * | 8 | * |
34 | * $Header: /var/cvs/openssh/openbsd-compat/setproctitle.c,v 1.5 2003/01/20 02:15:11 djm Exp $ | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
35 | * | 20 | * |
36 | * Copyright 2000 by PostgreSQL Global Development Group | 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
37 | * various details abducted from various places | 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
38 | *-------------------------------------------------------------------- | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
39 | */ | 32 | */ |
40 | 33 | ||
41 | #include "includes.h" | 34 | #include "includes.h" |
@@ -44,200 +37,121 @@ | |||
44 | 37 | ||
45 | #include <unistd.h> | 38 | #include <unistd.h> |
46 | #ifdef HAVE_SYS_PSTAT_H | 39 | #ifdef HAVE_SYS_PSTAT_H |
47 | #include <sys/pstat.h> /* for HP-UX */ | 40 | #include <sys/pstat.h> |
48 | #endif | ||
49 | #ifdef HAVE_PS_STRINGS | ||
50 | #include <machine/vmparam.h> /* for old BSD */ | ||
51 | #include <sys/exec.h> | ||
52 | #endif | 41 | #endif |
53 | 42 | ||
54 | /*------ | 43 | #define SPT_NONE 0 /* don't use it at all */ |
55 | * Alternative ways of updating ps display: | 44 | #define SPT_PSTAT 1 /* cover argv with title information */ |
56 | * | 45 | #define SPT_REUSEARGV 2 /* use pstat(PSTAT_SETCMD, ...) */ |
57 | * SETPROCTITLE_STRATEGY == PS_USE_PSTAT | ||
58 | * use the pstat(PSTAT_SETCMD, ) | ||
59 | * (HPUX) | ||
60 | * SETPROCTITLE_STRATEGY == PS_USE_PS_STRINGS | ||
61 | * assign PS_STRINGS->ps_argvstr = "string" | ||
62 | * (some BSD systems) | ||
63 | * SETPROCTITLE_STRATEGY == PS_USE_CHANGE_ARGV | ||
64 | * assign argv[0] = "string" | ||
65 | * (some other BSD systems) | ||
66 | * SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV | ||
67 | * write over the argv and environment area | ||
68 | * (most SysV-like systems) | ||
69 | * SETPROCTITLE_STRATEGY == PS_USE_NONE | ||
70 | * don't update ps display | ||
71 | * (This is the default, as it is safest.) | ||
72 | */ | ||
73 | 46 | ||
74 | #define PS_USE_NONE 0 | 47 | #ifndef SPT_TYPE |
75 | #define PS_USE_PSTAT 1 | 48 | # define SPT_TYPE SPT_NONE |
76 | #define PS_USE_PS_STRINGS 2 | ||
77 | #define PS_USE_CHANGE_ARGV 3 | ||
78 | #define PS_USE_CLOBBER_ARGV 4 | ||
79 | |||
80 | #ifndef SETPROCTITLE_STRATEGY | ||
81 | # define SETPROCTITLE_STRATEGY PS_USE_NONE | ||
82 | #endif | 49 | #endif |
83 | 50 | ||
84 | #ifndef SETPROCTITLE_PS_PADDING | 51 | #ifndef SPT_PADCHAR |
85 | # define SETPROCTITLE_PS_PADDING ' ' | 52 | # define SPT_PADCHAR '\0' |
86 | #endif | 53 | #endif |
87 | #endif /* HAVE_SETPROCTITLE */ | ||
88 | 54 | ||
89 | extern char **environ; | 55 | #if SPT_TYPE == SPT_REUSEARGV |
90 | 56 | static char *argv_start = NULL; | |
91 | /* | 57 | static size_t argv_env_len = 0; |
92 | * argv clobbering uses existing argv space, all other methods need a buffer | ||
93 | */ | ||
94 | #if SETPROCTITLE_STRATEGY != PS_USE_CLOBBER_ARGV | ||
95 | static char ps_buffer[256]; | ||
96 | static const size_t ps_buffer_size = sizeof(ps_buffer); | ||
97 | #else | ||
98 | static char *ps_buffer; /* will point to argv area */ | ||
99 | static size_t ps_buffer_size; /* space determined at run time */ | ||
100 | #endif | 58 | #endif |
101 | 59 | ||
102 | /* save the original argv[] location here */ | 60 | #endif /* HAVE_SETPROCTITLE */ |
103 | static int save_argc; | ||
104 | static char **save_argv; | ||
105 | |||
106 | extern char *__progname; | ||
107 | 61 | ||
108 | #ifndef HAVE_SETPROCTITLE | ||
109 | /* | ||
110 | * Call this to update the ps status display to a fixed prefix plus an | ||
111 | * indication of what you're currently doing passed in the argument. | ||
112 | */ | ||
113 | void | 62 | void |
114 | setproctitle(const char *fmt, ...) | 63 | compat_init_setproctitle(int argc, char *argv[]) |
115 | { | 64 | { |
116 | #if SETPROCTITLE_STRATEGY == PS_USE_PSTAT | 65 | #if defined(SPT_TYPE) && SPT_TYPE == SPT_REUSEARGV |
117 | union pstun pst; | 66 | extern char **environ; |
118 | #endif | 67 | char *lastargv = NULL; |
119 | #if SETPROCTITLE_STRATEGY != PS_USE_NONE | 68 | char **envp = environ; |
120 | ssize_t used; | 69 | int i; |
121 | va_list ap; | ||
122 | |||
123 | /* no ps display if you didn't call save_ps_display_args() */ | ||
124 | if (save_argv == NULL) | ||
125 | return; | ||
126 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV | ||
127 | /* If ps_buffer is a pointer, it might still be null */ | ||
128 | if (ps_buffer == NULL) | ||
129 | return; | ||
130 | #endif /* PS_USE_CLOBBER_ARGV */ | ||
131 | 70 | ||
132 | /* | 71 | /* |
133 | * Overwrite argv[] to point at appropriate space, if needed | 72 | * NB: This assumes that argv has already been copied out of the |
73 | * way. This is true for sshd, but may not be true for other | ||
74 | * programs. Beware. | ||
134 | */ | 75 | */ |
135 | #if SETPROCTITLE_STRATEGY == PS_USE_CHANGE_ARGV | ||
136 | save_argv[0] = ps_buffer; | ||
137 | save_argv[1] = NULL; | ||
138 | #endif /* PS_USE_CHANGE_ARGV */ | ||
139 | 76 | ||
140 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV | 77 | if (argc == 0 || argv[0] == NULL) |
141 | save_argv[1] = NULL; | 78 | return; |
142 | #endif /* PS_USE_CLOBBER_ARGV */ | 79 | |
80 | /* Fail if we can't allocate room for the new environment */ | ||
81 | for (i = 0; envp[i] != NULL; i++) | ||
82 | ; | ||
83 | if ((environ = malloc(sizeof(*environ) * (i + 1))) == NULL) { | ||
84 | environ = envp; /* put it back */ | ||
85 | return; | ||
86 | } | ||
143 | 87 | ||
144 | /* | 88 | /* |
145 | * Make fixed prefix of ps display. | 89 | * Find the last argv string or environment variable within |
90 | * our process memory area. | ||
146 | */ | 91 | */ |
147 | 92 | for (i = 0; i < argc; i++) { | |
148 | va_start(ap, fmt); | 93 | if (lastargv == NULL || lastargv + 1 == argv[i]) |
149 | if (fmt == NULL) | 94 | lastargv = argv[i] + strlen(argv[i]); |
150 | snprintf(ps_buffer, ps_buffer_size, "%s", __progname); | 95 | } |
151 | else { | 96 | for (i = 0; envp[i] != NULL; i++) { |
152 | used = snprintf(ps_buffer, ps_buffer_size, "%s: ", __progname); | 97 | if (lastargv + 1 == envp[i]) |
153 | if (used == -1 || used >= ps_buffer_size) | 98 | lastargv = envp[i] + strlen(envp[i]); |
154 | used = ps_buffer_size; | ||
155 | vsnprintf(ps_buffer + used, ps_buffer_size - used, fmt, ap); | ||
156 | } | 99 | } |
157 | va_end(ap); | ||
158 | |||
159 | #if SETPROCTITLE_STRATEGY == PS_USE_PSTAT | ||
160 | pst.pst_command = ps_buffer; | ||
161 | pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0); | ||
162 | #endif /* PS_USE_PSTAT */ | ||
163 | |||
164 | #if SETPROCTITLE_STRATEGY == PS_USE_PS_STRINGS | ||
165 | PS_STRINGS->ps_nargvstr = 1; | ||
166 | PS_STRINGS->ps_argvstr = ps_buffer; | ||
167 | #endif /* PS_USE_PS_STRINGS */ | ||
168 | 100 | ||
169 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV | 101 | argv[1] = NULL; |
170 | /* pad unused memory */ | 102 | argv_start = argv[0]; |
171 | used = strlen(ps_buffer); | 103 | argv_env_len = lastargv - argv[0] - 1; |
172 | memset(ps_buffer + used, SETPROCTITLE_PS_PADDING, | ||
173 | ps_buffer_size - used); | ||
174 | #endif /* PS_USE_CLOBBER_ARGV */ | ||
175 | 104 | ||
176 | #endif /* PS_USE_NONE */ | 105 | /* |
106 | * Copy environment | ||
107 | * XXX - will truncate env on strdup fail | ||
108 | */ | ||
109 | for (i = 0; envp[i] != NULL; i++) | ||
110 | environ[i] = strdup(envp[i]); | ||
111 | environ[i] = NULL; | ||
112 | #endif /* SPT_REUSEARGV */ | ||
177 | } | 113 | } |
178 | 114 | ||
179 | #endif /* HAVE_SETPROCTITLE */ | 115 | #ifndef HAVE_SETPROCTITLE |
180 | |||
181 | /* | ||
182 | * Call this early in startup to save the original argc/argv values. | ||
183 | * | ||
184 | * argv[] will not be overwritten by this routine, but may be overwritten | ||
185 | * during setproctitle. Also, the physical location of the environment | ||
186 | * strings may be moved, so this should be called before any code that | ||
187 | * might try to hang onto a getenv() result. | ||
188 | */ | ||
189 | void | 116 | void |
190 | compat_init_setproctitle(int argc, char *argv[]) | 117 | setproctitle(const char *fmt, ...) |
191 | { | 118 | { |
192 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV | 119 | #if SPT_TYPE != SPT_NONE |
193 | char *end_of_area = NULL; | 120 | va_list ap; |
194 | char **new_environ; | 121 | char buf[1024]; |
195 | int i; | 122 | size_t len; |
123 | extern char *__progname; | ||
124 | #if SPT_TYPE == SPT_PSTAT | ||
125 | union pstun pst; | ||
196 | #endif | 126 | #endif |
197 | 127 | ||
198 | save_argc = argc; | 128 | #if SPT_TYPE == SPT_REUSEARGV |
199 | save_argv = argv; | 129 | if (argv_env_len <= 0) |
200 | |||
201 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV | ||
202 | /* | ||
203 | * If we're going to overwrite the argv area, count the available | ||
204 | * space. Also move the environment to make additional room. | ||
205 | */ | ||
206 | |||
207 | /* | ||
208 | * check for contiguous argv strings | ||
209 | */ | ||
210 | for (i = 0; i < argc; i++) { | ||
211 | if (i == 0 || end_of_area + 1 == argv[i]) | ||
212 | end_of_area = argv[i] + strlen(argv[i]); | ||
213 | } | ||
214 | |||
215 | /* probably can't happen? */ | ||
216 | if (end_of_area == NULL) { | ||
217 | ps_buffer = NULL; | ||
218 | ps_buffer_size = 0; | ||
219 | return; | 130 | return; |
220 | } | 131 | #endif |
221 | 132 | ||
222 | /* | 133 | strlcpy(buf, __progname, sizeof(buf)); |
223 | * check for contiguous environ strings following argv | 134 | |
224 | */ | 135 | va_start(ap, fmt); |
225 | for (i = 0; environ[i] != NULL; i++) { | 136 | if (fmt != NULL) { |
226 | if (end_of_area + 1 == environ[i]) | 137 | len = strlcat(buf, ": ", sizeof(buf)); |
227 | end_of_area = environ[i] + strlen(environ[i]); | 138 | if (len < sizeof(buf)) |
139 | vsnprintf(buf + len, sizeof(buf) - len , fmt, ap); | ||
228 | } | 140 | } |
141 | va_end(ap); | ||
229 | 142 | ||
230 | ps_buffer = argv[0]; | 143 | #if SPT_TYPE == SPT_PSTAT |
231 | ps_buffer_size = end_of_area - argv[0] - 1; | 144 | pst.pst_command = buf; |
145 | pstat(PSTAT_SETCMD, pst, strlen(buf), 0, 0); | ||
146 | #elif SPT_TYPE == SPT_REUSEARGV | ||
147 | /* debug("setproctitle: copy \"%s\" into len %d", | ||
148 | buf, argv_env_len); */ | ||
149 | len = strlcpy(argv_start, buf, argv_env_len); | ||
150 | for(; len < argv_env_len; len++) | ||
151 | argv_start[len] = SPT_PADCHAR; | ||
152 | #endif | ||
232 | 153 | ||
233 | /* | 154 | #endif /* SPT_NONE */ |
234 | * Duplicate and move the environment out of the way | ||
235 | */ | ||
236 | new_environ = malloc(sizeof(char *) * (i + 1)); | ||
237 | for (i = 0; environ[i] != NULL; i++) | ||
238 | new_environ[i] = strdup(environ[i]); | ||
239 | new_environ[i] = NULL; | ||
240 | environ = new_environ; | ||
241 | #endif /* PS_USE_CLOBBER_ARGV */ | ||
242 | } | 155 | } |
243 | 156 | ||
157 | #endif /* HAVE_SETPROCTITLE */ | ||
diff --git a/openbsd-compat/setproctitle.h b/openbsd-compat/setproctitle.h deleted file mode 100644 index 48d26c6ea..000000000 --- a/openbsd-compat/setproctitle.h +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | /* $Id: setproctitle.h,v 1.3 2003/01/09 22:53:13 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_SETPROCTITLE_H | ||
4 | #define _BSD_SETPROCTITLE_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_SETPROCTITLE | ||
9 | void setproctitle(const char *fmt, ...); | ||
10 | void compat_init_setproctitle(int argc, char *argv[]); | ||
11 | #endif | ||
12 | |||
13 | #endif /* _BSD_SETPROCTITLE_H */ | ||
diff --git a/openbsd-compat/strlcat.c b/openbsd-compat/strlcat.c index 3a9b5d1a7..cae16657c 100644 --- a/openbsd-compat/strlcat.c +++ b/openbsd-compat/strlcat.c | |||
@@ -1,42 +1,30 @@ | |||
1 | /* $OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $ */ | 1 | /* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
5 | * All rights reserved. | ||
6 | * | 5 | * |
7 | * Redistribution and use in source and binary forms, with or without | 6 | * Permission to use, copy, modify, and distribute this software for any |
8 | * modification, are permitted provided that the following conditions | 7 | * purpose with or without fee is hereby granted, provided that the above |
9 | * are met: | 8 | * copyright notice and this permission notice appear in all copies. |
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of the author may not be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | 9 | * |
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | 17 | */ |
29 | 18 | ||
30 | #include "includes.h" | 19 | #include "includes.h" |
31 | #ifndef HAVE_STRLCAT | 20 | #ifndef HAVE_STRLCAT |
32 | 21 | ||
33 | #if defined(LIBC_SCCS) && !defined(lint) | 22 | #if defined(LIBC_SCCS) && !defined(lint) |
34 | static char *rcsid = "$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $"; | 23 | static char *rcsid = "$OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $"; |
35 | #endif /* LIBC_SCCS and not lint */ | 24 | #endif /* LIBC_SCCS and not lint */ |
36 | 25 | ||
37 | #include <sys/types.h> | 26 | #include <sys/types.h> |
38 | #include <string.h> | 27 | #include <string.h> |
39 | #include "strlcat.h" | ||
40 | 28 | ||
41 | /* | 29 | /* |
42 | * Appends src to string dst of size siz (unlike strncat, siz is the | 30 | * Appends src to string dst of size siz (unlike strncat, siz is the |
@@ -46,10 +34,7 @@ static char *rcsid = "$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp | |||
46 | * If retval >= siz, truncation occurred. | 34 | * If retval >= siz, truncation occurred. |
47 | */ | 35 | */ |
48 | size_t | 36 | size_t |
49 | strlcat(dst, src, siz) | 37 | strlcat(char *dst, const char *src, size_t siz) |
50 | char *dst; | ||
51 | const char *src; | ||
52 | size_t siz; | ||
53 | { | 38 | { |
54 | register char *d = dst; | 39 | register char *d = dst; |
55 | register const char *s = src; | 40 | register const char *s = src; |
diff --git a/openbsd-compat/strlcat.h b/openbsd-compat/strlcat.h deleted file mode 100644 index 753668563..000000000 --- a/openbsd-compat/strlcat.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: strlcat.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_STRLCAT_H | ||
4 | #define _BSD_STRLCAT_H | ||
5 | |||
6 | #include "config.h" | ||
7 | #ifndef HAVE_STRLCAT | ||
8 | #include <sys/types.h> | ||
9 | size_t strlcat(char *dst, const char *src, size_t siz); | ||
10 | #endif /* !HAVE_STRLCAT */ | ||
11 | |||
12 | #endif /* _BSD_STRLCAT_H */ | ||
diff --git a/openbsd-compat/strlcpy.c b/openbsd-compat/strlcpy.c index 2f87eca44..c8fe29987 100644 --- a/openbsd-compat/strlcpy.c +++ b/openbsd-compat/strlcpy.c | |||
@@ -1,42 +1,30 @@ | |||
1 | /* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $ */ | 1 | /* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
5 | * All rights reserved. | ||
6 | * | 5 | * |
7 | * Redistribution and use in source and binary forms, with or without | 6 | * Permission to use, copy, modify, and distribute this software for any |
8 | * modification, are permitted provided that the following conditions | 7 | * purpose with or without fee is hereby granted, provided that the above |
9 | * are met: | 8 | * copyright notice and this permission notice appear in all copies. |
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of the author may not be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | 9 | * |
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | 17 | */ |
29 | 18 | ||
30 | #include "includes.h" | 19 | #include "includes.h" |
31 | #ifndef HAVE_STRLCPY | 20 | #ifndef HAVE_STRLCPY |
32 | 21 | ||
33 | #if defined(LIBC_SCCS) && !defined(lint) | 22 | #if defined(LIBC_SCCS) && !defined(lint) |
34 | static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $"; | 23 | static char *rcsid = "$OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $"; |
35 | #endif /* LIBC_SCCS and not lint */ | 24 | #endif /* LIBC_SCCS and not lint */ |
36 | 25 | ||
37 | #include <sys/types.h> | 26 | #include <sys/types.h> |
38 | #include <string.h> | 27 | #include <string.h> |
39 | #include "strlcpy.h" | ||
40 | 28 | ||
41 | /* | 29 | /* |
42 | * Copy src to string dst of size siz. At most siz-1 characters | 30 | * Copy src to string dst of size siz. At most siz-1 characters |
@@ -44,10 +32,7 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp | |||
44 | * Returns strlen(src); if retval >= siz, truncation occurred. | 32 | * Returns strlen(src); if retval >= siz, truncation occurred. |
45 | */ | 33 | */ |
46 | size_t | 34 | size_t |
47 | strlcpy(dst, src, siz) | 35 | strlcpy(char *dst, const char *src, size_t siz) |
48 | char *dst; | ||
49 | const char *src; | ||
50 | size_t siz; | ||
51 | { | 36 | { |
52 | register char *d = dst; | 37 | register char *d = dst; |
53 | register const char *s = src; | 38 | register const char *s = src; |
diff --git a/openbsd-compat/strlcpy.h b/openbsd-compat/strlcpy.h deleted file mode 100644 index 3b137670d..000000000 --- a/openbsd-compat/strlcpy.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: strlcpy.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_STRLCPY_H | ||
4 | #define _BSD_STRLCPY_H | ||
5 | |||
6 | #include "config.h" | ||
7 | #ifndef HAVE_STRLCPY | ||
8 | #include <sys/types.h> | ||
9 | size_t strlcpy(char *dst, const char *src, size_t siz); | ||
10 | #endif /* !HAVE_STRLCPY */ | ||
11 | |||
12 | #endif /* _BSD_STRLCPY_H */ | ||
diff --git a/openbsd-compat/strmode.c b/openbsd-compat/strmode.c index e64d19869..adf5e273e 100644 --- a/openbsd-compat/strmode.c +++ b/openbsd-compat/strmode.c | |||
@@ -10,11 +10,7 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
14 | * must display the following acknowledgement: | ||
15 | * This product includes software developed by the University of | ||
16 | * California, Berkeley and its contributors. | ||
17 | * 4. Neither the name of the University nor the names of its contributors | ||
18 | * 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 |
19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
20 | * | 16 | * |
@@ -35,15 +31,17 @@ | |||
35 | #ifndef HAVE_STRMODE | 31 | #ifndef HAVE_STRMODE |
36 | 32 | ||
37 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | static char *rcsid = "$OpenBSD: strmode.c,v 1.3 1997/06/13 13:57:20 deraadt Exp $"; | 34 | static char *rcsid = "$OpenBSD: strmode.c,v 1.5 2003/06/11 21:08:16 deraadt Exp $"; |
39 | #endif /* LIBC_SCCS and not lint */ | 35 | #endif /* LIBC_SCCS and not lint */ |
40 | 36 | ||
41 | #include <sys/types.h> | 37 | #include <sys/types.h> |
42 | #include <sys/stat.h> | 38 | #include <sys/stat.h> |
43 | #include <string.h> | 39 | #include <string.h> |
44 | 40 | ||
41 | /* XXX mode should be mode_t */ | ||
42 | |||
45 | void | 43 | void |
46 | strmode(register mode_t mode, register char *p) | 44 | strmode(int mode, char *p) |
47 | { | 45 | { |
48 | /* print type */ | 46 | /* print type */ |
49 | switch (mode & S_IFMT) { | 47 | switch (mode & S_IFMT) { |
diff --git a/openbsd-compat/strmode.h b/openbsd-compat/strmode.h deleted file mode 100644 index 64f7c8aae..000000000 --- a/openbsd-compat/strmode.h +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | /* $Id: strmode.h,v 1.3 2001/06/09 02:22:17 mouring Exp $ */ | ||
2 | |||
3 | #ifndef HAVE_STRMODE | ||
4 | |||
5 | void strmode(register mode_t mode, register char *p); | ||
6 | |||
7 | #endif | ||
diff --git a/openbsd-compat/strsep.c b/openbsd-compat/strsep.c index d0afc44ae..b13671343 100644 --- a/openbsd-compat/strsep.c +++ b/openbsd-compat/strsep.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: strsep.c,v 1.3 1997/08/20 04:28:14 millert Exp $ */ | 1 | /* $OpenBSD: strsep.c,v 1.5 2003/06/11 21:08:16 deraadt Exp $ */ |
2 | 2 | ||
3 | /*- | 3 | /*- |
4 | * Copyright (c) 1990, 1993 | 4 | * Copyright (c) 1990, 1993 |
@@ -12,11 +12,7 @@ | |||
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. |
15 | * 3. All advertising materials mentioning features or use of this software | 15 | * 3. Neither the name of the University nor the names of its contributors |
16 | * must display the following acknowledgement: | ||
17 | * This product includes software developed by the University of | ||
18 | * California, Berkeley and its contributors. | ||
19 | * 4. 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 | 16 | * may be used to endorse or promote products derived from this software |
21 | * without specific prior written permission. | 17 | * without specific prior written permission. |
22 | * | 18 | * |
@@ -44,7 +40,7 @@ | |||
44 | #if 0 | 40 | #if 0 |
45 | static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93"; | 41 | static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93"; |
46 | #else | 42 | #else |
47 | static char *rcsid = "$OpenBSD: strsep.c,v 1.3 1997/08/20 04:28:14 millert Exp $"; | 43 | static char *rcsid = "$OpenBSD: strsep.c,v 1.5 2003/06/11 21:08:16 deraadt Exp $"; |
48 | #endif | 44 | #endif |
49 | #endif /* LIBC_SCCS and not lint */ | 45 | #endif /* LIBC_SCCS and not lint */ |
50 | 46 | ||
@@ -62,9 +58,9 @@ static char *rcsid = "$OpenBSD: strsep.c,v 1.3 1997/08/20 04:28:14 millert Exp $ | |||
62 | char * | 58 | char * |
63 | strsep(char **stringp, const char *delim) | 59 | strsep(char **stringp, const char *delim) |
64 | { | 60 | { |
65 | register char *s; | 61 | char *s; |
66 | register const char *spanp; | 62 | const char *spanp; |
67 | register int c, sc; | 63 | int c, sc; |
68 | char *tok; | 64 | char *tok; |
69 | 65 | ||
70 | if ((s = *stringp) == NULL) | 66 | if ((s = *stringp) == NULL) |
diff --git a/openbsd-compat/strsep.h b/openbsd-compat/strsep.h deleted file mode 100644 index 6ed810ac1..000000000 --- a/openbsd-compat/strsep.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id: strsep.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ | ||
2 | |||
3 | #ifndef _BSD_STRSEP_H | ||
4 | #define _BSD_STRSEP_H | ||
5 | |||
6 | #include "config.h" | ||
7 | |||
8 | #ifndef HAVE_STRSEP | ||
9 | char *strsep(char **stringp, const char *delim); | ||
10 | #endif /* HAVE_STRSEP */ | ||
11 | |||
12 | #endif /* _BSD_STRSEP_H */ | ||
diff --git a/openbsd-compat/sys-queue.h b/openbsd-compat/sys-queue.h index 176fe3174..dd5c47525 100644 --- a/openbsd-compat/sys-queue.h +++ b/openbsd-compat/sys-queue.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: queue.h,v 1.22 2001/06/23 04:39:35 angelos Exp $ */ | 1 | /* $OpenBSD: queue.h,v 1.23 2003/06/02 23:28:21 millert Exp $ */ |
2 | /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ | 2 | /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ |
3 | 3 | ||
4 | /* | 4 | /* |
@@ -13,11 +13,7 @@ | |||
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. |
16 | * 3. All advertising materials mentioning features or use of this software | 16 | * 3. Neither the name of the University nor the names of its contributors |
17 | * must display the following acknowledgement: | ||
18 | * This product includes software developed by the University of | ||
19 | * California, Berkeley and its contributors. | ||
20 | * 4. Neither the name of the University nor the names of its contributors | ||
21 | * may be used to endorse or promote products derived from this software | 17 | * may be used to endorse or promote products derived from this software |
22 | * without specific prior written permission. | 18 | * without specific prior written permission. |
23 | * | 19 | * |
diff --git a/openbsd-compat/vis.c b/openbsd-compat/vis.c index fc5741390..e6a2ce98d 100644 --- a/openbsd-compat/vis.c +++ b/openbsd-compat/vis.c | |||
@@ -10,11 +10,7 @@ | |||
10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
14 | * must display the following acknowledgement: | ||
15 | * This product includes software developed by the University of | ||
16 | * California, Berkeley and its contributors. | ||
17 | * 4. Neither the name of the University nor the names of its contributors | ||
18 | * 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 |
19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
20 | * | 16 | * |
@@ -30,14 +26,15 @@ | |||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
31 | * SUCH DAMAGE. | 27 | * SUCH DAMAGE. |
32 | */ | 28 | */ |
33 | #include "config.h" | 29 | #include "includes.h" |
34 | #if !defined(HAVE_STRNVIS) | 30 | #if !defined(HAVE_STRNVIS) |
35 | 31 | ||
36 | #if defined(LIBC_SCCS) && !defined(lint) | 32 | #if defined(LIBC_SCCS) && !defined(lint) |
37 | static char rcsid[] = "$OpenBSD: vis.c,v 1.8 2002/02/19 19:39:36 millert Exp $"; | 33 | static char rcsid[] = "$OpenBSD: vis.c,v 1.12 2003/06/02 20:18:35 millert Exp $"; |
38 | #endif /* LIBC_SCCS and not lint */ | 34 | #endif /* LIBC_SCCS and not lint */ |
39 | 35 | ||
40 | #include <ctype.h> | 36 | #include <ctype.h> |
37 | #include <string.h> | ||
41 | 38 | ||
42 | #include "vis.h" | 39 | #include "vis.h" |
43 | 40 | ||
@@ -47,8 +44,9 @@ static char rcsid[] = "$OpenBSD: vis.c,v 1.8 2002/02/19 19:39:36 millert Exp $"; | |||
47 | ((flag & VIS_SP) == 0 && (c) == ' ') || \ | 44 | ((flag & VIS_SP) == 0 && (c) == ' ') || \ |
48 | ((flag & VIS_TAB) == 0 && (c) == '\t') || \ | 45 | ((flag & VIS_TAB) == 0 && (c) == '\t') || \ |
49 | ((flag & VIS_NL) == 0 && (c) == '\n') || \ | 46 | ((flag & VIS_NL) == 0 && (c) == '\n') || \ |
50 | ((flag & VIS_SAFE) && \ | 47 | ((flag & VIS_SAFE) && ((c) == '\b' || \ |
51 | ((c) == '\b' || (c) == '\007' || (c) == '\r'))) | 48 | (c) == '\007' || (c) == '\r' || \ |
49 | isgraph((u_char)(c))))) | ||
52 | 50 | ||
53 | /* | 51 | /* |
54 | * vis - visually encode characters | 52 | * vis - visually encode characters |
@@ -169,16 +167,20 @@ strvis(dst, src, flag) | |||
169 | 167 | ||
170 | int | 168 | int |
171 | strnvis(dst, src, siz, flag) | 169 | strnvis(dst, src, siz, flag) |
172 | register char *dst; | 170 | char *dst; |
173 | register const char *src; | 171 | const char *src; |
174 | size_t siz; | 172 | size_t siz; |
175 | int flag; | 173 | int flag; |
176 | { | 174 | { |
177 | register char c; | 175 | char c; |
178 | char *start, *end; | 176 | char *start, *end; |
177 | char tbuf[5]; | ||
178 | int i; | ||
179 | 179 | ||
180 | i = 0; | ||
180 | for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) { | 181 | for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) { |
181 | if (isvisible(c)) { | 182 | if (isvisible(c)) { |
183 | i = 1; | ||
182 | *dst++ = c; | 184 | *dst++ = c; |
183 | if (c == '\\' && (flag & VIS_NOSLASH) == 0) { | 185 | if (c == '\\' && (flag & VIS_NOSLASH) == 0) { |
184 | /* need space for the extra '\\' */ | 186 | /* need space for the extra '\\' */ |
@@ -186,22 +188,25 @@ strnvis(dst, src, siz, flag) | |||
186 | *dst++ = '\\'; | 188 | *dst++ = '\\'; |
187 | else { | 189 | else { |
188 | dst--; | 190 | dst--; |
191 | i = 2; | ||
189 | break; | 192 | break; |
190 | } | 193 | } |
191 | } | 194 | } |
192 | src++; | 195 | src++; |
193 | } else { | 196 | } else { |
194 | /* vis(3) requires up to 4 chars */ | 197 | i = vis(tbuf, c, flag, *++src) - tbuf; |
195 | if (dst + 3 < end) | 198 | if (dst + i <= end) { |
196 | dst = vis(dst, c, flag, *++src); | 199 | memcpy(dst, tbuf, i); |
197 | else | 200 | dst += i; |
201 | } else { | ||
202 | src--; | ||
198 | break; | 203 | break; |
204 | } | ||
199 | } | 205 | } |
200 | } | 206 | } |
201 | *dst = '\0'; | 207 | if (siz > 0) |
202 | if (dst >= end) { | 208 | *dst = '\0'; |
203 | char tbuf[5]; | 209 | if (dst + i > end) { |
204 | |||
205 | /* adjust return value for truncation */ | 210 | /* adjust return value for truncation */ |
206 | while ((c = *src)) | 211 | while ((c = *src)) |
207 | dst += vis(tbuf, c, flag, *++src) - tbuf; | 212 | dst += vis(tbuf, c, flag, *++src) - tbuf; |
diff --git a/openbsd-compat/vis.h b/openbsd-compat/vis.h index 5df6f3694..1c131cc85 100644 --- a/openbsd-compat/vis.h +++ b/openbsd-compat/vis.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: vis.h,v 1.5 2002/02/16 21:27:17 millert Exp $ */ | 1 | /* $OpenBSD: vis.h,v 1.6 2003/06/02 19:34:12 millert Exp $ */ |
2 | /* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */ | 2 | /* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */ |
3 | 3 | ||
4 | /*- | 4 | /*- |
@@ -13,11 +13,7 @@ | |||
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. |
16 | * 3. All advertising materials mentioning features or use of this software | 16 | * 3. Neither the name of the University nor the names of its contributors |
17 | * must display the following acknowledgement: | ||
18 | * This product includes software developed by the University of | ||
19 | * California, Berkeley and its contributors. | ||
20 | * 4. Neither the name of the University nor the names of its contributors | ||
21 | * may be used to endorse or promote products derived from this software | 17 | * may be used to endorse or promote products derived from this software |
22 | * without specific prior written permission. | 18 | * without specific prior written permission. |
23 | * | 19 | * |
@@ -35,7 +31,8 @@ | |||
35 | * | 31 | * |
36 | * @(#)vis.h 5.9 (Berkeley) 4/3/91 | 32 | * @(#)vis.h 5.9 (Berkeley) 4/3/91 |
37 | */ | 33 | */ |
38 | #include "config.h" | 34 | |
35 | #include "includes.h" | ||
39 | #if !defined(HAVE_STRNVIS) | 36 | #if !defined(HAVE_STRNVIS) |
40 | 37 | ||
41 | #ifndef _VIS_H_ | 38 | #ifndef _VIS_H_ |
diff --git a/openbsd-compat/xcrypt.c b/openbsd-compat/xcrypt.c new file mode 100644 index 000000000..5b5d69c72 --- /dev/null +++ b/openbsd-compat/xcrypt.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2003 Ben Lindstrom. All rights reserved. | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * 1. Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * 2. Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * | ||
13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
14 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
15 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
16 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
19 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
20 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | |||
25 | #include "includes.h" | ||
26 | |||
27 | #if !defined(HAVE_OSF_SIA) | ||
28 | |||
29 | # ifdef HAVE_CRYPT_H | ||
30 | # include <crypt.h> | ||
31 | # endif | ||
32 | |||
33 | # ifdef __hpux | ||
34 | # include <hpsecurity.h> | ||
35 | # include <prot.h> | ||
36 | # endif | ||
37 | |||
38 | # ifdef HAVE_SECUREWARE | ||
39 | # include <sys/security.h> | ||
40 | # include <sys/audit.h> | ||
41 | # include <prot.h> | ||
42 | # endif | ||
43 | |||
44 | # if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) | ||
45 | # include <shadow.h> | ||
46 | # endif | ||
47 | |||
48 | # if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW) | ||
49 | # include <sys/label.h> | ||
50 | # include <sys/audit.h> | ||
51 | # include <pwdadj.h> | ||
52 | # endif | ||
53 | |||
54 | # if defined(HAVE_MD5_PASSWORDS) && !defined(HAVE_MD5_CRYPT) | ||
55 | # include "md5crypt.h" | ||
56 | # endif | ||
57 | |||
58 | char * | ||
59 | xcrypt(const char *password, const char *salt) | ||
60 | { | ||
61 | char *crypted; | ||
62 | |||
63 | # ifdef HAVE_MD5_PASSWORDS | ||
64 | if (is_md5_salt(salt)) | ||
65 | crypted = md5_crypt(password, salt); | ||
66 | else | ||
67 | crypted = crypt(password, salt); | ||
68 | # elif defined(__hpux) && !defined(HAVE_SECUREWARE) | ||
69 | if (iscomsec()) | ||
70 | crypted = bigcrypt(password, salt); | ||
71 | else | ||
72 | crypted = crypt(password, salt); | ||
73 | # elif defined(HAVE_SECUREWARE) | ||
74 | crypted = bigcrypt(password, salt); | ||
75 | # else | ||
76 | crypted = crypt(password, salt); | ||
77 | # endif | ||
78 | |||
79 | return crypted; | ||
80 | } | ||
81 | |||
82 | /* | ||
83 | * Handle shadowed password systems in a cleaner way for portable | ||
84 | * version. | ||
85 | */ | ||
86 | |||
87 | char * | ||
88 | shadow_pw(struct passwd *pw) | ||
89 | { | ||
90 | char *pw_password = pw->pw_passwd; | ||
91 | |||
92 | # if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) | ||
93 | struct spwd *spw = getspnam(pw->pw_name); | ||
94 | |||
95 | if (spw != NULL) | ||
96 | pw_password = spw->sp_pwdp; | ||
97 | # endif | ||
98 | # if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW) | ||
99 | struct passwd_adjunct *spw; | ||
100 | if (issecure() && (spw = getpwanam(pw->pw_name)) != NULL) | ||
101 | pw_password = spw->pwa_passwd; | ||
102 | # elif defined(HAVE_SECUREWARE) | ||
103 | struct pr_passwd *spw = getprpwnam(pw->pw_name); | ||
104 | |||
105 | if (spw != NULL) | ||
106 | pw_password = spw->ufld.fd_encrypt; | ||
107 | # elif defined(__hpux) && !defined(HAVE_SECUREWARE) | ||
108 | struct pr_passwd *spw; | ||
109 | if (iscomsec() && (spw = getprpwnam(pw->pw_name)) != NULL) | ||
110 | pw_password = spw->ufld.fd_encrypt; | ||
111 | # endif | ||
112 | |||
113 | return pw_password; | ||
114 | } | ||
115 | |||
116 | #endif /* !defined(HAVE_OSF_SIA) */ | ||
diff --git a/openbsd-compat/xmmap.c b/openbsd-compat/xmmap.c index 8f1d2022c..9dc4340a7 100644 --- a/openbsd-compat/xmmap.c +++ b/openbsd-compat/xmmap.c | |||
@@ -1,4 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2002 Tim Rice. All rights reserved. | ||
3 | * MAP_FAILED code by Solar Designer. | ||
4 | * | ||
2 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
3 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
4 | * are met: | 7 | * are met: |
@@ -20,6 +23,8 @@ | |||
20 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
21 | */ | 24 | */ |
22 | 25 | ||
26 | /* $Id: xmmap.c,v 1.3 2003/06/02 02:25:27 tim Exp $ */ | ||
27 | |||
23 | #include "includes.h" | 28 | #include "includes.h" |
24 | 29 | ||
25 | #ifdef HAVE_SYS_MMAN_H | 30 | #ifdef HAVE_SYS_MMAN_H |
diff --git a/openbsd-compat/xmmap.h b/openbsd-compat/xmmap.h deleted file mode 100644 index c0fa04aca..000000000 --- a/openbsd-compat/xmmap.h +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | /* | ||
2 | * Redistribution and use in source and binary forms, with or without | ||
3 | * modification, are permitted provided that the following conditions | ||
4 | * are met: | ||
5 | * 1. Redistributions of source code must retain the above copyright | ||
6 | * notice, this list of conditions and the following disclaimer. | ||
7 | * 2. Redistributions in binary form must reproduce the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer in the | ||
9 | * documentation and/or other materials provided with the distribution. | ||
10 | * | ||
11 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
12 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
13 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
14 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
15 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
16 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
17 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
18 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
19 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
20 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
21 | */ | ||
22 | |||
23 | void *xmmap(size_t size); | ||