X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/3cc5d22308fdae0d6c8626cc4f2420f4c2e837a4..51fa929a90af082f6f53f1c85ea99570bf7e0132:/openbsd-compat/bsd-misc.c diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index adf70e29..55f100ac 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c @@ -1,3 +1,4 @@ + /* * Copyright (c) 1999-2004 Damien Miller * @@ -15,9 +16,21 @@ */ #include "includes.h" -#include "xmalloc.h" -RCSID("$Id$"); +#include +#ifdef HAVE_SYS_SELECT_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#include +#include +#include +#include + +#include "xmalloc.h" #ifndef HAVE___PROGNAME char *__progname; @@ -121,17 +134,6 @@ int truncate(const char *path, off_t length) } #endif /* HAVE_TRUNCATE */ -#if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP) -/* - * Cygwin setgroups should be a noop. - */ -int -setgroups(size_t size, const gid_t *list) -{ - return (0); -} -#endif - #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) int nanosleep(const struct timespec *req, struct timespec *rem) { @@ -156,7 +158,8 @@ int nanosleep(const struct timespec *req, struct timespec *rem) tremain.tv_sec = 0; tremain.tv_usec = 0; } - TIMEVAL_TO_TIMESPEC(&tremain, rem) + if (rem != NULL) + TIMEVAL_TO_TIMESPEC(&tremain, rem) return(rc); } @@ -196,22 +199,6 @@ tcsendbreak(int fd, int duration) } #endif /* HAVE_TCSENDBREAK */ -#ifndef HAVE_CLOSEFROM -int -closefrom(int fd) -{ - int i, result = 0, err = 0; - - for (i = fd; i < 128; i++) - if (close(i) != 0) { - err = errno; - result = -1; - } - errno = err; - return result; -} -#endif /* HAVE_CLOSEFROM */ - mysig_t mysignal(int sig, mysig_t act) { @@ -238,3 +225,18 @@ mysignal(int sig, mysig_t act) return (signal(sig, act)); #endif } + +#ifndef HAVE_STRDUP +char * +strdup(const char *str) +{ + size_t len; + char *cp; + + len = strlen(str) + 1; + cp = malloc(len); + if (cp != NULL) + return(memcpy(cp, str, len)); + return NULL; +} +#endif