Dash:
[t2-trunk.git] / package / base / cron / hardened-remove.patch
blobe8678ed79eed501c1e060cb9291192dc76dbef29
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../cron/hardened-remove.patch
5 # Copyright (C) 2004 - 2010 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 Never ever remove my crontab with a mistyping -e, again ... - it just
18 happens too quickly!
20 - Rene Rebe <rene@exactcode.de>
22 --- cron3.0pl1/crontab.1.vanilla 2010-07-18 23:13:02.000000000 +0200
23 +++ cron3.0pl1/crontab.1 2010-07-18 23:22:52.000000000 +0200
24 @@ -24,7 +24,7 @@
25 .SH SYNOPSIS
26 crontab [ -u user ] file
27 .br
28 -crontab [ -u user ] [ -i ] { -e | -l | -r }
29 +crontab [ -u user ] [ -i ] { -e | -l | -rr }
30 .SH DESCRIPTION
31 .I crontab
32 is the program used to install, deinstall or list the tables
33 @@ -88,8 +88,11 @@
34 below.
35 .PP
36 The
37 -.I -r
38 -option causes the current crontab to be removed.
39 +.I -rr
40 +option causes the current crontab to be removed. NOTE: Since users accidently
41 +managed to delete their crontab serveral times, accidently hitting -r instead
42 +of -e, - we decided that -r needs to be specified two (!) times in order to
43 +delete the user's crontab, by default for the T2 SDE.
44 .PP
45 The
46 .I -e
47 --- cron3.0pl1/crontab.c.vanilla 2010-07-18 23:13:02.000000000 +0200
48 +++ cron3.0pl1/crontab.c 2010-07-18 23:23:22.000000000 +0200
49 @@ -82,11 +82,11 @@
51 fprintf(stderr, "%s: usage error: %s\n", ProgramName, msg);
52 fprintf(stderr, "usage:\t%s [-u user] file\n", ProgramName);
53 - fprintf(stderr, "\t%s [ -u user ] [ -i ] { -e | -l | -r }\n", ProgramName);
54 + fprintf(stderr, "\t%s [ -u user ] [ -i ] { -e | -l | -rr }\n", ProgramName);
55 fprintf(stderr, "\t\t(default operation is replace, per 1003.2)\n");
56 fprintf(stderr, "\t-e\t(edit user's crontab)\n");
57 fprintf(stderr, "\t-l\t(list user's crontab)\n");
58 - fprintf(stderr, "\t-r\t(delete user's crontab)\n");
59 + fprintf(stderr, "\t-rr\t(delete user's crontab)\n");
60 fprintf(stderr, "\t-i\t(prompt before deleting user's crontab)\n");
61 exit(ERROR_EXIT);
63 @@ -134,7 +134,7 @@
64 switch (Option) {
65 case opt_list: list_cmd();
66 break;
67 - case opt_delete: delete_cmd();
68 + case opt_delete: printf("here\n") ; // delete_cmd();
69 break;
70 case opt_edit: edit_cmd();
71 break;
72 @@ -166,6 +166,7 @@
74 int argch;
75 struct stat statbuf;
76 + static int really_delete = 0;
78 if (!(pw = getpwuid(getuid()))) {
79 fprintf(stderr, "%s: your UID isn't in the passwd file.\n",
80 @@ -219,7 +220,10 @@
81 case 'r':
82 if (Option != opt_unknown)
83 usage("only one operation permitted");
84 - Option = opt_delete;
85 + if (really_delete)
86 + Option = opt_delete;
87 + else
88 + really_delete = 1;
89 break;
90 case 'e':
91 if (Option != opt_unknown)