Bug 5545 - libnetapi_init always fails with 'out of memory' error when there's no USER environment variable
Summary: libnetapi_init always fails with 'out of memory' error when there's no USER e...
Alias: None
Product: Samba 3.2
Classification: Unclassified
Component: Client tools (show other bugs)
Version: 3.2.0
Hardware: x86 Linux
: P3 normal
Target Milestone: ---
Assignee: Guenther Deschner
QA Contact: Samba QA Contact
Depends on:
Reported: 2008-06-16 15:59 UTC by Erik van Pienbroek
Modified: 2008-06-17 03:59 UTC (History)
0 users

See Also:

Proposed patch (652 bytes, patch)
2008-06-16 16:21 UTC, Erik van Pienbroek
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erik van Pienbroek 2008-06-16 15:59:22 UTC

I've tried to create a small program with the new netapi that can be used during the (kickstart-based) installation of Fedora Linux to join the computer to the Active Directory in our environment.

This small program works fine when run from an terminal, but fails to run when launched during the kickstart installation or during the startup of the system.

After investigation I've found this code in source/lib/netapi/netapi.c :

        ctx->username = talloc_strdup(frame, getenv("USER"));
        if (!ctx->username) {
                fprintf(stderr, "out of memory\n");
                return W_ERROR_V(WERR_NOMEM);

So when there is no user logged in, the libnetapi_init always fails with an cryptic 'out of memory' error.

Attached patch fixes this behaviour and also makes the 'out of memory' error somewhat more clear
Comment 1 Erik van Pienbroek 2008-06-16 16:21:26 UTC
Created attachment 3347 [details]
Proposed patch
Comment 2 Guenther Deschner 2008-06-17 03:59:37 UTC
Fixed in git, thanks for the report!