Re: incron fails after dealing with changes done by useradd or userdell

From: Andrew Pollock <andrew-incron_at_andrew.net.au>
Date: Mon, 7 Mar 2011 08:05:15 -0800

On Mon, Mar 07, 2011 at 02:46:49PM +0100, Patryk wrote:
> Hello,
>
> I gave incron 0.5.8 a try.
>
> # `incrontab -e`
> /etc/passwd IN_CLOSE_WRITE /send/me/an/email
>
> useradd would trigger this immediately, sending 2 notification emails. After that incron
> would just hang and ignore any changes to the passwd file. The same happens with
> /etc/group or userdel, however echo text > /some/other/file works all the time without
> crashing anything.
>

I don't think this is a bug with incron.

I think you should strace useradd and see what it's doing. I think you may
find that it's creating a temporary file with the new user in it, and then
moving it over the top of the current passwd file. This isn't going to be
considered an IN_CLOSE_WRITE by incron, which is why you're not seeing your
job execute.

Sure enough, strace (on my system) reveals that useradd manipulates an
/etc/passwd+ and an /etc/passwd-, and rename()s /etc/passwd+ to /etc/passwd.

regards

Andrew
Received on Tue Jun 05 2012 - 22:14:21 CEST

This archive was generated by hypermail 2.2.0 : Tue Jun 05 2012 - 22:14:21 CEST