Bug 105 - nsdc lacks locking
nsdc lacks locking
Status: RESOLVED FIXED
Product: NSD
Classification: Unclassified
Component: NSD Code
2.3.x
All All
: P2 normal
Assigned To: NSD team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-09-28 14:32 CEST by Miek Gieben
Modified: 2006-07-25 13:51 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miek Gieben 2005-09-28 14:32:31 CEST
It is now possible to run parallel instances of nsdc rebuild. There should
be some kind of locking mechanism.
Comment 1 Miek Gieben 2005-09-28 14:35:19 CEST
First added Jakob's patch, replaced that with Ted's code.
Comment 2 Stephane Bortzmeyer 2006-07-10 12:32:46 CEST
It does not seem to work on my machine. The locking code is:

lock() {
        (umask 222; echo "database locked by PID: $$" >${lockfile}) ||
                (cat ${lockfile} ; "echo aborting..." ; exit 1)
}

and, while the lock file has the proper flags:

-r--r--r--  1 root root 18 Jul 10 12:27 /usr/local/nsd/var/nsd.db.lock

I can break the lock without noticing:

ns2:local/nsd/var # echo "I break your lock" > nsd.db.lock 
ns2:local/nsd/var # echo $?                               
0

Linux ns2.nic.fr 2.6.9-34.0.1.ELsmp #1 SMP Wed May 24 08:14:29 CDT 2006 i686 i686 i386 GNU/Linux
CentOS  release 4.3 (Final)


Comment 3 Stephane Bortzmeyer 2006-07-10 12:56:55 CEST
OK, it happened because nsdc ran as root (shame on me). root can do everything. 

I suggest either to document clearly "Thou Shalt Not Run nsd as Root" or to add a check in nsdc that id != 0. Otherwise, the lock is useless.
Comment 4 Wouter Wijngaards 2006-07-25 13:51:30 CEST
Fixed, with test code, also for the root user. With the noclobber option also for root the lock works as it should.