Merge ~juliank/ubuntu/+source/cron:inherit-path into ubuntu/+source/cron:ubuntu/devel

Proposed by Julian Andres Klode
Status: Needs review
Proposed branch: ~juliank/ubuntu/+source/cron:inherit-path
Merge into: ubuntu/+source/cron:ubuntu/devel
Diff against target: 169 lines (+111/-3)
6 files modified
debian/changelog (+10/-0)
debian/cron.init (+1/-1)
debian/cron.service (+1/-1)
debian/crontab.main (+2/-1)
debian/patches/features/inherit-path.patch (+96/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Steve Langasek (community) Approve
Canonical Foundations Team Pending
Review via email: mp+399661@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) wrote :

Bileto ticket: https://bileto.ubuntu.com/#/ticket/4490

Needs a change in anacron to to make anacrontab work correctly

Revision history for this message
Steve Langasek (vorlon) :
review: Needs Information
Revision history for this message
Julian Andres Klode (juliank) :
Revision history for this message
Steve Langasek (vorlon) wrote :

Ok, alignment with cronie is a reasonable justification. +1

review: Approve

Unmerged commits

b9457aa... by Julian Andres Klode

Add -P (inherit PATH) option and set it in service

* d/p/f/inherit-path.patch: Add -P option to inherit PATH from environment,
  thanks to Tom Jones for the patch (Closes: #688716)
* Inherit PATH by default (LP: #1779767):
  - debian/crontab.main: Stop setting PATH
  - debian/cron.service, debian/cron.init: Pass -P to cron

94e1e5c... by Steve Langasek

3.0pl1-136ubuntu1 (patches unapplied)

Imported using git-ubuntu import.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 2c8e458..feb358a 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+cron (3.0pl1-136ubuntu2) hirsute; urgency=medium
7+
8+ * d/p/f/inherit-path.patch: Add -P option to inherit PATH from environment,
9+ thanks to Tom Jones for the patch (Closes: #688716)
10+ * Inherit PATH by default (LP: #1779767):
11+ - debian/crontab.main: Stop setting PATH
12+ - debian/cron.service, debian/cron.init: Pass -P to cron
13+
14+ -- Julian Andres Klode <juliank@ubuntu.com> Mon, 15 Mar 2021 15:10:36 +0100
15+
16 cron (3.0pl1-136ubuntu1) focal; urgency=low
17
18 * Merge from Debian unstable. Remaining changes:
19diff --git a/debian/cron.init b/debian/cron.init
20index c90dc1e..ae607f7 100644
21--- a/debian/cron.init
22+++ b/debian/cron.init
23@@ -65,7 +65,7 @@ fi
24
25 case "$1" in
26 start) log_daemon_msg "Starting periodic command scheduler" "cron"
27- start_daemon -p $PIDFILE $DAEMON $EXTRA_OPTS
28+ start_daemon -p $PIDFILE $DAEMON -P $EXTRA_OPTS
29 log_end_msg $?
30 ;;
31 stop) log_daemon_msg "Stopping periodic command scheduler" "cron"
32diff --git a/debian/cron.service b/debian/cron.service
33index 47651a1..f5d22b5 100644
34--- a/debian/cron.service
35+++ b/debian/cron.service
36@@ -5,7 +5,7 @@ After=remote-fs.target nss-user-lookup.target
37
38 [Service]
39 EnvironmentFile=-/etc/default/cron
40-ExecStart=/usr/sbin/cron -f $EXTRA_OPTS
41+ExecStart=/usr/sbin/cron -f -P $EXTRA_OPTS
42 IgnoreSIGPIPE=false
43 KillMode=process
44 Restart=on-failure
45diff --git a/debian/crontab.main b/debian/crontab.main
46index c89cc0b..54aad03 100644
47--- a/debian/crontab.main
48+++ b/debian/crontab.main
49@@ -5,7 +5,8 @@
50 # that none of the other crontabs do.
51
52 SHELL=/bin/sh
53-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
54+# You can also override PATH, by default, newer versions inherit it from the environment
55+#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
56
57 # Example of job definition:
58 # .---------------- minute (0 - 59)
59diff --git a/debian/patches/features/inherit-path.patch b/debian/patches/features/inherit-path.patch
60new file mode 100644
61index 0000000..c9130a7
62--- /dev/null
63+++ b/debian/patches/features/inherit-path.patch
64@@ -0,0 +1,96 @@
65+Description: optionally inherit PATH from parent process
66+ The default PATH of cron isn't very useful. This patch adds an
67+ option -P to leave PATH alone, so that it's inherited from whatever
68+ execs cron. In our case that is daemontools, but could also be
69+ start-stop-daemon or whatever. This puts our sysadmins in control
70+ of cron's (and child processes') PATH, as they are able to set it in the
71+ run script. Without the -P option, crontabs that don't set PATH
72+ themselves get a value of /usr/bin:/bin, which is hardcoded as
73+ _PATH_DEFPATH in pathnames.h.
74+Author: Tom Jones <tom@oxix.org>
75+Origin: vendor, https://bugs.debian.org/688716
76+Bug-Debian: https://bugs.debian.org/688716
77+--- a/cron.8
78++++ b/cron.8
79+@@ -36,6 +36,9 @@ runlevels.
80+ .B \-f
81+ Stay in foreground mode, don't daemonize.
82+ .TP
83++.B -P
84++Don't set PATH for child processes. Let it inherit instead.
85++.TP
86+ .B \-l
87+ Enable LSB compliant names for /etc/cron.d files. This setting, however, does
88+ not affect the parsing of files under /etc/cron.hourly, /etc/cron.daily,
89+--- a/cron.c
90++++ b/cron.c
91+@@ -94,7 +94,9 @@ main(argc, argv)
92+ set_cron_cwd();
93+
94+ #if defined(POSIX)
95+- setenv("PATH", _PATH_DEFPATH, 1);
96++ if (change_child_path) {
97++ setenv("PATH", _PATH_DEFPATH, 1);
98++ }
99+ #endif
100+
101+ /* Get the default locale character set for the mail
102+@@ -448,9 +450,9 @@ sighup_handler(int x) {
103+
104+
105+ #if DEBUGGING
106+-const char *getoptarg = "flL:nx:";
107++const char *getoptarg = "fPlL:nx:";
108+ #else
109+-const char *getoptarg = "flL:n";
110++const char *getoptarg = "fPlL:n";
111+ #endif
112+
113+ static void
114+@@ -461,6 +463,7 @@ parse_args(argc, argv)
115+ int argch;
116+
117+ stay_foreground = 0;
118++ change_child_path = 1;
119+ lsbsysinit_mode = 0;
120+ log_level = 1;
121+ fqdn_in_subject = 0;
122+@@ -472,6 +475,9 @@ parse_args(argc, argv)
123+ case 'f':
124+ stay_foreground = 1;
125+ break;
126++ case 'P':
127++ change_child_path = 0;
128++ break;
129+ case 'l':
130+ lsbsysinit_mode = 1;
131+ break;
132+--- a/cron.h
133++++ b/cron.h
134+@@ -306,6 +306,7 @@ time_min clockTime;
135+ static long GMToff;
136+
137+ int stay_foreground;
138++int change_child_path;
139+ int lsbsysinit_mode;
140+ int log_level;
141+ int fqdn_in_subject;
142+--- a/entry.c
143++++ b/entry.c
144+@@ -28,6 +28,7 @@ static char rcsid[] = "$Id: entry.c,v 2.
145+
146+ #include "cron.h"
147+
148++extern int change_child_path;
149+
150+ typedef enum ecode {
151+ e_none, e_minute, e_hour, e_dom, e_month, e_dow,
152+@@ -289,7 +290,7 @@ load_entry(file, error_func, pw, envp)
153+ goto eof;
154+ }
155+ }
156+- if (!env_get("PATH", e->envp)) {
157++ if (!env_get("PATH", e->envp) && change_child_path) {
158+ snprintf(envstr, MAX_ENVSTR, "PATH=%s", _PATH_DEFPATH);
159+ if ((tenvp = env_set(e->envp, envstr))) {
160+ e->envp = tenvp;
161diff --git a/debian/patches/series b/debian/patches/series
162index 145c4ca..e4a0c48 100644
163--- a/debian/patches/series
164+++ b/debian/patches/series
165@@ -67,3 +67,4 @@ features/Recover-from-crontab-errors.patch
166 features/Selective-logging.patch
167 features/Check-orphaned-crontabs-for-adoption.patch
168 features/Add-option-to-include-FQDN-in-email.patch
169+features/inherit-path.patch

Subscribers

People subscribed via source and target branches