Damien Miller | af63951 | 2003-06-11 22:51:32 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 3 | * Copyright (c) 2003 Ben Lindstrom. All rights reserved. |
| 4 | * Copyright (c) 2002 Tim Rice. All rights reserved. |
Damien Miller | af63951 | 2003-06-11 22:51:32 +1000 | [diff] [blame] | 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 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | */ |
| 26 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 27 | #ifndef _OPENBSD_COMPAT_H |
| 28 | #define _OPENBSD_COMPAT_H |
Damien Miller | e9cf357 | 2001-02-09 12:55:35 +1100 | [diff] [blame] | 29 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 30 | #include "includes.h" |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 31 | |
Damien Miller | a1738e4 | 2006-07-10 21:33:04 +1000 | [diff] [blame] | 32 | #include <sys/types.h> |
| 33 | #include <pwd.h> |
| 34 | |
Darren Tucker | 4e880e6 | 2006-07-11 00:20:51 +1000 | [diff] [blame] | 35 | #include <sys/socket.h> |
| 36 | |
Darren Tucker | a233358 | 2016-07-14 10:59:09 +1000 | [diff] [blame] | 37 | #include <stddef.h> /* for wchar_t */ |
| 38 | |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 39 | /* OpenBSD function replacements */ |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 40 | #include "base64.h" |
Ben Lindstrom | 803f16c | 2001-02-24 00:24:19 +0000 | [diff] [blame] | 41 | #include "sigact.h" |
Damien Miller | c8a3868 | 2001-06-25 18:09:16 +1000 | [diff] [blame] | 42 | #include "readpassphrase.h" |
Damien Miller | b93addb | 2003-01-07 17:04:18 +1100 | [diff] [blame] | 43 | #include "vis.h" |
Damien Miller | d9ec370 | 2003-05-15 12:27:08 +1000 | [diff] [blame] | 44 | #include "getrrsetbyname.h" |
Damien Miller | 72ef7c1 | 2015-01-15 02:21:31 +1100 | [diff] [blame] | 45 | #include "sha1.h" |
Damien Miller | af87af1 | 2006-03-15 13:02:28 +1100 | [diff] [blame] | 46 | #include "sha2.h" |
Damien Miller | 72ef7c1 | 2015-01-15 02:21:31 +1100 | [diff] [blame] | 47 | #include "rmd160.h" |
| 48 | #include "md5.h" |
Damien Miller | 1ff130d | 2013-12-07 11:51:51 +1100 | [diff] [blame] | 49 | #include "blf.h" |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 50 | |
| 51 | #ifndef HAVE_BASENAME |
| 52 | char *basename(const char *path); |
| 53 | #endif |
| 54 | |
| 55 | #ifndef HAVE_BINDRESVPORT_SA |
| 56 | int bindresvport_sa(int sd, struct sockaddr *sa); |
| 57 | #endif |
| 58 | |
Damien Miller | 36f4965 | 2004-08-15 18:40:59 +1000 | [diff] [blame] | 59 | #ifndef HAVE_CLOSEFROM |
| 60 | void closefrom(int); |
| 61 | #endif |
| 62 | |
Darren Tucker | 6301e6c | 2018-07-02 21:16:58 +1000 | [diff] [blame] | 63 | #ifndef HAVE_GETLINE |
Darren Tucker | 8a85f54 | 2018-11-25 21:44:05 +1100 | [diff] [blame] | 64 | #include <stdio.h> |
Darren Tucker | 6301e6c | 2018-07-02 21:16:58 +1000 | [diff] [blame] | 65 | ssize_t getline(char **, size_t *, FILE *); |
| 66 | #endif |
| 67 | |
Damien Miller | 151c6e4 | 2017-06-01 15:25:13 +1000 | [diff] [blame] | 68 | #ifndef HAVE_GETPAGESIZE |
| 69 | int getpagesize(void); |
| 70 | #endif |
| 71 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 72 | #ifndef HAVE_GETCWD |
| 73 | char *getcwd(char *pt, size_t size); |
Darren Tucker | c20dccb | 2016-08-02 09:44:25 +1000 | [diff] [blame] | 74 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 75 | |
Darren Tucker | 642652d | 2014-12-10 01:32:23 +1100 | [diff] [blame] | 76 | #ifndef HAVE_REALLOCARRAY |
| 77 | void *reallocarray(void *, size_t, size_t); |
| 78 | #endif |
| 79 | |
Damien Miller | 151c6e4 | 2017-06-01 15:25:13 +1000 | [diff] [blame] | 80 | #ifndef HAVE_RECALLOCARRAY |
| 81 | void *recallocarray(void *, size_t, size_t, size_t); |
| 82 | #endif |
| 83 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 84 | #if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) |
Darren Tucker | d3e2aee | 2015-07-17 12:52:34 +1000 | [diff] [blame] | 85 | /* |
| 86 | * glibc's FORTIFY_SOURCE can redefine this and prevent us picking up the |
| 87 | * compat version. |
| 88 | */ |
| 89 | # ifdef BROKEN_REALPATH |
| 90 | # define realpath(x, y) _ssh_compat_realpath(x, y) |
| 91 | # endif |
| 92 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 93 | char *realpath(const char *path, char *resolved); |
Darren Tucker | d3e2aee | 2015-07-17 12:52:34 +1000 | [diff] [blame] | 94 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 95 | |
| 96 | #ifndef HAVE_RRESVPORT_AF |
| 97 | int rresvport_af(int *alport, sa_family_t af); |
| 98 | #endif |
| 99 | |
| 100 | #ifndef HAVE_STRLCPY |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 101 | size_t strlcpy(char *dst, const char *src, size_t siz); |
| 102 | #endif |
| 103 | |
| 104 | #ifndef HAVE_STRLCAT |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 105 | size_t strlcat(char *dst, const char *src, size_t siz); |
Darren Tucker | c20dccb | 2016-08-02 09:44:25 +1000 | [diff] [blame] | 106 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 107 | |
Darren Tucker | 25275f1 | 2016-12-13 12:54:23 +1100 | [diff] [blame] | 108 | #ifndef HAVE_STRCASESTR |
| 109 | char *strcasestr(const char *, const char *); |
| 110 | #endif |
| 111 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 112 | #ifndef HAVE_SETENV |
| 113 | int setenv(register const char *name, register const char *value, int rewrite); |
| 114 | #endif |
| 115 | |
| 116 | #ifndef HAVE_STRMODE |
| 117 | void strmode(int mode, char *p); |
| 118 | #endif |
| 119 | |
Darren Tucker | aa74f67 | 2010-08-16 13:15:23 +1000 | [diff] [blame] | 120 | #ifndef HAVE_STRPTIME |
| 121 | #include <time.h> |
| 122 | char *strptime(const char *buf, const char *fmt, struct tm *tm); |
| 123 | #endif |
| 124 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 125 | #if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) |
| 126 | int mkstemps(char *path, int slen); |
| 127 | int mkstemp(char *path); |
| 128 | char *mkdtemp(char *path); |
Darren Tucker | c20dccb | 2016-08-02 09:44:25 +1000 | [diff] [blame] | 129 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 130 | |
| 131 | #ifndef HAVE_DAEMON |
| 132 | int daemon(int nochdir, int noclose); |
Darren Tucker | c20dccb | 2016-08-02 09:44:25 +1000 | [diff] [blame] | 133 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 134 | |
| 135 | #ifndef HAVE_DIRNAME |
| 136 | char *dirname(const char *path); |
| 137 | #endif |
| 138 | |
Damien Miller | a7058ec | 2008-05-20 08:57:06 +1000 | [diff] [blame] | 139 | #ifndef HAVE_FMT_SCALED |
| 140 | #define FMT_SCALED_STRSIZE 7 |
| 141 | int fmt_scaled(long long number, char *result); |
| 142 | #endif |
| 143 | |
Darren Tucker | e194ba4 | 2013-05-16 20:47:31 +1000 | [diff] [blame] | 144 | #ifndef HAVE_SCAN_SCALED |
| 145 | int scan_scaled(char *, long long *); |
| 146 | #endif |
| 147 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 148 | #if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) |
| 149 | char *inet_ntoa(struct in_addr in); |
| 150 | #endif |
| 151 | |
| 152 | #ifndef HAVE_INET_NTOP |
Damien Miller | 3e6fe87 | 2011-09-23 11:16:09 +1000 | [diff] [blame] | 153 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 154 | #endif |
| 155 | |
| 156 | #ifndef HAVE_INET_ATON |
| 157 | int inet_aton(const char *cp, struct in_addr *addr); |
Darren Tucker | c20dccb | 2016-08-02 09:44:25 +1000 | [diff] [blame] | 158 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 159 | |
| 160 | #ifndef HAVE_STRSEP |
| 161 | char *strsep(char **stringp, const char *delim); |
| 162 | #endif |
| 163 | |
| 164 | #ifndef HAVE_SETPROCTITLE |
| 165 | void setproctitle(const char *fmt, ...); |
| 166 | void compat_init_setproctitle(int argc, char *argv[]); |
| 167 | #endif |
| 168 | |
| 169 | #ifndef HAVE_GETGROUPLIST |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 170 | int getgrouplist(const char *, gid_t, gid_t *, int *); |
| 171 | #endif |
| 172 | |
| 173 | #if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) |
| 174 | int BSDgetopt(int argc, char * const *argv, const char *opts); |
Darren Tucker | 0abfb55 | 2013-05-10 18:08:49 +1000 | [diff] [blame] | 175 | #include "openbsd-compat/getopt.h" |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 176 | #endif |
| 177 | |
Darren Tucker | 2eb4041 | 2018-02-24 21:06:48 +1100 | [diff] [blame] | 178 | #if ((defined(HAVE_DECL_READV) && HAVE_DECL_READV == 0) || \ |
| 179 | (defined(HAVE_DECL_WRITEV) && HAVE_DECL_WRITEV == 0)) |
Darren Tucker | ed0b592 | 2006-09-03 22:44:49 +1000 | [diff] [blame] | 180 | # include <sys/types.h> |
| 181 | # include <sys/uio.h> |
Darren Tucker | 2eb4041 | 2018-02-24 21:06:48 +1100 | [diff] [blame] | 182 | |
| 183 | # if defined(HAVE_DECL_READV) && HAVE_DECL_READV == 0 |
| 184 | int readv(int, struct iovec *, int); |
| 185 | # endif |
| 186 | |
| 187 | # if defined(HAVE_DECL_WRITEV) && HAVE_DECL_WRITEV == 0 |
Darren Tucker | ed0b592 | 2006-09-03 22:44:49 +1000 | [diff] [blame] | 188 | int writev(int, struct iovec *, int); |
Darren Tucker | 2eb4041 | 2018-02-24 21:06:48 +1100 | [diff] [blame] | 189 | # endif |
Darren Tucker | ed0b592 | 2006-09-03 22:44:49 +1000 | [diff] [blame] | 190 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 191 | |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 192 | /* Home grown routines */ |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 193 | #include "bsd-misc.h" |
Darren Tucker | f96ff18 | 2012-11-05 17:04:37 +1100 | [diff] [blame] | 194 | #include "bsd-setres_id.h" |
Darren Tucker | fbfa6f9 | 2018-02-11 21:25:11 +1300 | [diff] [blame] | 195 | #include "bsd-signal.h" |
Darren Tucker | 598eaa6 | 2008-06-09 03:32:29 +1000 | [diff] [blame] | 196 | #include "bsd-statvfs.h" |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 197 | #include "bsd-waitpid.h" |
Darren Tucker | febf0f5 | 2007-06-25 22:15:12 +1000 | [diff] [blame] | 198 | #include "bsd-poll.h" |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 199 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 200 | #ifndef HAVE_GETPEEREID |
| 201 | int getpeereid(int , uid_t *, gid_t *); |
Darren Tucker | ccdb9be | 2013-11-08 18:54:38 +1100 | [diff] [blame] | 202 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 203 | |
Darren Tucker | ccdb9be | 2013-11-08 18:54:38 +1100 | [diff] [blame] | 204 | #ifdef HAVE_ARC4RANDOM |
| 205 | # ifndef HAVE_ARC4RANDOM_STIR |
| 206 | # define arc4random_stir() |
| 207 | # endif |
| 208 | #else |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 209 | unsigned int arc4random(void); |
| 210 | void arc4random_stir(void); |
| 211 | #endif /* !HAVE_ARC4RANDOM */ |
| 212 | |
Damien Miller | a4be7c2 | 2008-05-19 14:47:37 +1000 | [diff] [blame] | 213 | #ifndef HAVE_ARC4RANDOM_BUF |
| 214 | void arc4random_buf(void *, size_t); |
| 215 | #endif |
| 216 | |
| 217 | #ifndef HAVE_ARC4RANDOM_UNIFORM |
| 218 | u_int32_t arc4random_uniform(u_int32_t); |
| 219 | #endif |
| 220 | |
Damien Miller | 57f3915 | 2005-11-24 19:58:19 +1100 | [diff] [blame] | 221 | #ifndef HAVE_ASPRINTF |
| 222 | int asprintf(char **, const char *, ...); |
Darren Tucker | c20dccb | 2016-08-02 09:44:25 +1000 | [diff] [blame] | 223 | #endif |
Damien Miller | 57f3915 | 2005-11-24 19:58:19 +1100 | [diff] [blame] | 224 | |
Damien Miller | f4da3bb | 2004-01-21 17:07:16 +1100 | [diff] [blame] | 225 | #ifndef HAVE_OPENPTY |
Darren Tucker | dc6118e | 2006-03-15 22:25:54 +1100 | [diff] [blame] | 226 | # include <sys/ioctl.h> /* for struct winsize */ |
Damien Miller | f4da3bb | 2004-01-21 17:07:16 +1100 | [diff] [blame] | 227 | int openpty(int *, int *, char *, struct termios *, struct winsize *); |
| 228 | #endif /* HAVE_OPENPTY */ |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 229 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 230 | #ifndef HAVE_SNPRINTF |
Darren Tucker | 66c32d5 | 2006-06-30 10:51:32 +1000 | [diff] [blame] | 231 | int snprintf(char *, size_t, SNPRINTF_CONST char *, ...); |
Darren Tucker | c20dccb | 2016-08-02 09:44:25 +1000 | [diff] [blame] | 232 | #endif |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 233 | |
Darren Tucker | 6e42211 | 2005-09-30 09:55:49 +1000 | [diff] [blame] | 234 | #ifndef HAVE_STRTOLL |
| 235 | long long strtoll(const char *, char **, int); |
| 236 | #endif |
| 237 | |
Darren Tucker | f32db83 | 2013-02-15 12:20:41 +1100 | [diff] [blame] | 238 | #ifndef HAVE_STRTOUL |
| 239 | unsigned long strtoul(const char *, char **, int); |
| 240 | #endif |
| 241 | |
| 242 | #ifndef HAVE_STRTOULL |
| 243 | unsigned long long strtoull(const char *, char **, int); |
| 244 | #endif |
| 245 | |
Damien Miller | de3cb0a | 2005-05-26 20:48:25 +1000 | [diff] [blame] | 246 | #ifndef HAVE_STRTONUM |
| 247 | long long strtonum(const char *, long long, long long, const char **); |
| 248 | #endif |
| 249 | |
Darren Tucker | ae133d4 | 2013-06-06 08:30:20 +1000 | [diff] [blame] | 250 | /* multibyte character support */ |
| 251 | #ifndef HAVE_MBLEN |
Darren Tucker | a647b9b | 2015-05-08 11:07:27 +1000 | [diff] [blame] | 252 | # define mblen(x, y) (1) |
Darren Tucker | ae133d4 | 2013-06-06 08:30:20 +1000 | [diff] [blame] | 253 | #endif |
| 254 | |
Darren Tucker | a233358 | 2016-07-14 10:59:09 +1000 | [diff] [blame] | 255 | #ifndef HAVE_WCWIDTH |
| 256 | # define wcwidth(x) (((x) >= 0x20 && (x) <= 0x7e) ? 1 : -1) |
| 257 | /* force our no-op nl_langinfo and mbtowc */ |
| 258 | # undef HAVE_NL_LANGINFO |
| 259 | # undef HAVE_MBTOWC |
| 260 | # undef HAVE_LANGINFO_H |
| 261 | #endif |
| 262 | |
| 263 | #ifndef HAVE_NL_LANGINFO |
| 264 | # define nl_langinfo(x) "" |
| 265 | #endif |
| 266 | |
| 267 | #ifndef HAVE_MBTOWC |
| 268 | int mbtowc(wchar_t *, const char*, size_t); |
| 269 | #endif |
| 270 | |
Darren Tucker | 5998ed0 | 2006-07-12 23:10:33 +1000 | [diff] [blame] | 271 | #if !defined(HAVE_VASPRINTF) || !defined(HAVE_VSNPRINTF) |
| 272 | # include <stdarg.h> |
| 273 | #endif |
| 274 | |
Darren Tucker | 5abfb15 | 2016-07-15 14:48:30 +1000 | [diff] [blame] | 275 | /* |
| 276 | * Some platforms unconditionally undefine va_copy() so we define VA_COPY() |
| 277 | * instead. This is known to be the case on at least some configurations of |
| 278 | * AIX with the xlc compiler. |
| 279 | */ |
| 280 | #ifndef VA_COPY |
| 281 | # ifdef HAVE_VA_COPY |
| 282 | # define VA_COPY(dest, src) va_copy(dest, src) |
| 283 | # else |
| 284 | # ifdef HAVE___VA_COPY |
| 285 | # define VA_COPY(dest, src) __va_copy(dest, src) |
| 286 | # else |
| 287 | # define VA_COPY(dest, src) (dest) = (src) |
| 288 | # endif |
| 289 | # endif |
| 290 | #endif |
| 291 | |
Damien Miller | 57f3915 | 2005-11-24 19:58:19 +1100 | [diff] [blame] | 292 | #ifndef HAVE_VASPRINTF |
| 293 | int vasprintf(char **, const char *, va_list); |
| 294 | #endif |
| 295 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 296 | #ifndef HAVE_VSNPRINTF |
| 297 | int vsnprintf(char *, size_t, const char *, va_list); |
| 298 | #endif |
| 299 | |
Darren Tucker | 2563e3f | 2010-01-16 11:53:07 +1100 | [diff] [blame] | 300 | #ifndef HAVE_USER_FROM_UID |
Darren Tucker | 69371b5 | 2010-01-16 13:30:30 +1100 | [diff] [blame] | 301 | char *user_from_uid(uid_t, int); |
Darren Tucker | 2563e3f | 2010-01-16 11:53:07 +1100 | [diff] [blame] | 302 | #endif |
| 303 | |
Darren Tucker | 4e21855 | 2010-01-16 23:58:37 +1100 | [diff] [blame] | 304 | #ifndef HAVE_GROUP_FROM_GID |
Darren Tucker | 69371b5 | 2010-01-16 13:30:30 +1100 | [diff] [blame] | 305 | char *group_from_gid(gid_t, int); |
Darren Tucker | 2563e3f | 2010-01-16 11:53:07 +1100 | [diff] [blame] | 306 | #endif |
| 307 | |
Damien Miller | aa18063 | 2010-10-07 21:25:27 +1100 | [diff] [blame] | 308 | #ifndef HAVE_TIMINGSAFE_BCMP |
| 309 | int timingsafe_bcmp(const void *, const void *, size_t); |
| 310 | #endif |
| 311 | |
Damien Miller | 1ff130d | 2013-12-07 11:51:51 +1100 | [diff] [blame] | 312 | #ifndef HAVE_BCRYPT_PBKDF |
| 313 | int bcrypt_pbkdf(const char *, size_t, const u_int8_t *, size_t, |
| 314 | u_int8_t *, size_t, unsigned int); |
| 315 | #endif |
| 316 | |
Damien Miller | 1d2c456 | 2014-02-04 11:18:20 +1100 | [diff] [blame] | 317 | #ifndef HAVE_EXPLICIT_BZERO |
| 318 | void explicit_bzero(void *p, size_t n); |
| 319 | #endif |
| 320 | |
Damien Miller | b795691 | 2017-09-19 12:29:23 +1000 | [diff] [blame] | 321 | #ifndef HAVE_FREEZERO |
| 322 | void freezero(void *, size_t); |
| 323 | #endif |
| 324 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 325 | char *xcrypt(const char *password, const char *salt); |
| 326 | char *shadow_pw(struct passwd *pw); |
| 327 | |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 328 | /* rfc2553 socket API replacements */ |
Damien Miller | c28e38d | 2003-06-05 18:52:47 +1000 | [diff] [blame] | 329 | #include "fake-rfc2553.h" |
Ben Lindstrom | 3c06f6a | 2001-01-31 21:52:01 +0000 | [diff] [blame] | 330 | |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 331 | /* Routines for a single OS platform */ |
Darren Tucker | 70a08cd | 2003-05-04 10:41:20 +1000 | [diff] [blame] | 332 | #include "bsd-cygwin_util.h" |
Damien Miller | 1b06dc3 | 2006-08-31 03:24:41 +1000 | [diff] [blame] | 333 | |
| 334 | #include "port-aix.h" |
Ben Lindstrom | f095a85 | 2002-02-19 20:02:48 +0000 | [diff] [blame] | 335 | #include "port-irix.h" |
Damien Miller | 73b42d2 | 2006-04-22 21:26:08 +1000 | [diff] [blame] | 336 | #include "port-linux.h" |
Damien Miller | 1b06dc3 | 2006-08-31 03:24:41 +1000 | [diff] [blame] | 337 | #include "port-solaris.h" |
Damien Miller | f5594f9 | 2017-10-25 13:13:57 +1100 | [diff] [blame] | 338 | #include "port-net.h" |
Damien Miller | 1b06dc3 | 2006-08-31 03:24:41 +1000 | [diff] [blame] | 339 | #include "port-uw.h" |
Ben Lindstrom | 6db66ff | 2001-08-06 23:29:16 +0000 | [diff] [blame] | 340 | |
Damien Miller | 703b98a | 2014-10-01 09:43:07 +1000 | [diff] [blame] | 341 | /* _FORTIFY_SOURCE breaks FD_ISSET(n)/FD_SET(n) for n > FD_SETSIZE. Avoid. */ |
| 342 | #if defined(HAVE_FEATURES_H) && defined(_FORTIFY_SOURCE) |
| 343 | # include <features.h> |
| 344 | # if defined(__GNU_LIBRARY__) && defined(__GLIBC_PREREQ) |
| 345 | # if __GLIBC_PREREQ(2, 15) && (_FORTIFY_SOURCE > 0) |
| 346 | # include <sys/socket.h> /* Ensure include guard is defined */ |
| 347 | # undef FD_SET |
| 348 | # undef FD_ISSET |
| 349 | # define FD_SET(n, set) kludge_FD_SET(n, set) |
| 350 | # define FD_ISSET(n, set) kludge_FD_ISSET(n, set) |
| 351 | void kludge_FD_SET(int, fd_set *); |
| 352 | int kludge_FD_ISSET(int, fd_set *); |
| 353 | # endif /* __GLIBC_PREREQ(2, 15) && (_FORTIFY_SOURCE > 0) */ |
| 354 | # endif /* __GNU_LIBRARY__ && __GLIBC_PREREQ */ |
| 355 | #endif /* HAVE_FEATURES_H && _FORTIFY_SOURCE */ |
| 356 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 357 | #endif /* _OPENBSD_COMPAT_H */ |