diff options
author | Sumanth Naropanth <Sumanth.Naropanth@Sun.COM> | 2009-03-26 15:58:31 -0700 |
---|---|---|
committer | Sumanth Naropanth <Sumanth.Naropanth@Sun.COM> | 2009-03-26 15:58:31 -0700 |
commit | 78ae324cd873d8b8b4ee8b2ea86a4f932a9e4f3e (patch) | |
tree | 069539467b990efbdd12c41609c113dd571e34e2 /usr/src/cmd/cron | |
parent | d553bafd8687032230dfa65449d7e52c251c5293 (diff) | |
download | illumos-joyent-78ae324cd873d8b8b4ee8b2ea86a4f932a9e4f3e.tar.gz |
6776875 setting EDITOR/VISUAL value with an argument (ed -s, vi -v), will fail on crontab -e
Diffstat (limited to 'usr/src/cmd/cron')
-rw-r--r-- | usr/src/cmd/cron/crontab.c | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/usr/src/cmd/cron/crontab.c b/usr/src/cmd/cron/crontab.c index 2b3054628e..9042bdfe45 100644 --- a/usr/src/cmd/cron/crontab.c +++ b/usr/src/cmd/cron/crontab.c @@ -43,7 +43,6 @@ #include <nl_types.h> #include <langinfo.h> #include <libintl.h> -#include <spawn.h> #include <security/pam_appl.h> #include <limits.h> #include <libzoneinfo.h> @@ -96,7 +95,6 @@ #define BAD_HOME "Unable to access directory: %s\t%s\n" extern int per_errno; -extern char **environ; extern int audit_crontab_modify(char *, char *, int); extern int audit_crontab_delete(char *, int); @@ -138,9 +136,8 @@ main(int argc, char **argv) int tmpfd = -1; pam_handle_t *pamh; int pam_error; - pid_t cpid; - int cstatus; - char *argvec[3]; + char *buf; + size_t buflen; (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ @@ -304,38 +301,14 @@ main(int argc, char **argv) #ifdef _XPG_NOTDEFINED } #endif - argvec[0] = strdup(editor); - argvec[1] = strdup(edtemp); - argvec[2] = NULL; - - if (argvec[0] == NULL || argvec[1] == NULL) - crabort("Insufficient memory"); + buflen = strlen(editor) + strlen(edtemp) + 2; + buf = xmalloc(buflen); + (void) snprintf(buf, buflen, "%s %s", editor, edtemp); sleep(1); while (1) { - /* - * posix_spawnp() allows the file pointed to - * by the 'EDITOR' variable to be searched in - * the PATH environment variable - */ - - ret = posix_spawnp(&cpid, editor, NULL, NULL, - (char *const *)argvec, - (char *const *)environ); - if (ret) { - (void) fprintf(stderr, - gettext("crontab: %s: %s\n"), - editor, strerror(errno)); - cstatus = -1; - } else { - pid_t wpid = 0; - while ((wpid = waitpid(cpid, &cstatus, - 0)) == -1 && errno == EINTR) - ; - if (wpid == -1) - cstatus = -1; - } + ret = system(buf); /* sanity checks */ if ((tmpfp = fopen(edtemp, "r")) == NULL) @@ -351,7 +324,7 @@ main(int argc, char **argv) " changed.\n")); exit(1); } - if ((cstatus) && (errno != EINTR)) { + if ((ret) && (errno != EINTR)) { /* * Some editors (like 'vi') can return * a non-zero exit status even though |