From e4a505192d23c7d77a6ee68e6e2946bab983ae43 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 1 Jun 2005 10:16:35 +0000 Subject: r7166: Move replacement stuff to seperate directory (easier to add win32-specific bits later) Trim LIBBASIC a bit more (This used to be commit fc7f519e4ae2051e9515df5f549c8e1842b7e70b) --- source4/lib/replace/replace.c | 564 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 564 insertions(+) create mode 100644 source4/lib/replace/replace.c (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c new file mode 100644 index 0000000000..89612912b7 --- /dev/null +++ b/source4/lib/replace/replace.c @@ -0,0 +1,564 @@ +/* + Unix SMB/CIFS implementation. + replacement routines for broken systems + Copyright (C) Andrew Tridgell 1992-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "system/wait.h" +#include "system/time.h" +#include "system/network.h" + + void replace_dummy(void); + void replace_dummy(void) {} + +#ifndef HAVE_FTRUNCATE + /******************************************************************* +ftruncate for operating systems that don't have it +********************************************************************/ + int ftruncate(int f,off_t l) +{ +#ifdef HAVE_CHSIZE + return chsize(f,l); +#else + struct flock fl; + + fl.l_whence = 0; + fl.l_len = 0; + fl.l_start = l; + fl.l_type = F_WRLCK; + return fcntl(f, F_FREESP, &fl); +#endif +} +#endif /* HAVE_FTRUNCATE */ + + +#ifndef HAVE_STRLCPY +/* like strncpy but does not 0 fill the buffer and always null + terminates. bufsize is the size of the destination buffer */ + size_t strlcpy(char *d, const char *s, size_t bufsize) +{ + size_t len = strlen(s); + size_t ret = len; + if (bufsize <= 0) return 0; + if (len >= bufsize) len = bufsize-1; + memcpy(d, s, len); + d[len] = 0; + return ret; +} +#endif + +#ifndef HAVE_STRLCAT +/* like strncat but does not 0 fill the buffer and always null + terminates. bufsize is the length of the buffer, which should + be one more than the maximum resulting string length */ + size_t strlcat(char *d, const char *s, size_t bufsize) +{ + size_t len1 = strlen(d); + size_t len2 = strlen(s); + size_t ret = len1 + len2; + + if (len1+len2 >= bufsize) { + len2 = bufsize - (len1+1); + } + if (len2 > 0) { + memcpy(d+len1, s, len2); + d[len1+len2] = 0; + } + return ret; +} +#endif + +#ifndef HAVE_MKTIME +/******************************************************************* +a mktime() replacement for those who don't have it - contributed by +C.A. Lademann +Corrections by richard.kettlewell@kewill.com +********************************************************************/ + +#define MINUTE 60 +#define HOUR 60*MINUTE +#define DAY 24*HOUR +#define YEAR 365*DAY + time_t mktime(struct tm *t) +{ + struct tm *u; + time_t epoch = 0; + int n; + int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + y, m, i; + + if(t->tm_year < 70) + return((time_t)-1); + + n = t->tm_year + 1900 - 1; + epoch = (t->tm_year - 70) * YEAR + + ((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY; + + y = t->tm_year + 1900; + m = 0; + + for(i = 0; i < t->tm_mon; i++) { + epoch += mon [m] * DAY; + if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) + epoch += DAY; + + if(++m > 11) { + m = 0; + y++; + } + } + + epoch += (t->tm_mday - 1) * DAY; + epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec; + + if((u = localtime(&epoch)) != NULL) { + t->tm_sec = u->tm_sec; + t->tm_min = u->tm_min; + t->tm_hour = u->tm_hour; + t->tm_mday = u->tm_mday; + t->tm_mon = u->tm_mon; + t->tm_year = u->tm_year; + t->tm_wday = u->tm_wday; + t->tm_yday = u->tm_yday; + t->tm_isdst = u->tm_isdst; + } + + return(epoch); +} +#endif /* !HAVE_MKTIME */ + + + +#ifndef HAVE_RENAME +/* Rename a file. (from libiberty in GNU binutils) */ + int rename(const char *zfrom, const char *zto) +{ + if (link (zfrom, zto) < 0) + { + if (errno != EEXIST) + return -1; + if (unlink (zto) < 0 + || link (zfrom, zto) < 0) + return -1; + } + return unlink (zfrom); +} +#endif /* HAVE_RENAME */ + + +#ifndef HAVE_INNETGR +#if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT) +/* + * Search for a match in a netgroup. This replaces it on broken systems. + */ + int innetgr(const char *group,const char *host,const char *user,const char *dom) +{ + char *hst, *usr, *dm; + + setnetgrent(group); + while (getnetgrent(&hst, &usr, &dm)) { + if (((host == 0) || (hst == 0) || !strcmp(host, hst)) && + ((user == 0) || (usr == 0) || !strcmp(user, usr)) && + ((dom == 0) || (dm == 0) || !strcmp(dom, dm))) { + endnetgrent(); + return (1); + } + } + endnetgrent(); + return (0); +} +#endif /* HAVE_SETNETGRENT HAVE_GETNETGRENT HAVE_ENDNETGRENT */ +#endif /* HAVE_INNETGR */ + + + +#ifndef HAVE_INITGROUPS +/**************************************************************************** + some systems don't have an initgroups call +****************************************************************************/ + int initgroups(char *name,gid_t id) +{ +#ifndef HAVE_SETGROUPS + static int done; + if (!done) { + DEBUG(1,("WARNING: running without setgroups\n")); + done=1; + } + /* yikes! no SETGROUPS or INITGROUPS? how can this work? */ + return(0); +#else /* HAVE_SETGROUPS */ + gid_t *grouplst = NULL; + int max_gr = groups_max(); + int ret; + int i,j; + struct group *g; + char *gr; + + if((grouplst = malloc_array_p(gid_t, max_gr)) == NULL) { + DEBUG(0,("initgroups: malloc fail !\n")); + return -1; + } + + grouplst[0] = id; + i = 1; + while (i < max_gr && ((g = (struct group *)getgrent()) != (struct group *)NULL)) { + if (g->gr_gid == id) + continue; + j = 0; + gr = g->gr_mem[0]; + while (gr && (*gr != (char)NULL)) { + if (strcmp(name,gr) == 0) { + grouplst[i] = g->gr_gid; + i++; + gr = (char *)NULL; + break; + } + gr = g->gr_mem[++j]; + } + } + endgrent(); + ret = sys_setgroups(i,grouplst); + SAFE_FREE(grouplst); + return ret; +#endif /* HAVE_SETGROUPS */ +} +#endif /* HAVE_INITGROUPS */ + + +#if (defined(SecureWare) && defined(SCO)) +/* This is needed due to needing the nap() function but we don't want + to include the Xenix libraries since that will break other things... + BTW: system call # 0x0c28 is the same as calling nap() */ + long nap(long milliseconds) { + return syscall(0x0c28, milliseconds); + } +#endif + + +#ifndef HAVE_MEMMOVE +/******************************************************************* +safely copies memory, ensuring no overlap problems. +this is only used if the machine does not have it's own memmove(). +this is not the fastest algorithm in town, but it will do for our +needs. +********************************************************************/ + void *memmove(void *dest,const void *src,int size) +{ + unsigned long d,s; + int i; + if (dest==src || !size) return(dest); + + d = (unsigned long)dest; + s = (unsigned long)src; + + if ((d >= (s+size)) || (s >= (d+size))) { + /* no overlap */ + memcpy(dest,src,size); + return(dest); + } + + if (d < s) { + /* we can forward copy */ + if (s-d >= sizeof(int) && + !(s%sizeof(int)) && + !(d%sizeof(int)) && + !(size%sizeof(int))) { + /* do it all as words */ + int *idest = (int *)dest; + int *isrc = (int *)src; + size /= sizeof(int); + for (i=0;i= sizeof(int) && + !(s%sizeof(int)) && + !(d%sizeof(int)) && + !(size%sizeof(int))) { + /* do it all as words */ + int *idest = (int *)dest; + int *isrc = (int *)src; + size /= sizeof(int); + for (i=size-1;i>=0;i--) idest[i] = isrc[i]; + } else { + /* simplest */ + char *cdest = (char *)dest; + char *csrc = (char *)src; + for (i=size-1;i>=0;i--) cdest[i] = csrc[i]; + } + } + return(dest); +} +#endif /* HAVE_MEMMOVE */ + +#ifndef HAVE_STRDUP +/**************************************************************************** +duplicate a string +****************************************************************************/ + char *strdup(const char *s) +{ + size_t len; + char *ret; + + if (!s) return(NULL); + + len = strlen(s)+1; + ret = (char *)malloc(len); + if (!ret) return(NULL); + memcpy(ret,s,len); + return(ret); +} +#endif /* HAVE_STRDUP */ + +#ifndef WITH_PTHREADS +/* REWRITE: not thread safe */ +#ifdef REPLACE_INET_NTOA + char *rep_inet_ntoa(struct in_addr ip) +{ + uint8_t *p = (uint8_t *)&ip.s_addr; + static char buf[18]; + slprintf(buf, 17, "%d.%d.%d.%d", + (int)p[0], (int)p[1], (int)p[2], (int)p[3]); + return buf; +} +#endif /* REPLACE_INET_NTOA */ +#endif + +#ifndef HAVE_STRTOUL +#ifndef ULONG_MAX +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ +#endif + +/* + * Convert a string to an unsigned long integer. + * Taken from libg++ - libiberty code. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ + unsigned long strtoul(const char *nptr, char **endptr, int base) +{ + const char *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; + cutlim = (int)((unsigned long)ULONG_MAX % (unsigned long)base); + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = ULONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} +#endif /* HAVE_STRTOUL */ + +#ifndef HAVE_SETLINEBUF + int setlinebuf(FILE *stream) +{ + return setvbuf(stream, (char *)NULL, _IOLBF, 0); +} +#endif /* HAVE_SETLINEBUF */ + +#ifndef HAVE_VSYSLOG +#ifdef HAVE_SYSLOG + void vsyslog (int facility_priority, char *format, va_list arglist) +{ + char *msg = NULL; + vasprintf(&msg, format, arglist); + if (!msg) + return; + syslog(facility_priority, "%s", msg); + SAFE_FREE(msg); +} +#endif /* HAVE_SYSLOG */ +#endif /* HAVE_VSYSLOG */ + +/******************************************************************* +yield the difference between *A and *B, in seconds, ignoring leap seconds +********************************************************************/ +static int tm_diff(struct tm *a, struct tm *b) +{ + int ay = a->tm_year + (1900 - 1); + int by = b->tm_year + (1900 - 1); + int intervening_leap_days = + (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400); + int years = ay - by; + int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday); + int hours = 24*days + (a->tm_hour - b->tm_hour); + int minutes = 60*hours + (a->tm_min - b->tm_min); + int seconds = 60*minutes + (a->tm_sec - b->tm_sec); + + return seconds; +} + +/******************************************************************* + return the UTC offset in seconds west of UTC, or 0 if it cannot be determined + ******************************************************************/ +int get_time_zone(time_t t) +{ + struct tm *tm = gmtime(&t); + struct tm tm_utc; + if (!tm) + return 0; + tm_utc = *tm; + tm = localtime(&t); + if (!tm) + return 0; + return tm_diff(&tm_utc,tm); +} + +#ifndef HAVE_TIMEGM +/* + yes, I know this looks insane, but its really needed. The function in the + Linux timegm() manpage does not work on solaris. +*/ + time_t timegm(struct tm *tm) +{ + struct tm tm2, tm3; + time_t t; + + tm2 = *tm; + + t = mktime(&tm2); + tm3 = *localtime(&t); + tm2 = *tm; + tm2.tm_isdst = tm3.tm_isdst; + t = mktime(&tm2); + t -= get_time_zone(t); + + return t; +} +#endif + +#ifndef HAVE_SETENV + int setenv(const char *name, const char *value, int overwrite) +{ + char *p = NULL; + int ret = -1; + + asprintf(&p, "%s=%s", name, value); + + if (overwrite || getenv(name)) { + if (p) ret = putenv(p); + } else { + ret = 0; + } + + return ret; +} +#endif + + +#ifndef HAVE_STRTOULL + unsigned long long int strtoull(const char *str, char **endptr, int base) +{ +#ifdef HAVE_STRTOUQ + return strtouq(str, endptr, base); +#else +#error "system must support 64 bit integer read from strings" +#endif +} +#endif + + +#ifndef HAVE_STRNDUP +/** + Some platforms don't have strndup. +**/ + char *strndup(const char *s, size_t n) +{ + char *ret; + + n = strnlen(s, n); + ret = malloc(n+1); + if (!ret) + return NULL; + memcpy(ret, s, n); + ret[n] = 0; + + return ret; +} +#endif + +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ + size_t strnlen(const char *s, size_t n) +{ + int i; + for (i=0; s[i] && i Date: Tue, 19 Jul 2005 05:35:19 +0000 Subject: r8580: try to fix the build on stratus (This used to be commit 58d7a1e6a311c98c9b4dfc9e280b328406165997) --- source4/lib/replace/replace.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 89612912b7..79b452d69c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -191,16 +191,12 @@ Corrections by richard.kettlewell@kewill.com /**************************************************************************** some systems don't have an initgroups call ****************************************************************************/ - int initgroups(char *name,gid_t id) + int initgroups(char *name, gid_t id) { #ifndef HAVE_SETGROUPS - static int done; - if (!done) { - DEBUG(1,("WARNING: running without setgroups\n")); - done=1; - } /* yikes! no SETGROUPS or INITGROUPS? how can this work? */ - return(0); + errno = ENOSYS; + return -1; #else /* HAVE_SETGROUPS */ gid_t *grouplst = NULL; int max_gr = groups_max(); @@ -209,8 +205,8 @@ Corrections by richard.kettlewell@kewill.com struct group *g; char *gr; - if((grouplst = malloc_array_p(gid_t, max_gr)) == NULL) { - DEBUG(0,("initgroups: malloc fail !\n")); + if((grouplst = malloc(sizeof(gid_t) * max_gr)) == NULL) { + errno = ENOMEM; return -1; } @@ -232,8 +228,8 @@ Corrections by richard.kettlewell@kewill.com } } endgrent(); - ret = sys_setgroups(i,grouplst); - SAFE_FREE(grouplst); + ret = setgroups(i, grouplst); + free(grouplst); return ret; #endif /* HAVE_SETGROUPS */ } @@ -429,7 +425,7 @@ duplicate a string if (!msg) return; syslog(facility_priority, "%s", msg); - SAFE_FREE(msg); + free(msg); } #endif /* HAVE_SYSLOG */ #endif /* HAVE_VSYSLOG */ -- cgit From fe6eeeb60177c0b55366bcfb69be3acf8a95fb3b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Jul 2005 03:46:57 +0000 Subject: r8698: attempt to cope with lack of strtoull() on HPUX (This used to be commit c84c516b179fcbbcdb36c0c0aa4ffb4ff12f2c35) --- source4/lib/replace/replace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 79b452d69c..20a420084a 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -512,7 +512,15 @@ int get_time_zone(time_t t) #ifdef HAVE_STRTOUQ return strtouq(str, endptr, base); #else -#error "system must support 64 bit integer read from strings" + unsigned long long int v; + if (sscanf(str, "%lli", &v) != 1) { + smb_panic("system does not support %lli in sscanf"); + } + if (endptr) { + /* try to get endptr right - uggh */ + strtoul(str, endptr, base); + } + return v; #endif } #endif -- cgit From 0edd0f43c0d25c31e893a4200aa583d83f81ba9c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Jul 2005 10:01:26 +0000 Subject: r8710: another attempt at fixing HPUX (This used to be commit eb3b3c8b407b2208291385539c3379f0420a448e) --- source4/lib/replace/replace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 20a420084a..9ef3999769 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -514,7 +514,8 @@ int get_time_zone(time_t t) #else unsigned long long int v; if (sscanf(str, "%lli", &v) != 1) { - smb_panic("system does not support %lli in sscanf"); + errno = EINVAL; + return 0; } if (endptr) { /* try to get endptr right - uggh */ -- cgit From 5d899b8a35c9ef1e3688fc56495be1c37477e726 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Aug 2005 00:20:40 +0000 Subject: r9369: an attempt to fix the build on HPUX. This is based on work by Don McCall, but takes a slightly different approach that I hope will be more generic (This used to be commit e8260a81cf99be2ccae64135ca0572c8a6ae62ad) --- source4/lib/replace/replace.c | 106 +++++++++++------------------------------- 1 file changed, 27 insertions(+), 79 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 9ef3999769..ae70634215 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -340,75 +340,6 @@ duplicate a string #endif /* REPLACE_INET_NTOA */ #endif -#ifndef HAVE_STRTOUL -#ifndef ULONG_MAX -#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ -#endif - -/* - * Convert a string to an unsigned long integer. - * Taken from libg++ - libiberty code. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ - unsigned long strtoul(const char *nptr, char **endptr, int base) -{ - const char *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; - - /* - * See strtol for comments as to the logic used. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; - cutlim = (int)((unsigned long)ULONG_MAX % (unsigned long)base); - for (acc = 0, any = 0;; c = *s++) { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = ULONG_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = (char *) (any ? s - 1 : nptr); - return (acc); -} -#endif /* HAVE_STRTOUL */ - #ifndef HAVE_SETLINEBUF int setlinebuf(FILE *stream) { @@ -511,17 +442,23 @@ int get_time_zone(time_t t) { #ifdef HAVE_STRTOUQ return strtouq(str, endptr, base); +#elif defined(HAVE___STRTOULL) + return __strtoull(str, endptr, base); #else - unsigned long long int v; - if (sscanf(str, "%lli", &v) != 1) { - errno = EINVAL; - return 0; - } - if (endptr) { - /* try to get endptr right - uggh */ - strtoul(str, endptr, base); - } - return v; +# error "You need a strtoull function" +#endif +} +#endif + +#ifndef HAVE_STRTOLL + long long int strtoll(const char *str, char **endptr, int base) +{ +#ifdef HAVE_STRTOQ + return strtoq(str, endptr, base); +#elif defined(HAVE___STRTOLL) + return __strtoll(str, endptr, base); +#else +# error "You need a strtoll function" #endif } #endif @@ -567,3 +504,14 @@ int sys_waitpid(pid_t pid,int *status,int options) return wait4(pid, status, options, NULL); #endif /* USE_WAITPID */ } + +#ifndef HAVE_SETEUID + int seteuid(uid_t euid) +{ +#ifdef HAVE_SETRESUID + return setresuid(-1, euid, -1); +#else +# error "You need a seteuid function" +#endif +} +#endif -- cgit From 3f260e2efe416a05571c29d8edb81ae0385a00c9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Aug 2005 01:57:43 +0000 Subject: r9374: HPUX is also missing setegid() (This used to be commit 57e6bd61395e82064c72510dcc326b11b7bdf7fd) --- source4/lib/replace/replace.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index ae70634215..ef8e053257 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -515,3 +515,14 @@ int sys_waitpid(pid_t pid,int *status,int options) #endif } #endif + +#ifndef HAVE_SETEGID + int setegid(gid_t egid) +{ +#ifdef HAVE_SETRESGID + return setresgid(-1, egid, -1); +#else +# error "You need a setegid function" +#endif +} +#endif -- cgit From f3b412fbd6dd94d64eb6a63d88baef2816891c29 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 Sep 2005 00:38:22 +0000 Subject: r10438: Move portability functions to lib/replace/; replace now simply ensures that a given set of (working) POSIX functions are available (without prefixes to their names, etc). See lib/replace/README for a list. Functions that behave different from their POSIX specification (such as sys_select, sys_read, etc) have kept the sys_ prefix. (This used to be commit 29919a71059b29fa27a49b1f5b84bb8881de65fc) --- source4/lib/replace/replace.c | 73 +++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 38 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index ef8e053257..aa79f23fd0 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -361,39 +361,6 @@ duplicate a string #endif /* HAVE_SYSLOG */ #endif /* HAVE_VSYSLOG */ -/******************************************************************* -yield the difference between *A and *B, in seconds, ignoring leap seconds -********************************************************************/ -static int tm_diff(struct tm *a, struct tm *b) -{ - int ay = a->tm_year + (1900 - 1); - int by = b->tm_year + (1900 - 1); - int intervening_leap_days = - (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400); - int years = ay - by; - int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday); - int hours = 24*days + (a->tm_hour - b->tm_hour); - int minutes = 60*hours + (a->tm_min - b->tm_min); - int seconds = 60*minutes + (a->tm_sec - b->tm_sec); - - return seconds; -} - -/******************************************************************* - return the UTC offset in seconds west of UTC, or 0 if it cannot be determined - ******************************************************************/ -int get_time_zone(time_t t) -{ - struct tm *tm = gmtime(&t); - struct tm tm_utc; - if (!tm) - return 0; - tm_utc = *tm; - tm = localtime(&t); - if (!tm) - return 0; - return tm_diff(&tm_utc,tm); -} #ifndef HAVE_TIMEGM /* @@ -496,14 +463,12 @@ int get_time_zone(time_t t) } #endif -int sys_waitpid(pid_t pid,int *status,int options) +#ifndef HAVE_WAITPID +int waitpid(pid_t pid,int *status,int options) { -#ifdef HAVE_WAITPID - return waitpid(pid,status,options); -#else /* USE_WAITPID */ return wait4(pid, status, options, NULL); -#endif /* USE_WAITPID */ } +#endif #ifndef HAVE_SETEUID int seteuid(uid_t euid) @@ -526,3 +491,35 @@ int sys_waitpid(pid_t pid,int *status,int options) #endif } #endif + +/******************************************************************* +os/2 also doesn't have chroot +********************************************************************/ +#ifndef HAVE_CHROOT +int chroot(const char *dname) +{ + static int done; + if (!done) { + DEBUG(1,("WARNING: no chroot!\n")); + done=1; + } + errno = ENOSYS; + return -1; +} +#endif + +/***************************************************************** + Possibly replace mkstemp if it is broken. +*****************************************************************/ + +#ifndef HAVE_SECURE_MKSTEMP +int rep_mkstemp(char *template) +{ + /* have a reasonable go at emulating it. Hope that + the system mktemp() isn't completly hopeless */ + char *p = mktemp(template); + if (!p) + return -1; + return open(p, O_CREAT|O_EXCL|O_RDWR, 0600); +} +#endif -- cgit From 4be0ae794e4af2354d678fddd7bf1e822ffa9148 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 Sep 2005 16:32:52 +0000 Subject: r10456: More SCons fixes: - Add framework for fallback generating code - Move pread / pwrite replacement functions to libreplace - Support pidl builds correctly - Support asn1 builds correctly - Move OS-specific checks to lib/replace/SConscript (This used to be commit fbbfad0a1f7dedbf48e835a864f8285f283d72f3) --- source4/lib/replace/replace.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index aa79f23fd0..c53b5a5727 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -523,3 +523,25 @@ int rep_mkstemp(char *template) return open(p, O_CREAT|O_EXCL|O_RDWR, 0600); } #endif + +#ifndef HAVE_PREAD +static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) +{ + if (lseek(__fd, __offset, SEEK_SET) != __offset) { + return -1; + } + return read(__fd, __buf, __nbytes); +} +#endif + +#ifndef HAVE_PWRITE +static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) +{ + if (lseek(__fd, __offset, SEEK_SET) != __offset) { + return -1; + } + return write(__fd, __buf, __nbytes); +} +#endif + + -- cgit From a2dffe109bc989c5a610d610a2f1a31f10d65968 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Sep 2005 02:36:56 +0000 Subject: r10523: fixed timegm() to not depend on get_time_zone(), so it works in lib/replace/ the old timegm() replacement was also broken (it returned the wrong value) (This used to be commit 342489a1d4d5cc4b16cf2e5ff7e671326f0cb3d5) --- source4/lib/replace/replace.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index c53b5a5727..5e60252a67 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -369,18 +369,8 @@ duplicate a string */ time_t timegm(struct tm *tm) { - struct tm tm2, tm3; - time_t t; - - tm2 = *tm; - - t = mktime(&tm2); - tm3 = *localtime(&t); - tm2 = *tm; - tm2.tm_isdst = tm3.tm_isdst; - t = mktime(&tm2); - t -= get_time_zone(t); - + time_t t = mktime(tm); + t -= mktime(gmtime(&t)) - (int)mktime(localtime(&t)); return t; } #endif -- cgit From 1584f64920431d15276dd44c59fc35dc5506c0e7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Oct 2005 12:30:34 +0000 Subject: r10896: added a strcasestr() replacement function (This used to be commit 4483d275e12006e5acc72ae143c0a01da01bd00d) --- source4/lib/replace/replace.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 5e60252a67..d87a009e8c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -22,6 +22,7 @@ #include "system/wait.h" #include "system/time.h" #include "system/network.h" +#include "system/iconv.h" void replace_dummy(void); void replace_dummy(void) {} @@ -534,4 +535,17 @@ static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offs } #endif - +#ifndef HAVE_STRCASESTR +char *strcasestr(const char *haystack, const char *needle) +{ + const char *s; + size_t nlen = strlen(needle); + for (s=haystack;*s;s++) { + if (toupper(*needle) == toupper(*s) && + strncasecmp(s, needle, nlen) == 0) { + return discard_const_p(char, s); + } + } + return NULL; +} +#endif -- cgit From 10ec7dd61f563cca0981d65ac3e84ed9f2bd1a12 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 27 Oct 2005 23:02:47 +0000 Subject: r11343: Remove dependency on DEBUG() (This used to be commit 407b5e615f80ab2f7a3d10bafd9284de7f02fe60) --- source4/lib/replace/replace.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index d87a009e8c..5d3ef52987 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -489,11 +489,6 @@ os/2 also doesn't have chroot #ifndef HAVE_CHROOT int chroot(const char *dname) { - static int done; - if (!done) { - DEBUG(1,("WARNING: no chroot!\n")); - done=1; - } errno = ENOSYS; return -1; } -- cgit From e572bbb94cb8a23d366647bcf584cc75029e8def Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 29 Apr 2006 12:39:19 +0000 Subject: r15321: Reduce the size of rewrite.m4 a bit more (This used to be commit c83e4b166534278c335254aa8890a50635bbf1b7) --- source4/lib/replace/replace.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 5d3ef52987..90f05d6c90 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -22,6 +22,7 @@ #include "system/wait.h" #include "system/time.h" #include "system/network.h" +#include "system/filesys.h" #include "system/iconv.h" void replace_dummy(void); -- cgit From ec83aa3fda3de99e1a58292af1302c42376c8739 Mon Sep 17 00:00:00 2001 From: Paul Green Date: Mon, 1 May 2006 20:57:15 +0000 Subject: r15382: Use grp.h in this block; it has been cleaned out of the other headers that formerly included it for us. Paul (This used to be commit a4d706cf26382820b58940458f8873a4f8f79612) --- source4/lib/replace/replace.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 90f05d6c90..415ea2f129 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -200,6 +200,9 @@ Corrections by richard.kettlewell@kewill.com errno = ENOSYS; return -1; #else /* HAVE_SETGROUPS */ + +#include + gid_t *grouplst = NULL; int max_gr = groups_max(); int ret; -- cgit From 172a83d72491f90f6191be1040ef8b2e1789bd2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 May 2006 19:14:12 +0000 Subject: r15573: Fix build of systems that have iconv headers in non-standard locations Split of system/locale.h header from system/iconv.h Previously, iconv wasn't being used on these systems (This used to be commit aa6d66fda69779d1c2948a1aca85dbd5208f1cba) --- source4/lib/replace/replace.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 415ea2f129..337a54f24f 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -23,7 +23,6 @@ #include "system/time.h" #include "system/network.h" #include "system/filesys.h" -#include "system/iconv.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 96a858b5cd6243c15fb9649956d2f7718521661b Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 19 May 2006 18:37:35 +0000 Subject: r15719: Fix build on systems (AIX) that don't have vsyslog or strcasestr, with --enable-developer on. syslog() and toupper() required more includes. Someone more familiar with samba4 builds should verify this, please. (This used to be commit d28f49fc6d3b7ee1b7077e2d35b2aee54d2d1469) --- source4/lib/replace/replace.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 337a54f24f..f72394cb0f 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -19,10 +19,12 @@ */ #include "includes.h" +#include "system/locale.h" #include "system/wait.h" #include "system/time.h" #include "system/network.h" #include "system/filesys.h" +#include "system/syslog.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 01b8c1913d75a9b74a1a4bf3e7d8a80f18db0b2d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 25 May 2006 02:09:00 +0000 Subject: r15879: strtok_r() replacement, for solaris (This used to be commit df5bd916db3cfbd6c145177fd8992261f03a5cbc) --- source4/lib/replace/replace.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index f72394cb0f..38a3d517df 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -549,3 +549,30 @@ char *strcasestr(const char *haystack, const char *needle) return NULL; } #endif + +#ifndef HAVE_STRTOK_R +/* based on GLIBC version, copyright Free Software Foundation */ +char *strtok_r(char *s, const char *delim, char **save_ptr) +{ + char *token; + + if (s == NULL) s = *save_ptr; + + s += strspn(s, delim); + if (*s == '\0') { + *save_ptr = s; + return NULL; + } + + token = s; + s = strpbrk(token, delim); + if (s == NULL) { + *save_ptr = token + strlen(token); + } else { + *s = '\0'; + *save_ptr = s + 1; + } + + return token; +} +#endif -- cgit From 0a1a19d9d95b5adbe6c3dd3ed689ce7e3b43ab12 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 30 May 2006 05:57:43 +0000 Subject: r15953: our timegm() replacement still doesn't work, so grab the one from Heimdal which does work. This should fix most of the rest of the failures on solaris (This used to be commit acfaa98b5ea686feb81350baf09b3f4480f96edc) --- source4/lib/replace/replace.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 38a3d517df..6f51bd2e99 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -368,19 +368,6 @@ duplicate a string #endif /* HAVE_VSYSLOG */ -#ifndef HAVE_TIMEGM -/* - yes, I know this looks insane, but its really needed. The function in the - Linux timegm() manpage does not work on solaris. -*/ - time_t timegm(struct tm *tm) -{ - time_t t = mktime(tm); - t -= mktime(gmtime(&t)) - (int)mktime(localtime(&t)); - return t; -} -#endif - #ifndef HAVE_SETENV int setenv(const char *name, const char *value, int overwrite) { -- cgit From c62d1d21ab0f3ff34c1c695ff2132b5a9ff25eaa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Jun 2006 12:51:42 +0000 Subject: r16003: Tru64 doesn't have strtoll/strtoull but the size of 'long' is equal to the size of 'long long' so we can use strtol/strtoul Patch from Bjoern Jacke, thanks! (I only added the SIZEOF_LONG == SIZEOF_LONG_LONG) metze (This used to be commit 2bda7b63be1257210601dac3e2b1070f48d765b4) --- source4/lib/replace/replace.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 6f51bd2e99..02c3d04163 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -394,6 +394,8 @@ duplicate a string return strtouq(str, endptr, base); #elif defined(HAVE___STRTOULL) return __strtoull(str, endptr, base); +#elif SIZEOF_LONG == SIZEOF_LONG_LONG + return (unsigned long long int) strtoul(str, endptr, base); #else # error "You need a strtoull function" #endif @@ -407,6 +409,8 @@ duplicate a string return strtoq(str, endptr, base); #elif defined(HAVE___STRTOLL) return __strtoll(str, endptr, base); +#elif SIZEOF_LONG == SIZEOF_LONG_LONG + return (long long int) strtol(str, endptr, base); #else # error "You need a strtoll function" #endif -- cgit From ff2041c955e9152bd286ab6ea534b8445caab574 Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 27 Jun 2006 05:49:09 +0000 Subject: r16556: Add mkdtemp to libreplace. This is apparantly available on Linux and BSD systems, but it's not everywhere. (This used to be commit b3d2512ed4fc8c378607bcc2dc241a1f77ab7197) --- source4/lib/replace/replace.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 02c3d04163..989c0947c3 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -506,6 +506,21 @@ int rep_mkstemp(char *template) } #endif +#ifndef HAVE_MKDTEMP +char * mkdtemp(char *template) +{ + char *dname; + + if (dname = mktemp(template)) { + if (mkdir(dname, 0700) >= 0) { + return dname; + } + } + + return NULL; +} +#endif + #ifndef HAVE_PREAD static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) { -- cgit From 09129c73d7b7fc97478fe642dc43f7e5ce9a2ba9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 23 Aug 2006 11:32:29 +0000 Subject: r17750: these have moved to ldb/replace/ now (This used to be commit ac178b52935d7629f8583092e833b74093ca70e1) --- source4/lib/replace/replace.c | 44 ------------------------------------------- 1 file changed, 44 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 989c0947c3..b74cd7f95a 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,37 +387,6 @@ duplicate a string #endif -#ifndef HAVE_STRTOULL - unsigned long long int strtoull(const char *str, char **endptr, int base) -{ -#ifdef HAVE_STRTOUQ - return strtouq(str, endptr, base); -#elif defined(HAVE___STRTOULL) - return __strtoull(str, endptr, base); -#elif SIZEOF_LONG == SIZEOF_LONG_LONG - return (unsigned long long int) strtoul(str, endptr, base); -#else -# error "You need a strtoull function" -#endif -} -#endif - -#ifndef HAVE_STRTOLL - long long int strtoll(const char *str, char **endptr, int base) -{ -#ifdef HAVE_STRTOQ - return strtoq(str, endptr, base); -#elif defined(HAVE___STRTOLL) - return __strtoll(str, endptr, base); -#elif SIZEOF_LONG == SIZEOF_LONG_LONG - return (long long int) strtol(str, endptr, base); -#else -# error "You need a strtoll function" -#endif -} -#endif - - #ifndef HAVE_STRNDUP /** Some platforms don't have strndup. @@ -437,19 +406,6 @@ duplicate a string } #endif -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ - size_t strnlen(const char *s, size_t n) -{ - int i; - for (i=0; s[i] && i Date: Wed, 23 Aug 2006 23:21:29 +0000 Subject: r17763: moved setenv to ldb/replace/ (This used to be commit ed2dbc4dfe4556831c809dab24e3833cd2018138) --- source4/lib/replace/replace.c | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b74cd7f95a..b8f4bc1c3c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -368,25 +368,6 @@ duplicate a string #endif /* HAVE_VSYSLOG */ -#ifndef HAVE_SETENV - int setenv(const char *name, const char *value, int overwrite) -{ - char *p = NULL; - int ret = -1; - - asprintf(&p, "%s=%s", name, value); - - if (overwrite || getenv(name)) { - if (p) ret = putenv(p); - } else { - ret = 0; - } - - return ret; -} -#endif - - #ifndef HAVE_STRNDUP /** Some platforms don't have strndup. -- cgit From d3c55f028e4160506538c9e1c57d3a6e22701a3c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Aug 2006 16:19:22 +0000 Subject: r17840: A step towards building on Solaris which appears not to have strnlen. Volker (This used to be commit ebf75c6196afdd4bfa4f11bb1d45d385ab0babed) --- source4/lib/replace/replace.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b8f4bc1c3c..1cf91751b3 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,6 +387,20 @@ duplicate a string } #endif +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ + + size_t strnlen(const char *s, size_t n) +{ + size_t i; + for (i=0; i Date: Sat, 26 Aug 2006 16:44:10 +0000 Subject: r17841: Revert 17840, libldb.a defines strnlen. Sorry for the noise (This used to be commit 1de34590821b0c076bf8d48cbdae97f33275647e) --- source4/lib/replace/replace.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 1cf91751b3..b8f4bc1c3c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,20 +387,6 @@ duplicate a string } #endif -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ - - size_t strnlen(const char *s, size_t n) -{ - size_t i; - for (i=0; i Date: Sat, 26 Aug 2006 17:19:58 +0000 Subject: r17842: After talking to Simo, apply the next attempt to resolve the strnlen problem. Timegm is the same. Simo says this is just a workaround, but it helps for now. Feel free to revert. Volker (This used to be commit fd166ca0c079d83081bc1d631fe40b965c7873d4) --- source4/lib/replace/replace.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b8f4bc1c3c..f8bd62109d 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,6 +387,20 @@ duplicate a string } #endif +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ + + size_t strnlen(const char *s, size_t n) +{ + size_t i; + for (i=0; itm_year; ++i) + res += is_leap(i) ? 366 : 365; + + for (i = 0; i < tm->tm_mon; ++i) + res += ndays[is_leap(tm->tm_year)][i]; + res += tm->tm_mday - 1; + res *= 24; + res += tm->tm_hour; + res *= 60; + res += tm->tm_min; + res *= 60; + res += tm->tm_sec; + return res; +} +#endif -- cgit From 0bb1c2da0e4164b448c6b7cc988f59b59225802c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Sep 2006 12:37:17 +0000 Subject: r17992: reverted r17842 This needs more consideration, as the patch removed the copyright notice and license from the timegm.c code. Volker, when you get a minute can you let me know what problem this patch fixed so I can find a different approach? (This used to be commit 5b9b9dd5303300778bb9e6d0479ab03fdd70c67d) --- source4/lib/replace/replace.c | 46 ------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index f8bd62109d..b8f4bc1c3c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,20 +387,6 @@ duplicate a string } #endif -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ - - size_t strnlen(const char *s, size_t n) -{ - size_t i; - for (i=0; itm_year; ++i) - res += is_leap(i) ? 366 : 365; - - for (i = 0; i < tm->tm_mon; ++i) - res += ndays[is_leap(tm->tm_year)][i]; - res += tm->tm_mday - 1; - res *= 24; - res += tm->tm_hour; - res *= 60; - res += tm->tm_min; - res *= 60; - res += tm->tm_sec; - return res; -} -#endif -- cgit From 515067a02eb03242411c8af4642265784af8d177 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Sep 2006 16:33:12 +0000 Subject: r18018: Fix the build on OpenBSD. No license problem this time, I've written strnlen from scratch. Volker (This used to be commit 2a7cdf52e4113db30a7a8b180c68cec736f6c186) --- source4/lib/replace/replace.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b8f4bc1c3c..4048fe558e 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -367,7 +367,23 @@ duplicate a string #endif /* HAVE_SYSLOG */ #endif /* HAVE_VSYSLOG */ - +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ + size_t strnlen(const char *s, size_t max) +{ + size_t len; + + for (len = 0; len < max; len++) { + if (s[len] == '\0') { + break; + } + } + return len; +} +#endif + #ifndef HAVE_STRNDUP /** Some platforms don't have strndup. -- cgit From 38fdde5d9bf15b10caa60ee216d278ba8d870c2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 12:21:42 +0000 Subject: r18031: Merge my replace fixes: * libreplace can now build stand-alone * add stub testsuite for libreplace * make talloc/tdb/ldb use libreplace (This used to be commit fe7ca4b1454e01a33ed0d53791ebffdd349298b4) --- source4/lib/replace/replace.c | 200 ++++++++++++++++++++++++++++++++---------- 1 file changed, 156 insertions(+), 44 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 4048fe558e..5333c6a9fe 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -2,38 +2,41 @@ Unix SMB/CIFS implementation. replacement routines for broken systems Copyright (C) Andrew Tridgell 1992-1998 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "includes.h" -#include "system/locale.h" -#include "system/wait.h" -#include "system/time.h" -#include "system/network.h" -#include "system/filesys.h" -#include "system/syslog.h" +#include "replace.h" + +#include +#include +#include +#include - void replace_dummy(void); - void replace_dummy(void) {} +void replace_dummy(void); +void replace_dummy(void) {} #ifndef HAVE_FTRUNCATE /******************************************************************* ftruncate for operating systems that don't have it ********************************************************************/ - int ftruncate(int f,off_t l) +int rep_ftruncate(int f, off_t l) { #ifdef HAVE_CHSIZE return chsize(f,l); @@ -53,7 +56,7 @@ ftruncate for operating systems that don't have it #ifndef HAVE_STRLCPY /* like strncpy but does not 0 fill the buffer and always null terminates. bufsize is the size of the destination buffer */ - size_t strlcpy(char *d, const char *s, size_t bufsize) +size_t rep_strlcpy(char *d, const char *s, size_t bufsize) { size_t len = strlen(s); size_t ret = len; @@ -69,7 +72,7 @@ ftruncate for operating systems that don't have it /* like strncat but does not 0 fill the buffer and always null terminates. bufsize is the length of the buffer, which should be one more than the maximum resulting string length */ - size_t strlcat(char *d, const char *s, size_t bufsize) +size_t rep_strlcat(char *d, const char *s, size_t bufsize) { size_t len1 = strlen(d); size_t len2 = strlen(s); @@ -97,7 +100,7 @@ Corrections by richard.kettlewell@kewill.com #define HOUR 60*MINUTE #define DAY 24*HOUR #define YEAR 365*DAY - time_t mktime(struct tm *t) +time_t rep_mktime(struct tm *t) { struct tm *u; time_t epoch = 0; @@ -149,7 +152,7 @@ Corrections by richard.kettlewell@kewill.com #ifndef HAVE_RENAME /* Rename a file. (from libiberty in GNU binutils) */ - int rename(const char *zfrom, const char *zto) +int rep_rename(const char *zfrom, const char *zto) { if (link (zfrom, zto) < 0) { @@ -169,7 +172,8 @@ Corrections by richard.kettlewell@kewill.com /* * Search for a match in a netgroup. This replaces it on broken systems. */ - int innetgr(const char *group,const char *host,const char *user,const char *dom) +int rep_innetgr(const char *group, const char *host, const char *user, + const char *dom) { char *hst, *usr, *dm; @@ -194,7 +198,7 @@ Corrections by richard.kettlewell@kewill.com /**************************************************************************** some systems don't have an initgroups call ****************************************************************************/ - int initgroups(char *name, gid_t id) +int rep_initgroups(char *name, gid_t id) { #ifndef HAVE_SETGROUPS /* yikes! no SETGROUPS or INITGROUPS? how can this work? */ @@ -246,7 +250,7 @@ Corrections by richard.kettlewell@kewill.com /* This is needed due to needing the nap() function but we don't want to include the Xenix libraries since that will break other things... BTW: system call # 0x0c28 is the same as calling nap() */ - long nap(long milliseconds) { +long nap(long milliseconds) { return syscall(0x0c28, milliseconds); } #endif @@ -259,7 +263,7 @@ this is only used if the machine does not have it's own memmove(). this is not the fastest algorithm in town, but it will do for our needs. ********************************************************************/ - void *memmove(void *dest,const void *src,int size) +void *rep_memmove(void *dest,const void *src,int size) { unsigned long d,s; int i; @@ -317,7 +321,7 @@ needs. /**************************************************************************** duplicate a string ****************************************************************************/ - char *strdup(const char *s) +char *rep_strdup(const char *s) { size_t len; char *ret; @@ -335,7 +339,7 @@ duplicate a string #ifndef WITH_PTHREADS /* REWRITE: not thread safe */ #ifdef REPLACE_INET_NTOA - char *rep_inet_ntoa(struct in_addr ip) +char *rep_inet_ntoa(struct in_addr ip) { uint8_t *p = (uint8_t *)&ip.s_addr; static char buf[18]; @@ -347,7 +351,7 @@ duplicate a string #endif #ifndef HAVE_SETLINEBUF - int setlinebuf(FILE *stream) +int rep_setlinebuf(FILE *stream) { return setvbuf(stream, (char *)NULL, _IOLBF, 0); } @@ -355,7 +359,7 @@ duplicate a string #ifndef HAVE_VSYSLOG #ifdef HAVE_SYSLOG - void vsyslog (int facility_priority, char *format, va_list arglist) +void rep_vsyslog (int facility_priority, char *format, va_list arglist) { char *msg = NULL; vasprintf(&msg, format, arglist); @@ -388,7 +392,7 @@ duplicate a string /** Some platforms don't have strndup. **/ - char *strndup(const char *s, size_t n) +char *rep_strndup(const char *s, size_t n) { char *ret; @@ -404,14 +408,14 @@ duplicate a string #endif #ifndef HAVE_WAITPID -int waitpid(pid_t pid,int *status,int options) +int rep_waitpid(pid_t pid,int *status,int options) { return wait4(pid, status, options, NULL); } #endif #ifndef HAVE_SETEUID - int seteuid(uid_t euid) +int rep_seteuid(uid_t euid) { #ifdef HAVE_SETRESUID return setresuid(-1, euid, -1); @@ -422,7 +426,7 @@ int waitpid(pid_t pid,int *status,int options) #endif #ifndef HAVE_SETEGID - int setegid(gid_t egid) +int rep_setegid(gid_t egid) { #ifdef HAVE_SETRESGID return setresgid(-1, egid, -1); @@ -436,7 +440,7 @@ int waitpid(pid_t pid,int *status,int options) os/2 also doesn't have chroot ********************************************************************/ #ifndef HAVE_CHROOT -int chroot(const char *dname) +int rep_chroot(const char *dname) { errno = ENOSYS; return -1; @@ -460,7 +464,7 @@ int rep_mkstemp(char *template) #endif #ifndef HAVE_MKDTEMP -char * mkdtemp(char *template) +char *rep_mkdtemp(char *template) { char *dname; @@ -475,7 +479,7 @@ char * mkdtemp(char *template) #endif #ifndef HAVE_PREAD -static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) +static ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; @@ -485,7 +489,7 @@ static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) #endif #ifndef HAVE_PWRITE -static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) +static ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; @@ -495,7 +499,7 @@ static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offs #endif #ifndef HAVE_STRCASESTR -char *strcasestr(const char *haystack, const char *needle) +char *rep_strcasestr(const char *haystack, const char *needle) { const char *s; size_t nlen = strlen(needle); @@ -511,7 +515,7 @@ char *strcasestr(const char *haystack, const char *needle) #ifndef HAVE_STRTOK_R /* based on GLIBC version, copyright Free Software Foundation */ -char *strtok_r(char *s, const char *delim, char **save_ptr) +char *rep_strtok_r(char *s, const char *delim, char **save_ptr) { char *token; @@ -535,3 +539,111 @@ char *strtok_r(char *s, const char *delim, char **save_ptr) return token; } #endif + +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ +size_t rep_strnlen(const char *s, size_t n) +{ + int i; + for (i=0; s[i] && itm_year; ++i) + res += is_leap(i) ? 366 : 365; + + for (i = 0; i < tm->tm_mon; ++i) + res += ndays[is_leap(tm->tm_year)][i]; + res += tm->tm_mday - 1; + res *= 24; + res += tm->tm_hour; + res *= 60; + res += tm->tm_min; + res *= 60; + res += tm->tm_sec; + return res; +} +#endif -- cgit From c90a12781be9f38ba2f03e903205e347733ff4a9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 13:10:14 +0000 Subject: r18040: Use only one strnlen implementation (This used to be commit 9a421425d242f6e0385414121c114c7c62ea1aaa) --- source4/lib/replace/replace.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 5333c6a9fe..1c05c14eb6 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -375,7 +375,7 @@ void rep_vsyslog (int facility_priority, char *format, va_list arglist) /** Some platforms don't have strnlen **/ - size_t strnlen(const char *s, size_t max) + size_t rep_strnlen(const char *s, size_t max) { size_t len; @@ -540,19 +540,6 @@ char *rep_strtok_r(char *s, const char *delim, char **save_ptr) } #endif -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ -size_t rep_strnlen(const char *s, size_t n) -{ - int i; - for (i=0; s[i] && i Date: Mon, 4 Sep 2006 13:35:03 +0000 Subject: r18044: timegm.c needs to be in a separate file (This used to be commit 3ec1db7bd12cdc233c37f261073a33fc48ecd7ce) --- source4/lib/replace/replace.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 1c05c14eb6..7bfdc3d640 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -468,7 +468,7 @@ char *rep_mkdtemp(char *template) { char *dname; - if (dname = mktemp(template)) { + if ((dname = mktemp(template))) { if (mkdir(dname, 0700) >= 0) { return dname; } @@ -603,34 +603,3 @@ int rep_setenv(const char *name, const char *value, int overwrite) } #endif -#if !defined(HAVE_TIMEGM) - -static int is_leap(unsigned y) -{ - y += 1900; - return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0); -} - -time_t timegm(struct tm *tm) -{ - static const unsigned ndays[2][12] ={ - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; - time_t res = 0; - unsigned i; - - for (i = 70; i < tm->tm_year; ++i) - res += is_leap(i) ? 366 : 365; - - for (i = 0; i < tm->tm_mon; ++i) - res += ndays[is_leap(tm->tm_year)][i]; - res += tm->tm_mday - 1; - res *= 24; - res += tm->tm_hour; - res *= 60; - res += tm->tm_min; - res *= 60; - res += tm->tm_sec; - return res; -} -#endif -- cgit From cbae8b2014dc118e876018a0dcf27167724d0143 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 22:58:55 +0000 Subject: r18052: discard_const_p() isn't part of the libreplace API, so we can't use it inside libreplace. (This used to be commit 5745ecdd826c387137a742f32ee3c8f60191a6a7) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 7bfdc3d640..17a04c6239 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -506,7 +506,7 @@ char *rep_strcasestr(const char *haystack, const char *needle) for (s=haystack;*s;s++) { if (toupper(*needle) == toupper(*s) && strncasecmp(s, needle, nlen) == 0) { - return discard_const_p(char, s); + return (char *)((intptr_t)s); } } return NULL; -- cgit From e057ef3c6f97f85b846add87aebf97c24170c55f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 02:05:36 +0000 Subject: r18056: includes needed for O_CREAT (This used to be commit 0b80ee8b3b17d4914010c9a54d5c2dcb69738990) --- source4/lib/replace/replace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 17a04c6239..b1154fb7a2 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -26,8 +26,10 @@ #include #include -#include #include +#include +#include +#include void replace_dummy(void); void replace_dummy(void) {} -- cgit From 5d363fa0ddcb8d6c6f13e4e975ce260c40780092 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 04:58:23 +0000 Subject: r18061: this should fix the libreplace build on us4 with gcc (This used to be commit 71c0a0731c52458105974e9ad727b7ba403fd992) --- source4/lib/replace/replace.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b1154fb7a2..b9c106d582 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -31,6 +31,14 @@ #include #include +#if HAVE_SYS_SOCKET_H +#include +#endif + +#if HAVE_NETINET_IN_H +#include +#endif + void replace_dummy(void); void replace_dummy(void) {} -- cgit From a983b06d37c3b87a02444d9a9862777b88629344 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 04:44:32 +0000 Subject: r18129: moved the system includes into libreplace - this gives much more isolation of our portability environment from the main code, and also simplifies the includes system (no separate #ifdef _SAMBA_BUILD for tdb. ldb etc now) (This used to be commit 77d1a468e06290aba789e2f3affc769fc5159a21) --- source4/lib/replace/replace.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b9c106d582..733cb758bd 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -24,20 +24,10 @@ #include "replace.h" -#include -#include -#include -#include -#include -#include - -#if HAVE_SYS_SOCKET_H -#include -#endif - -#if HAVE_NETINET_IN_H -#include -#endif +#include "system/filesys.h" +#include "system/time.h" +#include "system/passwd.h" +#include "system/syslog.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 9ac11823bb874dde0cc6341662825f6cd8c38a07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 06:12:36 +0000 Subject: r18139: irix needs system/network.h here (This used to be commit f46ab799b41c0ec520739ec11979771316781ce4) --- source4/lib/replace/replace.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 733cb758bd..79ec2b75b9 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -28,6 +28,7 @@ #include "system/time.h" #include "system/passwd.h" #include "system/syslog.h" +#include "system/network.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 92ff10f7b0bafb9260fff5d4abe6c596ac034e23 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 06:14:40 +0000 Subject: r18140: and this reduces warnings about toupper() (This used to be commit 41419e54d5e79d08a71cd9c94585be3448b1e9fc) --- source4/lib/replace/replace.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 79ec2b75b9..db07e49941 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -29,6 +29,7 @@ #include "system/passwd.h" #include "system/syslog.h" #include "system/network.h" +#include "system/locale.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 3ca73facc59ed8a97abbc28c1b4bedde87e109a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 11:31:59 +0000 Subject: r18160: - pread and pwrite replacements need to be non-static - replacing rename() is pointless - all platforms have it (and the #define of rename breaks some code) - use system/locale.h in snprintf.c - fix passwd.h for initgroups - stdlib is in replace.h, not needed elsewhere - fix the initgroups replacement - fix mapping of dl functions to rep_* (This used to be commit 57cd0ca176387d6a3acabf9fedeef4f2a3a3dad7) --- source4/lib/replace/replace.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index db07e49941..048ea3a998 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -30,6 +30,7 @@ #include "system/syslog.h" #include "system/network.h" #include "system/locale.h" +#include "system/wait.h" void replace_dummy(void); void replace_dummy(void) {} @@ -42,7 +43,7 @@ int rep_ftruncate(int f, off_t l) { #ifdef HAVE_CHSIZE return chsize(f,l); -#else +#elif defined(F_FREESP) struct flock fl; fl.l_whence = 0; @@ -50,6 +51,8 @@ int rep_ftruncate(int f, off_t l) fl.l_start = l; fl.l_type = F_WRLCK; return fcntl(f, F_FREESP, &fl); +#else +#error "you must have a ftruncate function" #endif } #endif /* HAVE_FTRUNCATE */ @@ -151,24 +154,6 @@ time_t rep_mktime(struct tm *t) #endif /* !HAVE_MKTIME */ - -#ifndef HAVE_RENAME -/* Rename a file. (from libiberty in GNU binutils) */ -int rep_rename(const char *zfrom, const char *zto) -{ - if (link (zfrom, zto) < 0) - { - if (errno != EEXIST) - return -1; - if (unlink (zto) < 0 - || link (zfrom, zto) < 0) - return -1; - } - return unlink (zfrom); -} -#endif /* HAVE_RENAME */ - - #ifndef HAVE_INNETGR #if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT) /* @@ -211,7 +196,7 @@ int rep_initgroups(char *name, gid_t id) #include gid_t *grouplst = NULL; - int max_gr = groups_max(); + int max_gr = 32; int ret; int i,j; struct group *g; @@ -481,7 +466,7 @@ char *rep_mkdtemp(char *template) #endif #ifndef HAVE_PREAD -static ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) +ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; @@ -491,7 +476,7 @@ static ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) #endif #ifndef HAVE_PWRITE -static ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) +ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; -- cgit From a8421e81078b91ae97ada3be352416eae26a9c7b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 14:19:38 +0000 Subject: r18343: fixed setlinebuf() prototype, added test for it, and use it in two places to avoid a #ifdef (This used to be commit 095b8057740a4bb207e24e4c63a2dcb53521a72f) --- source4/lib/replace/replace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 048ea3a998..aa3e8717c2 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -338,9 +338,9 @@ char *rep_inet_ntoa(struct in_addr ip) #endif #ifndef HAVE_SETLINEBUF -int rep_setlinebuf(FILE *stream) +void rep_setlinebuf(FILE *stream) { - return setvbuf(stream, (char *)NULL, _IOLBF, 0); + setvbuf(stream, (char *)NULL, _IOLBF, 0); } #endif /* HAVE_SETLINEBUF */ -- cgit From e8a005acfe15462b2f7e2aaa66a585d6da098a09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 29 Sep 2006 12:38:51 +0000 Subject: r18999: merge from samba3: - make more usage of PRINTF_ATTRIBUTE() - vsyslog takes a 'const char *format' metze (This used to be commit cdcd4232d2f383f4d2f9ca1d049b7b3cc7b58359) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index aa3e8717c2..e7f47d7d52 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -346,7 +346,7 @@ void rep_setlinebuf(FILE *stream) #ifndef HAVE_VSYSLOG #ifdef HAVE_SYSLOG -void rep_vsyslog (int facility_priority, char *format, va_list arglist) +void rep_vsyslog (int facility_priority, const char *format, va_list arglist) { char *msg = NULL; vasprintf(&msg, format, arglist); -- cgit From f9a0ada725b012261ec9460185105f57206c70c3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 18 Oct 2006 16:08:22 +0000 Subject: r19393: Add replacement function for socketpair() (This used to be commit 448a3ecc0184bfa063db1eb3ae6dc16b8b792792) --- source4/lib/replace/replace.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index e7f47d7d52..83d7948dfb 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -590,3 +590,24 @@ int rep_setenv(const char *name, const char *value, int overwrite) } #endif +#ifndef HAVE_SOCKETPAIR +int rep_socketpair(int d, int type, int protocol, int sv[2]) +{ + if (d != AF_UNIX) { + errno = EAFNOSUPPORT; + return -1; + } + + if (protocol != 0) { + errno = EPROTONOSUPPORT; + return -1; + } + + if (type != SOCK_STREAM) { + errno = EOPNOTSUPP; + return -1; + } + + return pipe(sock); +} +#endif -- cgit From 3a479ae55085e8dd315429dc5979534628891bbc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 18 Oct 2006 16:40:55 +0000 Subject: r19395: Fix replacement function compilation. (This used to be commit b79303f25180c777d9d09b2cdf852bf0a5eda70d) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 83d7948dfb..9e6c75bd35 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -608,6 +608,6 @@ int rep_socketpair(int d, int type, int protocol, int sv[2]) return -1; } - return pipe(sock); + return pipe(sv); } #endif -- cgit From 544a2d30e01b5f4f9849c9aa631e0525062c2707 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 09:59:06 +0000 Subject: r21793: add replacement for unsetenv() metze (This used to be commit d6de7f2cda70cfd55f0f7fbb9f3b93a5a58c6f51) --- source4/lib/replace/replace.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 9e6c75bd35..486c1c5e13 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -590,6 +590,40 @@ int rep_setenv(const char *name, const char *value, int overwrite) } #endif +#ifndef HAVE_UNSETENV +int rep_unsetenv(const char *name) +{ + char *p; + size_t l1; + int ret; + + if (!getenv(name)) { + return 0; + } + + l1 = strlen(name); + + p = malloc(l1+1); + if (p == NULL) { + return -1; + } + memcpy(p, name, l1); + p[l1] = 0; + + /* + * use using "name" here unsets the var + * + * "name=" would set it to an empty string.. + */ + ret = putenv(p); + if (ret != 0) { + free(p); + } + + return ret; +} +#endif + #ifndef HAVE_SOCKETPAIR int rep_socketpair(int d, int type, int protocol, int sv[2]) { -- cgit From d464f0e78b63ee7df52df9171943f6a9723260fc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 11:32:19 +0000 Subject: r21797: remove the key directly from the environ array inspired by: http://cvs.linux-ha.org/viewcvs/viewcvs.cgi/linux-ha/replace/unsetenv.c?rev=1.4&view=auto metze (This used to be commit 8787525e518805f8445a376dc4964921598cb2e0) --- source4/lib/replace/replace.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 486c1c5e13..03888a8eee 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -593,34 +593,26 @@ int rep_setenv(const char *name, const char *value, int overwrite) #ifndef HAVE_UNSETENV int rep_unsetenv(const char *name) { - char *p; - size_t l1; - int ret; - - if (!getenv(name)) { - return 0; - } - - l1 = strlen(name); - - p = malloc(l1+1); - if (p == NULL) { - return -1; - } - memcpy(p, name, l1); - p[l1] = 0; + extern char **environ; + size_t len = strlen(name); + size_t i; + int found = 0; + + for (i=0; (environ && environ[i]); i++) { + if (found) { + environ[i-1] = environ[i]; + continue; + } - /* - * use using "name" here unsets the var - * - * "name=" would set it to an empty string.. - */ - ret = putenv(p); - if (ret != 0) { - free(p); + if (strncmp(environ[i], name, len) == 0 && environ[i][len] == '=') { + free(environ[i]); + environ[i] = NULL; + found = 1; + continue; + } } - return ret; + return 0; } #endif -- cgit From 4cc500433d07decf8fc2551b117e15537f6c8558 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 10 Apr 2007 16:00:13 +0000 Subject: r22152: merge from samba3: remove netgr functions from libreplace they're not used in samba4 currently and samba3 has explicit configure checks for them. should fix bug #4496 metze (This used to be commit dd83a8dad8ad89a1485598fa6e11c9128d04e6d7) --- source4/lib/replace/replace.c | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 03888a8eee..db299130e5 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -154,33 +154,6 @@ time_t rep_mktime(struct tm *t) #endif /* !HAVE_MKTIME */ -#ifndef HAVE_INNETGR -#if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT) -/* - * Search for a match in a netgroup. This replaces it on broken systems. - */ -int rep_innetgr(const char *group, const char *host, const char *user, - const char *dom) -{ - char *hst, *usr, *dm; - - setnetgrent(group); - while (getnetgrent(&hst, &usr, &dm)) { - if (((host == 0) || (hst == 0) || !strcmp(host, hst)) && - ((user == 0) || (usr == 0) || !strcmp(user, usr)) && - ((dom == 0) || (dm == 0) || !strcmp(dom, dm))) { - endnetgrent(); - return (1); - } - } - endnetgrent(); - return (0); -} -#endif /* HAVE_SETNETGRENT HAVE_GETNETGRENT HAVE_ENDNETGRENT */ -#endif /* HAVE_INNETGR */ - - - #ifndef HAVE_INITGROUPS /**************************************************************************** some systems don't have an initgroups call -- cgit From 2ad24b9ba191ed9d2b77dbf3f667504e05bc9707 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 May 2007 06:53:57 +0000 Subject: r22988: fixed 2 bugs in our unsetenv() replacement code 1) you must not free the memory, as it is possible the memory did not come from malloc (try it under valgrind to test) 2) the old code didn't cope with duplicate environment variables I hope this will fix some of the build farm errors on irix, and maybe solaris (This used to be commit ec6900171d066e927f004b621fb39cc7b8dcfd90) --- source4/lib/replace/replace.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index db299130e5..87e73d001c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -568,20 +568,24 @@ int rep_unsetenv(const char *name) { extern char **environ; size_t len = strlen(name); - size_t i; - int found = 0; + size_t i, count; - for (i=0; (environ && environ[i]); i++) { - if (found) { - environ[i-1] = environ[i]; - continue; - } + if (environ == NULL || getenv(name) == NULL) { + return 0; + } + for (i=0;environ[i];i++) /* noop */ ; + + count=i; + + for (i=0;i Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b86da53caf..1b4a82cb03 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -10,7 +10,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/replace/replace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 1b4a82cb03..cec158be31 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -18,8 +18,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #include "replace.h" -- cgit From bab53c5e53bac25b7031838953de6083dbbfbc5d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Nov 2007 15:28:13 +0100 Subject: Fix bug 5055 (lib/replace part of 8bcd2df841bae63e7d58c35d4728b7d853471697 metze) (This used to be commit 8db9e196506f530c780d93e16da590566d16a407) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index cec158be31..b2a240e8ab 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -218,7 +218,7 @@ long nap(long milliseconds) { #ifndef HAVE_MEMMOVE /******************************************************************* safely copies memory, ensuring no overlap problems. -this is only used if the machine does not have it's own memmove(). +this is only used if the machine does not have its own memmove(). this is not the fastest algorithm in town, but it will do for our needs. ********************************************************************/ -- cgit From 87b48a812683794935db950446e9fb1db8e3da48 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 12:16:47 +0100 Subject: libreplace: replace inet_ntoa() when it is missing ...not only replace it when it is broken. This moves the defintion of rep_inet_ntoa from replace.c to inet_ntoa.c and adds configure checks for existence of inet_ntoa(). Checks are moved to an include file of its own. NOTE: The original rep_inet_ntoa in replace.c was wrapped into a "#ifndef WITH_PTHREADS" but the prototype in replace.h and the define in system/network.h were not. I removed that ifndef since the inet_ntoa() function is usually not thread safe anyways, since it returns a pointer to a static buffer. So whoever calls inet_ntoa() should be aware that it is not thread safe anyways. Michael (This used to be commit 974c0c45ad42644348e0b55454715b12158f1028) --- source4/lib/replace/replace.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b2a240e8ab..c16bded963 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -295,20 +295,6 @@ char *rep_strdup(const char *s) } #endif /* HAVE_STRDUP */ -#ifndef WITH_PTHREADS -/* REWRITE: not thread safe */ -#ifdef REPLACE_INET_NTOA -char *rep_inet_ntoa(struct in_addr ip) -{ - uint8_t *p = (uint8_t *)&ip.s_addr; - static char buf[18]; - slprintf(buf, 17, "%d.%d.%d.%d", - (int)p[0], (int)p[1], (int)p[2], (int)p[3]); - return buf; -} -#endif /* REPLACE_INET_NTOA */ -#endif - #ifndef HAVE_SETLINEBUF void rep_setlinebuf(FILE *stream) { -- cgit From 124f82efe13a453a3f5857c1e25584536147c3dc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 17:20:47 +0100 Subject: libreplace: move rep_socketpair() to its own module. Prototype is now in system/network.h, implementation in socketpair.c, and check in socketpair.m4. Now the last networking function has vanished from replace.c. Michael (This used to be commit 94ac8a25be15b55f66eff96fdddc2fdc71a43b1e) --- source4/lib/replace/replace.c | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index c16bded963..a6a8c0b6ed 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -585,25 +585,3 @@ int rep_unsetenv(const char *name) return 0; } #endif - -#ifndef HAVE_SOCKETPAIR -int rep_socketpair(int d, int type, int protocol, int sv[2]) -{ - if (d != AF_UNIX) { - errno = EAFNOSUPPORT; - return -1; - } - - if (protocol != 0) { - errno = EPROTONOSUPPORT; - return -1; - } - - if (type != SOCK_STREAM) { - errno = EOPNOTSUPP; - return -1; - } - - return pipe(sv); -} -#endif -- cgit From a310b0b84369da95c059ddb6ae90a524062eadd5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 17:50:23 +0100 Subject: libreplace: replace.c does not need system/network.h anymore. Michael (This used to be commit 2d3c2f34f33338ff422047dae9cc262522689328) --- source4/lib/replace/replace.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index a6a8c0b6ed..6930f9b079 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -27,7 +27,6 @@ #include "system/time.h" #include "system/passwd.h" #include "system/syslog.h" -#include "system/network.h" #include "system/locale.h" #include "system/wait.h" -- cgit From 107ab090e23dfc517bc74bb553315cd3528e1f7d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Apr 2008 14:47:07 +0200 Subject: use uintptr_t instead of intptr_t where appropriate (This used to be commit d62f2bcc85c13605c133db250e0a86d2d6ccc481) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 6930f9b079..443da2ab24 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -458,7 +458,7 @@ char *rep_strcasestr(const char *haystack, const char *needle) for (s=haystack;*s;s++) { if (toupper(*needle) == toupper(*s) && strncasecmp(s, needle, nlen) == 0) { - return (char *)((intptr_t)s); + return (char *)((uintptr_t)s); } } return NULL; -- cgit From bbf4ce91462598cee1eebfb94a773194e56a7ff8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 13:10:31 +0200 Subject: libreplace: always provide utime() and utimes() I'd like to also provide futimes(), but it seems that some systems doesn't support a it at kernel level. If someone knows how to write a portable replacement for futimes() please tell me... metze (This used to be commit a9604fe4a323dccb537cf02ea7594437b4995803) --- source4/lib/replace/replace.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 443da2ab24..2c3f14c2df 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -584,3 +584,30 @@ int rep_unsetenv(const char *name) return 0; } #endif + +#ifndef HAVE_UTIME +int rep_utime(const char *filename, const struct utimbuf *buf) +{ + errno = ENOSYS; + return -1; +} +#endif + +#ifndef HAVE_UTIMES +int rep_utimes(const char *filename, const struct timeval tv[2]) +{ + struct utimbuf u; + + u.actime = tv[0].tv_sec; + if (tv[0].tv_usec > 500000) { + u.actime += 1; + } + + u.modtime = tv[1].tv_sec; + if (tv[1].tv_usec > 500000) { + u.modtime += 1; + } + + return utime(filename, &u); +} +#endif -- cgit From d8ac9bde86f349fecb997a2c8c4d0e2cbfe22542 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Jul 2008 12:01:15 -0700 Subject: Fix bug #5578, reported by sendel2000@hotbox.ru. Bad (non-Samba) use of strlcat gives error. Jeremy. (This used to be commit e633dc4ec2d72c3d34b5e096e0460e07e07ab514) --- source4/lib/replace/replace.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 2c3f14c2df..106c9dfe62 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -82,6 +82,9 @@ size_t rep_strlcat(char *d, const char *s, size_t bufsize) size_t ret = len1 + len2; if (len1+len2 >= bufsize) { + if (bufsize < (len1+1)) { + return ret; + } len2 = bufsize - (len1+1); } if (len2 > 0) { -- cgit From 6b7c4413fec1337b843d40c4192ccc7f28df83d5 Mon Sep 17 00:00:00 2001 From: Yannick Bergeron Date: Fri, 8 Aug 2008 13:32:15 -0400 Subject: using NGROUPS_MAX instead of 32 for the max group value in rep_initgroups() subroutine in lib/replace/replace.c (cherry picked from commit 13b1a232d2fe05ae3e924ea2503d05ff5084146e) (This used to be commit 0d2fb0e280e497094a4c95f8dca1383ee1cfa982) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/replace.c') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 106c9dfe62..98d799b07e 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -170,7 +170,7 @@ int rep_initgroups(char *name, gid_t id) #include gid_t *grouplst = NULL; - int max_gr = 32; + int max_gr = NGROUPS_MAX; int ret; int i,j; struct group *g; -- cgit