Re: pw keeps setting /etc/group to 0600

看板FB_current作者時間12年前 (2013/04/27 12:33), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串8/9 (看更多)
On Wed, Nov 21, 2012 at 05:45:43PM +0200, Jaakko Heinonen wrote: > On 2012-11-19, Mateusz Guzik wrote: > > First, pw should not fail if other instance is running, it should wait > > instead (think of parallel batch scripts adding some users/groups). > > > > Second, current code has a race: > > lockfd = open(group_file, O_RDONLY, 0); > > if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1) > > err(1, "%s", group_file); > > if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) { > > [..] > > gr_copy(pfd, tfd, gr, old_gr); /* copy from groupfile to tempfile */ > > [..] > > rename(tempfile,groupfile); > > Hmm, could using the O_EXLOCK flag for open() instead of flock() help here? > Yes, this would fix the race. But the problem of pw exiting due to other process holding the lock remains. And I think that fixing it will require holding a lock over whole time pw is running so that we have stable snapshot of user base at least in regard of local files. One could create one lock, say /etc/.pw.lock, that would be used to synchronize any changes to /etc/master.passwd, /etc/group and whatnot. And then there is this API issue (but maybe this is just me nitpicking). -- Mateusz Guzik <mjguzik gmail.com> _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
文章代碼(AID): #1HUrK2MI (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1HUrK2MI (FB_current)