From: Todd C. Miller Date: Sat, 20 Nov 2010 15:33:23 +0000 (-0500) Subject: Avoid conflicts with system definitions in grp.h and pwd.h X-Git-Tag: SUDO_1_8_0~157 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a0f2164efc3b6d9d2df6912a50bfb16914b5153;p=sudo Avoid conflicts with system definitions in grp.h and pwd.h --- diff --git a/MANIFEST b/MANIFEST index 61df6f0cb..248aaa456 100644 --- a/MANIFEST +++ b/MANIFEST @@ -183,6 +183,7 @@ plugins/sudoers/timestr.c plugins/sudoers/toke.c plugins/sudoers/toke.l plugins/sudoers/tsgetgrpw.c +plugins/sudoers/tsgetgrpw.h plugins/sudoers/visudo.c pp src/Makefile.in diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index f7e9f2cba..1a4315278 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -55,12 +55,11 @@ #endif /* HAVE_NETGROUP_H */ #include #include -#include -#include #include #include #include +#include "tsgetgrpw.h" #include "sudoers.h" #include "interfaces.h" #include "parse.h" diff --git a/plugins/sudoers/tsgetgrpw.c b/plugins/sudoers/tsgetgrpw.c index ddfa2ffa3..69997ccc5 100644 --- a/plugins/sudoers/tsgetgrpw.c +++ b/plugins/sudoers/tsgetgrpw.c @@ -44,9 +44,8 @@ #endif /* HAVE_STRINGS_H */ #include #include -#include -#include +#include "tsgetgrpw.h" #include "sudoers.h" #ifndef LINE_MAX diff --git a/plugins/sudoers/tsgetgrpw.h b/plugins/sudoers/tsgetgrpw.h new file mode 100644 index 000000000..5c380c399 --- /dev/null +++ b/plugins/sudoers/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(const char *); +void setgrent(void); +void endgrent(void); +struct group *getgrent(void); +struct group *getgrnam(const char *); +struct group *getgrgid(gid_t); + +#undef setpwfile +#undef setpwent +#undef endpwent +#undef getpwent +#undef getpwnam +#undef getpwuid + +void setpwfile(const char *); +void setpwent(void); +void endpwent(void); +struct passwd *getpwent(void); +struct passwd *getpwnam(const char *); +struct passwd *getpwuid(uid_t);