Use a common function for resolviong the user's editor in sudoedit
and visudo. The find_path() function now returns a dynamically allocated path instead of using a static string.
This commit is contained in:
@@ -43,18 +43,22 @@
|
||||
bool
|
||||
sudo_goodpath(const char *path, struct stat *sbp)
|
||||
{
|
||||
struct stat sb;
|
||||
bool rval = false;
|
||||
debug_decl(sudo_goodpath, SUDOERS_DEBUG_UTIL)
|
||||
|
||||
if (path != NULL && stat(path, &sb) == 0) {
|
||||
/* Make sure path describes an executable regular file. */
|
||||
if (S_ISREG(sb.st_mode) && ISSET(sb.st_mode, 0111))
|
||||
rval = true;
|
||||
else
|
||||
errno = EACCES;
|
||||
if (sbp)
|
||||
(void) memcpy(sbp, &sb, sizeof(struct stat));
|
||||
if (path != NULL) {
|
||||
struct stat sb;
|
||||
|
||||
if (sbp == NULL)
|
||||
sbp = &sb;
|
||||
|
||||
if (stat(path, sbp) == 0) {
|
||||
/* Make sure path describes an executable regular file. */
|
||||
if (S_ISREG(sbp->st_mode) && ISSET(sbp->st_mode, 0111))
|
||||
rval = true;
|
||||
else
|
||||
errno = EACCES;
|
||||
}
|
||||
}
|
||||
|
||||
debug_return_bool(rval);
|
||||
|
Reference in New Issue
Block a user