[Mageia-dev] dhclient lease files location

Colin Guthrie mageia at colin.guthr.ie
Thu Feb 7 10:50:53 CET 2013


'Twas brillig, and Guillaume Rousse at 07/02/13 08:37 did gyre and gimble:
> I'm taking this out of bugzilla for larger visibility:
> https://bugs.mageia.org/show_bug.cgi?id=8391
> 
> Initiallly (mageia2), we had both dhcpd (the server) and dhclient (guess
> what?) use a shared directory (/var/lib/dhcp), belonging to dhcp-common
> package, to store their lease file. And I had this bugreport about
> dhclient trying to store under a non-existent /var/lib/dhclient directory.
> 
> I modified the dhcp package as in Fedora, to have each part
> (client/server) use their own, self-provided, state directory to store
> their lease file: /var/lib/dhcpd and /var/lib/dhclient. I expected to
> fix the issue, and making life easier by mimicating fedora setup.
> 
> Then Dave reported he now had the same error message as before, but with
> the old directory: dhclient tries to store lease files under no more
> existent /var/lib/dhcp directory...
> 
> I grepped /etc for occurences of '/var/lib/dhcp', without results. I had
> a look in networkmanager sources, which seems to be the culprit. It once
> used C macro NM_DHCLIENT_STATE_DIRECTORY for this purpose, but not
> anymore. Now, according to current code, it should uses its own state
> directory (/var/lib/NetworkManager) to store those files, but that's
> obviously not the case. And I'm myself having lease files in both
> directories (/var/lib/dhclient and /var/lib/dhcp).
> 
> I'm suspecting a mix of hardcoded or default configuration between dhcp
> (the package), networkmanager and initscripts, but I can't figure where
> exactly. If someone with more knowledge of those deep arcanes could
> help, I'd be very grateful.

Certainly here with my NM launched dhclient processes, it passes the
"-lf /var/lib/dhcp/dhclient-$FOO-eth0.lease"  argument to it.


What is also strange however is that NM doesn't build for me here. Seems
this was due to a commit by Olav to update it to 0.9.7.995

http://svnweb.mageia.org/packages?view=revision&revision=388631

http://svnweb.mageia.org/packages/cauldron/networkmanager/current/SPECS/networkmanager.spec?r1=388631&r2=388630&pathrev=388631


Interestingly the commit message is "SILENT: undo version change". Not
quite sure what to make of that. Can you elaborate on the version change
Olav? Perhaps I missed a mail somewhere asking for help rediffing a
patch or something? My memory is buggy :p


Anyway, going back to the 0.9.6.4 version (which is what is available as
built) and I find this via a quick grep:

[colin at jimmy NetworkManager-0.9.6.4]$ grep -rn --exclude=*.po "\.lease"
ChangeLog:19635:	dhclient with "-lf /var/lib/dhcp/dhclient-%s.leases".
src/dhcp-manager/nm-dhcp-dhclient.c:95:	return g_strdup_printf
("%s/dhclient%s-%s-%s.lease",

This uses NM_DHCLIENT_LEASE_DIR which is different to what you mentioned
above.

This appears to be the code in question:

#if defined(TARGET_DEBIAN) || defined(TARGET_SUSE) ||
defined(TARGET_MANDRIVA)
#if defined(DHCLIENT_V3)
#define NM_DHCLIENT_LEASE_DIR			LOCALSTATEDIR "/lib/dhcp3"
#else
#define NM_DHCLIENT_LEASE_DIR           LOCALSTATEDIR "/lib/dhcp"
#endif
#else
#define NM_DHCLIENT_LEASE_DIR           LOCALSTATEDIR "/lib/dhclient"
#endif


I presume just removing the "|| defined(TARGET_MANDRIVA)" bit of the
first #if condition should do the trick.

I'd like to see what Olav had in mind with that commit first tho'. Seems
there are a few changes in NM that will mean we have to refactor things
a bit (it should use NMSTATEDIR in the newer code like you say and thus
be in it's own directory).

Col


-- 

Colin Guthrie
colin(at)mageia.org
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the Mageia-dev mailing list