From e336dac8740f6c5c66e00df014f394ce8462c1bb Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 14 May 2010 16:35:03 -0400 Subject: [PATCH] Attempt to fix building on systems that only have setuid. --- src/parse_args.c | 6 +++++- src/sudo_edit.c | 21 ++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/parse_args.c b/src/parse_args.c index 801f41896..584f71b2d 100644 --- a/src/parse_args.c +++ b/src/parse_args.c @@ -418,11 +418,15 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp, } settings[j] = NULL; - /* Must have the command in argv[0]. */ if (mode == MODE_EDIT) { +#if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID) + /* Must have the command in argv[0]. */ argc++; argv--; argv[0] = "sudoedit"; +#else + errorx(1, "sudoedit is not supported on this platform"); +#endif } *settingsp = settings; diff --git a/src/sudo_edit.c b/src/sudo_edit.c index 1c961befb..c7eab5d5f 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -16,6 +16,8 @@ #include +#if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID) + #include #include #include @@ -237,7 +239,7 @@ sudo_edit(struct command_details *command_details, char *argv[], char *envp[]) j++; } if ((nfiles = j) == 0) - return(1); /* no files readable, you lose */ + return 1; /* no files readable, you lose */ /* * Allocate space for the new argument vector and fill it in. @@ -342,12 +344,25 @@ sudo_edit(struct command_details *command_details, char *argv[], char *envp[]) close(ofd); } - return(rval); + return rval; cleanup: /* Clean up temp files and return. */ for (i = 0; i < nfiles; i++) { if (tf[i].tfile != NULL) unlink(tf[i].tfile); } - return(1); + return 1; +} + +#else /* HAVE_SETRESUID || HAVE_SETREUID || HAVE_SETEUID */ + +/* + * Must have the ability to change the effective uid to use sudoedit. + */ +int +sudo_edit(struct command_details *command_details, char *argv[], char *envp[]) +{ + return 1; } + +#endif /* HAVE_SETRESUID || HAVE_SETREUID || HAVE_SETEUID */ -- 2.40.0