]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Prefill in username in libnetapi ctx.
authorGünther Deschner <gd@samba.org>
Tue, 8 Apr 2008 12:29:21 +0000 (14:29 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 8 Apr 2008 12:29:21 +0000 (14:29 +0200)
Guenther

source/lib/netapi/netapi.c

index 82a8a8d3cd814278340abe7441258e58d5cae59c..fbec2757f0f16f28c9af48a977a10c40005a52ce 100644 (file)
@@ -81,6 +81,13 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
                setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
        }
 
+       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);
+       }
+
        libnetapi_initialized = true;
 
        *context = stat_ctx = ctx;
@@ -162,7 +169,8 @@ NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
                                      const char *username)
 {
        TALLOC_FREE(ctx->username);
-       ctx->username = talloc_strdup(ctx, username);
+       ctx->username = talloc_strdup(ctx, username ? username : "");
+
        if (!ctx->username) {
                return W_ERROR_V(WERR_NOMEM);
        }