12c0338ffSzrj /* 22c0338ffSzrj * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org> 32c0338ffSzrj * 42c0338ffSzrj * Permission to use, copy, modify, and distribute this software for any 52c0338ffSzrj * purpose with or without fee is hereby granted, provided that the above 62c0338ffSzrj * copyright notice and this permission notice appear in all copies. 72c0338ffSzrj * 82c0338ffSzrj * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 92c0338ffSzrj * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 102c0338ffSzrj * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 112c0338ffSzrj * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 122c0338ffSzrj * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 132c0338ffSzrj * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 142c0338ffSzrj * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 152c0338ffSzrj */ 162c0338ffSzrj 172c0338ffSzrj #ifndef _BSD_MISC_H 182c0338ffSzrj #define _BSD_MISC_H 192c0338ffSzrj 202c0338ffSzrj #include "includes.h" 212c0338ffSzrj 222c0338ffSzrj char *ssh_get_progname(char *); 23*2c81fb9cSAntonio Huete Jimenez int seed_from_prngd(unsigned char *, size_t); 24*2c81fb9cSAntonio Huete Jimenez 25*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_SETSID 26*2c81fb9cSAntonio Huete Jimenez #define setsid() setpgrp(0, getpid()) 27*2c81fb9cSAntonio Huete Jimenez #endif /* !HAVE_SETSID */ 28*2c81fb9cSAntonio Huete Jimenez 29*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_SETENV 30*2c81fb9cSAntonio Huete Jimenez int setenv(const char *, const char *, int); 31*2c81fb9cSAntonio Huete Jimenez #endif /* !HAVE_SETENV */ 32*2c81fb9cSAntonio Huete Jimenez 33*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_SETLOGIN 34*2c81fb9cSAntonio Huete Jimenez int setlogin(const char *); 35*2c81fb9cSAntonio Huete Jimenez #endif /* !HAVE_SETLOGIN */ 36*2c81fb9cSAntonio Huete Jimenez 37*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_INNETGR 38*2c81fb9cSAntonio Huete Jimenez int innetgr(const char *, const char *, const char *, const char *); 39*2c81fb9cSAntonio Huete Jimenez #endif /* HAVE_INNETGR */ 40*2c81fb9cSAntonio Huete Jimenez 41*2c81fb9cSAntonio Huete Jimenez #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) 42*2c81fb9cSAntonio Huete Jimenez int seteuid(uid_t); 43*2c81fb9cSAntonio Huete Jimenez #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ 44*2c81fb9cSAntonio Huete Jimenez 45*2c81fb9cSAntonio Huete Jimenez #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) 46*2c81fb9cSAntonio Huete Jimenez int setegid(uid_t); 47*2c81fb9cSAntonio Huete Jimenez #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ 48*2c81fb9cSAntonio Huete Jimenez 49*2c81fb9cSAntonio Huete Jimenez #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) 50*2c81fb9cSAntonio Huete Jimenez const char *strerror(int); 51*2c81fb9cSAntonio Huete Jimenez #endif 52*2c81fb9cSAntonio Huete Jimenez 53*2c81fb9cSAntonio Huete Jimenez #if !defined(HAVE_SETLINEBUF) 54*2c81fb9cSAntonio Huete Jimenez #define setlinebuf(a) (setvbuf((a), NULL, _IOLBF, 0)) 55*2c81fb9cSAntonio Huete Jimenez #endif 56*2c81fb9cSAntonio Huete Jimenez 57*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_UTIMES 58*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_STRUCT_TIMEVAL 59*2c81fb9cSAntonio Huete Jimenez struct timeval { 60*2c81fb9cSAntonio Huete Jimenez long tv_sec; 61*2c81fb9cSAntonio Huete Jimenez long tv_usec; 62*2c81fb9cSAntonio Huete Jimenez } 63*2c81fb9cSAntonio Huete Jimenez #endif /* HAVE_STRUCT_TIMEVAL */ 64*2c81fb9cSAntonio Huete Jimenez 65*2c81fb9cSAntonio Huete Jimenez int utimes(const char *, struct timeval *); 66*2c81fb9cSAntonio Huete Jimenez #endif /* HAVE_UTIMES */ 67*2c81fb9cSAntonio Huete Jimenez 68*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_FCHMODAT 69*2c81fb9cSAntonio Huete Jimenez int fchmodat(int, const char *, mode_t, int); 70*2c81fb9cSAntonio Huete Jimenez #endif 71*2c81fb9cSAntonio Huete Jimenez 72*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_FCHOWNAT 73*2c81fb9cSAntonio Huete Jimenez int fchownat(int, const char *, uid_t, gid_t, int); 74*2c81fb9cSAntonio Huete Jimenez #endif 75*2c81fb9cSAntonio Huete Jimenez 76*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_TRUNCATE 77*2c81fb9cSAntonio Huete Jimenez int truncate (const char *, off_t); 78*2c81fb9cSAntonio Huete Jimenez #endif /* HAVE_TRUNCATE */ 79*2c81fb9cSAntonio Huete Jimenez 80*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_STRUCT_TIMESPEC 81*2c81fb9cSAntonio Huete Jimenez struct timespec { 82*2c81fb9cSAntonio Huete Jimenez time_t tv_sec; 83*2c81fb9cSAntonio Huete Jimenez long tv_nsec; 84*2c81fb9cSAntonio Huete Jimenez }; 85*2c81fb9cSAntonio Huete Jimenez #endif /* !HAVE_STRUCT_TIMESPEC */ 86*2c81fb9cSAntonio Huete Jimenez 87*2c81fb9cSAntonio Huete Jimenez #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) 88*2c81fb9cSAntonio Huete Jimenez # include <time.h> 89*2c81fb9cSAntonio Huete Jimenez int nanosleep(const struct timespec *, struct timespec *); 90*2c81fb9cSAntonio Huete Jimenez #endif 91*2c81fb9cSAntonio Huete Jimenez 92*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_UTIMENSAT 93*2c81fb9cSAntonio Huete Jimenez # include <time.h> 94*2c81fb9cSAntonio Huete Jimenez /* start with the high bits and work down to minimise risk of overlap */ 95*2c81fb9cSAntonio Huete Jimenez # ifndef AT_SYMLINK_NOFOLLOW 96*2c81fb9cSAntonio Huete Jimenez # define AT_SYMLINK_NOFOLLOW 0x80000000 97*2c81fb9cSAntonio Huete Jimenez # endif 98*2c81fb9cSAntonio Huete Jimenez int utimensat(int, const char *, const struct timespec[2], int); 99*2c81fb9cSAntonio Huete Jimenez #endif /* !HAVE_UTIMENSAT */ 100*2c81fb9cSAntonio Huete Jimenez 101*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_USLEEP 102*2c81fb9cSAntonio Huete Jimenez int usleep(unsigned int useconds); 103*2c81fb9cSAntonio Huete Jimenez #endif 104*2c81fb9cSAntonio Huete Jimenez 105*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_TCGETPGRP 106*2c81fb9cSAntonio Huete Jimenez pid_t tcgetpgrp(int); 107*2c81fb9cSAntonio Huete Jimenez #endif 108*2c81fb9cSAntonio Huete Jimenez 109*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_TCSENDBREAK 110*2c81fb9cSAntonio Huete Jimenez int tcsendbreak(int, int); 111*2c81fb9cSAntonio Huete Jimenez #endif 112*2c81fb9cSAntonio Huete Jimenez 113*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_UNSETENV 114*2c81fb9cSAntonio Huete Jimenez int unsetenv(const char *); 115*2c81fb9cSAntonio Huete Jimenez #endif 116*2c81fb9cSAntonio Huete Jimenez 117*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_ISBLANK 118*2c81fb9cSAntonio Huete Jimenez int isblank(int); 119*2c81fb9cSAntonio Huete Jimenez #endif 120*2c81fb9cSAntonio Huete Jimenez 121*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_GETPGID 122*2c81fb9cSAntonio Huete Jimenez pid_t getpgid(pid_t); 123*2c81fb9cSAntonio Huete Jimenez #endif 124*2c81fb9cSAntonio Huete Jimenez 125*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_PSELECT 126*2c81fb9cSAntonio Huete Jimenez int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, 127*2c81fb9cSAntonio Huete Jimenez const sigset_t *); 128*2c81fb9cSAntonio Huete Jimenez #endif 129*2c81fb9cSAntonio Huete Jimenez 130*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_ENDGRENT 131*2c81fb9cSAntonio Huete Jimenez # define endgrent() do { } while(0) 132*2c81fb9cSAntonio Huete Jimenez #endif 133*2c81fb9cSAntonio Huete Jimenez 134*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_KRB5_GET_ERROR_MESSAGE 135*2c81fb9cSAntonio Huete Jimenez # define krb5_get_error_message krb5_get_err_text 136*2c81fb9cSAntonio Huete Jimenez #endif 137*2c81fb9cSAntonio Huete Jimenez 138*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_KRB5_FREE_ERROR_MESSAGE 139*2c81fb9cSAntonio Huete Jimenez # define krb5_free_error_message(a,b) do { } while(0) 140*2c81fb9cSAntonio Huete Jimenez #endif 1412c0338ffSzrj 1422c0338ffSzrj #ifndef HAVE_PLEDGE 1432c0338ffSzrj int pledge(const char *promises, const char *paths[]); 1442c0338ffSzrj #endif 1452c0338ffSzrj 146*2c81fb9cSAntonio Huete Jimenez /* bsd-err.h */ 147*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_ERR 148*2c81fb9cSAntonio Huete Jimenez void err(int, const char *, ...) __attribute__((format(printf, 2, 3))); 149*2c81fb9cSAntonio Huete Jimenez #endif 150*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_ERRX 151*2c81fb9cSAntonio Huete Jimenez void errx(int, const char *, ...) __attribute__((format(printf, 2, 3))); 152*2c81fb9cSAntonio Huete Jimenez #endif 153*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_WARN 154*2c81fb9cSAntonio Huete Jimenez void warn(const char *, ...) __attribute__((format(printf, 1, 2))); 155*2c81fb9cSAntonio Huete Jimenez #endif 156*2c81fb9cSAntonio Huete Jimenez 157*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_LLABS 158*2c81fb9cSAntonio Huete Jimenez long long llabs(long long); 159*2c81fb9cSAntonio Huete Jimenez #endif 160*2c81fb9cSAntonio Huete Jimenez 161*2c81fb9cSAntonio Huete Jimenez #if defined(HAVE_DECL_BZERO) && HAVE_DECL_BZERO == 0 162*2c81fb9cSAntonio Huete Jimenez void bzero(void *, size_t); 163*2c81fb9cSAntonio Huete Jimenez #endif 164*2c81fb9cSAntonio Huete Jimenez 165*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_RAISE 166*2c81fb9cSAntonio Huete Jimenez int raise(int); 167*2c81fb9cSAntonio Huete Jimenez #endif 168*2c81fb9cSAntonio Huete Jimenez 169*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_GETSID 170*2c81fb9cSAntonio Huete Jimenez pid_t getsid(pid_t); 171*2c81fb9cSAntonio Huete Jimenez #endif 172*2c81fb9cSAntonio Huete Jimenez 173*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_FLOCK 174*2c81fb9cSAntonio Huete Jimenez # define LOCK_SH 0x01 175*2c81fb9cSAntonio Huete Jimenez # define LOCK_EX 0x02 176*2c81fb9cSAntonio Huete Jimenez # define LOCK_NB 0x04 177*2c81fb9cSAntonio Huete Jimenez # define LOCK_UN 0x08 178*2c81fb9cSAntonio Huete Jimenez int flock(int, int); 179*2c81fb9cSAntonio Huete Jimenez #endif 180*2c81fb9cSAntonio Huete Jimenez 181*2c81fb9cSAntonio Huete Jimenez #ifdef FFLUSH_NULL_BUG 182*2c81fb9cSAntonio Huete Jimenez # define fflush(x) (_ssh_compat_fflush(x)) 183*2c81fb9cSAntonio Huete Jimenez #endif 184*2c81fb9cSAntonio Huete Jimenez 185*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_LOCALTIME_R 186*2c81fb9cSAntonio Huete Jimenez struct tm *localtime_r(const time_t *, struct tm *); 187*2c81fb9cSAntonio Huete Jimenez #endif 188*2c81fb9cSAntonio Huete Jimenez 189*2c81fb9cSAntonio Huete Jimenez #ifndef HAVE_REALPATH 190*2c81fb9cSAntonio Huete Jimenez #define realpath(x, y) (sftp_realpath((x), (y))) 191*2c81fb9cSAntonio Huete Jimenez #endif 192*2c81fb9cSAntonio Huete Jimenez 1932c0338ffSzrj #endif /* _BSD_MISC_H */ 194