From 7bfceba4bc49f5f5c8d2836dfd76e1ec15459631 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 16 Jan 2008 17:05:38 +0100 Subject: Use lp_config_backend_is_registry() instead of lp_include_registry_globals(). Michael (This used to be commit c5a7d421c512a6221b0300549d7b5de0368d252e) --- source3/lib/netapi/serverinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index 67680ba55a..6cd074615b 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -167,7 +167,7 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, return WERR_INVALID_PARAM; } - if (!lp_include_registry_globals()) { + if (!lp_config_backend_is_registry()) { return WERR_NOT_SUPPORTED; } -- cgit From d1abd4d866b59fa67605fc469d6406a981455fbe Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 17 Jan 2008 10:39:15 +0100 Subject: Use new pidl-generated netlogon client calls in NetApi GetDcName(). Guenther (This used to be commit 733e07a06ce3c903ff5837df6a5119f6d6e3eccb) --- source3/lib/netapi/examples/getdc/getdc.c | 4 +-- source3/lib/netapi/getdc.c | 42 +++++-------------------------- 2 files changed, 8 insertions(+), 38 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/examples/getdc/getdc.c b/source3/lib/netapi/examples/getdc/getdc.c index cdd4d0b3b4..272ba1088e 100644 --- a/source3/lib/netapi/examples/getdc/getdc.c +++ b/source3/lib/netapi/examples/getdc/getdc.c @@ -29,7 +29,7 @@ int main(int argc, char **argv) { NET_API_STATUS status; struct libnetapi_ctx *ctx = NULL; - uint8_t *buffer; + uint8_t *buffer = NULL; if (argc < 3) { printf("usage: getdc \n"); @@ -50,7 +50,7 @@ int main(int argc, char **argv) } else { printf("%s\n", (char *)buffer); } - + NetApiBufferFree(buffer); libnetapi_free(ctx); return status; diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index 85a0ae52ef..484af04a55 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -22,22 +22,6 @@ #include "lib/netapi/netapi.h" #include "libnet/libnet.h" -#if 0 -#include "librpc/gen_ndr/cli_netlogon.h" -#endif - -NTSTATUS rpccli_netr_GetDcName(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *logon_server, - const char *domainname, - const char **dcname); -NTSTATUS rpccli_netr_GetAnyDCName(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *logon_server, - const char *domainname, - const char **dcname, - WERROR *werror); - static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -76,17 +60,11 @@ static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx, goto done; }; -#if 0 - werr = rpccli_netr_GetDcName(pipe_cli, ctx, - server_name, - domain_name, - (const char **)&buffer); -#else - werr = rpccli_netlogon_getdcname(pipe_cli, ctx, - server_name, - domain_name, - (char **)buffer); -#endif + status = rpccli_netr_GetDcName(pipe_cli, ctx, + server_name, + domain_name, + (const char **)buffer); + werr = ntstatus_to_werror(status); done: if (cli) { cli_shutdown(cli); @@ -175,22 +153,14 @@ static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx, goto done; }; -#if 0 status = rpccli_netr_GetAnyDCName(pipe_cli, ctx, server_name, domain_name, - (const char **)&buffer, + (const char **)buffer, &werr); if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); goto done; } -#else - werr = rpccli_netlogon_getanydcname(pipe_cli, ctx, - server_name, - domain_name, - (char **)buffer); -#endif done: if (cli) { cli_shutdown(cli); -- cgit From c2ff6c94f2f9ddc2c4b03f7907f7d6e0de951c24 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 01:56:01 +0100 Subject: Improve libnetapi_set_error_string(). Guenther (This used to be commit 96f645553ae5c75aabfe588e1a67f3d4bfacb5cb) --- source3/lib/netapi/netapi.c | 11 ++++++++--- source3/lib/netapi/netapi.h | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index ce00054e6e..5c3f7ec465 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -205,15 +205,20 @@ const char *libnetapi_errstr(NET_API_STATUS status) ****************************************************************/ NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, - const char *error_string) + const char *format, ...) { + va_list args; + TALLOC_FREE(ctx->error_string); - ctx->error_string = talloc_strdup(ctx, error_string); + + va_start(args, format); + ctx->error_string = talloc_vasprintf(ctx, format, args); + va_end(args); + if (!ctx->error_string) { return W_ERROR_V(WERR_NOMEM); } return NET_API_STATUS_SUCCESS; - } /**************************************************************** diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 274a167d53..67bb8a8fca 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -57,46 +57,73 @@ NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *use 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(NET_API_STATUS status); -NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *error_string); +NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *format, ...); const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx, NET_API_STATUS status); /**************************************************************** + NetApiBufferFree ****************************************************************/ NET_API_STATUS NetApiBufferFree(void *buffer); /**************************************************************** + NetJoinDomain ****************************************************************/ -/* wkssvc */ NET_API_STATUS NetJoinDomain(const char *server, const char *domain, const char *account_ou, const char *account, const char *password, uint32_t join_options); + +/**************************************************************** + NetUnjoinDomain +****************************************************************/ + NET_API_STATUS NetUnjoinDomain(const char *server_name, const char *account, const char *password, uint32_t unjoin_flags); + +/**************************************************************** + NetGetJoinInformation +****************************************************************/ + NET_API_STATUS NetGetJoinInformation(const char *server_name, const char **name_buffer, uint16_t *name_type); -/* srvsvc */ +/**************************************************************** + NetServerGetInfo +****************************************************************/ + NET_API_STATUS NetServerGetInfo(const char *server_name, uint32_t level, uint8_t **buffer); + +/**************************************************************** + NetServerSetInfo +****************************************************************/ + NET_API_STATUS NetServerSetInfo(const char *server_name, uint32_t level, uint8_t *buffer, uint32_t *parm_error); -/* netlogon */ +/**************************************************************** + NetGetDCName +****************************************************************/ + NET_API_STATUS NetGetDCName(const char *server_name, const char *domain_name, uint8_t **buffer); + +/**************************************************************** + NetGetAnyDCName +****************************************************************/ + NET_API_STATUS NetGetAnyDCName(const char *server_name, const char *domain_name, uint8_t **buffer); -- cgit From bb97b272a975e4af7738c58e7af4b8e3047d4b77 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 02:30:09 +0100 Subject: Fix local hostname detection in netdomjoin-gui. Guenther (This used to be commit 30458116b389889cad845eb96b54c3edc833e722) --- .../examples/netdomjoin-gui/netdomjoin-gui.c | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c index 9dc2a18138..6e958b4c73 100644 --- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c +++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -1263,28 +1264,44 @@ static int initialize_join_state(struct join_state *state, { char my_hostname[HOST_NAME_MAX]; const char *p = NULL; + struct hostent *hp = NULL; + if (gethostname(my_hostname, sizeof(my_hostname)) == -1) { return -1; } - state->my_fqdn = strdup(my_hostname); + p = strchr(my_hostname, '.'); + if (p) { + my_hostname[strlen(my_hostname)-strlen(p)] = '\0'; + } + state->my_hostname = strdup(my_hostname); + if (!state->my_hostname) { + return -1; + } + debug("state->my_hostname: %s\n", state->my_hostname); + + hp = gethostbyname(my_hostname); + if (!hp || !hp->h_name || !*hp->h_name) { + return -1; + } + + state->my_fqdn = strdup(hp->h_name); if (!state->my_fqdn) { return -1; } + debug("state->my_fqdn: %s\n", state->my_fqdn); - p = strchr(my_hostname, '.'); + p = strchr(state->my_fqdn, '.'); if (p) { - my_hostname[strlen(my_hostname) - strlen(p)] = '\0'; - state->my_hostname = strdup(my_hostname); - if (!state->my_hostname) { - return -1; - } p++; state->my_dnsdomain = strdup(p); - if (!state->my_dnsdomain) { - return -1; - } + } else { + state->my_dnsdomain = strdup(""); + } + if (!state->my_dnsdomain) { + return -1; } + debug("state->my_dnsdomain: %s\n", state->my_dnsdomain); } { -- cgit From cfb7e254662dd957da7e193010f87544b96c2f17 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 02:30:53 +0100 Subject: Add some more debugging into netdomjoin-gui. Guenther (This used to be commit d4c5b323229c6f43c824e3559084c98e370730a5) --- source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c index 6e958b4c73..73b14d4d87 100644 --- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c +++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c @@ -440,7 +440,7 @@ static void callback_do_join(GtkWidget *widget, state->password, unjoin_flags); if (status != 0) { - err_str = libnetapi_errstr(status); + err_str = libnetapi_get_error_string(state->ctx, status); g_print("callback_do_join: failed to unjoin (%s)\n", err_str); @@ -464,7 +464,7 @@ static void callback_do_join(GtkWidget *widget, state->password, join_flags); if (status != 0) { - err_str = libnetapi_errstr(status); + err_str = libnetapi_get_error_string(state->ctx, status); g_print("callback_do_join: failed to join (%s)\n", err_str); dialog = gtk_message_dialog_new(GTK_WINDOW(state->window_parent), @@ -1308,9 +1308,12 @@ static int initialize_join_state(struct join_state *state, const char *buffer = NULL; uint16_t type = 0; status = NetGetJoinInformation(NULL, &buffer, &type); - if (status) { + if (status != 0) { + printf("NetGetJoinInformation failed with: %s\n", + libnetapi_get_error_string(state->ctx, status)); return status; } + debug("NetGetJoinInformation gave: %s and %d\n", buffer, type); state->name_buffer_initial = strdup(buffer); if (!state->name_buffer_initial) { return -1; @@ -1324,7 +1327,9 @@ static int initialize_join_state(struct join_state *state, uint8_t *buffer = NULL; status = NetServerGetInfo(NULL, 1005, &buffer); - if (status) { + if (status != 0) { + printf("NetServerGetInfo failed with: %s\n", + libnetapi_get_error_string(state->ctx, status)); return status; } -- cgit From b1424846c60848d685853fcf632ab766543e05ee Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 02:38:35 +0100 Subject: Cosmetics and error string reporting for libnetapi. Guenther (This used to be commit 4ca33928512bd71268bafd41d2b608e814a7295f) --- source3/lib/netapi/getdc.c | 30 ++++++++++++++++++++-- source3/lib/netapi/joindomain.c | 57 ++++++++++++++++++++++++++++++++++++----- source3/lib/netapi/serverinfo.c | 43 +++++++++++++++++++++++++------ 3 files changed, 114 insertions(+), 16 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index 484af04a55..1084ddc3c8 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -22,6 +22,9 @@ #include "lib/netapi/netapi.h" #include "libnet/libnet.h" +/******************************************************************** +********************************************************************/ + static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -30,6 +33,9 @@ static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx, return WERR_NOT_SUPPORTED; } +/******************************************************************** +********************************************************************/ + static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -73,6 +79,9 @@ static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx, return werr; } +/******************************************************************** +********************************************************************/ + static WERROR libnetapi_NetGetDCName(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -91,6 +100,10 @@ static WERROR libnetapi_NetGetDCName(struct libnetapi_ctx *ctx, buffer); } +/**************************************************************** + NetGetDCName +****************************************************************/ + NET_API_STATUS NetGetDCName(const char *server_name, const char *domain_name, uint8_t **buffer) @@ -112,9 +125,12 @@ NET_API_STATUS NetGetDCName(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } +/******************************************************************** +********************************************************************/ + static WERROR NetGetAnyDCNameLocal(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -123,6 +139,9 @@ static WERROR NetGetAnyDCNameLocal(struct libnetapi_ctx *ctx, return WERR_NOT_SUPPORTED; } +/******************************************************************** +********************************************************************/ + static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -170,6 +189,9 @@ static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx, } +/******************************************************************** +********************************************************************/ + static WERROR libnetapi_NetGetAnyDCName(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -188,6 +210,10 @@ static WERROR libnetapi_NetGetAnyDCName(struct libnetapi_ctx *ctx, buffer); } +/**************************************************************** + NetGetAnyDCName +****************************************************************/ + NET_API_STATUS NetGetAnyDCName(const char *server_name, const char *domain_name, uint8_t **buffer) @@ -209,5 +235,5 @@ NET_API_STATUS NetGetAnyDCName(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index b268e41a2a..43662b3ffa 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -22,6 +22,9 @@ #include "lib/netapi/netapi.h" #include "libnet/libnet.h" +/**************************************************************** +****************************************************************/ + static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, const char *server_name, const char *domain_name, @@ -52,6 +55,8 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, status = dsgetdcname(mem_ctx, NULL, domain_name, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { + libnetapi_set_error_string(mem_ctx, + "%s", get_friendly_nt_error_msg(status)); return ntstatus_to_werror(status); } r->in.dc_name = talloc_strdup(mem_ctx, @@ -79,13 +84,16 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, 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); + libnetapi_set_error_string(mem_ctx, "%s", r->out.error_string); } TALLOC_FREE(r); return werr; } +/**************************************************************** +****************************************************************/ + static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -149,6 +157,9 @@ static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx, const char *server_name, const char *domain_name, @@ -181,6 +192,10 @@ static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx, join_flags); } +/**************************************************************** + NetJoinDomain +****************************************************************/ + NET_API_STATUS NetJoinDomain(const char *server_name, const char *domain_name, const char *account_ou, @@ -208,9 +223,12 @@ NET_API_STATUS NetJoinDomain(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, const char *server_name, const char *account, @@ -232,7 +250,6 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, r->in.dc_name = talloc_strdup(mem_ctx, server_name); W_ERROR_HAVE_NO_MEMORY(r->in.dc_name); } else { - NTSTATUS status; const char *domain = NULL; struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; @@ -247,6 +264,8 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, status = dsgetdcname(mem_ctx, NULL, domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { + libnetapi_set_error_string(mem_ctx, + "%s", get_friendly_nt_error_msg(status)); return ntstatus_to_werror(status); } r->in.dc_name = talloc_strdup(mem_ctx, @@ -266,13 +285,22 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, r->in.unjoin_flags = unjoin_flags; r->in.modify_config = true; + r->in.debug = true; r->in.domain_sid = &domain_sid; - return libnet_Unjoin(mem_ctx, r); + werr = libnet_Unjoin(mem_ctx, r); + if (!W_ERROR_IS_OK(werr) && r->out.error_string) { + libnetapi_set_error_string(mem_ctx, "%s", r->out.error_string); + } + TALLOC_FREE(r); + return werr; } +/**************************************************************** +****************************************************************/ + static WERROR NetUnjoinDomainRemote(struct libnetapi_ctx *ctx, const char *server_name, const char *account, @@ -335,6 +363,9 @@ static WERROR NetUnjoinDomainRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR libnetapi_NetUnjoinDomain(struct libnetapi_ctx *ctx, const char *server_name, const char *account, @@ -357,6 +388,10 @@ static WERROR libnetapi_NetUnjoinDomain(struct libnetapi_ctx *ctx, unjoin_flags); } +/**************************************************************** + NetUnjoinDomain +****************************************************************/ + NET_API_STATUS NetUnjoinDomain(const char *server_name, const char *account, const char *password, @@ -380,9 +415,12 @@ NET_API_STATUS NetUnjoinDomain(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + static WERROR NetGetJoinInformationRemote(struct libnetapi_ctx *ctx, const char *server_name, const char **name_buffer, @@ -431,6 +469,9 @@ static WERROR NetGetJoinInformationRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR NetGetJoinInformationLocal(struct libnetapi_ctx *ctx, const char *server_name, const char **name_buffer, @@ -478,6 +519,10 @@ static WERROR libnetapi_NetGetJoinInformation(struct libnetapi_ctx *ctx, name_type); } +/**************************************************************** + NetGetJoinInformation +****************************************************************/ + NET_API_STATUS NetGetJoinInformation(const char *server_name, const char **name_buffer, uint16_t *name_type) @@ -499,5 +544,5 @@ NET_API_STATUS NetGetJoinInformation(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index 6cd074615b..7fa166e411 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -22,6 +22,9 @@ #include "lib/netapi/netapi.h" #include "libnet/libnet.h" +/**************************************************************** +****************************************************************/ + static WERROR NetServerGetInfoLocal_1005(struct libnetapi_ctx *ctx, uint8_t **buffer) { @@ -36,6 +39,9 @@ static WERROR NetServerGetInfoLocal_1005(struct libnetapi_ctx *ctx, return WERR_OK; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerGetInfoLocal(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -51,6 +57,9 @@ static WERROR NetServerGetInfoLocal(struct libnetapi_ctx *ctx, return WERR_UNKNOWN_LEVEL; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerGetInfoRemote(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -102,6 +111,9 @@ static WERROR NetServerGetInfoRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR libnetapi_NetServerGetInfo(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -121,6 +133,10 @@ static WERROR libnetapi_NetServerGetInfo(struct libnetapi_ctx *ctx, } +/**************************************************************** + NetServerGetInfo +****************************************************************/ + NET_API_STATUS NetServerGetInfo(const char *server_name, uint32_t level, uint8_t **buffer) @@ -142,17 +158,18 @@ NET_API_STATUS NetServerGetInfo(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, uint8_t *buffer, uint32_t *parm_error) { WERROR werr; struct libnet_conf_ctx *conf_ctx; - TALLOC_CTX *mem_ctx; - struct srvsvc_NetSrvInfo1005 *info1005; if (!buffer) { @@ -171,8 +188,7 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, return WERR_NOT_SUPPORTED; } - mem_ctx = talloc_stackframe(); - werr = libnet_conf_open(mem_ctx, &conf_ctx); + werr = libnet_conf_open(ctx, &conf_ctx); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -181,12 +197,14 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, "server string", info1005->comment); -done: + done: libnet_conf_close(conf_ctx); - TALLOC_FREE(mem_ctx); return werr; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerSetInfoLocal(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -203,6 +221,9 @@ static WERROR NetServerSetInfoLocal(struct libnetapi_ctx *ctx, return WERR_UNKNOWN_LEVEL; } +/**************************************************************** +****************************************************************/ + static WERROR NetServerSetInfoRemote(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -263,6 +284,9 @@ static WERROR NetServerSetInfoRemote(struct libnetapi_ctx *ctx, return werr; } +/**************************************************************** +****************************************************************/ + static WERROR libnetapi_NetServerSetInfo(struct libnetapi_ctx *ctx, const char *server_name, uint32_t level, @@ -284,6 +308,9 @@ static WERROR libnetapi_NetServerSetInfo(struct libnetapi_ctx *ctx, parm_error); } +/**************************************************************** + NetServerSetInfo +****************************************************************/ NET_API_STATUS NetServerSetInfo(const char *server_name, uint32_t level, @@ -308,5 +335,5 @@ NET_API_STATUS NetServerSetInfo(const char *server_name, return W_ERROR_V(werr); } - return 0; + return NET_API_STATUS_SUCCESS; } -- cgit From b18fd380bd142933b7c1a341629aac61c8799d22 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 02:50:33 +0100 Subject: Add NetGetJoinableOUs() to libnetapi (incl. example). Guenther (This used to be commit 8858e403e1940c362d307b4d4125f977abb0b96a) --- source3/lib/netapi/examples/Makefile.in | 16 +- .../examples/getjoinableous/getjoinableous.c | 104 +++++++++++ source3/lib/netapi/joindomain.c | 192 +++++++++++++++++++++ 3 files changed, 309 insertions(+), 3 deletions(-) create mode 100644 source3/lib/netapi/examples/getjoinableous/getjoinableous.c (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/examples/Makefile.in b/source3/lib/netapi/examples/Makefile.in index c2f453dedc..86e1b1bc2f 100644 --- a/source3/lib/netapi/examples/Makefile.in +++ b/source3/lib/netapi/examples/Makefile.in @@ -5,7 +5,7 @@ KRB5LIBS=@KRB5_LIBS@ LDAP_LIBS=@LDAP_LIBS@ LIBS=@LIBS@ -lnetapi DEVELOPER_CFLAGS=@DEVELOPER_CFLAGS@ -FLAGS=@CFLAGS@ $(GTK_FLAGS) +FLAGS=-I../ -L../../../bin @CFLAGS@ $(GTK_FLAGS) CC=@CC@ LDFLAGS=@PIE_LDFLAGS@ @LDFLAGS@ DYNEXP=@DYNEXP@ @@ -36,8 +36,12 @@ MAKEDIR = || exec false; \ GETDC_OBJ = getdc/getdc.o NETDOMJOIN_OBJ = netdomjoin/netdomjoin.o NETDOMJOIN_GUI_OBJ = netdomjoin-gui/netdomjoin-gui.o +GETJOINABLEOUS_OBJ = getjoinableous/getjoinableous.o -PROGS = bin/getdc@EXEEXT@ bin/netdomjoin@EXEEXT@ bin/netdomjoin-gui@EXEEXT@ +PROGS = bin/getdc@EXEEXT@ \ + bin/netdomjoin@EXEEXT@ \ + bin/netdomjoin-gui@EXEEXT@ \ + bin/getjoinableous@EXEEXT@ all: $(PROGS) @@ -45,6 +49,10 @@ bin/getdc@EXEEXT@: $(GETDC_OBJ) @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(GETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) +bin/getjoinableous@EXEEXT@: $(GETJOINABLEOUS_OBJ) + @echo Linking $@ + @$(CC) $(FLAGS) -o $@ $(GETJOINABLEOUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) + bin/netdomjoin@EXEEXT@: $(NETDOMJOIN_OBJ) @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NETDOMJOIN_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @@ -54,4 +62,6 @@ bin/netdomjoin-gui@EXEEXT@: $(NETDOMJOIN_GUI_OBJ) @$(CC) $(FLAGS) $(GTK_FLAGS) -o $@ $(NETDOMJOIN_GUI_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(GTK_LIBS) clean: - @rm -f $(PROGS) + -rm -f $(PROGS) + -rm -f core */*~ *~ \ + */*.o */*/*.o */*/*/*.o \ diff --git a/source3/lib/netapi/examples/getjoinableous/getjoinableous.c b/source3/lib/netapi/examples/getjoinableous/getjoinableous.c new file mode 100644 index 0000000000..5a3366c9dc --- /dev/null +++ b/source3/lib/netapi/examples/getjoinableous/getjoinableous.c @@ -0,0 +1,104 @@ +/* + * Unix SMB/CIFS implementation. + * Join Support (cmdline + netapi) + * Copyright (C) Guenther Deschner 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include +#include + +#include + +char *get_string_param(const char *param) +{ + char *p; + + p = strchr(param, '='); + if (!p) { + return NULL; + } + + return (p+1); +} + +int main(int argc, char **argv) +{ + NET_API_STATUS status; + const char *server_name = NULL; + const char *domain_name = NULL; + const char *account = NULL; + const char *password = NULL; + const char **ous = NULL; + uint32_t num_ous = 0; + struct libnetapi_ctx *ctx = NULL; + int i; + + status = libnetapi_init(&ctx); + if (status != 0) { + return status; + } + + if (argc < 2) { + printf("usage: getjoinableous\n"); + printf("\t [domain=DOMAIN] \n"); + return 0; + } + + if (argc > 2) { + server_name = argv[1]; + } + + for (i=0; idomain_controller_name); + if (!ads) { + return WERR_GENERAL_FAILURE; + } + + SAFE_FREE(ads->auth.user_name); + if (account) { + ads->auth.user_name = SMB_STRDUP(account); + } else if (ctx->username) { + ads->auth.user_name = SMB_STRDUP(ctx->username); + } + + SAFE_FREE(ads->auth.password); + if (password) { + ads->auth.password = SMB_STRDUP(password); + } else if (ctx->password) { + ads->auth.password = SMB_STRDUP(ctx->password); + } + + ads_status = ads_connect(ads); + if (!ADS_ERR_OK(ads_status)) { + ads_destroy(&ads); + return WERR_DEFAULT_JOIN_REQUIRED; + } + + ads_status = ads_get_joinable_ous(ads, ctx, + (char ***)ous, + (size_t *)ou_count); + if (!ADS_ERR_OK(ads_status)) { + ads_destroy(&ads); + return WERR_DEFAULT_JOIN_REQUIRED; + } + + ads_destroy(&ads); + return WERR_OK; +} + +/**************************************************************** +****************************************************************/ + +static WERROR NetGetJoinableOUsRemote(struct libnetapi_ctx *ctx, + const char *server_name, + const char *domain, + const char *account, + const char *password, + uint32_t *ou_count, + const char ***ous) +{ + struct cli_state *cli = NULL; + struct rpc_pipe_client *pipe_cli = NULL; + struct wkssvc_PasswordBuffer *encrypted_password = NULL; + NTSTATUS status; + WERROR werr; + + status = cli_full_connection(&cli, NULL, server_name, + NULL, 0, + "IPC$", "IPC", + ctx->username, + ctx->workgroup, + ctx->password, + 0, Undefined, NULL); + + if (!NT_STATUS_IS_OK(status)) { + werr = ntstatus_to_werror(status); + goto done; + } + + pipe_cli = cli_rpc_pipe_open_noauth(cli, PI_WKSSVC, + &status); + if (!pipe_cli) { + werr = ntstatus_to_werror(status); + goto done; + } + + if (password) { + encode_wkssvc_join_password_buffer(ctx, + password, + &cli->user_session_key, + &encrypted_password); + } + + status = rpccli_wkssvc_NetrGetJoinableOus2(pipe_cli, ctx, + server_name, + domain, + account, + encrypted_password, + ou_count, + ous, + &werr); + if (!NT_STATUS_IS_OK(status)) { + werr = ntstatus_to_werror(status); + goto done; + } + + done: + if (cli) { + cli_shutdown(cli); + } + + return werr; +} + +/**************************************************************** +****************************************************************/ + +static WERROR libnetapi_NetGetJoinableOUs(struct libnetapi_ctx *ctx, + const char *server_name, + const char *domain, + const char *account, + const char *password, + uint32_t *ou_count, + const char ***ous) +{ + if (!server_name || is_myname_or_ipaddr(server_name)) { + return NetGetJoinableOUsLocal(ctx, + server_name, + domain, + account, + password, + ou_count, + ous); + } + + return NetGetJoinableOUsRemote(ctx, + server_name, + domain, + account, + password, + ou_count, + ous); +} + +/**************************************************************** + NetGetJoinableOUs +****************************************************************/ + +NET_API_STATUS NetGetJoinableOUs(const char *server_name, + const char *domain, + const char *account, + const char *password, + uint32_t *ou_count, + const char ***ous) +{ + struct libnetapi_ctx *ctx = NULL; + NET_API_STATUS status; + WERROR werr; + + status = libnetapi_getctx(&ctx); + if (status != 0) { + return status; + } + + werr = libnetapi_NetGetJoinableOUs(ctx, + server_name, + domain, + account, + password, + ou_count, + ous); + if (!W_ERROR_IS_OK(werr)) { + return W_ERROR_V(werr); + } + + return NET_API_STATUS_SUCCESS; +} -- cgit From 9dd8940e5f4d89da67b66fb1932a95cc6fda63a5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 03:14:08 +0100 Subject: Add header for NetGetJoinableOUs to libnetapi. Guenther (This used to be commit f297ea259d58f7a12924b7111ab79818188cff46) --- source3/lib/netapi/netapi.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 67bb8a8fca..c2f1b488db 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -95,6 +95,17 @@ NET_API_STATUS NetGetJoinInformation(const char *server_name, const char **name_buffer, uint16_t *name_type); +/**************************************************************** + NetGetJoinableOUs +****************************************************************/ + +NET_API_STATUS NetGetJoinableOUs(const char *server_name, + const char *domain, + const char *account, + const char *password, + uint32_t *ou_count, + const char ***ous); + /**************************************************************** NetServerGetInfo ****************************************************************/ -- cgit From db40120c73f4d4cbb132f94cd3c5859fbdad0f5a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 18 Jan 2008 08:48:44 +0100 Subject: Fix the build w/o ADS. Guenther (This used to be commit 645f2376d40fabdc787902ac7506ad7234616619) --- source3/lib/netapi/joindomain.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index cbfc6c01e3..133aff3dd8 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -558,6 +558,7 @@ static WERROR NetGetJoinableOUsLocal(struct libnetapi_ctx *ctx, uint32_t *ou_count, const char ***ous) { +#ifdef WITH_ADS NTSTATUS status; ADS_STATUS ads_status; ADS_STRUCT *ads = NULL; @@ -608,6 +609,9 @@ static WERROR NetGetJoinableOUsLocal(struct libnetapi_ctx *ctx, ads_destroy(&ads); return WERR_OK; +#else + return WERR_NOT_SUPPORTED; +#endif } /**************************************************************** -- cgit From a30361ede36af7ef9d8f6d723798a07b360c813b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 25 Jan 2008 15:45:38 +0100 Subject: No need to close registry on libnetapi_free() anymore. Guenther (This used to be commit 6bf75652ef07f5a534cef5034b7aad4fdcbcd265) --- source3/lib/netapi/netapi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 5c3f7ec465..47b3ba93cf 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -119,7 +119,6 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) gencache_shutdown(); secrets_shutdown(); - regdb_close(); TALLOC_FREE(ctx); TALLOC_FREE(frame); -- cgit From c04b738a136485a8f1df21fbccd1c418ee6fd444 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 25 Jan 2008 15:46:11 +0100 Subject: Add LIBNETAPI_LOCAL_SERVER() macro. Guenther (This used to be commit 4bdcf07bcc3aaf7c3f7245cfdda06433bcf4ae60) --- source3/lib/netapi/netapi.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index c2f1b488db..002fc37762 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -36,6 +36,11 @@ /**************************************************************** ****************************************************************/ +#define LIBNETAPI_LOCAL_SERVER(x) (!x || is_myname_or_ipaddr(x)) + +/**************************************************************** +****************************************************************/ + struct libnetapi_ctx { char *debuglevel; char *error_string; -- cgit From 5ab43ae0d8e66a1fd4c877089df52282367be7dd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 26 Jan 2008 01:39:33 +0100 Subject: Eliminate remote tree of dsgetdcname (which will happen in libnetapi then). Guenther (This used to be commit fd490d236b1fb73a75c457b75128c9b98719418f) --- source3/lib/netapi/joindomain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index 133aff3dd8..55f334b5e1 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -52,7 +52,7 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_WRITABLE_REQUIRED | DS_RETURN_DNS_NAME; - status = dsgetdcname(mem_ctx, NULL, domain_name, + status = dsgetdcname(mem_ctx, domain_name, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(mem_ctx, @@ -261,7 +261,7 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, } else { domain = lp_workgroup(); } - status = dsgetdcname(mem_ctx, NULL, domain, + status = dsgetdcname(mem_ctx, domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(mem_ctx, @@ -566,7 +566,7 @@ static WERROR NetGetJoinableOUsLocal(struct libnetapi_ctx *ctx, uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_RETURN_DNS_NAME; - status = dsgetdcname(ctx, NULL, domain, + status = dsgetdcname(ctx, domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(ctx, "%s", -- cgit From 2e0a1fcf3f461f134c910e83ab82115c00827231 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 31 Jan 2008 14:10:22 +0100 Subject: Re-run make idl. Guenther (This used to be commit b658270518140c457536b0c7db06a646d7077529) --- source3/lib/netapi/getdc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index 1084ddc3c8..2626eb0af4 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -69,8 +69,8 @@ static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx, status = rpccli_netr_GetDcName(pipe_cli, ctx, server_name, domain_name, - (const char **)buffer); - werr = ntstatus_to_werror(status); + (const char **)buffer, + &werr); done: if (cli) { cli_shutdown(cli); -- cgit From 0d8985f2da43d35d8f940af112ad74a199778dd8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 12:30:18 +0100 Subject: Let dsgetdcname() return a struct netr_DsRGetDCNameInfo. Guenther (This used to be commit b1a4b21f8c35dc23e5c986ebe44d3806055eb39b) --- source3/lib/netapi/joindomain.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index 55f334b5e1..405f96a87e 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -48,7 +48,7 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, if (join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) { NTSTATUS status; - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_WRITABLE_REQUIRED | DS_RETURN_DNS_NAME; @@ -60,7 +60,7 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, return ntstatus_to_werror(status); } r->in.dc_name = talloc_strdup(mem_ctx, - info->domain_controller_name); + info->dc_unc); W_ERROR_HAVE_NO_MEMORY(r->in.dc_name); } @@ -252,7 +252,7 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, } else { NTSTATUS status; const char *domain = NULL; - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_WRITABLE_REQUIRED | DS_RETURN_DNS_NAME; @@ -269,7 +269,7 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx, return ntstatus_to_werror(status); } r->in.dc_name = talloc_strdup(mem_ctx, - info->domain_controller_name); + info->dc_unc); W_ERROR_HAVE_NO_MEMORY(r->in.dc_name); } @@ -562,7 +562,7 @@ static WERROR NetGetJoinableOUsLocal(struct libnetapi_ctx *ctx, NTSTATUS status; ADS_STATUS ads_status; ADS_STRUCT *ads = NULL; - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_RETURN_DNS_NAME; @@ -574,7 +574,7 @@ static WERROR NetGetJoinableOUsLocal(struct libnetapi_ctx *ctx, return ntstatus_to_werror(status); } - ads = ads_init(domain, domain, info->domain_controller_name); + ads = ads_init(domain, domain, info->dc_unc); if (!ads) { return WERR_GENERAL_FAILURE; } -- cgit From 77a25318105d90ae34a05c8a1e71df84343bb28e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 17:09:47 +0100 Subject: Only set DEBUGLEVEL to 0 in libnetapi when not set already. Guenther (This used to be commit 3ace1601ac5b5d87d6bfd8aa0afe0c75858b6990) --- source3/lib/netapi/netapi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 47b3ba93cf..fb091f6e0b 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -50,7 +50,9 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) return W_ERROR_V(WERR_NOMEM); } - DEBUGLEVEL = 0; + if (!DEBUGLEVEL) { + DEBUGLEVEL = 0; + } setup_logging("libnetapi", true); dbf = x_stderr; -- cgit From 808348a8ca1499f74343808b043983cb6fd5d06d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 02:49:27 +0100 Subject: Trying to fix libnetapi examples Makefile.in. Guenther (This used to be commit 405ef74d7e9ef614ea39b7cfd1d57307d9490545) --- source3/lib/netapi/examples/Makefile.in | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'source3/lib/netapi') diff --git a/source3/lib/netapi/examples/Makefile.in b/source3/lib/netapi/examples/Makefile.in index 86e1b1bc2f..6de3e65546 100644 --- a/source3/lib/netapi/examples/Makefile.in +++ b/source3/lib/netapi/examples/Makefile.in @@ -3,7 +3,7 @@ GTK_LIBS=`pkg-config gtk+-2.0 --libs` KRB5LIBS=@KRB5_LIBS@ LDAP_LIBS=@LDAP_LIBS@ -LIBS=@LIBS@ -lnetapi +LIBS=@LIBS@ -lnetapi -ltdb -ltalloc DEVELOPER_CFLAGS=@DEVELOPER_CFLAGS@ FLAGS=-I../ -L../../../bin @CFLAGS@ $(GTK_FLAGS) CC=@CC@ @@ -14,7 +14,12 @@ DYNEXP=@DYNEXP@ COMPILE_CC = $(CC) -I. $(FLAGS) $(PICFLAG) -c $< -o $@ COMPILE = $(COMPILE_CC) -BINARY_PREREQS = proto_exists bin/.dummy +PROGS = bin/getdc@EXEEXT@ \ + bin/netdomjoin@EXEEXT@ \ + bin/netdomjoin-gui@EXEEXT@ \ + bin/getjoinableous@EXEEXT@ + +all: $(PROGS) MAKEDIR = || exec false; \ if test -d "$$dir"; then :; else \ @@ -24,6 +29,13 @@ MAKEDIR = || exec false; \ mkdir "$$dir" || \ exec false; fi || exec false +BINARY_PREREQS = bin/.dummy + +bin/.dummy: + @if (: >> $@ || : > $@) >/dev/null 2>&1; then :; else \ + dir=bin $(MAKEDIR); fi + @: >> $@ || : > $@ # what a fancy emoticon! + .c.o: @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi @@ -38,30 +50,23 @@ NETDOMJOIN_OBJ = netdomjoin/netdomjoin.o NETDOMJOIN_GUI_OBJ = netdomjoin-gui/netdomjoin-gui.o GETJOINABLEOUS_OBJ = getjoinableous/getjoinableous.o -PROGS = bin/getdc@EXEEXT@ \ - bin/netdomjoin@EXEEXT@ \ - bin/netdomjoin-gui@EXEEXT@ \ - bin/getjoinableous@EXEEXT@ - -all: $(PROGS) - -bin/getdc@EXEEXT@: $(GETDC_OBJ) +bin/getdc@EXEEXT@: $(BINARY_PREREQS) $(GETDC_OBJ) @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(GETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) -bin/getjoinableous@EXEEXT@: $(GETJOINABLEOUS_OBJ) +bin/getjoinableous@EXEEXT@: $(BINARY_PREREQS) $(GETJOINABLEOUS_OBJ) @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(GETJOINABLEOUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) -bin/netdomjoin@EXEEXT@: $(NETDOMJOIN_OBJ) +bin/netdomjoin@EXEEXT@: $(BINARY_PREREQS) $(NETDOMJOIN_OBJ) @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NETDOMJOIN_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) -bin/netdomjoin-gui@EXEEXT@: $(NETDOMJOIN_GUI_OBJ) +bin/netdomjoin-gui@EXEEXT@: $(BINARY_PREREQS) $(NETDOMJOIN_GUI_OBJ) @echo Linking $@ @$(CC) $(FLAGS) $(GTK_FLAGS) -o $@ $(NETDOMJOIN_GUI_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(GTK_LIBS) clean: -rm -f $(PROGS) -rm -f core */*~ *~ \ - */*.o */*/*.o */*/*/*.o \ + */*.o */*/*.o */*/*/*.o -- cgit