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, 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 .

Since this is a non-standard task, it is not necessary in the case of other Unix.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -