[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-unstable-1156-gb624db9
Günther Deschner
gd at samba.org
Mon Jan 7 19:16:30 GMT 2008
The branch, v3-2-test has been updated
via b624db92d61809a44881abbdd09dfa3a74ff7a88 (commit)
via 0f0f0e13022da584b77e850fec2cef6169e1ac28 (commit)
via f8806bad8134d544229c426f58bee143ba752cf8 (commit)
via df2b078fa1658bdbff1280f7fe0b062d9eabd60c (commit)
via 863fb30038e384585502f0154a742481594b99d0 (commit)
from f550ed02ff9e0546c63064ab9dac760eac7e1e16 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit b624db92d61809a44881abbdd09dfa3a74ff7a88
Author: Günther Deschner <gd at samba.org>
Date: Mon Jan 7 20:10:47 2008 +0100
In libnetapi example, use libnetapi_get_error_string().
Guenther
commit 0f0f0e13022da584b77e850fec2cef6169e1ac28
Author: Günther Deschner <gd at samba.org>
Date: Mon Jan 7 20:08:45 2008 +0100
In the local path of NetJoinDomain, try to get error string from libnetjoin.
Guenther
commit f8806bad8134d544229c426f58bee143ba752cf8
Author: Günther Deschner <gd at samba.org>
Date: Mon Jan 7 20:06:41 2008 +0100
Add libnetapi_set_error_string and libnetapi_get_error_string.
Guenther
commit df2b078fa1658bdbff1280f7fe0b062d9eabd60c
Author: Günther Deschner <gd at samba.org>
Date: Mon Jan 7 20:03:32 2008 +0100
Add krb5 cc env to libnetapi_ctx.
Guenther
commit 863fb30038e384585502f0154a742481594b99d0
Author: Günther Deschner <gd at samba.org>
Date: Mon Jan 7 20:01:28 2008 +0100
Let libnetapi use it's own krb5 cred cache in memory if necessary.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source/lib/netapi/examples/netdomjoin/netdomjoin.c | 7 ++-
source/lib/netapi/joindomain.c | 3 +
source/lib/netapi/netapi.c | 60 +++++++++++++++++++-
source/lib/netapi/netapi.h | 14 ++++-
4 files changed, 79 insertions(+), 5 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/lib/netapi/examples/netdomjoin/netdomjoin.c b/source/lib/netapi/examples/netdomjoin/netdomjoin.c
index 634d265..a0ac0b1 100644
--- a/source/lib/netapi/examples/netdomjoin/netdomjoin.c
+++ b/source/lib/netapi/examples/netdomjoin/netdomjoin.c
@@ -104,7 +104,12 @@ int main(int argc, char **argv)
password,
join_flags);
if (status != 0) {
- printf("Join failed with: %s\n", libnetapi_errstr(ctx, status));
+ const char *errstr = NULL;
+ errstr = libnetapi_get_error_string(ctx);
+ if (!errstr) {
+ errstr = libnetapi_errstr(ctx, status);
+ }
+ printf("Join failed with: %s\n", errstr);
} else {
printf("Successfully joined\n");
}
diff --git a/source/lib/netapi/joindomain.c b/source/lib/netapi/joindomain.c
index ceb7ca1..aa8ec6e 100644
--- a/source/lib/netapi/joindomain.c
+++ b/source/lib/netapi/joindomain.c
@@ -78,6 +78,9 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx,
r->in.modify_config = true;
werr = libnet_Join(mem_ctx, r);
+ if (!W_ERROR_IS_OK(werr) && r->out.error_string) {
+ libnetapi_set_error_string(mem_ctx, r->out.error_string);
+ }
TALLOC_FREE(r);
return werr;
diff --git a/source/lib/netapi/netapi.c b/source/lib/netapi/netapi.c
index 33ca67e..d5527dc 100644
--- a/source/lib/netapi/netapi.c
+++ b/source/lib/netapi/netapi.c
@@ -26,9 +26,13 @@ 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;
@@ -65,6 +69,12 @@ 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;
@@ -72,6 +82,9 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx)
{
if (stat_ctx) {
@@ -82,6 +95,9 @@ NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx)
return libnetapi_init(ctx);
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
{
gfree_names();
@@ -94,6 +110,11 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
secrets_shutdown();
regdb_close();
+ if (ctx->krb5_cc_env &&
+ (strequal(ctx->krb5_cc_env, getenv(KRB5_ENV_CCNAME)))) {
+ unsetenv(KRB5_ENV_CCNAME);
+ }
+
TALLOC_FREE(ctx);
TALLOC_FREE(frame);
@@ -102,24 +123,33 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
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 NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx,
- const char **debuglevel)
+ char **debuglevel)
{
*debuglevel = ctx->debuglevel;
return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
const char *username)
{
@@ -153,6 +183,9 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
NET_API_STATUS status)
{
@@ -162,3 +195,26 @@ 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;
+}
diff --git a/source/lib/netapi/netapi.h b/source/lib/netapi/netapi.h
index 2c6e126..46dd8e1 100644
--- a/source/lib/netapi/netapi.h
+++ b/source/lib/netapi/netapi.h
@@ -27,21 +27,31 @@
****************************************************************/
struct libnetapi_ctx {
- const char *debuglevel;
+ char *debuglevel;
+ char *error_string;
char *username;
char *workgroup;
char *password;
+ char *krb5_cc_env;
};
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, const char *debuglevel);
-NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, const char **debuglevel);
+NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, char **debuglevel);
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username);
NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, const char *password);
NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, const char *workgroup);
const char *libnetapi_errstr(struct libnetapi_ctx *ctx, NET_API_STATUS status);
+NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *error_string);
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx);
+
+/****************************************************************
+****************************************************************/
/* wkssvc */
NET_API_STATUS NetJoinDomain(const char *server,
--
Samba Shared Repository
More information about the samba-cvs
mailing list