RPM Community Forums

Mailing List Message of <popt-devel>

poptReadDefaultConfig reads /etc/popt twice

From: Robert Scheck <robert@rpm5.org>
Date: Fri 14 Sep 2007 - 13:21:51 CEST
Message-ID: <20070914112151.GA26682@hurricane.linuxnetz.de>
Hello all,

in Fedora a small issue was discovered, commented by Jeff as follows:

[13:03:17] < jbj> rsc: "flexible" prefix fubarage.
[13:04:02] < rsc> jbj: means?
[13:11:45] < jbj> rsc: popt, like rpm, needs default+system+user overrides.
changes this summer generalized system (i.e. /etc/popt) to multiple
"per-system" locations. Either fray or rse did the change iirc. easy fixing
no matter waht, and it really matters little whether /etc/popt is read
multiple times. but broken imho.
[13:14:47] < jbj> rsc: short note to popt-devel please.

Can somebody take care of this?


----- Forwarded message from bugzilla@redhat.com -----
Description of problem:

poptReadDefaultConfig reads /etc/popt twice

Version-Release number of component (if applicable):
popt-1.12-3.fc8

How reproducible:
Deterministic

Compile this program and debug/strace it:
include <popt.h>
int main(int argc, char *argv[] )
{
  poptContext ctx;
  ctx = poptGetContext( argv[0], argc, argv, NULL, 0);
  poptReadDefaultConfig( ctx, 1 );
}


Steps to Reproduce:
1. compile this program:

cat foo.c
include <popt.h>
int main(int argc, char *argv[] )
{
  poptContext ctx;
  ctx = poptGetContext( argv[0], argc, argv, NULL, 0);
  poptReadDefaultConfig( ctx, 1 );
}


2. debug or strace it.

  
Actual results:

# strace -o bla ./foo
# grep /etc/popt bla 
open("/etc/popt", O_RDONLY|O_LARGEFILE) = 3
open("/etc/popt", O_RDONLY|O_LARGEFILE) = 3


Expected results:
/etc/popt being opened only once.

Additional info:
The cause is this:

>From poptconfig.c
...
    rc = poptReadConfigFile(con, POPT_SYSCONFDIR "/popt");
    if (rc) return rc;

    rc = poptReadConfigFile(con, "/etc/popt");
    if (rc) return rc;
...

If popt is being configured with --sysconfdir=/etc this causes the code fragment
above to read /etc/popt twice.
----- End forwarded message -----


Greetings,
  Robert
Received on Fri Sep 14 13:37:50 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.