]> granicus.if.org Git - sudo/commitdiff
Avoid conflicts with system definitions in grp.h and pwd.h
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 20 Nov 2010 15:46:38 +0000 (10:46 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 20 Nov 2010 15:46:38 +0000 (10:46 -0500)
--HG--
branch : 1.7

testsudoers.c
tsgetgrpw.c
tsgetgrpw.h [new file with mode: 0644]

index 1bf2cd301a8fd031c668334afe24aec549f3d8b2..45d4cf74ddb6dc7a9fce6b3a67cff71aa473027a 100644 (file)
@@ -60,6 +60,7 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 
+#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;
index 6f14d3fb5ab928b01dc734432e1906dd34d6e792..b843df4bee589b101d786bfabbb92909b6972f82 100644 (file)
@@ -44,9 +44,8 @@
 #endif /* HAVE_STRINGS_H */
 #include <fcntl.h>
 #include <limits.h>
-#include <pwd.h>
-#include <grp.h>
 
+#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 (file)
index 0000000..83cbf13
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * 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 <config.h>
+
+/*
+ * 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 <pwd.h>
+#include <grp.h>
+
+#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));