linux - should my program lock /etc/.pwd.lock when reading /etc/passwd? -
I am writing some programs that read / etc / {passwd, group}.
I have learned that before writing the above files, you should lock /etc/.pwd.lock by calling lckpwdf () so that they write that the collision can be avoided.
I think the reading operation also needs this lock so that the program can not read incompatible data.
But I found that I can not lock while reading / etc / passwd non-root, because /etc/.pwd.lock is owned by root: root and mode is 0600.
Am I wrong? Do not read the requirement of this lock?
On Linux, Since this is a non-standard task, it is not necessary in the case of other Unix. lckpwdf ()
& lt; Shadow.h & gt; Has been declared in and should be used when accessing shadow password database (
/ etc / shadow ). No need to call it after reading
/ etc / passwd or
/ etc / group .
Comments
Post a Comment