Bug 7364 - monit builds a static application, even though BR2_PREFER_STATIC_LIB is not set, and with glibc.
Summary: monit builds a static application, even though BR2_PREFER_STATIC_LIB is not s...
Status: RESOLVED FIXED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2014.08
Hardware: PC Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-03 17:09 UTC by syntheticpp
Modified: 2014-09-06 21:48 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:


Attachments
defconfig (616 bytes, application/octet-stream)
2014-09-05 08:43 UTC, syntheticpp
Details
generated .config (40.23 KB, application/octet-stream)
2014-09-05 08:44 UTC, syntheticpp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description syntheticpp 2014-09-03 17:09:43 UTC
monit exits in src/env.c:

  struct passwd *pw;

  /* Get password struct */
  if ( ! (pw= getpwuid(geteuid())) ) {
    LogError("%s: You don't exist. Go away.\n", prog);
    exit(1);
  }

Only happens with glibc and eglibc 2.19 (tested with GCC 4.9.1), 2.18 is fine.

GCC warns while linking:
y.tab.c:(.text+0x379c): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Somehow libnss related?
Comment 1 syntheticpp 2014-09-03 18:02:48 UTC
Logging in via ssh is delayed, looks like it runs into a timeout.
(strace shows that a select() on the client IP is paused)
Comment 2 Yann E. MORIN 2014-09-03 18:57:16 UTC
Normally, static linking with glibc is not possible, just because of
this issue: all that has to deal with names (usernames, groups,
hostnames...) need dynamic linking, becasue glibc uses libnss, which
dlopen()s the backend libraries, such as libnss_files.so.

How did you manage to have a statically-linked monit when using a
glibc toolchain? Care to share your .config, please?

Regards,
Yann E. MORIN.
Comment 3 syntheticpp 2014-09-04 12:22:51 UTC
> 
> How did you manage to have a statically-linked monit when using a
> glibc toolchain? Care to share your .config, please?
> 

It's the configuration of 2014.08 no changes by me.
Comment 4 syntheticpp 2014-09-04 12:27:59 UTC
> 
> GCC warns while linking:
> y.tab.c:(.text+0x379c): warning: Using 'getpwuid' in statically linked
> applications requires at runtime the shared libraries from the glibc version
> used for linking

This warning also shows up in the build which works (eglibc 2.18)
Comment 5 Yann E. MORIN 2014-09-04 15:52:07 UTC
> It's the configuration of 2014.08 no changes by me.

Sorry, this does not make sense:
  - there is no default configuration in Buildroot;
  - the default C library is uClibc, not glibc/eglibc.

So, yes, you did some configuration.
Please provide your .config file.

Regards,
Yann E. MORIN.
Comment 6 syntheticpp 2014-09-05 08:43:42 UTC
Created attachment 5588 [details]
defconfig
Comment 7 syntheticpp 2014-09-05 08:44:35 UTC
Created attachment 5594 [details]
generated .config
Comment 8 Yann E. MORIN 2014-09-05 10:26:22 UTC
Indeed, the build warns about the use os the NSS functions in statically linked applications.

However, this is only a warning, and not a build failure.

monit should not build a static application to start with. Changing the subject to reflect the real issue.

Regards,
Yann E. MORIN.
Comment 9 Yann E. MORIN 2014-09-05 10:30:26 UTC
When the C library is glibc/eglibc, we copy those files to the target:
    LIB_EXTERNAL_LIBS+=libnss_files.so.* libnss_dns.so.*

Can you confirm those files are present in your target?

Regarding the delay to login: what is your authentication method? Maybe there are a few other libnss files tht should be copied over...

Regards,
Yann E. MORIN.
Comment 10 Yann E. MORIN 2014-09-05 11:18:45 UTC
I have a patch I'm currently testing...

Regards,
Yann E. MORIN.
Comment 11 syntheticpp 2014-09-05 12:38:10 UTC
(In reply to comment #9)
> When the C library is glibc/eglibc, we copy those files to the target:
>     LIB_EXTERNAL_LIBS+=libnss_files.so.* libnss_dns.so.*
> 
> Can you confirm those files are present in your target?

Yes, they are.

> 
> Regarding the delay to login: what is your authentication method? Maybe there
> are a few other libnss files tht should be copied over...

In meantime I saw it also with the other build, so not related to this bug here.

> 
> Regards,
> Yann E. MORIN.
Comment 12 Yann E. MORIN 2014-09-06 21:48:40 UTC
Hello!

We believe this isuue has now been fixed with this changeset:
    http://git.buildroot.org/buildroot/commit/?id=03f388619a4dfa2835774702a54504b56e2e00e0

I'm closing the issue now. If you believe this does not fix your
problem, be sure to re-open this issue for further investigations.

Thank you for the report! :-)

Regards,
Yann E. MORIN.