fcron
fcron copied to clipboard
Resolving fcrontab warnings when run as root
(raising on behalf of tux88)
I have encountered a problem for a long time with pam and nslcd,
which produces an unnecessary warning when calling
"fcrontab
Hi tux88,
Apologies for the delay. I've tried reproducing your issue, without success (when using a valid config line).
It looks like the fcrontab file example you proposed had some formatting issue, I assume when copying as a comment in github. I have fixed the formatting and used:
!erroronlymail(true)
!mailto(root)
IN_BOOT=
IN_RUNLEVEL=
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
20 2 * * * root /bin/true
Can you try with this exact example and tell me if you still see the warning?
Note that in my case I don't have nslcd, but instead I've added a debug statement to print the value of 'username' right before the if statement you are proposing to change:
/FIXME TEMPORARY DEBUG
fprintf(stderr, "username='%s'\n", username);
if ((userpwent = getpwnam(username)) != NULL) {
Based on your code change proposal, it seems that the issue would be if username=''
, but I could not reproduce this with a valid config line.
It seems to me the code before this function check_username()
is called should skip all blank spaces before calling check_username()
, so I can't see how username
could be empty, unless:
- the word being checked starts with a non-space, non-alpha-numerical character (e.g.
%word
). I am not clear how that could happen for a valid line, but could be missing something? - the line stops right after the 'day-of-week' field, i.e. no command was specified (which is invalid and fcron will flag it)
e.g. each of the two lines below will get me username=''
20 2 * * * %root /bin/true
20 2 * * *
I'd be quite curious to confirm which line does cause the issue on your side, so I can reproduce here
closing this old PR... feel free to reopen / open a new one answering the remaining questions and addressing the points I raised if you're still interested in this.