New Fedora 22 Change proposal: systemd-sysusers

Lennart Poettering mzerqung at 0pointer.de
Thu Jul 10 18:05:38 UTC 2014


On Thu, 10.07.14 12:44, Simo Sorce (simo at redhat.com) wrote:

> On Thu, 2014-07-10 at 17:18 +0200, Jakub Hrozek wrote:
> > We /do/ plan on the syncing anyway, because some admins are
> > still used to vipw their passwd databases and there are legacy scripts
> > around, but still --  could we, when the SSSD interface is available,
> > call out from systemd-sysusers to the SSSD, with some fallback for
> > cases where SSSD is not running?
> 
> Jakub,
> I think we can use inotify on /etc/passwd and friends and reread if
> someone modifies the file.

This is not that easy actually as it sounds, because you need to be able
to cover the case where the passwd file is replaced by a different one
(which is actually the common case, since that's what makes updates to
the file atomic). But inotify is not particulraly nice for doing that,
especially if you want to cover the state where the file missing is
missing entirely... In that case you'd have to watch all of /etc, which
of course is something to avoid, since you might get woken up quite a
bit too frequently.

My suggestion would be to simply check the mtime of /etc/passwd on each
query you get (well, but not more often than once per 1s or so), and
reread the file if the mtime changed. That way you have to issue one
stat() call every 1s if you are busy, and do nothing if you are
not. Which sounds like a good deal. Much simpler and safer than inotify.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the devel mailing list