From: Christian Kastner 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 . 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");