1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
From: Christian Kastner <ckk@kvr.at>
Date: Sat, 26 Dec 2015 19:51:53 +0100
Subject: Permit user to use -u option on self
Instead of entirely prohibiting non-root users to use the -u option, allow them
to use it on themselves, as this should be a null-op.
Fix provided by Steve Greenland <stevegr@debian.org>.
Forwarded: no
Last-Update: 2015-12-26
---
crontab.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/crontab.c b/crontab.c
index 992d175..7060db3 100644
--- a/crontab.c
+++ b/crontab.c
@@ -176,18 +176,19 @@ parse_args(argc, argv)
usage("bad debug option");
break;
case 'u':
- if (getuid() != ROOT_UID)
- {
- fprintf(stderr,
- "must be privileged to use -u\n");
- exit(ERROR_EXIT);
- }
if (!(pw = getpwnam(optarg)))
{
fprintf(stderr, "%s: user `%s' unknown\n",
ProgramName, optarg);
exit(ERROR_EXIT);
}
+ if ((getuid() != ROOT_UID) &&
+ (getuid() != pw->pw_uid))
+ {
+ fprintf(stderr,
+ "must be privileged to use -u\n");
+ exit(ERROR_EXIT);
+ }
free(User);
if ((User=strdup(pw->pw_name)) == NULL) {
fprintf(stderr, "Memory allocation error\n");
|