to handle errno in the proper locale.
int len; /* length parameter */
debug_decl(find_path, SUDO_DEBUG_UTIL)
- if (strlen(infile) >= PATH_MAX)
- errorx(1, _("%s: %s"), infile, strerror(ENAMETOOLONG));
+ if (strlen(infile) >= PATH_MAX) {
+ errno = ENAMETOOLONG;
+ error(1, "%s", infile);
+ }
/*
* If we were given a fully qualified or relative path
* Resolve the path and exit the loop if found.
*/
len = snprintf(command, sizeof(command), "%s/%s", path, infile);
- if (len <= 0 || len >= sizeof(command))
- errorx(1, _("%s: %s"), infile, strerror(ENAMETOOLONG));
+ if (len <= 0 || len >= sizeof(command)) {
+ errno = ENAMETOOLONG;
+ error(1, "%s", infile);
+ }
if ((found = sudo_goodpath(command, sbp)))
break;
*/
if (!found && checkdot) {
len = snprintf(command, sizeof(command), "./%s", infile);
- if (len <= 0 || len >= sizeof(command))
- errorx(1, _("%s: %s"), infile, strerror(ENAMETOOLONG));
+ if (len <= 0 || len >= sizeof(command)) {
+ errno = ENAMETOOLONG;
+ error(1, "%s", infile);
+ }
found = sudo_goodpath(command, sbp);
if (found && ignore_dot)
debug_return_int(NOT_FOUND_DOT);
(*plugin_info != '/') ? _PATH_SUDO_PLUGIN_DIR : "", plugin_info);
}
if (len <= 0 || len >= sizeof(path)) {
- warningx(N_("%s%s: %s"),
- (*plugin_info != '/') ? _PATH_SUDO_PLUGIN_DIR : "", plugin_info,
- strerror(ENAMETOOLONG));
+ errno = ENAMETOOLONG;
+ warning("%s%s",
+ (*plugin_info != '/') ? _PATH_SUDO_PLUGIN_DIR : "", plugin_info);
goto done;
}
if (mkdir(path, S_IRWXU) != 0)
log_fatal(USE_ERRNO, N_("unable to mkdir %s"), path);
} else if (!S_ISDIR(sb.st_mode)) {
- log_fatal(0, N_("%s: %s"), path, strerror(ENOTDIR));
+ errno = ENOTDIR;
+ log_fatal(USE_ERRNO, "%s", path);
}
*slash = '/';
}
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
+#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <setjmp.h>
}
/* 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))
}
}
}
- if (strlen(user_cmnd) >= PATH_MAX)
- errorx(1, _("%s: %s"), user_cmnd, strerror(ENAMETOOLONG));
+ if (strlen(user_cmnd) >= PATH_MAX) {
+ errno = ENAMETOOLONG;
+ error(1, "%s", user_cmnd);
+ }
if ((user_base = strrchr(user_cmnd, '/')) != NULL)
user_base++;
status = rmdir(timestampdir);
if (status == -1 && errno != ENOENT) {
log_error(0,
- N_("unable to remove %s (%s), will reset to the epoch"),
- path, strerror(errno));
+ N_("unable to remove %s, will reset to the epoch"), path);
remove = false;
}
}