Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 26519 - dhcpd-3.0_p2-r1 writes lease file before dropping root causing infinite loop
Summary: dhcpd-3.0_p2-r1 writes lease file before dropping root causing infinite loop
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Max Kalika (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 31840
  Show dependency tree
 
Reported: 2003-08-12 22:45 UTC by Henry Yang
Modified: 2004-02-25 16:48 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henry Yang 2003-08-12 22:45:43 UTC
This pathced version of dhcpd will drop to dhcp:dhcp after initializing the 
file dhcpd.lease after a while it seems dhcpd will fail to write to the file 
and go into infinite loop and slowly fill up harddrive space with temporary 
files in /var/lib/dhcp/ and syslog will be filled with these two lines:

[dhcpd] Wrote 0 new dynamic host decls to leases file.
[dhcpd] Wrote 0 deleted host decls to leases file.

dhcpd is run without chroot, with argument -user dhcp -group dhcp , 
and /var/lib/dhcp is owned by dhcp:dhcp
After starting dhcpd, the file dhcpd.lease is initialized and owned by root:root
Comment 1 Max Kalika (RETIRED) gentoo-dev 2003-08-13 11:59:11 UTC
I had a discussion with our networking guy and we came to the conclusion that 
creating/mucking with the leases file during install is a really bad idea.  I'm 
removing the creation of the lease files from the ebuild (the ebuild will only 
make the /var/lib/dhcp dir).  The dhcpd.leases file will be created *if needed* 
and with proper permissions in the startup script.  Let me test this locally 
and I'll commit if all checks out. 
Comment 2 Max Kalika (RETIRED) gentoo-dev 2003-08-13 13:36:09 UTC
Should be fixed, please try it. 
Comment 3 Henry Yang 2003-08-15 23:06:16 UTC
the lease file is still owned by root even after using the new rc script. It seems that dhcpd will make a copy of dhcpd.lease BEFORE dropping root. Maybe a patch to the code is needed to drop to root BEFORE doing anything to the lease file.
Comment 4 lou 2004-02-01 10:36:44 UTC
I'm now experiencing the same exact problem as the first comment. My DHCP server has been running fine for quite sometime, but the last 2 days, I've seen the same syslog messages:

Feb  1 10:26:06 foo dhcpd: Wrote 0 deleted host decls to leases file.
Feb  1 10:26:06 foo dhcpd: Wrote 0 new dynamic host decls to leases file.
Feb  1 10:26:06 foo dhcpd: Wrote 0 deleted host decls to leases file.
Feb  1 10:26:06 foo dhcpd: Wrote 0 new dynamic host decls to leases file.

I'm always unable to restart the dhcpd server when this occurs and the only option is to reboot. I'm not running chroot'd enviro. My only change is that I implemented GRSecurity in the kernel set to MEDIUM. I've recompiled the kernel without GRSecurity support today.. not sure if things will improve. Lastnight I removed my dhcp distfiles and preformed a re-emerge on it.. no change today, still experienced the error this morning while my laptop was trying to start eth0 and get an IP.

My System:
Linux foo 2.4.22-gentoo-r5 #5 Thu Jan 22 20:16:51 MST 2004 i686 Pentium II (Deschutes) GenuineIntel GNU/Linux

DHCP version:
dhcp-3.0_p2-r2 

Noticed on reboot that ownership of dhcpd.leases was changed before dhcpd start
* Setting ownership on dhcpd.leases ...
* Starting dhcpd ...

checking the permissions in /var/lib/dhcp, noticed that dhcpd.leases is still owned by root
-rw-r--r--    1 root     root         2062 Feb  1 11:48 dhcpd.leases
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566007
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566008
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566009
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566010
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566011
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566012
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566013
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566014
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566015
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566016
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566017
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566018
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 09:20 dhcpd.leases.1075566019
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614384
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614385
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614386
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614387
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614388
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614389
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614390
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614391
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614392
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614393
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614394
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614395
-rw-r--r--    1 dhcp     dhcp          467 Jan 31 22:46 dhcpd.leases.1075614396
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:25 dhcpd.leases.1075656354
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:25 dhcpd.leases.1075656355
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:25 dhcpd.leases.1075656356
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:25 dhcpd.leases.1075656357
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:25 dhcpd.leases.1075656358
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:26 dhcpd.leases.1075656359
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:26 dhcpd.leases.1075656360
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:26 dhcpd.leases.1075656361
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:26 dhcpd.leases.1075656362
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:26 dhcpd.leases.1075656363
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:26 dhcpd.leases.1075656364
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:26 dhcpd.leases.1075656365
-rw-r--r--    1 dhcp     dhcp          467 Feb  1 10:26 dhcpd.leases.1075656366
-rw-r--r--    1 dhcp     dhcp         2260 Feb  1 11:02 dhcpd.leases~


Thanks




Comment 5 Henry Yang 2004-02-02 08:03:46 UTC
That problem may be caused by the grsecurity "hard link restriction", which is part of the LOW security setting. Thats why dhcpd was not able to create a hard link to the root owned lease file. The rc script should be checked again to see if it's compatible with grsecurity.
Comment 6 Max Kalika (RETIRED) gentoo-dev 2004-02-09 11:24:13 UTC
please try -r3 and report your findings.
Comment 7 Max Kalika (RETIRED) gentoo-dev 2004-02-25 16:48:23 UTC
this should be fixed in -r3.