handler too.
#endif /* lint */
static void _warning __P((int, const char *, va_list));
- void cleanup __P((void));
+ void cleanup __P((int));
void
#ifdef __STDC__
#endif
_warning(1, fmt, ap);
va_end(ap);
- cleanup();
+ cleanup(0);
exit(eval);
}
#endif
_warning(0, fmt, ap);
va_end(ap);
- cleanup();
+ cleanup(0);
exit(eval);
}
* Stub for error()/errorx()
*/
void
-cleanup()
+cleanup(gotsignal)
+ int gotsignal;
{
- sudo_endpwent();
- sudo_endgrent();
+ if (!gotsignal) {
+ sudo_endpwent();
+ sudo_endgrent();
+ }
}
/*
void sudo_endpwent __P((void));
void sudo_setspent __P((void));
void sudo_endspent __P((void));
-void cleanup __P((void));
+void cleanup __P((int));
struct passwd *sudo_getpwnam __P((const char *));
struct passwd *sudo_fakepwnam __P((const char *));
struct passwd *sudo_getpwuid __P((uid_t));
}
void
-cleanup()
+cleanup(gotsignal)
+ int gotsignal;
{
- sudo_endpwent();
- sudo_endgrent();
+ if (!gotsignal) {
+ sudo_endpwent();
+ sudo_endgrent();
+ }
}
void
switch (whatnow()) {
case 'Q' : parse_error = FALSE; /* ignore parse error */
break;
- case 'x' : cleanup();
+ case 'x' : cleanup(0);
exit(0);
break;
}
* Unlink any sudoers temp files that remain.
*/
void
-cleanup()
+cleanup(gotsignal)
+ int gotsignal;
{
struct sudoersfile *sp;
if (sp->tpath != NULL)
(void) unlink(sp->tpath);
}
- /*
- * XXX - would like to call sudo_endpwent/sudo_endgrent but they
- * are not signal-safe.
- sudo_endpwent();
- sudo_endgrent();
- */
+ if (!gotsignal) {
+ sudo_endpwent();
+ sudo_endgrent();
+ }
}
/*
quit(signo)
int signo;
{
- cleanup();
+ cleanup(signo);
#define emsg " exiting due to signal.\n"
write(STDERR_FILENO, getprogname(), strlen(getprogname()));
write(STDERR_FILENO, emsg, sizeof(emsg) - 1);