summaryrefslogtreecommitdiff
path: root/source3/lib/netapi/netapi.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-08 15:43:11 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-01-08 15:43:11 +0100
commitbfab6ab14bd2ba69fde8bbe32f56f308010c8ea7 (patch)
tree4edbacab40c67bb5d9d6bebe66a22949349cbf9a /source3/lib/netapi/netapi.c
parent8dbeca6e9d06d573adebe8d9c5114b24d8782e43 (diff)
parent62c91987d902d4dfe27023ff2ec2fb73e602105b (diff)
downloadsamba-bfab6ab14bd2ba69fde8bbe32f56f308010c8ea7.tar.gz
samba-bfab6ab14bd2ba69fde8bbe32f56f308010c8ea7.tar.bz2
samba-bfab6ab14bd2ba69fde8bbe32f56f308010c8ea7.zip
Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
(This used to be commit ea36c3add588061cf338deabb2d8952f2213a8bd)
Diffstat (limited to 'source3/lib/netapi/netapi.c')
-rw-r--r--source3/lib/netapi/netapi.c104
1 files changed, 92 insertions, 12 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index 032798d0f9..d4cb3a9fe2 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -1,7 +1,7 @@
/*
* Unix SMB/CIFS implementation.
* NetApi Support
- * Copyright (C) Guenther Deschner 2007
+ * Copyright (C) Guenther Deschner 2007-2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,15 +26,22 @@ struct libnetapi_ctx *stat_ctx = NULL;
TALLOC_CTX *frame = NULL;
static bool libnetapi_initialized = false;
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
{
struct libnetapi_ctx *ctx = NULL;
+ char *krb5_cc_env = NULL;
if (stat_ctx && libnetapi_initialized) {
*context = stat_ctx;
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+#ifdef DEVELOPER
+ talloc_enable_leak_report();
+#endif
frame = talloc_stackframe();
ctx = talloc_zero(frame, struct libnetapi_ctx);
@@ -65,57 +72,90 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
BlockSignals(True, SIGPIPE);
+ krb5_cc_env = getenv(KRB5_ENV_CCNAME);
+ if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) {
+ ctx->krb5_cc_env = talloc_strdup(frame, "MEMORY:libnetapi");
+ setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
+ }
+
libnetapi_initialized = true;
*context = stat_ctx = ctx;
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx)
{
if (stat_ctx) {
*ctx = stat_ctx;
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
return libnetapi_init(ctx);
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
{
+
+ if (ctx->krb5_cc_env) {
+ char *env = getenv(KRB5_ENV_CCNAME);
+ if (env && (strequal(ctx->krb5_cc_env, env))) {
+ unsetenv(KRB5_ENV_CCNAME);
+ }
+ }
+
gfree_names();
gfree_loadparm();
gfree_case_tables();
gfree_charcnv();
gfree_interfaces();
+ gencache_shutdown();
+ secrets_shutdown();
+ regdb_close();
+
TALLOC_FREE(ctx);
TALLOC_FREE(frame);
gfree_debugsyms();
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
const char *debuglevel)
{
AllowDebugChange = true;
- ctx->debuglevel = debuglevel;
+ ctx->debuglevel = talloc_strdup(ctx, debuglevel);
if (!debug_parse_levels(debuglevel)) {
return W_ERROR_V(WERR_GENERAL_FAILURE);
}
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx,
- const char **debuglevel)
+ char **debuglevel)
{
*debuglevel = ctx->debuglevel;
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
const char *username)
{
@@ -124,7 +164,7 @@ NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
if (!ctx->username) {
return W_ERROR_V(WERR_NOMEM);
}
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
@@ -135,7 +175,7 @@ NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
if (!ctx->password) {
return W_ERROR_V(WERR_NOMEM);
}
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
@@ -146,9 +186,12 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
if (!ctx->workgroup) {
return W_ERROR_V(WERR_NOMEM);
}
- return W_ERROR_V(WERR_OK);
+ return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
NET_API_STATUS status)
{
@@ -158,3 +201,40 @@ const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
return get_friendly_werror_msg(W_ERROR(status));
}
+
+/****************************************************************
+****************************************************************/
+
+NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
+ const char *error_string)
+{
+ TALLOC_FREE(ctx->error_string);
+ ctx->error_string = talloc_strdup(ctx, error_string);
+ if (!ctx->error_string) {
+ return W_ERROR_V(WERR_NOMEM);
+ }
+ return NET_API_STATUS_SUCCESS;
+
+}
+
+/****************************************************************
+****************************************************************/
+
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx)
+{
+ return ctx->error_string;
+}
+
+/****************************************************************
+****************************************************************/
+
+NET_API_STATUS NetApiBufferFree(void *buffer)
+{
+ if (!buffer) {
+ return W_ERROR_V(WERR_INSUFFICIENT_BUFFER);
+ }
+
+ talloc_free(buffer);
+
+ return NET_API_STATUS_SUCCESS;
+}