From: Todd C. Miller Date: Sat, 20 Nov 2010 15:46:38 +0000 (-0500) Subject: Avoid conflicts with system definitions in grp.h and pwd.h X-Git-Tag: SUDO_1_7_5~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=062bbf28fc116075c0aec3e0cfb405eaf142db50;p=sudo Avoid conflicts with system definitions in grp.h and pwd.h --HG-- branch : 1.7 --- diff --git a/testsudoers.c b/testsudoers.c index 1bf2cd301..45d4cf74d 100644 --- a/testsudoers.c +++ b/testsudoers.c @@ -60,6 +60,7 @@ #include #include +#include "tsgetgrpw.h" #include "sudo.h" #include "interfaces.h" #include "parse.h" @@ -100,19 +101,6 @@ void usage __P((void)) __attribute__((__noreturn__)); void set_runasgr __P((char *)); void set_runaspw __P((char *)); -extern void setgrfile __P((const char *)); -extern void setgrent __P((void)); -extern void endgrent __P((void)); -extern struct group *getgrent __P((void)); -extern struct group *getgrnam __P((const char *)); -extern struct group *getgrgid __P((gid_t)); -extern void setpwfile __P((const char *)); -extern void setpwent __P((void)); -extern void endpwent __P((void)); -extern struct passwd *getpwent __P((void)); -extern struct passwd *getpwnam __P((const char *)); -extern struct passwd *getpwuid __P((uid_t)); - int main(argc, argv) int argc; diff --git a/tsgetgrpw.c b/tsgetgrpw.c index 6f14d3fb5..b843df4be 100644 --- a/tsgetgrpw.c +++ b/tsgetgrpw.c @@ -44,9 +44,8 @@ #endif /* HAVE_STRINGS_H */ #include #include -#include -#include +#include "tsgetgrpw.h" #include "sudo.h" #ifndef LINE_MAX @@ -64,20 +63,6 @@ static FILE *grf; static const char *grfile = "/etc/group"; static int gr_stayopen; -void setgrfile __P((const char *)); -void setgrent __P((void)); -void endgrent __P((void)); -struct group *getgrent __P((void)); -struct group *getgrnam __P((const char *)); -struct group *getgrgid __P((gid_t)); - -void setpwfile __P((const char *)); -void setpwent __P((void)); -void endpwent __P((void)); -struct passwd *getpwent __P((void)); -struct passwd *getpwnam __P((const char *)); -struct passwd *getpwuid __P((uid_t)); - void setpwfile(file) const char *file; diff --git a/tsgetgrpw.h b/tsgetgrpw.h new file mode 100644 index 000000000..83cbf1398 --- /dev/null +++ b/tsgetgrpw.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2010 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Trivial replacements for the libc get{gr,pw}{uid,nam}() routines + * for use by testsudoers in the sudo test harness. + * We need our own since many platforms don't provide set{pw,gr}file(). + */ + +#include + +/* + * Define away the system prototypes so we don't have any conflicts. + */ + +#define setgrfile sys_setgrfile +#define setgrent sys_setgrent +#define endgrent sys_endgrent +#define getgrent sys_getgrent +#define getgrnam sys_getgrnam +#define getgrgid sys_getgrgid + +#define setpwfile sys_setpwfile +#define setpwent sys_setpwent +#define endpwent sys_endpwent +#define getpwent sys_getpwent +#define getpwnam sys_getpwnam +#define getpwuid sys_getpwuid + +#include +#include + +#undef setgrfile +#undef setgrent +#undef endgrent +#undef getgrent +#undef getgrnam +#undef getgrgid + +void setgrfile __P((const char *)); +void setgrent __P((void)); +void endgrent __P((void)); +struct group *getgrent __P((void)); +struct group *getgrnam __P((const char *)); +struct group *getgrgid __P((gid_t)); + +#undef setpwfile +#undef setpwent +#undef endpwent +#undef getpwent +#undef getpwnam +#undef getpwuid + +void setpwfile __P((const char *)); +void setpwent __P((void)); +void endpwent __P((void)); +struct passwd *getpwent __P((void)); +struct passwd *getpwnam __P((const char *)); +struct passwd *getpwuid __P((uid_t));