LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-08-2014, 06:09 PM   #1
fpemud
LQ Newbie
 
Registered: Nov 2013
Posts: 3

Rep: Reputation: Disabled
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?
 
Old 10-09-2014, 01:22 PM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Reading doesn't need the lock because the file should be replaced rather than modified.

Are you sure you should be reading these rather than using the likes of getpwent() ?

Last edited by linosaurusroot; 10-09-2014 at 01:23 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adduser not working - unable to lock passwd Shin Takeshita Linux - General 4 10-24-2014 04:51 PM
deian yum lock [ ERR] Reading state information E: Could not get lock /var/lock/aptit jayakumar01 Linux - Server 1 12-05-2011 11:26 AM
all software installs hang scroll lock and caps lock lights flash jcorrnt Linux - Hardware 6 02-07-2009 12:44 PM
How can I lock/unlock passwd file? scorpionaag Linux - Server 2 01-04-2008 08:15 AM
How to Lock Files (/etc/passwd /var/spool/[user] Larry James Programming 3 12-04-2000 11:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration