{
setpwent();
sudo_setspent();
- pwcache_byuid = rbcreate(cmp_pwuid);
- pwcache_byname = rbcreate(cmp_pwnam);
+ if (pwcache_byuid == NULL)
+ pwcache_byuid = rbcreate(cmp_pwuid);
+ if (pwcache_byname == NULL)
+ pwcache_byname = rbcreate(cmp_pwnam);
}
+#if 0
void
-sudo_endpwent()
+sudo_freepwcache()
{
- endpwent();
- sudo_endspent();
if (pwcache_byuid != NULL) {
rbdestroy(pwcache_byuid, pw_free);
pwcache_byuid = NULL;
pwcache_byname = NULL;
}
}
+#endif
+
+void
+sudo_endpwent()
+{
+ endpwent();
+ sudo_endspent();
+}
static void
pw_free(v)
sudo_setgrent()
{
setgrent();
- grcache_bygid = rbcreate(cmp_grgid);
- grcache_byname = rbcreate(cmp_grnam);
+ if (grcache_bygid == NULL)
+ grcache_bygid = rbcreate(cmp_grgid);
+ if (grcache_byname == NULL)
+ grcache_byname = rbcreate(cmp_grnam);
}
+#if 0
void
-sudo_endgrent()
+sudo_freegrcache()
{
- endgrent();
- if (grcache_bygid != NULL) {
+ if (free_cache && grcache_bygid != NULL) {
rbdestroy(grcache_bygid, free);
grcache_bygid = NULL;
}
- if (grcache_byname != NULL) {
+ if (free_cache && grcache_byname != NULL) {
rbdestroy(grcache_byname, NULL);
grcache_byname = NULL;
}
}
+#endif
+
+void
+sudo_endgrent()
+{
+ endgrent();
+}
while (tmplen > 0 && tmpdir[tmplen - 1] == '/')
tmplen--;
+ /*
+ * Close password, shadow, and group files before we try to open
+ * user-specified files to prevent the opening of things like /dev/fd/4
+ */
+ sudo_endpwent();
+ sudo_endgrent();
+
/*
* For each file specified by the user, make a temporary version
* and copy the contents of the original to it.
- * XXX - It would be nice to lock the original files but that means
- * keeping an extra fd open for each file.
*/
tf = emalloc2(argc - 1, sizeof(*tf));
memset(tf, 0, (argc - 1) * sizeof(*tf));
(void) sigaction(SIGQUIT, &saved_sa_quit, NULL);
(void) sigaction(SIGCHLD, &saved_sa_chld, NULL);
set_perms(PERM_FULL_USER);
- sudo_endpwent();
- sudo_endgrent();
closefrom(def_closefrom + 1);
execvp(nargv[0], nargv);
warning("unable to execute %s", nargv[0]);
/*
* Wait for status from the child. Most modern kernels
* will not let an unprivileged child process send a
- * signal to its privileged parent to we have to request
+ * signal to its privileged parent so we have to request
* status when the child is stopped and then send the
* same signal to our own pid.
*/