Avoid strerror() when possible and just rely on warning/error

to handle errno in the proper locale.
This commit is contained in:
Todd C. Miller
2012-11-09 16:32:29 -05:00
parent e28ce01fe0
commit 56de023de8
6 changed files with 27 additions and 16 deletions

View File

@@ -40,6 +40,7 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <setjmp.h>
@@ -493,8 +494,10 @@ sudoers_policy_close(int exit_status, int error_code)
}
/* We do not currently log the exit status. */
if (error_code)
warningx(N_("unable to execute %s: %s"), safe_cmnd, strerror(error_code));
if (error_code) {
errno = error_code;
warning(N_("unable to execute %s"), safe_cmnd);
}
/* Close the session we opened in sudoers_policy_init_session(). */
if (ISSET(sudo_mode, MODE_RUN|MODE_EDIT))