User's incrontab not working (only root's) when incrond is run as a service
If the binary for incrontab (which I don't know, never used it) hasn't his SGID bit set, that could cause this type of strange behaviour.
Set it with chmod g+s /path/to/binary
(/usr/bin/incrontab, maybe?)
You can assess if it's set by:
ls -l /path/to/binary
(example)
ls -l /usr/bin/crontab
-rwxr-s--x 1 root crontab 44336 Jun 23 18:47 /usr/bin/crontab
Related videos on Youtube
![Antoine Pinsard](https://i.stack.imgur.com/HPzU4.jpg?s=256&g=1)
Antoine Pinsard
Web developer interested in system administration and security. Co-founder of Cocoonr, real estate agency specialized in short-stay rental. Python/Django enthusiast.
Updated on September 18, 2022Comments
-
Antoine Pinsard almost 2 years
Here is my incrontab (tony's incrontab):
/home/tony/Workspace/cocoonr/ui/static/ui/img/icons/vector IN_MODIFY,IN_CREATE,IN_MOVED_TO /bin/sh /home/tony/Workspace/cocoonr/boilerplate/svg2djangohtml $@/$# /home/tony/Workspace/cocoonr/ui/templates/inc/icons/
I tested it multiple times changing some things, no way to make it work when incrond is run as a service (using openrc).
If I run incrond in foreground (
incrond -n
), then tony's incrontab worksIf I set root's incrontab to the one given above, it works even when run as a service.
My tony is in
/etc/incron.allow
:root tony
And there is no
/etc/incron.deny
.I even tried with a much simpler incrontab:
/tmp/foo IN_ATTRIB touch /tmp/bar
The results are the same.
How to make user's incrontab working?
-
Atul almost 5 yearsAre there any errors in logs?
-
-
Rafael Umbelino almost 8 yearsincrontab has no binary? SGID bit was already set? What was the situation?
-
Antoine Pinsard almost 8 years/usr/bin/incrontab has SUID set. Owner is
root
, group isroot
. I tried to set SGID but it didn't work either. -
Rafael Umbelino almost 8 yearsNow that's strange. incrontab should run as root regardless of the user trying to execute it. But maybe we are onto something here. Group is root, right? Change it to crontab, set SGID bit and try again. Let's dig this one out.
-
Antoine Pinsard almost 8 yearsI can't see the point in setting group
crontab
. incrontab is not related to crontab. Could you please explain the idea behind this? -
Rafael Umbelino almost 8 yearsJust a hunch based on the fact that I hit almost the same situation with another application that didn't work if I called as normal user, but worked fine as root. I had to change the binary's group to video so it could output to video. Go figure that one.
-
Antoine Pinsard almost 8 yearsThis doesn't change anything either. But anyway, the issue should not be about calling the
incrontab
executable. The daemon executes the commands as the same user whether it is root's incrontab or a user incrontab. And I think it reads it directly from files in/var/spool/incron/
rather than through theincrontab
command.