As we talked in debian.users.russian about that problem best workaround (in our 
opinion) is add -i (inform) key to crontab. It's let backward compatibility to 
all users scripts that must be silent and give way for user make alias to 
crontab -r -i instead crontab -r in shell.

P.S. Patch is kindly gave by Dmitry E. Oboukhov


=begin of remove_crontab_warning_patch.diff
--- crontab.c   2007-03-12 11:35:54.000000000 +0300
+++ crontab.c.new       2007-03-12 11:52:10.000000000 +0300
@@ -15,6 +15,13 @@
 * Paul Vixie          <[EMAIL PROTECTED]>          uunet!decwrl!vixie!paul
 */

+/*
+ * Modified by Dmitry E. Oboukhov <[EMAIL PROTECTED]>
+ *   [+] added the request of deleting crontab
+ *   [+] added option '-i'
+ *
+ */
+
#if !defined(lint) && !defined(LINT)
static char rcsid[] = "$Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $";
#endif
@@ -54,6 +61,7 @@
#endif


+static int warning_remove=0;
static  PID_T           Pid;
static  char            *User, *RealUser;
static  char            Filename[MAX_FNAME];
@@ -86,6 +94,7 @@
        fprintf(stderr, "\t-e\t(edit user's crontab)\n");
        fprintf(stderr, "\t-l\t(list user's crontab)\n");
        fprintf(stderr, "\t-r\t(delete user's crontab)\n");
+  fprintf(stderr, "\t-i\t(warning for remove crontab)\n");
        exit(ERROR_EXIT);
}

@@ -140,9 +149,9 @@
}
        
#if DEBUGGING
-char *getoptarg = "u:lerx:";
+char *getoptarg = "u:lerx:i";
#else
-char *getoptarg = "u:ler";
+char *getoptarg = "u:leri";
#endif


@@ -177,6 +186,10 @@
                        usage("unrecognized option");
                        break;
#endif
+    case 'i':
+      warning_remove=1;
+      break;
+
                case 'u':
                        if (!(pw = getpwnam(optarg)))
                        {
@@ -336,7 +349,22 @@
delete_cmd() {
        char    n[MAX_FNAME];

-       log_it(RealUser, Pid, "DELETE", User);
+  if (warning_remove)
+  {
+    fprintf(stderr, "Are You sure that You want to delete crontab? [Y/N]: ");
+    int ch=getchar();
+ if (ch==EOF) + { + fprintf(stderr, "Error getchar: EOF\n"); + exit(ERROR_EXIT); + } + if (ch!='Y' && ch!='y') + {
+      exit(OK_EXIT);
+    }
+  }
+       
+  log_it(RealUser, Pid, "DELETE", User);
        (void) snprintf(n, MAX_FNAME, CRON_TAB(User));
        if (unlink(n)) {
                if (errno == ENOENT)
=end of remove_crontab_warning_patch.diff



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to