First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 27079
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Max Kalika (RETIRED) <max@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Danny Dowlearn <alwjdd@utdallas.edu>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
dhcp updated dhcpd init file text/plain Lars Kneschke 2004-01-01 15:39 0000 1.08 KB Details
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 27079 depends on: Show dependency tree
Bug 27079 blocks: 31840
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2003-08-21 14:41 0000
On my system, dhcpd is run as the 'dhcp' user (non-root).  But, the
'/var/lib/dhcp' directory (and its contents) were owned by root:root with 644
permissions.  So here's what would happen:

dhcpd would run for a while (having been started at boot-time or explicitly
restarted after it crashed) and would renew a few leases on my network (1
server, 3 workstations ; 3 static ip's, the rest from a pool.)  I would see a
few of the leases in my '/var/log/everything'.

Then, dhcpd would want to write the leases to '/var/lib/dhcp/dhcpd.leases'. 
Since it didn't have permission, it put an entry in syslog saying, "Can't create
new lease file: Permission denied", and it would crash.

The obvious workaround was to:

# cd /var/lib
# chown -R dhcp:dhcp dhcp/

leaving me to wonder why those permissions weren't set up in the first place. 
Since fixing that, dhcpd has been running for longer than the usual "time to
crash", so assume it's working now.

Originally I had tried to remerge dhcp, but that didn't fix the problem.  (Maybe
a remerge wouldn't replace the '/var/lib/dhcp' directory structure?)

Reproducible: Always
Steps to Reproduce:
1.emerge dhcp
2.look at how '/var/lib/dhcp' is owned by root:root, but dhcpd is run by user 'dhcp'
3.try to let dhcpd renew some leases, and watch it crash?

Actual Results:  
I watched it crash.

Expected Results:  
Not crash.

Moo.

------- Comment #1 From Martin Holzer (RETIRED) 2003-08-21 23:49:02 0000 -------
running in chroot is not an option for you ?

------- Comment #2 From Danny Dowlearn 2003-08-22 11:05:37 0000 -------
> running in chroot is not an option for you ?

you'll have to excuse my ignorance, but chroot to where?  i can't find any directories or files where user 'dhcp' has write access (besides the ones i manually switched).  i thought the 'standard' default behavior was to have the lease file in /var/lib/dhcp/ anyway.

------- Comment #3 From Martin Holzer (RETIRED) 2003-08-28 00:41:42 0000 -------
*** Bug 27460 has been marked as a duplicate of this bug. ***

------- Comment #4 From Eric Pretorious 2003-08-29 13:45:00 0000 -------
Is dhcpd pre-configured to run as the user dhcp? No 'dhcp' user is created
during installation or post-installation.

I only run dhcpcd (the client daemon) and  - even though it runs as root - It
still doesn't create the /var/lib/dhcp/dhclient.leases file.  :^(

------- Comment #5 From Danny Dowlearn 2003-08-29 15:55:50 0000 -------
> Is dhcpd pre-configured to run as the user dhcp? No 'dhcp' user is created during installation or post-installation.
>
>I only run dhcpcd (the client daemon) and  - even though it runs as root - It still doesn't create the /var/lib/dhcp/dhclient.leases file.  :^(

I did nothing special after the emerging dhcp utilities, and I run both dhcpcd
and dhcpd on my router.  dhcpd runs as the 'dhcp' user, but dhcpcd runs as
'root'.  This seems reasonable, given the functions that they perform.  I know
why my dhcpd was having problems (see the bug desc.), but I dunno why your
dhcpcd isn't writing lease files.  Although I'll note that my 'dhclient.leases'
is empty and owned by dhcp:dhcp, even though it does have a lease right now. 
No errors anywhere, though.

------- Comment #6 From Andreas Vinsander 2003-09-06 16:25:21 0000 -------
Actually dhcpd manage to write some leases to the file, I think it crashes when
it is about to cleanup the file and create a new one containing the valid
leases. Since it just adds leases to the end of the original lease file it
needs to clean it up once in a while. At least that is my observation. I did
the same thing 'chown dhcp.dhcp /var/lib/dhcp' to fix it and its running
flawlessly since.

------- Comment #7 From Max Kalika (RETIRED) 2003-09-16 19:00:06 0000 -------
Ok, reassigning this bug to myself because I maintain this ebuild. Let me
follow up on some things here so we can get this into stable.

Danny: I checked in a new version which is supposed to set proper perms.
Please try it and report back.  To chroot, you need to change
/etc/conf.d/dhcp to point to the dhcp directory.  This directory must be
set up properly. To do that you must first make sure dhcp works correctly
without chroot, and then you need to run:

  ebuild /var/db/pkg/net-misc/dhcp*/dhcp*.ebuild config

Eric: version 3.0_p2-r1 (currently ~x86) uses the paranoia patch which
changes the daemon to run as dhcp.  The user is added to the system
during the install procedure.

------- Comment #8 From Danny Dowlearn 2003-09-17 17:16:30 0000 -------
Okay, I'm trying it w/o chroot for now.  I'll have to run it for 24-48hrs. to
make sure it's working (give it enough time to need to update the file).

I completely unmerged both dhcpcd and dhcp(d) since they shared the offending
directory (could this have been the problem?).  I backedup'd/removed
/etc/dhcp/, /etc/dhcpcd/, and /var/lib/dhcp/.  Then, I remerged each package,
and re-copied by old /etc/dhcp/ and /etc/dhpcd/ _only_ (not /var/lib/dhcp/). 
I'll keep y'all posted.

(Btw, since remerging, they now have separate directories in /var/lib/, namely
/var/lib/dhcp/ and /var/lib/dhcpc/.  Is that what this is all about or is it
just 'cleaner' that way?  The latter, I'm thinking.)

------- Comment #9 From Danny Dowlearn 2003-09-19 01:17:10 0000 -------
(I just realized bugzilla/mozilla doesn't wrap text lines.  My bad.)

Okay.  It's been running for about 36hrs.  Have some info:

dannyd@alpha /var/lib $ ls -la dhcp/ dhcpc/
dhcp/:
total 9
drwxr-xr-x    2 dhcp     dhcp          136 Sep 18 21:52 .
drwxr-xr-x   15 root     root          368 Sep 17 18:58 ..
-rw-r--r--    1 root     root            0 Sep 17 18:58 .keep
-rw-r--r--    1 dhcp     dhcp          704 Sep 18 21:52 dhcpd.leases
-rw-r--r--    1 dhcp     dhcp          941 Sep 18 21:52 dhcpd.leases~

dhcpc/:
total 5
drwxr-xr-x    2 root     root           80 Sep 17 18:53 .
drwxr-xr-x   15 root     root          368 Sep 17 18:58 ..
-rw-r--r--    1 root     root          469 Sep 17 18:53 dhcpcd-eth1.info

dannyd@alpha /var/lib $ ps axuf | grep dhcp
root  3669  0.0  0.1  1340  316 ?  S  Sep17  0:00 /sbin/dhcpcd -R eth1
dhcp  6092  0.0  0.4  2572  992 ?  S  Sep17  0:00 [dhcpd]

So I guess it's going to work now.  I have just executed the 'ebuild config'
thing to set up the chroot.  '/etc/init.d/dhcp restart' looks good with:

"Starting chrooted dhcp...    [OK]"

All permissions/ownerships look the same as before chroot.  Rad.

------- Comment #10 From JG 2003-09-19 02:38:25 0000 -------
hi,
is it possible that there is a bug in the init-script of dhcpd or somewhere else?
i just installed dhcp 3.0_p2-r1 on a new server and used my config from the old server which i should replace, but it just died after 1 hour running.

first i thought it was grsecurity because of those messages:
grsec: From 10.x.x.x: denied hardlink of /var/lib/dhcp/dhcpd.leases (owned by 0.0) to /var/lib/dhcp/dhcpd.leases~ for (dhcpd:3098) UID(1000) EUID(1000), parent (init:1) UID(0) EUID(0)
grsec: From 10.x.x.x: signal 11 sent to (dhcpd:3098) UID(1000) EUID(1000), parent (init:1) UID(0) EUID(0)

if i manually "chown dhcp:dhcp /var/lib/dhcp/dhcpd.leases" it seems to be fine (though i can only tell in a few hours).
if i then restart dhcpd with "/etc/init.d/dhcp restart" the ownership of the dhcpd.leases file is set to root:root again...and then when dhcpd wants to write to it => crash
at the moment i'm using a kernel without grsecurity for testing.

i'm not using chrooted environment (commented out the CHROOT line in /etc/conf.d/dhcp) because i got problems with logging when chrooted.

JG

------- Comment #11 From Max Kalika (RETIRED) 2003-09-19 08:37:41 0000 -------
Danny, thanks for confirming. I'll close this as fixed. 
 
JG, it seems entirely a problem with the grsec patch.  You may need to 
relax/adjust your ACLs.  If problems persist, open another bug because 
that is a completely separate issue.  Thanks. 

------- Comment #12 From Eric Pretorious 2003-10-02 15:26:29 0000 -------
Max: My bug relates specically to dhcpcd-1.3.2* (not dhcpd-3.0). (I had
originally
opened bug 27460 to report this but it was marked as a duplicate of this
bug.) 

I'm still experiencing the same failure to utilize /var/lib/dhcp/client.leases.

------- Comment #13 From Lars Kneschke 2003-12-31 05:12:49 0000 -------
I do still have this problem! I'm using net-misc/dhcp-3.0_p2-r2 and my dhcpd is
still crashing regulary. 

I do also have this root:root problem.

ProxyLK root # ls -l /var/lib/dhcp/
total 8
-rw-r--r--    1 root     root         1211 Dec 31 14:06 dhcpd.leases
-rw-r--r--    1 dhcp     dhcp         1211 Dec 31 13:48 dhcpd.leases~

------- Comment #14 From Max Kalika (RETIRED) 2003-12-31 08:02:31 0000 -------
Reopening.. I'm really lost as to what is happening here.  Mine works just fine
without any crashes.

------- Comment #15 From ari edelkind 2003-12-31 12:54:49 0000 -------
I'm the author of the isc-dhcpd paranoia patch (max contacted me).  I'm not in
charge of the gentoo package.

The fact that the dhcpd.leases file is originally created as root is not a
problem; these permissions affect file/inode content only, and should not
affect directory actions, such as renaming or deleting the file.  This is
standard unix behavior, and if the grsecurity patch breaks this, it's a problem
with the grsecurity patch.

Anyone currently experiencing a server lease-write problem should update this
ticket with the following:

  - permissions of /var/lib/dhcp (ls -ld /var/lib/dhcp)
  - permissions of <chroot>/var/lib/dhcp if you're using chroot
  - if the owner of either of these directories is root, that's your problem,
and you should list the gentoo package revision you're using.
  - if the owner of these directories is your dhcp user, i'll need the output
of strace, detailing the events leading to program abort.  You can use:
      # strace -o <file> -f dhcpd <options>

You can attach the entire strace output to this ticket, though you probably
shouldn't include it all in the body of your report.

If you're experiencing a client (dhcpcd) lease problem, you have a separate
issue, and this ticket is not for you.

------- Comment #16 From Lars Kneschke 2004-01-01 15:34:11 0000 -------
ProxyLK root # ls -ld /var/lib/dhcp
drwxr-xr-x    2 dhcp     dhcp          136 Jan  1 23:37 /var/lib/dhcp

This is from syslog:

Jan  1 14:23:07 ProxyLK grsec: denied hardlink of /var/lib/dhcp/dhcpd.leases (owned by 0.0) to /var/lib/dhcp/dhcpd.leases~ for (dhcpd:6787) UID(1002) EUID(1002), parent (init:1) UID(0) EUID(0)

The dhcpd is starting up and is creating the dhcpd.leases as root. After that it switches to user dhcp. After is trys to create the hardlink, which gets denied by grsecurity. Why can't the dhcpd.leases get created as the dhcp user?

Anyways, i attached my new init script, which seems to fix the problem. I change the ownership of dhcpd.leases after dhcpd gets started.

Cu

------- Comment #17 From Lars Kneschke 2004-01-01 15:39:18 0000 -------
Created an attachment (id=22983) [edit]
updated dhcpd init file

------- Comment #18 From ari edelkind 2004-01-02 12:14:25 0000 -------
The script you attached introduces a race condition, in which the lease file
may not have been created by the time chown is called.

As i mentioned, your issue can be considered a problem with the grsecurity
patch, or at least its restrictive settings.  However, if you wish to account
for this behavior in dhcpd anyway, i know that max had been writing an
additional patch to change ownership of the original lease file after creation.

------- Comment #19 From Max Kalika (RETIRED) 2004-01-02 12:21:30 0000 -------
Thank you for clearing this Ari, I completely ignored the fact that grsecurity
might be the culprit, but now it makes a lot of sense.  Do you see any problems
with the patch you mention?  If not, I'll put it back for folks with grsec. 
Thanks again.

------- Comment #20 From Danny Dowlearn 2004-01-08 14:08:23 0000 -------
Hello again.  I'm the original reporter from back in the day.  While recently
upgrading my system (via emerge world), a new version of dhcpd was installed. 
The original fix worked for a while (i.e. putting "Setting permissions on dhcpd
leases file" in the init script).  However, after upgrading the (original)
problem came back.  Right after the server would start.  (I'm fairly sure that)
the problem is that the permissions on the leases file are being set (via the
init script) _before_ the server starts.  The server re-chown's it to
root:root.  My kludge was to stick an additional "Setting permissions on dhcpd
leases file . . . again" ebegin right after the server starts in the start()
functions (rather than in the check_config() function where it currently
resides.  Also, I'm not using any grsecurity stuff or chroot stuff.

Back when this issue first came up, I can't remember if the fixed init script
put the "Setting permissions..." in check_config() or in start().  However,
putting it in the latter has worked for me.

dannyd

------- Comment #21 From Max Kalika (RETIRED) 2004-01-14 17:05:51 0000 -------
I went ahead and re-added the ebuild with the chown patch. Give it a try
please.

------- Comment #22 From Lars Kneschke 2004-01-14 23:45:38 0000 -------
Looks good now. No problems so far.

------- Comment #23 From Martin Holzer (RETIRED) 2004-01-20 15:43:01 0000 -------
closing the last time, hope so

First Last Prev Next    No search results available      Search page      Enter new bug