Bug 5545 - libnetapi_init always fails with 'out of memory' error when there's no USER environment variable
libnetapi_init always fails with 'out of memory' error when there's no USER e...
Status: RESOLVED FIXED
Product: Samba 3.2
Classification: Unclassified
Component: Client tools
3.2.0
x86 Linux
: P3 normal
: ---
Assigned To: Guenther Deschner
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-16 15:59 UTC by Erik van Pienbroek
Modified: 2008-06-17 03:59 UTC (History)
0 users

See Also:


Attachments
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
Hi,

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) {
                TALLOC_FREE(frame);
                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!