Darren Tucker | f3ab2c5 | 2013-08-04 21:48:41 +1000 | [diff] [blame] | 1 | /* $Id: bsd-misc.h,v 1.25 2013/08/04 11:48:41 dtucker Exp $ */ |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 2 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 3 | /* |
Damien Miller | 98225c2 | 2004-02-17 16:49:41 +1100 | [diff] [blame] | 4 | * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org> |
Damien Miller | 040f383 | 2000-04-03 14:50:43 +1000 | [diff] [blame] | 5 | * |
Damien Miller | 98225c2 | 2004-02-17 16:49:41 +1100 | [diff] [blame] | 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. |
Damien Miller | 040f383 | 2000-04-03 14:50:43 +1000 | [diff] [blame] | 9 | * |
Damien Miller | 98225c2 | 2004-02-17 16:49:41 +1100 | [diff] [blame] | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Damien Miller | 040f383 | 2000-04-03 14:50:43 +1000 | [diff] [blame] | 17 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 18 | |
Damien Miller | 753331e | 1999-12-30 01:29:35 +1100 | [diff] [blame] | 19 | #ifndef _BSD_MISC_H |
| 20 | #define _BSD_MISC_H |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 21 | |
Ben Lindstrom | 515d0f9 | 2003-08-29 16:59:52 +0000 | [diff] [blame] | 22 | #include "includes.h" |
Damien Miller | e413cba | 1999-10-28 14:12:54 +1000 | [diff] [blame] | 23 | |
Damien Miller | 59d3d5b | 2003-08-22 09:34:41 +1000 | [diff] [blame] | 24 | char *ssh_get_progname(char *); |
Ben Lindstrom | 49a79c0 | 2000-11-17 03:47:20 +0000 | [diff] [blame] | 25 | |
Ben Lindstrom | 67e21e1 | 2000-11-05 09:08:45 +0000 | [diff] [blame] | 26 | #ifndef HAVE_SETSID |
| 27 | #define setsid() setpgrp(0, getpid()) |
| 28 | #endif /* !HAVE_SETSID */ |
| 29 | |
Damien Miller | d770252 | 1999-11-22 16:11:05 +1100 | [diff] [blame] | 30 | #ifndef HAVE_SETENV |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 31 | int setenv(const char *, const char *, int); |
Damien Miller | d770252 | 1999-11-22 16:11:05 +1100 | [diff] [blame] | 32 | #endif /* !HAVE_SETENV */ |
| 33 | |
Damien Miller | e72b7af | 1999-12-30 15:08:44 +1100 | [diff] [blame] | 34 | #ifndef HAVE_SETLOGIN |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 35 | int setlogin(const char *); |
Damien Miller | e72b7af | 1999-12-30 15:08:44 +1100 | [diff] [blame] | 36 | #endif /* !HAVE_SETLOGIN */ |
| 37 | |
| 38 | #ifndef HAVE_INNETGR |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 39 | int innetgr(const char *, const char *, const char *, const char *); |
Damien Miller | e72b7af | 1999-12-30 15:08:44 +1100 | [diff] [blame] | 40 | #endif /* HAVE_INNETGR */ |
| 41 | |
| 42 | #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 43 | int seteuid(uid_t); |
Damien Miller | e72b7af | 1999-12-30 15:08:44 +1100 | [diff] [blame] | 44 | #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ |
| 45 | |
Kevin Steves | cb17e99 | 2001-04-09 14:50:52 +0000 | [diff] [blame] | 46 | #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 47 | int setegid(uid_t); |
Kevin Steves | cb17e99 | 2001-04-09 14:50:52 +0000 | [diff] [blame] | 48 | #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ |
| 49 | |
Damien Miller | 11fa2cc | 2000-08-16 10:35:58 +1000 | [diff] [blame] | 50 | #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 51 | const char *strerror(int); |
Damien Miller | 11fa2cc | 2000-08-16 10:35:58 +1000 | [diff] [blame] | 52 | #endif |
Damien Miller | ecbb26d | 2000-07-15 14:59:14 +1000 | [diff] [blame] | 53 | |
Darren Tucker | 34f702a | 2012-07-04 08:50:09 +1000 | [diff] [blame] | 54 | #if !defined(HAVE_SETLINEBUF) |
| 55 | #define setlinebuf(a) (setvbuf((a), NULL, _IOLBF, 0)) |
| 56 | #endif |
Ben Lindstrom | 42202bc | 2001-01-15 02:34:37 +0000 | [diff] [blame] | 57 | |
| 58 | #ifndef HAVE_UTIMES |
| 59 | #ifndef HAVE_STRUCT_TIMEVAL |
| 60 | struct timeval { |
| 61 | long tv_sec; |
| 62 | long tv_usec; |
| 63 | } |
| 64 | #endif /* HAVE_STRUCT_TIMEVAL */ |
| 65 | |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 66 | int utimes(char *, struct timeval *); |
Ben Lindstrom | 42202bc | 2001-01-15 02:34:37 +0000 | [diff] [blame] | 67 | #endif /* HAVE_UTIMES */ |
| 68 | |
Tim Rice | 4bd2a19 | 2002-05-07 19:51:31 -0700 | [diff] [blame] | 69 | #ifndef HAVE_TRUNCATE |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 70 | int truncate (const char *, off_t); |
Tim Rice | 4bd2a19 | 2002-05-07 19:51:31 -0700 | [diff] [blame] | 71 | #endif /* HAVE_TRUNCATE */ |
Ben Lindstrom | 42202bc | 2001-01-15 02:34:37 +0000 | [diff] [blame] | 72 | |
Tim Rice | 4e4dc56 | 2003-03-18 10:21:40 -0800 | [diff] [blame] | 73 | #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) |
| 74 | #ifndef HAVE_STRUCT_TIMESPEC |
| 75 | struct timespec { |
| 76 | time_t tv_sec; |
| 77 | long tv_nsec; |
| 78 | }; |
| 79 | #endif |
Damien Miller | 3174125 | 2003-05-19 00:13:38 +1000 | [diff] [blame] | 80 | int nanosleep(const struct timespec *, struct timespec *); |
Tim Rice | 4e4dc56 | 2003-03-18 10:21:40 -0800 | [diff] [blame] | 81 | #endif |
Ben Lindstrom | 837461b | 2002-06-12 16:57:14 +0000 | [diff] [blame] | 82 | |
Damien Miller | f4db77d | 2013-03-15 10:34:25 +1100 | [diff] [blame] | 83 | #ifndef HAVE_USLEEP |
| 84 | int usleep(unsigned int useconds); |
| 85 | #endif |
| 86 | |
Darren Tucker | 2e9c9cf | 2003-08-02 23:31:42 +1000 | [diff] [blame] | 87 | #ifndef HAVE_TCGETPGRP |
| 88 | pid_t tcgetpgrp(int); |
Darren Tucker | f38ea77 | 2003-08-13 20:48:07 +1000 | [diff] [blame] | 89 | #endif |
| 90 | |
| 91 | #ifndef HAVE_TCSENDBREAK |
| 92 | int tcsendbreak(int, int); |
| 93 | #endif |
Darren Tucker | 2e9c9cf | 2003-08-02 23:31:42 +1000 | [diff] [blame] | 94 | |
Darren Tucker | 86c093d | 2004-03-08 22:59:03 +1100 | [diff] [blame] | 95 | #ifndef HAVE_UNSETENV |
Tim Rice | e3609c9 | 2012-02-14 10:03:30 -0800 | [diff] [blame] | 96 | int unsetenv(const char *); |
Darren Tucker | 86c093d | 2004-03-08 22:59:03 +1100 | [diff] [blame] | 97 | #endif |
| 98 | |
Ben Lindstrom | 5ade9ab | 2003-08-25 01:16:21 +0000 | [diff] [blame] | 99 | /* wrapper for signal interface */ |
| 100 | typedef void (*mysig_t)(int); |
| 101 | mysig_t mysignal(int sig, mysig_t act); |
| 102 | |
| 103 | #define signal(a,b) mysignal(a,b) |
| 104 | |
Tim Rice | c7a8af0 | 2010-11-08 14:26:23 -0800 | [diff] [blame] | 105 | #ifndef HAVE_ISBLANK |
| 106 | int isblank(int); |
| 107 | #endif |
| 108 | |
Darren Tucker | 3c4a24c | 2013-02-15 11:41:35 +1100 | [diff] [blame] | 109 | #ifndef HAVE_GETPGID |
| 110 | pid_t getpgid(pid_t); |
| 111 | #endif |
| 112 | |
Darren Tucker | efdf534 | 2013-05-30 08:29:08 +1000 | [diff] [blame] | 113 | #ifndef HAVE_ENDGRENT |
Darren Tucker | e7bf3a5 | 2015-04-07 10:48:04 +1000 | [diff] [blame] | 114 | # define endgrent() do { } while(0) |
Darren Tucker | efdf534 | 2013-05-30 08:29:08 +1000 | [diff] [blame] | 115 | #endif |
| 116 | |
Darren Tucker | f3ab2c5 | 2013-08-04 21:48:41 +1000 | [diff] [blame] | 117 | #ifndef HAVE_KRB5_GET_ERROR_MESSAGE |
| 118 | # define krb5_get_error_message krb5_get_err_text |
| 119 | #endif |
| 120 | |
| 121 | #ifndef HAVE_KRB5_FREE_ERROR_MESSAGE |
Darren Tucker | e7bf3a5 | 2015-04-07 10:48:04 +1000 | [diff] [blame] | 122 | # define krb5_free_error_message(a,b) do { } while(0) |
Darren Tucker | f3ab2c5 | 2013-08-04 21:48:41 +1000 | [diff] [blame] | 123 | #endif |
| 124 | |
Damien Miller | 753331e | 1999-12-30 01:29:35 +1100 | [diff] [blame] | 125 | #endif /* _BSD_MISC_H */ |