should my program lock /etc/.pwd.lock when reading /etc/passwd?
I'm writing some program that operates /etc/{passwd,group,shadow,gshadow}.
I learned that any program should lock /etc/.pwd.lock by calling lckpwdf() before writing the above files so that write collisions can be avoided.
I guess reading operation also needs this lock so that program won't read out inconsistent data.
But I found I can't do the lock when reading /etc/passwd as non-root, because /etc/.pwd.lock is owned by root:root and has mode 0600.
Am I wrong? Doesn't reading need this lock?
|