diff options
author | Günther Deschner <gd@samba.org> | 2008-04-08 14:29:21 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-04-08 14:29:21 +0200 |
commit | 0f86cc18ff2e88a0f1fe244574ff5e3fcfce2f92 (patch) | |
tree | f810948ee995bf2445859568a21748795a5cd8ef /source3/lib/netapi | |
parent | e49200c1a2836bda4a86b034153365b8d9e99ce1 (diff) | |
download | samba-0f86cc18ff2e88a0f1fe244574ff5e3fcfce2f92.tar.gz samba-0f86cc18ff2e88a0f1fe244574ff5e3fcfce2f92.tar.bz2 samba-0f86cc18ff2e88a0f1fe244574ff5e3fcfce2f92.zip |
Prefill in username in libnetapi ctx.
Guenther
(This used to be commit 394bdb89ef350db0ab6aca093054e1048a8ffe1f)
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r-- | source3/lib/netapi/netapi.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 82a8a8d3cd..fbec2757f0 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -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); } |