From 0d3df21f35245ad81cc65b4aea7f45938397a126 Mon Sep 17 00:00:00 2001 From: jdolecek Date: Sun, 4 Jan 2004 09:09:56 +0000 Subject: [PATCH] use system() to spawn editor, so that it's possible to use EDITOR setting which includes options; this reinstates functionality lost in rev 1.18 --- usr.sbin/cron/crontab.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 0acf13d6ff53..c938f83e146c 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.21 2003/12/07 16:50:43 is Exp $ */ +/* $NetBSD: crontab.c,v 1.22 2004/01/04 09:09:56 jdolecek Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -22,7 +22,7 @@ #if 0 static char rcsid[] = "Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp"; #else -__RCSID("$NetBSD: crontab.c,v 1.21 2003/12/07 16:50:43 is Exp $"); +__RCSID("$NetBSD: crontab.c,v 1.22 2004/01/04 09:09:56 jdolecek Exp $"); #endif #endif @@ -340,7 +340,7 @@ check_error(msg) static void edit_cmd() { char n[MAX_FNAME], q[MAX_TEMPSTR]; - char *editor; + const char *editor; FILE *f; int ch, t; struct stat statbuf; @@ -349,7 +349,7 @@ edit_cmd() { WAIT_T waiter; PID_T pid, xpid; sig_t oint, oabrt; - char *argv[3]; + char *edit; log_it(RealUser, Pid, "BEGIN EDIT", User); (void) snprintf(n, sizeof(n), CRON_TAB(User)); @@ -446,12 +446,12 @@ edit_cmd() { perror("chdir(/tmp)"); exit(ERROR_EXIT); } - argv[0] = editor; - argv[1] = Filename; - argv[2] = NULL; - execvp(editor, argv); - perror(editor); - exit(ERROR_EXIT); + asprintf(&edit, "%s %s", editor, Filename); + if (system(edit) == -1) { + perror(editor); + exit(ERROR_EXIT); + } else + exit(OK_EXIT); /*NOTREACHED*/ default: /* parent */ @@ -588,7 +588,7 @@ replace_cmd() { fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n"); fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now)); fprintf(tmp, "# (Cron version -- %s)\n", - "$NetBSD: crontab.c,v 1.21 2003/12/07 16:50:43 is Exp $"); + "$NetBSD: crontab.c,v 1.22 2004/01/04 09:09:56 jdolecek Exp $"); /* copy the crontab to the tmp */