From 4cd4ff474e49bc12fdd4079283cde1fcc66f5f81 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 13 Feb 2008 11:54:41 +0100 Subject: Add libreplace objects to libtalloc.so. Michael (This used to be commit a84bf0786f269b8514e0a08e32fa429cefabe1d3) --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index e0bb772f0e..f91bdf5c10 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -300,7 +300,7 @@ TALLOC_OBJ = @TALLOC_OBJS@ LIBTALLOC_OBJ0 = $(TALLOC_OBJ) -LIBTALLOC_OBJ = $(LIBTALLOC_OBJ0) +LIBTALLOC_OBJ = $(LIBTALLOC_OBJ0) $(LIBREPLACE_OBJ) LIBSAMBAUTIL_OBJ = @LIBTALLOC_STATIC@ \ $(LIBREPLACE_OBJ) \ -- cgit From 7f09dcdd4baa5ba195d72185ee6cd21a23202b0c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 11:43:45 +0100 Subject: Remove redundant (and unused) set of samr opcodes. Guenther (This used to be commit 46d5989562bb771b3dcb2fdd197d2f90c3ff8653) --- source3/include/rpc_samr.h | 71 ---------------------------------------------- 1 file changed, 71 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h index 62c6b167db..cf6027999b 100644 --- a/source3/include/rpc_samr.h +++ b/source3/include/rpc_samr.h @@ -74,77 +74,6 @@ SamrTestPrivateFunctionsUser ********************************************************************/ -#define SAMR_CONNECT_ANON 0x00 -#define SAMR_CLOSE_HND 0x01 -#define SAMR_SET_SEC_OBJECT 0x02 -#define SAMR_QUERY_SEC_OBJECT 0x03 - -#define SAMR_UNKNOWN_4 0x04 /* profile info? */ -#define SAMR_LOOKUP_DOMAIN 0x05 -#define SAMR_ENUM_DOMAINS 0x06 -#define SAMR_OPEN_DOMAIN 0x07 -#define SAMR_QUERY_DOMAIN_INFO 0x08 -#define SAMR_SET_DOMAIN_INFO 0x09 - -#define SAMR_CREATE_DOM_GROUP 0x0a -#define SAMR_ENUM_DOM_GROUPS 0x0b -#define SAMR_ENUM_DOM_USERS 0x0d -#define SAMR_CREATE_DOM_ALIAS 0x0e -#define SAMR_ENUM_DOM_ALIASES 0x0f -#define SAMR_QUERY_USERALIASES 0x10 - -#define SAMR_LOOKUP_NAMES 0x11 -#define SAMR_LOOKUP_RIDS 0x12 - -#define SAMR_OPEN_GROUP 0x13 -#define SAMR_QUERY_GROUPINFO 0x14 -#define SAMR_SET_GROUPINFO 0x15 -#define SAMR_ADD_GROUPMEM 0x16 -#define SAMR_DELETE_DOM_GROUP 0x17 -#define SAMR_DEL_GROUPMEM 0x18 -#define SAMR_QUERY_GROUPMEM 0x19 -#define SAMR_UNKNOWN_1A 0x1a - -#define SAMR_OPEN_ALIAS 0x1b -#define SAMR_QUERY_ALIASINFO 0x1c -#define SAMR_SET_ALIASINFO 0x1d -#define SAMR_DELETE_DOM_ALIAS 0x1e -#define SAMR_ADD_ALIASMEM 0x1f -#define SAMR_DEL_ALIASMEM 0x20 -#define SAMR_QUERY_ALIASMEM 0x21 - -#define SAMR_OPEN_USER 0x22 -#define SAMR_DELETE_DOM_USER 0x23 -#define SAMR_QUERY_USERINFO 0x24 -#define SAMR_SET_USERINFO2 0x25 /* this is SAMR_SET_USERINFO! */ -#define SAMR_QUERY_USERGROUPS 0x27 - -#define SAMR_QUERY_DISPINFO 0x28 -#define SAMR_GET_DISPENUM_INDEX 0x29 -#define SAMR_UNKNOWN_2a 0x2a -#define SAMR_UNKNOWN_2b 0x2b -#define SAMR_GET_USRDOM_PWINFO 0x2c -#define SAMR_REMOVE_SID_FOREIGN_DOMAIN 0x2d -#define SAMR_QUERY_DOMAIN_INFO2 0x2e /* looks like an alias for SAMR_QUERY_DOMAIN_INFO */ -#define SAMR_UNKNOWN_2f 0x2f -#define SAMR_QUERY_DISPINFO3 0x30 /* Alias for SAMR_QUERY_DISPINFO - with info level 3 */ -#define SAMR_UNKNOWN_31 0x31 -#define SAMR_CREATE_USER 0x32 -#define SAMR_QUERY_DISPINFO4 0x33 /* Alias for SAMR_QUERY_DISPINFO - with info level 4 */ -#define SAMR_ADDMULTI_ALIASMEM 0x34 - -#define SAMR_UNKNOWN_35 0x35 -#define SAMR_UNKNOWN_36 0x36 -#define SAMR_CHGPASSWD_USER 0x37 -#define SAMR_GET_DOM_PWINFO 0x38 -#define SAMR_CONNECT 0x39 -#define SAMR_SET_USERINFO 0x3A /* this is SAMR_SET_USERINFO2! */ -#define SAMR_CONNECT4 0x3E -#define SAMR_CHGPASSWD_USER3 0x3F -#define SAMR_CONNECT5 0x40 - #define PASS_MUST_CHANGE_AT_NEXT_LOGON 0x01 #define PASS_DONT_CHANGE_AT_NEXT_LOGON 0x00 -- cgit From c6acbc16a6c6dca611a624a5e9c502dfcac92f93 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 30 Jan 2008 23:43:57 +0100 Subject: Use rpccli_netr_LogonControl() in rpcclient. Guenther (This used to be commit d54456f3c42f123af5516c6f75c87b279fdc775f) --- source3/rpcclient/cmd_netlogon.c | 56 ++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index a752003e8d..b1753575f5 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -348,30 +348,52 @@ static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli, return WERR_OK; } -static NTSTATUS cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { -#if 0 - uint32 query_level = 1; -#endif - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr; + const char *logon_server = cli->cli->desthost; + enum netr_LogonControlCode function_code = 1; + uint32_t level = 1; + union netr_CONTROL_QUERY_INFORMATION info; + + if (argc > 4) { + fprintf(stderr, "Usage: %s " + "\n", argv[0]); + return WERR_OK; + } - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", argv[0]); - return NT_STATUS_OK; + if (argc >= 2) { + logon_server = argv[1]; } -#if 0 - result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level); - if (!NT_STATUS_IS_OK(result)) { - goto done; + if (argc >= 3) { + function_code = atoi(argv[2]); + } + + if (argc >= 4) { + level = atoi(argv[3]); + } + + status = rpccli_netr_LogonControl(cli, mem_ctx, + logon_server, + function_code, + level, + &info, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; } -#endif /* Display results */ - return result; + return werr; } /* Display sam synchronisation information */ @@ -852,7 +874,7 @@ struct cmd_set netlogon_commands[] = { { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, { "dsr_getforesttrustinfo", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getforesttrustinfo, PI_NETLOGON, NULL, "Get Forest Trust Info", "" }, - { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, + { "logonctrl", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl, PI_NETLOGON, NULL, "Logon Control", "" }, { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, NULL, "Sam Logon", "" }, -- cgit From abba82ef5b81f065169bf0ec78494b525354cc26 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 11:56:24 +0100 Subject: Use pidl for _netr_LogonControl. Guenther (This used to be commit ec4947525e0881bfcde661f906ccd1f66fe54f5a) --- source3/rpc_server/srv_netlog.c | 23 +-------------------- source3/rpc_server/srv_netlog_nt.c | 41 ++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 41 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 4f0a0142e5..7faf63205e 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -279,28 +279,7 @@ static bool api_net_logon_ctrl2(pipes_struct *p) static bool api_net_logon_ctrl(pipes_struct *p) { - NET_Q_LOGON_CTRL q_u; - NET_R_LOGON_CTRL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the lsa netlogon ctrl query... */ - if(!net_io_q_logon_ctrl("", &q_u, data, 0)) { - DEBUG(0,("api_net_logon_ctrl: Failed to unmarshall NET_Q_LOGON_CTRL.\n")); - return False; - } - - r_u.status = _net_logon_ctrl(p, &q_u, &r_u); - - if(!net_io_r_logon_ctrl("", &r_u, rdata, 0)) { - DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONCONTROL); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 528a33915a..b59ad62169 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -43,21 +43,34 @@ static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, } /************************************************************************* - net_reply_logon_ctrl: + _netr_LogonControl *************************************************************************/ -NTSTATUS _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, - NET_R_LOGON_CTRL *r_u) +WERROR _netr_LogonControl(pipes_struct *p, + struct netr_LogonControl *r) { - uint32 flags = 0x0; - uint32 pdc_connection_status = 0x00; /* Maybe a win32 error code? */ - + struct netr_NETLOGON_INFO_1 *info1; + uint32_t flags = 0x0; + uint32_t pdc_connection_status = W_ERROR_V(WERR_OK); + /* Setup the Logon Control response */ - init_net_r_logon_ctrl(r_u, q_u->query_level, flags, - pdc_connection_status); + switch (r->in.level) { + case 1: + info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1); + if (!info1) { + return WERR_NOMEM; + } + info1->flags = flags; + info1->pdc_connection_status = pdc_connection_status; - return r_u->status; + r->out.info->info1 = info1; + break; + default: + return WERR_UNKNOWN_LEVEL; + } + + return WERR_OK; } /**************************************************************************** @@ -1257,16 +1270,6 @@ NTSTATUS _netr_AccountSync(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _netr_LogonControl(pipes_struct *p, - struct netr_LogonControl *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _netr_GetDcName(pipes_struct *p, struct netr_GetDcName *r) { -- cgit From dc708ef3a2ec4d55e38c7fd79205d77a0cf33bbb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 13 Feb 2008 12:41:00 +0100 Subject: Only export talloc related symbols in libtalloc.so. Michael (This used to be commit 60a4c8411b71f9f17956b51fd882f71273f5b0ca) --- source3/exports/libtalloc.syms | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/exports/libtalloc.syms b/source3/exports/libtalloc.syms index eb34bfc012..87f1c5c63e 100644 --- a/source3/exports/libtalloc.syms +++ b/source3/exports/libtalloc.syms @@ -1,3 +1,6 @@ { - global: *; + global: + talloc_*; + _talloc_*; + local: *; }; -- cgit From 3649f728ed3a449622c4e1dbc3ebf4c3536b72f7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 18 Jan 2008 08:43:45 +0100 Subject: winbindd: add rids and other_sids arrays in WBFLAG_PAM_INFO3_TEXT mode metze (This used to be commit c5e6dd1ca9611e2830ff773875998c01bf779a64) --- source3/winbindd/winbindd_pam.c | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c index dd27ad62f3..e3574bbcd6 100644 --- a/source3/winbindd/winbindd_pam.c +++ b/source3/winbindd/winbindd_pam.c @@ -31,6 +31,10 @@ static NTSTATUS append_info3_as_txt(TALLOC_CTX *mem_ctx, struct winbindd_cli_state *state, NET_USER_INFO_3 *info3) { + char *ex; + size_t size; + uint32_t i; + state->response.data.auth.info3.logon_time = nt_time_to_unix(info3->logon_time); state->response.data.auth.info3.logoff_time = @@ -83,6 +87,42 @@ static NTSTATUS append_info3_as_txt(TALLOC_CTX *mem_ctx, &info3->uni_logon_dom, sizeof(state->response.data.auth.info3.logon_dom)); + ex = talloc_strdup(mem_ctx, ""); + NT_STATUS_HAVE_NO_MEMORY(ex); + + for (i=0; i < info3->num_groups; i++) { + ex = talloc_asprintf_append_buffer(ex, "0x%08X:0x%08X\n", + info3->gids[i].g_rid, + info3->gids[i].attr); + NT_STATUS_HAVE_NO_MEMORY(ex); + } + + for (i=0; i < info3->num_other_sids; i++) { + char *sid; + + sid = dom_sid_string(mem_ctx, &info3->other_sids[i].sid); + NT_STATUS_HAVE_NO_MEMORY(sid); + + ex = talloc_asprintf_append_buffer(ex, "%s:0x%08X\n", + sid, + info3->other_sids_attrib[i]); + NT_STATUS_HAVE_NO_MEMORY(ex); + + talloc_free(sid); + } + + size = talloc_get_size(ex); + + SAFE_FREE(state->response.extra_data.data); + state->response.extra_data.data = SMB_MALLOC(size); + if (!state->response.extra_data.data) { + return NT_STATUS_NO_MEMORY; + } + memcpy(state->response.extra_data.data, ex, size); + talloc_free(ex); + + state->response.length += size; + return NT_STATUS_OK; } @@ -703,16 +743,18 @@ static bool check_request_flags(uint32_t flags) { uint32_t flags_edata = WBFLAG_PAM_AFS_TOKEN | WBFLAG_PAM_UNIX_NAME | + WBFLAG_PAM_INFO3_TEXT | WBFLAG_PAM_INFO3_NDR; if ( ( (flags & flags_edata) == WBFLAG_PAM_AFS_TOKEN) || ( (flags & flags_edata) == WBFLAG_PAM_INFO3_NDR) || + ( (flags & flags_edata) == WBFLAG_PAM_INFO3_TEXT)|| ( (flags & flags_edata) == WBFLAG_PAM_UNIX_NAME) || !(flags & flags_edata) ) { return True; } - DEBUG(1,("check_request_flags: invalid request flags\n")); + DEBUG(1,("check_request_flags: invalid request flags[0x%08X]\n",flags)); return False; } -- cgit From 9d27ded946daaa7d484f8b93921bac961ea2e071 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 24 Jan 2008 14:05:59 +0100 Subject: libwbclient: add wbcAuthenticateUserEx() function This function will be used by auth_winbind.c. metze (This used to be commit 72af96a320a97ce1a730d6e33d01950123d6a97c) --- source3/nsswitch/libwbclient/wbc_pam.c | 300 ++++++++++++++++++++++++++++++++ source3/nsswitch/libwbclient/wbclient.c | 2 + source3/nsswitch/libwbclient/wbclient.h | 159 ++++++++++++++++- 3 files changed, 460 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c index 7f7c7b8140..e7bcdfe20d 100644 --- a/source3/nsswitch/libwbclient/wbc_pam.c +++ b/source3/nsswitch/libwbclient/wbc_pam.c @@ -63,3 +63,303 @@ wbcErr wbcAuthenticateUser(const char *username, done: return wbc_status; } + +static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx, + const struct winbindd_response *resp, + struct wbcAuthUserInfo **_i) +{ + wbcErr wbc_status = WBC_ERR_SUCCESS; + struct wbcAuthUserInfo *i; + struct wbcDomainSid domain_sid; + char *p; + uint32_t sn = 0; + uint32_t j; + + i = talloc(mem_ctx, struct wbcAuthUserInfo); + BAIL_ON_PTR_ERROR(i, wbc_status); + + i->user_flags = resp->data.auth.info3.user_flgs; + + i->account_name = talloc_strdup(i, resp->data.auth.info3.user_name); + BAIL_ON_PTR_ERROR(i->account_name, wbc_status); + i->user_principal= NULL; + i->full_name = talloc_strdup(i, resp->data.auth.info3.full_name); + BAIL_ON_PTR_ERROR(i->full_name, wbc_status); + i->domain_name = talloc_strdup(i, resp->data.auth.info3.logon_dom); + BAIL_ON_PTR_ERROR(i->domain_name, wbc_status); + i->dns_domain_name= NULL; + + i->acct_flags = resp->data.auth.info3.acct_flags; + memcpy(i->user_session_key, + resp->data.auth.user_session_key, + sizeof(i->user_session_key)); + memcpy(i->lm_session_key, + resp->data.auth.first_8_lm_hash, + sizeof(i->lm_session_key)); + + i->logon_count = resp->data.auth.info3.logon_count; + i->bad_password_count = resp->data.auth.info3.bad_pw_count; + + i->logon_time = resp->data.auth.info3.logon_time; + i->logoff_time = resp->data.auth.info3.logoff_time; + i->kickoff_time = resp->data.auth.info3.kickoff_time; + i->pass_last_set_time = resp->data.auth.info3.pass_last_set_time; + i->pass_can_change_time = resp->data.auth.info3.pass_can_change_time; + i->pass_must_change_time= resp->data.auth.info3.pass_must_change_time; + + i->logon_server = talloc_strdup(i, resp->data.auth.info3.logon_srv); + BAIL_ON_PTR_ERROR(i->logon_server, wbc_status); + i->logon_script = talloc_strdup(i, resp->data.auth.info3.logon_script); + BAIL_ON_PTR_ERROR(i->logon_script, wbc_status); + i->profile_path = talloc_strdup(i, resp->data.auth.info3.profile_path); + BAIL_ON_PTR_ERROR(i->profile_path, wbc_status); + i->home_directory= talloc_strdup(i, resp->data.auth.info3.home_dir); + BAIL_ON_PTR_ERROR(i->home_directory, wbc_status); + i->home_drive = talloc_strdup(i, resp->data.auth.info3.dir_drive); + BAIL_ON_PTR_ERROR(i->home_drive, wbc_status); + + i->num_sids = 2; + i->num_sids += resp->data.auth.info3.num_groups; + i->num_sids += resp->data.auth.info3.num_other_sids; + + i->sids = talloc_array(i, struct wbcSidWithAttr, i->num_sids); + BAIL_ON_PTR_ERROR(i->sids, wbc_status); + + wbc_status = wbcStringToSid(resp->data.auth.info3.dom_sid, + &domain_sid); + BAIL_ON_WBC_ERROR(wbc_status); + +#define _SID_COMPOSE(s, d, r, a) { \ + (s).sid = d; \ + if ((s).sid.num_auths < MAXSUBAUTHS) { \ + (s).sid.sub_auths[(s).sid.num_auths++] = r; \ + } else { \ + wbc_status = WBC_ERR_INVALID_SID; \ + BAIL_ON_WBC_ERROR(wbc_status); \ + } \ + (s).attributes = a; \ +} while (0) + + sn = 0; + _SID_COMPOSE(i->sids[sn], domain_sid, + resp->data.auth.info3.user_rid, + 0); + sn++; + _SID_COMPOSE(i->sids[sn], domain_sid, + resp->data.auth.info3.group_rid, + 0); + sn++; + + p = resp->extra_data.data; + if (!p) { + wbc_status = WBC_INVALID_RESPONSE; + BAIL_ON_WBC_ERROR(wbc_status); + } + + for (j=0; j < resp->data.auth.info3.num_groups; j++) { + uint32_t rid; + uint32_t attrs; + int ret; + char *s = p; + char *e = strchr(p, '\n'); + if (!e) { + wbc_status = WBC_INVALID_RESPONSE; + BAIL_ON_WBC_ERROR(wbc_status); + } + e[0] = '\0'; + p = &e[1]; + + ret = sscanf(s, "0x%08X:0x%08X", &rid, &attrs); + if (ret != 2) { + wbc_status = WBC_INVALID_RESPONSE; + BAIL_ON_WBC_ERROR(wbc_status); + } + + _SID_COMPOSE(i->sids[sn], domain_sid, + rid, attrs); + sn++; + } + + for (j=0; j < resp->data.auth.info3.num_other_sids; j++) { + uint32_t attrs; + int ret; + char *s = p; + char *a; + char *e = strchr(p, '\n'); + if (!e) { + wbc_status = WBC_INVALID_RESPONSE; + BAIL_ON_WBC_ERROR(wbc_status); + } + e[0] = '\0'; + p = &e[1]; + + e = strchr(s, ':'); + if (!e) { + wbc_status = WBC_INVALID_RESPONSE; + BAIL_ON_WBC_ERROR(wbc_status); + } + e[0] = '\0'; + a = &e[1]; + + ret = sscanf(a, "0x%08X", + &attrs); + if (ret != 1) { + wbc_status = WBC_INVALID_RESPONSE; + BAIL_ON_WBC_ERROR(wbc_status); + } + + wbc_status = wbcStringToSid(s, &i->sids[sn].sid); + BAIL_ON_WBC_ERROR(wbc_status); + + i->sids[sn].attributes = attrs; + sn++; + } + + i->num_sids = sn; + + *_i = i; + i = NULL; +done: + talloc_free(i); + return wbc_status; +} + +static wbcErr wbc_create_error_info(TALLOC_CTX *mem_ctx, + const struct winbindd_response *resp, + struct wbcAuthErrorInfo **_e) +{ + wbcErr wbc_status = WBC_ERR_SUCCESS; + struct wbcAuthErrorInfo *e; + + e = talloc(mem_ctx, struct wbcAuthErrorInfo); + BAIL_ON_PTR_ERROR(e, wbc_status); + + e->nt_status = resp->data.auth.nt_status; + e->pam_error = resp->data.auth.pam_error; + e->nt_string = talloc_strdup(e, resp->data.auth.nt_status_string); + BAIL_ON_PTR_ERROR(e->nt_string, wbc_status); + + e->display_string = talloc_strdup(e, resp->data.auth.error_string); + BAIL_ON_PTR_ERROR(e->display_string, wbc_status); + + *_e = e; + e = NULL; + +done: + talloc_free(e); + return wbc_status; +} + +/** @brief Authenticate with more detailed information + * + * @param params Input parameters, only WBC_AUTH_USER_LEVEL_RESPONSE + * is supported yet + * @param info Output details on WBC_ERR_SUCCESS + * @param error Output details on WBC_ERR_AUTH_ERROR + * + * @return #wbcErr + **/ + +wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, + struct wbcAuthUserInfo **info, + struct wbcAuthErrorInfo **error) +{ + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + int cmd; + struct winbindd_request request; + struct winbindd_response response; + + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + if (error) { + *error = NULL; + } + + if (!params) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + /* Initialize request */ + + switch (params->level) { + case WBC_AUTH_USER_LEVEL_PLAIN: + wbc_status = WBC_ERR_NOT_IMPLEMENTED; + BAIL_ON_WBC_ERROR(wbc_status); + break; + + case WBC_AUTH_USER_LEVEL_HASH: + wbc_status = WBC_ERR_NOT_IMPLEMENTED; + BAIL_ON_WBC_ERROR(wbc_status); + break; + + case WBC_AUTH_USER_LEVEL_RESPONSE: + cmd = WINBINDD_PAM_AUTH_CRAP; + request.flags = WBFLAG_PAM_INFO3_TEXT | + WBFLAG_PAM_USER_SESSION_KEY | + WBFLAG_PAM_LMKEY; + + strncpy(request.data.auth_crap.user, + params->account_name, + sizeof(request.data.auth_crap.user)-1); + strncpy(request.data.auth_crap.domain, + params->domain_name, + sizeof(request.data.auth_crap.domain)-1); + if (params->workstation_name) { + strncpy(request.data.auth_crap.workstation, + params->workstation_name, + sizeof(request.data.auth_crap.workstation)-1); + } + + request.data.auth_crap.logon_parameters = + params->parameter_control; + + memcpy(request.data.auth_crap.chal, + params->password.response.challenge, + sizeof(request.data.auth_crap.chal)); + + request.data.auth_crap.lm_resp_len = + MIN(params->password.response.lm_length, + sizeof(request.data.auth_crap.lm_resp)); + request.data.auth_crap.nt_resp_len = + MIN(params->password.response.nt_length, + sizeof(request.data.auth_crap.nt_resp)); + memcpy(request.data.auth_crap.lm_resp, + params->password.response.lm_data, + request.data.auth_crap.lm_resp_len); + memcpy(request.data.auth_crap.nt_resp, + params->password.response.nt_data, + request.data.auth_crap.nt_resp_len); + + break; + } + + wbc_status = wbcRequestResponse(cmd, + &request, + &response); + if (response.data.auth.nt_status != 0) { + if (error) { + wbc_status = wbc_create_error_info(NULL, + &response, + error); + BAIL_ON_WBC_ERROR(wbc_status); + } + + wbc_status = WBC_ERR_AUTH_ERROR; + BAIL_ON_WBC_ERROR(wbc_status); + } + BAIL_ON_WBC_ERROR(wbc_status); + + if (info) { + wbc_status = wbc_create_auth_info(NULL, + &response, + info); + BAIL_ON_WBC_ERROR(wbc_status); + } + +done: + + return wbc_status; +} diff --git a/source3/nsswitch/libwbclient/wbclient.c b/source3/nsswitch/libwbclient/wbclient.c index 5aad378ad0..e17296283f 100644 --- a/source3/nsswitch/libwbclient/wbclient.c +++ b/source3/nsswitch/libwbclient/wbclient.c @@ -110,6 +110,8 @@ const char *wbcErrorString(wbcErr error) return "WBC_INVALID_RESPONSE"; case WBC_ERR_NSS_ERROR: return "WBC_ERR_NSS_ERROR"; + case WBC_ERR_AUTH_ERROR: + return "WBC_ERR_AUTH_ERROR"; } return "unknown wbcErr value"; diff --git a/source3/nsswitch/libwbclient/wbclient.h b/source3/nsswitch/libwbclient/wbclient.h index ef9e3557da..c01db9618d 100644 --- a/source3/nsswitch/libwbclient/wbclient.h +++ b/source3/nsswitch/libwbclient/wbclient.h @@ -41,7 +41,8 @@ enum _wbcErrType { WBC_ERR_WINBIND_NOT_AVAILABLE, /**< Winbind daemon is not available **/ WBC_ERR_DOMAIN_NOT_FOUND, /**< Domain is not trusted or cannot be found **/ WBC_INVALID_RESPONSE, /**< Winbind returned an invalid response **/ - WBC_ERR_NSS_ERROR /**< NSS_STATUS error **/ + WBC_ERR_NSS_ERROR, /**< NSS_STATUS error **/ + WBC_ERR_AUTH_ERROR /**< Authentication failed **/ }; typedef enum _wbcErrType wbcErr; @@ -87,6 +88,25 @@ enum wbcSidType { WBC_SID_NAME_COMPUTER=9 }; +/** + * @brief Security Identifier with attributes + **/ + +struct wbcSidWithAttr { + struct wbcDomainSid sid; + uint32_t attributes; +}; + +/* wbcSidWithAttr->attributes */ + +#define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001 +#define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002 +#define WBC_SID_ATTR_GROUP_ENABLED 0x00000004 +#define WBC_SID_ATTR_GROUP_OWNER 0x00000008 +#define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010 +#define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000 +#define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000 + /** * @brief Domain Information **/ @@ -104,6 +124,140 @@ struct wbcDomainInfo { #define WBC_DOMINFO_AD 0x00000002 #define WBC_DOMINFO_PRIMARY 0x00000004 +/** + * @brief Auth User Parameters + **/ + +struct wbcAuthUserParams { + const char *account_name; + const char *domain_name; + const char *workstation_name; + + uint32_t flags; + + uint32_t parameter_control; + + enum wbcAuthUserLevel { + WBC_AUTH_USER_LEVEL_PLAIN = 1, + WBC_AUTH_USER_LEVEL_HASH = 2, + WBC_AUTH_USER_LEVEL_RESPONSE = 3 + } level; + union { + const char *plaintext; + struct { + uint8_t nt_hash[16]; + uint8_t lm_hash[16]; + } hash; + struct { + uint8_t challenge[8]; + uint32_t nt_length; + uint8_t *nt_data; + uint32_t lm_length; + uint8_t *lm_data; + } response; + } password; +}; + +/* wbcAuthUserParams->parameter_control */ + +#define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002 +#define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004 +#define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008 +#define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020 +#define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200 +#define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800 + +/* wbcAuthUserParams->flags */ + +#define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001 + +/** + * @brief Auth User Information + * + * Some of the strings are maybe NULL + **/ + +struct wbcAuthUserInfo { + uint32_t user_flags; + + char *account_name; + char *user_principal; + char *full_name; + char *domain_name; + char *dns_domain_name; + + uint32_t acct_flags; + uint8_t user_session_key[16]; + uint8_t lm_session_key[8]; + + uint16_t logon_count; + uint16_t bad_password_count; + + uint64_t logon_time; + uint64_t logoff_time; + uint64_t kickoff_time; + uint64_t pass_last_set_time; + uint64_t pass_can_change_time; + uint64_t pass_must_change_time; + + char *logon_server; + char *logon_script; + char *profile_path; + char *home_directory; + char *home_drive; + + /* + * the 1st one is the account sid + * the 2nd one is the primary_group sid + * followed by the rest of the groups + */ + uint32_t num_sids; + struct wbcSidWithAttr *sids; +}; + +/* wbcAuthUserInfo->user_flags */ + +#define WBC_AUTH_USER_INFO_GUEST 0x00000001 +#define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002 +#define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004 +#define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008 +#define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020 +#define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040 +#define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080 +#define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100 +#define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200 +#define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400 +#define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000 + +/* wbcAuthUserInfo->acct_flags */ + +#define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */ +#define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */ +#define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */ +#define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */ +#define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */ +#define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */ +#define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */ +#define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */ +#define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */ +#define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */ +#define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */ +#define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */ +#define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */ +#define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */ +#define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */ +#define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */ +#define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */ +#define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */ +#define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */ + +struct wbcAuthErrorInfo { + uint32_t nt_status; + char *nt_string; + int32_t pam_error; + char *display_string; +}; + /* * Memory Management */ @@ -205,5 +359,8 @@ wbcErr wbcDomainSequenceNumbers(void); wbcErr wbcAuthenticateUser(const char *username, const char *password); +wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, + struct wbcAuthUserInfo **info, + struct wbcAuthErrorInfo **error); #endif /* _WBCLIENT_H */ -- cgit From 5fb87ff3efc56de954ea08d286c90fbaaf99ea0a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 29 Jan 2008 16:21:14 +0100 Subject: wbinfo: use wbcAuthenticateUserEx() metze (This used to be commit 923cb37837d508d5355038e95ed1ac09c5869a89) --- source3/nsswitch/wbinfo.c | 90 ++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 47 deletions(-) (limited to 'source3') diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index 9d1a56536b..689dc5e9e1 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -904,19 +904,16 @@ static bool wbinfo_auth(char *username) static bool wbinfo_auth_crap(char *username) { - struct winbindd_request request; - struct winbindd_response response; - NSS_STATUS result; + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + struct wbcAuthUserParams params; + struct wbcAuthErrorInfo *err = NULL; + DATA_BLOB lm = data_blob_null; + DATA_BLOB nt = data_blob_null; fstring name_user; fstring name_domain; fstring pass; char *p; - /* Send off request */ - - ZERO_STRUCT(request); - ZERO_STRUCT(response); - p = strchr(username, '%'); if (p) { @@ -926,29 +923,30 @@ static bool wbinfo_auth_crap(char *username) parse_wbinfo_domain_user(username, name_domain, name_user); - request.data.auth_crap.logon_parameters = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT | MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT; + params.account_name = name_user; + params.domain_name = name_domain; + params.workstation_name = NULL; - fstrcpy(request.data.auth_crap.user, name_user); + params.flags = 0; + params.parameter_control= WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT | + WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT; - fstrcpy(request.data.auth_crap.domain, name_domain); + params.level = WBC_AUTH_USER_LEVEL_RESPONSE; - generate_random_buffer(request.data.auth_crap.chal, 8); + generate_random_buffer(params.password.response.challenge, 8); if (lp_client_ntlmv2_auth()) { DATA_BLOB server_chal; DATA_BLOB names_blob; - DATA_BLOB lm_response; - DATA_BLOB nt_response; - - server_chal = data_blob(request.data.auth_crap.chal, 8); + server_chal = data_blob(params.password.response.challenge, 8); /* Pretend this is a login to 'us', for blob purposes */ names_blob = NTLMv2_generate_names_blob(global_myname(), lp_workgroup()); if (!SMBNTLMv2encrypt(name_user, name_domain, pass, &server_chal, &names_blob, - &lm_response, &nt_response, NULL)) { + &lm, &nt, NULL)) { data_blob_free(&names_blob); data_blob_free(&server_chal); return false; @@ -956,47 +954,45 @@ static bool wbinfo_auth_crap(char *username) data_blob_free(&names_blob); data_blob_free(&server_chal); - memcpy(request.data.auth_crap.nt_resp, nt_response.data, - MIN(nt_response.length, - sizeof(request.data.auth_crap.nt_resp))); - request.data.auth_crap.nt_resp_len = nt_response.length; - - memcpy(request.data.auth_crap.lm_resp, lm_response.data, - MIN(lm_response.length, - sizeof(request.data.auth_crap.lm_resp))); - request.data.auth_crap.lm_resp_len = lm_response.length; - - data_blob_free(&nt_response); - data_blob_free(&lm_response); - } else { - if (lp_client_lanman_auth() - && SMBencrypt(pass, request.data.auth_crap.chal, - (uchar *)request.data.auth_crap.lm_resp)) { - request.data.auth_crap.lm_resp_len = 24; - } else { - request.data.auth_crap.lm_resp_len = 0; + if (lp_client_lanman_auth()) { + bool ok; + lm = data_blob(NULL, 24); + ok = SMBencrypt(pass, params.password.response.challenge, + lm.data); + if (!ok) { + data_blob_free(&lm); + } } - SMBNTencrypt(pass, request.data.auth_crap.chal, - (uchar *)request.data.auth_crap.nt_resp); - - request.data.auth_crap.nt_resp_len = 24; + nt = data_blob(NULL, 24); + SMBNTencrypt(pass, params.password.response.challenge, + nt.data); } - result = winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response); + params.password.response.nt_length = nt.length; + params.password.response.nt_data = nt.data; + params.password.response.lm_length = lm.length; + params.password.response.lm_data = lm.data; + + wbc_status = wbcAuthenticateUserEx(¶ms, NULL, &err); /* Display response */ d_printf("challenge/response password authentication %s\n", - (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); + WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed"); - if (response.data.auth.nt_status) + if (wbc_status == WBC_ERR_AUTH_ERROR) { d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", - response.data.auth.nt_status_string, - response.data.auth.nt_status, - response.data.auth.error_string); + err->nt_string, + err->nt_status, + err->display_string); + wbcFreeMemory(err); + } - return result == NSS_STATUS_SUCCESS; + data_blob_free(&nt); + data_blob_free(&lm); + + return WBC_ERROR_IS_OK(wbc_status); } /* Authenticate a user with a plaintext password and set a token */ -- cgit From b397b5cb8f0a9ca5d5b2fa3349635a4cebd81779 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 4 Feb 2008 18:18:36 +0100 Subject: auth_winbind: use wbcAuthenticateUserEx() smbd doesn't need $(WBCOMMON_OBJ) anymore, it works with any libwbclient.so now and may talk to an older winbindd. metze (This used to be commit e3435930a307cff3066fe2047ed8c5c48911f001) --- source3/Makefile.in | 5 +- source3/auth/auth_util.c | 233 ++++++++++++++++++++++++++++++++++++++++++++ source3/auth/auth_winbind.c | 113 +++++++++------------ 3 files changed, 279 insertions(+), 72 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index f91bdf5c10..e1a6436365 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -640,9 +640,8 @@ SMBD_OBJ_BASE = $(PARAM_WITHOUT_REG_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \ $(NOTIFY_OBJ) $(GROUPDB_OBJ) $(AUTH_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \ $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(LIBADS_SERVER_OBJ) \ - $(REGISTRY_OBJ) $(POPT_LIB_OBJ) \ - $(BUILDOPT_OBJ) $(SMBLDAP_OBJ) $(LDB_OBJ) $(LIBNET_OBJ) \ - $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ + $(REGISTRY_OBJ) $(POPT_LIB_OBJ) $(BUILDOPT_OBJ) \ + $(SMBLDAP_OBJ) $(LDB_OBJ) $(LIBNET_OBJ) @LIBWBCLIENT_STATIC@ PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/print_aix.o \ printing/print_cups.o printing/print_generic.o \ diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index ce47e94eb5..6efd31d574 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -1654,6 +1654,239 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +/***************************************************************************** + Make a server_info struct from the wbcAuthUserInfo returned by a domain logon +******************************************************************************/ + +NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx, + const char *sent_nt_username, + const char *domain, + const struct wbcAuthUserInfo *info, + auth_serversupplied_info **server_info) +{ + char zeros[16]; + + NTSTATUS nt_status = NT_STATUS_OK; + char *found_username = NULL; + const char *nt_domain; + const char *nt_username; + struct samu *sam_account = NULL; + DOM_SID user_sid; + DOM_SID group_sid; + bool username_was_mapped; + uint32_t i; + + uid_t uid = (uid_t)-1; + gid_t gid = (gid_t)-1; + + auth_serversupplied_info *result; + + result = make_server_info(NULL); + if (result == NULL) { + DEBUG(4, ("make_server_info failed!\n")); + return NT_STATUS_NO_MEMORY; + } + + /* + Here is where we should check the list of + trusted domains, and verify that the SID + matches. + */ + + memcpy(&user_sid, &info->sids[0].sid, sizeof(user_sid)); + memcpy(&group_sid, &info->sids[1].sid, sizeof(group_sid)); + + if (info->account_name) { + nt_username = talloc_strdup(result, info->account_name); + } else { + /* If the server didn't give us one, just use the one we sent + * them */ + nt_username = talloc_strdup(result, sent_nt_username); + } + if (!nt_username) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (info->domain_name) { + nt_domain = talloc_strdup(result, info->domain_name); + } else { + /* If the server didn't give us one, just use the one we sent + * them */ + nt_domain = talloc_strdup(result, domain); + } + if (!nt_domain) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + /* try to fill the SAM account.. If getpwnam() fails, then try the + add user script (2.2.x behavior). + + We use the _unmapped_ username here in an attempt to provide + consistent username mapping behavior between kerberos and NTLM[SSP] + authentication in domain mode security. I.E. Username mapping + should be applied to the fully qualified username + (e.g. DOMAIN\user) and not just the login name. Yes this means we + called map_username() unnecessarily in make_user_info_map() but + that is how the current code is designed. Making the change here + is the least disruptive place. -- jerry */ + + if ( !(sam_account = samu_new( result )) ) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + /* this call will try to create the user if necessary */ + + nt_status = fill_sam_account(result, nt_domain, sent_nt_username, + &found_username, &uid, &gid, sam_account, + &username_was_mapped); + + /* if we still don't have a valid unix account check for + 'map to guest = bad uid' */ + + if (!NT_STATUS_IS_OK(nt_status)) { + TALLOC_FREE( result ); + if ( lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_UID ) { + make_server_info_guest(server_info); + return NT_STATUS_OK; + } + return nt_status; + } + + if (!pdb_set_nt_username(sam_account, nt_username, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_username(sam_account, nt_username, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_domain(sam_account, nt_domain, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_user_sid(sam_account, &user_sid, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_UNSUCCESSFUL; + } + + if (!pdb_set_group_sid(sam_account, &group_sid, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_UNSUCCESSFUL; + } + + if (!pdb_set_fullname(sam_account, info->full_name, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_logon_script(sam_account, info->logon_script, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_profile_path(sam_account, info->profile_path, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_homedir(sam_account, info->home_directory, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_dir_drive(sam_account, info->home_drive, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_acct_ctrl(sam_account, info->acct_flags, PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_pass_last_set_time( + sam_account, + nt_time_to_unix(info->pass_last_set_time), + PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_pass_can_change_time( + sam_account, + nt_time_to_unix(info->pass_can_change_time), + PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_pass_must_change_time( + sam_account, + nt_time_to_unix(info->pass_must_change_time), + PDB_CHANGED)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + /* save this here to _net_sam_logon() doesn't fail (it assumes a + valid struct samu) */ + + result->sam_account = sam_account; + result->unix_name = talloc_strdup(result, found_username); + + result->login_server = talloc_strdup(result, info->logon_server); + + /* Fill in the unix info we found on the way */ + + result->uid = uid; + result->gid = gid; + + /* Create a 'combined' list of all SIDs we might want in the SD */ + + result->num_sids = info->num_sids - 2; + result->sids = talloc_array(result, DOM_SID, result->num_sids); + if (result->sids == NULL) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i < result->num_sids; i++) { + memcpy(&result->sids[i], &info->sids[i+2].sid, sizeof(result->sids[i])); + } + + /* ensure we are never given NULL session keys */ + + ZERO_STRUCT(zeros); + + if (memcmp(info->user_session_key, zeros, sizeof(zeros)) == 0) { + result->user_session_key = data_blob_null; + } else { + result->user_session_key = data_blob_talloc( + result, info->user_session_key, + sizeof(info->user_session_key)); + } + + if (memcmp(info->lm_session_key, zeros, 8) == 0) { + result->lm_session_key = data_blob_null; + } else { + result->lm_session_key = data_blob_talloc( + result, info->lm_session_key, + sizeof(info->lm_session_key)); + } + + result->was_mapped = username_was_mapped; + + *server_info = result; + + return NT_STATUS_OK; +} + /*************************************************************************** Free a user_info struct ***************************************************************************/ diff --git a/source3/auth/auth_winbind.c b/source3/auth/auth_winbind.c index b24aa3a75b..26a1b7f101 100644 --- a/source3/auth/auth_winbind.c +++ b/source3/auth/auth_winbind.c @@ -25,31 +25,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_AUTH -static NTSTATUS get_info3_from_ndr(TALLOC_CTX *mem_ctx, struct winbindd_response *response, NET_USER_INFO_3 *info3) -{ - uint8 *info3_ndr; - size_t len = response->length - sizeof(struct winbindd_response); - prs_struct ps; - if (len > 0) { - info3_ndr = (uint8 *)response->extra_data.data; - if (!prs_init(&ps, len, mem_ctx, UNMARSHALL)) { - return NT_STATUS_NO_MEMORY; - } - prs_copy_data_in(&ps, (char *)info3_ndr, len); - prs_set_offset(&ps,0); - if (!net_io_user_info3("", info3, &ps, 1, 3, False)) { - DEBUG(2, ("get_info3_from_ndr: could not parse info3 struct!\n")); - return NT_STATUS_UNSUCCESSFUL; - } - prs_mem_free(&ps); - - return NT_STATUS_OK; - } else { - DEBUG(2, ("get_info3_from_ndr: No info3 struct found!\n")); - return NT_STATUS_UNSUCCESSFUL; - } -} - /* Authenticate a user with a challenge/response */ static NTSTATUS check_winbind_security(const struct auth_context *auth_context, @@ -58,11 +33,11 @@ static NTSTATUS check_winbind_security(const struct auth_context *auth_context, const auth_usersupplied_info *user_info, auth_serversupplied_info **server_info) { - struct winbindd_request request; - struct winbindd_response response; - NSS_STATUS result; NTSTATUS nt_status; - NET_USER_INFO_3 info3; + wbcErr wbc_status; + struct wbcAuthUserParams params; + struct wbcAuthUserInfo *info = NULL; + struct wbcAuthErrorInfo *err = NULL; if (!user_info) { return NT_STATUS_INVALID_PARAMETER; @@ -82,36 +57,34 @@ static NTSTATUS check_winbind_security(const struct auth_context *auth_context, /* Send off request */ - ZERO_STRUCT(request); - ZERO_STRUCT(response); + params.account_name = user_info->smb_name; + params.domain_name = user_info->domain; + params.workstation_name = user_info->wksta_name; - request.flags = WBFLAG_PAM_INFO3_NDR; + params.flags = 0; + params.parameter_control= user_info->logon_parameters; - request.data.auth_crap.logon_parameters = user_info->logon_parameters; + params.level = WBC_AUTH_USER_LEVEL_RESPONSE; - fstrcpy(request.data.auth_crap.user, user_info->smb_name); - fstrcpy(request.data.auth_crap.domain, user_info->domain); - fstrcpy(request.data.auth_crap.workstation, user_info->wksta_name); + memcpy(params.password.response.challenge, + auth_context->challenge.data, + sizeof(params.password.response.challenge)); - memcpy(request.data.auth_crap.chal, auth_context->challenge.data, sizeof(request.data.auth_crap.chal)); - - request.data.auth_crap.lm_resp_len = MIN(user_info->lm_resp.length, - sizeof(request.data.auth_crap.lm_resp)); - request.data.auth_crap.nt_resp_len = MIN(user_info->nt_resp.length, - sizeof(request.data.auth_crap.nt_resp)); - - memcpy(request.data.auth_crap.lm_resp, user_info->lm_resp.data, - request.data.auth_crap.lm_resp_len); - memcpy(request.data.auth_crap.nt_resp, user_info->nt_resp.data, - request.data.auth_crap.nt_resp_len); + params.password.response.nt_length = user_info->nt_resp.length; + params.password.response.nt_data = user_info->nt_resp.data; + params.password.response.lm_length = user_info->lm_resp.length; + params.password.response.lm_data = user_info->lm_resp.data; /* we are contacting the privileged pipe */ become_root(); - result = winbindd_priv_request_response(WINBINDD_PAM_AUTH_CRAP, - &request, &response); + wbc_status = wbcAuthenticateUserEx(¶ms, &info, &err); unbecome_root(); - if ( result == NSS_STATUS_UNAVAIL ) { + if (wbc_status == WBC_ERR_NO_MEMORY) { + return NT_STATUS_NO_MEMORY; + } + + if (wbc_status == WBC_ERR_WINBIND_NOT_AVAILABLE) { struct auth_methods *auth_method = (struct auth_methods *)my_private_data; @@ -123,27 +96,29 @@ static NTSTATUS check_winbind_security(const struct auth_context *auth_context, DEBUG(0,("check_winbind_security: ERROR! my_private_data == NULL!\n")); } - nt_status = NT_STATUS(response.data.auth.nt_status); - - if (result == NSS_STATUS_SUCCESS && response.extra_data.data) { - if (NT_STATUS_IS_OK(nt_status)) { - if (NT_STATUS_IS_OK(nt_status = get_info3_from_ndr(mem_ctx, &response, &info3))) { - nt_status = make_server_info_info3(mem_ctx, - user_info->smb_name, user_info->domain, - server_info, &info3); - } - - if (NT_STATUS_IS_OK(nt_status)) { - if (user_info->was_mapped) { - (*server_info)->was_mapped = user_info->was_mapped; - } - } - } - } else if (NT_STATUS_IS_OK(nt_status)) { - nt_status = NT_STATUS_NO_LOGON_SERVERS; + if (wbc_status == WBC_ERR_AUTH_ERROR) { + nt_status = NT_STATUS(err->nt_status); + wbcFreeMemory(err); + return nt_status; + } + + if (!WBC_ERROR_IS_OK(wbc_status)) { + return NT_STATUS_LOGON_FAILURE; + } + + nt_status = make_server_info_wbcAuthUserInfo(mem_ctx, + user_info->smb_name, + user_info->domain, + info, server_info); + wbcFreeMemory(info); + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } + + if (user_info->was_mapped) { + (*server_info)->was_mapped = user_info->was_mapped; } - SAFE_FREE(response.extra_data.data); return nt_status; } -- cgit From 1fee36432be65bd9e7477cfe9fb567de352399c3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 13 Feb 2008 13:48:00 +0100 Subject: Add -L./bin to LDFLAGS when building shared libs. Formerly this was only needed for libwbclient, but now that we start using more shared libs internally, this is needed more globally to support linking internal libs dynamically on systemy without winbindd. Michael (This used to be commit ec793572187228deda7210dab02882e4e09f1972) --- source3/configure.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index f3187aa915..cde3c0b76e 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1996,6 +1996,10 @@ if test "$enable_shared" = yes -a "${ac_cv_gnu_ld_version_script}" = yes; then DSO_EXPORTS=\$\(DSO_EXPORTS_CMD\) fi +if test x"$BLDSHARED" = x"true" ; then + LDFLAGS="$LDFLAGS -L./bin" +fi + AC_MSG_RESULT($BLDSHARED) AC_MSG_CHECKING([LDFLAGS]) @@ -6284,7 +6288,6 @@ if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_S INSTALL_LIBWBCLIENT=installlibwbclient UNINSTALL_LIBWBCLIENT=uninstalllibwbclient WINBIND_LIBS="-lwbclient" - LDFLAGS="$LDFLAGS -L./bin" else LIBWBCLIENT_STATIC=bin/libwbclient.a fi -- cgit From 4b18f4f222ed800975a6172973de2e5698563117 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 13 Feb 2008 14:10:06 +0100 Subject: Only use the needed objects for libnetapi.a Michael (This used to be commit 4ffc73d90883491b9d4dc6d0249e1d859939670b) --- source3/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index e1a6436365..5302fce384 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1479,9 +1479,9 @@ bin/libnetapi.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBWBCLIENT_SHARED $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) -bin/libnetapi.a: $(BINARY_PREREQS) $(LIBNETAPI_OBJ) +bin/libnetapi.a: $(BINARY_PREREQS) $(LIBNETAPI_OBJ1) @echo Linking non-shared library $@ - @-$(AR) -rc $@ $(LIBNETAPI_OBJ) + @-$(AR) -rc $@ $(LIBNETAPI_OBJ1) bin/libsmbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ -- cgit From a2c0ca84d51945e01f3acdba05430a2736fa9278 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 14:10:10 +0100 Subject: Remove const on policy handle in net rpc. Volker, are you ok with that? Guenther (This used to be commit f1c7fa19e43d720f0d42e6d1999130462d5979da) --- source3/utils/net_rpc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 3767138601..5bc37f391f 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -1406,9 +1406,8 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx, TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx, struct rpc_pipe_client *pipe_hnd, - const POLICY_HND *user_hnd, + POLICY_HND *user_hnd, int argc, const char **argv)) - { POLICY_HND connect_pol, domain_pol, user_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; @@ -1490,7 +1489,7 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx, static NTSTATUS rpc_sh_user_show_internals(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx, struct rpc_pipe_client *pipe_hnd, - const POLICY_HND *user_hnd, + POLICY_HND *user_hnd, int argc, const char **argv) { NTSTATUS result; @@ -1502,7 +1501,7 @@ static NTSTATUS rpc_sh_user_show_internals(TALLOC_CTX *mem_ctx, } result = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx, - CONST_DISCARD(struct policy_handle *, user_hnd), + user_hnd, 21, &info); if (!NT_STATUS_IS_OK(result)) { @@ -1539,7 +1538,7 @@ do { if (strequal(ctx->thiscmd, name)) { \ static NTSTATUS rpc_sh_user_str_edit_internals(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx, struct rpc_pipe_client *pipe_hnd, - const POLICY_HND *user_hnd, + POLICY_HND *user_hnd, int argc, const char **argv) { NTSTATUS result; @@ -1554,7 +1553,7 @@ static NTSTATUS rpc_sh_user_str_edit_internals(TALLOC_CTX *mem_ctx, } result = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx, - CONST_DISCARD(struct policy_handle *, user_hnd), + user_hnd, 21, &info); if (!NT_STATUS_IS_OK(result)) { @@ -1589,7 +1588,7 @@ static NTSTATUS rpc_sh_user_str_edit_internals(TALLOC_CTX *mem_ctx, SETSTR("description", description, DESCRIPTION); result = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, - CONST_DISCARD(struct policy_handle *, user_hnd), + user_hnd, 21, info); @@ -1622,7 +1621,7 @@ static NTSTATUS rpc_sh_user_str_edit(TALLOC_CTX *mem_ctx, static NTSTATUS rpc_sh_user_flag_edit_internals(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx, struct rpc_pipe_client *pipe_hnd, - const POLICY_HND *user_hnd, + POLICY_HND *user_hnd, int argc, const char **argv) { NTSTATUS result; @@ -1643,7 +1642,7 @@ static NTSTATUS rpc_sh_user_flag_edit_internals(TALLOC_CTX *mem_ctx, newval = strequal(argv[0], "yes"); result = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx, - CONST_DISCARD(struct policy_handle *, user_hnd), + user_hnd, 21, &info); if (!NT_STATUS_IS_OK(result)) { @@ -1670,7 +1669,7 @@ static NTSTATUS rpc_sh_user_flag_edit_internals(TALLOC_CTX *mem_ctx, info->info21.fields_present = SAMR_FIELD_ACCT_FLAGS; result = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, - CONST_DISCARD(struct policy_handle *, user_hnd), + user_hnd, 21, info); -- cgit From b94093173d9831935b7526ad0e8a93b791d7957a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 12:24:56 +0100 Subject: Pure cosmetics: remove trailing whitespace in netlogon server. Guenther (This used to be commit 983ac0a6762b52945a784ccbc371f4df99a0a52b) --- source3/rpc_server/srv_netlog_nt.c | 138 ++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 69 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index b59ad62169..d9fcbeb285 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -1,4 +1,4 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, @@ -11,12 +11,12 @@ * 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 . */ @@ -101,54 +101,54 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C unistr2_to_ascii(servername, &q_u->uni_server_name, sizeof(servername)); r_u->status = NT_STATUS_OK; - + tc_status = W_ERROR_V(WERR_NO_SUCH_DOMAIN); fstrcpy( dc_name, "" ); - + switch ( q_u->function_code ) { case NETLOGON_CONTROL_TC_QUERY: unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); - + if ( !is_trusted_domain( domain ) ) break; - + if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) { tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS); break; } fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); - + tc_status = W_ERROR_V(WERR_OK); - + break; - + case NETLOGON_CONTROL_REDISCOVER: unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); - + if ( !is_trusted_domain( domain ) ) break; - + if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) { tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS); break; } fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); - + tc_status = W_ERROR_V(WERR_OK); - + break; - + default: /* no idea what this should be */ DEBUG(0,("_net_logon_ctrl2: unimplemented function level [%d]\n", q_u->function_code)); } - + /* prepare the response */ - - init_net_r_logon_ctrl2( r_u, q_u->query_level, flags, + + init_net_r_logon_ctrl2( r_u, q_u->query_level, flags, pdc_connection_status, logon_attempts, tc_status, dc_name ); if (lp_server_role() == ROLE_DOMAIN_BDC) @@ -187,7 +187,7 @@ WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, ***********************************************************************************/ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, - DOM_CRED *srv_cred, NTSTATUS status) + DOM_CRED *srv_cred, NTSTATUS status) { DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); @@ -207,13 +207,13 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) const uint8 *pass; bool ret; uint32 acct_ctrl; - + #if 0 char addr[INET6_ADDRSTRLEN]; /* * Currently this code is redundent as we already have a filter - * by hostname list. What this code really needs to do is to + * by hostname list. What this code really needs to do is to * get a hosts allowed/hosts denied list from the SAM database * on a per user basis, and make the access decision there. * I will leave this code here for now as a reminder to implement @@ -236,7 +236,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) become_root(); ret = pdb_getsampwnam(sampass, mach_acct); unbecome_root(); - + if (!ret) { DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); TALLOC_FREE(sampass); @@ -252,7 +252,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) if (!(acct_ctrl & ACB_SVRTRUST) && !(acct_ctrl & ACB_WSTRUST) && - !(acct_ctrl & ACB_DOMTRUST)) + !(acct_ctrl & ACB_DOMTRUST)) { DEBUG(0,("get_md4pw: Workstation %s: account is not a trust account\n", mach_acct)); TALLOC_FREE(sampass); @@ -298,9 +298,9 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) dump_data(5, (uint8 *)md4pw, 16); TALLOC_FREE(sampass); - + return NT_STATUS_OK; - + } @@ -330,10 +330,10 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u /* Create a server challenge for the client */ /* Set this to a random value. */ generate_random_buffer(p->dc->srv_chal.data, 8); - + /* set up the LSA REQUEST CHALLENGE response */ init_net_r_req_chal(r_u, &p->dc->srv_chal, NT_STATUS_OK); - + p->dc->challenge_sent = True; return NT_STATUS_OK; @@ -385,7 +385,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ p->dc->mach_pw, - &srv_chal_out); + &srv_chal_out); /* Check client credentials are valid. */ if (!creds_server_check(p->dc, &q_u->clnt_chal)) { @@ -468,7 +468,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ p->dc->mach_pw, - &srv_chal_out); + &srv_chal_out); /* Check client credentials are valid. */ if (!creds_server_check(p->dc, &q_u->clnt_chal)) { @@ -551,7 +551,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * DEBUG(3,("_net_srv_pwset: Server Password Set by remote machine:[%s] on account [%s]\n", remote_machine, p->dc->mach_acct)); - + /* Step the creds chain forward. */ if (!creds_server_step(p->dc, &q_u->clnt_id.cred, &cred_out)) { DEBUG(2,("_net_srv_pwset: creds_server_step failed. Rejecting auth " @@ -579,7 +579,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } /* Ensure the account exists and is a machine account. */ - + acct_ctrl = pdb_get_acct_ctrl(sampass); if (!(acct_ctrl & ACB_WSTRUST || @@ -588,7 +588,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * TALLOC_FREE(sampass); return NT_STATUS_NO_SUCH_USER; } - + if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) { TALLOC_FREE(sampass); return NT_STATUS_ACCOUNT_DISABLED; @@ -605,7 +605,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * old_pw = pdb_get_nt_passwd(sampass); if (old_pw && memcmp(pwd, old_pw, 16) == 0) { - /* Avoid backend modificiations and other fun if the + /* Avoid backend modificiations and other fun if the client changed the password to the *same thing* */ ret = True; @@ -616,18 +616,18 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * TALLOC_FREE(sampass); return NT_STATUS_NO_MEMORY; } - + if (!pdb_set_nt_passwd(sampass, pwd, PDB_CHANGED)) { TALLOC_FREE(sampass); return NT_STATUS_NO_MEMORY; } - + if (!pdb_set_pass_last_set_time(sampass, time(NULL), PDB_CHANGED)) { TALLOC_FREE(sampass); /* Not quite sure what this one qualifies as, but this will do */ - return NT_STATUS_UNSUCCESSFUL; + return NT_STATUS_UNSUCCESSFUL; } - + become_root(); r_u->status = pdb_update_sam_account(sampass); unbecome_root(); @@ -712,7 +712,7 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, size_t num_sids, const DOM_SID *sids, - int *numgroups, DOM_GID **pgids) + int *numgroups, DOM_GID **pgids) { int i; @@ -754,7 +754,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, auth_serversupplied_info *server_info = NULL; struct samu *sampw; struct auth_context *auth_context = NULL; - + if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but @@ -781,7 +781,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, /* We handle the return of USER_INFO_2 instead of 3 in the parse return. Sucks, I know... */ r_u->switch_value = q_u->validation_level; /* indicates type of validation user info */ r_u->buffer_creds = 1; /* Ensure we always return server creds. */ - + if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; @@ -835,14 +835,14 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; - + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; case NET_LOGON_TYPE: uni_samlogon_user = &ctr->auth.id2.uni_user_name; uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; - + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); break; default: @@ -857,16 +857,16 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); - + DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); status = NT_STATUS_OK; - + switch (ctr->switch_value) { case NET_LOGON_TYPE: { const char *wksname = nt_workstation; - + if (!NT_STATUS_IS_OK(status = make_auth_context_fixed(&auth_context, ctr->auth.id2.lm_chal))) { return status; } @@ -878,8 +878,8 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (*wksname == '\\') wksname++; /* Standard challenge/response authenticaion */ - if (!make_user_info_netlogon_network(&user_info, - nt_username, nt_domain, + if (!make_user_info_netlogon_network(&user_info, + nt_username, nt_domain, wksname, ctr->auth.id2.param_ctrl, ctr->auth.id2.lm_chal_resp.buffer, @@ -887,7 +887,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, ctr->auth.id2.nt_chal_resp.buffer, ctr->auth.id2.nt_chal_resp.str_str_len)) { status = NT_STATUS_NO_MEMORY; - } + } break; } case INTERACTIVE_LOGON_TYPE: @@ -897,20 +897,20 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, on */ { const uint8 *chal; - + if (!NT_STATUS_IS_OK(status = make_auth_context_subsystem(&auth_context))) { return status; } - + chal = auth_context->get_ntlm_challenge(auth_context); - if (!make_user_info_netlogon_interactive(&user_info, - nt_username, nt_domain, - nt_workstation, + if (!make_user_info_netlogon_interactive(&user_info, + nt_username, nt_domain, + nt_workstation, ctr->auth.id1.param_ctrl, chal, - ctr->auth.id1.lm_owf.data, - ctr->auth.id1.nt_owf.data, + ctr->auth.id1.lm_owf.data, + ctr->auth.id1.nt_owf.data, p->dc->sess_key)) { status = NT_STATUS_NO_MEMORY; } @@ -920,26 +920,26 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, DEBUG(2,("SAM Logon: unsupported switch value\n")); return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ - + if ( NT_STATUS_IS_OK(status) ) { - status = auth_context->check_ntlm_password(auth_context, + status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); } - (auth_context->free)(&auth_context); + (auth_context->free)(&auth_context); free_user_info(&user_info); - - DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", + + DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", nt_errstr(status))); /* Check account and password */ - + if (!NT_STATUS_IS_OK(status)) { - /* If we don't know what this domain is, we need to - indicate that we are not authoritative. This - allows the client to decide if it needs to try + /* If we don't know what this domain is, we need to + indicate that we are not authoritative. This + allows the client to decide if it needs to try a local user. Fix by jpjanosi@us.ibm.com, #2976 */ - if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER) + if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER) && !strequal(nt_domain, get_global_sam_name()) && !is_trusted_domain(nt_domain) ) r_u->auth_resp = 0; /* We are not authoritative */ @@ -1095,7 +1095,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * { return _net_sam_logon_internal(p, q_u, r_u, True); } - + /************************************************************************* _net_sam_logon_ex - no credential chaining. Map into net sam logon. *************************************************************************/ @@ -1146,10 +1146,10 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L { NTSTATUS status = NT_STATUS_OK; - /* TODO: According to MSDN, the can only be executed against a + /* TODO: According to MSDN, the can only be executed against a DC or domain member running Windows 2000 or later. Need - to test against a standalone 2k server and see what it - does. A windows 2000 DC includes its own domain in the + to test against a standalone 2k server and see what it + does. A windows 2000 DC includes its own domain in the list. --jerry */ return status; -- cgit From 4140f3213d678fa998d1cf6e6f1eaf4d5be7903a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 14:08:59 +0100 Subject: Use pidl for _netr_ServerReqChallenge. Guenther (This used to be commit ef424319410b7a29ecdfefca53b7e9704beb6139) --- source3/rpc_server/srv_netlog.c | 24 +----------------------- source3/rpc_server/srv_netlog_nt.c | 34 ++++++++++++---------------------- 2 files changed, 13 insertions(+), 45 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7faf63205e..1b23cd835a 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -55,29 +55,7 @@ static bool proxy_netr_call(pipes_struct *p, uint8 opnum) static bool api_net_req_chal(pipes_struct *p) { - NET_Q_REQ_CHAL q_u; - NET_R_REQ_CHAL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the challenge... */ - if(!net_io_q_req_chal("", &q_u, data, 0)) { - DEBUG(0,("api_net_req_chal: Failed to unmarshall NET_Q_REQ_CHAL.\n")); - return False; - } - - r_u.status = _net_req_chal(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_req_chal("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_req_chal: Failed to marshall NET_R_REQ_CHAL.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_SERVERREQCHALLENGE); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d9fcbeb285..acf694b128 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -34,12 +34,12 @@ extern userdom_struct current_user_info; init_net_r_req_chal: *************************************************************************/ -static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, - DOM_CHAL *srv_chal, NTSTATUS status) +static void init_net_r_req_chal(struct netr_Credential *r, + DOM_CHAL *srv_chal) { DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__)); - memcpy(r_c->srv_chal.data, srv_chal->data, sizeof(srv_chal->data)); - r_c->status = status; + + memcpy(r->data, srv_chal->data, sizeof(r->data)); } /************************************************************************* @@ -305,10 +305,11 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) } /************************************************************************* - _net_req_chal + _netr_ServerReqChallenge *************************************************************************/ -NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) +NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, + struct netr_ServerReqChallenge *r) { if (!p->dc) { p->dc = TALLOC_ZERO_P(p->pipe_state_mem_ctx, struct dcinfo); @@ -316,23 +317,22 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u return NT_STATUS_NO_MEMORY; } } else { - DEBUG(10,("_net_req_chal: new challenge requested. Clearing old state.\n")); + DEBUG(10,("_netr_ServerReqChallenge: new challenge requested. Clearing old state.\n")); ZERO_STRUCTP(p->dc); } - rpcstr_pull(p->dc->remote_machine, - q_u->uni_logon_clnt.buffer, - sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); + fstrcpy(p->dc->remote_machine, r->in.computer_name); /* Save the client challenge to the server. */ - memcpy(p->dc->clnt_chal.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc->clnt_chal.data, r->in.credentials->data, + sizeof(r->in.credentials->data)); /* Create a server challenge for the client */ /* Set this to a random value. */ generate_random_buffer(p->dc->srv_chal.data, 8); /* set up the LSA REQUEST CHALLENGE response */ - init_net_r_req_chal(r_u, &p->dc->srv_chal, NT_STATUS_OK); + init_net_r_req_chal(r->out.credentials, &p->dc->srv_chal); p->dc->challenge_sent = True; @@ -1200,16 +1200,6 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, - struct netr_ServerReqChallenge *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, struct netr_ServerAuthenticate *r) { -- cgit From 24aeb67d5c89083a310892959273b681721d4d2b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 12:29:24 +0100 Subject: Fix IDL for netr_LogonControl2. Guenther (This used to be commit d16af5105d307ebb88190176d7f89971d0f40351) --- source3/librpc/idl/netlogon.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index ae16884896..25118bc816 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -834,7 +834,7 @@ interface netlogon [in,unique] [string,charset(UTF16)] uint16 *logon_server, [in] uint32 function_code, [in] uint32 level, - [in][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION data, + [in,ref][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION *data, [out,ref][switch_is(level)] netr_CONTROL_QUERY_INFORMATION *query ); -- cgit From 120939d5d6ec0bae3a92b18ac3707fd9d3f36e46 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 14:12:29 +0100 Subject: Re-run make idl. Guenther (This used to be commit 782ad12e3c100cf74ca0bc353379efe90da69b98) --- source3/librpc/gen_ndr/cli_netlogon.c | 2 +- source3/librpc/gen_ndr/cli_netlogon.h | 2 +- source3/librpc/gen_ndr/ndr_netlogon.c | 25 +++++++++++++++++++------ source3/librpc/gen_ndr/netlogon.h | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_netlogon.c b/source3/librpc/gen_ndr/cli_netlogon.c index de04c21dc5..f355856fd5 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.c +++ b/source3/librpc/gen_ndr/cli_netlogon.c @@ -745,7 +745,7 @@ NTSTATUS rpccli_netr_LogonControl2(struct rpc_pipe_client *cli, const char *logon_server, uint32_t function_code, uint32_t level, - union netr_CONTROL_DATA_INFORMATION data, + union netr_CONTROL_DATA_INFORMATION *data, union netr_CONTROL_QUERY_INFORMATION *query, WERROR *werror) { diff --git a/source3/librpc/gen_ndr/cli_netlogon.h b/source3/librpc/gen_ndr/cli_netlogon.h index 4aa0f9fa73..0b6ed869c5 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.h +++ b/source3/librpc/gen_ndr/cli_netlogon.h @@ -127,7 +127,7 @@ NTSTATUS rpccli_netr_LogonControl2(struct rpc_pipe_client *cli, const char *logon_server, uint32_t function_code, uint32_t level, - union netr_CONTROL_DATA_INFORMATION data, + union netr_CONTROL_DATA_INFORMATION *data, union netr_CONTROL_QUERY_INFORMATION *query, WERROR *werror); NTSTATUS rpccli_netr_ServerAuthenticate2(struct rpc_pipe_client *cli, diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index b12a347ded..624c9acc69 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -10166,8 +10166,11 @@ static enum ndr_err_code ndr_push_netr_LogonControl2(struct ndr_push *ndr, int f } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.function_code)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.data, r->in.function_code)); - NDR_CHECK(ndr_push_netr_CONTROL_DATA_INFORMATION(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.data)); + if (r->in.data == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.data, r->in.function_code)); + NDR_CHECK(ndr_push_netr_CONTROL_DATA_INFORMATION(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.data)); } if (flags & NDR_OUT) { if (r->out.query == NULL) { @@ -10184,6 +10187,7 @@ static enum ndr_err_code ndr_pull_netr_LogonControl2(struct ndr_pull *ndr, int f { uint32_t _ptr_logon_server; TALLOC_CTX *_mem_save_logon_server_0; + TALLOC_CTX *_mem_save_data_0; TALLOC_CTX *_mem_save_query_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -10208,8 +10212,14 @@ static enum ndr_err_code ndr_pull_netr_LogonControl2(struct ndr_pull *ndr, int f } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.function_code)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.data, r->in.function_code)); - NDR_CHECK(ndr_pull_netr_CONTROL_DATA_INFORMATION(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.data)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.data); + } + _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.data, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.data, r->in.function_code)); + NDR_CHECK(ndr_pull_netr_CONTROL_DATA_INFORMATION(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.data)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.query); ZERO_STRUCTP(r->out.query); } @@ -10245,8 +10255,11 @@ _PUBLIC_ void ndr_print_netr_LogonControl2(struct ndr_print *ndr, const char *na ndr->depth--; ndr_print_uint32(ndr, "function_code", r->in.function_code); ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_set_switch_value(ndr, &r->in.data, r->in.function_code); - ndr_print_netr_CONTROL_DATA_INFORMATION(ndr, "data", &r->in.data); + ndr_print_ptr(ndr, "data", r->in.data); + ndr->depth++; + ndr_print_set_switch_value(ndr, r->in.data, r->in.function_code); + ndr_print_netr_CONTROL_DATA_INFORMATION(ndr, "data", r->in.data); + ndr->depth--; ndr->depth--; } if (flags & NDR_OUT) { diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index ef2218c0f2..36380f1498 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -1071,7 +1071,7 @@ struct netr_LogonControl2 { const char *logon_server;/* [unique,charset(UTF16)] */ uint32_t function_code; uint32_t level; - union netr_CONTROL_DATA_INFORMATION data;/* [switch_is(function_code)] */ + union netr_CONTROL_DATA_INFORMATION *data;/* [ref,switch_is(function_code)] */ } in; struct { -- cgit From 574dce7c0e7f0c869ec3404a2c2a898f57b436be Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 13 Feb 2008 14:43:56 +0100 Subject: Link in libnetapi as shared or static library (same mechanism as talloc). This, too, can be turned to static linking by providing the configure parameter --with-static-libs=netapi. Michael (This used to be commit a4c773de0fbd303f633e120e817b4c88fcff2064) --- source3/Makefile.in | 24 +++++++++------- source3/configure.in | 77 ++++++++++++++++++++++++++-------------------------- 2 files changed, 53 insertions(+), 48 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 5302fce384..c42b3c3465 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -144,11 +144,15 @@ PIDDIR = @piddir@ LIBTALLOC_SHARED_TARGET=@LIBTALLOC_SHARED_TARGET@ LIBTALLOC_STATIC_TARGET=@LIBTALLOC_STATIC_TARGET@ LIBTALLOC=$(LIBTALLOC_STATIC_TARGET) @LIBTALLOC_SHARED@ + LIBSMBCLIENT=bin/libsmbclient.a @LIBSMBCLIENT_SHARED@ LIBSMBSHAREMODES=bin/libsmbsharemodes.a @LIBSMBSHAREMODES_SHARED@ LIBADDNS=bin/libaddns.a @LIBADDNS_SHARED@ LIBWBCLIENT=@LIBWBCLIENT_SHARED@ -LIBNETAPI=bin/libnetapi.a @LIBNETAPI_SHARED@ + +LIBNETAPI_SHARED_TARGET=@LIBNETAPI_SHARED_TARGET@ +LIBNETAPI_STATIC_TARGET=@LIBNETAPI_STATIC_TARGET@ +LIBNETAPI=$(LIBNETAPI_STATIC_TARGET) @LIBNETAPI_SHARED@ FLAGS1 = $(CFLAGS) @FLAGS1@ @SAMBA_CPPFLAGS@ $(CPPFLAGS) FLAGS2 = @@ -206,7 +210,7 @@ EVERYTHING_PROGS = bin/debug2html@EXEEXT@ bin/smbfilter@EXEEXT@ \ bin/log2pcap@EXEEXT@ bin/sharesec@EXEEXT@ bin/ndrdump@EXEEXT@ \ bin/vlp@EXEEXT@ -SHLIBS = libtalloc @LIBWBCLIENT@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@ @LIBADDNS@ @LIBNETAPI@ +SHLIBS = libtalloc @LIBWBCLIENT@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@ @LIBADDNS@ libnetapi PAM_MODULES = @PAM_MODULES@ @@ -803,7 +807,7 @@ NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ $(SMBLDAP_OBJ) $(DCUTIL_OBJ) $(SERVER_MUTEX_OBJ) \ $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(REGFIO_OBJ) $(READLINE_OBJ) \ $(LDB_OBJ) $(LIBGPO_OBJ) @BUILD_INIPARSER@ $(DISPLAY_SEC_OBJ) \ - $(REG_API_OBJ) $(DISPLAY_DSDCINFO_OBJ) $(LIBNETAPI_OBJ1) $(LIBNET_OBJ) \ + $(REG_API_OBJ) $(DISPLAY_DSDCINFO_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ @@ -1254,7 +1258,7 @@ bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ - $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @INIPARSERLIBS@ @WINBIND_LIBS@ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @INIPARSERLIBS@ @WINBIND_LIBS@ @LIBNETAPI_LIBS@ bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @echo Linking $@ @@ -1473,13 +1477,13 @@ bin/libaddns.a: $(BINARY_PREREQS) $(LIBADDNS_OBJ) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBADDNS_OBJ) -bin/libnetapi.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBWBCLIENT_SHARED@ +$(LIBNETAPI_SHARED_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ @$(SHLD_DSO) $(LIBNETAPI_OBJ) @LIBWBCLIENT_SHARED@ $(LIBS) \ $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) -bin/libnetapi.a: $(BINARY_PREREQS) $(LIBNETAPI_OBJ1) +$(LIBNETAPI_STATIC_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ1) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBNETAPI_OBJ1) @@ -1888,7 +1892,7 @@ install: installservers installbin @INSTALL_CIFSMOUNT@ @INSTALL_CIFSSPNEGO@ inst installscripts installdat installmodules @SWAT_INSTALL_TARGETS@ \ installlibtalloc \ @INSTALL_LIBSMBCLIENT@ @INSTALL_PAM_MODULES@ \ - @INSTALL_LIBSMBSHAREMODES@ @INSTALL_LIBWBCLIENT@ @INSTALL_LIBNETAPI@ + @INSTALL_LIBSMBSHAREMODES@ @INSTALL_LIBWBCLIENT@ installlibnetapi install-everything: install installmodules @@ -1981,8 +1985,8 @@ installlibwbclient: installdirs libwbclient installlibnetapi: installdirs libnetapi @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(LIBDIR) - -$(INSTALLLIBCMD_SH) bin/libnetapi.@SHLIBEXT@ $(DESTDIR)$(LIBDIR) - -$(INSTALLLIBCMD_A) bin/libnetapi.a $(DESTDIR)$(LIBDIR) + -$(INSTALLLIBCMD_SH) $(LIBNETAPI_SHARED_TARGET) $(DESTDIR)$(LIBDIR) + -$(INSTALLLIBCMD_A) $(LIBNETAPI_STATIC_TARGET) $(DESTDIR)$(LIBDIR) -$(INSTALLCMD) -m $(INSTALLPERMS_DATA) $(srcdir)/lib/netapi/netapi.h $(DESTDIR)${prefix}/include installpammodules: $(PAM_MODULES) @@ -2019,7 +2023,7 @@ showlayout: @echo " swatdir: $(SWATDIR)" -uninstall: uninstallman uninstallservers uninstallbin @UNINSTALL_CIFSMOUNT@ @UNINSTALL_CIFSSPNEGO@ uninstallscripts uninstalldat uninstallswat uninstallmodules uninstalllibtalloc @UNINSTALL_LIBSMBCLIENT@ @UNINSTALL_PAM_MODULES@ @UNINSTALL_LIBSMBSHAREMODES@ @UNINSTALL_LIBNETAPI@ +uninstall: uninstallman uninstallservers uninstallbin @UNINSTALL_CIFSMOUNT@ @UNINSTALL_CIFSSPNEGO@ uninstallscripts uninstalldat uninstallswat uninstallmodules uninstalllibtalloc @UNINSTALL_LIBSMBCLIENT@ @UNINSTALL_PAM_MODULES@ @UNINSTALL_LIBSMBSHAREMODES@ uninstalllibnetapi uninstallman: @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(srcdir) C diff --git a/source3/configure.in b/source3/configure.in index cde3c0b76e..34b6465d45 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -354,10 +354,13 @@ AC_SUBST(INSTALL_LIBSMBSHAREMODES) AC_SUBST(UNINSTALL_LIBSMBSHAREMODES) AC_SUBST(LIBSMBSHAREMODES_SHARED) AC_SUBST(LIBSMBSHAREMODES) -AC_SUBST(INSTALL_LIBNETAPI) -AC_SUBST(UNINSTALL_LIBNETAPI) + +AC_SUBST(LIBNETAPI_SHARED_TARGET) +AC_SUBST(LIBNETAPI_STATIC_TARGET) AC_SUBST(LIBNETAPI_SHARED) -AC_SUBST(LIBNETAPI) +AC_SUBST(LIBNETAPI_STATIC) +AC_SUBST(LIBNETAPI_LIBS) + AC_SUBST(PRINT_LIBS) AC_SUBST(AUTH_LIBS) AC_SUBST(ACL_LIBS) @@ -5209,49 +5212,47 @@ fi ################################################# # should we build libnetapi? -INSTALL_LIBNETAPI= -UNINSTALL_LIBNETAPI= +LIBNETAPI_SHARED_TARGET=bin/libnetapi.$SHLIBEXT +LIBNETAPI_STATIC_TARGET=bin/libnetapi.a LIBNETAPI_SHARED= -LIBNETAPI= +LIBNETAPI_STATIC= +LIBNETAPI_LIBS= + AC_MSG_CHECKING(whether to build the libnetapi shared library) AC_ARG_WITH(libnetapi, [AS_HELP_STRING([--with-libnetapi], [Build the libnetapi shared library (default=yes if shared libs supported)])], -[ case "$withval" in - *) - AC_MSG_RESULT(no) - ;; - yes) - if test $BLDSHARED = true; then - LIBNETAPI_SHARED=bin/libnetapi.$SHLIBEXT - LIBNETAPI=libnetapi - AC_MSG_RESULT(yes) - else - enable_static=yes - AC_MSG_RESULT(no shared library support -- will supply static library) - fi - if test $enable_static = yes; then - LIBNETAPI=libnetapi - fi - INSTALL_LIBNETAPI=installlibnetapi - UNINSTALL_LIBNETAPI=uninstalllibnetapi - ;; - esac ], +[ +case "$withval" in + *) + AC_MSG_RESULT(no) + ;; + yes) + samba_cv_with_libnetapi=yes + ;; +esac +], [ # if unspecified, default is to build it if possible. - if test $BLDSHARED = true; then - LIBNETAPI_SHARED=bin/libnetapi.$SHLIBEXT - LIBNETAPI=libnetapi - AC_MSG_RESULT(yes) - else - enable_static=yes - AC_MSG_RESULT(no shared library support -- will supply static library) - fi - if test $enable_static = yes; then - LIBNETAPI=libnetapi - fi] - INSTALL_LIBNETAPI=installlibnetapi +samba_cv_with_libnetapi=yes +] ) +if test x"$samba_cv_with_libnetapi" = x"yes" -a $BLDSHARED = true; then + LIBNETAPI_SHARED=$LIBNETAPI_SHARED_TARGET + AC_MSG_RESULT(yes) + if test x"$LIB_NETAPI" = x"STATIC" ; then + LIBNETAPI_STATIC=$LIBNETAPI_STATIC_TARGET + else + LIBNETAPI_LIBS=-lnetapi + fi +else + enable_static=yes + AC_MSG_RESULT(no shared library support -- will supply static library) +fi +if test x"$enable_static" = x"yes"; then + LIBNETAPI_STATIC=$LIBNETAPI_STATIC_TARGET +fi + ################################################# # should we build libaddns? INSTALL_LIBADDNS= -- cgit From 8a8c71e08e1cabb796150c4b25bce22264a6cdb1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 13 Feb 2008 15:10:53 +0100 Subject: Use --with-static-libs=libtalloc instead of --with-static-libs=talloc for consistency (and similar for all other examples). Michael (This used to be commit 198768a83242cca3f03d839598200d794bb11606) --- source3/configure.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 34b6465d45..a22979e104 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -5146,7 +5146,7 @@ fi # appears in the --with-static-libs configure option. # # Example: -# --with-static-libs=talloc makes use of libtalloc.a instead +# --with-static-libs=libtalloc makes use of libtalloc.a instead # of linking the dynamic variant with -ltalloc. # # NOTE: This option only affects libraries that we do not only build @@ -5161,7 +5161,7 @@ AC_ARG_WITH([static-libs], [AS_IF([test $withval], [for lib in `echo $withval | sed -e 's/,/ /g'` ; do [lib=`echo $lib | tr '[a-z]' '[A-Z]'`] - eval LIB_$lib=STATIC + eval LINK_$lib=STATIC done], [])], []) @@ -5196,7 +5196,7 @@ samba_cv_with_libtalloc=yes if test x"$samba_cv_with_libtalloc" = "xyes" -a $BLDSHARED = true; then LIBTALLOC_SHARED=$LIBTALLOC_SHARED_TARGET AC_MSG_RESULT(yes) - if test x"$LIB_TALLOC" = "xSTATIC" ; then + if test x"$LINK_LIBTALLOC" = "xSTATIC" ; then LIBTALLOC_STATIC=$LIBTALLOC_STATIC_TARGET else LIBTALLOC_LIBS=-ltalloc @@ -5240,7 +5240,7 @@ samba_cv_with_libnetapi=yes if test x"$samba_cv_with_libnetapi" = x"yes" -a $BLDSHARED = true; then LIBNETAPI_SHARED=$LIBNETAPI_SHARED_TARGET AC_MSG_RESULT(yes) - if test x"$LIB_NETAPI" = x"STATIC" ; then + if test x"$LINK_LIBNETAPI" = x"STATIC" ; then LIBNETAPI_STATIC=$LIBNETAPI_STATIC_TARGET else LIBNETAPI_LIBS=-lnetapi -- cgit From adcbc2439cb33ca1ebaa4fdaf6e8c49af67a1d5a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 13 Feb 2008 14:53:34 +0100 Subject: Remove --enable-libwbclient-shared , use --with-static-libs=libwbclient instead. Use the more general mechanism. The enable_developer-check is preserved, of course. Michael (This used to be commit 4321d5aba7ec808aee473c1123027f14bfa19f19) --- source3/configure.in | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index a22979e104..9b3f5b9e3a 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -6272,13 +6272,11 @@ if test x"$HAVE_WINBIND" = x"no"; then WINBIND_WINS_NSS="" fi -BUILD_LIBWBCLIENT_SHARED=yes - -AC_ARG_ENABLE(libwbclient-shared, -[AS_HELP_STRING([--enable-libwbclient-shared], [Build libwbclient as shared object (default=yes, \"no\" only for --enable-developer)])], - [if eval "test x$enable_developer = xyes -a x$enable_libwbclient_shared = xno" ; then - BUILD_LIBWBCLIENT_SHARED=no - fi]) +if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then + BUILD_LIBWBCLIENT_SHARED=no +else + BUILD_LIBWBCLIENT_SHARED=yes +fi if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}" -- cgit From 354a99eee18d937a18c2ea6a1b63edce68f9a7ce Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 16:46:23 +0100 Subject: Fix IDL for netr_ServerPasswordSet. Guenther (This used to be commit da951e278c5253b0d23145790c817b2f01ac47ef) --- source3/librpc/idl/netlogon.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index 25118bc816..7f977a454b 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -298,9 +298,9 @@ interface netlogon [in] [string,charset(UTF16)] uint16 account_name[], [in] netr_SchannelType secure_channel_type, [in] [string,charset(UTF16)] uint16 computer_name[], - [in] netr_Authenticator credential, - [in] samr_Password new_password, - [out,ref] netr_Authenticator *return_authenticator + [in,ref] netr_Authenticator *credential, + [out,ref] netr_Authenticator *return_authenticator, + [in,ref] samr_Password *new_password ); -- cgit From a15db9cadaedd000687a9dab1b027f0093f764a7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 23:00:36 +0100 Subject: Re-run make idl. Guenther (This used to be commit a111167062f0bee9477b5988a3ce796af81407fc) --- source3/librpc/gen_ndr/cli_netlogon.c | 6 +++--- source3/librpc/gen_ndr/cli_netlogon.h | 6 +++--- source3/librpc/gen_ndr/ndr_netlogon.c | 38 +++++++++++++++++++++++++++++------ source3/librpc/gen_ndr/netlogon.h | 4 ++-- 4 files changed, 40 insertions(+), 14 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_netlogon.c b/source3/librpc/gen_ndr/cli_netlogon.c index f355856fd5..7efcae2c56 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.c +++ b/source3/librpc/gen_ndr/cli_netlogon.c @@ -314,9 +314,9 @@ NTSTATUS rpccli_netr_ServerPasswordSet(struct rpc_pipe_client *cli, const char *account_name, enum netr_SchannelType secure_channel_type, const char *computer_name, - struct netr_Authenticator credential, - struct samr_Password new_password, - struct netr_Authenticator *return_authenticator) + struct netr_Authenticator *credential, + struct netr_Authenticator *return_authenticator, + struct samr_Password *new_password) { struct netr_ServerPasswordSet r; NTSTATUS status; diff --git a/source3/librpc/gen_ndr/cli_netlogon.h b/source3/librpc/gen_ndr/cli_netlogon.h index 0b6ed869c5..f07c429224 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.h +++ b/source3/librpc/gen_ndr/cli_netlogon.h @@ -52,9 +52,9 @@ NTSTATUS rpccli_netr_ServerPasswordSet(struct rpc_pipe_client *cli, const char *account_name, enum netr_SchannelType secure_channel_type, const char *computer_name, - struct netr_Authenticator credential, - struct samr_Password new_password, - struct netr_Authenticator *return_authenticator); + struct netr_Authenticator *credential, + struct netr_Authenticator *return_authenticator, + struct samr_Password *new_password); NTSTATUS rpccli_netr_DatabaseDeltas(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *logon_server, diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index 624c9acc69..d31e19a9cc 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -8864,8 +8864,14 @@ static enum ndr_err_code ndr_push_netr_ServerPasswordSet(struct ndr_push *ndr, i NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.computer_name, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.computer_name, ndr_charset_length(r->in.computer_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); - NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, &r->in.credential)); - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.new_password)); + if (r->in.credential == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, r->in.credential)); + if (r->in.new_password == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.new_password)); } if (flags & NDR_OUT) { if (r->out.return_authenticator == NULL) { @@ -8881,7 +8887,9 @@ static enum ndr_err_code ndr_pull_netr_ServerPasswordSet(struct ndr_pull *ndr, i { uint32_t _ptr_server_name; TALLOC_CTX *_mem_save_server_name_0; + TALLOC_CTX *_mem_save_credential_0; TALLOC_CTX *_mem_save_return_authenticator_0; + TALLOC_CTX *_mem_save_new_password_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -8918,8 +8926,20 @@ static enum ndr_err_code ndr_pull_netr_ServerPasswordSet(struct ndr_pull *ndr, i } NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.computer_name), sizeof(uint16_t))); NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.computer_name, ndr_get_array_length(ndr, &r->in.computer_name), sizeof(uint16_t), CH_UTF16)); - NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, &r->in.credential)); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.new_password)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.credential); + } + _mem_save_credential_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.credential, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, r->in.credential)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_credential_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.new_password); + } + _mem_save_new_password_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.new_password, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.new_password)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_new_password_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.return_authenticator); ZERO_STRUCTP(r->out.return_authenticator); } @@ -8955,8 +8975,14 @@ _PUBLIC_ void ndr_print_netr_ServerPasswordSet(struct ndr_print *ndr, const char ndr_print_string(ndr, "account_name", r->in.account_name); ndr_print_netr_SchannelType(ndr, "secure_channel_type", r->in.secure_channel_type); ndr_print_string(ndr, "computer_name", r->in.computer_name); - ndr_print_netr_Authenticator(ndr, "credential", &r->in.credential); - ndr_print_samr_Password(ndr, "new_password", &r->in.new_password); + ndr_print_ptr(ndr, "credential", r->in.credential); + ndr->depth++; + ndr_print_netr_Authenticator(ndr, "credential", r->in.credential); + ndr->depth--; + ndr_print_ptr(ndr, "new_password", r->in.new_password); + ndr->depth++; + ndr_print_samr_Password(ndr, "new_password", r->in.new_password); + ndr->depth--; ndr->depth--; } if (flags & NDR_OUT) { diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index 36380f1498..97089d45f7 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -920,8 +920,8 @@ struct netr_ServerPasswordSet { const char *account_name;/* [charset(UTF16)] */ enum netr_SchannelType secure_channel_type; const char *computer_name;/* [charset(UTF16)] */ - struct netr_Authenticator credential; - struct samr_Password new_password; + struct netr_Authenticator *credential;/* [ref] */ + struct samr_Password *new_password;/* [ref] */ } in; struct { -- cgit From 834fa856dae7c2a7d802fce55621055417946f16 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 17:57:57 +0100 Subject: Move some lsa init routines around. Guenther (This used to be commit 8d3e7e8bb067b9e0aab79bc460647e8a6176102e) --- source3/rpc_client/init_lsa.c | 40 ++++++++++++++++++++++++++++++++++++++++ source3/rpc_parse/parse_lsa.c | 40 ---------------------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/init_lsa.c b/source3/rpc_client/init_lsa.c index 0af85c0373..114e435945 100644 --- a/source3/rpc_client/init_lsa.c +++ b/source3/rpc_client/init_lsa.c @@ -46,3 +46,43 @@ void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s) name->string = s; } +/******************************************************************* + Inits an lsa_QosInfo structure. +********************************************************************/ + +void init_lsa_sec_qos(struct lsa_QosInfo *r, + uint32_t len, + uint16_t impersonation_level, + uint8_t context_mode, + uint8_t effective_only) +{ + DEBUG(5, ("init_lsa_sec_qos\n")); + + r->len = len; + r->impersonation_level = impersonation_level; + r->context_mode = context_mode; + r->effective_only = effective_only; +} + +/******************************************************************* + Inits an lsa_ObjectAttribute structure. +********************************************************************/ + +void init_lsa_obj_attr(struct lsa_ObjectAttribute *r, + uint32_t len, + uint8_t *root_dir, + const char *object_name, + uint32_t attributes, + struct security_descriptor *sec_desc, + struct lsa_QosInfo *sec_qos) +{ + DEBUG(5,("init_lsa_obj_attr\n")); + + r->len = len; + r->root_dir = root_dir; + r->object_name = object_name; + r->attributes = attributes; + r->sec_desc = sec_desc; + r->sec_qos = sec_qos; +} + diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index c4a7c057a6..b8a0b03273 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -175,46 +175,6 @@ static bool lsa_io_dom_r_ref(const char *desc, DOM_R_REF *dom, prs_struct *ps, i return True; } -/******************************************************************* - Inits an lsa_QosInfo structure. -********************************************************************/ - -void init_lsa_sec_qos(struct lsa_QosInfo *r, - uint32_t len, - uint16_t impersonation_level, - uint8_t context_mode, - uint8_t effective_only) -{ - DEBUG(5, ("init_lsa_sec_qos\n")); - - r->len = len; - r->impersonation_level = impersonation_level; - r->context_mode = context_mode; - r->effective_only = effective_only; -} - -/******************************************************************* - Inits an lsa_ObjectAttribute structure. -********************************************************************/ - -void init_lsa_obj_attr(struct lsa_ObjectAttribute *r, - uint32_t len, - uint8_t *root_dir, - const char *object_name, - uint32_t attributes, - struct security_descriptor *sec_desc, - struct lsa_QosInfo *sec_qos) -{ - DEBUG(5,("init_lsa_obj_attr\n")); - - r->len = len; - r->root_dir = root_dir; - r->object_name = object_name; - r->attributes = attributes; - r->sec_desc = sec_desc; - r->sec_qos = sec_qos; -} - /******************************************************************* Inits a LSA_SID_ENUM structure. ********************************************************************/ -- cgit From 6f05330e4a831058d02506d04f89b8cc10fa238b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 22:54:43 +0100 Subject: Fix logonctrl2 command in rpcclient. Guenther (This used to be commit c58be24cd43092e5ebf7aa84f167a5cc8344edfc) --- source3/rpcclient/cmd_netlogon.c | 70 +++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index b1753575f5..0efee845f4 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -21,27 +21,68 @@ #include "includes.h" #include "rpcclient.h" -static NTSTATUS cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { - uint32 query_level = 1; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr; + const char *logon_server = cli->cli->desthost; + enum netr_LogonControlCode function_code = NETLOGON_CONTROL_REDISCOVER; + uint32_t level = 1; + union netr_CONTROL_DATA_INFORMATION data; + union netr_CONTROL_QUERY_INFORMATION query; + const char *domain = "BER"; - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", argv[0]); - return NT_STATUS_OK; + if (argc > 5) { + fprintf(stderr, "Usage: %s " + " \n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + logon_server = argv[1]; } - result = rpccli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); + if (argc >= 3) { + function_code = atoi(argv[2]); + } - if (!NT_STATUS_IS_OK(result)) - goto done; + if (argc >= 4) { + level = atoi(argv[3]); + } + + if (argc >= 5) { + domain = argv[4]; + } + + switch (function_code) { + case NETLOGON_CONTROL_REDISCOVER: + case NETLOGON_CONTROL_TC_QUERY: + data.domain = domain; + break; + default: + break; + } + + status = rpccli_netr_LogonControl2(cli, mem_ctx, + logon_server, + function_code, + level, + &data, + &query, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; + } /* Display results */ - done: - return result; + return werr; } static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, @@ -859,14 +900,13 @@ static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli, } - /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, + { "logonctrl2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl2, PI_NETLOGON, NULL, "Logon Control 2", "" }, { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, -- cgit From 3722208ddff6386ff93d8445337442569710ff23 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 22:55:44 +0100 Subject: Add some netr_NETLOGON_INFO init functions. Guenther (This used to be commit f0c66688588a4e62c4a250b0d21a0fe14bbc5099) --- source3/rpc_server/srv_netlog_nt.c | 46 +++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index acf694b128..2c52ba87af 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -42,6 +42,46 @@ static void init_net_r_req_chal(struct netr_Credential *r, memcpy(r->data, srv_chal->data, sizeof(r->data)); } +/******************************************************************* + Inits a netr_NETLOGON_INFO_1 structure. +********************************************************************/ + +static void init_netlogon_info1(struct netr_NETLOGON_INFO_1 *r, + uint32_t flags, + uint32_t pdc_connection_status) +{ + r->flags = flags; + r->pdc_connection_status = pdc_connection_status; +} + +/******************************************************************* + Inits a netr_NETLOGON_INFO_2 structure. +********************************************************************/ + +static void init_netlogon_info2(struct netr_NETLOGON_INFO_2 *r, + uint32_t flags, + uint32_t pdc_connection_status, + const char *trusted_dc_name, + uint32_t tc_connection_status) +{ + r->flags = flags; + r->pdc_connection_status = pdc_connection_status; + r->trusted_dc_name = trusted_dc_name; + r->tc_connection_status = tc_connection_status; +} + +/******************************************************************* + Inits a netr_NETLOGON_INFO_3 structure. +********************************************************************/ + +static void init_netlogon_info3(struct netr_NETLOGON_INFO_3 *r, + uint32_t flags, + uint32_t logon_attempts) +{ + r->flags = flags; + r->logon_attempts = logon_attempts; +} + /************************************************************************* _netr_LogonControl *************************************************************************/ @@ -61,9 +101,9 @@ WERROR _netr_LogonControl(pipes_struct *p, if (!info1) { return WERR_NOMEM; } - info1->flags = flags; - info1->pdc_connection_status = pdc_connection_status; - + init_netlogon_info1(info1, + flags, + pdc_connection_status); r->out.info->info1 = info1; break; default: -- cgit From 7acdc9e8d6a6311983e1d3f19047293e47f92722 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 23:06:09 +0100 Subject: Use pidl for _netr_LogonControl2. Guenther (This used to be commit 4bd02aa6cdfdfd8f3b678fc81a0a1bd70cef9a67) --- source3/rpc_server/srv_netlog.c | 24 +----------- source3/rpc_server/srv_netlog_nt.c | 77 +++++++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 50 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 1b23cd835a..791752c5d0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -226,29 +226,7 @@ static bool api_net_trust_dom_list(pipes_struct *p) static bool api_net_logon_ctrl2(pipes_struct *p) { - NET_Q_LOGON_CTRL2 q_u; - NET_R_LOGON_CTRL2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - - /* grab the lsa netlogon ctrl2 query... */ - if(!net_io_q_logon_ctrl2("", &q_u, data, 0)) { - DEBUG(0,("api_net_logon_ctrl2: Failed to unmarshall NET_Q_LOGON_CTRL2.\n")); - return False; - } - - r_u.status = _net_logon_ctrl2(p, &q_u, &r_u); - - if(!net_io_r_logon_ctrl2("", &r_u, rdata, 0)) { - DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONCONTROL2); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2c52ba87af..3cfab7843d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -125,29 +125,29 @@ static void send_sync_message(void) } /************************************************************************* - net_reply_logon_ctrl2: + _netr_LogonControl2 *************************************************************************/ -NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTRL2 *r_u) +WERROR _netr_LogonControl2(pipes_struct *p, + struct netr_LogonControl2 *r) { uint32 flags = 0x0; uint32 pdc_connection_status = 0x0; uint32 logon_attempts = 0x0; uint32 tc_status; - fstring servername, domain, dc_name, dc_name2; + fstring dc_name, dc_name2; struct sockaddr_storage dc_ss; - - /* this should be \\global_myname() */ - unistr2_to_ascii(servername, &q_u->uni_server_name, sizeof(servername)); - - r_u->status = NT_STATUS_OK; + const char *domain = NULL; + struct netr_NETLOGON_INFO_1 *info1; + struct netr_NETLOGON_INFO_2 *info2; + struct netr_NETLOGON_INFO_3 *info3; tc_status = W_ERROR_V(WERR_NO_SUCH_DOMAIN); fstrcpy( dc_name, "" ); - switch ( q_u->function_code ) { + switch (r->in.function_code) { case NETLOGON_CONTROL_TC_QUERY: - unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); + domain = r->in.data->domain; if ( !is_trusted_domain( domain ) ) break; @@ -164,7 +164,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C break; case NETLOGON_CONTROL_REDISCOVER: - unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); + domain = r->in.data->domain; if ( !is_trusted_domain( domain ) ) break; @@ -182,19 +182,52 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C default: /* no idea what this should be */ - DEBUG(0,("_net_logon_ctrl2: unimplemented function level [%d]\n", - q_u->function_code)); + DEBUG(0,("_netr_LogonControl2: unimplemented function level [%d]\n", + r->in.function_code)); + return WERR_UNKNOWN_LEVEL; } /* prepare the response */ - init_net_r_logon_ctrl2( r_u, q_u->query_level, flags, - pdc_connection_status, logon_attempts, tc_status, dc_name ); + switch (r->in.level) { + case 1: + info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1); + W_ERROR_HAVE_NO_MEMORY(info1); - if (lp_server_role() == ROLE_DOMAIN_BDC) + init_netlogon_info1(info1, + flags, + pdc_connection_status); + r->out.query->info1 = info1; + break; + case 2: + info2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_2); + W_ERROR_HAVE_NO_MEMORY(info2); + + init_netlogon_info2(info2, + flags, + pdc_connection_status, + dc_name, + tc_status); + r->out.query->info2 = info2; + break; + case 3: + info3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_3); + W_ERROR_HAVE_NO_MEMORY(info3); + + init_netlogon_info3(info3, + flags, + logon_attempts); + r->out.query->info3 = info3; + break; + default: + return WERR_UNKNOWN_LEVEL; + } + + if (lp_server_role() == ROLE_DOMAIN_BDC) { send_sync_message(); + } - return r_u->status; + return WERR_OK; } /************************************************************************* @@ -1320,16 +1353,6 @@ WERROR _netr_GetAnyDCName(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _netr_LogonControl2(pipes_struct *p, - struct netr_LogonControl2 *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, struct netr_ServerAuthenticate2 *r) { -- cgit From d134bd3c27ba3317e323a2c37d43f80c0ec58cbc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 23:12:42 +0100 Subject: Remove unused marshalling for NET_LOGON_CTRL and NET_LOGON_CTRL2. Guenther (This used to be commit c94538e742e469e4afc6e30d9d99951fda6dd219) --- source3/include/rpc_netlogon.h | 81 ------- source3/rpc_client/cli_netlogon.c | 32 --- source3/rpc_parse/parse_net.c | 432 -------------------------------------- 3 files changed, 545 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index f2802b8e72..f8c9fc5c7f 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -317,87 +317,6 @@ typedef struct netlogon_3_info { ********************************************************/ -/* NET_Q_LOGON_CTRL - LSA Netr Logon Control */ - -typedef struct net_q_logon_ctrl_info { - uint32 ptr; - UNISTR2 uni_server_name; - uint32 function_code; - uint32 query_level; -} NET_Q_LOGON_CTRL; - -/* NET_R_LOGON_CTRL - LSA Netr Logon Control */ - -typedef struct net_r_logon_ctrl_info { - uint32 switch_value; - uint32 ptr; - - union { - NETLOGON_INFO_1 info1; - } logon; - - NTSTATUS status; -} NET_R_LOGON_CTRL; - - -typedef struct ctrl_data_info_5 { - uint32 function_code; - - uint32 ptr_domain; - UNISTR2 domain; -} CTRL_DATA_INFO_5; - -typedef struct ctrl_data_info_6 { - uint32 function_code; - - uint32 ptr_domain; - UNISTR2 domain; -} CTRL_DATA_INFO_6; - - -/******************************************************** - Logon Control2 Query - - query_level 0x1 - pdc status - query_level 0x3 - number of logon attempts. - - ********************************************************/ - -/* NET_Q_LOGON_CTRL2 - LSA Netr Logon Control 2 */ -typedef struct net_q_logon_ctrl2_info { - uint32 ptr; /* undocumented buffer pointer */ - UNISTR2 uni_server_name; /* server name, starting with two '\'s */ - - uint32 function_code; - uint32 query_level; - union { - CTRL_DATA_INFO_5 info5; - CTRL_DATA_INFO_6 info6; - } info; -} NET_Q_LOGON_CTRL2; - -/******************************************************* - Logon Control Response - - switch_value is same as query_level in request - *******************************************************/ - -/* NET_R_LOGON_CTRL2 - response to LSA Logon Control2 */ -typedef struct net_r_logon_ctrl2_info { - uint32 switch_value; /* 0x1, 0x3 */ - uint32 ptr; - - union - { - NETLOGON_INFO_1 info1; - NETLOGON_INFO_2 info2; - NETLOGON_INFO_3 info3; - - } logon; - - NTSTATUS status; /* return code */ -} NET_R_LOGON_CTRL2; - /* NEG_FLAGS */ typedef struct neg_flags_info { uint32 neg_flags; /* negotiated flags */ diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index a6167bb851..d28df3c164 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -347,38 +347,6 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli, return NT_STATUS_OK; } -/* Logon Control 2 */ - -NTSTATUS rpccli_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - uint32 query_level) -{ - prs_struct qbuf, rbuf; - NET_Q_LOGON_CTRL2 q; - NET_R_LOGON_CTRL2 r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - fstring server; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialise input parameters */ - - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); - init_net_q_logon_ctrl2(&q, server, query_level); - - /* Marshall data and send request */ - - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_LOGON_CTRL2, - q, r, - qbuf, rbuf, - net_io_q_logon_ctrl2, - net_io_r_logon_ctrl2, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - return result; -} - /* Sam synchronisation */ NTSTATUS rpccli_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index 257f461d7c..8105ac5470 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -46,438 +46,6 @@ static bool net_io_neg_flags(const char *desc, NEG_FLAGS *neg, prs_struct *ps, i return True; } -/******************************************************************* - Inits a NETLOGON_INFO_3 structure. -********************************************************************/ - -static void init_netinfo_3(NETLOGON_INFO_3 *info, uint32 flags, uint32 logon_attempts) -{ - info->flags = flags; - info->logon_attempts = logon_attempts; - info->reserved_1 = 0x0; - info->reserved_2 = 0x0; - info->reserved_3 = 0x0; - info->reserved_4 = 0x0; - info->reserved_5 = 0x0; -} - -/******************************************************************* - Reads or writes a NETLOGON_INFO_3 structure. -********************************************************************/ - -static bool net_io_netinfo_3(const char *desc, NETLOGON_INFO_3 *info, prs_struct *ps, int depth) -{ - if (info == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_netinfo_3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &info->flags)) - return False; - if(!prs_uint32("logon_attempts", ps, depth, &info->logon_attempts)) - return False; - if(!prs_uint32("reserved_1 ", ps, depth, &info->reserved_1)) - return False; - if(!prs_uint32("reserved_2 ", ps, depth, &info->reserved_2)) - return False; - if(!prs_uint32("reserved_3 ", ps, depth, &info->reserved_3)) - return False; - if(!prs_uint32("reserved_4 ", ps, depth, &info->reserved_4)) - return False; - if(!prs_uint32("reserved_5 ", ps, depth, &info->reserved_5)) - return False; - - return True; -} - - -/******************************************************************* - Inits a NETLOGON_INFO_1 structure. -********************************************************************/ - -static void init_netinfo_1(NETLOGON_INFO_1 *info, uint32 flags, uint32 pdc_status) -{ - info->flags = flags; - info->pdc_status = pdc_status; -} - -/******************************************************************* - Reads or writes a NETLOGON_INFO_1 structure. -********************************************************************/ - -static bool net_io_netinfo_1(const char *desc, NETLOGON_INFO_1 *info, prs_struct *ps, int depth) -{ - if (info == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_netinfo_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &info->flags)) - return False; - if(!prs_uint32("pdc_status", ps, depth, &info->pdc_status)) - return False; - - return True; -} - -/******************************************************************* - Inits a NETLOGON_INFO_2 structure. -********************************************************************/ - -static void init_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status, - uint32 tc_status, const char *trusted_dc_name) -{ - info->flags = flags; - info->pdc_status = pdc_status; - info->ptr_trusted_dc_name = 1; - info->tc_status = tc_status; - - if (trusted_dc_name != NULL) - init_unistr2(&info->uni_trusted_dc_name, trusted_dc_name, UNI_STR_TERMINATE); - else - init_unistr2(&info->uni_trusted_dc_name, "", UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a NETLOGON_INFO_2 structure. -********************************************************************/ - -static bool net_io_netinfo_2(const char *desc, NETLOGON_INFO_2 *info, prs_struct *ps, int depth) -{ - if (info == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_netinfo_2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &info->flags)) - return False; - if(!prs_uint32("pdc_status ", ps, depth, &info->pdc_status)) - return False; - if(!prs_uint32("ptr_trusted_dc_name", ps, depth, &info->ptr_trusted_dc_name)) - return False; - if(!prs_uint32("tc_status ", ps, depth, &info->tc_status)) - return False; - - if (info->ptr_trusted_dc_name != 0) { - if(!smb_io_unistr2("unistr2", &info->uni_trusted_dc_name, info->ptr_trusted_dc_name, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - return True; -} - -static bool net_io_ctrl_data_info_5(const char *desc, CTRL_DATA_INFO_5 *info, prs_struct *ps, int depth) -{ - if (info == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_ctrl_data_info_5"); - depth++; - - if ( !prs_uint32( "function_code", ps, depth, &info->function_code ) ) - return False; - - if(!prs_uint32("ptr_domain", ps, depth, &info->ptr_domain)) - return False; - - if ( info->ptr_domain ) { - if(!smb_io_unistr2("domain", &info->domain, info->ptr_domain, ps, depth)) - return False; - } - - return True; -} - -static bool net_io_ctrl_data_info_6(const char *desc, CTRL_DATA_INFO_6 *info, prs_struct *ps, int depth) -{ - if (info == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_ctrl_data_info_6"); - depth++; - - if ( !prs_uint32( "function_code", ps, depth, &info->function_code ) ) - return False; - - if(!prs_uint32("ptr_domain", ps, depth, &info->ptr_domain)) - return False; - - if ( info->ptr_domain ) { - if(!smb_io_unistr2("domain", &info->domain, info->ptr_domain, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes an NET_Q_LOGON_CTRL2 structure. -********************************************************************/ - -bool net_io_q_logon_ctrl2(const char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, int depth) -{ - if (q_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_logon_ctrl2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &q_l->ptr)) - return False; - - if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("function_code", ps, depth, &q_l->function_code)) - return False; - if(!prs_uint32("query_level ", ps, depth, &q_l->query_level)) - return False; - switch ( q_l->function_code ) { - case NETLOGON_CONTROL_REDISCOVER: - if ( !net_io_ctrl_data_info_5( "ctrl_data_info5", &q_l->info.info5, ps, depth) ) - return False; - break; - - case NETLOGON_CONTROL_TC_QUERY: - if ( !net_io_ctrl_data_info_6( "ctrl_data_info6", &q_l->info.info6, ps, depth) ) - return False; - break; - - default: - DEBUG(0,("net_io_q_logon_ctrl2: unknown function_code [%d]\n", - q_l->function_code)); - return False; - } - - return True; -} - -/******************************************************************* - Inits an NET_Q_LOGON_CTRL2 structure. -********************************************************************/ - -void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, const char *srv_name, - uint32 query_level) -{ - DEBUG(5,("init_q_logon_ctrl2\n")); - - q_l->function_code = 0x01; - q_l->query_level = query_level; - - init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE); -} - -/******************************************************************* - Inits an NET_R_LOGON_CTRL2 structure. -********************************************************************/ - -void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level, - uint32 flags, uint32 pdc_status, - uint32 logon_attempts, uint32 tc_status, - const char *trusted_domain_name) -{ - r_l->switch_value = query_level; - - switch (query_level) { - case 1: - r_l->ptr = 1; /* undocumented pointer */ - init_netinfo_1(&r_l->logon.info1, flags, pdc_status); - r_l->status = NT_STATUS_OK; - break; - case 2: - r_l->ptr = 1; /* undocumented pointer */ - init_netinfo_2(&r_l->logon.info2, flags, pdc_status, - tc_status, trusted_domain_name); - r_l->status = NT_STATUS_OK; - break; - case 3: - r_l->ptr = 1; /* undocumented pointer */ - init_netinfo_3(&r_l->logon.info3, flags, logon_attempts); - r_l->status = NT_STATUS_OK; - break; - default: - DEBUG(2,("init_r_logon_ctrl2: unsupported switch value %d\n", - r_l->switch_value)); - r_l->ptr = 0; /* undocumented pointer */ - - /* take a guess at an error code... */ - r_l->status = NT_STATUS_INVALID_INFO_CLASS; - break; - } -} - -/******************************************************************* - Reads or writes an NET_R_LOGON_CTRL2 structure. -********************************************************************/ - -bool net_io_r_logon_ctrl2(const char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, int depth) -{ - if (r_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_logon_ctrl2"); - depth++; - - if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value)) - return False; - if(!prs_uint32("ptr ", ps, depth, &r_l->ptr)) - return False; - - if (r_l->ptr != 0) { - switch (r_l->switch_value) { - case 1: - if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth)) - return False; - break; - case 2: - if(!net_io_netinfo_2("", &r_l->logon.info2, ps, depth)) - return False; - break; - case 3: - if(!net_io_netinfo_3("", &r_l->logon.info3, ps, depth)) - return False; - break; - default: - DEBUG(2,("net_io_r_logon_ctrl2: unsupported switch value %d\n", - r_l->switch_value)); - break; - } - } - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an NET_Q_LOGON_CTRL structure. -********************************************************************/ - -bool net_io_q_logon_ctrl(const char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "net_io_q_logon_ctrl"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &q_l->ptr)) - return False; - - if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("function_code", ps, depth, &q_l->function_code)) - return False; - if(!prs_uint32("query_level ", ps, depth, &q_l->query_level)) - return False; - - return True; -} - -/******************************************************************* - Inits an NET_Q_LOGON_CTRL structure. -********************************************************************/ - -void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, const char *srv_name, - uint32 query_level) -{ - DEBUG(5,("init_q_logon_ctrl\n")); - - q_l->function_code = 0x01; /* ??? */ - q_l->query_level = query_level; - - init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE); -} - -/******************************************************************* - Inits an NET_R_LOGON_CTRL structure. -********************************************************************/ - -void init_net_r_logon_ctrl(NET_R_LOGON_CTRL *r_l, uint32 query_level, - uint32 flags, uint32 pdc_status) -{ - DEBUG(5,("init_r_logon_ctrl\n")); - - r_l->switch_value = query_level; /* should only be 0x1 */ - - switch (query_level) { - case 1: - r_l->ptr = 1; /* undocumented pointer */ - init_netinfo_1(&r_l->logon.info1, flags, pdc_status); - r_l->status = NT_STATUS_OK; - break; - default: - DEBUG(2,("init_r_logon_ctrl: unsupported switch value %d\n", - r_l->switch_value)); - r_l->ptr = 0; /* undocumented pointer */ - - /* take a guess at an error code... */ - r_l->status = NT_STATUS_INVALID_INFO_CLASS; - break; - } -} - -/******************************************************************* - Reads or writes an NET_R_LOGON_CTRL structure. -********************************************************************/ - -bool net_io_r_logon_ctrl(const char *desc, NET_R_LOGON_CTRL *r_l, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "net_io_r_logon_ctrl"); - depth++; - - if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value)) - return False; - if(!prs_uint32("ptr ", ps, depth, &r_l->ptr)) - return False; - - if (r_l->ptr != 0) { - switch (r_l->switch_value) { - case 1: - if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth)) - return False; - break; - default: - DEBUG(2,("net_io_r_logon_ctrl: unsupported switch value %d\n", - r_l->switch_value)); - break; - } - } - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - return True; -} - /******************************************************************* Inits an NET_Q_REQ_CHAL structure. ********************************************************************/ -- cgit From f292f3de3fc2f9afaa9fdf1f6d894e8fc5e01dd4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 14 Feb 2008 00:09:17 +0100 Subject: Try and fix the Darwin build with dynamic libs. Golly gosh, this one took me quite some time to figure out! Hopefully, I did not introduce any typos copying... Michael (This used to be commit 85ca2c9edb9ac54d3fa18d6b343a73dda1d48040) --- source3/configure.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 9b3f5b9e3a..25f52e484a 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1974,7 +1974,9 @@ DSO_EXPORTS="" *darwin*) AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX]) BLDSHARED="true" - LDSHFLAGS="-bundle -flat_namespace -undefined suppress" + LDSHFLAGS="-dynamiclib -flat_namespace -undefined suppress" + CFLAGS="$CFLAGS -fno-common" + SHLD="\${CC}" SHLIBEXT="dylib" MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms" SHLIBEXT="dylib" -- cgit From 0b4dbfebaa64766829fc36866fe44c18a19b6a3d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:08:40 +0100 Subject: Fix IDL for lsa_EnumAccounts. Guenther (This used to be commit d4744fe33fa99152f414e6e3a048eb9479f3d2b2) --- source3/librpc/idl/lsa.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 305bab3d03..6eb96a8b26 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -297,9 +297,9 @@ import "security.idl"; [public] NTSTATUS lsa_EnumAccounts ( [in] policy_handle *handle, - [in,out] uint32 *resume_handle, - [in,range(0,8192)] uint32 num_entries, - [out] lsa_SidArray *sids + [in,out,ref] uint32 *resume_handle, + [out,ref] lsa_SidArray *sids, + [in,range(0,8192)] uint32 num_entries ); -- cgit From f14ff502d87182ab5bbb182a460b47f90d7295e3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:07:54 +0100 Subject: Re-run make idl. Guenther (This used to be commit debf51aa966d1f243894d458069346a60c76714b) --- source3/librpc/gen_ndr/cli_lsa.c | 4 ++-- source3/librpc/gen_ndr/cli_lsa.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 27ed572a19..5b277ca50c 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -471,8 +471,8 @@ NTSTATUS rpccli_lsa_EnumAccounts(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t *resume_handle, - uint32_t num_entries, - struct lsa_SidArray *sids) + struct lsa_SidArray *sids, + uint32_t num_entries) { struct lsa_EnumAccounts r; NTSTATUS status; diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index ddcd161413..3e1a8445f1 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -53,8 +53,8 @@ NTSTATUS rpccli_lsa_EnumAccounts(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t *resume_handle, - uint32_t num_entries, - struct lsa_SidArray *sids); + struct lsa_SidArray *sids, + uint32_t num_entries); NTSTATUS rpccli_lsa_CreateTrustedDomain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, -- cgit From 0460295c1fe1c3103bbe03d6ca5a8028d79f1704 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:16:03 +0100 Subject: Use pidl for _lsa_EnumAccounts. Guenther (This used to be commit 07e5138ad960bce8569ea593ca9a1b4fbf2b1048) --- source3/rpc_server/srv_lsa.c | 23 +------------------ source3/rpc_server/srv_lsa_nt.c | 50 ++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 48 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index f48a397f1d..a3fe00cced 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -185,28 +185,7 @@ static bool api_lsa_priv_get_dispname(pipes_struct *p) static bool api_lsa_enum_accounts(pipes_struct *p) { - LSA_Q_ENUM_ACCOUNTS q_u; - LSA_R_ENUM_ACCOUNTS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n")); - return False; - } - - r_u.status = _lsa_enum_accounts(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ENUMACCOUNTS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 3cf83962ee..097b50504f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1519,18 +1519,19 @@ NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, } /*************************************************************************** -_lsa_enum_accounts. + _lsa_EnumAccounts ***************************************************************************/ -NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u) +NTSTATUS _lsa_EnumAccounts(pipes_struct *p, + struct lsa_EnumAccounts *r) { struct lsa_info *handle; DOM_SID *sid_list; int i, j, num_entries; - LSA_SID_ENUM *sids=&r_u->sids; - NTSTATUS ret; + NTSTATUS status; + struct lsa_SidPtr *sids = NULL; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) @@ -1542,34 +1543,37 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU /* The only way we can currently find out all the SIDs that have been privileged is to scan all privileges */ - if (!NT_STATUS_IS_OK(ret = privilege_enumerate_accounts(&sid_list, &num_entries))) { - return ret; + status = privilege_enumerate_accounts(&sid_list, &num_entries); + if (!NT_STATUS_IS_OK(status)) { + return status; } - if (q_u->enum_context >= num_entries) + if (*r->in.resume_handle >= num_entries) { return NT_STATUS_NO_MORE_ENTRIES; + } - if (num_entries-q_u->enum_context) { - sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context); - sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context); - - if (sids->ptr_sid==NULL || sids->sid==NULL) { + if (num_entries - *r->in.resume_handle) { + sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr, + num_entries - *r->in.resume_handle); + if (!sids) { SAFE_FREE(sid_list); return NT_STATUS_NO_MEMORY; } - for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) { - init_dom_sid2(&(*sids).sid[j], &sid_list[i]); - (*sids).ptr_sid[j] = 1; + for (i = *r->in.resume_handle, j = 0; i < num_entries; i++, j++) { + sids[j].sid = sid_dup_talloc(p->mem_ctx, &sid_list[i]); + if (!sids[j].sid) { + SAFE_FREE(sid_list); + return NT_STATUS_NO_MEMORY; + } } - } else { - sids->ptr_sid = NULL; - sids->sid = NULL; } talloc_free(sid_list); - init_lsa_r_enum_accounts(r_u, num_entries); + *r->out.resume_handle = num_entries; + r->out.sids->num_sids = num_entries; + r->out.sids->sids = sids; return NT_STATUS_OK; } @@ -2230,12 +2234,6 @@ NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct lsa_EnumAccounts *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r) { p->rng_fault_state = True; -- cgit From 2b84f4119d0d5dc0eac0e3596260901e3dc3eefd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:32:56 +0100 Subject: Use rpccli_lsa_EnumAccounts() in net and rpcclient. Guenther (This used to be commit bdbcfa4419a54b98ea577b0052894ddaa06890ce) --- source3/rpcclient/cmd_lsarpc.c | 16 ++++++------ source3/utils/net_rpc_rights.c | 55 +++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 32 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index c014dba676..6e12a90982 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -550,8 +550,7 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli, uint32 enum_context=0; uint32 pref_max_length=0x1000; - DOM_SID *sids; - uint32 count=0; + struct lsa_SidArray sid_array; int i; if (argc > 3) { @@ -572,19 +571,22 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_enum_sids(cli, mem_ctx, &pol, &enum_context, pref_max_length, - &count, &sids); + result = rpccli_lsa_EnumAccounts(cli, mem_ctx, + &pol, + &enum_context, + &sid_array, + pref_max_length); if (!NT_STATUS_IS_OK(result)) goto done; /* Print results */ - printf("found %d SIDs\n\n", count); + printf("found %d SIDs\n\n", sid_array.num_sids); - for (i = 0; i < count; i++) { + for (i = 0; i < sid_array.num_sids; i++) { fstring sid_str; - sid_to_fstring(sid_str, &sids[i]); + sid_to_fstring(sid_str, sid_array.sids[i].sid); printf("%s\n", sid_str); } diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index de6e14ebad..d8c7462c0d 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -214,24 +214,27 @@ static NTSTATUS enum_accounts_for_privilege(struct rpc_pipe_client *pipe_hnd, NTSTATUS result; uint32 enum_context=0; uint32 pref_max_length=0x1000; - DOM_SID *sids = NULL; - uint32 count=0; + struct lsa_SidArray sid_array; int i; fstring name; - result = rpccli_lsa_enum_sids(pipe_hnd, ctx, pol, &enum_context, - pref_max_length, &count, &sids); + result = rpccli_lsa_EnumAccounts(pipe_hnd, ctx, + pol, + &enum_context, + &sid_array, + pref_max_length); if (!NT_STATUS_IS_OK(result)) return result; d_printf("%s:\n", privilege); - for ( i=0; i Date: Thu, 14 Feb 2008 01:34:34 +0100 Subject: Remove unused marshalling for LSA_ENUM_ACCOUNTS. Guenther (This used to be commit 8c476ad51622f76bf8f03f6255369b8e19f24a72) --- source3/include/rpc_lsa.h | 16 -------- source3/rpc_client/cli_lsarpc.c | 56 --------------------------- source3/rpc_parse/parse_lsa.c | 84 ----------------------------------------- 3 files changed, 156 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 724a980b45..46a01d53e5 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -495,22 +495,6 @@ typedef struct } LSA_R_REMOVE_ACCT_RIGHTS; -/* LSA_Q_ENUM_ACCOUNTS */ -typedef struct lsa_q_enum_accounts -{ - POLICY_HND pol; /* policy handle */ - uint32 enum_context; - uint32 pref_max_length; -} LSA_Q_ENUM_ACCOUNTS; - -/* LSA_R_ENUM_ACCOUNTS */ -typedef struct lsa_r_enum_accounts -{ - uint32 enum_context; - LSA_SID_ENUM sids; - NTSTATUS status; -} LSA_R_ENUM_ACCOUNTS; - typedef struct lsa_q_enumprivsaccount { POLICY_HND pol; /* policy handle */ diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index c42938d6e9..20a0fe28b6 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -452,62 +452,6 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli, return result; } -/** Enumerate list of SIDs */ - -NTSTATUS rpccli_lsa_enum_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, uint32 *enum_ctx, uint32 pref_max_length, - uint32 *num_sids, DOM_SID **sids) -{ - prs_struct qbuf, rbuf; - LSA_Q_ENUM_ACCOUNTS q; - LSA_R_ENUM_ACCOUNTS r; - NTSTATUS result; - int i; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - init_lsa_q_enum_accounts(&q, pol, *enum_ctx, pref_max_length); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_ENUM_ACCOUNTS, - q, r, - qbuf, rbuf, - lsa_io_q_enum_accounts, - lsa_io_r_enum_accounts, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - if (r.sids.num_entries==0) - goto done; - - /* Return output parameters */ - - *sids = TALLOC_ARRAY(mem_ctx, DOM_SID, r.sids.num_entries); - if (!*sids) { - DEBUG(0, ("(cli_lsa_enum_sids): out of memory\n")); - result = NT_STATUS_UNSUCCESSFUL; - goto done; - } - - /* Copy across names and sids */ - - for (i = 0; i < r.sids.num_entries; i++) { - sid_copy(&(*sids)[i], &r.sids.sid[i].sid); - } - - *num_sids= r.sids.num_entries; - *enum_ctx = r.enum_context; - - done: - - return result; -} - /** Enumerate user privileges * * @param cli Handle on an initialised SMB connection */ diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index b8a0b03273..6a80bb28a8 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -1207,90 +1207,6 @@ bool lsa_io_r_lookup_names4(const char *desc, LSA_R_LOOKUP_NAMES4 *out, prs_stru return True; } -/* - initialise a LSA_Q_ENUM_ACCOUNTS structure -*/ -void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length) -{ - memcpy(&trn->pol, hnd, sizeof(trn->pol)); - - trn->enum_context = enum_context; - trn->pref_max_length = pref_max_length; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -bool lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *in, prs_struct *ps, int depth) -{ - if (in == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts"); - depth++; - - if (!smb_io_pol_hnd("", &in->pol, ps, depth)) - return False; - - if(!prs_uint32("enum_context ", ps, depth, &in->enum_context)) - return False; - if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length)) - return False; - - return True; -} - - -/******************************************************************* - Inits an LSA_R_ENUM_PRIVS structure. -********************************************************************/ - -void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *out, uint32 enum_context) -{ - DEBUG(5, ("init_lsa_r_enum_accounts\n")); - - out->enum_context=enum_context; - if (out->enum_context!=0) { - out->sids.num_entries=enum_context; - out->sids.ptr_sid_enum=1; - out->sids.num_entries2=enum_context; - } else { - out->sids.num_entries=0; - out->sids.ptr_sid_enum=0; - out->sids.num_entries2=0; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -bool lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *out, prs_struct *ps, int depth) -{ - if (out == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("enum_context", ps, depth, &out->enum_context)) - return False; - - if (!lsa_io_sid_enum("sids", &out->sids, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - - void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd) { memcpy(&trn->pol, hnd, sizeof(trn->pol)); -- cgit From f9d992827a0935a21a1bf09a12ffd0146880fdc5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:45:07 +0100 Subject: Remove accidential commit. Guenther (This used to be commit 2ab1167e156e989f4b60fcb4dbc7d7eefc64bed0) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 0efee845f4..ac27d387ce 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -32,7 +32,7 @@ static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, uint32_t level = 1; union netr_CONTROL_DATA_INFORMATION data; union netr_CONTROL_QUERY_INFORMATION query; - const char *domain = "BER"; + const char *domain = lp_workgroup(); if (argc > 5) { fprintf(stderr, "Usage: %s " -- cgit From d69d58664c7bc2a2815b4e7c5a6d61646a5bf0ff Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:53:42 +0100 Subject: Fix typo. Guenther (This used to be commit 4e3357ac3a1b0adac1744a71f997e3442e0e4209) --- source3/rpc_server/srv_lsa_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 097b50504f..275f3d9cb4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1424,10 +1424,10 @@ NTSTATUS _lsa_EnumPrivs(pipes_struct *p, if ( enum_context >= num_privs ) return NT_STATUS_NO_MORE_ENTRIES; - - DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", + + DEBUG(10,("_lsa_EnumPrivs: enum_context:%d total entries:%d\n", enum_context, num_privs)); - + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; -- cgit From ba33ff8e63e80096a5c2c787dcc5b8b841f44ba4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:51:15 +0100 Subject: Fix IDL for lsa_EnumPrivsAccount. Guenther (This used to be commit 369df93875c501af460d87b67bb5e919f7741a69) --- source3/librpc/idl/lsa.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 6eb96a8b26..390debc505 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -453,7 +453,7 @@ import "security.idl"; NTSTATUS lsa_EnumPrivsAccount ( [in] policy_handle *handle, - [out,unique] lsa_PrivilegeSet *privs + [out,ref] lsa_PrivilegeSet **privs ); -- cgit From 306061370b71a7234c476247bf5c920dde731de4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:55:22 +0100 Subject: Re-run make idl. Guenther (This used to be commit e75283178dee42a64ec3963f64652c202f0dbd0b) --- source3/librpc/gen_ndr/cli_lsa.c | 6 ++---- source3/librpc/gen_ndr/cli_lsa.h | 2 +- source3/librpc/gen_ndr/lsa.h | 2 +- source3/librpc/gen_ndr/ndr_lsa.c | 39 +++++++++++++++++++++++++++------------ source3/librpc/gen_ndr/srv_lsa.c | 2 +- 5 files changed, 32 insertions(+), 19 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 5b277ca50c..205faa6e07 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -805,7 +805,7 @@ NTSTATUS rpccli_lsa_OpenAccount(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_EnumPrivsAccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, - struct lsa_PrivilegeSet *privs) + struct lsa_PrivilegeSet **privs) { struct lsa_EnumPrivsAccount r; NTSTATUS status; @@ -837,9 +837,7 @@ NTSTATUS rpccli_lsa_EnumPrivsAccount(struct rpc_pipe_client *cli, } /* Return variables */ - if (privs && r.out.privs) { - *privs = *r.out.privs; - } + *privs = *r.out.privs; /* Return result */ return r.out.result; diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index 3e1a8445f1..67aafe3d1a 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -99,7 +99,7 @@ NTSTATUS rpccli_lsa_OpenAccount(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_EnumPrivsAccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, - struct lsa_PrivilegeSet *privs); + struct lsa_PrivilegeSet **privs); NTSTATUS rpccli_lsa_AddPrivilegesToAccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 14d46a6542..a948f6d5e8 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -838,7 +838,7 @@ struct lsa_EnumPrivsAccount { } in; struct { - struct lsa_PrivilegeSet *privs;/* [unique] */ + struct lsa_PrivilegeSet **privs;/* [ref] */ NTSTATUS result; } out; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index 84f99749fe..12544b1b72 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -6224,9 +6224,12 @@ static enum ndr_err_code ndr_push_lsa_EnumPrivsAccount(struct ndr_push *ndr, int NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.privs)); - if (r->out.privs) { - NDR_CHECK(ndr_push_lsa_PrivilegeSet(ndr, NDR_SCALARS, r->out.privs)); + if (r->out.privs == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.privs)); + if (*r->out.privs) { + NDR_CHECK(ndr_push_lsa_PrivilegeSet(ndr, NDR_SCALARS, *r->out.privs)); } NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } @@ -6238,6 +6241,7 @@ static enum ndr_err_code ndr_pull_lsa_EnumPrivsAccount(struct ndr_pull *ndr, int uint32_t _ptr_privs; TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_privs_0; + TALLOC_CTX *_mem_save_privs_1; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -6248,20 +6252,28 @@ static enum ndr_err_code ndr_pull_lsa_EnumPrivsAccount(struct ndr_pull *ndr, int NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.privs); + ZERO_STRUCTP(r->out.privs); } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.privs); + } + _mem_save_privs_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.privs, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_privs)); if (_ptr_privs) { - NDR_PULL_ALLOC(ndr, r->out.privs); + NDR_PULL_ALLOC(ndr, *r->out.privs); } else { - r->out.privs = NULL; + *r->out.privs = NULL; } - if (r->out.privs) { - _mem_save_privs_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.privs, 0); - NDR_CHECK(ndr_pull_lsa_PrivilegeSet(ndr, NDR_SCALARS, r->out.privs)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_privs_0, 0); + if (*r->out.privs) { + _mem_save_privs_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.privs, 0); + NDR_CHECK(ndr_pull_lsa_PrivilegeSet(ndr, NDR_SCALARS, *r->out.privs)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_privs_1, 0); } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_privs_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -6288,10 +6300,13 @@ _PUBLIC_ void ndr_print_lsa_EnumPrivsAccount(struct ndr_print *ndr, const char * ndr->depth++; ndr_print_ptr(ndr, "privs", r->out.privs); ndr->depth++; - if (r->out.privs) { - ndr_print_lsa_PrivilegeSet(ndr, "privs", r->out.privs); + ndr_print_ptr(ndr, "privs", *r->out.privs); + ndr->depth++; + if (*r->out.privs) { + ndr_print_lsa_PrivilegeSet(ndr, "privs", *r->out.privs); } ndr->depth--; + ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/srv_lsa.c b/source3/librpc/gen_ndr/srv_lsa.c index b4600017bc..183cd355c0 100644 --- a/source3/librpc/gen_ndr/srv_lsa.c +++ b/source3/librpc/gen_ndr/srv_lsa.c @@ -1452,7 +1452,7 @@ static bool api_lsa_EnumPrivsAccount(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.privs = talloc_zero(r, struct lsa_PrivilegeSet); + r->out.privs = talloc_zero(r, struct lsa_PrivilegeSet *); if (r->out.privs == NULL) { talloc_free(r); return false; -- cgit From 4583389f9323cc6b405b6d54125ee2d7e21707b8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:53:00 +0100 Subject: Use pidl for _lsa_EnumPrivsAccount(). Guenther (This used to be commit d7655932a7cb436f1ee44e443882e2f06d598aa0) --- source3/rpc_server/srv_lsa.c | 24 +------------------ source3/rpc_server/srv_lsa_nt.c | 53 ++++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 37 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index a3fe00cced..60a3bd3671 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -221,29 +221,7 @@ static bool api_lsa_open_account(pipes_struct *p) static bool api_lsa_enum_privsaccount(pipes_struct *p) { - LSA_Q_ENUMPRIVSACCOUNT q_u; - LSA_R_ENUMPRIVSACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_enum_privsaccount(p, rdata, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ENUMPRIVSACCOUNT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 275f3d9cb4..4e2884ccdb 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1720,38 +1720,69 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p, } /*************************************************************************** + _lsa_EnumPrivsAccount For a given SID, enumerate all the privilege this account has. ***************************************************************************/ -NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) +NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, + struct lsa_EnumPrivsAccount *r) { + NTSTATUS status = NT_STATUS_OK; struct lsa_info *info=NULL; SE_PRIV mask; PRIVILEGE_SET privileges; + struct lsa_PrivilegeSet *priv_set = NULL; + struct lsa_LUIDAttribute *luid_attrs = NULL; + int i; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) ) + if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) ) return NT_STATUS_OBJECT_NAME_NOT_FOUND; privilege_set_init( &privileges ); if ( se_priv_to_privilege_set( &privileges, &mask ) ) { - DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n", + DEBUG(10,("_lsa_EnumPrivsAccount: %s has %d privileges\n", sid_string_dbg(&info->sid), privileges.count)); - r_u->status = init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, privileges.set, privileges.count, 0); + priv_set = TALLOC_ZERO_P(p->mem_ctx, struct lsa_PrivilegeSet); + if (!priv_set) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + luid_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, + struct lsa_LUIDAttribute, + privileges.count); + if (!luid_attrs) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + for (i=0; icount = privileges.count; + priv_set->unknown = 0; + priv_set->set = luid_attrs; + + *r->out.privs = priv_set; + } else { + status = NT_STATUS_NO_SUCH_PRIVILEGE; } - else - r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE; + done: privilege_set_free( &privileges ); - return r_u->status; + return status; } /*************************************************************************** @@ -2246,12 +2277,6 @@ NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct lsa_EnumPrivsAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct lsa_AddPrivilegesToAccount *r) { p->rng_fault_state = True; -- cgit From d0ae7cfb6fb3ed85d87334ce42ed7d3ce84a91a0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:12:28 +0100 Subject: Remove white space. Guenther (This used to be commit a33ed085094b200e153939cb1b02e567f07b1e50) --- source3/rpc_server/srv_lsa_nt.c | 120 ++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 4e2884ccdb..ef09b28dde 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -15,12 +15,12 @@ * 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 . */ @@ -467,7 +467,7 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, r_l->hdr_nb_dom_name.uni_max_len += 2; r_l->uni_nb_dom_name.uni_max_len += 1; } - + if (dns_name && *dns_name) { init_unistr2(&r_l->uni_dns_dom_name, dns_name, UNI_FLAGS_NONE); init_uni_hdr(&r_l->hdr_dns_dom_name, &r_l->uni_dns_dom_name); @@ -486,7 +486,7 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, if (dom_guid) { memcpy(&r_l->dom_guid, dom_guid, sizeof(struct GUID)); } - + if (dom_sid) { r_l->ptr_dom_sid = 1; init_dom_sid2(&r_l->dom_sid, dom_sid); @@ -874,7 +874,7 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, * RID as 8 bytes hex, in others it returns the full * SID. We (Jerry/VL) could not figure out which the * hard cases are, so leave it with the SID. */ - name->name = talloc_asprintf(p->mem_ctx, "%s", + name->name = talloc_asprintf(p->mem_ctx, "%s", sid_to_fstring(tmp, sids[i])); if (name->name == NULL) { @@ -942,7 +942,7 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, r_u->status = _lsa_lookup_sids_internal(p, q_u->level, - num_sids, + num_sids, q_u->sids.sid, &ref, &names, @@ -991,7 +991,7 @@ NTSTATUS _lsa_lookup_sids2(pipes_struct *p, r_u->status = _lsa_lookup_sids_internal(p, q_u->level, - num_sids, + num_sids, q_u->sids.sid, &ref, &r_u->names, @@ -1032,7 +1032,7 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, r_u->status = _lsa_lookup_sids_internal(p, q_u->level, - num_sids, + num_sids, q_u->sids.sid, &ref, &r_u->names, @@ -1085,7 +1085,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); } - + flags = lsa_lookup_level_to_flags(q_u->lookup_level); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); @@ -1230,7 +1230,7 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names3: truncating name lookup list to %d\n", num_entries)); } - + /* Probably the lookup_level is some sort of bitmask. */ if (q_u->lookup_level == 1) { flags = LOOKUP_NAME_ALL; @@ -1297,7 +1297,7 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries)); } - + /* Probably the lookup_level is some sort of bitmask. */ if (q_u->lookup_level == 1) { flags = LOOKUP_NAME_ALL; @@ -1650,17 +1650,17 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - /* check to see if the pipe_user is a Domain Admin since + /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - + if ( is_privileged_sid( r->in.sid ) ) return NT_STATUS_OBJECT_NAME_COLLISION; /* associate the user/group SID with the (unique) handle. */ - + if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) return NT_STATUS_NO_MEMORY; @@ -1807,7 +1807,7 @@ NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, 0x02 -> Access this computer from network 0x04 -> Log on as a batch job 0x10 -> Log on as a service - + they can be ORed together */ @@ -1830,9 +1830,9 @@ NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - /* check to see if the pipe_user is a Domain Admin since + /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; @@ -1855,11 +1855,11 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - - /* check to see if the pipe_user is root or a Domain Admin since + + /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - - if ( p->pipe_user.ut.uid != sec_initial_uid() + + if ( p->pipe_user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1895,11 +1895,11 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - /* check to see if the pipe_user is root or a Domain Admin since + /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( p->pipe_user.ut.uid != sec_initial_uid() - && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; } @@ -2020,7 +2020,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } - init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name, + init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name, forest_name,&guid,sid); break; default: @@ -2048,33 +2048,33 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R DOM_SID sid; fstring privname; UNISTR4_ARRAY *uni_privnames = q_u->rights; - + /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - - /* check to see if the pipe_user is a Domain Admin since + + /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( p->pipe_user.ut.uid != sec_initial_uid() - && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; } /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ - + sid_copy( &sid, &q_u->sid.sid ); - + /* just a little sanity check */ - + if ( q_u->count != uni_privnames->count ) { DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); - return NT_STATUS_INVALID_HANDLE; + return NT_STATUS_INVALID_HANDLE; } - + for ( i=0; icount; i++ ) { UNISTR4 *uni4_str = &uni_privnames->strings[i]; @@ -2084,7 +2084,7 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R continue; rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - + if ( !grant_privilege_by_name( &sid, privname ) ) { DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; @@ -2104,15 +2104,15 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, DOM_SID sid; fstring privname; UNISTR4_ARRAY *uni_privnames = q_u->rights; - + /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - - /* check to see if the pipe_user is a Domain Admin since + + /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( p->pipe_user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { @@ -2122,19 +2122,19 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, sid_copy( &sid, &q_u->sid.sid ); if ( q_u->removeall ) { - if ( !revoke_all_privileges( &sid ) ) + if ( !revoke_all_privileges( &sid ) ) return NT_STATUS_ACCESS_DENIED; - + return NT_STATUS_OK; } - + /* just a little sanity check */ - + if ( q_u->count != uni_privnames->count ) { DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); - return NT_STATUS_INVALID_HANDLE; + return NT_STATUS_INVALID_HANDLE; } - + for ( i=0; icount; i++ ) { UNISTR4 *uni4_str = &uni_privnames->strings[i]; @@ -2144,7 +2144,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, continue; rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - + if ( !revoke_privilege_by_name( &sid, privname ) ) { DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; @@ -2164,18 +2164,18 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA DOM_SID sid; PRIVILEGE_SET privileges; SE_PRIV mask; - + /* find the connection policy handle. */ - + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - + /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ - + sid_copy( &sid, &q_u->sid.sid ); - + if ( !get_privileges_for_sids( &mask, &sid, 1 ) ) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2188,7 +2188,7 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA r_u->status = init_r_enum_acct_rights( r_u, &privileges ); } - else + else r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE; privilege_set_free( &privileges ); @@ -2206,14 +2206,14 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L fstring name; LUID_ATTR priv_luid; SE_PRIV mask; - + /* find the connection policy handle. */ - + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - + unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name)); - + DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name)); if ( !se_priv_from_name( name, &mask ) ) @@ -2223,7 +2223,7 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L r_u->luid.low = priv_luid.luid.low; r_u->luid.high = priv_luid.luid.high; - + return NT_STATUS_OK; } @@ -2233,7 +2233,7 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L * From here on the server routines are just dummy ones to make smbd link with * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are * pulling the server stubs across one by one. - */ + */ NTSTATUS _lsa_Delete(pipes_struct *p, struct lsa_Delete *r) { -- cgit From eccaf125a9e3590af0a0ef84980314ea5190e586 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 12:13:13 +0100 Subject: Use rpccli_lsa_EnumPrivsAccount() in rpcclient. Guenther (This used to be commit c28b52dcfedd575f5ae4ed7942857d3853bdd051) --- source3/rpcclient/cmd_lsarpc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 6e12a90982..bd9d3c03cd 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -652,10 +652,8 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli, POLICY_HND user_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; uint32 access_desired = 0x000f000f; - DOM_SID sid; - uint32 count=0; - LUID_ATTR *set; + struct lsa_PrivilegeSet *privs = NULL; int i; if (argc != 2 ) { @@ -683,17 +681,22 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_enum_privsaccount(cli, mem_ctx, &user_pol, &count, &set); + result = rpccli_lsa_EnumPrivsAccount(cli, mem_ctx, + &user_pol, + &privs); if (!NT_STATUS_IS_OK(result)) goto done; /* Print results */ - printf("found %d privileges for SID %s\n\n", count, argv[1]); + printf("found %d privileges for SID %s\n\n", privs->count, argv[1]); printf("high\tlow\tattribute\n"); - for (i = 0; i < count; i++) { - printf("%u\t%u\t%u\n", set[i].luid.high, set[i].luid.low, set[i].attr); + for (i = 0; i < privs->count; i++) { + printf("%u\t%u\t%u\n", + privs->set[i].luid.high, + privs->set[i].luid.low, + privs->set[i].attribute); } rpccli_lsa_Close(cli, mem_ctx, &dom_pol); -- cgit From 341e5ea3eb5068d5b742deb6d14d58500330d27c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 12:15:17 +0100 Subject: Remove unused marshalling for LSA_ENUMPRIVSACCOUNT. Guenther (This used to be commit 004598bc1322b6e2deb62115713768682fee988e) --- source3/include/rpc_lsa.h | 13 ------- source3/rpc_client/cli_lsarpc.c | 56 --------------------------- source3/rpc_parse/parse_lsa.c | 84 ----------------------------------------- 3 files changed, 153 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 46a01d53e5..0e61b7b2d9 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -495,19 +495,6 @@ typedef struct } LSA_R_REMOVE_ACCT_RIGHTS; -typedef struct lsa_q_enumprivsaccount -{ - POLICY_HND pol; /* policy handle */ -} LSA_Q_ENUMPRIVSACCOUNT; - -typedef struct lsa_r_enumprivsaccount -{ - uint32 ptr; - uint32 count; - PRIVILEGE_SET set; - NTSTATUS status; -} LSA_R_ENUMPRIVSACCOUNT; - typedef struct { UNIHDR hdr; UNISTR2 unistring; diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index 20a0fe28b6..c5ad98c3ad 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -452,62 +452,6 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli, return result; } -/** Enumerate user privileges - * - * @param cli Handle on an initialised SMB connection */ - -NTSTATUS rpccli_lsa_enum_privsaccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, uint32 *count, LUID_ATTR **set) -{ - prs_struct qbuf, rbuf; - LSA_Q_ENUMPRIVSACCOUNT q; - LSA_R_ENUMPRIVSACCOUNT r; - NTSTATUS result; - int i; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialise input parameters */ - - init_lsa_q_enum_privsaccount(&q, pol); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_ENUMPRIVSACCOUNT, - q, r, - qbuf, rbuf, - lsa_io_q_enum_privsaccount, - lsa_io_r_enum_privsaccount, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - if (r.count == 0) - goto done; - - if (!((*set = TALLOC_ARRAY(mem_ctx, LUID_ATTR, r.count)))) { - DEBUG(0, ("(cli_lsa_enum_privsaccount): out of memory\n")); - result = NT_STATUS_UNSUCCESSFUL; - goto done; - } - - for (i=0; ipol, hnd, sizeof(trn->pol)); - -} - -/******************************************************************* - Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure. -********************************************************************/ - -bool lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) - return False; - - return True; -} - /******************************************************************* Reads or writes an LUID structure. ********************************************************************/ @@ -1300,66 +1276,6 @@ static bool lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *out, prs_struc return True; } -NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *out, LUID_ATTR *set, uint32 count, uint32 control) -{ - NTSTATUS ret = NT_STATUS_OK; - - out->ptr = 1; - out->count = count; - - if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(out->set))) ) - return ret; - - out->set.count = count; - - if (!NT_STATUS_IS_OK(ret = dup_luid_attr(out->set.mem_ctx, &(out->set.set), set, count))) - return ret; - - DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", out->count)); - - return ret; -} - -/******************************************************************* - Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure. -********************************************************************/ - -bool lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &out->ptr)) - return False; - - if (out->ptr!=0) { - if(!prs_uint32("count", ps, depth, &out->count)) - return False; - - /* malloc memory if unmarshalling here */ - - if (UNMARSHALLING(ps) && out->count != 0) { - if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set)))) - return False; - - if (!(out->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,out->count))) - return False; - - } - - if(!lsa_io_privilege_set(desc, &out->set, ps, depth)) - return False; - } - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - void init_lsa_string( LSA_STRING *uni, const char *string ) { init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE); -- cgit From a34188d0dbf2de964a1ecd386576b53ee92ab49a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:09:54 +0100 Subject: Fix IDL for lsa_LookupPrivValue. Guenther (This used to be commit 05386f70566e272247ed917b51d712054196ebcb) --- source3/librpc/idl/lsa.idl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 390debc505..ffad802ecd 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -637,8 +637,8 @@ import "security.idl"; /* Function: 0x1f */ NTSTATUS lsa_LookupPrivValue( [in] policy_handle *handle, - [in] lsa_String *name, - [out] lsa_LUID *luid + [in,ref] lsa_String *name, + [out,ref] lsa_LUID *luid ); -- cgit From a63b27bec0da21b319133ade40303b4dce46412a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:25:42 +0100 Subject: Use pidl for _lsa_LookupPrivValue(). Guenther (This used to be commit 87dc2471d1c2a5be17604399d4f684193a6bba38) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 37 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 60a3bd3671..c4ca22f401 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -413,29 +413,7 @@ static bool api_lsa_enum_acct_rights(pipes_struct *p) static bool api_lsa_lookup_priv_value(pipes_struct *p) { - LSA_Q_LOOKUP_PRIV_VALUE q_u; - LSA_R_LOOKUP_PRIV_VALUE r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_lookup_priv_value("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_priv_value: failed to unmarshall LSA_Q_LOOKUP_PRIV_VALUE .\n")); - return False; - } - - r_u.status = _lsa_lookup_priv_value(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_priv_value("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_priv_value: Failed to marshall LSA_R_LOOKUP_PRIV_VALUE.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPPRIVVALUE); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ef09b28dde..a8f6e15e23 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2198,21 +2198,23 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA /*************************************************************************** + _lsa_LookupPrivValue ***************************************************************************/ -NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, LSA_R_LOOKUP_PRIV_VALUE *r_u) +NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, + struct lsa_LookupPrivValue *r) { struct lsa_info *info = NULL; - fstring name; + const char *name = NULL; LUID_ATTR priv_luid; SE_PRIV mask; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name)); + name = r->in.name->string; DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name)); @@ -2221,14 +2223,12 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L priv_luid = get_privilege_luid( &mask ); - r_u->luid.low = priv_luid.luid.low; - r_u->luid.high = priv_luid.luid.high; - + r->out.luid->low = priv_luid.luid.low; + r->out.luid->high = priv_luid.luid.high; return NT_STATUS_OK; } - /* * From here on the server routines are just dummy ones to make smbd link with * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are @@ -2319,12 +2319,6 @@ NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct lsa_QuerySecret *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, struct lsa_LookupPrivValue *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct lsa_LookupPrivName *r) { p->rng_fault_state = True; -- cgit From a75d6543a00fbdc52f2f783377737c4dc6f28569 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:29:18 +0100 Subject: Use rpccli_lsa_LookupPrivValue() in rpcclient. Guenther (This used to be commit c15243dd1faaa01cd05d6e2f6ae873cc32097397) --- source3/rpcclient/cmd_lsarpc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index bd9d3c03cd..69585eea57 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -841,7 +841,8 @@ static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - LUID luid; + struct lsa_LUID luid; + struct lsa_String name; if (argc != 2 ) { printf("Usage: %s name\n", argv[0]); @@ -855,7 +856,12 @@ static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_lookup_priv_value(cli, mem_ctx, &pol, argv[1], &luid); + init_lsa_String(&name, argv[1]); + + result = rpccli_lsa_LookupPrivValue(cli, mem_ctx, + &pol, + &name, + &luid); if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From c6cd8ec909269be0f6800c7d59db94090b3c647b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:31:55 +0100 Subject: Remove unused marshalling for LSA_LOOKUP_PRIV_VALUE. Guenther (This used to be commit 8125d8557fb4b27873f8eabc6ad1019491d18cce) --- source3/include/rpc_lsa.h | 10 ------ source3/rpc_client/cli_lsarpc.c | 40 ------------------------ source3/rpc_parse/parse_lsa.c | 67 ----------------------------------------- 3 files changed, 117 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 0e61b7b2d9..4e6a1e16cc 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -500,16 +500,6 @@ typedef struct { UNISTR2 unistring; } LSA_STRING; -typedef struct { - POLICY_HND pol; /* policy handle */ - LSA_STRING privname; -} LSA_Q_LOOKUP_PRIV_VALUE; - -typedef struct { - LUID luid; - NTSTATUS status; -} LSA_R_LOOKUP_PRIV_VALUE; - typedef struct lsa_q_addprivs { POLICY_HND pol; /* policy handle */ diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index c5ad98c3ad..9d9a131a1a 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -452,46 +452,6 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli, return result; } -/** Get a privilege value given its name */ - -NTSTATUS rpccli_lsa_lookup_priv_value(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, const char *name, LUID *luid) -{ - prs_struct qbuf, rbuf; - LSA_Q_LOOKUP_PRIV_VALUE q; - LSA_R_LOOKUP_PRIV_VALUE r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - - init_lsa_q_lookup_priv_value(&q, pol, name); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_LOOKUPPRIVVALUE, - q, r, - qbuf, rbuf, - lsa_io_q_lookup_priv_value, - lsa_io_r_lookup_priv_value, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - /* Return output parameters */ - - (*luid).low=r.luid.low; - (*luid).high=r.luid.high; - - done: - - return result; -} - /* Enumerate account rights This is similar to enum_privileges but takes a SID directly, avoiding the open_account call. */ diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index 2230c9147f..602021146f 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -1276,73 +1276,6 @@ static bool lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *out, prs_struc return True; } -void init_lsa_string( LSA_STRING *uni, const char *string ) -{ - init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE); - init_uni_hdr(&uni->hdr, &uni->unistring); -} - -void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name) -{ - memcpy(&q_u->pol, hnd, sizeof(q_u->pol)); - init_lsa_string( &q_u->privname, name ); -} - -bool smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth ) -{ - prs_debug(ps, depth, desc, "smb_io_lsa_string"); - depth++; - - if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth)) - return False; - if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure. -********************************************************************/ - -bool lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) - return False; - if(!smb_io_lsa_string("privname", &out->privname, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure. -********************************************************************/ - -bool lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!lsa_io_luid("luid", &out->luid, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - - /******************************************************************* Reads or writes an LSA_Q_ADDPRIVS structure. ********************************************************************/ -- cgit From 6e01d7cb6daf3bb961107a6d6c4a5f6537a97d13 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 12:47:04 +0100 Subject: Fix IDL for lsa_AddPrivilegesToAccount. Guenther (This used to be commit 21f82166982784c9685a6403c8db21f421ed0bad) --- source3/librpc/idl/lsa.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index ffad802ecd..6bb34a9dc5 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -461,7 +461,7 @@ import "security.idl"; /* Function: 0x13 */ NTSTATUS lsa_AddPrivilegesToAccount( [in] policy_handle *handle, - [in] lsa_PrivilegeSet *privs + [in,ref] lsa_PrivilegeSet *privs ); -- cgit From 55e5e753bbe22c2467b5ea85abde8cee4ec838d6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:46:39 +0100 Subject: Add lsaaddpriv and lsadelpriv commands to rpcclient. Guenther (This used to be commit e55bb83f84d0d459f4280c2a4bfa4cc14bd3924d) --- source3/rpcclient/cmd_lsarpc.c | 176 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 172 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 69585eea57..120fb9b173 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -1141,6 +1141,176 @@ static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli, return result; } +static NTSTATUS cmd_lsa_add_priv(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + POLICY_HND dom_pol, user_pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + struct lsa_PrivilegeSet privs; + struct lsa_LUIDAttribute *set = NULL; + DOM_SID sid; + int i; + + ZERO_STRUCT(privs); + + if (argc < 3 ) { + printf("Usage: %s SID [rights...]\n", argv[0]); + return NT_STATUS_OK; + } + + result = name_to_sid(cli, mem_ctx, &sid, argv[1]); + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &dom_pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_OpenAccount(cli, mem_ctx, + &dom_pol, + &sid, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &user_pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + for (i=2; i Date: Thu, 14 Feb 2008 13:50:32 +0100 Subject: Use pidl for _lsa_AddPrivilegesToAccount and _lsa_RemovePrivilegesFromAccount. Guenther (This used to be commit 0c9904864b5c3b893f99abdebb18d9624aa0f560) --- source3/lib/privileges_basic.c | 4 ++-- source3/rpc_server/srv_lsa.c | 48 ++--------------------------------------- source3/rpc_server/srv_lsa_nt.c | 37 ++++++++++++------------------- 3 files changed, 18 insertions(+), 71 deletions(-) (limited to 'source3') diff --git a/source3/lib/privileges_basic.c b/source3/lib/privileges_basic.c index 753f7265a1..865c1f655c 100644 --- a/source3/lib/privileges_basic.c +++ b/source3/lib/privileges_basic.c @@ -473,7 +473,7 @@ bool se_priv_to_privilege_set( PRIVILEGE_SET *set, SE_PRIV *mask ) /******************************************************************* *******************************************************************/ -static bool luid_to_se_priv( LUID *luid, SE_PRIV *mask ) +static bool luid_to_se_priv( struct lsa_LUID *luid, SE_PRIV *mask ) { int i; uint32 num_privs = count_all_privileges(); @@ -491,7 +491,7 @@ static bool luid_to_se_priv( LUID *luid, SE_PRIV *mask ) /******************************************************************* *******************************************************************/ -bool privilege_set_to_se_priv( SE_PRIV *mask, PRIVILEGE_SET *privset ) +bool privilege_set_to_se_priv( SE_PRIV *mask, struct lsa_PrivilegeSet *privset ) { int i; diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index c4ca22f401..ff274473d6 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -249,29 +249,7 @@ static bool api_lsa_setsystemaccount(pipes_struct *p) static bool api_lsa_addprivs(pipes_struct *p) { - LSA_Q_ADDPRIVS q_u; - LSA_R_ADDPRIVS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_addprivs("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n")); - return False; - } - - r_u.status = _lsa_addprivs(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_addprivs("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_addprivs: Failed to marshall LSA_R_ADDPRIVS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ADDPRIVILEGESTOACCOUNT); } /*************************************************************************** @@ -280,29 +258,7 @@ static bool api_lsa_addprivs(pipes_struct *p) static bool api_lsa_removeprivs(pipes_struct *p) { - LSA_Q_REMOVEPRIVS q_u; - LSA_R_REMOVEPRIVS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_removeprivs("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n")); - return False; - } - - r_u.status = _lsa_removeprivs(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_removeprivs("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_removeprivs: Failed to marshall LSA_R_REMOVEPRIVS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_REMOVEPRIVILEGESFROMACCOUNT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a8f6e15e23..10842a1ada 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1843,17 +1843,19 @@ NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, } /*************************************************************************** + _lsa_AddPrivilegesToAccount For a given SID, add some privileges. ***************************************************************************/ -NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u) +NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, + struct lsa_AddPrivilegesToAccount *r) { struct lsa_info *info = NULL; SE_PRIV mask; - PRIVILEGE_SET *set = NULL; + struct lsa_PrivilegeSet *set = NULL; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is root or a Domain Admin since @@ -1865,13 +1867,12 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u return NT_STATUS_ACCESS_DENIED; } - set = &q_u->set; - + set = r->in.privs; if ( !privilege_set_to_se_priv( &mask, set ) ) return NT_STATUS_NO_SUCH_PRIVILEGE; if ( !grant_privilege( &info->sid, &mask ) ) { - DEBUG(3,("_lsa_addprivs: grant_privilege(%s) failed!\n", + DEBUG(3,("_lsa_AddPrivilegesToAccount: grant_privilege(%s) failed!\n", sid_string_dbg(&info->sid) )); DEBUG(3,("Privilege mask:\n")); dump_se_priv( DBGC_ALL, 3, &mask ); @@ -1882,17 +1883,19 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u } /*************************************************************************** + _lsa_RemovePrivilegesFromAccount For a given SID, remove some privileges. ***************************************************************************/ -NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u) +NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, + struct lsa_RemovePrivilegesFromAccount *r) { struct lsa_info *info = NULL; SE_PRIV mask; - PRIVILEGE_SET *set = NULL; + struct lsa_PrivilegeSet *set = NULL; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is root or a Domain Admin since @@ -1904,13 +1907,13 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP return NT_STATUS_ACCESS_DENIED; } - set = &q_u->set; + set = r->in.privs; if ( !privilege_set_to_se_priv( &mask, set ) ) return NT_STATUS_NO_SUCH_PRIVILEGE; if ( !revoke_privilege( &info->sid, &mask ) ) { - DEBUG(3,("_lsa_removeprivs: revoke_privilege(%s) failed!\n", + DEBUG(3,("_lsa_RemovePrivilegesFromAccount: revoke_privilege(%s) failed!\n", sid_string_dbg(&info->sid) )); DEBUG(3,("Privilege mask:\n")); dump_se_priv( DBGC_ALL, 3, &mask ); @@ -2277,18 +2280,6 @@ NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct lsa_AddPrivilegesToAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, struct lsa_RemovePrivilegesFromAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r) { p->rng_fault_state = True; -- cgit From ff85aec1937692c9aa62855bdc2f35df0db6d890 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 14:01:49 +0100 Subject: Remove unused marshalling for LSA_ADDPRIVS and LSA_REMOVEPRIVS. Guenther (This used to be commit 5b700aba1a2e1559c17fec9d82e87312e8a5b15d) --- source3/include/rpc_lsa.h | 33 -------- source3/rpc_parse/parse_lsa.c | 178 ------------------------------------------ 2 files changed, 211 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 4e6a1e16cc..e7e013f8aa 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -494,37 +494,4 @@ typedef struct NTSTATUS status; } LSA_R_REMOVE_ACCT_RIGHTS; - -typedef struct { - UNIHDR hdr; - UNISTR2 unistring; -} LSA_STRING; - -typedef struct lsa_q_addprivs -{ - POLICY_HND pol; /* policy handle */ - uint32 count; - PRIVILEGE_SET set; -} LSA_Q_ADDPRIVS; - -typedef struct lsa_r_addprivs -{ - NTSTATUS status; -} LSA_R_ADDPRIVS; - - -typedef struct lsa_q_removeprivs -{ - POLICY_HND pol; /* policy handle */ - uint32 allrights; - uint32 ptr; - uint32 count; - PRIVILEGE_SET set; -} LSA_Q_REMOVEPRIVS; - -typedef struct lsa_r_removeprivs -{ - NTSTATUS status; -} LSA_R_REMOVEPRIVS; - #endif /* _RPC_LSA_H */ diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index 602021146f..d4d32531a0 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -1207,188 +1207,10 @@ bool lsa_io_r_lookup_names4(const char *desc, LSA_R_LOOKUP_NAMES4 *out, prs_stru return True; } -/******************************************************************* - Reads or writes an LUID structure. -********************************************************************/ - -static bool lsa_io_luid(const char *desc, LUID *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_luid"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("low", ps, depth, &out->low)) - return False; - - if(!prs_uint32("high", ps, depth, &out->high)) - return False; - - return True; -} - /******************************************************************* Reads or writes an LUID_ATTR structure. ********************************************************************/ -static bool lsa_io_luid_attr(const char *desc, LUID_ATTR *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_luid_attr"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!lsa_io_luid(desc, &out->luid, ps, depth)) - return False; - - if(!prs_uint32("attr", ps, depth, &out->attr)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an PRIVILEGE_SET structure. -********************************************************************/ - -static bool lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *out, prs_struct *ps, int depth) -{ - uint32 i, dummy; - - prs_debug(ps, depth, desc, "lsa_io_privilege_set"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("count", ps, depth, &dummy)) - return False; - if(!prs_uint32("control", ps, depth, &out->control)) - return False; - - for (i=0; icount; i++) { - if (!lsa_io_luid_attr(desc, &out->set[i], ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes an LSA_Q_ADDPRIVS structure. -********************************************************************/ - -bool lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_addprivs"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) - return False; - - if(!prs_uint32("count", ps, depth, &out->count)) - return False; - - if (UNMARSHALLING(ps) && out->count!=0) { - if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set)))) - return False; - - if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count))) - return False; - } - - if(!lsa_io_privilege_set(desc, &out->set, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_ADDPRIVS structure. -********************************************************************/ - -bool lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_addprivs"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_Q_REMOVEPRIVS structure. -********************************************************************/ - -bool lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_removeprivs"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) - return False; - - if(!prs_uint32("allrights", ps, depth, &out->allrights)) - return False; - - if(!prs_uint32("ptr", ps, depth, &out->ptr)) - return False; - - /* - * JFM: I'm not sure at all if the count is inside the ptr - * never seen one with ptr=0 - */ - - if (out->ptr!=0) { - if(!prs_uint32("count", ps, depth, &out->count)) - return False; - - if (UNMARSHALLING(ps) && out->count!=0) { - if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set)))) - return False; - - if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count))) - return False; - } - - if(!lsa_io_privilege_set(desc, &out->set, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_REMOVEPRIVS structure. -********************************************************************/ - -bool lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_removeprivs"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - bool policy_handle_is_valid(const POLICY_HND *hnd) { POLICY_HND zero_pol; -- cgit From 879b32806df9304b46fc311073e623295ecbb974 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 14 Feb 2008 00:31:37 +0100 Subject: Fix a typo. This had no negative side effect since currently TALLOC_OBJ only consists of one object. Michael (This used to be commit 9cf3be852024f05a73bf23fe5df6264e5252889b) --- source3/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 25f52e484a..70d573c7a2 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -276,7 +276,7 @@ m4_include(lib/talloc/libtalloc.m4) TALLOC_OBJS="" for obj in ${TALLOC_OBJ}; do - TALLOC_OBJS="${TALLOCOBJS} ${tallocdir}/${obj}" + TALLOC_OBJS="${TALLOC_OBJS} ${tallocdir}/${obj}" done AC_SUBST(TALLOC_OBJS) -- cgit From 8e3ae7baaf287f70123eda7aa478ac82812e7c81 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 14 Feb 2008 13:29:44 +0100 Subject: Add support for building and using shared and static libtdb library. This should work with m4_include(lib/tdb/libtdb.m4) like already done with talloc, but currently this does not work (yet) - tdb code has to be merged from s4 before that. Michael (This used to be commit e92fdf6b202bd67a9bb6fcc1ced56513a2d0bd3f) --- source3/Makefile.in | 238 +++++++++++++++++++++++++------------------- source3/configure.in | 67 ++++++++++++- source3/exports/libtdb.syms | 4 + source3/library-versions.in | 1 + 4 files changed, 207 insertions(+), 103 deletions(-) create mode 100644 source3/exports/libtdb.syms (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index c42b3c3465..9b210cc9e7 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -145,6 +145,10 @@ LIBTALLOC_SHARED_TARGET=@LIBTALLOC_SHARED_TARGET@ LIBTALLOC_STATIC_TARGET=@LIBTALLOC_STATIC_TARGET@ LIBTALLOC=$(LIBTALLOC_STATIC_TARGET) @LIBTALLOC_SHARED@ +LIBTDB_SHARED_TARGET=@LIBTDB_SHARED_TARGET@ +LIBTDB_STATIC_TARGET=@LIBTDB_STATIC_TARGET@ +LIBTDB=$(LIBTDB_STATIC_TARGET) @LIBTDB_SHARED@ + LIBSMBCLIENT=bin/libsmbclient.a @LIBSMBCLIENT_SHARED@ LIBSMBSHAREMODES=bin/libsmbsharemodes.a @LIBSMBSHAREMODES_SHARED@ LIBADDNS=bin/libaddns.a @LIBADDNS_SHARED@ @@ -210,7 +214,7 @@ EVERYTHING_PROGS = bin/debug2html@EXEEXT@ bin/smbfilter@EXEEXT@ \ bin/log2pcap@EXEEXT@ bin/sharesec@EXEEXT@ bin/ndrdump@EXEEXT@ \ bin/vlp@EXEEXT@ -SHLIBS = libtalloc @LIBWBCLIENT@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@ @LIBADDNS@ libnetapi +SHLIBS = libtalloc libtdb @LIBWBCLIENT@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@ @LIBADDNS@ libnetapi PAM_MODULES = @PAM_MODULES@ @@ -232,13 +236,18 @@ MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(IDMAP_MODULES) \ # object file lists ###################################################################### -TDBBASE_OBJ = lib/tdb/common/tdb.o lib/tdb/common/dump.o lib/tdb/common/error.o \ - lib/tdb/common/freelist.o lib/tdb/common/freelistcheck.o \ - lib/tdb/common/io.o lib/tdb/common/lock.o \ - lib/tdb/common/open.o lib/tdb/common/transaction.o \ - lib/tdb/common/traverse.o +#TDBBASE_OBJ = lib/tdb/common/tdb.o lib/tdb/common/dump.o lib/tdb/common/error.o \ +# lib/tdb/common/freelist.o lib/tdb/common/freelistcheck.o \ +# lib/tdb/common/io.o lib/tdb/common/lock.o \ +# lib/tdb/common/open.o lib/tdb/common/transaction.o \ +# lib/tdb/common/traverse.o + +TDBBASE_OBJ = @TDB_OBJS@ + +LIBTDB_OBJ0 = $(TDBBASE_OBJ) +LIBTDB_OBJ = $(LIBTDB_OBJ0) $(LIBREPLACE_OBJ) -TDB_OBJ = $(TDBBASE_OBJ) lib/util_tdb.o \ +TDB_OBJ = @LIBTDB_STATIC@ lib/util_tdb.o \ lib/dbwrap.o lib/dbwrap_tdb.o lib/dbwrap_ctdb.o lib/dbwrap_rbt.o SMBLDAP_OBJ = @SMBLDAP@ @SMBLDAPUTIL@ @@ -749,7 +758,7 @@ LIBSMBCLIENT_OBJ = libsmb/libsmbclient.o libsmb/libsmb_compat.o \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \ $(SECRETS_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) -LIBSMBSHAREMODES_OBJ = libsmb/smb_share_modes.o $(TDBBASE_OBJ) +LIBSMBSHAREMODES_OBJ = libsmb/smb_share_modes.o @LIBTDB_STATIC@ # This shared library is intended for linking with unit test programs # to test Samba internals. It's called libbigballofmud.so to @@ -1023,16 +1032,16 @@ POPT_OBJ=popt/findme.o popt/popt.o popt/poptconfig.o \ INIPARSER_OBJ = iniparser_build/iniparser.o iniparser_build/dictionary.o \ iniparser_build/strlib.o -TDBBACKUP_OBJ = lib/tdb/tools/tdbbackup.o $(LIBREPLACE_OBJ) \ - $(TDBBASE_OBJ) $(SOCKET_WRAPPER_OBJ) +TDBBACKUP_OBJ = @tdbdir@/tools/tdbbackup.o $(LIBREPLACE_OBJ) \ + @LIBTDB_STATIC@ $(SOCKET_WRAPPER_OBJ) -TDBTOOL_OBJ = lib/tdb/tools/tdbtool.o $(TDBBASE_OBJ) $(LIBREPLACE_OBJ) \ +TDBTOOL_OBJ = @tdbdir@/tools/tdbtool.o @LIBTDB_STATIC@ $(LIBREPLACE_OBJ) \ $(SOCKET_WRAPPER_OBJ) -TDBDUMP_OBJ = lib/tdb/tools/tdbdump.o $(TDBBASE_OBJ) $(LIBREPLACE_OBJ) \ +TDBDUMP_OBJ = @tdbdir@/tools/tdbdump.o @LIBTDB_STATIC@ $(LIBREPLACE_OBJ) \ $(SOCKET_WRAPPER_OBJ) -TDBTORTURE_OBJ = lib/tdb/tools/tdbtorture.o $(TDBBASE_OBJ) $(LIBREPLACE_OBJ) \ +TDBTORTURE_OBJ = @tdbdir@/tools/tdbtorture.o @LIBTDB_STATIC@ $(LIBREPLACE_OBJ) \ $(SOCKET_WRAPPER_OBJ) @@ -1224,49 +1233,50 @@ bin/.dummy: dir=bin $(MAKEDIR); fi @: >> $@ || : > $@ # what a fancy emoticon! -bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBWBCLIENT_SHARED@ @BUILD_POPT@ +bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) \ $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) \ - @POPTLIBS@ @SMBD_LIBS@ @WINBIND_LIBS@ + @POPTLIBS@ @SMBD_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/nmbd@EXEEXT@: $(BINARY_PREREQS) $(NMBD_OBJ) @BUILD_POPT@ +bin/nmbd@EXEEXT@: $(BINARY_PREREQS) $(NMBD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ - @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) + @LIBTDB_LIBS@ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) -bin/swat@EXEEXT@: $(BINARY_PREREQS) $(SWAT_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/swat@EXEEXT@: $(BINARY_PREREQS) $(SWAT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINT_LIBS) \ $(AUTH_LIBS) $(LIBS) $(PASSDB_LIBS) @POPTLIBS@ $(KRB5LIBS) \ - $(LDAP_LIBS) @WINBIND_LIBS@ + $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/rpcclient@EXEEXT@: $(BINARY_PREREQS) $(RPCCLIENT_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/rpcclient@EXEEXT@: $(BINARY_PREREQS) $(RPCCLIENT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(PASSDB_LIBS) $(RPCCLIENT_OBJ) \ $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) @WINBIND_LIBS@ + $(KRB5LIBS) $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) \ $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) $(DNSSD_LIBS) @WINBIND_LIBS@ + $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) $(DNSSD_LIBS) \ + @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ - $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @INIPARSERLIBS@ @WINBIND_LIBS@ @LIBNETAPI_LIBS@ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @INIPARSERLIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ @LIBNETAPI_LIBS@ -bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ +bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ +bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ bin/smbmount@EXEEXT@: $(BINARY_PREREQS) $(MOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ @@ -1293,104 +1303,108 @@ bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ @$(CC) $(FLAGS) -o $@ $(CIFS_SPNEGO_OBJ) $(DYNEXP) $(LDFLAGS) -lkeyutils $(LIBS) \ $(LIBSMBCLIENT_OBJ) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBWBCLIENT_SHARED@ -bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ +bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbstatus@EXEEXT@: $(BINARY_PREREQS) $(STATUS_OBJ) @BUILD_POPT@ +bin/smbstatus@EXEEXT@: $(BINARY_PREREQS) $(STATUS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) \ - @POPTLIBS@ + @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbcontrol@EXEEXT@: $(BINARY_PREREQS) $(SMBCONTROL_OBJ) @BUILD_POPT@ +bin/smbcontrol@EXEEXT@: $(BINARY_PREREQS) $(SMBCONTROL_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ \ $(SMBCONTROL_OBJ) $(DYNEXP) $(LDFLAGS) \ - $(LIBS) $(LDAP_LIBS) @LIBUNWIND_PTRACE@ @POPTLIBS@ + $(LIBS) $(LDAP_LIBS) @LIBUNWIND_PTRACE@ @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbtree@EXEEXT@: $(BINARY_PREREQS) $(SMBTREE_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/smbtree@EXEEXT@: $(BINARY_PREREQS) $(SMBTREE_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(DYNEXP) \ - $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ + @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(PASSDB_LIBS) \ - $(DYNEXP) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) @WINBIND_LIBS@ + $(DYNEXP) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) \ + @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ - @POPTLIBS@ $(PASSDB_LIBS) $(LDAP_LIBS) @WINBIND_LIBS@ + @POPTLIBS@ $(PASSDB_LIBS) $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBGET_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ - @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ + @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/samtest@EXEEXT@: $(SAMTEST_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SAMTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) @POPTLIBS@ $(PASSDB_LIBS) $(KRB5LIBS) $(LDAP_LIBS) -bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ +bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @POPTLIBS@ $(LDAP_LIBS) + @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + @POPTLIBS@ $(LDAP_LIBS) @LIBTDB_LIBS@ -bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ +bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ +bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(TALLOCTORT_OBJ) $(LDFLAGS) \ - $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ + $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ bin/replacetort@EXEEXT@: $(REPLACETORT_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(REPLACETORT_OBJ) $(LDFLAGS) \ $(DYNEXP) $(LIBS) @POPTLIBS@ -bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ +bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/msgtest@EXEEXT@: $(BINARY_PREREQS) $(MSGTEST_OBJ) @BUILD_POPT@ +bin/msgtest@EXEEXT@: $(BINARY_PREREQS) $(MSGTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbcacls@EXEEXT@: $(BINARY_PREREQS) $(SMBCACLS_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/smbcacls@EXEEXT@: $(BINARY_PREREQS) $(SMBCACLS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/smbcquotas@EXEEXT@: $(BINARY_PREREQS) $(SMBCQUOTAS_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/smbcquotas@EXEEXT@: $(BINARY_PREREQS) $(SMBCQUOTAS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBCQUOTAS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/eventlogadm@EXEEXT@: $(BINARY_PREREQS) $(EVTLOGADM_OBJ) @BUILD_POPT@ +bin/eventlogadm@EXEEXT@: $(BINARY_PREREQS) $(EVTLOGADM_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/sharesec@EXEEXT@: $(BINARY_PREREQS) $(SHARESEC_OBJ) @BUILD_POPT@ +bin/sharesec@EXEEXT@: $(BINARY_PREREQS) $(SHARESEC_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ +bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ +bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(LIBS) @POPTLIBS@ @LIBWBCLIENT_SHARED@ + @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(LIBS) @POPTLIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ -bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) $(ACL_LIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) @SMBD_LIBS@ $(NSCD_LIBS) @LIBWBCLIENT_SHARED@ + @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) $(ACL_LIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) @SMBD_LIBS@ $(NSCD_LIBS) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ @echo Linking $@ @@ -1400,52 +1414,52 @@ bin/log2pcap@EXEEXT@: $(BINARY_PREREQS) $(LOG2PCAP_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LOG2PCAP_OBJ) $(LDFLAGS) $(DYNEXP) @POPTLIBS@ $(LIBS) -bin/locktest2@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST2_OBJ) @BUILD_POPT@ +bin/locktest2@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST2_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/ndrdump@EXEEXT@: $(BINARY_PREREQS) $(NDRDUMP_OBJ) @BUILD_POPT@ +bin/ndrdump@EXEEXT@: $(BINARY_PREREQS) $(NDRDUMP_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NDRDUMP_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - @POPTLIBS@ @LDAP_LIBS@ + @POPTLIBS@ @LDAP_LIBS@ @LIBTDB_LIBS@ bin/debug2html@EXEEXT@: $(BINARY_PREREQS) $(DEBUG2HTML_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) -bin/smbfilter@EXEEXT@: $(BINARY_PREREQS) $(SMBFILTER_OBJ) @BUILD_POPT@ +bin/smbfilter@EXEEXT@: $(BINARY_PREREQS) $(SMBFILTER_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/ldbedit: $(BINARY_PREREQS) $(LDBEDIT_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/ldbedit: $(BINARY_PREREQS) $(LDBEDIT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBEDIT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/ldbsearch: $(BINARY_PREREQS) $(LDBSEARCH_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/ldbsearch: $(BINARY_PREREQS) $(LDBSEARCH_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBSEARCH_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/ldbadd: $(BINARY_PREREQS) $(LDBADD_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/ldbadd: $(BINARY_PREREQS) $(LDBADD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBADD_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/ldbmodify: $(BINARY_PREREQS) $(LDBMODIFY_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/ldbmodify: $(BINARY_PREREQS) $(LDBMODIFY_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBMODIFY_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/ldbdel: $(BINARY_PREREQS) $(LDBDEL_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/ldbdel: $(BINARY_PREREQS) $(LDBDEL_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBDEL_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ $(LIBTALLOC_SHARED_TARGET): $(BINARY_PREREQS) $(LIBTALLOC_OBJ) @echo Linking shared library $@ @@ -1457,6 +1471,16 @@ $(LIBTALLOC_STATIC_TARGET): $(BINARY_PREREQS) $(LIBTALLOC_OBJ0) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBTALLOC_OBJ0) +$(LIBTDB_SHARED_TARGET): $(BINARY_PREREQS) $(LIBTDB_OBJ) + @echo Linking shared library $@ + @$(SHLD_DSO) $(LIBTDB_OBJ) \ + @SONAMEFLAG@`basename $@`.$(SONAME_VER) + @ln -s -f `basename $@` $@.$(SONAME_VER) + +$(LIBTDB_STATIC_TARGET): $(BINARY_PREREQS) $(LIBTDB_OBJ0) + @echo Linking non-shared library $@ + @-$(AR) -rc $@ $(LIBTDB_OBJ0) + bin/libwbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBWBCLIENT_OBJ) @LIBTALLOC_SHARED@ @echo Linking shared library $@ @$(SHLD_DSO) @LIBTALLOC_LIBS@ $(LIBWBCLIENT_OBJ) \ @@ -1521,6 +1545,7 @@ bin/libbigballofmud.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBBIGBALLOFMUD_OBJ) # library. libtalloc: $(LIBTALLOC) +libtdb: $(LIBTDB) libsmbclient: $(LIBSMBCLIENT) libsmbsharemodes: $(LIBSMBSHAREMODES) libaddns: $(LIBADDNS) @@ -1591,16 +1616,16 @@ bin/librpc_echo.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_ECHO_OBJ) @echo "Linking $@" @$(SHLD_MODULE) $(RPC_ECHO_OBJ) -bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" @$(CC) $(FLAGS) -o $@ $(WINBINDD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) \ - $(PASSDB_LIBS) @WINBIND_LIBS@ + $(PASSDB_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBWBCLIENT_SHARED@ +bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" @$(CC) $(FLAGS) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBWBCLIENT_SHARED@ + $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ @WINBIND_NSS@: $(BINARY_PREREQS) $(WINBIND_NSS_OBJ) @echo "Linking $@" @@ -1840,37 +1865,38 @@ bin/fileid.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_FILEID_OBJ) ## None here right now ######################################################### -bin/wbinfo@EXEEXT@: $(BINARY_PREREQS) $(WBINFO_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ +bin/wbinfo@EXEEXT@: $(BINARY_PREREQS) $(WBINFO_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(WBINFO_OBJ) $(DYNEXP) $(LIBS) \ - $(LDAP_LIBS) @POPTLIBS@ @WINBIND_LIBS@ + $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \ - $(LIB_NONSMBD_OBJ) @BUILD_POPT@ @LIBWBCLIENT_SHARED@ + $(LIB_NONSMBD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(NTLM_AUTH_OBJ) \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBS) \ - @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @WINBIND_LIBS@ + @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ + @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) @echo "Linking shared library $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) -bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) +bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) $(TDBBACKUP_OBJ) + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ $(TDBBACKUP_OBJ) -bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) +bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) $(TDBTOOL_OBJ) + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTDB_SHARED@ $(TDBTOOL_OBJ) -bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) +bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) $(TDBDUMP_OBJ) + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ $(TDBDUMP_OBJ) -bin/tdbtorture@EXEEXT@: $(BINARY_PREREQS) $(TDBTORTURE_OBJ) +bin/tdbtorture@EXEEXT@: $(BINARY_PREREQS) $(TDBTORTURE_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) $(TDBTORTURE_OBJ) + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ $(TDBTORTURE_OBJ) bin/t_strcmp@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_strcmp.o $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_strcmp.o -L ./bin -lbigballofmud @@ -1891,6 +1917,7 @@ bin/timelimit@EXEEXT@: script/tests/timelimit.o install: installservers installbin @INSTALL_CIFSMOUNT@ @INSTALL_CIFSSPNEGO@ installman \ installscripts installdat installmodules @SWAT_INSTALL_TARGETS@ \ installlibtalloc \ + installlibtdb \ @INSTALL_LIBSMBCLIENT@ @INSTALL_PAM_MODULES@ \ @INSTALL_LIBSMBSHAREMODES@ @INSTALL_LIBWBCLIENT@ installlibnetapi @@ -1966,6 +1993,13 @@ installlibtalloc: installdirs libtalloc @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) ${prefix}/include -$(INSTALLCMD) -m $(INSTALLPERMS_DATA) @tallocdir@/talloc.h $(DESTDIR)${prefix}/include +installlibtdb: installdirs libtdb + @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(LIBDIR) + -$(INSTALLLIBCMD_SH) $(LIBTDB_SHARED_TARGET) $(DESTDIR)$(LIBDIR) + -$(INSTALLLIBCMD_A) $(LIBTDB_STATIC_TARGET) $(DESTDIR)$(LIBDIR) + @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) ${prefix}/include + -$(INSTALLCMD) -m $(INSTALLPERMS_DATA) @tdbdir@/include/tdb.h $(DESTDIR)${prefix}/include + installlibsmbsharemodes: installdirs libsmbsharemodes @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(LIBDIR) -$(INSTALLLIBCMD_SH) bin/libsmbsharemodes.@SHLIBEXT@ $(DESTDIR)$(LIBDIR) @@ -2023,7 +2057,7 @@ showlayout: @echo " swatdir: $(SWATDIR)" -uninstall: uninstallman uninstallservers uninstallbin @UNINSTALL_CIFSMOUNT@ @UNINSTALL_CIFSSPNEGO@ uninstallscripts uninstalldat uninstallswat uninstallmodules uninstalllibtalloc @UNINSTALL_LIBSMBCLIENT@ @UNINSTALL_PAM_MODULES@ @UNINSTALL_LIBSMBSHAREMODES@ uninstalllibnetapi +uninstall: uninstallman uninstallservers uninstallbin @UNINSTALL_CIFSMOUNT@ @UNINSTALL_CIFSSPNEGO@ uninstallscripts uninstalldat uninstallswat uninstallmodules uninstalllibtalloc uninstalllibtdb @UNINSTALL_LIBSMBCLIENT@ @UNINSTALL_PAM_MODULES@ @UNINSTALL_LIBSMBSHAREMODES@ uninstalllibnetapi uninstallman: @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(srcdir) C diff --git a/source3/configure.in b/source3/configure.in index 70d573c7a2..aa024c6e59 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -280,10 +280,26 @@ for obj in ${TALLOC_OBJ}; do done AC_SUBST(TALLOC_OBJS) +# TODO: These should come from m4_include(lib/tdb/libtdb.m4) +# but currently this fails: things have to get merged from s4. +tdbdir="lib/tdb" +AC_SUBST(tdbdir) +TDB_CFLAGS="-I$tdbdir/include" +AC_SUBST(TDB_CFLAGS) +TDB_OBJ="common/tdb.o common/dump.o common/transaction.o common/error.o common/traverse.o" +TDB_OBJ="$TDB_OBJ common/freelist.o common/freelistcheck.o common/io.o common/lock.o common/open.o" +AC_SUBST(TDB_OBJ) + +TDB_OBJS="" +for obj in ${TDB_OBJ}; do + TDB_OBJS="${TDB_OBJS} ${tdbdir}/${obj}" +done +AC_SUBST(TDB_OBJS) + SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include -I. -I${srcdir-.}" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/replace" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}" -SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/tdb/include" +SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc" @@ -337,6 +353,12 @@ AC_SUBST(LIBTALLOC_SHARED) AC_SUBST(LIBTALLOC_STATIC) AC_SUBST(LIBTALLOC_LIBS) +AC_SUBST(LIBTDB_STATIC_TARGET) +AC_SUBST(LIBTDB_SHARED_TARGET) +AC_SUBST(LIBTDB_SHARED) +AC_SUBST(LIBTDB_STATIC) +AC_SUBST(LIBTDB_LIBS) + AC_SUBST(INSTALL_LIBWBCLIENT) AC_SUBST(UNINSTALL_LIBWBCLIENT) AC_SUBST(LIBWBCLIENT_SHARED) @@ -5211,6 +5233,49 @@ if test $enable_static = yes; then LIBTALLOC_STATIC=$LIBTALLOC_STATIC_TARGET fi +################################################# +# should we build libtdb? +LIBTDB_SHARED_TARGET=bin/libtdb.$SHLIBEXT +LIBTDB_STATIC_TARGET=bin/libtdb.a +LIBTDB_SHARED= +LIBTDB_STATIC= +LIBTDB_LIBS= + +AC_MSG_CHECKING(whether to build the libtdb shared library) +AC_ARG_WITH(libtdb, +[AS_HELP_STRING([--with-libtdb], + [Build the libtdb shared library (default=yes if shared libs supported)])], +[ +case "$withval" in + *) + AC_MSG_RESULT(no) + ;; + yes) + samba_cv_with_libtdb=yes + ;; +esac +], +[ +# if unspecified, default is to build it if possible. +samba_cv_with_libtdb=yes +] +) + +if test x"$samba_cv_with_libtdb" = "xyes" -a $BLDSHARED = true; then + LIBTDB_SHARED=$LIBTDB_SHARED_TARGET + AC_MSG_RESULT(yes) + if test x"$LINK_LIBTDB" = "xSTATIC" ; then + LIBTDB_STATIC=$LIBTDB_STATIC_TARGET + else + LIBTDB_LIBS=-ltdb + fi +else + enable_static=yes + AC_MSG_RESULT(no shared library support -- will supply static library) +fi +if test $enable_static = yes; then + LIBTDB_STATIC=$LIBTDB_STATIC_TARGET +fi ################################################# # should we build libnetapi? diff --git a/source3/exports/libtdb.syms b/source3/exports/libtdb.syms new file mode 100644 index 0000000000..5d24771a1a --- /dev/null +++ b/source3/exports/libtdb.syms @@ -0,0 +1,4 @@ +{ + global: tdb_*; + local: *; +}; diff --git a/source3/library-versions.in b/source3/library-versions.in index 2d69d3e02c..e8ef0645a7 100644 --- a/source3/library-versions.in +++ b/source3/library-versions.in @@ -3,6 +3,7 @@ ## Makefile_target:major:minor ## bin/libtalloc.@SHLIBEXT@:1:0 +bin/libtdb.@SHLIBEXT@:0:1 bin/libsmbclient.@SHLIBEXT@:0:1 bin/libsmbsharemodes.@SHLIBEXT@:0:2 bin/libaddns.@SHLIBEXT@:0:1 -- cgit From b09b3ac8f88d7b89501193efca3615518218d6f1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 14 Feb 2008 14:15:07 +0100 Subject: Create symbols to export in libtdb dynamically from tdb.h. This adds a general mechanism to create version-scripts for linking shared libraries from one or several header files, similar to mkproto.sh/awk. Michael (This used to be commit 65817703c49a7410f4f0c8b46494ede6169d9fa6) --- source3/Makefile.in | 14 +++++++-- source3/exports/libtdb.syms | 4 --- source3/script/mksyms.awk | 76 +++++++++++++++++++++++++++++++++++++++++++++ source3/script/mksyms.sh | 45 +++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 7 deletions(-) delete mode 100644 source3/exports/libtdb.syms create mode 100644 source3/script/mksyms.awk create mode 100755 source3/script/mksyms.sh (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 9b210cc9e7..0e2e22ca86 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -148,6 +148,8 @@ LIBTALLOC=$(LIBTALLOC_STATIC_TARGET) @LIBTALLOC_SHARED@ LIBTDB_SHARED_TARGET=@LIBTDB_SHARED_TARGET@ LIBTDB_STATIC_TARGET=@LIBTDB_STATIC_TARGET@ LIBTDB=$(LIBTDB_STATIC_TARGET) @LIBTDB_SHARED@ +LIBTDB_SYMS=exports/libtdb.syms +LIBTDB_HEADERS=@tdbdir@/include/tdb.h LIBSMBCLIENT=bin/libsmbclient.a @LIBSMBCLIENT_SHARED@ LIBSMBSHAREMODES=bin/libsmbsharemodes.a @LIBSMBSHAREMODES_SHARED@ @@ -1471,7 +1473,12 @@ $(LIBTALLOC_STATIC_TARGET): $(BINARY_PREREQS) $(LIBTALLOC_OBJ0) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBTALLOC_OBJ0) -$(LIBTDB_SHARED_TARGET): $(BINARY_PREREQS) $(LIBTDB_OBJ) +MKSYMS_SH = $(srcdir)/script/mksyms.sh + +$(LIBTDB_SYMS): $(LIBTDB_HEADERS) + @$(MKSYMS_SH) $(AWK) $@ $(LIBTDB_HEADERS) + +$(LIBTDB_SHARED_TARGET): $(BINARY_PREREQS) $(LIBTDB_OBJ) $(LIBTDB_SYMS) @echo Linking shared library $@ @$(SHLD_DSO) $(LIBTDB_OBJ) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @@ -1998,7 +2005,7 @@ installlibtdb: installdirs libtdb -$(INSTALLLIBCMD_SH) $(LIBTDB_SHARED_TARGET) $(DESTDIR)$(LIBDIR) -$(INSTALLLIBCMD_A) $(LIBTDB_STATIC_TARGET) $(DESTDIR)$(LIBDIR) @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) ${prefix}/include - -$(INSTALLCMD) -m $(INSTALLPERMS_DATA) @tdbdir@/include/tdb.h $(DESTDIR)${prefix}/include + -$(INSTALLCMD) -m $(INSTALLPERMS_DATA) $(LIBTDB_HEADERS) $(DESTDIR)${prefix}/include installlibsmbsharemodes: installdirs libsmbsharemodes @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(LIBDIR) @@ -2132,7 +2139,8 @@ clean: delheaders $(LIBTALLOC) $(LIBSMBCLIENT) $(LIBADDNS) \ $(LIBSMBSHAREMODES) $(EVERYTHING_PROGS) $(LIBNETAPI) \ bin/libwbclient.so.0 bin/timelimit \ - .headers.stamp */src/*.o proto_exists + .headers.stamp */src/*.o proto_exists \ + $(LIBTDB_SYMS) -rm -rf t_dir # Making this target will just make sure that the prototype files diff --git a/source3/exports/libtdb.syms b/source3/exports/libtdb.syms deleted file mode 100644 index 5d24771a1a..0000000000 --- a/source3/exports/libtdb.syms +++ /dev/null @@ -1,4 +0,0 @@ -{ - global: tdb_*; - local: *; -}; diff --git a/source3/script/mksyms.awk b/source3/script/mksyms.awk new file mode 100644 index 0000000000..a30bea4d34 --- /dev/null +++ b/source3/script/mksyms.awk @@ -0,0 +1,76 @@ +# +# mksyms.awk +# +# Extract symbols to export from C-header files. +# output in version-script format for linking shared libraries. +# +# Copyright (C) 2008 Micheal Adam +# +BEGIN { + inheader=0; + current_file=""; + print "#" + print "# This file is automatically generated with \"make symbols\". DO NOT EDIT " + print "#" + print "{" + print "\tglobal:" +} + +END { + print"" + print "\tlocal: *;" + print "};" +} + +{ + if (FILENAME!=current_file) { + print "\t\t# The following definitions come from",FILENAME + current_file=FILENAME + } + if (inheader) { + if (match($0,"[)][ \t]*[;][ \t]*$")) { + inheader = 0; + } + next; + } +} + +/^static/ || /^[ \t]*typedef/ || !/^[a-zA-Z\_]/ { + next; +} + +/^extern[ \t]+[^()]+[;][ \t]*$/ { + gsub(/[^ \t]+[ \t]+/, ""); + sub(/[;][ \t]*$/, ""); + printf "\t\t%s;\n", $0; + next; +} + +# look for function headers: +{ + gotstart = 0; + if ($0 ~ /^[A-Za-z_][A-Za-z0-9_]+/) { + gotstart = 1; + } + if(!gotstart) { + next; + } +} + +/[_A-Za-z0-9]+[ \t]*[(].*[)][ \t]*;[ \t]*$/ { + sub(/[(].*$/, ""); + gsub(/[^ \t]+[ \t]+/, ""); + gsub(/^[*]/, ""); + printf "\t\t%s;\n",$0; + next; +} + +/[_A-Za-z0-9]+[ \t]*[(]/ { + inheader=1; + sub(/[(].*$/, ""); + gsub(/[^ \t]+[ \t]+/, ""); + gsub(/^[*]/, ""); + printf "\t\t%s;\n",$0; + next; +} + diff --git a/source3/script/mksyms.sh b/source3/script/mksyms.sh new file mode 100755 index 0000000000..637ec5027c --- /dev/null +++ b/source3/script/mksyms.sh @@ -0,0 +1,45 @@ +#! /bin/sh + +# +# mksyms.sh +# +# Extract symbols to export from C-header files. +# output in version-script format for linking shared libraries. +# +# This is the shell warpper for the mksyms.awk core script. +# +# Copyright (C) 2008 Micheal Adam +# + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_COLLATE=C; export LC_COLLATE + +if [ $# -lt 2 ] +then + echo "Usage: $0 awk output_file header_files" + exit 1 +fi + +awk="$1" +shift + +symsfile="$1" +shift +symsfile_tmp="$symsfile.$$.tmp~" + +proto_src="`echo $@ | tr ' ' '\n' | sort | uniq `" + +echo creating $symsfile + +mkdir -p `dirname $symsfile` + +${awk} -f script/mksyms.awk $proto_src > $symsfile_tmp + +if cmp -s $symsfile $symsfile_tmp 2>/dev/null +then + echo "$symsfile unchanged" + rm $symsfile_tmp +else + mv $symsfile_tmp $symsfile +fi -- cgit From 3329432d1f6e9dab31a970b2b407374c144d68ba Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 14:22:25 +0100 Subject: Fix IDL for lsa_AddAccountRights. Guenther (This used to be commit 7319986a3e9a640ea2d605dc7a2104f43f74f8a2) --- source3/librpc/idl/lsa.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 6bb34a9dc5..df948bc68e 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -682,7 +682,7 @@ import "security.idl"; } lsa_RightAttribute; typedef struct { - uint32 count; + [range(0,256)] uint32 count; [size_is(count)] lsa_StringLarge *names; } lsa_RightSet; @@ -697,8 +697,8 @@ import "security.idl"; /* Function: 0x25 */ NTSTATUS lsa_AddAccountRights ( [in] policy_handle *handle, - [in] dom_sid2 *sid, - [in] lsa_RightSet *rights + [in,ref] dom_sid2 *sid, + [in,ref] lsa_RightSet *rights ); /**********************/ -- cgit From 01f5d15b2c0e988e9f9cea36bcdd776be2536b71 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 14:36:30 +0100 Subject: Re-run make idl. Guenther (This used to be commit 5137ebe068c32ce7cb204cff049ba7f7f2d86abc) --- source3/librpc/gen_ndr/ndr_lsa.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index 12544b1b72..a95665f0fa 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -3288,6 +3288,9 @@ static enum ndr_err_code ndr_pull_lsa_RightSet(struct ndr_pull *ndr, int ndr_fla if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count)); + if (r->count < 0 || r->count > 256) { + return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); + } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_names)); if (_ptr_names) { NDR_PULL_ALLOC(ndr, r->names); -- cgit From b9bc1ac1b92f993a71f6eb64b15f486538bf50d7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 14:21:49 +0100 Subject: Use pidl for _lsa_AddAccountRights(). Guenther (This used to be commit 253cf1523871f2218e9e59b0a01f47b8bc745ac9) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 34 ++++++++++------------------------ 2 files changed, 11 insertions(+), 47 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index ff274473d6..33686e575f 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -276,29 +276,7 @@ static bool api_lsa_query_secobj(pipes_struct *p) static bool api_lsa_add_acct_rights(pipes_struct *p) { - LSA_Q_ADD_ACCT_RIGHTS q_u; - LSA_R_ADD_ACCT_RIGHTS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_add_acct_rights("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_add_acct_rights: failed to unmarshall LSA_Q_ADD_ACCT_RIGHTS.\n")); - return False; - } - - r_u.status = _lsa_add_acct_rights(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_add_acct_rights("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_add_acct_rights: Failed to marshall LSA_R_ADD_ACCT_RIGHTS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ADDACCOUNTRIGHTS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 10842a1ada..0be72c5d75 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2042,19 +2042,18 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, #endif /* AD DC work in ongoing in Samba 4 */ /*************************************************************************** + _lsa_AddAccountRights ***************************************************************************/ -NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R_ADD_ACCT_RIGHTS *r_u) +NTSTATUS _lsa_AddAccountRights(pipes_struct *p, + struct lsa_AddAccountRights *r) { struct lsa_info *info = NULL; int i = 0; DOM_SID sid; - fstring privname; - UNISTR4_ARRAY *uni_privnames = q_u->rights; - /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -2069,27 +2068,20 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ - sid_copy( &sid, &q_u->sid.sid ); + sid_copy( &sid, r->in.sid ); - /* just a little sanity check */ - - if ( q_u->count != uni_privnames->count ) { - DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); - return NT_STATUS_INVALID_HANDLE; - } + for ( i=0; i < r->in.rights->count; i++ ) { - for ( i=0; icount; i++ ) { - UNISTR4 *uni4_str = &uni_privnames->strings[i]; + const char *privname = r->in.rights->names[i].string; /* only try to add non-null strings */ - if ( !uni4_str->string ) + if ( !privname ) continue; - rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - if ( !grant_privilege_by_name( &sid, privname ) ) { - DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname )); + DEBUG(2,("_lsa_AddAccountRights: Failed to add privilege [%s]\n", + privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; } } @@ -2328,12 +2320,6 @@ NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct lsa_EnumAccountRights *r return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_AddAccountRights(pipes_struct *p, struct lsa_AddAccountRights *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r) { p->rng_fault_state = True; -- cgit From 96aa5dea8e53eaa96511d8091101da7d88046396 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 14:34:10 +0100 Subject: Use rpccli_lsa_AddAccountRights in net and rpcclient. Guenther (This used to be commit e94ded74d6541d1d8954cfbbbd577ca0c83ecd4c) --- source3/rpcclient/cmd_lsarpc.c | 20 +++++++++++++++++--- source3/utils/net_rpc_rights.c | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 120fb9b173..079a914830 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -762,8 +762,9 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli, { POLICY_HND dom_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - + struct lsa_RightSet rights; DOM_SID sid; + int i; if (argc < 3 ) { printf("Usage: %s SID [rights...]\n", argv[0]); @@ -781,8 +782,21 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_add_account_rights(cli, mem_ctx, &dom_pol, sid, - argc-2, argv+2); + rights.count = argc-2; + rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, + rights.count); + if (!rights.names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i Date: Thu, 14 Feb 2008 14:35:27 +0100 Subject: Remove unused marshalling for LSA_ADD_ACCT_RIGHTS. Guenther (This used to be commit 15b97d1aafd6c8ad936944b611188154b191167f) --- source3/include/rpc_lsa.h | 16 ----------- source3/rpc_client/cli_lsarpc.c | 36 ------------------------- source3/rpc_parse/parse_lsa.c | 59 ----------------------------------------- 3 files changed, 111 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index e7e013f8aa..1b82342cfc 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -462,22 +462,6 @@ typedef struct } LSA_R_ENUM_ACCT_RIGHTS; -/* LSA_Q_ADD_ACCT_RIGHTS - LSA add account rights */ -typedef struct -{ - POLICY_HND pol; /* policy handle */ - DOM_SID2 sid; - uint32 count; - UNISTR4_ARRAY *rights; -} LSA_Q_ADD_ACCT_RIGHTS; - -/* LSA_R_ADD_ACCT_RIGHTS - LSA add account rights */ -typedef struct -{ - NTSTATUS status; -} LSA_R_ADD_ACCT_RIGHTS; - - /* LSA_Q_REMOVE_ACCT_RIGHTS - LSA remove account rights */ typedef struct { diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index 9d9a131a1a..1395aa6632 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -522,42 +522,6 @@ done: } - -/* add account rights to an account. */ - -NTSTATUS rpccli_lsa_add_account_rights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, DOM_SID sid, - uint32 count, const char **privs_name) -{ - prs_struct qbuf, rbuf; - LSA_Q_ADD_ACCT_RIGHTS q; - LSA_R_ADD_ACCT_RIGHTS r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - init_q_add_acct_rights(&q, pol, &sid, count, privs_name); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_ADDACCTRIGHTS, - q, r, - qbuf, rbuf, - lsa_io_q_add_acct_rights, - lsa_io_r_add_acct_rights, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } -done: - - return result; -} - - /* remove account rights for an account. */ NTSTATUS rpccli_lsa_remove_account_rights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index d4d32531a0..05841e59a7 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -1311,65 +1311,6 @@ bool lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *out, pr } -/******************************************************************* - Inits an LSA_Q_ADD_ACCT_RIGHTS structure. -********************************************************************/ -void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *in, POLICY_HND *hnd, - DOM_SID *sid, uint32 count, const char **rights ) -{ - DEBUG(5, ("init_q_add_acct_rights\n")); - - in->pol = *hnd; - init_dom_sid2(&in->sid, sid); - - in->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY ); - if (!in->rights) { - smb_panic("init_q_add_acct_rights: talloc fail\n"); - return; - } - init_unistr4_array( in->rights, count, rights ); - - in->count = count; -} - - -/******************************************************************* -reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure. -********************************************************************/ -bool lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *in, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights"); - depth++; - - if (!smb_io_pol_hnd("", &in->pol, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &in->sid, ps, depth)) - return False; - - if(!prs_uint32("count", ps, depth, &in->count)) - return False; - - if ( !prs_pointer("rights", ps, depth, (void*)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) - return False; - - return True; -} - -/******************************************************************* -reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure. -********************************************************************/ -bool lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights"); - depth++; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - /******************************************************************* Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure. ********************************************************************/ -- cgit From 41b574783d4bdb86ee5c4a826d85705786948843 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:02:31 +0100 Subject: Use pidl for _lsa_EnumAccountRights(). Guenther (This used to be commit cb6a84712cf91d104206356f0ac256a071868d66) --- source3/rpc_server/srv_lsa.c | 24 +-------------- source3/rpc_server/srv_lsa_nt.c | 67 +++++++++++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 39 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 33686e575f..14cf0b3cc9 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -316,29 +316,7 @@ static bool api_lsa_remove_acct_rights(pipes_struct *p) static bool api_lsa_enum_acct_rights(pipes_struct *p) { - LSA_Q_ENUM_ACCT_RIGHTS q_u; - LSA_R_ENUM_ACCT_RIGHTS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_enum_acct_rights("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_enum_acct_rights: failed to unmarshall LSA_Q_ENUM_ACCT_RIGHTS.\n")); - return False; - } - - r_u.status = _lsa_enum_acct_rights(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_enum_acct_rights("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_enum_acct_rights: Failed to marshall LSA_R_ENUM_ACCT_RIGHTS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ENUMACCOUNTRIGHTS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 0be72c5d75..a709877d6e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2149,27 +2149,69 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, return NT_STATUS_OK; } +/******************************************************************* +********************************************************************/ + +static NTSTATUS init_lsa_right_set(TALLOC_CTX *mem_ctx, + struct lsa_RightSet *r, + PRIVILEGE_SET *privileges) +{ + uint32 i; + const char *privname; + const char **privname_array = NULL; + int num_priv = 0; + + for (i=0; icount; i++) { + + privname = luid_to_privilege_name(&privileges->set[i].luid); + if (privname) { + if (!add_string_to_array(mem_ctx, privname, + &privname_array, &num_priv)) { + return NT_STATUS_NO_MEMORY; + } + } + } + + if (num_priv) { + + r->names = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_StringLarge, + num_priv); + if (!r->names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; inames[i], privname_array[i]); + } + + r->count = num_priv; + } + + return NT_STATUS_OK; +} /*************************************************************************** + _lsa_EnumAccountRights ***************************************************************************/ -NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA_R_ENUM_ACCT_RIGHTS *r_u) +NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, + struct lsa_EnumAccountRights *r) { + NTSTATUS status; struct lsa_info *info = NULL; DOM_SID sid; PRIVILEGE_SET privileges; SE_PRIV mask; - /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ - sid_copy( &sid, &q_u->sid.sid ); + sid_copy( &sid, r->in.sid ); if ( !get_privileges_for_sids( &mask, &sid, 1 ) ) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2178,20 +2220,19 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA if ( se_priv_to_privilege_set( &privileges, &mask ) ) { - DEBUG(10,("_lsa_enum_acct_rights: %s has %d privileges\n", + DEBUG(10,("_lsa_EnumAccountRights: %s has %d privileges\n", sid_string_dbg(&sid), privileges.count)); - r_u->status = init_r_enum_acct_rights( r_u, &privileges ); + status = init_lsa_right_set(p->mem_ctx, r->out.rights, &privileges); + } else { + status = NT_STATUS_NO_SUCH_PRIVILEGE; } - else - r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE; privilege_set_free( &privileges ); - return r_u->status; + return status; } - /*************************************************************************** _lsa_LookupPrivValue ***************************************************************************/ @@ -2314,12 +2355,6 @@ NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccounts return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct lsa_EnumAccountRights *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r) { p->rng_fault_state = True; -- cgit From 235efc0ede0a4951f4f6c4714e1bfd123d0816bd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:02:59 +0100 Subject: Fix IDL for lsa_EnumAccountRights. Guenther (This used to be commit ef9b65dd115591d8976f0248cf1c639fd05c03d7) --- source3/librpc/idl/lsa.idl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index df948bc68e..aad9c3b9a1 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -688,8 +688,8 @@ import "security.idl"; NTSTATUS lsa_EnumAccountRights ( [in] policy_handle *handle, - [in] dom_sid2 *sid, - [out] lsa_RightSet *rights + [in,ref] dom_sid2 *sid, + [out,ref] lsa_RightSet *rights ); -- cgit From 7b5ef3569f081e29890594b533ee0062deec0b15 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:09:21 +0100 Subject: Use rpccli_lsa_EnumAccountRights in net and rpcclient. Guenther (This used to be commit 6e9195329d9f2b26c959f64485902c032f140ec8) --- source3/rpcclient/cmd_lsarpc.c | 15 ++++++++------- source3/utils/net_rpc_rights.c | 33 +++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 21 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 079a914830..d7f5e55df4 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -713,10 +713,8 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli, { POLICY_HND dom_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_SID sid; - uint32 count; - char **rights; + struct lsa_RightSet rights; int i; @@ -736,16 +734,19 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_enum_account_rights(cli, mem_ctx, &dom_pol, &sid, &count, &rights); + result = rpccli_lsa_EnumAccountRights(cli, mem_ctx, + &dom_pol, + &sid, + &rights); if (!NT_STATUS_IS_OK(result)) goto done; - printf("found %d privileges for SID %s\n", count, + printf("found %d privileges for SID %s\n", rights.count, sid_string_tos(&sid)); - for (i = 0; i < count; i++) { - printf("\t%s\n", rights[i]); + for (i = 0; i < rights.count; i++) { + printf("\t%s\n", rights.names[i].string); } rpccli_lsa_Close(cli, mem_ctx, &dom_pol); diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index 9ba0eaae00..a0df5d8980 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -152,22 +152,24 @@ static NTSTATUS check_privilege_for_user(struct rpc_pipe_client *pipe_hnd, const char *right) { NTSTATUS result; - uint32 count; - char **rights; + struct lsa_RightSet rights; int i; - result = rpccli_lsa_enum_account_rights(pipe_hnd, ctx, pol, sid, &count, &rights); + result = rpccli_lsa_EnumAccountRights(pipe_hnd, ctx, + pol, + sid, + &rights); if (!NT_STATUS_IS_OK(result)) { return result; } - if (count == 0) { + if (rights.count == 0) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - - for (i = 0; i < count; i++) { - if (StrCaseCmp(rights[i], right) == 0) { + + for (i = 0; i < rights.count; i++) { + if (StrCaseCmp(rights.names[i].string, right) == 0) { return NT_STATUS_OK; } } @@ -184,20 +186,23 @@ static NTSTATUS enum_privileges_for_user(struct rpc_pipe_client *pipe_hnd, DOM_SID *sid ) { NTSTATUS result; - uint32 count; - char **rights; + struct lsa_RightSet rights; int i; - result = rpccli_lsa_enum_account_rights(pipe_hnd, ctx, pol, sid, &count, &rights); + result = rpccli_lsa_EnumAccountRights(pipe_hnd, ctx, + pol, + sid, + &rights); if (!NT_STATUS_IS_OK(result)) return result; - if ( count == 0 ) + if (rights.count == 0) { d_printf("No privileges assigned\n"); - - for (i = 0; i < count; i++) { - printf("%s\n", rights[i]); + } + + for (i = 0; i < rights.count; i++) { + printf("%s\n", rights.names[i].string); } return NT_STATUS_OK; -- cgit From d64ae7328ad3fdf587ec939f02189ff9439acea8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:11:35 +0100 Subject: Remove unused marshalling for LSA_ENUM_ACCT_RIGHTS. Guenther (This used to be commit 34c0e64026b7f5f223c7d7f1d7e162b5659f3bd3) --- source3/include/rpc_lsa.h | 16 ------- source3/rpc_client/cli_lsarpc.c | 70 ------------------------------- source3/rpc_parse/parse_lsa.c | 92 ----------------------------------------- 3 files changed, 178 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 1b82342cfc..0cfee2da61 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -446,22 +446,6 @@ typedef struct lsa_r_lookup_names4 NTSTATUS status; /* return code */ } LSA_R_LOOKUP_NAMES4; -/* LSA_Q_ENUM_ACCT_RIGHTS - LSA enum account rights */ -typedef struct -{ - POLICY_HND pol; /* policy handle */ - DOM_SID2 sid; -} LSA_Q_ENUM_ACCT_RIGHTS; - -/* LSA_R_ENUM_ACCT_RIGHTS - LSA enum account rights */ -typedef struct -{ - uint32 count; - UNISTR4_ARRAY *rights; - NTSTATUS status; -} LSA_R_ENUM_ACCT_RIGHTS; - - /* LSA_Q_REMOVE_ACCT_RIGHTS - LSA remove account rights */ typedef struct { diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index 1395aa6632..1de95920de 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -452,76 +452,6 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli, return result; } -/* Enumerate account rights This is similar to enum_privileges but - takes a SID directly, avoiding the open_account call. -*/ - -NTSTATUS rpccli_lsa_enum_account_rights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, DOM_SID *sid, - uint32 *count, char ***priv_names) -{ - prs_struct qbuf, rbuf; - LSA_Q_ENUM_ACCT_RIGHTS q; - LSA_R_ENUM_ACCT_RIGHTS r; - NTSTATUS result; - int i; - fstring *privileges; - char **names; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - init_q_enum_acct_rights(&q, pol, 2, sid); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_ENUMACCTRIGHTS, - q, r, - qbuf, rbuf, - lsa_io_q_enum_acct_rights, - lsa_io_r_enum_acct_rights, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - *count = r.count; - if (! *count) { - goto done; - } - - - privileges = TALLOC_ARRAY( mem_ctx, fstring, *count ); - names = TALLOC_ARRAY( mem_ctx, char *, *count ); - - if ((privileges == NULL) || (names == NULL)) { - TALLOC_FREE(privileges); - TALLOC_FREE(names); - return NT_STATUS_NO_MEMORY; - } - - for ( i=0; i<*count; i++ ) { - UNISTR4 *uni_string = &r.rights->strings[i]; - - if ( !uni_string->string ) - continue; - - rpcstr_pull( privileges[i], uni_string->string->buffer, sizeof(privileges[i]), -1, STR_TERMINATE ); - - /* now copy to the return array */ - names[i] = talloc_strdup( mem_ctx, privileges[i] ); - } - - *priv_names = names; - -done: - - return result; -} - - /* remove account rights for an account. */ NTSTATUS rpccli_lsa_remove_account_rights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index 05841e59a7..1a5c5e8a3e 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -1219,98 +1219,6 @@ bool policy_handle_is_valid(const POLICY_HND *hnd) return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True ); } -/******************************************************************* - Inits an LSA_Q_ENUM_ACCT_RIGHTS structure. -********************************************************************/ -void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *in, - POLICY_HND *hnd, - uint32 count, - DOM_SID *sid) -{ - DEBUG(5, ("init_q_enum_acct_rights\n")); - - in->pol = *hnd; - init_dom_sid2(&in->sid, sid); -} - -/******************************************************************* -********************************************************************/ -NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *out, PRIVILEGE_SET *privileges ) -{ - uint32 i; - const char *privname; - const char **privname_array = NULL; - int num_priv = 0; - - for ( i=0; icount; i++ ) { - privname = luid_to_privilege_name( &privileges->set[i].luid ); - if ( privname ) { - if ( !add_string_to_array( talloc_tos(), privname, &privname_array, &num_priv ) ) - return NT_STATUS_NO_MEMORY; - } - } - - if ( num_priv ) { - out->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY ); - if (!out->rights) { - return NT_STATUS_NO_MEMORY; - } - - if ( !init_unistr4_array( out->rights, num_priv, privname_array ) ) - return NT_STATUS_NO_MEMORY; - - out->count = num_priv; - } - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure. -********************************************************************/ -bool lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *in, prs_struct *ps, int depth) -{ - - if (in == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights"); - depth++; - - if (!smb_io_pol_hnd("", &in->pol, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &in->sid, ps, depth)) - return False; - - return True; -} - - -/******************************************************************* -reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure. -********************************************************************/ -bool lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights"); - depth++; - - if(!prs_uint32("count ", ps, depth, &out->count)) - return False; - - if ( !prs_pointer("rights", ps, depth, (void*)&out->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - - /******************************************************************* Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure. ********************************************************************/ -- cgit From fbe577a67e16695a5aa6df536c13aae356c3b4fd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:20:47 +0100 Subject: Fix IDL for lsa_RemoveAccountRights. Guenther (This used to be commit d65b2504de6e433e1ca3ea8aa839b4209dd1b99a) --- source3/librpc/idl/lsa.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index aad9c3b9a1..47fa9f43b6 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -705,9 +705,9 @@ import "security.idl"; /* Function: 0x26 */ NTSTATUS lsa_RemoveAccountRights ( [in] policy_handle *handle, - [in] dom_sid2 *sid, - [in] uint32 unknown, - [in] lsa_RightSet *rights + [in,ref] dom_sid2 *sid, + [in] uint8 remove_all, + [in,ref] lsa_RightSet *rights ); /* Function: 0x27 */ -- cgit From 1592cc3df2a38d47f5e215b12ef5fff3698561b4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:21:54 +0100 Subject: Re-run make idl. Guenther (This used to be commit 3436a54662fad1c69cfd1211f1afaa5a9d3d6d36) --- source3/librpc/gen_ndr/cli_lsa.c | 4 ++-- source3/librpc/gen_ndr/cli_lsa.h | 2 +- source3/librpc/gen_ndr/lsa.h | 4 ++-- source3/librpc/gen_ndr/ndr_lsa.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 205faa6e07..7484edca49 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -1667,7 +1667,7 @@ NTSTATUS rpccli_lsa_RemoveAccountRights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct dom_sid2 *sid, - uint32_t unknown, + uint8_t remove_all, struct lsa_RightSet *rights) { struct lsa_RemoveAccountRights r; @@ -1676,7 +1676,7 @@ NTSTATUS rpccli_lsa_RemoveAccountRights(struct rpc_pipe_client *cli, /* In parameters */ r.in.handle = handle; r.in.sid = sid; - r.in.unknown = unknown; + r.in.remove_all = remove_all; r.in.rights = rights; if (DEBUGLEVEL >= 10) { diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index 67aafe3d1a..e4bf43a1e8 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -192,7 +192,7 @@ NTSTATUS rpccli_lsa_RemoveAccountRights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct dom_sid2 *sid, - uint32_t unknown, + uint8_t remove_all, struct lsa_RightSet *rights); NTSTATUS rpccli_lsa_QueryTrustedDomainInfoBySid(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index a948f6d5e8..4a1ebdb7a9 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -448,7 +448,7 @@ struct lsa_RightAttribute { }; struct lsa_RightSet { - uint32_t count; + uint32_t count;/* [range(0,256)] */ struct lsa_StringLarge *names;/* [unique,size_is(count)] */ }; @@ -1104,7 +1104,7 @@ struct lsa_RemoveAccountRights { struct { struct policy_handle *handle;/* [ref] */ struct dom_sid2 *sid;/* [ref] */ - uint32_t unknown; + uint8_t remove_all; struct lsa_RightSet *rights;/* [ref] */ } in; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index a95665f0fa..74d8a314e1 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -8049,7 +8049,7 @@ static enum ndr_err_code ndr_push_lsa_RemoveAccountRights(struct ndr_push *ndr, return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sid)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown)); + NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->in.remove_all)); if (r->in.rights == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -8081,7 +8081,7 @@ static enum ndr_err_code ndr_pull_lsa_RemoveAccountRights(struct ndr_pull *ndr, NDR_PULL_SET_MEM_CTX(ndr, r->in.sid, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown)); + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->in.remove_all)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.rights); } @@ -8114,7 +8114,7 @@ _PUBLIC_ void ndr_print_lsa_RemoveAccountRights(struct ndr_print *ndr, const cha ndr->depth++; ndr_print_dom_sid2(ndr, "sid", r->in.sid); ndr->depth--; - ndr_print_uint32(ndr, "unknown", r->in.unknown); + ndr_print_uint8(ndr, "remove_all", r->in.remove_all); ndr_print_ptr(ndr, "rights", r->in.rights); ndr->depth++; ndr_print_lsa_RightSet(ndr, "rights", r->in.rights); -- cgit From 10462a5a795fe357c6487a85fedcb23adf8ab886 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:20:18 +0100 Subject: Use pidl for _lsa_RemoveAccountRights. Guenther (This used to be commit 39f8508f5d978a936779fdfd51b90fec4faa4301) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 37 ++++++++++++------------------------- 2 files changed, 13 insertions(+), 48 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 14cf0b3cc9..dfb3323873 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -285,29 +285,7 @@ static bool api_lsa_add_acct_rights(pipes_struct *p) static bool api_lsa_remove_acct_rights(pipes_struct *p) { - LSA_Q_REMOVE_ACCT_RIGHTS q_u; - LSA_R_REMOVE_ACCT_RIGHTS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_remove_acct_rights("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_remove_acct_rights: failed to unmarshall LSA_Q_REMOVE_ACCT_RIGHTS.\n")); - return False; - } - - r_u.status = _lsa_remove_acct_rights(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_remove_acct_rights("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_remove_acct_rights: Failed to marshall LSA_R_REMOVE_ACCT_RIGHTS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_REMOVEACCOUNTRIGHTS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a709877d6e..027277e8d9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2090,19 +2090,19 @@ NTSTATUS _lsa_AddAccountRights(pipes_struct *p, } /*************************************************************************** + _lsa_RemoveAccountRights ***************************************************************************/ -NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, LSA_R_REMOVE_ACCT_RIGHTS *r_u) +NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, + struct lsa_RemoveAccountRights *r) { struct lsa_info *info = NULL; int i = 0; DOM_SID sid; - fstring privname; - UNISTR4_ARRAY *uni_privnames = q_u->rights; - + const char *privname = NULL; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -2114,34 +2114,27 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, return NT_STATUS_ACCESS_DENIED; } - sid_copy( &sid, &q_u->sid.sid ); + sid_copy( &sid, r->in.sid ); - if ( q_u->removeall ) { + if ( r->in.remove_all ) { if ( !revoke_all_privileges( &sid ) ) return NT_STATUS_ACCESS_DENIED; return NT_STATUS_OK; } - /* just a little sanity check */ - - if ( q_u->count != uni_privnames->count ) { - DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); - return NT_STATUS_INVALID_HANDLE; - } + for ( i=0; i < r->in.rights->count; i++ ) { - for ( i=0; icount; i++ ) { - UNISTR4 *uni4_str = &uni_privnames->strings[i]; + privname = r->in.rights->names[i].string; /* only try to add non-null strings */ - if ( !uni4_str->string ) + if ( !privname ) continue; - rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - if ( !revoke_privilege_by_name( &sid, privname ) ) { - DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname )); + DEBUG(2,("_lsa_RemoveAccountRights: Failed to revoke privilege [%s]\n", + privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; } } @@ -2355,12 +2348,6 @@ NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccounts return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct lsa_QueryTrustedDomainInfoBySid *r) { p->rng_fault_state = True; -- cgit From f21cdab938a0a94405d595bb80fbda724315d984 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:28:26 +0100 Subject: Use rpccli_lsa_RemoveAccountRights() in net and rpcclient. Guenther (This used to be commit 78200d88924bbef3df7185fc3a0e1753160a592f) --- source3/rpcclient/cmd_lsarpc.c | 21 ++++++++++++++++++--- source3/utils/net_rpc_rights.c | 21 ++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index d7f5e55df4..3fe8bc8e52 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -816,8 +816,9 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli, { POLICY_HND dom_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - + struct lsa_RightSet rights; DOM_SID sid; + int i; if (argc < 3 ) { printf("Usage: %s SID [rights...]\n", argv[0]); @@ -835,8 +836,22 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_remove_account_rights(cli, mem_ctx, &dom_pol, sid, - False, argc-2, argv+2); + rights.count = argc-2; + rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, + rights.count); + if (!rights.names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i \n"); @@ -521,8 +522,22 @@ static NTSTATUS rpc_rights_revoke_internal(const DOM_SID *domain_sid, if (!NT_STATUS_IS_OK(result)) return result; - result = rpccli_lsa_remove_account_rights(pipe_hnd, mem_ctx, &dom_pol, sid, - False, argc-1, argv+1); + rights.count = argc-1; + rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, + rights.count); + if (!rights.names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i Date: Thu, 14 Feb 2008 15:29:51 +0100 Subject: Remove unused marshalling for LSA_REMOVE_ACCT_RIGHTS. Guenther (This used to be commit 80e39330bf15cc57f2780a5b900d8a2b14d92fa9) --- source3/include/rpc_lsa.h | 16 ---------- source3/rpc_client/cli_lsarpc.c | 35 --------------------- source3/rpc_parse/parse_lsa.c | 69 ----------------------------------------- 3 files changed, 120 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 0cfee2da61..dde014a4cc 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -446,20 +446,4 @@ typedef struct lsa_r_lookup_names4 NTSTATUS status; /* return code */ } LSA_R_LOOKUP_NAMES4; -/* LSA_Q_REMOVE_ACCT_RIGHTS - LSA remove account rights */ -typedef struct -{ - POLICY_HND pol; /* policy handle */ - DOM_SID2 sid; - uint32 removeall; - uint32 count; - UNISTR4_ARRAY *rights; -} LSA_Q_REMOVE_ACCT_RIGHTS; - -/* LSA_R_REMOVE_ACCT_RIGHTS - LSA remove account rights */ -typedef struct -{ - NTSTATUS status; -} LSA_R_REMOVE_ACCT_RIGHTS; - #endif /* _RPC_LSA_H */ diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index 1de95920de..a4c5331008 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -452,41 +452,6 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli, return result; } -/* remove account rights for an account. */ - -NTSTATUS rpccli_lsa_remove_account_rights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, DOM_SID sid, bool removeall, - uint32 count, const char **privs_name) -{ - prs_struct qbuf, rbuf; - LSA_Q_REMOVE_ACCT_RIGHTS q; - LSA_R_REMOVE_ACCT_RIGHTS r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Marshall data and send request */ - init_q_remove_acct_rights(&q, pol, &sid, removeall?1:0, count, privs_name); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_REMOVEACCTRIGHTS, - q, r, - qbuf, rbuf, - lsa_io_q_remove_acct_rights, - lsa_io_r_remove_acct_rights, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } -done: - - return result; -} - - #if 0 /** An example of how to use the routines in this file. Fetch a DOMAIN diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index 1a5c5e8a3e..80e90a8265 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -1218,72 +1218,3 @@ bool policy_handle_is_valid(const POLICY_HND *hnd) ZERO_STRUCT(zero_pol); return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True ); } - -/******************************************************************* - Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure. -********************************************************************/ - -void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *in, - POLICY_HND *hnd, - DOM_SID *sid, - uint32 removeall, - uint32 count, - const char **rights) -{ - DEBUG(5, ("init_q_remove_acct_rights\n")); - - in->pol = *hnd; - - init_dom_sid2(&in->sid, sid); - - in->removeall = removeall; - in->count = count; - - in->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY ); - if (!in->rights) { - smb_panic("init_q_remove_acct_rights: talloc fail\n"); - return; - } - init_unistr4_array( in->rights, count, rights ); -} - -/******************************************************************* -reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure. -********************************************************************/ - -bool lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *in, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights"); - depth++; - - if (!smb_io_pol_hnd("", &in->pol, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &in->sid, ps, depth)) - return False; - - if(!prs_uint32("removeall", ps, depth, &in->removeall)) - return False; - - if(!prs_uint32("count", ps, depth, &in->count)) - return False; - - if ( !prs_pointer("rights", ps, depth, (void*)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) - return False; - - return True; -} - -/******************************************************************* -reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure. -********************************************************************/ -bool lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights"); - depth++; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} -- cgit From b2b0a42fb86eabccc2d89646868c7d5b4ea544d8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 14 Feb 2008 14:21:49 +0100 Subject: Clean up LIBTDB-related Makefile variables a bit (removing commented out stuff). Michael (This used to be commit 0755785d80f22fe7d8d5be682f4c7bd88c987c3c) --- source3/Makefile.in | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 0e2e22ca86..eda800c597 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -238,15 +238,7 @@ MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(IDMAP_MODULES) \ # object file lists ###################################################################### -#TDBBASE_OBJ = lib/tdb/common/tdb.o lib/tdb/common/dump.o lib/tdb/common/error.o \ -# lib/tdb/common/freelist.o lib/tdb/common/freelistcheck.o \ -# lib/tdb/common/io.o lib/tdb/common/lock.o \ -# lib/tdb/common/open.o lib/tdb/common/transaction.o \ -# lib/tdb/common/traverse.o - -TDBBASE_OBJ = @TDB_OBJS@ - -LIBTDB_OBJ0 = $(TDBBASE_OBJ) +LIBTDB_OBJ0 = @TDB_OBJS@ LIBTDB_OBJ = $(LIBTDB_OBJ0) $(LIBREPLACE_OBJ) TDB_OBJ = @LIBTDB_STATIC@ lib/util_tdb.o \ -- cgit From 8d703d66d2b7b16ab8ab7fc5a4f15130787e10fe Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 14 Feb 2008 15:35:07 +0100 Subject: Use the proper boolean constants. Michael (This used to be commit 1c215325d1fb90f92fbe85011ab822892d5c994b) --- source3/lib/util_reg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_reg.c b/source3/lib/util_reg.c index 2d7d70c63f..2475dca040 100644 --- a/source3/lib/util_reg.c +++ b/source3/lib/util_reg.c @@ -95,7 +95,7 @@ WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len, thislen = strnlen_w(p, len) + 1; dstlen = convert_string_allocate(*values, CH_UTF16LE, CH_UNIX, p, thislen*2, (void *)&val, - True); + true); if (dstlen == (size_t)-1) { TALLOC_FREE(*values); return WERR_NOMEM; @@ -137,8 +137,8 @@ bool registry_smbconf_valname_forbidden(const char *valname) for (forbidden = forbidden_valnames; *forbidden != NULL; forbidden++) { if (strwicmp(valname, *forbidden) == 0) { - return True; + return true; } } - return False; + return false; } -- cgit From 769d6eb7eb6b839dda0754669f7a90670d7241c3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 14 Feb 2008 16:32:25 +0100 Subject: Remove the regfio objects from the ldb commandlin tools object list - unused. Michael (This used to be commit 047c5ba740c6b6c3d6bacf818dcdae8ec0af2292) --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index eda800c597..79863b7316 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1007,7 +1007,7 @@ LDB_CMDLINE_OBJ = $(PARAM_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \ $(LIBADS_OBJ) $(LIBADS_SERVER_OBJ) $(POPT_LIB_OBJ) \ $(SMBLDAP_OBJ) $(DCUTIL_OBJ) $(SERVER_MUTEX_OBJ) \ - $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(REGFIO_OBJ) $(READLINE_OBJ) \ + $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(READLINE_OBJ) \ $(LDB_OBJ) lib/ldb/tools/cmdline.o -- cgit From 31e5116a88b57d20ba8017e779345f8e2108c8d7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 14 Feb 2008 12:03:32 -0500 Subject: Revert "Merge in J.Layton patch and resolve conflict." This reverts commit 6b1a118eaaab405eeef0cf3c0488a2747af562ba. We found that this patch does not play well with currently released cifs.ko code, so after discussions with Jeff Layton and Steve french we decided it is best to back it off and re-think a better approach. Jeff will send new patches later, but for now it is better to just revert to the previous code (This used to be commit c5b7d538ecfa93377ff20704633ac57dbf8dd530) --- source3/client/mount.cifs.c | 90 +++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 64 deletions(-) (limited to 'source3') diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index 79f402a7d4..3acf2154b6 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -62,8 +62,6 @@ #define MS_BIND 4096 #endif -#define MAX_UNC_LEN 1024 - #define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr))) const char *thisprogram; @@ -75,6 +73,7 @@ static int got_ip = 0; static int got_unc = 0; static int got_uid = 0; static int got_gid = 0; +static int free_share_name = 0; static char * user_name = NULL; static char * mountpassword = NULL; char * domain_name = NULL; @@ -831,27 +830,17 @@ static char * check_for_domain(char **ppuser) return domainnm; } -/* replace all occurances of "from" in a string with "to" */ -static void replace_char(char *string, char from, char to) -{ - while (string) { - string = strchr(string, from); - if (string) - *string = to; - } -} - /* Note that caller frees the returned buffer if necessary */ static char * parse_server(char ** punc_name) { char * unc_name = *punc_name; - int length = strnlen(unc_name, MAX_UNC_LEN); + int length = strnlen(unc_name,1024); char * share; char * ipaddress_string = NULL; struct hostent * host_entry = NULL; struct in_addr server_ipaddr; - if(length > (MAX_UNC_LEN - 1)) { + if(length > 1023) { printf("mount error: UNC name too long"); return NULL; } @@ -870,6 +859,7 @@ static char * parse_server(char ** punc_name) /* check for nfs syntax ie server:share */ share = strchr(unc_name,':'); if(share) { + free_share_name = 1; *punc_name = (char *)malloc(length+3); if(*punc_name == NULL) { /* put the original string back if @@ -877,9 +867,9 @@ static char * parse_server(char ** punc_name) *punc_name = unc_name; return NULL; } + *share = '/'; strncpy((*punc_name)+2,unc_name,length); - free(unc_name); unc_name = *punc_name; unc_name[length+2] = 0; goto continue_unc_parsing; @@ -890,21 +880,18 @@ static char * parse_server(char ** punc_name) } } else { continue_unc_parsing: - unc_name[0] = '\\'; - unc_name[1] = '\\'; + unc_name[0] = '/'; + unc_name[1] = '/'; unc_name += 2; - - /* convert any '/' in unc to '\\' */ - replace_char(unc_name, '/', '\\'); - - if ((share = strchr(unc_name,'\\'))) { + if ((share = strchr(unc_name, '/')) || + (share = strchr(unc_name,'\\'))) { *share = 0; /* temporarily terminate the string */ share += 1; if(got_ip == 0) { host_entry = gethostbyname(unc_name); } - *(share - 1) = '\\'; /* put delimiter back */ - if ((prefixpath = strchr(share, '\\'))) { + *(share - 1) = '/'; /* put the slash back */ + if ((prefixpath = strchr(share, '/'))) { *prefixpath = 0; /* permanently terminate the string */ if (!strlen(++prefixpath)) prefixpath = NULL; /* this needs to be done explicitly */ @@ -969,25 +956,6 @@ static struct option longopts[] = { { NULL, 0, NULL, 0 } }; -/* convert a string to uppercase. return false if the string - * wasn't ASCII or was a NULL ptr */ -static int -uppercase_string(char *string) -{ - if (!string) - return 0; - - while (*string) { - /* check for unicode */ - if ((unsigned char) string[0] & 0x80) - return 0; - *string = toupper((unsigned char) *string); - string++; - } - - return 1; -} - int main(int argc, char ** argv) { int c; @@ -1000,7 +968,6 @@ int main(int argc, char ** argv) char * options = NULL; char * resolved_path = NULL; char * temp; - char * dev_name; int rc; int rsize = 0; int wsize = 0; @@ -1037,16 +1004,8 @@ int main(int argc, char ** argv) printf(" node: %s machine: %s sysname %s domain %s\n", sysinfo.nodename,sysinfo.machine,sysinfo.sysname,sysinfo.domainname); #endif */ if(argc > 2) { - dev_name = argv[1]; - share_name = strndup(argv[1], MAX_UNC_LEN); - if (share_name == NULL) { - fprintf(stderr, "%s: %s", argv[0], strerror(ENOMEM)); - exit(1); - } + share_name = argv[1]; mountpoint = argv[2]; - } else { - mount_cifs_usage(); - exit(1); } /* add sharename in opts string as unc= parm */ @@ -1186,7 +1145,7 @@ int main(int argc, char ** argv) } } - if((argc < 3) || (dev_name == NULL) || (mountpoint == NULL)) { + if((argc < 3) || (share_name == NULL) || (mountpoint == NULL)) { mount_cifs_usage(); exit(1); } @@ -1344,12 +1303,10 @@ mount_retry: } if(verboseflag) printf("\nmount.cifs kernel mount options %s \n",options); - - /* convert all '\\' to '/' so that /proc/mounts looks pretty */ - replace_char(dev_name, '\\', '/'); - - if(mount(dev_name, mountpoint, "cifs", flags, options)) { + if(mount(share_name, mountpoint, "cifs", flags, options)) { /* remember to kill daemon on error */ + char * tmp; + switch (errno) { case 0: printf("mount failed but no error number set\n"); @@ -1360,9 +1317,12 @@ mount_retry: case ENXIO: if(retry == 0) { retry = 1; - if (uppercase_string(dev_name) && - uppercase_string(share_name) && - uppercase_string(prefixpath)) { + tmp = share_name; + while (*tmp && !(((unsigned char)tmp[0]) & 0x80)) { + *tmp = toupper((unsigned char)*tmp); + tmp++; + } + if(!*tmp) { printf("retrying with upper case share name\n"); goto mount_retry; } @@ -1376,7 +1336,7 @@ mount_retry: } else { pmntfile = setmntent(MOUNTED, "a+"); if(pmntfile) { - mountent.mnt_fsname = dev_name; + mountent.mnt_fsname = share_name; mountent.mnt_dir = mountpoint; mountent.mnt_type = CONST_DISCARD(char *,"cifs"); mountent.mnt_opts = (char *)malloc(220); @@ -1436,6 +1396,8 @@ mount_exit: free(resolved_path); } - free(share_name); + if(free_share_name) { + free(share_name); + } return rc; } -- cgit From 39e0dbcf07251670b5475e9d0533c08a2712fffa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Feb 2008 11:29:54 -0800 Subject: Allow the mechOID to be written separately. Jeremy. (This used to be commit e3e08c6e7d270e1be7a9d3042b1f36f5a291f90a) --- source3/libsmb/clispnego.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clispnego.c b/source3/libsmb/clispnego.c index f95b11e4cd..a75032a47d 100644 --- a/source3/libsmb/clispnego.c +++ b/source3/libsmb/clispnego.c @@ -498,11 +498,13 @@ DATA_BLOB spnego_gen_auth_response(DATA_BLOB *reply, NTSTATUS nt_status, asn1_write_enumerated(&data, negResult); asn1_pop_tag(&data); - if (reply->data != NULL) { + if (mechOID) { asn1_push_tag(&data,ASN1_CONTEXT(1)); asn1_write_OID(&data, mechOID); asn1_pop_tag(&data); - + } + + if (reply && reply->data != NULL) { asn1_push_tag(&data,ASN1_CONTEXT(2)); asn1_write_OctetString(&data, reply->data, reply->length); asn1_pop_tag(&data); -- cgit From 4f1cc7b4958f06a54da92c82f19fba61e76d25b8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Feb 2008 18:05:37 -0800 Subject: Allow auth_ntlmssp_end() to ignore null pointers passed in. Jeremy. (This used to be commit b7628f3a47166791db4cd6451d52ea3881a45bed) --- source3/auth/auth_ntlmssp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c index 526f2c93df..ed66d0db0a 100644 --- a/source3/auth/auth_ntlmssp.c +++ b/source3/auth/auth_ntlmssp.c @@ -186,8 +186,13 @@ NTSTATUS auth_ntlmssp_start(AUTH_NTLMSSP_STATE **auth_ntlmssp_state) void auth_ntlmssp_end(AUTH_NTLMSSP_STATE **auth_ntlmssp_state) { - TALLOC_CTX *mem_ctx = (*auth_ntlmssp_state)->mem_ctx; + TALLOC_CTX *mem_ctx; + + if (*auth_ntlmssp_state == NULL) { + return; + } + mem_ctx = (*auth_ntlmssp_state)->mem_ctx; if ((*auth_ntlmssp_state)->ntlmssp_state) { ntlmssp_end(&(*auth_ntlmssp_state)->ntlmssp_state); } -- cgit From 0a89940df5255a3921f81721a627610967fe2698 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Feb 2008 18:06:16 -0800 Subject: Ensure invalidate_vuid() deletes any ntlmssp state. Jeremy. (This used to be commit b41799c351c72b268ef094047a51766747671280) --- source3/smbd/password.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3') diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 687b67950a..80eba562c5 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -121,6 +121,10 @@ void invalidate_vuid(uint16 vuid) data_blob_free(&vuser->session_key); + if (vuser->auth_ntlmssp_state) { + auth_ntlmssp_end(&vuser->auth_ntlmssp_state); + } + DLIST_REMOVE(validated_users, vuser); /* clear the vuid from the 'cache' on each connection, and -- cgit From 81d6133b0363be3736e60d8336a90129d67d7e4a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Feb 2008 18:07:27 -0800 Subject: Currently we don't SPNEGO negotiate back to NTLMSSP. Note this. Jeremy. (This used to be commit 8cd04b948bfba3896d40c9e314a197f60ad76833) --- source3/smbd/seal.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c index ea017e08d8..d4394e5bca 100644 --- a/source3/smbd/seal.c +++ b/source3/smbd/seal.c @@ -496,12 +496,15 @@ static NTSTATUS srv_enc_spnego_negotiate(connection_struct *conn, srv_free_encryption_context(&partial_srv_trans_enc_ctx); + if (got_kerberos_mechanism) { #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5) - if (got_kerberos_mechanism && lp_use_kerberos_keytab() ) { status = srv_enc_spnego_gss_negotiate(ppdata, p_data_size, secblob); - } else +#else + /* Currently we don't SPNEGO negotiate + * back to NTLMSSP as we do in sessionsetupX. We should... */ + return NT_STATUS_LOGON_FAILURE; #endif - { + } else { status = srv_enc_ntlm_negotiate(ppdata, p_data_size, secblob, true); } @@ -558,7 +561,16 @@ static NTSTATUS srv_enc_spnego_ntlm_auth(connection_struct *conn, status = auth_ntlmssp_update(ec->auth_ntlmssp_state, auth, &auth_reply); data_blob_free(&auth); - response = spnego_gen_auth_response(&auth_reply, status, OID_NTLMSSP); + /* From RFC4178. + * + * supportedMech + * + * This field SHALL only be present in the first reply from the + * target. + * So set mechOID to NULL here. + */ + + response = spnego_gen_auth_response(&auth_reply, status, NULL); data_blob_free(&auth_reply); if (NT_STATUS_IS_OK(status)) { -- cgit From ba9499e8dcdebda06ff1a3a38ad601011151410e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Feb 2008 18:08:23 -0800 Subject: Currently we don't SPNEGO negotiate back to NTLMSSP. Note this. Jeremy. (This used to be commit 67768fc71f9bd7ff3d61acc50360356b524ae923) --- source3/rpc_server/srv_pipe.c | 55 +++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 06694a2701..a671f89238 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1105,7 +1105,7 @@ static bool pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ char *OIDs[ASN1_MAX_OIDS]; int i; NTSTATUS status; - bool got_kerberos_mechanism = False; + bool got_kerberos_mechanism = false; AUTH_NTLMSSP_STATE *a = NULL; RPC_HDR_AUTH auth_info; @@ -1133,7 +1133,7 @@ static bool pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ } if (strcmp(OID_KERBEROS5, OIDs[0]) == 0 || strcmp(OID_KERBEROS5_OLD, OIDs[0]) == 0) { - got_kerberos_mechanism = True; + got_kerberos_mechanism = true; } for (i=0;OIDs[i];i++) { @@ -1154,27 +1154,38 @@ static bool pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ free_pipe_ntlmssp_auth_data(&p->auth); } - /* Initialize the NTLM engine. */ - status = auth_ntlmssp_start(&a); - if (!NT_STATUS_IS_OK(status)) { - goto err; - } + if (!got_kerberos_mechanism) { + /* Initialize the NTLM engine. */ + status = auth_ntlmssp_start(&a); + if (!NT_STATUS_IS_OK(status)) { + goto err; + } - /* - * Pass the first security blob of data to it. - * This can return an error or NT_STATUS_MORE_PROCESSING_REQUIRED - * which means we need another packet to complete the bind. - */ + /* + * Pass the first security blob of data to it. + * This can return an error or NT_STATUS_MORE_PROCESSING_REQUIRED + * which means we need another packet to complete the bind. + */ - status = auth_ntlmssp_update(a, secblob, &chal); + status = auth_ntlmssp_update(a, secblob, &chal); - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - DEBUG(3,("pipe_spnego_auth_bind_negotiate: auth_ntlmssp_update failed.\n")); - goto err; - } + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + DEBUG(3,("pipe_spnego_auth_bind_negotiate: auth_ntlmssp_update failed.\n")); + goto err; + } - /* Generate the response blob we need for step 2 of the bind. */ - response = spnego_gen_auth_response(&chal, status, OID_NTLMSSP); + /* Generate the response blob we need for step 2 of the bind. */ + response = spnego_gen_auth_response(&chal, status, OID_NTLMSSP); + } else { + /* + * SPNEGO negotiate down to NTLMSSP. The subsequent + * code to process follow-up packets is not complete + * yet. JRA. + */ + response = spnego_gen_auth_response(NULL, + NT_STATUS_MORE_PROCESSING_REQUIRED, + OID_NTLMSSP); + } /* Copy the blob into the pout_auth parse struct */ init_rpc_hdr_auth(&auth_info, RPC_SPNEGO_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); @@ -1231,6 +1242,10 @@ static bool pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p ZERO_STRUCT(auth_reply); ZERO_STRUCT(response); + /* + * NB. If we've negotiated down from krb5 to NTLMSSP we'll currently + * fail here as 'a' == NULL. + */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP || !a) { DEBUG(0,("pipe_spnego_auth_bind_continue: not in NTLMSSP auth state.\n")); goto err; @@ -1259,7 +1274,7 @@ static bool pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p * The following call actually checks the challenge/response data. * for correctness against the given DOMAIN\user name. */ - + if (!pipe_ntlmssp_verify_final(p, &auth_blob)) { goto err; } -- cgit From 4754c2bafe0ac5dc176c1e1d371bbc15165a7447 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Feb 2008 18:10:50 -0800 Subject: Correctly use SPNEGO to negotiate down from krb5 to NTLMSSP. Previously we didn't implement the 'NEGO' part of SPNEGO :-). Jeremy. (This used to be commit 8767a0dab95c544878b4187157e494e740974bb8) --- source3/smbd/sesssetup.c | 109 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 28 deletions(-) (limited to 'source3') diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c index 1e4e208951..3e04da35df 100644 --- a/source3/smbd/sesssetup.c +++ b/source3/smbd/sesssetup.c @@ -620,6 +620,7 @@ static void reply_spnego_ntlmssp(struct smb_request *req, uint16 vuid, AUTH_NTLMSSP_STATE **auth_ntlmssp_state, DATA_BLOB *ntlmssp_blob, NTSTATUS nt_status, + const char *OID, bool wrap) { DATA_BLOB response; @@ -680,7 +681,7 @@ static void reply_spnego_ntlmssp(struct smb_request *req, if (wrap) { response = spnego_gen_auth_response(ntlmssp_blob, - nt_status, OID_NTLMSSP); + nt_status, OID); } else { response = *ntlmssp_blob; } @@ -744,6 +745,28 @@ NTSTATUS parse_spnego_mechanisms(DATA_BLOB blob_in, DATA_BLOB *pblob_out, return NT_STATUS_OK; } +/**************************************************************************** + Fall back from krb5 to NTLMSSP. +****************************************************************************/ + +static void reply_spnego_downgrade_to_ntlmssp(struct smb_request *req, + uint16 vuid) +{ + DATA_BLOB response; + + reply_outbuf(req, 4, 0); + SSVAL(req->outbuf,smb_uid,vuid); + + DEBUG(3,("reply_spnego_downgrade_to_ntlmssp: Got krb5 ticket in SPNEGO " + "but set to downgrade to NTLMSSP\n")); + + response = spnego_gen_auth_response(NULL, + NT_STATUS_MORE_PROCESSING_REQUIRED, + OID_NTLMSSP); + reply_sesssetup_blob(req, response, NT_STATUS_MORE_PROCESSING_REQUIRED); + data_blob_free(&response); +} + /**************************************************************************** Reply to a session setup spnego negotiate packet. ****************************************************************************/ @@ -789,6 +812,15 @@ static void reply_spnego_negotiate(struct smb_request *req, auth_ntlmssp_end(auth_ntlmssp_state); } + if (got_kerberos_mechanism) { + data_blob_free(&secblob); + /* The mechtoken is a krb5 ticket, but + * we need to fall back to NTLM. */ + reply_spnego_downgrade_to_ntlmssp(req, + vuid); + return; + } + status = auth_ntlmssp_start(auth_ntlmssp_state); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ @@ -803,7 +835,7 @@ static void reply_spnego_negotiate(struct smb_request *req, data_blob_free(&secblob); reply_spnego_ntlmssp(req, vuid, auth_ntlmssp_state, - &chal, status, True); + &chal, status, OID_NTLMSSP, true); data_blob_free(&chal); @@ -823,7 +855,7 @@ static void reply_spnego_auth(struct smb_request *req, DATA_BLOB auth = data_blob_null; DATA_BLOB auth_reply = data_blob_null; DATA_BLOB secblob = data_blob_null; - NTSTATUS status = NT_STATUS_INVALID_PARAMETER; + NTSTATUS status = NT_STATUS_LOGON_FAILURE; if (!spnego_parse_auth(blob1, &auth)) { #if 0 @@ -833,7 +865,7 @@ static void reply_spnego_auth(struct smb_request *req, invalidate_vuid(vuid); reply_nterror(req, nt_status_squash( - NT_STATUS_INVALID_PARAMETER)); + NT_STATUS_LOGON_FAILURE)); return; } @@ -843,24 +875,43 @@ static void reply_spnego_auth(struct smb_request *req, bool got_krb5_mechanism = False; status = parse_spnego_mechanisms(auth, &secblob, &got_krb5_mechanism); - if (NT_STATUS_IS_OK(status)) { - DEBUG(3,("reply_spnego_auth: Got secblob of size %lu\n", - (unsigned long)secblob.length)); + + if (!NT_STATUS_IS_OK(status)) { + /* Kill the intermediate vuid */ + invalidate_vuid(vuid); + reply_nterror(req, nt_status_squash(status)); + return; + } + + DEBUG(3,("reply_spnego_auth: Got secblob of size %lu\n", + (unsigned long)secblob.length)); #ifdef HAVE_KRB5 - if ( got_krb5_mechanism && ((lp_security()==SEC_ADS) || - lp_use_kerberos_keytab()) ) { - bool destroy_vuid = True; - reply_spnego_kerberos(req, &secblob, - vuid, &destroy_vuid); - data_blob_free(&secblob); - data_blob_free(&auth); - if (destroy_vuid) { - /* Kill the intermediate vuid */ - invalidate_vuid(vuid); - } - return; + if ( got_krb5_mechanism && ((lp_security()==SEC_ADS) || + lp_use_kerberos_keytab()) ) { + bool destroy_vuid = True; + reply_spnego_kerberos(req, &secblob, + vuid, &destroy_vuid); + data_blob_free(&secblob); + data_blob_free(&auth); + if (destroy_vuid) { + /* Kill the intermediate vuid */ + invalidate_vuid(vuid); } + return; + } #endif + /* Can't blunder into NTLMSSP auth if we have + * a krb5 ticket. */ + + if (got_krb5_mechanism) { + /* Kill the intermediate vuid */ + invalidate_vuid(vuid); + DEBUG(3,("reply_spnego_auth: network " + "misconfiguration, client sent us a " + "krb5 ticket and kerberos security " + "not enabled")); + reply_nterror(req, nt_status_squash( + NT_STATUS_LOGON_FAILURE)); } } @@ -868,13 +919,13 @@ static void reply_spnego_auth(struct smb_request *req, data_blob_free(&secblob); if (!*auth_ntlmssp_state) { - /* Kill the intermediate vuid */ - invalidate_vuid(vuid); - - /* auth before negotiatiate? */ - reply_nterror(req, nt_status_squash( - NT_STATUS_INVALID_PARAMETER)); - return; + status = auth_ntlmssp_start(auth_ntlmssp_state); + if (!NT_STATUS_IS_OK(status)) { + /* Kill the intermediate vuid */ + invalidate_vuid(vuid); + reply_nterror(req, nt_status_squash(status)); + return; + } } status = auth_ntlmssp_update(*auth_ntlmssp_state, @@ -882,9 +933,11 @@ static void reply_spnego_auth(struct smb_request *req, data_blob_free(&auth); + /* Don't send the mechid as we've already sent this (RFC4178). */ + reply_spnego_ntlmssp(req, vuid, auth_ntlmssp_state, - &auth_reply, status, True); + &auth_reply, status, NULL, true); data_blob_free(&auth_reply); @@ -1251,7 +1304,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) reply_spnego_ntlmssp(req, vuid, &vuser->auth_ntlmssp_state, - &chal, status, False); + &chal, status, OID_NTLMSSP, false); data_blob_free(&chal); return; } -- cgit From 4737a35ac81803275f2c1edc860a87f31d14f2eb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Feb 2008 18:16:09 -0800 Subject: Fix "warning: 'cmd' may be used uninitialized in this function" Jeremy. (This used to be commit 58b0f022ffce7fda531f6f8ea7392a963e8ec0c5) --- source3/nsswitch/libwbclient/wbc_pam.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3') diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c index e7bcdfe20d..d614474cb7 100644 --- a/source3/nsswitch/libwbclient/wbc_pam.c +++ b/source3/nsswitch/libwbclient/wbc_pam.c @@ -334,6 +334,9 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, request.data.auth_crap.nt_resp_len); break; + default: + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); } wbc_status = wbcRequestResponse(cmd, -- cgit From 48f3c385bcbb5bbd6ff2d539301a41bb11a78168 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:08:56 +0100 Subject: Fix building smbmount with shared libtdb. Michael (This used to be commit 7f2c4b1a336310fedda4c36314d3b4aabbdf2c31) --- source3/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 79863b7316..b670bf8332 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1272,9 +1272,9 @@ bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbmount@EXEEXT@: $(BINARY_PREREQS) $(MOUNT_OBJ) @BUILD_POPT@ +bin/smbmount@EXEEXT@: $(BINARY_PREREQS) $(MOUNT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_SHARED@ bin/smbmnt@EXEEXT@: $(BINARY_PREREQS) $(MNT_OBJ) @BUILD_POPT@ @echo Linking $@ -- cgit From 3756759f2190abbf1fb010bb781e05b8aef2a41f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:10:53 +0100 Subject: Fix build of smbumount with shared libtdb. Michael (This used to be commit 61fb01f17b981b7317e87b9049e3fbf7f6476941) --- source3/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index b670bf8332..12c8599fe1 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1280,9 +1280,9 @@ bin/smbmnt@EXEEXT@: $(BINARY_PREREQS) $(MNT_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(MNT_OBJ) $(DYNEXP) $(LDFLAGS) @POPTLIBS@ -bin/smbumount@EXEEXT@: $(BINARY_PREREQS) $(UMOUNT_OBJ) @BUILD_POPT@ +bin/smbumount@EXEEXT@: $(BINARY_PREREQS) $(UMOUNT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ bin/mount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_MOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ -- cgit From 895ab0368ab87e3a65b3169dfb966eb0205e31ab Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:11:46 +0100 Subject: Use -ltdb instead of bin/libtdb.so for linking. Michael (This used to be commit c47005189690f5a89a3aabe919e9ce2d2604dc5e) --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 12c8599fe1..dd6b0ce2af 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1274,7 +1274,7 @@ bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ bin/smbmount@EXEEXT@: $(BINARY_PREREQS) $(MOUNT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_SHARED@ + @$(CC) $(FLAGS) -o $@ $(MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ bin/smbmnt@EXEEXT@: $(BINARY_PREREQS) $(MNT_OBJ) @BUILD_POPT@ @echo Linking $@ -- cgit From 9aa1c9f7fe54137957ebc1774b071d409106dc2f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:15:13 +0100 Subject: Fix build of cifs.spnego with libtdb. Michael (This used to be commit e5e621681db8300d7388167cba979cbdc8ff0aee) --- source3/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index dd6b0ce2af..0e90283406 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1292,10 +1292,10 @@ bin/umount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UMOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CIFS_UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) @POPTLIBS@ -bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ) @BUILD_POPT@ +bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CIFS_SPNEGO_OBJ) $(DYNEXP) $(LDFLAGS) -lkeyutils $(LIBS) \ - $(LIBSMBCLIENT_OBJ) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBWBCLIENT_SHARED@ + $(LIBSMBCLIENT_OBJ) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBWBCLIENT_SHARED@ @LIBTDB_LIBS@ bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ -- cgit From a3e38fd9218167f8b38ab8a0114766b64443cd32 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:27:01 +0100 Subject: Remove useless build-target bin/samtest. (The objects exist no more.) Michael (This used to be commit e78831cf59196ff6e4f9384f83dbc180c4e341e2) --- source3/Makefile.in | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 0e90283406..314c52e0ca 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1335,10 +1335,6 @@ bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/samtest@EXEEXT@: $(SAMTEST_OBJ) @BUILD_POPT@ - @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SAMTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) @POPTLIBS@ $(PASSDB_LIBS) $(KRB5LIBS) $(LDAP_LIBS) - bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ -- cgit From d4ab4b3af7cf606cb099786bae30b92fd996faac Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:27:42 +0100 Subject: Remove torture/samtest.h - last trace of late samtest. Michael (This used to be commit e846148116f84d1428b5c7e60a4181cc872cc3eb) --- source3/torture/samtest.h | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 source3/torture/samtest.h (limited to 'source3') diff --git a/source3/torture/samtest.h b/source3/torture/samtest.h deleted file mode 100644 index 5cde3fadb5..0000000000 --- a/source3/torture/samtest.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SAM module tester - - Copyright (C) Jelmer Vernooij 2002 - - Most of this code was ripped off of rpcclient. - Copyright (C) Tim Potter 2000-2001 - - 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 . -*/ - -struct samtest_state { - SAM_CONTEXT *context; - NT_USER_TOKEN *token; -}; - -struct cmd_set { - char *name; - NTSTATUS (*fn)(struct samtest_state *sam, TALLOC_CTX *mem_ctx, int argc, - char **argv); - char *description; - char *usage; -}; - - -- cgit From dd255b427515d0f22695185bd78c16bc58de6c09 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:39:25 +0100 Subject: Fix compiling torture/smbiconv.c: allow to use realloc directly by #undef realloc. Michael (This used to be commit 113377a7929975bf29c2cfff1652781fae24e826) --- source3/torture/smbiconv.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/torture/smbiconv.c b/source3/torture/smbiconv.c index 05a8c3d815..c4d30164e4 100644 --- a/source3/torture/smbiconv.c +++ b/source3/torture/smbiconv.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#undef realloc static int process_block (smb_iconv_t cd, const char *addr, size_t len, FILE *output) -- cgit From a4b93e2063fcfeb00c179216a6b731948c94d28d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:42:31 +0100 Subject: Fix linkage of bin/smbiconv by adding needed libs and objects. Michael (This used to be commit fc08bf5a466b84e041a655eaa21a31006ede191f) --- source3/Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 314c52e0ca..df6601f8f0 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -858,7 +858,7 @@ PDBTEST_OBJ = torture/pdbtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ VFSTEST_OBJ = torture/cmd_vfs.o torture/vfstest.o $(SMBD_OBJ_BASE) $(READLINE_OBJ) -SMBICONV_OBJ = $(PARAM_OBJ) torture/smbiconv.o $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) $(LIBSAMBA_OBJ) +SMBICONV_OBJ = $(PARAM_OBJ) torture/smbiconv.o $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) $(LIBSAMBA_OBJ) $(DOSERR_OBJ) LOG2PCAP_OBJ = utils/log2pcaphex.o @@ -1396,9 +1396,9 @@ bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARE @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) $(ACL_LIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) @SMBD_LIBS@ $(NSCD_LIBS) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ -bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ +bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) @POPTLIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ bin/log2pcap@EXEEXT@: $(BINARY_PREREQS) $(LOG2PCAP_OBJ) @BUILD_POPT@ @echo Linking $@ -- cgit From f4c8b8553229992df8f78c4325185e7ce050df77 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 11:52:15 +0100 Subject: Add orphaned target smbiconv to "make everything" targets. Michael (This used to be commit 92cc5d88bbc63edac3e7c4b483c1a75f91263827) --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index df6601f8f0..730b1fdff9 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -214,7 +214,7 @@ BIN_PROGS = @EXTRA_BIN_PROGS@ @SMBMOUNT_PROGS@ \ EVERYTHING_PROGS = bin/debug2html@EXEEXT@ bin/smbfilter@EXEEXT@ \ bin/talloctort@EXEEXT@ bin/replacetort@EXEEXT@ \ bin/log2pcap@EXEEXT@ bin/sharesec@EXEEXT@ bin/ndrdump@EXEEXT@ \ - bin/vlp@EXEEXT@ + bin/vlp@EXEEXT@ bin/smbiconv@EXEEXT@ SHLIBS = libtalloc libtdb @LIBWBCLIENT@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@ @LIBADDNS@ libnetapi -- cgit From b8e0b5cbffb370aa0011cb8c0d4e85378044b99b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Feb 2008 10:30:15 +0100 Subject: libwbclient: wbcAuthenticateUserEx() be more strict regarding invalid parameters metze (This used to be commit 491ba9c0c9d479bc686c75242a3749f14d103fcd) --- source3/nsswitch/libwbclient/wbc_pam.c | 60 +++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 12 deletions(-) (limited to 'source3') diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c index e7bcdfe20d..cf56a8b6d6 100644 --- a/source3/nsswitch/libwbclient/wbc_pam.c +++ b/source3/nsswitch/libwbclient/wbc_pam.c @@ -265,11 +265,10 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, struct wbcAuthErrorInfo **error) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; - int cmd; + int cmd = 0; struct winbindd_request request; struct winbindd_response response; - ZERO_STRUCT(request); ZERO_STRUCT(response); @@ -282,6 +281,11 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, BAIL_ON_WBC_ERROR(wbc_status); } + if (!params->account_name) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + /* Initialize request */ switch (params->level) { @@ -301,12 +305,36 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, WBFLAG_PAM_USER_SESSION_KEY | WBFLAG_PAM_LMKEY; + if (params->password.response.lm_length && + params->password.response.lm_data) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + if (params->password.response.lm_length == 0 && + params->password.response.lm_data) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + if (params->password.response.nt_length && + !params->password.response.nt_data) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + if (params->password.response.nt_length == 0&& + params->password.response.nt_data) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + strncpy(request.data.auth_crap.user, params->account_name, sizeof(request.data.auth_crap.user)-1); - strncpy(request.data.auth_crap.domain, - params->domain_name, - sizeof(request.data.auth_crap.domain)-1); + if (params->domain_name) { + strncpy(request.data.auth_crap.domain, + params->domain_name, + sizeof(request.data.auth_crap.domain)-1); + } if (params->workstation_name) { strncpy(request.data.auth_crap.workstation, params->workstation_name, @@ -326,16 +354,24 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, request.data.auth_crap.nt_resp_len = MIN(params->password.response.nt_length, sizeof(request.data.auth_crap.nt_resp)); - memcpy(request.data.auth_crap.lm_resp, - params->password.response.lm_data, - request.data.auth_crap.lm_resp_len); - memcpy(request.data.auth_crap.nt_resp, - params->password.response.nt_data, - request.data.auth_crap.nt_resp_len); - + if (params->password.response.lm_data) { + memcpy(request.data.auth_crap.lm_resp, + params->password.response.lm_data, + request.data.auth_crap.lm_resp_len); + } + if (params->password.response.nt_data) { + memcpy(request.data.auth_crap.nt_resp, + params->password.response.nt_data, + request.data.auth_crap.nt_resp_len); + } break; } + if (cmd == 0) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + wbc_status = wbcRequestResponse(cmd, &request, &response); -- cgit From a12528f82650aee6bef80fee858600d502464614 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Feb 2008 10:34:46 +0100 Subject: libwbclient: implement WBC_AUTH_USER_LEVEL_PLAIN in wbcAuthenticateUserEx() metze (This used to be commit 423f139fd37496db2e690f20399357496367ed7c) --- source3/nsswitch/libwbclient/wbc_pam.c | 40 ++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c index cf56a8b6d6..aac7e690ff 100644 --- a/source3/nsswitch/libwbclient/wbc_pam.c +++ b/source3/nsswitch/libwbclient/wbc_pam.c @@ -252,8 +252,8 @@ done: /** @brief Authenticate with more detailed information * - * @param params Input parameters, only WBC_AUTH_USER_LEVEL_RESPONSE - * is supported yet + * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH + * is not supported yet * @param info Output details on WBC_ERR_SUCCESS * @param error Output details on WBC_ERR_AUTH_ERROR * @@ -290,8 +290,40 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, switch (params->level) { case WBC_AUTH_USER_LEVEL_PLAIN: - wbc_status = WBC_ERR_NOT_IMPLEMENTED; - BAIL_ON_WBC_ERROR(wbc_status); + cmd = WINBINDD_PAM_AUTH; + request.flags = WBFLAG_PAM_INFO3_TEXT | + WBFLAG_PAM_USER_SESSION_KEY | + WBFLAG_PAM_LMKEY; + + if (!params->password.plaintext) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + if (params->domain_name && params->domain_name[0]) { + /* We need to get the winbind separator :-( */ + struct winbindd_response sep_response; + + ZERO_STRUCT(sep_response); + + wbc_status = wbcRequestResponse(WINBINDD_INFO, + NULL, &sep_response); + BAIL_ON_WBC_ERROR(wbc_status); + + snprintf(request.data.auth.user, + sizeof(request.data.auth.user)-1, + "%s%c%s", + params->domain_name, + sep_response.data.info.winbind_separator, + params->account_name); + } else { + strncpy(request.data.auth.user, + params->account_name, + sizeof(request.data.auth.user)-1); + } + strncpy(request.data.auth.pass, + params->password.plaintext, + sizeof(request.data.auth.user)-1); break; case WBC_AUTH_USER_LEVEL_HASH: -- cgit From 23b7f7ea095644b1a5ba104fde5841676dfc9ed4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Feb 2008 10:46:19 +0100 Subject: libwbclient: let wbcAuthenticateUser() use wbcAuthenticateUserEx() metze (This used to be commit 237c2e9738ae29ca7046d6f886d6f777a6206045) --- source3/nsswitch/libwbclient/wbc_pam.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'source3') diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c index aac7e690ff..de49a6b543 100644 --- a/source3/nsswitch/libwbclient/wbc_pam.c +++ b/source3/nsswitch/libwbclient/wbc_pam.c @@ -34,30 +34,16 @@ wbcErr wbcAuthenticateUser(const char *username, const char *password) { - wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; - struct winbindd_request request; - struct winbindd_response response; - - if (!username) { - wbc_status = WBC_ERR_INVALID_PARAM; - BAIL_ON_WBC_ERROR(wbc_status); - } - - /* Initialize request */ - - ZERO_STRUCT(request); - ZERO_STRUCT(response); + wbcErr wbc_status = WBC_ERR_SUCCESS; + struct wbcAuthUserParams params; - /* dst is already null terminated from the memset above */ + ZERO_STRUCT(params); - strncpy(request.data.auth.user, username, - sizeof(request.data.auth.user)-1); - strncpy(request.data.auth.pass, password, - sizeof(request.data.auth.user)-1); + params.account_name = username; + params.level = WBC_AUTH_USER_LEVEL_PLAIN; + params.password.plaintext = password; - wbc_status = wbcRequestResponse(WINBINDD_PAM_AUTH, - &request, - &response); + wbc_status = wbcAuthenticateUserEx(¶ms, NULL, NULL); BAIL_ON_WBC_ERROR(wbc_status); done: -- cgit From 2c14442e8d20b5005d22ab6874f2e75975b85214 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Feb 2008 10:40:43 +0100 Subject: wbinfo: ask wbcAuthenticateUserEx() for user info to test the more complex code path metze (This used to be commit 432a77e0d7dbd52fd230e4ee9641b6ab4f4d3b73) --- source3/nsswitch/wbinfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index 689dc5e9e1..ee51cce835 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -906,6 +906,7 @@ static bool wbinfo_auth_crap(char *username) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct wbcAuthUserParams params; + struct wbcAuthUserInfo *info = NULL; struct wbcAuthErrorInfo *err = NULL; DATA_BLOB lm = data_blob_null; DATA_BLOB nt = data_blob_null; @@ -974,7 +975,7 @@ static bool wbinfo_auth_crap(char *username) params.password.response.lm_length = lm.length; params.password.response.lm_data = lm.data; - wbc_status = wbcAuthenticateUserEx(¶ms, NULL, &err); + wbc_status = wbcAuthenticateUserEx(¶ms, &info, &err); /* Display response */ @@ -987,6 +988,8 @@ static bool wbinfo_auth_crap(char *username) err->nt_status, err->display_string); wbcFreeMemory(err); + } else if (WBC_ERROR_IS_OK(wbc_status)) { + wbcFreeMemory(info); } data_blob_free(&nt); -- cgit From 6b88ba1761e2ffbd95f1ef19e5da8e2ad85837a6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 12:18:20 +0100 Subject: Remove libwbclient.a from standard (static) libsmbclient object list. Michael (This used to be commit 8e57df28861a11b8bf60d30e33120a286bfad7be) --- source3/Makefile.in | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 730b1fdff9..bf20991cb0 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -721,7 +721,7 @@ PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) @LIB $(SECRETS_OBJ) $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) libsmb/asn1.o \ $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(LDB_OBJ) $(ERRORMAP_OBJ) -SMBGET_OBJ = utils/smbget.o $(POPT_LIB_OBJ) $(LIBSMBCLIENT_OBJ) +SMBGET_OBJ = utils/smbget.o $(POPT_LIB_OBJ) $(LIBSMBCLIENT_OBJ0) DISPLAY_SEC_OBJ= lib/display_sec.o DISPLAY_DSDCINFO_OBJ= lib/display_dsdcinfo.o @@ -745,12 +745,14 @@ RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \ PAM_WINBIND_OBJ = nsswitch/pam_winbind.o $(WBCOMMON_OBJ) \ $(LIBREPLACE_OBJ) @BUILD_INIPARSER@ -LIBSMBCLIENT_OBJ = libsmb/libsmbclient.o libsmb/libsmb_compat.o \ - libsmb/libsmb_cache.o \ - $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ - $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ - $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \ - $(SECRETS_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) +LIBSMBCLIENT_OBJ0 = libsmb/libsmbclient.o libsmb/libsmb_compat.o \ + libsmb/libsmb_cache.o \ + $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ + $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ + $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \ + $(SECRETS_OBJ) $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) + +LIBSMBCLIENT_OBJ = $(LIBSMBCLIENT_OBJ0) @LIBWBCLIENT_STATIC@ LIBSMBSHAREMODES_OBJ = libsmb/smb_share_modes.o @LIBTDB_STATIC@ @@ -1292,10 +1294,10 @@ bin/umount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UMOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CIFS_UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) @POPTLIBS@ -bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ0) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CIFS_SPNEGO_OBJ) $(DYNEXP) $(LDFLAGS) -lkeyutils $(LIBS) \ - $(LIBSMBCLIENT_OBJ) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBWBCLIENT_SHARED@ @LIBTDB_LIBS@ + $(LIBSMBCLIENT_OBJ0) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBWBCLIENT_SHARED@ @LIBTDB_LIBS@ bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @@ -1512,9 +1514,9 @@ bin/libsmbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) @LIBWBCLIENT_ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) -bin/libsmbclient.a: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) +bin/libsmbclient.a: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ0) @echo Linking non-shared library $@ - @-$(AR) -rc $@ $(LIBSMBCLIENT_OBJ) + @-$(AR) -rc $@ $(LIBSMBCLIENT_OBJ0) bin/libsmbsharemodes.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) @echo Linking shared library $@ -- cgit From 8a63e1322581f0adf842d92b8e57919dab7d459b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 13:11:41 +0100 Subject: Try to fix the build of smbiconv on systems without native iconv. Use the smb_iconv_t instead of iconv_t. Michael (This used to be commit bdc00a05b95a7a629a6cbf2af21760b6ff874bd9) --- source3/torture/smbiconv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/torture/smbiconv.c b/source3/torture/smbiconv.c index c4d30164e4..ad4d6b26cc 100644 --- a/source3/torture/smbiconv.c +++ b/source3/torture/smbiconv.c @@ -86,7 +86,7 @@ incomplete character or shift sequence at end of buffer")); static int -process_fd (iconv_t cd, int fd, FILE *output) +process_fd (smb_iconv_t cd, int fd, FILE *output) { /* we have a problem with reading from a descriptor since we must not provide the iconv() function an incomplete character or shift -- cgit From a10e6183aa05f26583dfe0fc7037d9190b57a69d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 13:12:38 +0100 Subject: Fix two const warnings. Michael (This used to be commit 03db3bd0774e0435089eef15f88355133149d658) --- source3/torture/smbiconv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/torture/smbiconv.c b/source3/torture/smbiconv.c index ad4d6b26cc..6e609aa851 100644 --- a/source3/torture/smbiconv.c +++ b/source3/torture/smbiconv.c @@ -168,8 +168,8 @@ process_fd (smb_iconv_t cd, int fd, FILE *output) int main(int argc, char *argv[]) { const char *file = NULL; - char *from = ""; - char *to = ""; + const char *from = ""; + const char *to = ""; char *output = NULL; const char *preload_modules[] = {NULL, NULL}; FILE *out = stdout; -- cgit From d4123ba9ee7ec59331cffb846d9c82dce3d84d0d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 13:14:20 +0100 Subject: Fix a pointer to int conversion warning: cast the int instead. Michael (This used to be commit 3cace4b7aa87a2f5bc7b6efd095366699d939511) --- source3/torture/smbiconv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/torture/smbiconv.c b/source3/torture/smbiconv.c index 6e609aa851..72fbdc470f 100644 --- a/source3/torture/smbiconv.c +++ b/source3/torture/smbiconv.c @@ -214,7 +214,7 @@ int main(int argc, char *argv[]) } cd = smb_iconv_open(to, from); - if((int)cd == -1) { + if (cd == (smb_iconv_t)-1) { DEBUG(0,("unable to find from or to encoding, exiting...\n")); return 1; } -- cgit From 66ad7e82dcb531caa1731e6d09e9ee233488be39 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 13:39:24 +0100 Subject: Fix the build on IRIX by placing the object files before the shared libs in linking. Michael (This used to be commit f2c6585329ddd71acf5921c58435e53febb57b43) --- source3/Makefile.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index bf20991cb0..39c89f6725 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1881,19 +1881,19 @@ bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ $(TDBBACKUP_OBJ) + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBBACKUP_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTDB_SHARED@ $(TDBTOOL_OBJ) + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_SHARED@ bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ $(TDBDUMP_OBJ) + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBDUMP_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ bin/tdbtorture@EXEEXT@: $(BINARY_PREREQS) $(TDBTORTURE_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ $(TDBTORTURE_OBJ) + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTORTURE_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ bin/t_strcmp@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_strcmp.o $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_strcmp.o -L ./bin -lbigballofmud -- cgit From 71c34ad4e09aad2fbf5de9c60c0dd65874751e13 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 13:40:28 +0100 Subject: Use -ltdb instead of bin/libtdb.so for linking. Michael (This used to be commit 47b952b9a5bfeac248be393d2459fb67137644e4) --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 39c89f6725..7e627d6e9e 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1885,7 +1885,7 @@ bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTDB_SHARED@ bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_SHARED@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) @LIBTDB_SHARED@ @echo Linking $@ -- cgit From cfd9d5d65959e9360711494d62e19a8bb55626d7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 01:19:43 +0100 Subject: Remove some unused/redundant set of netlogon headers. Guenther (This used to be commit 1cd556f763da2ffba6078135b9436906987f1235) --- source3/include/rpc_netlogon.h | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index f8c9fc5c7f..c8a25cdf4d 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -63,11 +63,6 @@ #define SAM_DELTA_DELETE_USER 0x15 #define SAM_DELTA_MODIFIED_COUNT 0x16 -/* SAM database types */ -#define SAM_DATABASE_DOMAIN 0x00 /* Domain users and groups */ -#define SAM_DATABASE_BUILTIN 0x01 /* BUILTIN users and groups */ -#define SAM_DATABASE_PRIVS 0x02 /* Privileges */ - /* flags use when sending a NETLOGON_CONTROL request */ #define NETLOGON_CONTROL_SYNC 0x2 @@ -281,42 +276,6 @@ typedef struct net_user_info_3 { uint32 *other_sids_attrib; } NET_USER_INFO_3; - -/* NETLOGON_INFO_1 - pdc status info, i presume */ -typedef struct netlogon_1_info { - uint32 flags; /* 0x0 - undocumented */ - uint32 pdc_status; /* 0x0 - undocumented */ -} NETLOGON_INFO_1; - -/* NETLOGON_INFO_2 - pdc status info, plus trusted domain info */ -typedef struct netlogon_2_info { - uint32 flags; /* 0x0 - undocumented */ - uint32 pdc_status; /* 0x0 - undocumented */ - uint32 ptr_trusted_dc_name; /* pointer to trusted domain controller name */ - uint32 tc_status; - UNISTR2 uni_trusted_dc_name; /* unicode string - trusted dc name */ -} NETLOGON_INFO_2; - -/* NETLOGON_INFO_3 - logon status info, i presume */ -typedef struct netlogon_3_info { - uint32 flags; /* 0x0 - undocumented */ - uint32 logon_attempts; /* number of logon attempts */ - uint32 reserved_1; /* 0x0 - undocumented */ - uint32 reserved_2; /* 0x0 - undocumented */ - uint32 reserved_3; /* 0x0 - undocumented */ - uint32 reserved_4; /* 0x0 - undocumented */ - uint32 reserved_5; /* 0x0 - undocumented */ -} NETLOGON_INFO_3; - -/******************************************************** - Logon Control Query - - This is generated by a nltest /bdc_query:DOMAIN - - query_level 0x1, function_code 0x1 - - ********************************************************/ - /* NEG_FLAGS */ typedef struct neg_flags_info { uint32 neg_flags; /* negotiated flags */ -- cgit From 10023ef50a36bb43c3f480a13ddc45ef83658e05 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 01:23:59 +0100 Subject: Fix IDL for netr_DatabaseDeltas. Guenther (This used to be commit a28729e48f5beffb4ffe324da30548d948fa51b4) --- source3/librpc/idl/netlogon.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index 7f977a454b..e79096269f 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -680,12 +680,12 @@ interface netlogon NTSTATUS netr_DatabaseDeltas( [in] [string,charset(UTF16)] uint16 logon_server[], [in] [string,charset(UTF16)] uint16 computername[], - [in] netr_Authenticator credential, + [in,ref] netr_Authenticator *credential, [in,out,ref] netr_Authenticator *return_authenticator, [in] netr_SamDatabaseID database_id, [in,out,ref] udlong *sequence_num, - [in] uint32 preferredmaximumlength, - [out,ref] netr_DELTA_ENUM_ARRAY *delta_enum_array + [out,ref] netr_DELTA_ENUM_ARRAY **delta_enum_array, + [in] uint32 preferredmaximumlength ); -- cgit From 1976c7acc7f98914be50c0dd5d5c259511e273fa Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 14:04:08 +0100 Subject: Re-run make idl. Guenther (This used to be commit 06f2f4c4707d13bfc5510f3ff068534a01456fe5) --- source3/librpc/gen_ndr/cli_netlogon.c | 6 ++--- source3/librpc/gen_ndr/cli_netlogon.h | 6 ++--- source3/librpc/gen_ndr/ndr_netlogon.c | 46 ++++++++++++++++++++++++++++++----- source3/librpc/gen_ndr/netlogon.h | 4 +-- source3/librpc/gen_ndr/srv_netlogon.c | 2 +- 5 files changed, 49 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_netlogon.c b/source3/librpc/gen_ndr/cli_netlogon.c index 7efcae2c56..5e1593249d 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.c +++ b/source3/librpc/gen_ndr/cli_netlogon.c @@ -363,12 +363,12 @@ NTSTATUS rpccli_netr_DatabaseDeltas(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *logon_server, const char *computername, - struct netr_Authenticator credential, + struct netr_Authenticator *credential, struct netr_Authenticator *return_authenticator, enum netr_SamDatabaseID database_id, uint64_t *sequence_num, - uint32_t preferredmaximumlength, - struct netr_DELTA_ENUM_ARRAY *delta_enum_array) + struct netr_DELTA_ENUM_ARRAY **delta_enum_array, + uint32_t preferredmaximumlength) { struct netr_DatabaseDeltas r; NTSTATUS status; diff --git a/source3/librpc/gen_ndr/cli_netlogon.h b/source3/librpc/gen_ndr/cli_netlogon.h index f07c429224..034594147a 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.h +++ b/source3/librpc/gen_ndr/cli_netlogon.h @@ -59,12 +59,12 @@ NTSTATUS rpccli_netr_DatabaseDeltas(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *logon_server, const char *computername, - struct netr_Authenticator credential, + struct netr_Authenticator *credential, struct netr_Authenticator *return_authenticator, enum netr_SamDatabaseID database_id, uint64_t *sequence_num, - uint32_t preferredmaximumlength, - struct netr_DELTA_ENUM_ARRAY *delta_enum_array); + struct netr_DELTA_ENUM_ARRAY **delta_enum_array, + uint32_t preferredmaximumlength); NTSTATUS rpccli_netr_DatabaseSync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *logon_server, diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index d31e19a9cc..43a077f7f9 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -9009,7 +9009,10 @@ static enum ndr_err_code ndr_push_netr_DatabaseDeltas(struct ndr_push *ndr, int NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.computername, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.computername, ndr_charset_length(r->in.computername, CH_UTF16), sizeof(uint16_t), CH_UTF16)); - NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, &r->in.credential)); + if (r->in.credential == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, r->in.credential)); if (r->in.return_authenticator == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -9033,7 +9036,10 @@ static enum ndr_err_code ndr_push_netr_DatabaseDeltas(struct ndr_push *ndr, int if (r->out.delta_enum_array == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_netr_DELTA_ENUM_ARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.delta_enum_array)); + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.delta_enum_array)); + if (*r->out.delta_enum_array) { + NDR_CHECK(ndr_push_netr_DELTA_ENUM_ARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.delta_enum_array)); + } NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -9041,9 +9047,12 @@ static enum ndr_err_code ndr_push_netr_DatabaseDeltas(struct ndr_push *ndr, int static enum ndr_err_code ndr_pull_netr_DatabaseDeltas(struct ndr_pull *ndr, int flags, struct netr_DatabaseDeltas *r) { + uint32_t _ptr_delta_enum_array; + TALLOC_CTX *_mem_save_credential_0; TALLOC_CTX *_mem_save_return_authenticator_0; TALLOC_CTX *_mem_save_sequence_num_0; TALLOC_CTX *_mem_save_delta_enum_array_0; + TALLOC_CTX *_mem_save_delta_enum_array_1; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -9061,7 +9070,13 @@ static enum ndr_err_code ndr_pull_netr_DatabaseDeltas(struct ndr_pull *ndr, int } NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.computername), sizeof(uint16_t))); NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.computername, ndr_get_array_length(ndr, &r->in.computername), sizeof(uint16_t), CH_UTF16)); - NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, &r->in.credential)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.credential); + } + _mem_save_credential_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.credential, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, r->in.credential)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_credential_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.return_authenticator); } @@ -9105,7 +9120,18 @@ static enum ndr_err_code ndr_pull_netr_DatabaseDeltas(struct ndr_pull *ndr, int } _mem_save_delta_enum_array_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.delta_enum_array, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_netr_DELTA_ENUM_ARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.delta_enum_array)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_delta_enum_array)); + if (_ptr_delta_enum_array) { + NDR_PULL_ALLOC(ndr, *r->out.delta_enum_array); + } else { + *r->out.delta_enum_array = NULL; + } + if (*r->out.delta_enum_array) { + _mem_save_delta_enum_array_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.delta_enum_array, 0); + NDR_CHECK(ndr_pull_netr_DELTA_ENUM_ARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.delta_enum_array)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_delta_enum_array_1, 0); + } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_delta_enum_array_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -9124,7 +9150,10 @@ _PUBLIC_ void ndr_print_netr_DatabaseDeltas(struct ndr_print *ndr, const char *n ndr->depth++; ndr_print_string(ndr, "logon_server", r->in.logon_server); ndr_print_string(ndr, "computername", r->in.computername); - ndr_print_netr_Authenticator(ndr, "credential", &r->in.credential); + ndr_print_ptr(ndr, "credential", r->in.credential); + ndr->depth++; + ndr_print_netr_Authenticator(ndr, "credential", r->in.credential); + ndr->depth--; ndr_print_ptr(ndr, "return_authenticator", r->in.return_authenticator); ndr->depth++; ndr_print_netr_Authenticator(ndr, "return_authenticator", r->in.return_authenticator); @@ -9150,7 +9179,12 @@ _PUBLIC_ void ndr_print_netr_DatabaseDeltas(struct ndr_print *ndr, const char *n ndr->depth--; ndr_print_ptr(ndr, "delta_enum_array", r->out.delta_enum_array); ndr->depth++; - ndr_print_netr_DELTA_ENUM_ARRAY(ndr, "delta_enum_array", r->out.delta_enum_array); + ndr_print_ptr(ndr, "delta_enum_array", *r->out.delta_enum_array); + ndr->depth++; + if (*r->out.delta_enum_array) { + ndr_print_netr_DELTA_ENUM_ARRAY(ndr, "delta_enum_array", *r->out.delta_enum_array); + } + ndr->depth--; ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index 97089d45f7..83879e2c21 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -936,7 +936,7 @@ struct netr_DatabaseDeltas { struct { const char *logon_server;/* [charset(UTF16)] */ const char *computername;/* [charset(UTF16)] */ - struct netr_Authenticator credential; + struct netr_Authenticator *credential;/* [ref] */ enum netr_SamDatabaseID database_id; uint32_t preferredmaximumlength; struct netr_Authenticator *return_authenticator;/* [ref] */ @@ -944,7 +944,7 @@ struct netr_DatabaseDeltas { } in; struct { - struct netr_DELTA_ENUM_ARRAY *delta_enum_array;/* [ref] */ + struct netr_DELTA_ENUM_ARRAY **delta_enum_array;/* [ref] */ struct netr_Authenticator *return_authenticator;/* [ref] */ uint64_t *sequence_num;/* [ref] */ NTSTATUS result; diff --git a/source3/librpc/gen_ndr/srv_netlogon.c b/source3/librpc/gen_ndr/srv_netlogon.c index 808493463a..5965490e24 100644 --- a/source3/librpc/gen_ndr/srv_netlogon.c +++ b/source3/librpc/gen_ndr/srv_netlogon.c @@ -599,7 +599,7 @@ static bool api_netr_DatabaseDeltas(pipes_struct *p) ZERO_STRUCT(r->out); r->out.return_authenticator = r->in.return_authenticator; r->out.sequence_num = r->in.sequence_num; - r->out.delta_enum_array = talloc_zero(r, struct netr_DELTA_ENUM_ARRAY); + r->out.delta_enum_array = talloc_zero(r, struct netr_DELTA_ENUM_ARRAY *); if (r->out.delta_enum_array == NULL) { talloc_free(r); return false; -- cgit From 401c0a6551efe2ac574d4fa0337c15ee2dd61da7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 13:51:54 +0100 Subject: Add netlogon_creds_client_check and netlogon_creds_client_step. Guenther (This used to be commit 41d33a2507e3fae7837bb8e42b1ac30cc31c31dc) --- source3/libsmb/credentials.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source3') diff --git a/source3/libsmb/credentials.c b/source3/libsmb/credentials.c index 1256a6210e..f03bf22df1 100644 --- a/source3/libsmb/credentials.c +++ b/source3/libsmb/credentials.c @@ -329,6 +329,25 @@ bool creds_client_check(const struct dcinfo *dc, const DOM_CHAL *rcv_srv_chal_in return True; } +bool netlogon_creds_client_check(const struct dcinfo *dc, + const struct netr_Credential *rcv_srv_chal_in) +{ + if (memcmp(dc->srv_chal.data, rcv_srv_chal_in->data, + sizeof(dc->srv_chal.data))) { + + DEBUG(0,("netlogon_creds_client_check: credentials check failed.\n")); + DEBUGADD(5,("netlogon_creds_client_check: challenge : %s\n", + credstr(rcv_srv_chal_in->data))); + DEBUGADD(5,("calculated: %s\n", credstr(dc->srv_chal.data))); + return false; + } + + DEBUG(10,("netlogon_creds_client_check: credentials check OK.\n")); + + return true; +} + + /**************************************************************************** Step the client credentials to the next element in the chain, updating the current client and server credentials and the seed @@ -345,3 +364,15 @@ void creds_client_step(struct dcinfo *dc, DOM_CRED *next_cred_out) next_cred_out->challenge = dc->clnt_chal; next_cred_out->timestamp.time = dc->sequence; } + +void netlogon_creds_client_step(struct dcinfo *dc, + struct netr_Authenticator *next_cred_out) +{ + dc->sequence += 2; + creds_step(dc); + creds_reseed(dc); + + memcpy(&next_cred_out->cred.data, &dc->clnt_chal.data, + sizeof(next_cred_out->cred.data)); + next_cred_out->timestamp = dc->sequence; +} -- cgit From 013a15a1b8b1b2e410582d6b97831bbb45d06c79 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 13:55:18 +0100 Subject: Use rpccli_netr_DatabaseDeltas() in rpcclient. Guenther (This used to be commit 72ad42fee30242eb57ae0db825127fdb8f9375fd) --- source3/rpcclient/cmd_netlogon.c | 246 +++++++++++++++++++++++++-------------- 1 file changed, 159 insertions(+), 87 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ac27d387ce..cf52da7c9f 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -439,70 +439,117 @@ static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, /* Display sam synchronisation information */ -static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, - SAM_DELTA_CTR *deltas) +static void display_sam_sync(struct netr_DELTA_ENUM_ARRAY *r) { - fstring name; - uint32 i, j; - - for (i = 0; i < num_deltas; i++) { - switch (hdr_deltas[i].type) { - case SAM_DELTA_DOMAIN_INFO: - unistr2_to_ascii(name, - &deltas[i].domain_info.uni_dom_name, - sizeof(name)); - printf("Domain: %s\n", name); - break; - case SAM_DELTA_GROUP_INFO: - unistr2_to_ascii(name, - &deltas[i].group_info.uni_grp_name, - sizeof(name)); - printf("Group: %s\n", name); - break; - case SAM_DELTA_ACCOUNT_INFO: - unistr2_to_ascii(name, - &deltas[i].account_info.uni_acct_name, - sizeof(name)); - printf("Account: %s\n", name); - break; - case SAM_DELTA_ALIAS_INFO: - unistr2_to_ascii(name, - &deltas[i].alias_info.uni_als_name, - sizeof(name)); - printf("Alias: %s\n", name); - break; - case SAM_DELTA_ALIAS_MEM: { - SAM_ALIAS_MEM_INFO *alias = &deltas[i].als_mem_info; - - for (j = 0; j < alias->num_members; j++) { - fstring sid_str; - - sid_to_fstring(sid_str, &alias->sids[j].sid); - - printf("%s\n", sid_str); - } - break; - } - case SAM_DELTA_GROUP_MEM: { - SAM_GROUP_MEM_INFO *group = &deltas[i].grp_mem_info; - - for (j = 0; j < group->num_members; j++) - printf("rid 0x%x, attrib 0x%08x\n", - group->rids[j], group->attribs[j]); - break; - } - case SAM_DELTA_MODIFIED_COUNT: { - SAM_DELTA_MOD_COUNT *mc = &deltas[i].mod_count; - - printf("sam sequence update: 0x%04x\n", mc->seqnum); - break; - } - default: - printf("unknown delta type 0x%02x\n", - hdr_deltas[i].type); - break; - } - } + uint32_t i, j; + + for (i=0; i < r->num_deltas; i++) { + + union netr_DELTA_UNION u = r->delta_enum[i].delta_union; + union netr_DELTA_ID_UNION id = r->delta_enum[i].delta_id_union; + + switch (r->delta_enum[i].delta_type) { + case NETR_DELTA_DOMAIN: + printf("Domain: %s\n", + u.domain->domain_name.string); + break; + case NETR_DELTA_GROUP: + printf("Group: %s\n", + u.group->group_name.string); + break; + case NETR_DELTA_DELETE_GROUP: + printf("Delete Group: %d\n", + u.delete_account.unknown); + break; + case NETR_DELTA_RENAME_GROUP: + printf("Rename Group: %s -> %s\n", + u.rename_group->OldName.string, + u.rename_group->NewName.string); + break; + case NETR_DELTA_USER: + printf("Account: %s\n", + u.user->account_name.string); + break; + case NETR_DELTA_DELETE_USER: + printf("Delete User: %d\n", + id.rid); + break; + case NETR_DELTA_RENAME_USER: + printf("Rename user: %s -> %s\n", + u.rename_user->OldName.string, + u.rename_user->NewName.string); + break; + case NETR_DELTA_GROUP_MEMBER: + for (j=0; j < u.group_member->num_rids; j++) { + printf("rid 0x%x, attrib 0x%08x\n", + u.group_member->rids[j], + u.group_member->attribs[j]); + } + break; + case NETR_DELTA_ALIAS: + printf("Alias: %s\n", + u.alias->alias_name.string); + break; + case NETR_DELTA_DELETE_ALIAS: + printf("Delete Alias: %d\n", + r->delta_enum[i].delta_id_union.rid); + break; + case NETR_DELTA_RENAME_ALIAS: + printf("Rename alias: %s -> %s\n", + u.rename_alias->OldName.string, + u.rename_alias->NewName.string); + break; + case NETR_DELTA_ALIAS_MEMBER: + for (j=0; j < u.alias_member->sids.num_sids; j++) { + fstring sid_str; + sid_to_fstring(sid_str, + u.alias_member->sids.sids[j].sid); + printf("%s\n", sid_str); + } + break; + case NETR_DELTA_POLICY: + printf("Policy\n"); + break; + case NETR_DELTA_TRUSTED_DOMAIN: + printf("Trusted Domain: %s\n", + u.trusted_domain->domain_name.string); + break; + case NETR_DELTA_DELETE_TRUST: + printf("Delete Trust: %d\n", + u.delete_trust.unknown); + break; + case NETR_DELTA_ACCOUNT: + printf("Account\n"); + break; + case NETR_DELTA_DELETE_ACCOUNT: + printf("Delete Account: %d\n", + u.delete_account.unknown); + break; + case NETR_DELTA_SECRET: + printf("Secret\n"); + break; + case NETR_DELTA_DELETE_SECRET: + printf("Delete Secret: %d\n", + u.delete_secret.unknown); + break; + case NETR_DELTA_DELETE_GROUP2: + printf("Delete Group2: %s\n", + u.delete_group->account_name); + break; + case NETR_DELTA_DELETE_USER2: + printf("Delete User2: %s\n", + u.delete_user->account_name); + break; + case NETR_DELTA_MODIFY_COUNT: + printf("sam sequence update: 0x%016llx\n", + (unsigned long long) *u.modified_count); + break; + default: + printf("unknown delta type 0x%02x\n", + r->delta_enum[i].delta_type); + break; + } + } } /* Perform sam synchronisation */ @@ -534,7 +581,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, /* Display results */ - display_sam_sync(num_deltas, hdr_deltas, deltas); +/* display_sam_sync(num_deltas, hdr_deltas, deltas); */ done: return result; @@ -542,38 +589,63 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, /* Perform sam delta synchronisation */ -static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - uint32 database_id, num_deltas, tmp; - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; - uint64 seqnum; + uint32_t tmp; + const char *logon_server = cli->cli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; + uint64_t sequence_num; + + if (argc != 3) { + fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); + return NT_STATUS_OK; + } - if (argc != 3) { - fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); - return NT_STATUS_OK; - } + database_id = atoi(argv[1]); + tmp = atoi(argv[2]); - database_id = atoi(argv[1]); - tmp = atoi(argv[2]); + sequence_num = tmp & 0xffff; - seqnum = tmp & 0xffff; + do { + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; - result = rpccli_netlogon_sam_deltas(cli, mem_ctx, database_id, - seqnum, &num_deltas, - &hdr_deltas, &deltas); + netlogon_creds_client_step(cli->dc, &credential); - if (!NT_STATUS_IS_OK(result)) - goto done; + result = rpccli_netr_DatabaseDeltas(cli, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + &sequence_num, + &delta_enum_array, + 0xffff); - /* Display results */ + /* Check returned credentials. */ + if (!netlogon_creds_client_check(cli->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } + + if (NT_STATUS_IS_ERR(result)) { + break; + } + + /* Display results */ + + display_sam_sync(delta_enum_array); + + TALLOC_FREE(delta_enum_array); + + } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); - display_sam_sync(num_deltas, hdr_deltas, deltas); - - done: return result; } -- cgit From 99f1806af994dad5923c9e94b4a83ca094f991a4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 02:59:48 +0100 Subject: Remove unused marshalling for NET_SAM_DELTAS. Guenther (This used to be commit 2dd01f07411744f1f8fec0bff7af554db08ab960) --- source3/include/rpc_netlogon.h | 29 -------- source3/rpc_client/cli_netlogon.c | 52 --------------- source3/rpc_parse/parse_net.c | 135 -------------------------------------- 3 files changed, 216 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index c8a25cdf4d..93b50c9c00 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -831,35 +831,6 @@ typedef struct net_r_sam_sync_info { NTSTATUS status; } NET_R_SAM_SYNC; -/* NET_Q_SAM_DELTAS */ -typedef struct net_q_sam_deltas_info { - UNISTR2 uni_srv_name; - UNISTR2 uni_cli_name; - DOM_CRED cli_creds; - DOM_CRED ret_creds; - - uint32 database_id; - uint64 dom_mod_count; /* domain mod count at last sync */ - - uint32 max_size; /* preferred maximum length */ -} NET_Q_SAM_DELTAS; - -/* NET_R_SAM_DELTAS */ -typedef struct net_r_sam_deltas_info { - DOM_CRED srv_creds; - - uint64 dom_mod_count; /* new domain mod count */ - - uint32 ptr_deltas; - uint32 num_deltas; - uint32 num_deltas2; - - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; - - NTSTATUS status; -} NET_R_SAM_DELTAS; - #define DSGETDC_VALID_FLAGS ( \ DS_FORCE_REDISCOVERY | \ DS_DIRECTORY_SERVICE_REQUIRED | \ diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index d28df3c164..0da482c9ef 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -400,58 +400,6 @@ NTSTATUS rpccli_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c return result; } -/* Sam synchronisation */ - -NTSTATUS rpccli_netlogon_sam_deltas(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - uint32 database_id, uint64 seqnum, - uint32 *num_deltas, - SAM_DELTA_HDR **hdr_deltas, - SAM_DELTA_CTR **deltas) -{ - prs_struct qbuf, rbuf; - NET_Q_SAM_DELTAS q; - NET_R_SAM_DELTAS r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_CRED clnt_creds; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialise input parameters */ - - creds_client_step(cli->dc, &clnt_creds); - - init_net_q_sam_deltas(&q, cli->dc->remote_machine, - global_myname(), &clnt_creds, - database_id, seqnum); - - /* Marshall data and send request */ - - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_SAM_DELTAS, - q, r, - qbuf, rbuf, - net_io_q_sam_deltas, - net_io_r_sam_deltas, - NT_STATUS_UNSUCCESSFUL); - - /* Return results */ - - result = r.status; - *num_deltas = r.num_deltas2; - *hdr_deltas = r.hdr_deltas; - *deltas = r.deltas; - - if (!NT_STATUS_IS_ERR(result)) { - /* Check returned credentials. */ - if (!creds_client_check(cli->dc, &r.srv_creds.challenge)) { - DEBUG(0,("cli_netlogon_sam_sync: credentials chain check failed\n")); - return NT_STATUS_ACCESS_DENIED; - } - } - - return result; -} - /* Logon domain user */ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index 8105ac5470..b4ed470cce 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -2571,138 +2571,3 @@ bool net_io_r_sam_sync(const char *desc, return True; } - -/******************************************************************* -makes a NET_Q_SAM_DELTAS structure. -********************************************************************/ -bool init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name, - const char *cli_name, DOM_CRED *cli_creds, - uint32 database_id, uint64 dom_mod_count) -{ - DEBUG(5, ("init_net_q_sam_deltas\n")); - - init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE); - init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE); - - memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds)); - memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds)); - - q_s->database_id = database_id; - q_s->dom_mod_count = dom_mod_count; - q_s->max_size = 0xffff; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -bool net_io_q_sam_deltas(const char *desc, NET_Q_SAM_DELTAS *q_s, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "net_io_q_sam_deltas"); - depth++; - - if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth)) - return False; - if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth)) - return False; - - if (!smb_io_cred("", &q_s->cli_creds, ps, depth)) - return False; - if (!smb_io_cred("", &q_s->ret_creds, ps, depth)) - return False; - - if (!prs_uint32("database_id ", ps, depth, &q_s->database_id)) - return False; - if (!prs_uint64("dom_mod_count", ps, depth, &q_s->dom_mod_count)) - return False; - if (!prs_uint32("max_size", ps, depth, &q_s->max_size)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -bool net_io_r_sam_deltas(const char *desc, - NET_R_SAM_DELTAS *r_s, prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "net_io_r_sam_deltas"); - depth++; - - if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth)) - return False; - if (!prs_uint64("dom_mod_count", ps, depth, &r_s->dom_mod_count)) - return False; - - if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas)) - return False; - if (!prs_uint32("num_deltas", ps, depth, &r_s->num_deltas)) - return False; - if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->num_deltas2)) - return False; - - if (r_s->num_deltas2 != 0) - { - if (!prs_uint32("num_deltas2 ", ps, depth, &r_s->num_deltas2)) - return False; - - if (r_s->ptr_deltas != 0) - { - if (UNMARSHALLING(ps)) { - if (r_s->num_deltas) { - r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas); - if (r_s->hdr_deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d delta headers\n", - r_s->num_deltas)); - return False; - } - } else { - r_s->hdr_deltas = NULL; - } - } - - for (i = 0; i < r_s->num_deltas; i++) - { - net_io_sam_delta_hdr("", &r_s->hdr_deltas[i], - ps, depth); - } - - if (UNMARSHALLING(ps)) { - if (r_s->num_deltas) { - r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas); - if (r_s->deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d deltas\n", - r_s->num_deltas)); - return False; - } - } else { - r_s->deltas = NULL; - } - } - - for (i = 0; i < r_s->num_deltas; i++) - { - if (!net_io_sam_delta_ctr( - "", - &r_s->deltas[i], - r_s->hdr_deltas[i].type2, - ps, depth)) - - return False; - } - } - } - - prs_align(ps); - if (!prs_ntstatus("status", ps, depth, &r_s->status)) - return False; - - return True; -} -- cgit From b757512d16cb61fbbeac633fda3e8593cf746c86 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 01:18:47 +0100 Subject: Fix IDL for netr_DatabaseSync2. Guenther (This used to be commit 6355a8ee9789b8a30b00876835c22a724e637cf1) --- source3/librpc/idl/netlogon.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index e79096269f..60bf075ddf 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -865,13 +865,13 @@ interface netlogon NTSTATUS netr_DatabaseSync2( [in] [string,charset(UTF16)] uint16 logon_server[], [in] [string,charset(UTF16)] uint16 computername[], - [in] netr_Authenticator credential, + [in] netr_Authenticator *credential, [in,out,ref] netr_Authenticator *return_authenticator, [in] netr_SamDatabaseID database_id, [in] uint16 restart_state, [in,out,ref] uint32 *sync_context, - [in] uint32 preferredmaximumlength, - [out,ref] netr_DELTA_ENUM_ARRAY *delta_enum_array + [out,ref] netr_DELTA_ENUM_ARRAY **delta_enum_array, + [in] uint32 preferredmaximumlength ); -- cgit From 13f9cd938d2cfc8dc270314aa3ee6a8b80de90fd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 14:08:24 +0100 Subject: Re-run make idl. Guenther (This used to be commit 2add8790199079753c21ec2797e14b8bed2d8278) --- source3/librpc/gen_ndr/cli_netlogon.c | 6 ++--- source3/librpc/gen_ndr/cli_netlogon.h | 6 ++--- source3/librpc/gen_ndr/ndr_netlogon.c | 46 ++++++++++++++++++++++++++++++----- source3/librpc/gen_ndr/netlogon.h | 4 +-- source3/librpc/gen_ndr/srv_netlogon.c | 2 +- 5 files changed, 49 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_netlogon.c b/source3/librpc/gen_ndr/cli_netlogon.c index 5e1593249d..ef9eeaf7c2 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.c +++ b/source3/librpc/gen_ndr/cli_netlogon.c @@ -847,13 +847,13 @@ NTSTATUS rpccli_netr_DatabaseSync2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *logon_server, const char *computername, - struct netr_Authenticator credential, + struct netr_Authenticator *credential, struct netr_Authenticator *return_authenticator, enum netr_SamDatabaseID database_id, uint16_t restart_state, uint32_t *sync_context, - uint32_t preferredmaximumlength, - struct netr_DELTA_ENUM_ARRAY *delta_enum_array) + struct netr_DELTA_ENUM_ARRAY **delta_enum_array, + uint32_t preferredmaximumlength) { struct netr_DatabaseSync2 r; NTSTATUS status; diff --git a/source3/librpc/gen_ndr/cli_netlogon.h b/source3/librpc/gen_ndr/cli_netlogon.h index 034594147a..35f903267d 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.h +++ b/source3/librpc/gen_ndr/cli_netlogon.h @@ -142,13 +142,13 @@ NTSTATUS rpccli_netr_DatabaseSync2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *logon_server, const char *computername, - struct netr_Authenticator credential, + struct netr_Authenticator *credential, struct netr_Authenticator *return_authenticator, enum netr_SamDatabaseID database_id, uint16_t restart_state, uint32_t *sync_context, - uint32_t preferredmaximumlength, - struct netr_DELTA_ENUM_ARRAY *delta_enum_array); + struct netr_DELTA_ENUM_ARRAY **delta_enum_array, + uint32_t preferredmaximumlength); NTSTATUS rpccli_netr_DatabaseRedo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *logon_server, diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index 43a077f7f9..e5766487b3 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -10516,7 +10516,10 @@ static enum ndr_err_code ndr_push_netr_DatabaseSync2(struct ndr_push *ndr, int f NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.computername, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.computername, ndr_charset_length(r->in.computername, CH_UTF16), sizeof(uint16_t), CH_UTF16)); - NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, &r->in.credential)); + if (r->in.credential == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, r->in.credential)); if (r->in.return_authenticator == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -10541,7 +10544,10 @@ static enum ndr_err_code ndr_push_netr_DatabaseSync2(struct ndr_push *ndr, int f if (r->out.delta_enum_array == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_netr_DELTA_ENUM_ARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.delta_enum_array)); + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.delta_enum_array)); + if (*r->out.delta_enum_array) { + NDR_CHECK(ndr_push_netr_DELTA_ENUM_ARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.delta_enum_array)); + } NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -10549,9 +10555,12 @@ static enum ndr_err_code ndr_push_netr_DatabaseSync2(struct ndr_push *ndr, int f static enum ndr_err_code ndr_pull_netr_DatabaseSync2(struct ndr_pull *ndr, int flags, struct netr_DatabaseSync2 *r) { + uint32_t _ptr_delta_enum_array; + TALLOC_CTX *_mem_save_credential_0; TALLOC_CTX *_mem_save_return_authenticator_0; TALLOC_CTX *_mem_save_sync_context_0; TALLOC_CTX *_mem_save_delta_enum_array_0; + TALLOC_CTX *_mem_save_delta_enum_array_1; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -10569,7 +10578,13 @@ static enum ndr_err_code ndr_pull_netr_DatabaseSync2(struct ndr_pull *ndr, int f } NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.computername), sizeof(uint16_t))); NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.computername, ndr_get_array_length(ndr, &r->in.computername), sizeof(uint16_t), CH_UTF16)); - NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, &r->in.credential)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.credential); + } + _mem_save_credential_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.credential, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, r->in.credential)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_credential_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.return_authenticator); } @@ -10614,7 +10629,18 @@ static enum ndr_err_code ndr_pull_netr_DatabaseSync2(struct ndr_pull *ndr, int f } _mem_save_delta_enum_array_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.delta_enum_array, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_netr_DELTA_ENUM_ARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.delta_enum_array)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_delta_enum_array)); + if (_ptr_delta_enum_array) { + NDR_PULL_ALLOC(ndr, *r->out.delta_enum_array); + } else { + *r->out.delta_enum_array = NULL; + } + if (*r->out.delta_enum_array) { + _mem_save_delta_enum_array_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.delta_enum_array, 0); + NDR_CHECK(ndr_pull_netr_DELTA_ENUM_ARRAY(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.delta_enum_array)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_delta_enum_array_1, 0); + } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_delta_enum_array_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -10633,7 +10659,10 @@ _PUBLIC_ void ndr_print_netr_DatabaseSync2(struct ndr_print *ndr, const char *na ndr->depth++; ndr_print_string(ndr, "logon_server", r->in.logon_server); ndr_print_string(ndr, "computername", r->in.computername); - ndr_print_netr_Authenticator(ndr, "credential", &r->in.credential); + ndr_print_ptr(ndr, "credential", r->in.credential); + ndr->depth++; + ndr_print_netr_Authenticator(ndr, "credential", r->in.credential); + ndr->depth--; ndr_print_ptr(ndr, "return_authenticator", r->in.return_authenticator); ndr->depth++; ndr_print_netr_Authenticator(ndr, "return_authenticator", r->in.return_authenticator); @@ -10660,7 +10689,12 @@ _PUBLIC_ void ndr_print_netr_DatabaseSync2(struct ndr_print *ndr, const char *na ndr->depth--; ndr_print_ptr(ndr, "delta_enum_array", r->out.delta_enum_array); ndr->depth++; - ndr_print_netr_DELTA_ENUM_ARRAY(ndr, "delta_enum_array", r->out.delta_enum_array); + ndr_print_ptr(ndr, "delta_enum_array", *r->out.delta_enum_array); + ndr->depth++; + if (*r->out.delta_enum_array) { + ndr_print_netr_DELTA_ENUM_ARRAY(ndr, "delta_enum_array", *r->out.delta_enum_array); + } + ndr->depth--; ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index 83879e2c21..c18527da00 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -1105,7 +1105,7 @@ struct netr_DatabaseSync2 { struct { const char *logon_server;/* [charset(UTF16)] */ const char *computername;/* [charset(UTF16)] */ - struct netr_Authenticator credential; + struct netr_Authenticator *credential;/* [ref] */ enum netr_SamDatabaseID database_id; uint16_t restart_state; uint32_t preferredmaximumlength; @@ -1114,7 +1114,7 @@ struct netr_DatabaseSync2 { } in; struct { - struct netr_DELTA_ENUM_ARRAY *delta_enum_array;/* [ref] */ + struct netr_DELTA_ENUM_ARRAY **delta_enum_array;/* [ref] */ struct netr_Authenticator *return_authenticator;/* [ref] */ uint32_t *sync_context;/* [ref] */ NTSTATUS result; diff --git a/source3/librpc/gen_ndr/srv_netlogon.c b/source3/librpc/gen_ndr/srv_netlogon.c index 5965490e24..98ba48aa17 100644 --- a/source3/librpc/gen_ndr/srv_netlogon.c +++ b/source3/librpc/gen_ndr/srv_netlogon.c @@ -1358,7 +1358,7 @@ static bool api_netr_DatabaseSync2(pipes_struct *p) ZERO_STRUCT(r->out); r->out.return_authenticator = r->in.return_authenticator; r->out.sync_context = r->in.sync_context; - r->out.delta_enum_array = talloc_zero(r, struct netr_DELTA_ENUM_ARRAY); + r->out.delta_enum_array = talloc_zero(r, struct netr_DELTA_ENUM_ARRAY *); if (r->out.delta_enum_array == NULL) { talloc_free(r); return false; -- cgit From eafec423b78f91f97793e26b6dd0c2a27c557d19 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 14:11:20 +0100 Subject: Use rpccli_netr_DatabaseSync2() in rpcclient. Guenther (This used to be commit 042173b00e023b4d4e7739524e24baa8803850bd) --- source3/rpcclient/cmd_netlogon.c | 59 ++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index cf52da7c9f..49098b12e4 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -554,37 +554,66 @@ static void display_sam_sync(struct netr_DELTA_ENUM_ARRAY *r) /* Perform sam synchronisation */ -static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, +static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - uint32 database_id = 0, num_deltas; - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; + const char *logon_server = cli->cli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; + uint16_t restart_state = 0; + uint32_t sync_context = 0; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); return NT_STATUS_OK; } - if (argc == 2) - database_id = atoi(argv[1]); + if (argc == 2) { + database_id = atoi(argv[1]); + } + + /* Synchronise sam database */ + + do { + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; - /* Synchronise sam database */ + netlogon_creds_client_step(cli->dc, &credential); - result = rpccli_netlogon_sam_sync(cli, mem_ctx, database_id, - 0, &num_deltas, &hdr_deltas, &deltas); + result = rpccli_netr_DatabaseSync2(cli, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + restart_state, + &sync_context, + &delta_enum_array, + 0xffff); - if (!NT_STATUS_IS_OK(result)) - goto done; + /* Check returned credentials. */ + if (!netlogon_creds_client_check(cli->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } - /* Display results */ + if (NT_STATUS_IS_ERR(result)) { + break; + } -/* display_sam_sync(num_deltas, hdr_deltas, deltas); */ + /* Display results */ - done: - return result; + display_sam_sync(delta_enum_array); + + TALLOC_FREE(delta_enum_array); + + } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); + + return result; } /* Perform sam delta synchronisation */ -- cgit From b7f483e6bda197d62a1432629b62bd9f834df42b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 14:13:11 +0100 Subject: Convert "net rpc vampire/samdump" to pidl generated functions. Guenther (This used to be commit f53393677d2c4b5ca117eed3ed660fafc4c650da) --- source3/utils/net_rpc_samsync.c | 944 +++++++++++++++++++++++----------------- 1 file changed, 556 insertions(+), 388 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index e1f0cd3751..569bbea857 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. dump the remote SAM using rpc samsync operations @@ -12,12 +12,12 @@ 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 . */ @@ -31,57 +31,62 @@ static uint32 ldif_uid = 999; /* Keep track of ldap initialization */ static int init_ldap = 1; -static void display_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *g) +static void display_group_mem_info(uint32_t rid, + struct netr_DELTA_GROUP_MEMBER *r) { int i; d_printf("Group mem %u: ", rid); - for (i=0;inum_members;i++) { - d_printf("%u ", g->rids[i]); + for (i=0; i< r->num_rids; i++) { + d_printf("%u ", r->rids[i]); } d_printf("\n"); } -static void display_alias_info(uint32 rid, SAM_ALIAS_INFO *a) +static void display_alias_info(uint32_t rid, + struct netr_DELTA_ALIAS *r) { - d_printf("Alias '%s' ", unistr2_static(&a->uni_als_name)); - d_printf("desc='%s' rid=%u\n", unistr2_static(&a->uni_als_desc), a->als_rid); + d_printf("Alias '%s' ", r->alias_name.string); + d_printf("desc='%s' rid=%u\n", r->description.string, r->rid); } -static void display_alias_mem(uint32 rid, SAM_ALIAS_MEM_INFO *a) +static void display_alias_mem(uint32_t rid, + struct netr_DELTA_ALIAS_MEMBER *r) { int i; d_printf("Alias rid %u: ", rid); - for (i=0;inum_members;i++) { - d_printf("%s ", sid_string_tos(&a->sids[i].sid)); + for (i=0; i< r->sids.num_sids; i++) { + d_printf("%s ", sid_string_tos(r->sids.sids[i].sid)); } d_printf("\n"); } -static void display_account_info(uint32 rid, SAM_ACCOUNT_INFO *a) +static void display_account_info(uint32_t rid, + struct netr_DELTA_USER *r) { fstring hex_nt_passwd, hex_lm_passwd; uchar lm_passwd[16], nt_passwd[16]; static uchar zero_buf[16]; /* Decode hashes from password hash (if they are not NULL) */ - - if (memcmp(a->pass.buf_lm_pwd, zero_buf, 16) != 0) { - sam_pwd_hash(a->user_rid, a->pass.buf_lm_pwd, lm_passwd, 0); - pdb_sethexpwd(hex_lm_passwd, lm_passwd, a->acb_info); + + if (memcmp(r->lmpassword.hash, zero_buf, 16) != 0) { + sam_pwd_hash(r->rid, r->lmpassword.hash, lm_passwd, 0); + pdb_sethexpwd(hex_lm_passwd, lm_passwd, r->acct_flags); } else { pdb_sethexpwd(hex_lm_passwd, NULL, 0); } - if (memcmp(a->pass.buf_nt_pwd, zero_buf, 16) != 0) { - sam_pwd_hash(a->user_rid, a->pass.buf_nt_pwd, nt_passwd, 0); - pdb_sethexpwd(hex_nt_passwd, nt_passwd, a->acb_info); + if (memcmp(r->ntpassword.hash, zero_buf, 16) != 0) { + sam_pwd_hash(r->rid, r->ntpassword.hash, nt_passwd, 0); + pdb_sethexpwd(hex_nt_passwd, nt_passwd, r->acct_flags); } else { pdb_sethexpwd(hex_nt_passwd, NULL, 0); } - - printf("%s:%d:%s:%s:%s:LCT-0\n", unistr2_static(&a->uni_acct_name), - a->user_rid, hex_lm_passwd, hex_nt_passwd, - pdb_encode_acct_ctrl(a->acb_info, NEW_PW_FORMAT_SPACE_PADDED_LEN)); + + printf("%s:%d:%s:%s:%s:LCT-0\n", + r->account_name.string, + r->rid, hex_lm_passwd, hex_nt_passwd, + pdb_encode_acct_ctrl(r->acct_flags, NEW_PW_FORMAT_SPACE_PADDED_LEN)); } static time_t uint64s_nt_time_to_unix_abs(const uint64 *src) @@ -91,102 +96,201 @@ static time_t uint64s_nt_time_to_unix_abs(const uint64 *src) return nt_time_to_unix_abs(&nttime); } -static void display_domain_info(SAM_DOMAIN_INFO *a) +static void display_domain_info(struct netr_DELTA_DOMAIN *r) { time_t u_logout; - u_logout = uint64s_nt_time_to_unix_abs(&a->force_logoff); + u_logout = uint64s_nt_time_to_unix_abs((const uint64 *)&r->force_logoff_time); - d_printf("Domain name: %s\n", unistr2_static(&a->uni_dom_name)); + d_printf("Domain name: %s\n", r->domain_name.string); - d_printf("Minimal Password Length: %d\n", a->min_pwd_len); - d_printf("Password History Length: %d\n", a->pwd_history_len); + d_printf("Minimal Password Length: %d\n", r->min_password_length); + d_printf("Password History Length: %d\n", r->password_history_length); d_printf("Force Logoff: %d\n", (int)u_logout); - d_printf("Max Password Age: %s\n", display_time(a->max_pwd_age)); - d_printf("Min Password Age: %s\n", display_time(a->min_pwd_age)); + d_printf("Max Password Age: %s\n", display_time(r->max_password_age)); + d_printf("Min Password Age: %s\n", display_time(r->min_password_age)); +#if 0 + /* FIXME - gd */ d_printf("Lockout Time: %s\n", display_time(a->account_lockout.lockout_duration)); d_printf("Lockout Reset Time: %s\n", display_time(a->account_lockout.reset_count)); - d_printf("Bad Attempt Lockout: %d\n", a->account_lockout.bad_attempt_lockout); - d_printf("User must logon to change password: %d\n", a->logon_chgpass); +#endif + d_printf("User must logon to change password: %d\n", r->logon_to_chgpass); } -static void display_group_info(uint32 rid, SAM_GROUP_INFO *a) +static void display_group_info(uint32_t rid, struct netr_DELTA_GROUP *r) { - d_printf("Group '%s' ", unistr2_static(&a->uni_grp_name)); - d_printf("desc='%s', rid=%u\n", unistr2_static(&a->uni_grp_desc), rid); + d_printf("Group '%s' ", r->group_name.string); + d_printf("desc='%s', rid=%u\n", r->description.string, rid); } -static void display_sam_entry(SAM_DELTA_HDR *hdr_delta, SAM_DELTA_CTR *delta) +static void display_sam_entry(struct netr_DELTA_ENUM *r) { - switch (hdr_delta->type) { - case SAM_DELTA_ACCOUNT_INFO: - display_account_info(hdr_delta->target_rid, &delta->account_info); + union netr_DELTA_UNION u = r->delta_union; + union netr_DELTA_ID_UNION id = r->delta_id_union; + + switch (r->delta_type) { + case NETR_DELTA_DOMAIN: + display_domain_info(u.domain); + break; + case NETR_DELTA_GROUP: + display_group_info(id.rid, u.group); + break; +#if 0 + case NETR_DELTA_DELETE_GROUP: + printf("Delete Group: %d\n", + u.delete_account.unknown); + break; + case NETR_DELTA_RENAME_GROUP: + printf("Rename Group: %s -> %s\n", + u.rename_group->OldName.string, + u.rename_group->NewName.string); + break; +#endif + case NETR_DELTA_USER: + display_account_info(id.rid, u.user); + break; +#if 0 + case NETR_DELTA_DELETE_USER: + printf("Delete User: %d\n", + id.rid); + break; + case NETR_DELTA_RENAME_USER: + printf("Rename user: %s -> %s\n", + u.rename_user->OldName.string, + u.rename_user->NewName.string); + break; +#endif + case NETR_DELTA_GROUP_MEMBER: + display_group_mem_info(id.rid, u.group_member); + break; + case NETR_DELTA_ALIAS: + display_alias_info(id.rid, u.alias); + break; +#if 0 + case NETR_DELTA_DELETE_ALIAS: + printf("Delete Alias: %d\n", + id.rid); + break; + case NETR_DELTA_RENAME_ALIAS: + printf("Rename alias: %s -> %s\n", + u.rename_alias->OldName.string, + u.rename_alias->NewName.string); + break; +#endif + case NETR_DELTA_ALIAS_MEMBER: + display_alias_mem(id.rid, u.alias_member); + break; +#if 0 + case NETR_DELTA_POLICY: + printf("Policy\n"); + break; + case NETR_DELTA_TRUSTED_DOMAIN: + printf("Trusted Domain: %s\n", + u.trusted_domain->domain_name.string); + break; + case NETR_DELTA_DELETE_TRUST: + printf("Delete Trust: %d\n", + u.delete_trust.unknown); + break; + case NETR_DELTA_ACCOUNT: + printf("Account\n"); + break; + case NETR_DELTA_DELETE_ACCOUNT: + printf("Delete Account: %d\n", + u.delete_account.unknown); break; - case SAM_DELTA_GROUP_MEM: - display_group_mem_info(hdr_delta->target_rid, &delta->grp_mem_info); + case NETR_DELTA_SECRET: + printf("Secret\n"); break; - case SAM_DELTA_ALIAS_INFO: - display_alias_info(hdr_delta->target_rid, &delta->alias_info); + case NETR_DELTA_DELETE_SECRET: + printf("Delete Secret: %d\n", + u.delete_secret.unknown); + break; + case NETR_DELTA_DELETE_GROUP2: + printf("Delete Group2: %s\n", + u.delete_group->account_name); + break; + case NETR_DELTA_DELETE_USER2: + printf("Delete User2: %s\n", + u.delete_user->account_name); + break; + case NETR_DELTA_MODIFY_COUNT: + printf("sam sequence update: 0x%016llx\n", + (unsigned long long) *u.modified_count); + break; +#endif + /* The following types are recognised but not handled */ + case NETR_DELTA_RENAME_GROUP: + d_printf("NETR_DELTA_RENAME_GROUP not handled\n"); break; - case SAM_DELTA_ALIAS_MEM: - display_alias_mem(hdr_delta->target_rid, &delta->als_mem_info); + case NETR_DELTA_RENAME_USER: + d_printf("NETR_DELTA_RENAME_USER not handled\n"); break; - case SAM_DELTA_DOMAIN_INFO: - display_domain_info(&delta->domain_info); + case NETR_DELTA_RENAME_ALIAS: + d_printf("NETR_DELTA_RENAME_ALIAS not handled\n"); break; - case SAM_DELTA_GROUP_INFO: - display_group_info(hdr_delta->target_rid, &delta->group_info); + case NETR_DELTA_POLICY: + d_printf("NETR_DELTA_POLICY not handled\n"); break; - /* The following types are recognised but not handled */ - case SAM_DELTA_RENAME_GROUP: - d_printf("SAM_DELTA_RENAME_GROUP not handled\n"); + case NETR_DELTA_TRUSTED_DOMAIN: + d_printf("NETR_DELTA_TRUSTED_DOMAIN not handled\n"); break; - case SAM_DELTA_RENAME_USER: - d_printf("SAM_DELTA_RENAME_USER not handled\n"); + case NETR_DELTA_ACCOUNT: + d_printf("NETR_DELTA_ACCOUNT not handled\n"); break; - case SAM_DELTA_RENAME_ALIAS: - d_printf("SAM_DELTA_RENAME_ALIAS not handled\n"); + case NETR_DELTA_SECRET: + d_printf("NETR_DELTA_SECRET not handled\n"); break; - case SAM_DELTA_POLICY_INFO: - d_printf("SAM_DELTA_POLICY_INFO not handled\n"); + case NETR_DELTA_DELETE_GROUP: + d_printf("NETR_DELTA_DELETE_GROUP not handled\n"); break; - case SAM_DELTA_TRUST_DOMS: - d_printf("SAM_DELTA_TRUST_DOMS not handled\n"); + case NETR_DELTA_DELETE_USER: + d_printf("NETR_DELTA_DELETE_USER not handled\n"); break; - case SAM_DELTA_PRIVS_INFO: - d_printf("SAM_DELTA_PRIVS_INFO not handled\n"); + case NETR_DELTA_MODIFY_COUNT: + d_printf("NETR_DELTA_MODIFY_COUNT not handled\n"); break; - case SAM_DELTA_SECRET_INFO: - d_printf("SAM_DELTA_SECRET_INFO not handled\n"); + case NETR_DELTA_DELETE_ALIAS: + d_printf("NETR_DELTA_DELETE_ALIAS not handled\n"); break; - case SAM_DELTA_DELETE_GROUP: - d_printf("SAM_DELTA_DELETE_GROUP not handled\n"); + case NETR_DELTA_DELETE_TRUST: + d_printf("NETR_DELTA_DELETE_TRUST not handled\n"); break; - case SAM_DELTA_DELETE_USER: - d_printf("SAM_DELTA_DELETE_USER not handled\n"); + case NETR_DELTA_DELETE_ACCOUNT: + d_printf("NETR_DELTA_DELETE_ACCOUNT not handled\n"); break; - case SAM_DELTA_MODIFIED_COUNT: - d_printf("SAM_DELTA_MODIFIED_COUNT not handled\n"); + case NETR_DELTA_DELETE_SECRET: + d_printf("NETR_DELTA_DELETE_SECRET not handled\n"); + break; + case NETR_DELTA_DELETE_GROUP2: + d_printf("NETR_DELTA_DELETE_GROUP2 not handled\n"); + break; + case NETR_DELTA_DELETE_USER2: + d_printf("NETR_DELTA_DELETE_USER2 not handled\n"); break; default: - d_printf("Unknown delta record type %d\n", hdr_delta->type); + printf("unknown delta type 0x%02x\n", + r->delta_type); break; } } static void dump_database(struct rpc_pipe_client *pipe_hnd, uint32 db_type) { - uint32 sync_context = 0; NTSTATUS result; int i; TALLOC_CTX *mem_ctx; - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; - uint32 num_deltas; + const char *logon_server = pipe_hnd->cli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = db_type; + uint16_t restart_state = 0; + uint32_t sync_context = 0; if (!(mem_ctx = talloc_init("dump_database"))) { return; @@ -208,29 +312,52 @@ static void dump_database(struct rpc_pipe_client *pipe_hnd, uint32 db_type) } do { - result = rpccli_netlogon_sam_sync(pipe_hnd, mem_ctx, db_type, - sync_context, - &num_deltas, &hdr_deltas, &deltas); - if (!NT_STATUS_IS_OK(result)) + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; + + netlogon_creds_client_step(pipe_hnd->dc, &credential); + + result = rpccli_netr_DatabaseSync2(pipe_hnd, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + restart_state, + &sync_context, + &delta_enum_array, + 0xffff); + + /* Check returned credentials. */ + if (!netlogon_creds_client_check(pipe_hnd->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return; + } + + if (NT_STATUS_IS_ERR(result)) { break; + } - for (i = 0; i < num_deltas; i++) { - display_sam_entry(&hdr_deltas[i], &deltas[i]); + /* Display results */ + for (i = 0; i < delta_enum_array->num_deltas; i++) { + display_sam_entry(&delta_enum_array->delta_enum[i]); } - sync_context += 1; + + TALLOC_FREE(delta_enum_array); + } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); talloc_destroy(mem_ctx); } /* dump sam database via samsync rpc calls */ -NTSTATUS rpc_samdump_internals(const DOM_SID *domain_sid, - const char *domain_name, +NTSTATUS rpc_samdump_internals(const DOM_SID *domain_sid, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, - const char **argv) + const char **argv) { #if 0 /* net_rpc.c now always tries to create an schannel pipe.. */ @@ -277,7 +404,8 @@ NTSTATUS rpc_samdump_internals(const DOM_SID *domain_sid, (!(s1) && (s2)) ||\ ((s1) && (s2) && (strcmp((s1), (s2)) != 0)) -static NTSTATUS sam_account_from_delta(struct samu *account, SAM_ACCOUNT_INFO *delta) +static NTSTATUS sam_account_from_delta(struct samu *account, + struct netr_DELTA_USER *r) { const char *old_string, *new_string; time_t unix_time, stored_time; @@ -287,15 +415,14 @@ static NTSTATUS sam_account_from_delta(struct samu *account, SAM_ACCOUNT_INFO *d /* Username, fullname, home dir, dir drive, logon script, acct desc, workstations, profile. */ - if (delta->hdr_acct_name.buffer) { + if (r->account_name.string) { old_string = pdb_get_nt_username(account); - new_string = unistr2_static(&delta->uni_acct_name); + new_string = r->account_name.string; if (STRING_CHANGED) { pdb_set_nt_username(account, new_string, PDB_CHANGED); - } - + /* Unix username is the same - for sanity */ old_string = pdb_get_username( account ); if (STRING_CHANGED) { @@ -303,68 +430,68 @@ static NTSTATUS sam_account_from_delta(struct samu *account, SAM_ACCOUNT_INFO *d } } - if (delta->hdr_full_name.buffer) { + if (r->full_name.string) { old_string = pdb_get_fullname(account); - new_string = unistr2_static(&delta->uni_full_name); + new_string = r->full_name.string; if (STRING_CHANGED) pdb_set_fullname(account, new_string, PDB_CHANGED); } - if (delta->hdr_home_dir.buffer) { + if (r->home_directory.string) { old_string = pdb_get_homedir(account); - new_string = unistr2_static(&delta->uni_home_dir); + new_string = r->home_directory.string; if (STRING_CHANGED) pdb_set_homedir(account, new_string, PDB_CHANGED); } - if (delta->hdr_dir_drive.buffer) { + if (r->home_drive.string) { old_string = pdb_get_dir_drive(account); - new_string = unistr2_static(&delta->uni_dir_drive); + new_string = r->home_drive.string; if (STRING_CHANGED) pdb_set_dir_drive(account, new_string, PDB_CHANGED); } - if (delta->hdr_logon_script.buffer) { + if (r->logon_script.string) { old_string = pdb_get_logon_script(account); - new_string = unistr2_static(&delta->uni_logon_script); + new_string = r->logon_script.string; if (STRING_CHANGED) pdb_set_logon_script(account, new_string, PDB_CHANGED); } - if (delta->hdr_acct_desc.buffer) { + if (r->description.string) { old_string = pdb_get_acct_desc(account); - new_string = unistr2_static(&delta->uni_acct_desc); + new_string = r->description.string; if (STRING_CHANGED) pdb_set_acct_desc(account, new_string, PDB_CHANGED); } - if (delta->hdr_workstations.buffer) { + if (r->workstations.string) { old_string = pdb_get_workstations(account); - new_string = unistr2_static(&delta->uni_workstations); + new_string = r->workstations.string; if (STRING_CHANGED) pdb_set_workstations(account, new_string, PDB_CHANGED); } - if (delta->hdr_profile.buffer) { + if (r->profile_path.string) { old_string = pdb_get_profile_path(account); - new_string = unistr2_static(&delta->uni_profile); + new_string = r->profile_path.string; if (STRING_CHANGED) pdb_set_profile_path(account, new_string, PDB_CHANGED); } - if (delta->hdr_parameters.buffer) { + if (r->parameters.string) { DATA_BLOB mung; char *newstr; old_string = pdb_get_munged_dial(account); - mung.length = delta->hdr_parameters.uni_str_len; - mung.data = (uint8 *) delta->uni_parameters.buffer; + mung.length = r->parameters.length; + mung.data = (uint8 *) r->parameters.string; newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); @@ -374,57 +501,59 @@ static NTSTATUS sam_account_from_delta(struct samu *account, SAM_ACCOUNT_INFO *d } /* User and group sid */ - if (pdb_get_user_rid(account) != delta->user_rid) - pdb_set_user_sid_from_rid(account, delta->user_rid, PDB_CHANGED); - if (pdb_get_group_rid(account) != delta->group_rid) - pdb_set_group_sid_from_rid(account, delta->group_rid, PDB_CHANGED); + if (pdb_get_user_rid(account) != r->rid) + pdb_set_user_sid_from_rid(account, r->rid, PDB_CHANGED); + if (pdb_get_group_rid(account) != r->primary_gid) + pdb_set_group_sid_from_rid(account, r->primary_gid, PDB_CHANGED); /* Logon and password information */ - if (!nt_time_is_zero(&delta->logon_time)) { - unix_time = nt_time_to_unix(delta->logon_time); + if (!nt_time_is_zero(&r->last_logon)) { + unix_time = nt_time_to_unix(r->last_logon); stored_time = pdb_get_logon_time(account); if (stored_time != unix_time) pdb_set_logon_time(account, unix_time, PDB_CHANGED); } - if (!nt_time_is_zero(&delta->logoff_time)) { - unix_time = nt_time_to_unix(delta->logoff_time); + if (!nt_time_is_zero(&r->last_logoff)) { + unix_time = nt_time_to_unix(r->last_logoff); stored_time = pdb_get_logoff_time(account); if (stored_time != unix_time) pdb_set_logoff_time(account, unix_time,PDB_CHANGED); } /* Logon Divs */ - if (pdb_get_logon_divs(account) != delta->logon_divs) - pdb_set_logon_divs(account, delta->logon_divs, PDB_CHANGED); + if (pdb_get_logon_divs(account) != r->logon_hours.units_per_week) + pdb_set_logon_divs(account, r->logon_hours.units_per_week, PDB_CHANGED); +#if 0 + /* no idea what to do with this one - gd */ /* Max Logon Hours */ if (delta->unknown1 != pdb_get_unknown_6(account)) { pdb_set_unknown_6(account, delta->unknown1, PDB_CHANGED); } - +#endif /* Logon Hours Len */ - if (delta->buf_logon_hrs.buf_len != pdb_get_hours_len(account)) { - pdb_set_hours_len(account, delta->buf_logon_hrs.buf_len, PDB_CHANGED); + if (r->logon_hours.units_per_week/8 != pdb_get_hours_len(account)) { + pdb_set_hours_len(account, r->logon_hours.units_per_week/8, PDB_CHANGED); } /* Logon Hours */ - if (delta->buf_logon_hrs.buffer) { + if (r->logon_hours.bits) { char oldstr[44], newstr[44]; pdb_sethexhours(oldstr, pdb_get_hours(account)); - pdb_sethexhours(newstr, delta->buf_logon_hrs.buffer); + pdb_sethexhours(newstr, r->logon_hours.bits); if (!strequal(oldstr, newstr)) - pdb_set_hours(account, (const uint8 *)delta->buf_logon_hrs.buffer, PDB_CHANGED); + pdb_set_hours(account, r->logon_hours.bits, PDB_CHANGED); } - if (pdb_get_bad_password_count(account) != delta->bad_pwd_count) - pdb_set_bad_password_count(account, delta->bad_pwd_count, PDB_CHANGED); + if (pdb_get_bad_password_count(account) != r->bad_password_count) + pdb_set_bad_password_count(account, r->bad_password_count, PDB_CHANGED); - if (pdb_get_logon_count(account) != delta->logon_count) - pdb_set_logon_count(account, delta->logon_count, PDB_CHANGED); + if (pdb_get_logon_count(account) != r->logon_count) + pdb_set_logon_count(account, r->logon_count, PDB_CHANGED); - if (!nt_time_is_zero(&delta->pwd_last_set_time)) { - unix_time = nt_time_to_unix(delta->pwd_last_set_time); + if (!nt_time_is_zero(&r->last_password_change)) { + unix_time = nt_time_to_unix(r->last_password_change); stored_time = pdb_get_pass_last_set_time(account); if (stored_time != unix_time) pdb_set_pass_last_set_time(account, unix_time, PDB_CHANGED); @@ -433,42 +562,41 @@ static NTSTATUS sam_account_from_delta(struct samu *account, SAM_ACCOUNT_INFO *d pdb_set_pass_last_set_time(account, time(NULL), PDB_CHANGED); } -#if 0 -/* No kickoff time in the delta? */ - if (!nt_time_is_zero(&delta->kickoff_time)) { - unix_time = nt_time_to_unix(&delta->kickoff_time); + if (!nt_time_is_zero(&r->acct_expiry)) { + unix_time = nt_time_to_unix(r->acct_expiry); stored_time = pdb_get_kickoff_time(account); if (stored_time != unix_time) pdb_set_kickoff_time(account, unix_time, PDB_CHANGED); } -#endif - /* Decode hashes from password hash - Note that win2000 may send us all zeros for the hashes if it doesn't + /* Decode hashes from password hash + Note that win2000 may send us all zeros for the hashes if it doesn't think this channel is secure enough - don't set the passwords at all in that case */ - if (memcmp(delta->pass.buf_lm_pwd, zero_buf, 16) != 0) { - sam_pwd_hash(delta->user_rid, delta->pass.buf_lm_pwd, lm_passwd, 0); + if (memcmp(r->ntpassword.hash, zero_buf, 16) != 0) { + sam_pwd_hash(r->rid, r->ntpassword.hash, lm_passwd, 0); pdb_set_lanman_passwd(account, lm_passwd, PDB_CHANGED); } - if (memcmp(delta->pass.buf_nt_pwd, zero_buf, 16) != 0) { - sam_pwd_hash(delta->user_rid, delta->pass.buf_nt_pwd, nt_passwd, 0); + if (memcmp(r->lmpassword.hash, zero_buf, 16) != 0) { + sam_pwd_hash(r->rid, r->lmpassword.hash, nt_passwd, 0); pdb_set_nt_passwd(account, nt_passwd, PDB_CHANGED); } /* TODO: account expiry time */ - pdb_set_acct_ctrl(account, delta->acb_info, PDB_CHANGED); + pdb_set_acct_ctrl(account, r->acct_flags, PDB_CHANGED); pdb_set_domain(account, lp_workgroup(), PDB_CHANGED); return NT_STATUS_OK; } -static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) +static NTSTATUS fetch_account_info(uint32_t rid, + struct netr_DELTA_USER *r) { + NTSTATUS nt_ret = NT_STATUS_UNSUCCESSFUL; fstring account; char *add_script = NULL; @@ -480,7 +608,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) struct passwd *passwd; fstring sid_string; - fstrcpy(account, unistr2_static(&delta->uni_acct_name)); + fstrcpy(account, r->account_name.string); d_printf("Creating account: %s\n", account); if ( !(sam_account = samu_new( NULL )) ) { @@ -489,17 +617,17 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) if (!(passwd = Get_Pwnam_alloc(sam_account, account))) { /* Create appropriate user */ - if (delta->acb_info & ACB_NORMAL) { + if (r->acct_flags & ACB_NORMAL) { add_script = talloc_strdup(sam_account, lp_adduser_script()); - } else if ( (delta->acb_info & ACB_WSTRUST) || - (delta->acb_info & ACB_SVRTRUST) || - (delta->acb_info & ACB_DOMTRUST) ) { + } else if ( (r->acct_flags & ACB_WSTRUST) || + (r->acct_flags & ACB_SVRTRUST) || + (r->acct_flags & ACB_DOMTRUST) ) { add_script = talloc_strdup(sam_account, lp_addmachine_script()); } else { DEBUG(1, ("Unknown user type: %s\n", - pdb_encode_acct_ctrl(delta->acb_info, NEW_PW_FORMAT_SPACE_PADDED_LEN))); + pdb_encode_acct_ctrl(r->acct_flags, NEW_PW_FORMAT_SPACE_PADDED_LEN))); nt_ret = NT_STATUS_UNSUCCESSFUL; goto done; } @@ -534,30 +662,30 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) } sid_copy(&user_sid, get_global_sam_sid()); - sid_append_rid(&user_sid, delta->user_rid); + sid_append_rid(&user_sid, r->rid); DEBUG(3, ("Attempting to find SID %s for user %s in the passdb\n", sid_to_fstring(sid_string, &user_sid), account)); if (!pdb_getsampwsid(sam_account, &user_sid)) { - sam_account_from_delta(sam_account, delta); - DEBUG(3, ("Attempting to add user SID %s for user %s in the passdb\n", + sam_account_from_delta(sam_account, r); + DEBUG(3, ("Attempting to add user SID %s for user %s in the passdb\n", sid_to_fstring(sid_string, &user_sid), pdb_get_username(sam_account))); if (!NT_STATUS_IS_OK(pdb_add_sam_account(sam_account))) { DEBUG(1, ("SAM Account for %s failed to be added to the passdb!\n", account)); - return NT_STATUS_ACCESS_DENIED; + return NT_STATUS_ACCESS_DENIED; } } else { - sam_account_from_delta(sam_account, delta); - DEBUG(3, ("Attempting to update user SID %s for user %s in the passdb\n", + sam_account_from_delta(sam_account, r); + DEBUG(3, ("Attempting to update user SID %s for user %s in the passdb\n", sid_to_fstring(sid_string, &user_sid), pdb_get_username(sam_account))); if (!NT_STATUS_IS_OK(pdb_update_sam_account(sam_account))) { DEBUG(1, ("SAM Account for %s failed to be updated in the passdb!\n", account)); TALLOC_FREE(sam_account); - return NT_STATUS_ACCESS_DENIED; + return NT_STATUS_ACCESS_DENIED; } } @@ -573,7 +701,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) } else { if (map.gid != passwd->pw_gid) { if (!(grp = getgrgid(map.gid))) { - DEBUG(0, ("Could not find unix group %lu for user %s (group SID=%s)\n", + DEBUG(0, ("Could not find unix group %lu for user %s (group SID=%s)\n", (unsigned long)map.gid, pdb_get_username(sam_account), sid_string_tos(&group_sid))); } else { smb_set_primary_group(grp->gr_name, pdb_get_username(sam_account)); @@ -582,7 +710,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) } if ( !passwd ) { - DEBUG(1, ("No unix user for this account (%s), cannot adjust mappings\n", + DEBUG(1, ("No unix user for this account (%s), cannot adjust mappings\n", pdb_get_username(sam_account))); } @@ -591,7 +719,8 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) return nt_ret; } -static NTSTATUS fetch_group_info(uint32 rid, SAM_GROUP_INFO *delta) +static NTSTATUS fetch_group_info(uint32_t rid, + struct netr_DELTA_GROUP *r) { fstring name; fstring comment; @@ -601,8 +730,8 @@ static NTSTATUS fetch_group_info(uint32 rid, SAM_GROUP_INFO *delta) GROUP_MAP map; bool insert = True; - unistr2_to_ascii(name, &delta->uni_grp_name, sizeof(name)); - unistr2_to_ascii(comment, &delta->uni_grp_desc, sizeof(comment)); + fstrcpy(name, r->group_name.string); + fstrcpy(comment, r->description.string); /* add the group to the mapping table */ sid_copy(&group_sid, get_global_sam_sid()); @@ -620,14 +749,14 @@ static NTSTATUS fetch_group_info(uint32 rid, SAM_GROUP_INFO *delta) /* No group found from mapping, find it from its name. */ if ((grp = getgrnam(name)) == NULL) { - + /* No appropriate group found, create one */ - + d_printf("Creating unix group: '%s'\n", name); - + if (smb_create_group(name, &gid) != 0) return NT_STATUS_ACCESS_DENIED; - + if ((grp = getgrnam(name)) == NULL) return NT_STATUS_ACCESS_DENIED; } @@ -637,7 +766,7 @@ static NTSTATUS fetch_group_info(uint32 rid, SAM_GROUP_INFO *delta) map.sid = group_sid; map.sid_name_use = SID_NAME_DOM_GRP; fstrcpy(map.nt_name, name); - if (delta->hdr_grp_desc.buffer) { + if (r->description.string) { fstrcpy(map.comment, comment); } else { fstrcpy(map.comment, ""); @@ -651,7 +780,8 @@ static NTSTATUS fetch_group_info(uint32 rid, SAM_GROUP_INFO *delta) return NT_STATUS_OK; } -static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) +static NTSTATUS fetch_group_mem_info(uint32_t rid, + struct netr_DELTA_GROUP_MEMBER *r) { int i; TALLOC_CTX *t = NULL; @@ -661,7 +791,7 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) GROUP_MAP map; struct group *grp; - if (delta->num_members == 0) { + if (r->num_rids == 0) { return NT_STATUS_OK; } @@ -685,8 +815,8 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) return NT_STATUS_NO_MEMORY; } - if (delta->num_members) { - if ((nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members)) == NULL) { + if (r->num_rids) { + if ((nt_members = TALLOC_ZERO_ARRAY(t, char *, r->num_rids)) == NULL) { DEBUG(0, ("talloc failed\n")); talloc_free(t); return NT_STATUS_NO_MEMORY; @@ -695,7 +825,7 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) nt_members = NULL; } - for (i=0; inum_members; i++) { + for (i=0; i < r->num_rids; i++) { struct samu *member = NULL; DOM_SID member_sid; @@ -705,11 +835,11 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) } sid_copy(&member_sid, get_global_sam_sid()); - sid_append_rid(&member_sid, delta->rids[i]); + sid_append_rid(&member_sid, r->rids[i]); if (!pdb_getsampwsid(member, &member_sid)) { DEBUG(1, ("Found bogus group member: %d (member_sid=%s group=%s)\n", - delta->rids[i], sid_string_tos(&member_sid), grp->gr_name)); + r->rids[i], sid_string_tos(&member_sid), grp->gr_name)); TALLOC_FREE(member); continue; } @@ -719,7 +849,7 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) TALLOC_FREE(member); continue; } - + d_printf("%s,", pdb_get_username(member)); nt_members[i] = talloc_strdup(t, pdb_get_username(member)); TALLOC_FREE(member); @@ -731,7 +861,7 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) while (*unix_members) { bool is_nt_member = False; - for (i=0; inum_members; i++) { + for (i=0; i < r->num_rids; i++) { if (nt_members[i] == NULL) { /* This was a primary group */ continue; @@ -751,7 +881,7 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) unix_members += 1; } - for (i=0; inum_members; i++) { + for (i=0; i < r->num_rids; i++) { bool is_unix_member = False; if (nt_members[i] == NULL) { @@ -776,12 +906,13 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) smb_add_user_group(grp->gr_name, nt_members[i]); } } - + talloc_destroy(t); return NT_STATUS_OK; } -static NTSTATUS fetch_alias_info(uint32 rid, SAM_ALIAS_INFO *delta, +static NTSTATUS fetch_alias_info(uint32_t rid, + struct netr_DELTA_ALIAS *r, DOM_SID dom_sid) { fstring name; @@ -792,8 +923,8 @@ static NTSTATUS fetch_alias_info(uint32 rid, SAM_ALIAS_INFO *delta, GROUP_MAP map; bool insert = True; - unistr2_to_ascii(name, &delta->uni_als_name, sizeof(name)); - unistr2_to_ascii(comment, &delta->uni_als_desc, sizeof(comment)); + fstrcpy(name, r->alias_name.string); + fstrcpy(comment, r->description.string); /* Find out whether the group is already mapped */ sid_copy(&alias_sid, &dom_sid); @@ -838,24 +969,29 @@ static NTSTATUS fetch_alias_info(uint32 rid, SAM_ALIAS_INFO *delta, return NT_STATUS_OK; } -static NTSTATUS fetch_alias_mem(uint32 rid, SAM_ALIAS_MEM_INFO *delta, DOM_SID dom_sid) +static NTSTATUS fetch_alias_mem(uint32_t rid, + struct netr_DELTA_ALIAS_MEMBER *r, + DOM_SID dom_sid) { return NT_STATUS_OK; } -static NTSTATUS fetch_domain_info(uint32 rid, SAM_DOMAIN_INFO *delta) +static NTSTATUS fetch_domain_info(uint32_t rid, + struct netr_DELTA_DOMAIN *r) { time_t u_max_age, u_min_age, u_logout, u_lockoutreset, u_lockouttime; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; - char *domname; + const char *domname; - u_max_age = uint64s_nt_time_to_unix_abs(&delta->max_pwd_age); - u_min_age = uint64s_nt_time_to_unix_abs(&delta->min_pwd_age); - u_logout = uint64s_nt_time_to_unix_abs(&delta->force_logoff); + u_max_age = uint64s_nt_time_to_unix_abs((uint64 *)&r->max_password_age); + u_min_age = uint64s_nt_time_to_unix_abs((uint64 *)&r->min_password_age); + u_logout = uint64s_nt_time_to_unix_abs((uint64 *)&r->force_logoff_time); +#if 0 + /* FIXME: gd */ u_lockoutreset = uint64s_nt_time_to_unix_abs(&delta->account_lockout.reset_count); u_lockouttime = uint64s_nt_time_to_unix_abs(&delta->account_lockout.lockout_duration); - - domname = unistr2_to_ascii_talloc(talloc_tos(), &delta->uni_dom_name); +#endif + domname = r->domain_name.string; if (!domname) { return NT_STATUS_NO_MEMORY; } @@ -867,10 +1003,12 @@ static NTSTATUS fetch_domain_info(uint32 rid, SAM_DOMAIN_INFO *delta) } - if (!pdb_set_account_policy(AP_PASSWORD_HISTORY, delta->pwd_history_len)) + if (!pdb_set_account_policy(AP_PASSWORD_HISTORY, + r->password_history_length)) return nt_status; - if (!pdb_set_account_policy(AP_MIN_PASSWORD_LEN, delta->min_pwd_len)) + if (!pdb_set_account_policy(AP_MIN_PASSWORD_LEN, + r->min_password_length)) return nt_status; if (!pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (uint32)u_max_age)) @@ -881,9 +1019,11 @@ static NTSTATUS fetch_domain_info(uint32 rid, SAM_DOMAIN_INFO *delta) if (!pdb_set_account_policy(AP_TIME_TO_LOGOUT, (uint32)u_logout)) return nt_status; - +#if 0 +/* FIXME: gd */ if (!pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, delta->account_lockout.bad_attempt_lockout)) return nt_status; +#endif if (!pdb_set_account_policy(AP_RESET_COUNT_TIME, (uint32)u_lockoutreset/60)) return nt_status; @@ -894,87 +1034,109 @@ static NTSTATUS fetch_domain_info(uint32 rid, SAM_DOMAIN_INFO *delta) if (!pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (uint32)u_lockouttime)) return nt_status; - if (!pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, delta->logon_chgpass)) + if (!pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, + r->logon_to_chgpass)) return nt_status; return NT_STATUS_OK; } - -static void fetch_sam_entry(SAM_DELTA_HDR *hdr_delta, SAM_DELTA_CTR *delta, - DOM_SID dom_sid) +static void fetch_sam_entry(struct netr_DELTA_ENUM *r, DOM_SID dom_sid) { - switch(hdr_delta->type) { - case SAM_DELTA_ACCOUNT_INFO: - fetch_account_info(hdr_delta->target_rid, - &delta->account_info); + switch(r->delta_type) { + case NETR_DELTA_USER: + fetch_account_info(r->delta_id_union.rid, + r->delta_union.user); break; - case SAM_DELTA_GROUP_INFO: - fetch_group_info(hdr_delta->target_rid, - &delta->group_info); + case NETR_DELTA_GROUP: + fetch_group_info(r->delta_id_union.rid, + r->delta_union.group); break; - case SAM_DELTA_GROUP_MEM: - fetch_group_mem_info(hdr_delta->target_rid, - &delta->grp_mem_info); + case NETR_DELTA_GROUP_MEMBER: + fetch_group_mem_info(r->delta_id_union.rid, + r->delta_union.group_member); break; - case SAM_DELTA_ALIAS_INFO: - fetch_alias_info(hdr_delta->target_rid, - &delta->alias_info, dom_sid); + case NETR_DELTA_ALIAS: + fetch_alias_info(r->delta_id_union.rid, + r->delta_union.alias, + dom_sid); break; - case SAM_DELTA_ALIAS_MEM: - fetch_alias_mem(hdr_delta->target_rid, - &delta->als_mem_info, dom_sid); + case NETR_DELTA_ALIAS_MEMBER: + fetch_alias_mem(r->delta_id_union.rid, + r->delta_union.alias_member, + dom_sid); break; - case SAM_DELTA_DOMAIN_INFO: - fetch_domain_info(hdr_delta->target_rid, - &delta->domain_info); + case NETR_DELTA_DOMAIN: + fetch_domain_info(r->delta_id_union.rid, + r->delta_union.domain); break; /* The following types are recognised but not handled */ - case SAM_DELTA_RENAME_GROUP: - d_printf("SAM_DELTA_RENAME_GROUP not handled\n"); + case NETR_DELTA_RENAME_GROUP: + d_printf("NETR_DELTA_RENAME_GROUP not handled\n"); + break; + case NETR_DELTA_RENAME_USER: + d_printf("NETR_DELTA_RENAME_USER not handled\n"); + break; + case NETR_DELTA_RENAME_ALIAS: + d_printf("NETR_DELTA_RENAME_ALIAS not handled\n"); + break; + case NETR_DELTA_POLICY: + d_printf("NETR_DELTA_POLICY not handled\n"); break; - case SAM_DELTA_RENAME_USER: - d_printf("SAM_DELTA_RENAME_USER not handled\n"); + case NETR_DELTA_TRUSTED_DOMAIN: + d_printf("NETR_DELTA_TRUSTED_DOMAIN not handled\n"); break; - case SAM_DELTA_RENAME_ALIAS: - d_printf("SAM_DELTA_RENAME_ALIAS not handled\n"); + case NETR_DELTA_ACCOUNT: + d_printf("NETR_DELTA_ACCOUNT not handled\n"); break; - case SAM_DELTA_POLICY_INFO: - d_printf("SAM_DELTA_POLICY_INFO not handled\n"); + case NETR_DELTA_SECRET: + d_printf("NETR_DELTA_SECRET not handled\n"); break; - case SAM_DELTA_TRUST_DOMS: - d_printf("SAM_DELTA_TRUST_DOMS not handled\n"); + case NETR_DELTA_DELETE_GROUP: + d_printf("NETR_DELTA_DELETE_GROUP not handled\n"); break; - case SAM_DELTA_PRIVS_INFO: - d_printf("SAM_DELTA_PRIVS_INFO not handled\n"); + case NETR_DELTA_DELETE_USER: + d_printf("NETR_DELTA_DELETE_USER not handled\n"); break; - case SAM_DELTA_SECRET_INFO: - d_printf("SAM_DELTA_SECRET_INFO not handled\n"); + case NETR_DELTA_MODIFY_COUNT: + d_printf("NETR_DELTA_MODIFY_COUNT not handled\n"); break; - case SAM_DELTA_DELETE_GROUP: - d_printf("SAM_DELTA_DELETE_GROUP not handled\n"); + case NETR_DELTA_DELETE_ALIAS: + d_printf("NETR_DELTA_DELETE_ALIAS not handled\n"); break; - case SAM_DELTA_DELETE_USER: - d_printf("SAM_DELTA_DELETE_USER not handled\n"); + case NETR_DELTA_DELETE_TRUST: + d_printf("NETR_DELTA_DELETE_TRUST not handled\n"); break; - case SAM_DELTA_MODIFIED_COUNT: - d_printf("SAM_DELTA_MODIFIED_COUNT not handled\n"); + case NETR_DELTA_DELETE_ACCOUNT: + d_printf("NETR_DELTA_DELETE_ACCOUNT not handled\n"); + break; + case NETR_DELTA_DELETE_SECRET: + d_printf("NETR_DELTA_DELETE_SECRET not handled\n"); + break; + case NETR_DELTA_DELETE_GROUP2: + d_printf("NETR_DELTA_DELETE_GROUP2 not handled\n"); + break; + case NETR_DELTA_DELETE_USER2: + d_printf("NETR_DELTA_DELETE_USER2 not handled\n"); break; default: - d_printf("Unknown delta record type %d\n", hdr_delta->type); + d_printf("Unknown delta record type %d\n", r->delta_type); break; } } static NTSTATUS fetch_database(struct rpc_pipe_client *pipe_hnd, uint32 db_type, DOM_SID dom_sid) { - uint32 sync_context = 0; NTSTATUS result; int i; TALLOC_CTX *mem_ctx; - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; - uint32 num_deltas; + const char *logon_server = pipe_hnd->cli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = db_type; + uint16_t restart_state = 0; + uint32_t sync_context = 0; if (!(mem_ctx = talloc_init("fetch_database"))) return NT_STATUS_NO_MEMORY; @@ -995,20 +1157,36 @@ static NTSTATUS fetch_database(struct rpc_pipe_client *pipe_hnd, uint32 db_type, } do { - result = rpccli_netlogon_sam_sync(pipe_hnd, mem_ctx, - db_type, sync_context, - &num_deltas, - &hdr_deltas, &deltas); - - if (NT_STATUS_IS_OK(result) || - NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) { - for (i = 0; i < num_deltas; i++) { - fetch_sam_entry(&hdr_deltas[i], &deltas[i], dom_sid); - } - } else - return result; + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; + + netlogon_creds_client_step(pipe_hnd->dc, &credential); + + result = rpccli_netr_DatabaseSync2(pipe_hnd, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + restart_state, + &sync_context, + &delta_enum_array, + 0xffff); + + /* Check returned credentials. */ + if (!netlogon_creds_client_check(pipe_hnd->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } + + if (NT_STATUS_IS_ERR(result)) { + break; + } + + for (i = 0; i < delta_enum_array->num_deltas; i++) { + fetch_sam_entry(&delta_enum_array->delta_enum[i], dom_sid); + } - sync_context += 1; } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); talloc_destroy(mem_ctx); @@ -1016,7 +1194,7 @@ static NTSTATUS fetch_database(struct rpc_pipe_client *pipe_hnd, uint32 db_type, return result; } -static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const char +static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const char *builtin_sid, FILE *add_fd) { const char *user_suffix, *group_suffix, *machine_suffix, *idmap_suffix; @@ -1048,7 +1226,7 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch SAFE_FREE(suffix_attr); return NT_STATUS_NO_MEMORY; } - /* If it exists and is distinct from other containers, + /* If it exists and is distinct from other containers, Write the Users entity */ if (*user_suffix && strcmp(user_suffix, suffix)) { user_attr = sstring_sub(lp_ldap_user_suffix(), '=', ','); @@ -1067,7 +1245,7 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch SAFE_FREE(user_attr); return NT_STATUS_NO_MEMORY; } - /* If it exists and is distinct from other containers, + /* If it exists and is distinct from other containers, Write the Groups entity */ if (*group_suffix && strcmp(group_suffix, suffix)) { group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ','); @@ -1079,7 +1257,7 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch fflush(add_fd); } - /* If it exists and is distinct from other containers, + /* If it exists and is distinct from other containers, Write the Computers entity */ machine_suffix = lp_ldap_machine_suffix(); if (machine_suffix == NULL) { @@ -1103,7 +1281,7 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch fflush(add_fd); } - /* If it exists and is distinct from other containers, + /* If it exists and is distinct from other containers, Write the IdMap entity */ idmap_suffix = lp_ldap_idmap_suffix(); if (idmap_suffix == NULL) { @@ -1139,7 +1317,7 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch fprintf(add_fd, "\n"); fflush(add_fd); - /* Write the Domain Admins entity */ + /* Write the Domain Admins entity */ fprintf(add_fd, "# Domain Admins, %s, %s\n", group_attr, suffix); fprintf(add_fd, "dn: cn=Domain Admins,ou=%s,%s\n", group_attr, @@ -1156,7 +1334,7 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch fprintf(add_fd, "\n"); fflush(add_fd); - /* Write the Domain Users entity */ + /* Write the Domain Users entity */ fprintf(add_fd, "# Domain Users, %s, %s\n", group_attr, suffix); fprintf(add_fd, "dn: cn=Domain Users,ou=%s,%s\n", group_attr, @@ -1172,7 +1350,7 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch fprintf(add_fd, "\n"); fflush(add_fd); - /* Write the Domain Guests entity */ + /* Write the Domain Guests entity */ fprintf(add_fd, "# Domain Guests, %s, %s\n", group_attr, suffix); fprintf(add_fd, "dn: cn=Domain Guests,ou=%s,%s\n", group_attr, @@ -1273,7 +1451,7 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch return NT_STATUS_OK; } -static NTSTATUS map_populate_groups(GROUPMAP *groupmap, ACCOUNTMAP *accountmap, fstring sid, +static NTSTATUS map_populate_groups(GROUPMAP *groupmap, ACCOUNTMAP *accountmap, fstring sid, const char *suffix, const char *builtin_sid) { char *group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ','); @@ -1431,7 +1609,7 @@ static int fprintf_attr(FILE *add_fd, const char *attr_name, return res; } -static NTSTATUS fetch_group_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupmap, +static NTSTATUS fetch_group_info_to_ldif(struct netr_DELTA_GROUP *r, GROUPMAP *groupmap, FILE *add_fd, fstring sid, char *suffix) { fstring groupname; @@ -1439,9 +1617,7 @@ static NTSTATUS fetch_group_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupma char *group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ','); /* Get the group name */ - unistr2_to_ascii(groupname, - &delta->group_info.uni_grp_name, - sizeof(groupname)); + fstrcpy(groupname, r->group_name.string); /* Set up the group type (always 2 for group info) */ grouptype = 2; @@ -1463,7 +1639,7 @@ static NTSTATUS fetch_group_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupma } /* Map the group rid, gid, and dn */ - g_rid = delta->group_info.gid.g_rid; + g_rid = r->rid; groupmap->rid = g_rid; groupmap->gidNumber = ldif_gid; snprintf(groupmap->sambaSID, sizeof(groupmap->sambaSID), @@ -1491,7 +1667,7 @@ static NTSTATUS fetch_group_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupma return NT_STATUS_OK; } -static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, +static NTSTATUS fetch_account_info_to_ldif(struct netr_DELTA_USER *r, GROUPMAP *groupmap, ACCOUNTMAP *accountmap, FILE *add_fd, @@ -1511,21 +1687,18 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, int i; /* Get the username */ - unistr2_to_ascii(username, - &(delta->account_info.uni_acct_name), - sizeof(username)); + fstrcpy(username, r->account_name.string); /* Get the rid */ - rid = delta->account_info.user_rid; + rid = r->rid; /* Map the rid and username for group member info later */ accountmap->rid = rid; snprintf(accountmap->cn, sizeof(accountmap->cn), "%s", username); /* Get the home directory */ - if (delta->account_info.acb_info & ACB_NORMAL) { - unistr2_to_ascii(homedir, &(delta->account_info.uni_home_dir), - sizeof(homedir)); + if (r->acct_flags & ACB_NORMAL) { + fstrcpy(homedir, r->home_directory.string); if (!*homedir) { snprintf(homedir, sizeof(homedir), "/home/%s", username); } else { @@ -1538,60 +1711,48 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, } /* Get the logon script */ - unistr2_to_ascii(logonscript, &(delta->account_info.uni_logon_script), - sizeof(logonscript)); + fstrcpy(logonscript, r->logon_script.string); /* Get the home drive */ - unistr2_to_ascii(homedrive, &(delta->account_info.uni_dir_drive), - sizeof(homedrive)); + fstrcpy(homedrive, r->home_drive.string); /* Get the home path */ - unistr2_to_ascii(homepath, &(delta->account_info.uni_home_dir), - sizeof(homepath)); + fstrcpy(homepath, r->home_directory.string); /* Get the description */ - unistr2_to_ascii(description, &(delta->account_info.uni_acct_desc), - sizeof(description)); + fstrcpy(description, r->description.string); /* Get the display name */ - unistr2_to_ascii(fullname, &(delta->account_info.uni_full_name), - sizeof(fullname)); + fstrcpy(fullname, r->full_name.string); /* Get the profile path */ - unistr2_to_ascii(profilepath, &(delta->account_info.uni_profile), - sizeof(profilepath)); + fstrcpy(profilepath, r->profile_path.string); /* Get lm and nt password data */ - if (memcmp(delta->account_info.pass.buf_lm_pwd, zero_buf, 16) != 0) { - sam_pwd_hash(delta->account_info.user_rid, - delta->account_info.pass.buf_lm_pwd, - lm_passwd, 0); - pdb_sethexpwd(hex_lm_passwd, lm_passwd, - delta->account_info.acb_info); + if (memcmp(r->lmpassword.hash, zero_buf, 16) != 0) { + sam_pwd_hash(r->rid, r->lmpassword.hash, lm_passwd, 0); + pdb_sethexpwd(hex_lm_passwd, lm_passwd, r->acct_flags); } else { pdb_sethexpwd(hex_lm_passwd, NULL, 0); } - if (memcmp(delta->account_info.pass.buf_nt_pwd, zero_buf, 16) != 0) { - sam_pwd_hash(delta->account_info.user_rid, - delta->account_info.pass.buf_nt_pwd, - nt_passwd, 0); - pdb_sethexpwd(hex_nt_passwd, nt_passwd, - delta->account_info.acb_info); + if (memcmp(r->ntpassword.hash, zero_buf, 16) != 0) { + sam_pwd_hash(r->rid, r->ntpassword.hash, nt_passwd, 0); + pdb_sethexpwd(hex_nt_passwd, nt_passwd, r->acct_flags); } else { pdb_sethexpwd(hex_nt_passwd, NULL, 0); } - unix_time = nt_time_to_unix(delta->account_info.pwd_last_set_time); + unix_time = nt_time_to_unix(r->last_password_change); /* Increment the uid for the new user */ ldif_uid++; /* Set up group id and sambaSID for the user */ - group_rid = delta->account_info.group_rid; + group_rid = r->primary_gid; for (i=0; iaccount_info.acb_info, + flags = pdb_encode_acct_ctrl(r->acct_flags, NEW_PW_FORMAT_SPACE_PADDED_LEN); /* Add the user to the temporary add ldif file */ @@ -1626,8 +1787,8 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, fprintf_attr(add_fd, "sambaHomeDrive", "%s", homedrive); if (*logonscript) fprintf_attr(add_fd, "sambaLogonScript", "%s", logonscript); - fprintf(add_fd, "loginShell: %s\n", - ((delta->account_info.acb_info & ACB_NORMAL) ? + fprintf(add_fd, "loginShell: %s\n", + ((r->acct_flags & ACB_NORMAL) ? "/bin/bash" : "/bin/false")); fprintf(add_fd, "gecos: System User\n"); if (*description) @@ -1651,10 +1812,10 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, return NT_STATUS_OK; } -static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, +static NTSTATUS fetch_alias_info_to_ldif(struct netr_DELTA_ALIAS *r, GROUPMAP *groupmap, FILE *add_fd, fstring sid, - char *suffix, + char *suffix, unsigned db_type) { fstring aliasname, description; @@ -1662,12 +1823,10 @@ static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, char *group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ','); /* Get the alias name */ - unistr2_to_ascii(aliasname, &(delta->alias_info.uni_als_name), - sizeof(aliasname)); + fstrcpy(aliasname, r->alias_name.string); /* Get the alias description */ - unistr2_to_ascii(description, &(delta->alias_info.uni_als_desc), - sizeof(description)); + fstrcpy(description, r->description.string); /* Set up the group type */ switch (db_type) { @@ -1684,7 +1843,7 @@ static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, /* These groups are entered by populate_ldap_for_ldif - Note that populate creates a group called Relicators, + Note that populate creates a group called Relicators, but NT returns a group called Replicator */ if (strcmp(aliasname, "Domain Admins") == 0 || @@ -1703,7 +1862,7 @@ static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, } /* Map the group rid and gid */ - g_rid = delta->group_info.gid.g_rid; + g_rid = r->rid; groupmap->gidNumber = ldif_gid; snprintf(groupmap->sambaSID, sizeof(groupmap->sambaSID), "%s-%d", sid, g_rid); @@ -1730,8 +1889,8 @@ static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, return NT_STATUS_OK; } -static NTSTATUS fetch_groupmem_info_to_ldif(SAM_DELTA_CTR *delta, - SAM_DELTA_HDR *hdr_delta, +static NTSTATUS fetch_groupmem_info_to_ldif(struct netr_DELTA_GROUP_MEMBER *r, + uint32_t id_rid, GROUPMAP *groupmap, ACCOUNTMAP *accountmap, FILE *mod_fd, int alloced) @@ -1741,8 +1900,8 @@ static NTSTATUS fetch_groupmem_info_to_ldif(SAM_DELTA_CTR *delta, int i, j, k; /* Get the dn for the group */ - if (delta->grp_mem_info.num_members > 0) { - group_rid = hdr_delta->target_rid; + if (r->num_rids > 0) { + group_rid = id_rid; for (j=0; jgrp_mem_info.num_members; i++) { - rid = delta->grp_mem_info.rids[i]; + for (i=0; i < r->num_rids; i++) { + rid = r->rids[i]; for (k=0; kcli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = db_type; + uint16_t restart_state = 0; + uint32_t sync_context = 0; /* Set up array for mapping accounts to groups */ /* Array element is the group rid */ @@ -1802,7 +1965,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, /* Set up array for mapping account rid's to cn's */ /* Array element is the account rid */ - ACCOUNTMAP *accountmap = NULL; + ACCOUNTMAP *accountmap = NULL; if (!(mem_ctx = talloc_init("fetch_database"))) { return NT_STATUS_NO_MEMORY; @@ -1838,7 +2001,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, DEBUG(1, ("Could not open %s\n", mod_name)); ret = NT_STATUS_UNSUCCESSFUL; goto done; - } + } /* Get the sid */ sid_to_fstring(sid, &dom_sid); @@ -1894,23 +2057,41 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, d_fprintf(stderr, "Fetching PRIVS databases\n"); break; default: - d_fprintf(stderr, - "Fetching unknown database type %u\n", + d_fprintf(stderr, + "Fetching unknown database type %u\n", db_type ); break; } do { - result = rpccli_netlogon_sam_sync(pipe_hnd, mem_ctx, - db_type, sync_context, - &num_deltas, &hdr_deltas, - &deltas); - if (!NT_STATUS_IS_OK(result) && - !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) { - ret = NT_STATUS_OK; - goto done; /* is this correct? jmcd */ + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; + + netlogon_creds_client_step(pipe_hnd->dc, &credential); + + result = rpccli_netr_DatabaseSync2(pipe_hnd, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + restart_state, + &sync_context, + &delta_enum_array, + 0xffff); + + /* Check returned credentials. */ + if (!netlogon_creds_client_check(pipe_hnd->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; } + if (NT_STATUS_IS_ERR(result)) { + break; + } + + num_deltas = delta_enum_array->num_deltas; + /* Re-allocate memory for groupmap and accountmap arrays */ groupmap = SMB_REALLOC_ARRAY(groupmap, GROUPMAP, num_deltas+num_alloced); @@ -1923,7 +2104,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, } /* Initialize the new records */ - memset(&groupmap[num_alloced], 0, + memset(&groupmap[num_alloced], 0, sizeof(GROUPMAP)*num_deltas); memset(&accountmap[num_alloced], 0, sizeof(ACCOUNTMAP)*num_deltas); @@ -1933,73 +2114,60 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, /* Loop through the deltas */ for (k=0; kdelta_enum[k].delta_union; + union netr_DELTA_ID_UNION id = + delta_enum_array->delta_enum[k].delta_id_union; + + switch(delta_enum_array->delta_enum[k].delta_type) { + case NETR_DELTA_DOMAIN: /* Is this case needed? */ - unistr2_to_ascii( - domainname, - &deltas[k].domain_info.uni_dom_name, - sizeof(domainname)); + fstrcpy(domainname, + u.domain->domain_name.string); break; - case SAM_DELTA_GROUP_INFO: + case NETR_DELTA_GROUP: fetch_group_info_to_ldif( - &deltas[k], &groupmap[g_index], + u.group, + &groupmap[g_index], add_file, sid, suffix); g_index++; break; - case SAM_DELTA_ACCOUNT_INFO: + case NETR_DELTA_USER: fetch_account_info_to_ldif( - &deltas[k], groupmap, + u.user, groupmap, &accountmap[a_index], add_file, sid, suffix, num_alloced); a_index++; break; - case SAM_DELTA_ALIAS_INFO: + case NETR_DELTA_ALIAS: fetch_alias_info_to_ldif( - &deltas[k], &groupmap[g_index], + u.alias, &groupmap[g_index], add_file, sid, suffix, db_type); g_index++; break; - case SAM_DELTA_GROUP_MEM: + case NETR_DELTA_GROUP_MEMBER: fetch_groupmem_info_to_ldif( - &deltas[k], &hdr_deltas[k], - groupmap, accountmap, + u.group_member, id.rid, + groupmap, accountmap, mod_file, num_alloced); break; - case SAM_DELTA_ALIAS_MEM: - break; - case SAM_DELTA_POLICY_INFO: - break; - case SAM_DELTA_PRIVS_INFO: - break; - case SAM_DELTA_TRUST_DOMS: - /* Implemented but broken */ - break; - case SAM_DELTA_SECRET_INFO: - /* Implemented but broken */ - break; - case SAM_DELTA_RENAME_GROUP: - /* Not yet implemented */ - break; - case SAM_DELTA_RENAME_USER: - /* Not yet implemented */ - break; - case SAM_DELTA_RENAME_ALIAS: - /* Not yet implemented */ - break; - case SAM_DELTA_DELETE_GROUP: - /* Not yet implemented */ - break; - case SAM_DELTA_DELETE_USER: - /* Not yet implemented */ - break; - case SAM_DELTA_MODIFIED_COUNT: - break; + case NETR_DELTA_ALIAS_MEMBER: + case NETR_DELTA_POLICY: + case NETR_DELTA_ACCOUNT: + case NETR_DELTA_TRUSTED_DOMAIN: + case NETR_DELTA_SECRET: + case NETR_DELTA_RENAME_GROUP: + case NETR_DELTA_RENAME_USER: + case NETR_DELTA_RENAME_ALIAS: + case NETR_DELTA_DELETE_GROUP: + case NETR_DELTA_DELETE_USER: + case NETR_DELTA_MODIFY_COUNT: default: break; } /* end of switch */ @@ -2065,7 +2233,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, DEBUG(1,("unlink(%s) failed, error was (%s)\n", mod_name, strerror(errno))); } - + if (ldif_file && (ldif_file != stdout)) { fclose(ldif_file); } @@ -2079,15 +2247,15 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, return ret; } -/** +/** * Basic usage function for 'net rpc vampire' * @param argc Standard main() style argc * @param argc Standard main() style argv. Initial components are already * stripped **/ -int rpc_vampire_usage(int argc, const char **argv) -{ +int rpc_vampire_usage(int argc, const char **argv) +{ d_printf("net rpc vampire [ldif [] [options]\n" "\t to pull accounts from a remote PDC where we are a BDC\n" "\t\t no args puts accounts in local passdb from smb.conf\n" @@ -2100,13 +2268,13 @@ int rpc_vampire_usage(int argc, const char **argv) /* dump sam database via samsync rpc calls */ -NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid, - const char *domain_name, +NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, - const char **argv) + const char **argv) { NTSTATUS result; fstring my_dom_sid_str; @@ -2120,7 +2288,7 @@ NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid, "workgroup=%s\n\n in your smb.conf?\n", domain_name, get_global_sam_name(), - sid_to_fstring(my_dom_sid_str, + sid_to_fstring(my_dom_sid_str, get_global_sam_sid()), domain_name, sid_to_fstring(rem_dom_sid_str, domain_sid), -- cgit From 34df32446df1167cddea2dd9a3fb3240e817f731 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 14:24:31 +0100 Subject: Remove unused marshalling for NET_SAM_SYNC. Guenther (This used to be commit a94d93725a649c7a0ac1fcd61ea07579f65596da) --- source3/include/rpc_netlogon.h | 345 ----------- source3/rpc_client/cli_netlogon.c | 53 -- source3/rpc_parse/parse_net.c | 1165 ------------------------------------- 3 files changed, 1563 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index 93b50c9c00..4105b34e10 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -467,30 +467,6 @@ typedef struct net_r_sam_logoff_info { NTSTATUS status; /* return code */ } NET_R_SAM_LOGOFF; -/* NET_Q_SAM_SYNC */ -typedef struct net_q_sam_sync_info { - UNISTR2 uni_srv_name; /* \\PDC */ - UNISTR2 uni_cli_name; /* BDC */ - DOM_CRED cli_creds; - DOM_CRED ret_creds; - - uint32 database_id; - uint32 restart_state; - uint32 sync_context; - - uint32 max_size; /* preferred maximum length */ -} NET_Q_SAM_SYNC; - -/* SAM_DELTA_HDR */ -typedef struct sam_delta_hdr_info { - uint16 type; /* type of structure attached */ - uint16 type2; - uint32 target_rid; - - uint32 type3; - uint32 ptr_delta; -} SAM_DELTA_HDR; - /* LOCKOUT_STRING */ typedef struct account_lockout_string { uint32 array_size; @@ -510,327 +486,6 @@ typedef struct hdr_account_lockout_string { uint32 buffer; } HDR_LOCKOUT_STRING; -/* SAM_DOMAIN_INFO (0x1) */ -typedef struct sam_domain_info_info { - UNIHDR hdr_dom_name; - UNIHDR hdr_oem_info; - - uint64 force_logoff; - uint16 min_pwd_len; - uint16 pwd_history_len; - uint64 max_pwd_age; - uint64 min_pwd_age; - uint64 dom_mod_count; - NTTIME creation_time; - uint32 security_information; - - BUFHDR4 hdr_sec_desc; /* security descriptor */ - - HDR_LOCKOUT_STRING hdr_account_lockout; - - UNIHDR hdr_unknown2; - UNIHDR hdr_unknown3; - UNIHDR hdr_unknown4; - - UNISTR2 uni_dom_name; - UNISTR2 buf_oem_info; - - RPC_DATA_BLOB buf_sec_desc; - - LOCKOUT_STRING account_lockout; - - UNISTR2 buf_unknown2; - UNISTR2 buf_unknown3; - UNISTR2 buf_unknown4; - - uint32 logon_chgpass; - uint32 unknown6; - uint32 unknown7; - uint32 unknown8; -} SAM_DOMAIN_INFO; - -/* SAM_GROUP_INFO (0x2) */ -typedef struct sam_group_info_info { - UNIHDR hdr_grp_name; - DOM_GID gid; - UNIHDR hdr_grp_desc; - BUFHDR2 hdr_sec_desc; /* security descriptor */ - uint8 reserved[48]; - - UNISTR2 uni_grp_name; - UNISTR2 uni_grp_desc; - RPC_DATA_BLOB buf_sec_desc; -} SAM_GROUP_INFO; - -/* SAM_PWD */ -typedef struct sam_passwd_info { - /* this structure probably contains password history */ - /* this is probably a count of lm/nt pairs */ - uint32 unk_0; /* 0x0000 0002 */ - - UNIHDR hdr_lm_pwd; - uint8 buf_lm_pwd[16]; - - UNIHDR hdr_nt_pwd; - uint8 buf_nt_pwd[16]; - - UNIHDR hdr_empty_lm; - UNIHDR hdr_empty_nt; -} SAM_PWD; - -/* SAM_ACCOUNT_INFO (0x5) */ -typedef struct sam_account_info_info { - UNIHDR hdr_acct_name; - UNIHDR hdr_full_name; - - uint32 user_rid; - uint32 group_rid; - - UNIHDR hdr_home_dir; - UNIHDR hdr_dir_drive; - UNIHDR hdr_logon_script; - UNIHDR hdr_acct_desc; - UNIHDR hdr_workstations; - - NTTIME logon_time; - NTTIME logoff_time; - - uint32 logon_divs; /* 0xA8 */ - uint32 ptr_logon_hrs; - - uint16 bad_pwd_count; - uint16 logon_count; - NTTIME pwd_last_set_time; - NTTIME acct_expiry_time; - - uint32 acb_info; - uint8 nt_pwd[16]; - uint8 lm_pwd[16]; - uint8 nt_pwd_present; - uint8 lm_pwd_present; - uint8 pwd_expired; - - UNIHDR hdr_comment; - UNIHDR hdr_parameters; - uint16 country; - uint16 codepage; - - BUFHDR2 hdr_sec_desc; /* security descriptor */ - - UNIHDR hdr_profile; - UNIHDR hdr_reserved[3]; /* space for more strings */ - uint32 dw_reserved[4]; /* space for more data - first two seem to - be an NTTIME */ - - UNISTR2 uni_acct_name; - UNISTR2 uni_full_name; - UNISTR2 uni_home_dir; - UNISTR2 uni_dir_drive; - UNISTR2 uni_logon_script; - UNISTR2 uni_acct_desc; - UNISTR2 uni_workstations; - - uint32 unknown1; /* 0x4EC */ - uint32 unknown2; /* 0 */ - - RPC_DATA_BLOB buf_logon_hrs; - UNISTR2 uni_comment; - UNISTR2 uni_parameters; - SAM_PWD pass; - RPC_DATA_BLOB buf_sec_desc; - UNISTR2 uni_profile; -} SAM_ACCOUNT_INFO; - -/* SAM_GROUP_MEM_INFO (0x8) */ -typedef struct sam_group_mem_info_info { - uint32 ptr_rids; - uint32 ptr_attribs; - uint32 num_members; - uint8 unknown[16]; - - uint32 num_members2; - uint32 *rids; - - uint32 num_members3; - uint32 *attribs; - -} SAM_GROUP_MEM_INFO; - -/* SAM_ALIAS_INFO (0x9) */ -typedef struct sam_alias_info_info { - UNIHDR hdr_als_name; - uint32 als_rid; - BUFHDR2 hdr_sec_desc; /* security descriptor */ - UNIHDR hdr_als_desc; - uint8 reserved[40]; - - UNISTR2 uni_als_name; - RPC_DATA_BLOB buf_sec_desc; - UNISTR2 uni_als_desc; -} SAM_ALIAS_INFO; - -/* SAM_ALIAS_MEM_INFO (0xC) */ -typedef struct sam_alias_mem_info_info { - uint32 num_members; - uint32 ptr_members; - uint8 unknown[16]; - - uint32 num_sids; - uint32 *ptr_sids; - DOM_SID2 *sids; -} SAM_ALIAS_MEM_INFO; - - -/* SAM_DELTA_POLICY (0x0D) */ -typedef struct { - uint32 max_log_size; /* 0x5000 */ - uint64 audit_retention_period; /* 0 */ - uint32 auditing_mode; /* 0 */ - uint32 num_events; - uint32 ptr_events; - UNIHDR hdr_dom_name; - uint32 sid_ptr; - - uint32 paged_pool_limit; /* 0x02000000 */ - uint32 non_paged_pool_limit; /* 0x00100000 */ - uint32 min_workset_size; /* 0x00010000 */ - uint32 max_workset_size; /* 0x0f000000 */ - uint32 page_file_limit; /* 0 */ - uint64 time_limit; /* 0 */ - NTTIME modify_time; /* 0x3c*/ - NTTIME create_time; /* a7080110 */ - BUFHDR2 hdr_sec_desc; - - uint32 num_event_audit_options; - uint32 event_audit_option; - - UNISTR2 domain_name; - DOM_SID2 domain_sid; - - RPC_DATA_BLOB buf_sec_desc; -} SAM_DELTA_POLICY; - -/* SAM_DELTA_TRUST_DOMS */ -typedef struct { - uint32 buf_size; - SEC_DESC *sec_desc; - DOM_SID2 sid; - UNIHDR hdr_domain; - - uint32 unknown0; - uint32 unknown1; - uint32 unknown2; - - uint32 buf_size2; - uint32 ptr; - - uint32 unknown3; - UNISTR2 domain; -} SAM_DELTA_TRUSTDOMS; - -/* SAM_DELTA_PRIVS (0x10) */ -typedef struct { - DOM_SID2 sid; - - uint32 priv_count; - uint32 priv_control; - - uint32 priv_attr_ptr; - uint32 priv_name_ptr; - - uint32 paged_pool_limit; /* 0x02000000 */ - uint32 non_paged_pool_limit; /* 0x00100000 */ - uint32 min_workset_size; /* 0x00010000 */ - uint32 max_workset_size; /* 0x0f000000 */ - uint32 page_file_limit; /* 0 */ - uint64 time_limit; /* 0 */ - uint32 system_flags; /* 1 */ - BUFHDR2 hdr_sec_desc; - - uint32 buf_size2; - - uint32 attribute_count; - uint32 *attributes; - - uint32 privlist_count; - UNIHDR *hdr_privslist; - UNISTR2 *uni_privslist; - - RPC_DATA_BLOB buf_sec_desc; -} SAM_DELTA_PRIVS; - -/* SAM_DELTA_SECRET */ -typedef struct { - uint32 buf_size; - SEC_DESC *sec_desc; - UNISTR2 secret; - - uint32 count1; - uint32 count2; - uint32 ptr; - NTTIME time1; - uint32 count3; - uint32 count4; - uint32 ptr2; - NTTIME time2; - uint32 unknow1; - - uint32 buf_size2; - uint32 ptr3; - uint32 unknow2; /* 0x0 12 times */ - - uint32 chal_len; - uint32 reserved1; /* 0 */ - uint32 chal_len2; - uint8 chal[16]; - - uint32 key_len; - uint32 reserved2; /* 0 */ - uint32 key_len2; - uint8 key[8]; - - uint32 buf_size3; - SEC_DESC *sec_desc2; -} SAM_DELTA_SECRET; - -/* SAM_DELTA_MOD_COUNT (0x16) */ -typedef struct { - uint32 seqnum; - uint32 dom_mod_count_ptr; - uint64 dom_mod_count; /* domain mod count at last sync */ -} SAM_DELTA_MOD_COUNT; - -typedef union sam_delta_ctr_info { - SAM_DOMAIN_INFO domain_info ; - SAM_GROUP_INFO group_info ; - SAM_ACCOUNT_INFO account_info; - SAM_GROUP_MEM_INFO grp_mem_info; - SAM_ALIAS_INFO alias_info ; - SAM_ALIAS_MEM_INFO als_mem_info; - SAM_DELTA_POLICY policy_info; - SAM_DELTA_PRIVS privs_info; - SAM_DELTA_MOD_COUNT mod_count; - SAM_DELTA_TRUSTDOMS trustdoms_info; - SAM_DELTA_SECRET secret_info; -} SAM_DELTA_CTR; - -/* NET_R_SAM_SYNC */ -typedef struct net_r_sam_sync_info { - DOM_CRED srv_creds; - - uint32 sync_context; - - uint32 ptr_deltas; - uint32 num_deltas; - uint32 ptr_deltas2; - uint32 num_deltas2; - - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; - - NTSTATUS status; -} NET_R_SAM_SYNC; - #define DSGETDC_VALID_FLAGS ( \ DS_FORCE_REDISCOVERY | \ DS_DIRECTORY_SERVICE_REQUIRED | \ diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index 0da482c9ef..f15340ffec 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -347,59 +347,6 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli, return NT_STATUS_OK; } -/* Sam synchronisation */ - -NTSTATUS rpccli_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - uint32 database_id, uint32 next_rid, uint32 *num_deltas, - SAM_DELTA_HDR **hdr_deltas, - SAM_DELTA_CTR **deltas) -{ - prs_struct qbuf, rbuf; - NET_Q_SAM_SYNC q; - NET_R_SAM_SYNC r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_CRED clnt_creds; - DOM_CRED ret_creds; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - ZERO_STRUCT(ret_creds); - - /* Initialise input parameters */ - - creds_client_step(cli->dc, &clnt_creds); - - init_net_q_sam_sync(&q, cli->dc->remote_machine, global_myname(), - &clnt_creds, &ret_creds, database_id, next_rid); - - /* Marshall data and send request */ - - CLI_DO_RPC_COPY_SESS_KEY(cli, mem_ctx, PI_NETLOGON, NET_SAM_SYNC, - q, r, - qbuf, rbuf, - net_io_q_sam_sync, - net_io_r_sam_sync, - NT_STATUS_UNSUCCESSFUL); - - /* Return results */ - - result = r.status; - *num_deltas = r.num_deltas2; - *hdr_deltas = r.hdr_deltas; - *deltas = r.deltas; - - if (!NT_STATUS_IS_ERR(result)) { - /* Check returned credentials. */ - if (!creds_client_check(cli->dc, &r.srv_creds.challenge)) { - DEBUG(0,("cli_netlogon_sam_sync: credentials chain check failed\n")); - return NT_STATUS_ACCESS_DENIED; - } - } - - return result; -} - /* Logon domain user */ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index b4ed470cce..8677924d6a 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -1406,1168 +1406,3 @@ bool net_io_r_sam_logoff(const char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps return True; } - -/******************************************************************* -makes a NET_Q_SAM_SYNC structure. -********************************************************************/ -bool init_net_q_sam_sync(NET_Q_SAM_SYNC * q_s, const char *srv_name, - const char *cli_name, DOM_CRED *cli_creds, - DOM_CRED *ret_creds, uint32 database_id, - uint32 next_rid) -{ - DEBUG(5, ("init_q_sam_sync\n")); - - init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE); - init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE); - - if (cli_creds) - memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds)); - - if (cli_creds) - memcpy(&q_s->ret_creds, ret_creds, sizeof(q_s->ret_creds)); - else - memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds)); - - q_s->database_id = database_id; - q_s->restart_state = 0; - q_s->sync_context = next_rid; - q_s->max_size = 0xffff; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -bool net_io_q_sam_sync(const char *desc, NET_Q_SAM_SYNC * q_s, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "net_io_q_sam_sync"); - depth++; - - if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth)) - return False; - if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth)) - return False; - - if (!smb_io_cred("", &q_s->cli_creds, ps, depth)) - return False; - if (!smb_io_cred("", &q_s->ret_creds, ps, depth)) - return False; - - if (!prs_uint32("database_id ", ps, depth, &q_s->database_id)) - return False; - if (!prs_uint32("restart_state", ps, depth, &q_s->restart_state)) - return False; - if (!prs_uint32("sync_context ", ps, depth, &q_s->sync_context)) - return False; - - if (!prs_uint32("max_size", ps, depth, &q_s->max_size)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_delta_hdr(const char *desc, SAM_DELTA_HDR * delta, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_delta_hdr"); - depth++; - - if (!prs_uint16("type", ps, depth, &delta->type)) - return False; - if (!prs_uint16("type2", ps, depth, &delta->type2)) - return False; - if (!prs_uint32("target_rid", ps, depth, &delta->target_rid)) - return False; - - if (!prs_uint32("type3", ps, depth, &delta->type3)) - return False; - - /* Not sure why we need this but it seems to be necessary to get - sam deltas working. */ - - if (delta->type != 0x16) { - if (!prs_uint32("ptr_delta", ps, depth, &delta->ptr_delta)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_delta_mod_count(const char *desc, SAM_DELTA_MOD_COUNT *info, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_delta_stamp"); - depth++; - - if (!prs_uint32("seqnum", ps, depth, &info->seqnum)) - return False; - if (!prs_uint32("dom_mod_count_ptr", ps, depth, - &info->dom_mod_count_ptr)) - return False; - - if (info->dom_mod_count_ptr) { - if (!prs_uint64("dom_mod_count", ps, depth, - &info->dom_mod_count)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_domain_info(const char *desc, SAM_DOMAIN_INFO * info, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_domain_info"); - depth++; - - if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_oem_info", &info->hdr_oem_info, ps, depth)) - return False; - - if (!prs_uint64("force_logoff", ps, depth, &info->force_logoff)) - return False; - if (!prs_uint16("min_pwd_len", ps, depth, &info->min_pwd_len)) - return False; - if (!prs_uint16("pwd_history_len", ps, depth, &info->pwd_history_len)) - return False; - if (!prs_uint64("max_pwd_age", ps, depth, &info->max_pwd_age)) - return False; - if (!prs_uint64("min_pwd_age", ps, depth, &info->min_pwd_age)) - return False; - if (!prs_uint64("dom_mod_count", ps, depth, &info->dom_mod_count)) - return False; - if (!smb_io_time("creation_time", &info->creation_time, ps, depth)) - return False; - if (!prs_uint32("security_information", ps, depth, &info->security_information)) - return False; - if (!smb_io_bufhdr4("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - if (!smb_io_lockout_string_hdr("hdr_account_lockout_string", &info->hdr_account_lockout, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_unknown2", &info->hdr_unknown2, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_unknown3", &info->hdr_unknown3, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_unknown4", &info->hdr_unknown4, ps, depth)) - return False; - if (!prs_uint32("logon_chgpass", ps, depth, &info->logon_chgpass)) - return False; - if (!prs_uint32("unknown6", ps, depth, &info->unknown6)) - return False; - if (!prs_uint32("unknown7", ps, depth, &info->unknown7)) - return False; - if (!prs_uint32("unknown8", ps, depth, &info->unknown8)) - return False; - - if (!smb_io_unistr2("uni_dom_name", &info->uni_dom_name, - info->hdr_dom_name.buffer, ps, depth)) - return False; - if (!smb_io_unistr2("buf_oem_info", &info->buf_oem_info, - info->hdr_oem_info.buffer, ps, depth)) - return False; - - if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) - return False; - - if (!smb_io_account_lockout_str("account_lockout", &info->account_lockout, - info->hdr_account_lockout.buffer, ps, depth)) - return False; - - if (!smb_io_unistr2("buf_unknown2", &info->buf_unknown2, - info->hdr_unknown2.buffer, ps, depth)) - return False; - if (!smb_io_unistr2("buf_unknown3", &info->buf_unknown3, - info->hdr_unknown3.buffer, ps, depth)) - return False; - if (!smb_io_unistr2("buf_unknown4", &info->buf_unknown4, - info->hdr_unknown4.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_group_info(const char *desc, SAM_GROUP_INFO * info, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_group_info"); - depth++; - - if (!smb_io_unihdr("hdr_grp_name", &info->hdr_grp_name, ps, depth)) - return False; - if (!smb_io_gid("gid", &info->gid, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_grp_desc", &info->hdr_grp_desc, ps, depth)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - - if (ps->data_offset + 48 > ps->buffer_size) - return False; - ps->data_offset += 48; - - if (!smb_io_unistr2("uni_grp_name", &info->uni_grp_name, - info->hdr_grp_name.buffer, ps, depth)) - return False; - if (!smb_io_unistr2("uni_grp_desc", &info->uni_grp_desc, - info->hdr_grp_desc.buffer, ps, depth)) - return False; - if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_passwd_info(const char *desc, SAM_PWD * pwd, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_passwd_info"); - depth++; - - if (!prs_uint32("unk_0 ", ps, depth, &pwd->unk_0)) - return False; - - if (!smb_io_unihdr("hdr_lm_pwd", &pwd->hdr_lm_pwd, ps, depth)) - return False; - if (!prs_uint8s(False, "buf_lm_pwd", ps, depth, pwd->buf_lm_pwd, 16)) - return False; - - if (!smb_io_unihdr("hdr_nt_pwd", &pwd->hdr_nt_pwd, ps, depth)) - return False; - if (!prs_uint8s(False, "buf_nt_pwd", ps, depth, pwd->buf_nt_pwd, 16)) - return False; - - if (!smb_io_unihdr("", &pwd->hdr_empty_lm, ps, depth)) - return False; - if (!smb_io_unihdr("", &pwd->hdr_empty_nt, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_account_info(const char *desc, SAM_ACCOUNT_INFO *info, - prs_struct *ps, int depth) -{ - BUFHDR2 hdr_priv_data; - uint32 i; - - prs_debug(ps, depth, desc, "net_io_sam_account_info"); - depth++; - - if (!smb_io_unihdr("hdr_acct_name", &info->hdr_acct_name, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_full_name", &info->hdr_full_name, ps, depth)) - return False; - - if (!prs_uint32("user_rid ", ps, depth, &info->user_rid)) - return False; - if (!prs_uint32("group_rid", ps, depth, &info->group_rid)) - return False; - - if (!smb_io_unihdr("hdr_home_dir ", &info->hdr_home_dir, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_dir_drive", &info->hdr_dir_drive, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_logon_script", &info->hdr_logon_script, ps, - depth)) - return False; - - if (!smb_io_unihdr("hdr_acct_desc", &info->hdr_acct_desc, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_workstations", &info->hdr_workstations, ps, - depth)) - return False; - - if (!smb_io_time("logon_time", &info->logon_time, ps, depth)) - return False; - if (!smb_io_time("logoff_time", &info->logoff_time, ps, depth)) - return False; - - if (!prs_uint32("logon_divs ", ps, depth, &info->logon_divs)) - return False; - if (!prs_uint32("ptr_logon_hrs", ps, depth, &info->ptr_logon_hrs)) - return False; - - if (!prs_uint16("bad_pwd_count", ps, depth, &info->bad_pwd_count)) - return False; - if (!prs_uint16("logon_count", ps, depth, &info->logon_count)) - return False; - if (!smb_io_time("pwd_last_set_time", &info->pwd_last_set_time, ps, - depth)) - return False; - if (!smb_io_time("acct_expiry_time", &info->acct_expiry_time, ps, - depth)) - return False; - - if (!prs_uint32("acb_info", ps, depth, &info->acb_info)) - return False; - if (!prs_uint8s(False, "nt_pwd", ps, depth, info->nt_pwd, 16)) - return False; - if (!prs_uint8s(False, "lm_pwd", ps, depth, info->lm_pwd, 16)) - return False; - if (!prs_uint8("lm_pwd_present", ps, depth, &info->lm_pwd_present)) - return False; - if (!prs_uint8("nt_pwd_present", ps, depth, &info->nt_pwd_present)) - return False; - if (!prs_uint8("pwd_expired", ps, depth, &info->pwd_expired)) - return False; - - if (!smb_io_unihdr("hdr_comment", &info->hdr_comment, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_parameters", &info->hdr_parameters, ps, - depth)) - return False; - if (!prs_uint16("country", ps, depth, &info->country)) - return False; - if (!prs_uint16("codepage", ps, depth, &info->codepage)) - return False; - - if (!smb_io_bufhdr2("hdr_priv_data", &hdr_priv_data, ps, depth)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_profile", &info->hdr_profile, ps, depth)) - return False; - - for (i = 0; i < 3; i++) - { - if (!smb_io_unihdr("hdr_reserved", &info->hdr_reserved[i], - ps, depth)) - return False; - } - - for (i = 0; i < 4; i++) - { - if (!prs_uint32("dw_reserved", ps, depth, - &info->dw_reserved[i])) - return False; - } - - if (!smb_io_unistr2("uni_acct_name", &info->uni_acct_name, - info->hdr_acct_name.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_full_name", &info->uni_full_name, - info->hdr_full_name.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_home_dir ", &info->uni_home_dir, - info->hdr_home_dir.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_dir_drive", &info->uni_dir_drive, - info->hdr_dir_drive.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_logon_script", &info->uni_logon_script, - info->hdr_logon_script.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_acct_desc", &info->uni_acct_desc, - info->hdr_acct_desc.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_workstations", &info->uni_workstations, - info->hdr_workstations.buffer, ps, depth)) - return False; - prs_align(ps); - - if (!prs_uint32("unknown1", ps, depth, &info->unknown1)) - return False; - if (!prs_uint32("unknown2", ps, depth, &info->unknown2)) - return False; - - if (!smb_io_rpc_blob("buf_logon_hrs", &info->buf_logon_hrs, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_comment", &info->uni_comment, - info->hdr_comment.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_parameters", &info->uni_parameters, - info->hdr_parameters.buffer, ps, depth)) - return False; - prs_align(ps); - if (hdr_priv_data.buffer != 0) - { - int old_offset = 0; - uint32 len = 0x44; - if (!prs_uint32("pwd_len", ps, depth, &len)) - return False; - old_offset = ps->data_offset; - if (len > 0) - { - if (ps->io) - { - /* reading */ - if (!prs_hash1(ps, ps->data_offset, len)) - return False; - } - if (!net_io_sam_passwd_info("pass", &info->pass, - ps, depth)) - return False; - - if (!ps->io) - { - /* writing */ - if (!prs_hash1(ps, old_offset, len)) - return False; - } - } - if (old_offset + len > ps->buffer_size) - return False; - ps->data_offset = old_offset + len; - } - if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_profile", &info->uni_profile, - info->hdr_profile.buffer, ps, depth)) - return False; - - prs_align(ps); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_group_mem_info(const char *desc, SAM_GROUP_MEM_INFO * info, - prs_struct *ps, int depth) -{ - uint32 i; - fstring tmp; - - prs_debug(ps, depth, desc, "net_io_sam_group_mem_info"); - depth++; - - prs_align(ps); - if (!prs_uint32("ptr_rids ", ps, depth, &info->ptr_rids)) - return False; - if (!prs_uint32("ptr_attribs", ps, depth, &info->ptr_attribs)) - return False; - if (!prs_uint32("num_members", ps, depth, &info->num_members)) - return False; - - if (ps->data_offset + 16 > ps->buffer_size) - return False; - ps->data_offset += 16; - - if (info->ptr_rids != 0) - { - if (!prs_uint32("num_members2", ps, depth, - &info->num_members2)) - return False; - - if (info->num_members2 != info->num_members) - { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps)) { - if (info->num_members2) { - info->rids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members2); - - if (info->rids == NULL) { - DEBUG(0, ("out of memory allocating %d rids\n", - info->num_members2)); - return False; - } - } else { - info->rids = NULL; - } - } - - for (i = 0; i < info->num_members2; i++) - { - slprintf(tmp, sizeof(tmp) - 1, "rids[%02d]", i); - if (!prs_uint32(tmp, ps, depth, &info->rids[i])) - return False; - } - } - - if (info->ptr_attribs != 0) - { - if (!prs_uint32("num_members3", ps, depth, - &info->num_members3)) - return False; - if (info->num_members3 != info->num_members) - { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps)) { - if (info->num_members3) { - info->attribs = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members3); - - if (info->attribs == NULL) { - DEBUG(0, ("out of memory allocating %d attribs\n", - info->num_members3)); - return False; - } - } else { - info->attribs = NULL; - } - } - - for (i = 0; i < info->num_members3; i++) - { - slprintf(tmp, sizeof(tmp) - 1, "attribs[%02d]", i); - if (!prs_uint32(tmp, ps, depth, &info->attribs[i])) - return False; - } - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_alias_info(const char *desc, SAM_ALIAS_INFO * info, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_alias_info"); - depth++; - - if (!smb_io_unihdr("hdr_als_name", &info->hdr_als_name, ps, depth)) - return False; - if (!prs_uint32("als_rid", ps, depth, &info->als_rid)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_als_desc", &info->hdr_als_desc, ps, depth)) - return False; - - if (ps->data_offset + 40 > ps->buffer_size) - return False; - ps->data_offset += 40; - - if (!smb_io_unistr2("uni_als_name", &info->uni_als_name, - info->hdr_als_name.buffer, ps, depth)) - return False; - if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) - return False; - - if (!smb_io_unistr2("uni_als_desc", &info->uni_als_desc, - info->hdr_als_desc.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_alias_mem_info(const char *desc, SAM_ALIAS_MEM_INFO * info, - prs_struct *ps, int depth) -{ - uint32 i; - fstring tmp; - - prs_debug(ps, depth, desc, "net_io_sam_alias_mem_info"); - depth++; - - prs_align(ps); - if (!prs_uint32("num_members", ps, depth, &info->num_members)) - return False; - if (!prs_uint32("ptr_members", ps, depth, &info->ptr_members)) - return False; - - if (ps->data_offset + 16 > ps->buffer_size) - return False; - ps->data_offset += 16; - - if (info->ptr_members != 0) - { - if (!prs_uint32("num_sids", ps, depth, &info->num_sids)) - return False; - if (info->num_sids != info->num_members) - { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps)) { - if (info->num_sids) { - info->ptr_sids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_sids); - - if (info->ptr_sids == NULL) { - DEBUG(0, ("out of memory allocating %d ptr_sids\n", - info->num_sids)); - return False; - } - } else { - info->ptr_sids = NULL; - } - } - - for (i = 0; i < info->num_sids; i++) - { - slprintf(tmp, sizeof(tmp) - 1, "ptr_sids[%02d]", i); - if (!prs_uint32(tmp, ps, depth, &info->ptr_sids[i])) - return False; - } - - if (UNMARSHALLING(ps)) { - if (info->num_sids) { - info->sids = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, info->num_sids); - - if (info->sids == NULL) { - DEBUG(0, ("error allocating %d sids\n", - info->num_sids)); - return False; - } - } else { - info->sids = NULL; - } - } - - for (i = 0; i < info->num_sids; i++) - { - if (info->ptr_sids[i] != 0) - { - slprintf(tmp, sizeof(tmp) - 1, "sids[%02d]", - i); - if (!smb_io_dom_sid2(tmp, &info->sids[i], - ps, depth)) - return False; - } - } - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_policy_info(const char *desc, SAM_DELTA_POLICY *info, - prs_struct *ps, int depth) -{ - unsigned int i; - prs_debug(ps, depth, desc, "net_io_sam_policy_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!prs_uint32("max_log_size", ps, depth, &info->max_log_size)) - return False; - if (!prs_uint64("audit_retention_period", ps, depth, - &info->audit_retention_period)) - return False; - if (!prs_uint32("auditing_mode", ps, depth, &info->auditing_mode)) - return False; - if (!prs_uint32("num_events", ps, depth, &info->num_events)) - return False; - if (!prs_uint32("ptr_events", ps, depth, &info->ptr_events)) - return False; - - if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth)) - return False; - - if (!prs_uint32("sid_ptr", ps, depth, &info->sid_ptr)) - return False; - - if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit)) - return False; - if (!prs_uint32("non_paged_pool_limit", ps, depth, - &info->non_paged_pool_limit)) - return False; - if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size)) - return False; - if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size)) - return False; - if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit)) - return False; - if (!prs_uint64("time_limit", ps, depth, &info->time_limit)) - return False; - if (!smb_io_time("modify_time", &info->modify_time, ps, depth)) - return False; - if (!smb_io_time("create_time", &info->create_time, ps, depth)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - - for (i=0; i<4; i++) { - UNIHDR dummy; - if (!smb_io_unihdr("dummy", &dummy, ps, depth)) - return False; - } - - for (i=0; i<4; i++) { - uint32 reserved; - if (!prs_uint32("reserved", ps, depth, &reserved)) - return False; - } - - if (!prs_uint32("num_event_audit_options", ps, depth, - &info->num_event_audit_options)) - return False; - - for (i=0; inum_event_audit_options; i++) - if (!prs_uint32("event_audit_option", ps, depth, - &info->event_audit_option)) - return False; - - if (!smb_io_unistr2("domain_name", &info->domain_name, True, ps, depth)) - return False; - - if(!smb_io_dom_sid2("domain_sid", &info->domain_sid, ps, depth)) - return False; - - if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) - - return False; - - return True; -} - -#if 0 - -/* This function is pretty broken - see bug #334 */ - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_trustdoms_info(const char *desc, SAM_DELTA_TRUSTDOMS *info, - prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "net_io_sam_trustdoms_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buf_size", ps, depth, &info->buf_size)) - return False; - - if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &info->sid, ps, depth)) - return False; - - if(!smb_io_unihdr("hdr_domain", &info->hdr_domain, ps, depth)) - return False; - - if(!prs_uint32("unknown0", ps, depth, &info->unknown0)) - return False; - if(!prs_uint32("unknown1", ps, depth, &info->unknown1)) - return False; - if(!prs_uint32("unknown2", ps, depth, &info->unknown2)) - return False; - - if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2)) - return False; - if(!prs_uint32("ptr", ps, depth, &info->ptr)) - return False; - - for (i=0; i<12; i++) - if(!prs_uint32("unknown3", ps, depth, &info->unknown3)) - return False; - - if (!smb_io_unistr2("domain", &info->domain, True, ps, depth)) - return False; - - return True; -} - -#endif - -#if 0 - -/* This function doesn't work - see bug #334 */ - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_secret_info(const char *desc, SAM_DELTA_SECRET *info, - prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "net_io_sam_secret_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buf_size", ps, depth, &info->buf_size)) - return False; - - if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth)) - return False; - - if (!smb_io_unistr2("secret", &info->secret, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("count1", ps, depth, &info->count1)) - return False; - if(!prs_uint32("count2", ps, depth, &info->count2)) - return False; - if(!prs_uint32("ptr", ps, depth, &info->ptr)) - return False; - - - if(!smb_io_time("time1", &info->time1, ps, depth)) /* logon time */ - return False; - if(!prs_uint32("count3", ps, depth, &info->count3)) - return False; - if(!prs_uint32("count4", ps, depth, &info->count4)) - return False; - if(!prs_uint32("ptr2", ps, depth, &info->ptr2)) - return False; - if(!smb_io_time("time2", &info->time2, ps, depth)) /* logon time */ - return False; - if(!prs_uint32("unknow1", ps, depth, &info->unknow1)) - return False; - - - if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2)) - return False; - if(!prs_uint32("ptr3", ps, depth, &info->ptr3)) - return False; - for(i=0; i<12; i++) - if(!prs_uint32("unknow2", ps, depth, &info->unknow2)) - return False; - - if(!prs_uint32("chal_len", ps, depth, &info->chal_len)) - return False; - if(!prs_uint32("reserved1", ps, depth, &info->reserved1)) - return False; - if(!prs_uint32("chal_len2", ps, depth, &info->chal_len2)) - return False; - - if(!prs_uint8s (False, "chal", ps, depth, info->chal, info->chal_len2)) - return False; - - if(!prs_uint32("key_len", ps, depth, &info->key_len)) - return False; - if(!prs_uint32("reserved2", ps, depth, &info->reserved2)) - return False; - if(!prs_uint32("key_len2", ps, depth, &info->key_len2)) - return False; - - if(!prs_uint8s (False, "key", ps, depth, info->key, info->key_len2)) - return False; - - - if(!prs_uint32("buf_size3", ps, depth, &info->buf_size3)) - return False; - - if(!sec_io_desc("sec_desc2", &info->sec_desc2, ps, depth)) - return False; - - - return True; -} - -#endif - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_privs_info(const char *desc, SAM_DELTA_PRIVS *info, - prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "net_io_sam_privs_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_dom_sid2("sid", &info->sid, ps, depth)) - return False; - - if(!prs_uint32("priv_count", ps, depth, &info->priv_count)) - return False; - if(!prs_uint32("priv_control", ps, depth, &info->priv_control)) - return False; - - if(!prs_uint32("priv_attr_ptr", ps, depth, &info->priv_attr_ptr)) - return False; - if(!prs_uint32("priv_name_ptr", ps, depth, &info->priv_name_ptr)) - return False; - - if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit)) - return False; - if (!prs_uint32("non_paged_pool_limit", ps, depth, - &info->non_paged_pool_limit)) - return False; - if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size)) - return False; - if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size)) - return False; - if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit)) - return False; - if (!prs_uint64("time_limit", ps, depth, &info->time_limit)) - return False; - if (!prs_uint32("system_flags", ps, depth, &info->system_flags)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - - for (i=0; i<4; i++) { - UNIHDR dummy; - if (!smb_io_unihdr("dummy", &dummy, ps, depth)) - return False; - } - - for (i=0; i<4; i++) { - uint32 reserved; - if (!prs_uint32("reserved", ps, depth, &reserved)) - return False; - } - - if(!prs_uint32("attribute_count", ps, depth, &info->attribute_count)) - return False; - - if (UNMARSHALLING(ps)) { - if (info->attribute_count) { - info->attributes = TALLOC_ARRAY(ps->mem_ctx, uint32, info->attribute_count); - if (!info->attributes) { - return False; - } - } else { - info->attributes = NULL; - } - } - - for (i=0; iattribute_count; i++) - if(!prs_uint32("attributes", ps, depth, &info->attributes[i])) - return False; - - if(!prs_uint32("privlist_count", ps, depth, &info->privlist_count)) - return False; - - if (UNMARSHALLING(ps)) { - if (info->privlist_count) { - info->hdr_privslist = TALLOC_ARRAY(ps->mem_ctx, UNIHDR, info->privlist_count); - info->uni_privslist = TALLOC_ARRAY(ps->mem_ctx, UNISTR2, info->privlist_count); - if (!info->hdr_privslist) { - return False; - } - if (!info->uni_privslist) { - return False; - } - } else { - info->hdr_privslist = NULL; - info->uni_privslist = NULL; - } - } - - for (i=0; iprivlist_count; i++) - if(!smb_io_unihdr("hdr_privslist", &info->hdr_privslist[i], ps, depth)) - return False; - - for (i=0; iprivlist_count; i++) - if (!smb_io_unistr2("uni_privslist", &info->uni_privslist[i], True, ps, depth)) - return False; - - if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static bool net_io_sam_delta_ctr(const char *desc, - SAM_DELTA_CTR * delta, uint16 type, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_delta_ctr"); - depth++; - - switch (type) { - /* Seen in sam deltas */ - case SAM_DELTA_MODIFIED_COUNT: - if (!net_io_sam_delta_mod_count("", &delta->mod_count, ps, depth)) - return False; - break; - - case SAM_DELTA_DOMAIN_INFO: - if (!net_io_sam_domain_info("", &delta->domain_info, ps, depth)) - return False; - break; - - case SAM_DELTA_GROUP_INFO: - if (!net_io_sam_group_info("", &delta->group_info, ps, depth)) - return False; - break; - - case SAM_DELTA_ACCOUNT_INFO: - if (!net_io_sam_account_info("", &delta->account_info, ps, depth)) - return False; - break; - - case SAM_DELTA_GROUP_MEM: - if (!net_io_sam_group_mem_info("", &delta->grp_mem_info, ps, depth)) - return False; - break; - - case SAM_DELTA_ALIAS_INFO: - if (!net_io_sam_alias_info("", &delta->alias_info, ps, depth)) - return False; - break; - - case SAM_DELTA_POLICY_INFO: - if (!net_io_sam_policy_info("", &delta->policy_info, ps, depth)) - return False; - break; - - case SAM_DELTA_ALIAS_MEM: - if (!net_io_sam_alias_mem_info("", &delta->als_mem_info, ps, depth)) - return False; - break; - - case SAM_DELTA_PRIVS_INFO: - if (!net_io_sam_privs_info("", &delta->privs_info, ps, depth)) - return False; - break; - - /* These guys are implemented but broken */ - - case SAM_DELTA_TRUST_DOMS: - case SAM_DELTA_SECRET_INFO: - break; - - /* These guys are not implemented yet */ - - case SAM_DELTA_RENAME_GROUP: - case SAM_DELTA_RENAME_USER: - case SAM_DELTA_RENAME_ALIAS: - case SAM_DELTA_DELETE_GROUP: - case SAM_DELTA_DELETE_USER: - default: - DEBUG(0, ("Replication error: Unknown delta type 0x%x\n", type)); - break; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -bool net_io_r_sam_sync(const char *desc, - NET_R_SAM_SYNC * r_s, prs_struct *ps, int depth) -{ - uint32 i; - - prs_debug(ps, depth, desc, "net_io_r_sam_sync"); - depth++; - - if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth)) - return False; - if (!prs_uint32("sync_context", ps, depth, &r_s->sync_context)) - return False; - - if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas)) - return False; - if (r_s->ptr_deltas != 0) - { - if (!prs_uint32("num_deltas ", ps, depth, &r_s->num_deltas)) - return False; - if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->ptr_deltas2)) - return False; - if (r_s->ptr_deltas2 != 0) - { - if (!prs_uint32("num_deltas2", ps, depth, - &r_s->num_deltas2)) - return False; - - if (r_s->num_deltas2 != r_s->num_deltas) - { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps)) { - if (r_s->num_deltas2) { - r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas2); - if (r_s->hdr_deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d delta headers\n", - r_s->num_deltas2)); - return False; - } - } else { - r_s->hdr_deltas = NULL; - } - } - - for (i = 0; i < r_s->num_deltas2; i++) - { - if (!net_io_sam_delta_hdr("", - &r_s->hdr_deltas[i], - ps, depth)) - return False; - } - - if (UNMARSHALLING(ps)) { - if (r_s->num_deltas2) { - r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas2); - if (r_s->deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d deltas\n", - r_s->num_deltas2)); - return False; - } - } else { - r_s->deltas = NULL; - } - } - - for (i = 0; i < r_s->num_deltas2; i++) - { - if (!net_io_sam_delta_ctr( - "", &r_s->deltas[i], - r_s->hdr_deltas[i].type3, - ps, depth)) { - DEBUG(0, ("hmm, failed on i=%d\n", i)); - return False; - } - } - } - } - - prs_align(ps); - if (!prs_ntstatus("status", ps, depth, &(r_s->status))) - return False; - - return True; -} -- cgit From 6fe7ed0b12d244086f59c0cad2bb4f26879c95e0 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 15:59:55 +0100 Subject: Add libtdb dependency to libsmbclient, libsmbsharemodes and libnetapi. Michael (This used to be commit 94d9d5023eee1bdfd8a06581683829cf265f2f0a) --- source3/Makefile.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 7e627d6e9e..2d249a6f61 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1498,9 +1498,9 @@ bin/libaddns.a: $(BINARY_PREREQS) $(LIBADDNS_OBJ) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBADDNS_OBJ) -$(LIBNETAPI_SHARED_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBWBCLIENT_SHARED@ +$(LIBNETAPI_SHARED_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBNETAPI_OBJ) @LIBWBCLIENT_SHARED@ $(LIBS) \ + @$(SHLD_DSO) $(LIBNETAPI_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @@ -1508,9 +1508,9 @@ $(LIBNETAPI_STATIC_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ1) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBNETAPI_OBJ1) -bin/libsmbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) @LIBWBCLIENT_SHARED@ +bin/libsmbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) @LIBWBCLIENT_SHARED@ $(LIBS) \ + @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @@ -1518,9 +1518,9 @@ bin/libsmbclient.a: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ0) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBSMBCLIENT_OBJ0) -bin/libsmbsharemodes.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) +bin/libsmbsharemodes.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) @LIBTDB_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LIBS) \ + @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LIBS) @LIBTDB_LIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) -- cgit From 9af84dd382aad55fcdfa803238d8edd57636f2aa Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 13:57:31 +0100 Subject: Rename registry_init_regdb() to registry_init_smbconf(). That's what it actually is. Michael (This used to be commit 9d3c27f55726dbdce41fcf71c8bc1a7829340268) --- source3/libnet/libnet_conf.c | 2 +- source3/param/loadparm.c | 2 +- source3/registry/reg_init_smbconf.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 4d998acad8..c3872b68de 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -62,7 +62,7 @@ static WERROR libnet_conf_reg_initialize(struct libnet_conf_ctx *ctx) { WERROR werr = WERR_OK; - if (!registry_init_regdb()) { + if (!registry_init_smbconf()) { werr = WERR_REG_IO_FAILURE; goto done; } diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 3737224275..29de336df5 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -3561,7 +3561,7 @@ static bool process_registry_globals(bool (*pfunc)(const char *, const char *)) smb_panic("Failed to create talloc context!"); } - if (!registry_init_regdb()) { + if (!registry_init_smbconf()) { DEBUG(1, ("Error initializing the registry.\n")); goto done; } diff --git a/source3/registry/reg_init_smbconf.c b/source3/registry/reg_init_smbconf.c index 6452b0b15b..b7e6add112 100644 --- a/source3/registry/reg_init_smbconf.c +++ b/source3/registry/reg_init_smbconf.c @@ -67,13 +67,13 @@ done: * for use in places where not the whole registry is needed, * e.g. utils/net_conf.c and loadparm.c */ -bool registry_init_regdb(void) +bool registry_init_smbconf(void) { bool ret = false; int saved_errno = 0; static REGISTRY_HOOK smbconf_reg_hook = {KEY_SMBCONF, &smbconf_reg_ops}; - DEBUG(10, ("registry_init_regdb called\n")); + DEBUG(10, ("registry_init_smbconf called\n")); if (!regdb_init()) { saved_errno = errno; -- cgit From 8fffca2e9505e08a6e9b89d88dcb43dc6fa69eb6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 14:23:31 +0100 Subject: Adapt a comment to current circumstances. Michael (This used to be commit 84ec89ab9f7837e8a9830a0236fddc2d00d1c0d6) --- source3/registry/reg_api.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index 9c4009368d..1358fcbde6 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -726,9 +726,7 @@ WERROR reg_deleteallvalues(struct registry_key *key) } /* - * Utility function to open a complete registry path including the hive - * prefix. This should become the replacement function for - * regkey_open_internal. + * Utility function to open a complete registry path including the hive prefix. */ WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path, -- cgit From c720a0e228bd157b8c743f8b98cc63817650d364 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 15:14:20 +0100 Subject: Move implementation of _winreg_SaveKey() from srv_winreg_nt.c to reg_api.c This gives a new function reg_savekey() and hides a piece of the backend code from srv_winreg_nt.c. One step towards using reg_api throughout samba code. Michael (This used to be commit bf6340d00dd631fdc909c20632250977a3a112c4) --- source3/registry/reg_api.c | 168 +++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_winreg_nt.c | 171 +------------------------------------ 2 files changed, 168 insertions(+), 171 deletions(-) (limited to 'source3') diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index 1358fcbde6..fd3e08cacd 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -44,7 +44,7 @@ * 0x11 winreg_QueryValue reg_queryvalue * 0x12 winreg_ReplaceKey * 0x13 winreg_RestoreKey - * 0x14 winreg_SaveKey + * 0x14 winreg_SaveKey reg_savekey * 0x15 winreg_SetKeySecurity reg_setkeysecurity * 0x16 winreg_SetValue reg_setvalue * 0x17 winreg_UnLoadKey @@ -63,6 +63,7 @@ */ #include "includes.h" +#include "regfio.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_REGISTRY @@ -696,6 +697,171 @@ WERROR reg_getversion(uint32_t *version) return WERR_OK; } +/******************************************************************** +********************************************************************/ + +static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, + REGF_NK_REC *parent, SEC_DESC *sec_desc ) +{ + REGF_NK_REC *key; + REGVAL_CTR *values; + REGSUBKEY_CTR *subkeys; + int i, num_subkeys; + char *key_tmp = NULL; + char *keyname, *parentpath; + char *subkeypath = NULL; + char *subkeyname; + REGISTRY_KEY registry_key; + WERROR result = WERR_OK; + + if (!regfile) + return WERR_GENERAL_FAILURE; + + if (!keypath) + return WERR_OBJECT_PATH_INVALID; + + /* split up the registry key path */ + + key_tmp = talloc_strdup(regfile->mem_ctx, keypath); + if (!key_tmp) { + return WERR_NOMEM; + } + if (!reg_split_key( key_tmp, &parentpath, &keyname ) ) + return WERR_OBJECT_PATH_INVALID; + + if ( !keyname ) + keyname = parentpath; + + /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ + + ZERO_STRUCT( registry_key ); + + if ( (registry_key.name = talloc_strdup(regfile->mem_ctx, keypath)) == NULL ) + return WERR_NOMEM; + + if ( (registry_key.hook = reghook_cache_find( registry_key.name )) == NULL ) + return WERR_BADFILE; + + /* lookup the values and subkeys */ + + if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + return WERR_NOMEM; + + if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) + return WERR_NOMEM; + + fetch_reg_keys( ®istry_key, subkeys ); + fetch_reg_values( ®istry_key, values ); + + /* write out this key */ + + if ( !(key = regfio_write_key( regfile, keyname, values, subkeys, sec_desc, parent )) ) { + result = WERR_CAN_NOT_COMPLETE; + goto done; + } + + /* write each one of the subkeys out */ + + num_subkeys = regsubkey_ctr_numkeys( subkeys ); + for ( i=0; imem_ctx, + "%s\\%s", keypath, subkeyname); + if (!subkeypath) { + result = WERR_NOMEM; + goto done; + } + result = reg_write_tree( regfile, subkeypath, key, sec_desc ); + if ( !W_ERROR_IS_OK(result) ) + goto done; + } + + DEBUG(6,("reg_write_tree: wrote key [%s]\n", keypath )); + +done: + TALLOC_FREE( subkeys ); + TALLOC_FREE( registry_key.name ); + + return result; +} + +static const struct generic_mapping reg_generic_map = + { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; + +static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) +{ + DOM_SID adm_sid, owner_sid; + SEC_ACE ace[2]; /* at most 2 entries */ + SEC_ACCESS mask; + SEC_ACL *psa = NULL; + size_t sd_size; + + /* set the owner to BUILTIN\Administrator */ + + sid_copy(&owner_sid, &global_sid_Builtin); + sid_append_rid(&owner_sid, DOMAIN_USER_RID_ADMIN ); + + + /* basic access for Everyone */ + + init_sec_access(&mask, reg_generic_map.generic_execute | reg_generic_map.generic_read ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* add Full Access 'BUILTIN\Administrators' */ + + init_sec_access(&mask, reg_generic_map.generic_all); + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* create the security descriptor */ + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 2, ace)) == NULL) + return WERR_NOMEM; + + if ((*psd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, + SEC_DESC_SELF_RELATIVE, &owner_sid, NULL, + NULL, psa, &sd_size)) == NULL) + return WERR_NOMEM; + + return WERR_OK; +} + +static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) +{ + REGF_FILE *regfile; + WERROR result; + SEC_DESC *sd = NULL; + + /* open the registry file....fail if the file already exists */ + + if ( !(regfile = regfio_open( fname, (O_RDWR|O_CREAT|O_EXCL), (S_IREAD|S_IWRITE) )) ) { + DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", + fname, strerror(errno) )); + return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); + } + + if ( !W_ERROR_IS_OK(result = make_default_reg_sd( regfile->mem_ctx, &sd )) ) { + regfio_close( regfile ); + return result; + } + + /* write the registry tree to the file */ + + result = reg_write_tree( regfile, krecord->name, NULL, sd ); + + /* cleanup */ + + regfio_close( regfile ); + + return result; +} + +WERROR reg_savekey(struct registry_key *key, const char *fname) +{ + return backup_registry_key(key->key, fname); +} + /********************************************************************** * Higher level utility functions **********************************************************************/ diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 92c178042f..c6447b4556 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -26,9 +26,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -static const struct generic_mapping reg_generic_map = - { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; - /****************************************************************** free() function for struct registry_key *****************************************************************/ @@ -810,172 +807,6 @@ WERROR _winreg_RestoreKey(pipes_struct *p, struct winreg_RestoreKey *r) return restore_registry_key( regkey->key, fname ); } -/******************************************************************** -********************************************************************/ - -static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, - REGF_NK_REC *parent, SEC_DESC *sec_desc ) -{ - REGF_NK_REC *key; - REGVAL_CTR *values; - REGSUBKEY_CTR *subkeys; - int i, num_subkeys; - char *key_tmp = NULL; - char *keyname, *parentpath; - char *subkeypath = NULL; - char *subkeyname; - REGISTRY_KEY registry_key; - WERROR result = WERR_OK; - - if (!regfile) - return WERR_GENERAL_FAILURE; - - if (!keypath) - return WERR_OBJECT_PATH_INVALID; - - /* split up the registry key path */ - - key_tmp = talloc_strdup(regfile->mem_ctx, keypath); - if (!key_tmp) { - return WERR_NOMEM; - } - if (!reg_split_key( key_tmp, &parentpath, &keyname ) ) - return WERR_OBJECT_PATH_INVALID; - - if ( !keyname ) - keyname = parentpath; - - /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ - - ZERO_STRUCT( registry_key ); - - if ( (registry_key.name = talloc_strdup(regfile->mem_ctx, keypath)) == NULL ) - return WERR_NOMEM; - - if ( (registry_key.hook = reghook_cache_find( registry_key.name )) == NULL ) - return WERR_BADFILE; - - /* lookup the values and subkeys */ - - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) - return WERR_NOMEM; - - if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) - return WERR_NOMEM; - - fetch_reg_keys( ®istry_key, subkeys ); - fetch_reg_values( ®istry_key, values ); - - /* write out this key */ - - if ( !(key = regfio_write_key( regfile, keyname, values, subkeys, sec_desc, parent )) ) { - result = WERR_CAN_NOT_COMPLETE; - goto done; - } - - /* write each one of the subkeys out */ - - num_subkeys = regsubkey_ctr_numkeys( subkeys ); - for ( i=0; imem_ctx, - "%s\\%s", keypath, subkeyname); - if (!subkeypath) { - result = WERR_NOMEM; - goto done; - } - result = reg_write_tree( regfile, subkeypath, key, sec_desc ); - if ( !W_ERROR_IS_OK(result) ) - goto done; - } - - DEBUG(6,("reg_write_tree: wrote key [%s]\n", keypath )); - -done: - TALLOC_FREE( subkeys ); - TALLOC_FREE( registry_key.name ); - - return result; -} - -/******************************************************************* - ********************************************************************/ - -static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) -{ - DOM_SID adm_sid, owner_sid; - SEC_ACE ace[2]; /* at most 2 entries */ - SEC_ACCESS mask; - SEC_ACL *psa = NULL; - size_t sd_size; - - /* set the owner to BUILTIN\Administrator */ - - sid_copy(&owner_sid, &global_sid_Builtin); - sid_append_rid(&owner_sid, DOMAIN_USER_RID_ADMIN ); - - - /* basic access for Everyone */ - - init_sec_access(&mask, reg_generic_map.generic_execute | reg_generic_map.generic_read ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* add Full Access 'BUILTIN\Administrators' */ - - init_sec_access(&mask, reg_generic_map.generic_all); - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* create the security descriptor */ - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 2, ace)) == NULL) - return WERR_NOMEM; - - if ((*psd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, - SEC_DESC_SELF_RELATIVE, &owner_sid, NULL, - NULL, psa, &sd_size)) == NULL) - return WERR_NOMEM; - - return WERR_OK; -} - -/******************************************************************* - ********************************************************************/ - -static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) -{ - REGF_FILE *regfile; - WERROR result; - SEC_DESC *sd = NULL; - - /* open the registry file....fail if the file already exists */ - - if ( !(regfile = regfio_open( fname, (O_RDWR|O_CREAT|O_EXCL), (S_IREAD|S_IWRITE) )) ) { - DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", - fname, strerror(errno) )); - return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); - } - - if ( !W_ERROR_IS_OK(result = make_default_reg_sd( regfile->mem_ctx, &sd )) ) { - regfio_close( regfile ); - return result; - } - - /* write the registry tree to the file */ - - result = reg_write_tree( regfile, krecord->name, NULL, sd ); - - /* cleanup */ - - regfio_close( regfile ); - - return result; -} - -/******************************************************************* - ********************************************************************/ - WERROR _winreg_SaveKey(pipes_struct *p, struct winreg_SaveKey *r) { struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); @@ -1002,7 +833,7 @@ WERROR _winreg_SaveKey(pipes_struct *p, struct winreg_SaveKey *r) DEBUG(2,("_winreg_SaveKey: Saving [%s] to %s in share %s\n", regkey->key->name, fname, lp_servicename(snum) )); - return backup_registry_key( regkey->key, fname ); + return reg_savekey(regkey, fname); } /******************************************************************* -- cgit From 355faf2e3d0aa83401c63e70a5aff9c9f5466195 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 15:31:31 +0100 Subject: Move the implementation of _winreg_RestoreKey to reg_api.c This removes the internals of reg_api from srv_winreg_nt.c entirely, only reg_api is used there, now. This enlarges the dependencies of reg_api somewhat now since it adds regfio. But this can be separated out later. The current goal is to achieve a complete use of reg_api. Michael (This used to be commit 2222acbac955cd6d5bd48d1ce5cf4b4c7c067093) --- source3/Makefile.in | 11 ++-- source3/registry/reg_api.c | 126 ++++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_winreg_nt.c | 122 +---------------------------------- 3 files changed, 132 insertions(+), 127 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 2d249a6f61..c3840d788d 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -459,7 +459,8 @@ REGISTRY_OBJ = registry/reg_init_full.o registry/reg_cachehook.o \ registry/reg_dispatcher.o \ $(REGISTRY_BACKENDS) \ $(UTIL_REG_API_OBJ) \ - $(REG_INIT_SMBCONF_OBJ) + $(REG_INIT_SMBCONF_OBJ) \ + $(REGFIO_OBJ) # objects to be used when not all of the registry code should be # loaded but only the portion needed by reg_api, typically for @@ -474,7 +475,8 @@ REG_API_OBJ = registry/reg_api.o \ \ lib/util_nttoken.o \ $(UTIL_REG_API_OBJ) \ - $(REG_INIT_SMBCONF_OBJ) + $(REG_INIT_SMBCONF_OBJ) \ + $(REGFIO_OBJ) RPC_LSA_OBJ = rpc_server/srv_lsa.o rpc_server/srv_lsa_nt.o librpc/gen_ndr/srv_lsa.o @@ -489,8 +491,7 @@ RPC_SAMR_OBJ = rpc_server/srv_samr_nt.o \ RPC_INITSHUTDOWN_OBJ = librpc/gen_ndr/srv_initshutdown.o rpc_server/srv_initshutdown_nt.o RPC_REG_OBJ = rpc_server/srv_winreg_nt.o \ - librpc/gen_ndr/srv_winreg.o \ - $(REGFIO_OBJ) + librpc/gen_ndr/srv_winreg.o RPC_DSSETUP_OBJ = rpc_server/srv_dssetup_nt.o librpc/gen_ndr/srv_dssetup.o @@ -810,7 +811,7 @@ NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \ $(LIBADS_OBJ) $(LIBADS_SERVER_OBJ) $(POPT_LIB_OBJ) \ $(SMBLDAP_OBJ) $(DCUTIL_OBJ) $(SERVER_MUTEX_OBJ) \ - $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(REGFIO_OBJ) $(READLINE_OBJ) \ + $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(READLINE_OBJ) \ $(LDB_OBJ) $(LIBGPO_OBJ) @BUILD_INIPARSER@ $(DISPLAY_SEC_OBJ) \ $(REG_API_OBJ) $(DISPLAY_DSDCINFO_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index fd3e08cacd..6be60f04ec 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -43,7 +43,7 @@ * 0x10 winreg_QueryInfoKey reg_queryinfokey * 0x11 winreg_QueryValue reg_queryvalue * 0x12 winreg_ReplaceKey - * 0x13 winreg_RestoreKey + * 0x13 winreg_RestoreKey reg_restorekey * 0x14 winreg_SaveKey reg_savekey * 0x15 winreg_SetKeySecurity reg_setkeysecurity * 0x16 winreg_SetValue reg_setvalue @@ -697,6 +697,130 @@ WERROR reg_getversion(uint32_t *version) return WERR_OK; } +/******************************************************************* + Note: topkeypat is the *full* path that this *key will be + loaded into (including the name of the key) + ********************************************************************/ + +static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, + REGF_NK_REC *key ) +{ + REGF_NK_REC *subkey; + REGISTRY_KEY registry_key; + REGVAL_CTR *values; + REGSUBKEY_CTR *subkeys; + int i; + char *path = NULL; + WERROR result = WERR_OK; + + /* initialize the REGISTRY_KEY structure */ + + if ( !(registry_key.hook = reghook_cache_find(topkeypath)) ) { + DEBUG(0,("reg_load_tree: Failed to assigned a REGISTRY_HOOK to [%s]\n", + topkeypath )); + return WERR_BADFILE; + } + + registry_key.name = talloc_strdup( regfile->mem_ctx, topkeypath ); + if ( !registry_key.name ) { + DEBUG(0,("reg_load_tree: Talloc failed for reg_key.name!\n")); + return WERR_NOMEM; + } + + /* now start parsing the values and subkeys */ + + if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + return WERR_NOMEM; + + if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) + return WERR_NOMEM; + + /* copy values into the REGVAL_CTR */ + + for ( i=0; inum_values; i++ ) { + regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, + (char*)key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); + } + + /* copy subkeys into the REGSUBKEY_CTR */ + + key->subkey_index = 0; + while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { + regsubkey_ctr_addkey( subkeys, subkey->keyname ); + } + + /* write this key and values out */ + + if ( !store_reg_values( ®istry_key, values ) + || !store_reg_keys( ®istry_key, subkeys ) ) + { + DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); + result = WERR_REG_IO_FAILURE; + } + + TALLOC_FREE( subkeys ); + + if ( !W_ERROR_IS_OK(result) ) + return result; + + /* now continue to load each subkey registry tree */ + + key->subkey_index = 0; + while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { + path = talloc_asprintf(regfile->mem_ctx, + "%s\\%s", + topkeypath, + subkey->keyname); + if (!path) { + return WERR_NOMEM; + } + result = reg_load_tree( regfile, path, subkey ); + if ( !W_ERROR_IS_OK(result) ) + break; + } + + return result; +} + +/******************************************************************* + ********************************************************************/ + +static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) +{ + REGF_FILE *regfile; + REGF_NK_REC *rootkey; + WERROR result; + + /* open the registry file....fail if the file already exists */ + + if ( !(regfile = regfio_open( fname, (O_RDONLY), 0 )) ) { + DEBUG(0,("restore_registry_key: failed to open \"%s\" (%s)\n", + fname, strerror(errno) )); + return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); + } + + /* get the rootkey from the regf file and then load the tree + via recursive calls */ + + if ( !(rootkey = regfio_rootkey( regfile )) ) { + regfio_close( regfile ); + return WERR_REG_FILE_INVALID; + } + + result = reg_load_tree( regfile, krecord->name, rootkey ); + + /* cleanup */ + + regfio_close( regfile ); + + return result; +} + +WERROR reg_restorekey(struct registry_key *key, const char *fname) +{ + return restore_registry_key(key->key, fname); +} + /******************************************************************** ********************************************************************/ diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index c6447b4556..5d18419c75 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -21,7 +21,6 @@ /* Implementation of registry functions. */ #include "includes.h" -#include "regfio.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -651,125 +650,6 @@ static int validate_reg_filename(TALLOC_CTX *ctx, char **pp_fname ) return (snum < num_services) ? snum : -1; } -/******************************************************************* - Note: topkeypat is the *full* path that this *key will be - loaded into (including the name of the key) - ********************************************************************/ - -static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, - REGF_NK_REC *key ) -{ - REGF_NK_REC *subkey; - REGISTRY_KEY registry_key; - REGVAL_CTR *values; - REGSUBKEY_CTR *subkeys; - int i; - char *path = NULL; - WERROR result = WERR_OK; - - /* initialize the REGISTRY_KEY structure */ - - if ( !(registry_key.hook = reghook_cache_find(topkeypath)) ) { - DEBUG(0,("reg_load_tree: Failed to assigned a REGISTRY_HOOK to [%s]\n", - topkeypath )); - return WERR_BADFILE; - } - - registry_key.name = talloc_strdup( regfile->mem_ctx, topkeypath ); - if ( !registry_key.name ) { - DEBUG(0,("reg_load_tree: Talloc failed for reg_key.name!\n")); - return WERR_NOMEM; - } - - /* now start parsing the values and subkeys */ - - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) - return WERR_NOMEM; - - if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) - return WERR_NOMEM; - - /* copy values into the REGVAL_CTR */ - - for ( i=0; inum_values; i++ ) { - regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, - (char*)key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); - } - - /* copy subkeys into the REGSUBKEY_CTR */ - - key->subkey_index = 0; - while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - regsubkey_ctr_addkey( subkeys, subkey->keyname ); - } - - /* write this key and values out */ - - if ( !store_reg_values( ®istry_key, values ) - || !store_reg_keys( ®istry_key, subkeys ) ) - { - DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); - result = WERR_REG_IO_FAILURE; - } - - TALLOC_FREE( subkeys ); - - if ( !W_ERROR_IS_OK(result) ) - return result; - - /* now continue to load each subkey registry tree */ - - key->subkey_index = 0; - while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - path = talloc_asprintf(regfile->mem_ctx, - "%s\\%s", - topkeypath, - subkey->keyname); - if (!path) { - return WERR_NOMEM; - } - result = reg_load_tree( regfile, path, subkey ); - if ( !W_ERROR_IS_OK(result) ) - break; - } - - return result; -} - -/******************************************************************* - ********************************************************************/ - -static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) -{ - REGF_FILE *regfile; - REGF_NK_REC *rootkey; - WERROR result; - - /* open the registry file....fail if the file already exists */ - - if ( !(regfile = regfio_open( fname, (O_RDONLY), 0 )) ) { - DEBUG(0,("restore_registry_key: failed to open \"%s\" (%s)\n", - fname, strerror(errno) )); - return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); - } - - /* get the rootkey from the regf file and then load the tree - via recursive calls */ - - if ( !(rootkey = regfio_rootkey( regfile )) ) { - regfio_close( regfile ); - return WERR_REG_FILE_INVALID; - } - - result = reg_load_tree( regfile, krecord->name, rootkey ); - - /* cleanup */ - - regfio_close( regfile ); - - return result; -} - /******************************************************************* ********************************************************************/ @@ -804,7 +684,7 @@ WERROR _winreg_RestoreKey(pipes_struct *p, struct winreg_RestoreKey *r) DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n", regkey->key->name, fname, lp_servicename(snum) )); - return restore_registry_key( regkey->key, fname ); + return reg_restorekey(regkey, fname); } WERROR _winreg_SaveKey(pipes_struct *p, struct winreg_SaveKey *r) -- cgit From abdedc7940b187789ffc583dabc778f824039095 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 17:25:16 +0100 Subject: Reformat copied reg_savekey/reg_restorekey code. Sticking to coding rules. Michael (This used to be commit 2c54ef2d07ab440f1c163b666caedcb9c061543b) --- source3/registry/reg_api.c | 205 ++++++++++++++++++++++++++------------------- 1 file changed, 119 insertions(+), 86 deletions(-) (limited to 'source3') diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index 6be60f04ec..aba5735a0c 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -702,8 +702,8 @@ WERROR reg_getversion(uint32_t *version) loaded into (including the name of the key) ********************************************************************/ -static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, - REGF_NK_REC *key ) +static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath, + REGF_NK_REC *key) { REGF_NK_REC *subkey; REGISTRY_KEY registry_key; @@ -715,68 +715,77 @@ static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, /* initialize the REGISTRY_KEY structure */ - if ( !(registry_key.hook = reghook_cache_find(topkeypath)) ) { - DEBUG(0,("reg_load_tree: Failed to assigned a REGISTRY_HOOK to [%s]\n", - topkeypath )); + registry_key.hook = reghook_cache_find(topkeypath); + if (!registry_key.hook) { + DEBUG(0, ("reg_load_tree: Failed to assigned a REGISTRY_HOOK " + "to [%s]\n", topkeypath)); return WERR_BADFILE; } - registry_key.name = talloc_strdup( regfile->mem_ctx, topkeypath ); - if ( !registry_key.name ) { - DEBUG(0,("reg_load_tree: Talloc failed for reg_key.name!\n")); + registry_key.name = talloc_strdup(regfile->mem_ctx, topkeypath); + if (!registry_key.name) { + DEBUG(0, ("reg_load_tree: Talloc failed for reg_key.name!\n")); return WERR_NOMEM; } /* now start parsing the values and subkeys */ - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + subkeys = TALLOC_ZERO_P(regfile->mem_ctx, REGSUBKEY_CTR); + if (subkeys == NULL) { return WERR_NOMEM; + } - if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) + values = TALLOC_ZERO_P(subkeys, REGVAL_CTR); + if (values == NULL) { return WERR_NOMEM; + } /* copy values into the REGVAL_CTR */ - for ( i=0; inum_values; i++ ) { - regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, - (char*)key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); + for (i=0; inum_values; i++) { + regval_ctr_addvalue(values, key->values[i].valuename, + key->values[i].type, + (char*)key->values[i].data, + (key->values[i].data_size & ~VK_DATA_IN_OFFSET)); } /* copy subkeys into the REGSUBKEY_CTR */ key->subkey_index = 0; - while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - regsubkey_ctr_addkey( subkeys, subkey->keyname ); + while ((subkey = regfio_fetch_subkey( regfile, key ))) { + regsubkey_ctr_addkey(subkeys, subkey->keyname); } /* write this key and values out */ - if ( !store_reg_values( ®istry_key, values ) - || !store_reg_keys( ®istry_key, subkeys ) ) + if (!store_reg_values(®istry_key, values) + || !store_reg_keys(®istry_key, subkeys)) { DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); result = WERR_REG_IO_FAILURE; } - TALLOC_FREE( subkeys ); + TALLOC_FREE(subkeys); - if ( !W_ERROR_IS_OK(result) ) + if (!W_ERROR_IS_OK(result)) { return result; + } /* now continue to load each subkey registry tree */ key->subkey_index = 0; - while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { + while ((subkey = regfio_fetch_subkey(regfile, key))) { path = talloc_asprintf(regfile->mem_ctx, - "%s\\%s", - topkeypath, - subkey->keyname); - if (!path) { + "%s\\%s", + topkeypath, + subkey->keyname); + if (path == NULL) { return WERR_NOMEM; } - result = reg_load_tree( regfile, path, subkey ); - if ( !W_ERROR_IS_OK(result) ) + result = reg_load_tree(regfile, path, subkey); + if (!W_ERROR_IS_OK(result)) { break; + } } return result; @@ -785,33 +794,34 @@ static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, /******************************************************************* ********************************************************************/ -static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) +static WERROR restore_registry_key(REGISTRY_KEY *krecord, const char *fname) { REGF_FILE *regfile; REGF_NK_REC *rootkey; WERROR result; - + /* open the registry file....fail if the file already exists */ - - if ( !(regfile = regfio_open( fname, (O_RDONLY), 0 )) ) { - DEBUG(0,("restore_registry_key: failed to open \"%s\" (%s)\n", - fname, strerror(errno) )); - return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); - } - + + regfile = regfio_open(fname, (O_RDONLY), 0); + if (regfile == NULL) { + DEBUG(0, ("restore_registry_key: failed to open \"%s\" (%s)\n", + fname, strerror(errno))); + return ntstatus_to_werror(map_nt_error_from_unix(errno)); + } + /* get the rootkey from the regf file and then load the tree via recursive calls */ - - if ( !(rootkey = regfio_rootkey( regfile )) ) { - regfio_close( regfile ); + + if (!(rootkey = regfio_rootkey(regfile))) { + regfio_close(regfile); return WERR_REG_FILE_INVALID; } - result = reg_load_tree( regfile, krecord->name, rootkey ); + result = reg_load_tree(regfile, krecord->name, rootkey); /* cleanup */ - regfio_close( regfile ); + regfio_close(regfile); return result; } @@ -824,8 +834,8 @@ WERROR reg_restorekey(struct registry_key *key, const char *fname) /******************************************************************** ********************************************************************/ -static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, - REGF_NK_REC *parent, SEC_DESC *sec_desc ) +static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath, + REGF_NK_REC *parent, SEC_DESC *sec_desc) { REGF_NK_REC *key; REGVAL_CTR *values; @@ -838,11 +848,13 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, REGISTRY_KEY registry_key; WERROR result = WERR_OK; - if (!regfile) + if (!regfile) { return WERR_GENERAL_FAILURE; + } - if (!keypath) + if (!keypath) { return WERR_OBJECT_PATH_INVALID; + } /* split up the registry key path */ @@ -850,61 +862,73 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, if (!key_tmp) { return WERR_NOMEM; } - if (!reg_split_key( key_tmp, &parentpath, &keyname ) ) + if (!reg_split_key(key_tmp, &parentpath, &keyname)) { return WERR_OBJECT_PATH_INVALID; + } - if ( !keyname ) + if (!keyname) { keyname = parentpath; + } /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ - ZERO_STRUCT( registry_key ); + ZERO_STRUCT(registry_key); - if ( (registry_key.name = talloc_strdup(regfile->mem_ctx, keypath)) == NULL ) + registry_key.name = talloc_strdup(regfile->mem_ctx, keypath); + if (registry_key.name == NULL) { return WERR_NOMEM; + } - if ( (registry_key.hook = reghook_cache_find( registry_key.name )) == NULL ) + registry_key.hook = reghook_cache_find(registry_key.name); + if (registry_key.hook == NULL) { return WERR_BADFILE; + } /* lookup the values and subkeys */ - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + subkeys = TALLOC_ZERO_P(regfile->mem_ctx, REGSUBKEY_CTR); + if (subkeys == NULL) { return WERR_NOMEM; + } - if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) + values = TALLOC_ZERO_P(subkeys, REGVAL_CTR); + if (values == NULL) { return WERR_NOMEM; + } - fetch_reg_keys( ®istry_key, subkeys ); - fetch_reg_values( ®istry_key, values ); + fetch_reg_keys(®istry_key, subkeys); + fetch_reg_values(®istry_key, values); /* write out this key */ - if ( !(key = regfio_write_key( regfile, keyname, values, subkeys, sec_desc, parent )) ) { + key = regfio_write_key(regfile, keyname, values, subkeys, sec_desc, + parent); + if (key == NULL) { result = WERR_CAN_NOT_COMPLETE; goto done; } /* write each one of the subkeys out */ - num_subkeys = regsubkey_ctr_numkeys( subkeys ); - for ( i=0; imem_ctx, - "%s\\%s", keypath, subkeyname); - if (!subkeypath) { + num_subkeys = regsubkey_ctr_numkeys(subkeys); + for (i=0; imem_ctx, "%s\\%s", + keypath, subkeyname); + if (subkeypath == NULL) { result = WERR_NOMEM; goto done; } - result = reg_write_tree( regfile, subkeypath, key, sec_desc ); - if ( !W_ERROR_IS_OK(result) ) + result = reg_write_tree(regfile, subkeypath, key, sec_desc); + if (!W_ERROR_IS_OK(result)) goto done; } - DEBUG(6,("reg_write_tree: wrote key [%s]\n", keypath )); + DEBUG(6, ("reg_write_tree: wrote key [%s]\n", keypath)); done: - TALLOC_FREE( subkeys ); - TALLOC_FREE( registry_key.name ); + TALLOC_FREE(subkeys); + TALLOC_FREE(registry_key.name); return result; } @@ -912,7 +936,7 @@ done: static const struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; -static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) +static WERROR make_default_reg_sd(TALLOC_CTX *ctx, SEC_DESC **psd) { DOM_SID adm_sid, owner_sid; SEC_ACE ace[2]; /* at most 2 entries */ @@ -928,8 +952,10 @@ static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) /* basic access for Everyone */ - init_sec_access(&mask, reg_generic_map.generic_execute | reg_generic_map.generic_read ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_access(&mask, reg_generic_map.generic_execute + | reg_generic_map.generic_read); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, 0); /* add Full Access 'BUILTIN\Administrators' */ @@ -938,45 +964,52 @@ static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - /* create the security descriptor */ + /* create the security descriptor */ - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 2, ace)) == NULL) - return WERR_NOMEM; + psa = make_sec_acl(ctx, NT4_ACL_REVISION, 2, ace); + if (psa == NULL) { + return WERR_NOMEM; + } - if ((*psd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, - SEC_DESC_SELF_RELATIVE, &owner_sid, NULL, - NULL, psa, &sd_size)) == NULL) - return WERR_NOMEM; + *psd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, + SEC_DESC_SELF_RELATIVE, &owner_sid, NULL, + NULL, psa, &sd_size); + if (*psd == NULL) { + return WERR_NOMEM; + } return WERR_OK; } -static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) +static WERROR backup_registry_key(REGISTRY_KEY *krecord, const char *fname) { REGF_FILE *regfile; WERROR result; SEC_DESC *sd = NULL; - + /* open the registry file....fail if the file already exists */ - if ( !(regfile = regfio_open( fname, (O_RDWR|O_CREAT|O_EXCL), (S_IREAD|S_IWRITE) )) ) { - DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", - fname, strerror(errno) )); - return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); - } + regfile = regfio_open(fname, (O_RDWR|O_CREAT|O_EXCL), + (S_IREAD|S_IWRITE)); + if (regfile == NULL) { + DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", + fname, strerror(errno) )); + return ntstatus_to_werror(map_nt_error_from_unix(errno)); + } - if ( !W_ERROR_IS_OK(result = make_default_reg_sd( regfile->mem_ctx, &sd )) ) { - regfio_close( regfile ); + result = make_default_reg_sd(regfile->mem_ctx, &sd); + if (!W_ERROR_IS_OK(result)) { + regfio_close(regfile); return result; } /* write the registry tree to the file */ - result = reg_write_tree( regfile, krecord->name, NULL, sd ); + result = reg_write_tree(regfile, krecord->name, NULL, sd); /* cleanup */ - regfio_close( regfile ); + regfio_close(regfile); return result; } -- cgit From f8bd3e82e5eda052ede2d294f08165cb23df9d90 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 17:30:38 +0100 Subject: Add netlogon_creds_server_check and netlogon_creds_server_step. Guenther (This used to be commit ea0bf74918e7b009439452ea14ed68b0ce620787) --- source3/libsmb/credentials.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'source3') diff --git a/source3/libsmb/credentials.c b/source3/libsmb/credentials.c index f03bf22df1..0043f4e6a9 100644 --- a/source3/libsmb/credentials.c +++ b/source3/libsmb/credentials.c @@ -225,6 +225,21 @@ bool creds_server_check(const struct dcinfo *dc, const DOM_CHAL *rcv_cli_chal_in return True; } +bool netlogon_creds_server_check(const struct dcinfo *dc, + const struct netr_Credential *rcv_cli_chal_in) +{ + if (memcmp(dc->clnt_chal.data, rcv_cli_chal_in->data, 8)) { + DEBUG(5,("netlogon_creds_server_check: challenge : %s\n", + credstr(rcv_cli_chal_in->data))); + DEBUG(5,("calculated: %s\n", credstr(dc->clnt_chal.data))); + DEBUG(2,("netlogon_creds_server_check: credentials check failed.\n")); + return false; + } + + DEBUG(10,("netlogon_creds_server_check: credentials check OK.\n")); + + return true; +} /**************************************************************************** Replace current seed chal. Internal function - due to split server step below. ****************************************************************************/ @@ -273,6 +288,36 @@ bool creds_server_step(struct dcinfo *dc, const DOM_CRED *received_cred, DOM_CRE return True; } +bool netlogon_creds_server_step(struct dcinfo *dc, + const struct netr_Authenticator *received_cred, + struct netr_Authenticator *cred_out) +{ + bool ret; + struct dcinfo tmp_dc = *dc; + + /* Do all operations on a temporary copy of the dc, + which we throw away if the checks fail. */ + + tmp_dc.sequence = received_cred->timestamp; + + creds_step(&tmp_dc); + + /* Create the outgoing credentials */ + cred_out->timestamp = tmp_dc.sequence + 1; + memcpy(&cred_out->cred, &tmp_dc.srv_chal, sizeof(cred_out->cred)); + + creds_reseed(&tmp_dc); + + ret = netlogon_creds_server_check(&tmp_dc, &received_cred->cred); + if (!ret) { + return false; + } + + /* creds step succeeded - replace the current creds. */ + *dc = tmp_dc; + return true; +} + /**************************************************************************** Create a client credential struct. ****************************************************************************/ -- cgit From 4f0b904538b376ed117fc23b6e34fbed37141437 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 21:13:50 +0100 Subject: Use pidl for _netr_ServerPasswordSet(). Guenther (This used to be commit 85b7489dd2e8181ee48caa8273020885a08bbb74) --- source3/rpc_server/srv_netlog.c | 24 +--------------- source3/rpc_server/srv_netlog_nt.c | 58 ++++++++++++-------------------------- 2 files changed, 19 insertions(+), 63 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 791752c5d0..60688d201d 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -126,29 +126,7 @@ static bool api_net_auth_2(pipes_struct *p) static bool api_net_srv_pwset(pipes_struct *p) { - NET_Q_SRV_PWSET q_u; - NET_R_SRV_PWSET r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the challenge and encrypted password ... */ - if(!net_io_q_srv_pwset("", &q_u, data, 0)) { - DEBUG(0,("api_net_srv_pwset: Failed to unmarshall NET_Q_SRV_PWSET.\n")); - return False; - } - - r_u.status = _net_srv_pwset(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_srv_pwset("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_srv_pwset: Failed to marshall NET_R_SRV_PWSET.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_SERVERPASSWORDSET); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 3cfab7843d..bb346650f2 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -255,21 +255,6 @@ WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, return WERR_OK; } -/*********************************************************************************** - init_net_r_srv_pwset: - ***********************************************************************************/ - -static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, - DOM_CRED *srv_cred, NTSTATUS status) -{ - DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); - - memcpy(&r_s->srv_cred, srv_cred, sizeof(r_s->srv_cred)); - r_s->status = status; - - DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); -} - /****************************************************************** gets a machine password entry. checks access rights of the host. ******************************************************************/ @@ -577,31 +562,32 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) } /************************************************************************* - _net_srv_pwset + _netr_ServerPasswordSet *************************************************************************/ -NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) +NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, + struct netr_ServerPasswordSet *r) { + NTSTATUS status = NT_STATUS_OK; fstring remote_machine; struct samu *sampass=NULL; bool ret = False; unsigned char pwd[16]; int i; uint32 acct_ctrl; - DOM_CRED cred_out; + struct netr_Authenticator cred_out; const uchar *old_pw; - DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); + DEBUG(5,("_netr_ServerPasswordSet: %d\n", __LINE__)); /* We need the remote machine name for the creds lookup. */ - rpcstr_pull(remote_machine,q_u->clnt_id.login.uni_comp_name.buffer, - sizeof(remote_machine),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); + fstrcpy(remote_machine, r->in.computer_name); if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but obviously did not use it. */ - DEBUG(0,("_net_srv_pwset: client %s not using schannel for netlogon\n", + DEBUG(0,("_netr_ServerPasswordSet: client %s not using schannel for netlogon\n", remote_machine )); return NT_STATUS_ACCESS_DENIED; } @@ -622,12 +608,12 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_INVALID_HANDLE; } - DEBUG(3,("_net_srv_pwset: Server Password Set by remote machine:[%s] on account [%s]\n", + DEBUG(3,("_netr_ServerPasswordSet: Server Password Set by remote machine:[%s] on account [%s]\n", remote_machine, p->dc->mach_acct)); /* Step the creds chain forward. */ - if (!creds_server_step(p->dc, &q_u->clnt_id.cred, &cred_out)) { - DEBUG(2,("_net_srv_pwset: creds_server_step failed. Rejecting auth " + if (!netlogon_creds_server_step(p->dc, r->in.credential, &cred_out)) { + DEBUG(2,("_netr_ServerPasswordSet: netlogon_creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", remote_machine, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; @@ -668,9 +654,9 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } /* Woah - what does this to to the credential chain ? JRA */ - cred_hash3( pwd, q_u->pwd, p->dc->sess_key, 0); + cred_hash3(pwd, r->in.new_password->hash, p->dc->sess_key, 0); - DEBUG(100,("Server password set : new given value was :\n")); + DEBUG(100,("_netr_ServerPasswordSet: new given value was :\n")); for(i = 0; i < sizeof(pwd); i++) DEBUG(100,("%02X ", pwd[i])); DEBUG(100,("\n")); @@ -702,15 +688,17 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } become_root(); - r_u->status = pdb_update_sam_account(sampass); + status = pdb_update_sam_account(sampass); unbecome_root(); } /* set up the LSA Server Password Set response */ - init_net_r_srv_pwset(r_u, &cred_out, r_u->status); + + memcpy(r->out.return_authenticator, &cred_out, + sizeof(r->out.return_authenticator)); TALLOC_FREE(sampass); - return r_u->status; + return status; } /************************************************************************* @@ -1283,16 +1271,6 @@ NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, - struct netr_ServerPasswordSet *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, struct netr_DatabaseDeltas *r) { -- cgit From 55b2292abace1d12b04fb47a61daab26923f887c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 21:24:39 +0100 Subject: Use pidl for _netr_ServerAuthenticate(). Guenther (This used to be commit 943386c5dd601f5c8cf85bfcb08f731dd5a6437d) --- source3/rpc_server/srv_netlog.c | 24 +-------------- source3/rpc_server/srv_netlog_nt.c | 62 ++++++++++++++------------------------ 2 files changed, 23 insertions(+), 63 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 60688d201d..7f67fe51f0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -64,29 +64,7 @@ static bool api_net_req_chal(pipes_struct *p) static bool api_net_auth(pipes_struct *p) { - NET_Q_AUTH q_u; - NET_R_AUTH r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the challenge... */ - if(!net_io_q_auth("", &q_u, data, 0)) { - DEBUG(0,("api_net_auth: Failed to unmarshall NET_Q_AUTH.\n")); - return False; - } - - r_u.status = _net_auth(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_auth("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_auth: Failed to marshall NET_R_AUTH.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_SERVERAUTHENTICATE); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index bb346650f2..2b4921921f 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -259,7 +259,7 @@ WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, gets a machine password entry. checks access rights of the host. ******************************************************************/ -static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) +static NTSTATUS get_md4pw(char *md4pw, const char *mach_acct, uint16 sec_chan_type) { struct samu *sampass = NULL; const uint8 *pass; @@ -398,41 +398,30 @@ NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, } /************************************************************************* - init_net_r_auth: + _netr_ServerAuthenticate + Create the initial credentials. *************************************************************************/ -static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, NTSTATUS status) -{ - memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); - r_a->status = status; -} - -/************************************************************************* - _net_auth. Create the initial credentials. - *************************************************************************/ - -NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) +NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, + struct netr_ServerAuthenticate *r) { NTSTATUS status; - fstring mach_acct; - fstring remote_machine; DOM_CHAL srv_chal_out; if (!p->dc || !p->dc->challenge_sent) { return NT_STATUS_ACCESS_DENIED; } - rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring), - q_u->clnt_id.uni_acct_name.uni_str_len*2,0); - rpcstr_pull(remote_machine, q_u->clnt_id.uni_comp_name.buffer,sizeof(fstring), - q_u->clnt_id.uni_comp_name.uni_str_len*2,0); - - status = get_md4pw((char *)p->dc->mach_pw, mach_acct, q_u->clnt_id.sec_chan); + status = get_md4pw((char *)p->dc->mach_pw, + r->in.account_name, + r->in.secure_channel_type); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("_net_auth: creds_server_check failed. Failed to " + DEBUG(0,("_netr_ServerAuthenticate: get_md4pw failed. Failed to " "get password for machine account %s " "from client %s: %s\n", - mach_acct, remote_machine, nt_errstr(status) )); + r->in.account_name, + r->in.computer_name, + nt_errstr(status) )); /* always return NT_STATUS_ACCESS_DENIED */ return NT_STATUS_ACCESS_DENIED; } @@ -446,22 +435,25 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) &srv_chal_out); /* Check client credentials are valid. */ - if (!creds_server_check(p->dc, &q_u->clnt_chal)) { - DEBUG(0,("_net_auth: creds_server_check failed. Rejecting auth " + if (!netlogon_creds_server_check(p->dc, r->in.credentials)) { + DEBUG(0,("_netr_ServerAuthenticate: netlogon_creds_server_check failed. Rejecting auth " "request from client %s machine account %s\n", - remote_machine, mach_acct )); + r->in.computer_name, + r->in.account_name)); return NT_STATUS_ACCESS_DENIED; } - fstrcpy(p->dc->mach_acct, mach_acct); - fstrcpy(p->dc->remote_machine, remote_machine); + fstrcpy(p->dc->mach_acct, r->in.account_name); + fstrcpy(p->dc->remote_machine, r->in.computer_name); p->dc->authenticated = True; /* set up the LSA AUTH response */ /* Return the server credentials. */ - init_net_r_auth(r_u, &srv_chal_out, NT_STATUS_OK); - return r_u->status; + memcpy(r->out.credentials->data, &srv_chal_out.data, + sizeof(r->out.credentials->data)); + + return NT_STATUS_OK; } /************************************************************************* @@ -1261,16 +1253,6 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, - struct netr_ServerAuthenticate *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, struct netr_DatabaseDeltas *r) { -- cgit From c9f1f3d5ff07224e0da3df759215e7680893812e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 21:41:16 +0100 Subject: Use pidl for _netr_ServerAuthenticate2(). Guenther (This used to be commit 5d81cc136bcd8f53bedea6de5380b1147862c391) --- source3/rpc_server/srv_netlog.c | 24 +---------- source3/rpc_server/srv_netlog_nt.c | 88 ++++++++++++++------------------------ 2 files changed, 34 insertions(+), 78 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7f67fe51f0..719cdff41c 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -73,29 +73,7 @@ static bool api_net_auth(pipes_struct *p) static bool api_net_auth_2(pipes_struct *p) { - NET_Q_AUTH_2 q_u; - NET_R_AUTH_2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the challenge... */ - if(!net_io_q_auth_2("", &q_u, data, 0)) { - DEBUG(0,("api_net_auth_2: Failed to unmarshall NET_Q_AUTH_2.\n")); - return False; - } - - r_u.status = _net_auth_2(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_auth_2("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_auth_2: Failed to marshall NET_R_AUTH_2.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_SERVERAUTHENTICATE2); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2b4921921f..c11ada2461 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -457,63 +457,48 @@ NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, } /************************************************************************* - init_net_r_auth_2: + _netr_ServerAuthenticate2 *************************************************************************/ -static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, - DOM_CHAL *resp_cred, NEG_FLAGS *flgs, NTSTATUS status) -{ - memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); - memcpy(&r_a->srv_flgs, flgs, sizeof(r_a->srv_flgs)); - r_a->status = status; -} - -/************************************************************************* - _net_auth_2 - *************************************************************************/ - -NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) +NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, + struct netr_ServerAuthenticate2 *r) { NTSTATUS status; - NEG_FLAGS srv_flgs; - fstring mach_acct; - fstring remote_machine; + uint32_t srv_flgs; DOM_CHAL srv_chal_out; - rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring), - q_u->clnt_id.uni_acct_name.uni_str_len*2,0); - - /* We use this as the key to store the creds. */ - rpcstr_pull(remote_machine, q_u->clnt_id.uni_comp_name.buffer,sizeof(fstring), - q_u->clnt_id.uni_comp_name.uni_str_len*2,0); + /* We use this as the key to store the creds: */ + /* r->in.computer_name */ if (!p->dc || !p->dc->challenge_sent) { - DEBUG(0,("_net_auth2: no challenge sent to client %s\n", - remote_machine )); + DEBUG(0,("_netr_ServerAuthenticate2: no challenge sent to client %s\n", + r->in.computer_name)); return NT_STATUS_ACCESS_DENIED; } - if ( (lp_server_schannel() == True) && - ((q_u->clnt_flgs.neg_flags & NETLOGON_NEG_SCHANNEL) == 0) ) { + if ( (lp_server_schannel() == true) && + ((*r->in.negotiate_flags & NETLOGON_NEG_SCHANNEL) == 0) ) { /* schannel must be used, but client did not offer it. */ - DEBUG(0,("_net_auth2: schannel required but client failed " + DEBUG(0,("_netr_ServerAuthenticate2: schannel required but client failed " "to offer it. Client was %s\n", - mach_acct )); + r->in.account_name)); return NT_STATUS_ACCESS_DENIED; } - status = get_md4pw((char *)p->dc->mach_pw, mach_acct, q_u->clnt_id.sec_chan); + status = get_md4pw((char *)p->dc->mach_pw, + r->in.account_name, + r->in.secure_channel_type); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("_net_auth2: failed to get machine password for " + DEBUG(0,("_netr_ServerAuthenticate2: failed to get machine password for " "account %s: %s\n", - mach_acct, nt_errstr(status) )); + r->in.account_name, nt_errstr(status) )); /* always return NT_STATUS_ACCESS_DENIED */ return NT_STATUS_ACCESS_DENIED; } /* From the client / server challenges and md4 password, generate sess key */ - creds_server_init(q_u->clnt_flgs.neg_flags, + creds_server_init(*r->in.negotiate_flags, p->dc, &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ @@ -521,24 +506,27 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) &srv_chal_out); /* Check client credentials are valid. */ - if (!creds_server_check(p->dc, &q_u->clnt_chal)) { - DEBUG(0,("_net_auth2: creds_server_check failed. Rejecting auth " + if (!netlogon_creds_server_check(p->dc, r->in.credentials)) { + DEBUG(0,("_netr_ServerAuthenticate2: netlogon_creds_server_check failed. Rejecting auth " "request from client %s machine account %s\n", - remote_machine, mach_acct )); + r->in.computer_name, + r->in.account_name)); return NT_STATUS_ACCESS_DENIED; } - srv_flgs.neg_flags = 0x000001ff; + srv_flgs = 0x000001ff; - if (lp_server_schannel() != False) { - srv_flgs.neg_flags |= NETLOGON_NEG_SCHANNEL; + if (lp_server_schannel() != false) { + srv_flgs |= NETLOGON_NEG_SCHANNEL; } /* set up the LSA AUTH 2 response */ - init_net_r_auth_2(r_u, &srv_chal_out, &srv_flgs, NT_STATUS_OK); + memcpy(r->out.credentials->data, &srv_chal_out.data, + sizeof(r->out.credentials->data)); + *r->out.negotiate_flags = srv_flgs; - fstrcpy(p->dc->mach_acct, mach_acct); - fstrcpy(p->dc->remote_machine, remote_machine); + fstrcpy(p->dc->mach_acct, r->in.account_name); + fstrcpy(p->dc->remote_machine, r->in.computer_name); fstrcpy(p->dc->domain, lp_workgroup() ); p->dc->authenticated = True; @@ -546,11 +534,11 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) /* Store off the state so we can continue after client disconnect. */ become_root(); secrets_store_schannel_session_info(p->mem_ctx, - remote_machine, - p->dc); + r->in.computer_name, + p->dc); unbecome_root(); - return r_u->status; + return NT_STATUS_OK; } /************************************************************************* @@ -1313,16 +1301,6 @@ WERROR _netr_GetAnyDCName(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, - struct netr_ServerAuthenticate2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseSync2(pipes_struct *p, struct netr_DatabaseSync2 *r) { -- cgit From 5bce07977a18cd6bfd4714030707d3b2643cd840 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 21:46:42 +0100 Subject: Use pidl for _netr_LogonSamLogoff(). Guenther (This used to be commit a9683cbf4352ce331156f40b24a481fc87854b50) --- source3/rpc_server/srv_netlog.c | 23 +------------------- source3/rpc_server/srv_netlog_nt.c | 43 +++++++++++++------------------------- 2 files changed, 15 insertions(+), 51 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 719cdff41c..0e386c0de3 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -91,28 +91,7 @@ static bool api_net_srv_pwset(pipes_struct *p) static bool api_net_sam_logoff(pipes_struct *p) { - NET_Q_SAM_LOGOFF q_u; - NET_R_SAM_LOGOFF r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!net_io_q_sam_logoff("", &q_u, data, 0)) { - DEBUG(0,("api_net_sam_logoff: Failed to unmarshall NET_Q_SAM_LOGOFF.\n")); - return False; - } - - r_u.status = _net_sam_logoff(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_sam_logoff("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_sam_logoff: Failed to marshall NET_R_SAM_LOGOFF.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGOFF); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c11ada2461..30066dc58f 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -682,18 +682,17 @@ NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, } /************************************************************************* - _net_sam_logoff: + _netr_LogonSamLogoff *************************************************************************/ -NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) +NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, + struct netr_LogonSamLogoff *r) { - fstring remote_machine; - if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but obviously did not use it. */ - DEBUG(0,("_net_sam_logoff: client %s not using schannel for netlogon\n", + DEBUG(0,("_netr_LogonSamLogoff: client %s not using schannel for netlogon\n", get_remote_machine_name() )); return NT_STATUS_ACCESS_DENIED; } @@ -702,9 +701,8 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - /* Get the remote machine name for the creds store. */ - rpcstr_pull(remote_machine,q_u->sam_id.client.login.uni_comp_name.buffer, - sizeof(remote_machine),q_u->sam_id.client.login.uni_comp_name.uni_str_len*2,0); + /* Using the remote machine name for the creds store: */ + /* r->in.computer_name */ if (!p->dc) { /* Restore the saved state of the netlogon creds. */ @@ -712,8 +710,8 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - remote_machine, - &p->dc); + r->in.computer_name, + &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -724,25 +722,22 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF return NT_STATUS_INVALID_HANDLE; } - r_u->buffer_creds = 1; /* yes, we have valid server credentials */ - /* checks and updates credentials. creates reply credentials */ - if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(2,("_net_sam_logoff: creds_server_step failed. Rejecting auth " + if (!netlogon_creds_server_step(p->dc, r->in.credential, r->out.return_authenticator)) { + DEBUG(2,("_netr_LogonSamLogoff: netlogon_creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", - remote_machine, p->dc->mach_acct )); + r->in.computer_name, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; } /* We must store the creds state after an update. */ become_root(); secrets_store_schannel_session_info(p->pipe_state_mem_ctx, - remote_machine, - p->dc); + r->in.computer_name, + p->dc); unbecome_root(); - r_u->status = NT_STATUS_OK; - return r_u->status; + return NT_STATUS_OK; } /******************************************************************* @@ -1231,16 +1226,6 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, - struct netr_LogonSamLogoff *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, struct netr_DatabaseDeltas *r) { -- cgit From e3a975b7f3d6ceaf32bdc70963fd0af87e2ef1ff Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 22:38:29 +0100 Subject: Remove unused marshalling for NET_SAM_LOGOFF. Guenther (This used to be commit b419e7fa32ce34ee1ddde562223fe08f5d07a012) --- source3/include/rpc_netlogon.h | 13 ------------ source3/rpc_parse/parse_net.c | 48 ------------------------------------------ 2 files changed, 61 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index 4105b34e10..3d7e11d1d6 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -454,19 +454,6 @@ typedef struct net_r_sam_logon_info_ex { NTSTATUS status; /* return code */ } NET_R_SAM_LOGON_EX; - -/* NET_Q_SAM_LOGOFF */ -typedef struct net_q_sam_logoff_info { - DOM_SAM_INFO sam_id; -} NET_Q_SAM_LOGOFF; - -/* NET_R_SAM_LOGOFF */ -typedef struct net_r_sam_logoff_info { - uint32 buffer_creds; /* undocumented buffer pointer */ - DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */ - NTSTATUS status; /* return code */ -} NET_R_SAM_LOGOFF; - /* LOCKOUT_STRING */ typedef struct account_lockout_string { uint32 array_size; diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index 8677924d6a..b3a0997c7a 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -1358,51 +1358,3 @@ bool net_io_r_sam_logon_ex(const char *desc, NET_R_SAM_LOGON_EX *r_l, prs_struct return True; } - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_q_sam_logoff(const char *desc, NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth) -{ - if (q_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_sam_logoff"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_sam_info("", &q_l->sam_id, ps, depth)) /* domain SID */ - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_r_sam_logoff(const char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int depth) -{ - if (r_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_sam_logoff"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */ - return False; - if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */ - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - return True; -} -- cgit From ab09585d82f675d47d14ca3d6ff16e70d6203f5f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 23:30:53 +0100 Subject: Fix IDL for netr_ServerReqChallenge, netr_ServerAuthenticate and netr_ServerAuthenticate2 to match what is on NDR and to generate a more appropriate samba3 netlogon client. Guenther (This used to be commit 3bee9b89792055bc902e3feab21e80a6f5a756fe) --- source3/librpc/idl/netlogon.idl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index 60bf075ddf..e5e789c965 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -272,7 +272,8 @@ interface netlogon NTSTATUS netr_ServerReqChallenge( [in,unique,string,charset(UTF16)] uint16 *server_name, [in,string,charset(UTF16)] uint16 computer_name[], - [in,out,ref] netr_Credential *credentials + [in,ref] netr_Credential *credentials, + [out,ref] netr_Credential *return_credentials ); @@ -286,7 +287,8 @@ interface netlogon [in,string,charset(UTF16)] uint16 account_name[], [in] netr_SchannelType secure_channel_type, [in,string,charset(UTF16)] uint16 computer_name[], - [in,out,ref] netr_Credential *credentials + [in,ref] netr_Credential *credentials, + [out,ref] netr_Credential *return_credentials ); @@ -854,7 +856,8 @@ interface netlogon [in] [string,charset(UTF16)] uint16 account_name[], [in] netr_SchannelType secure_channel_type, [in] [string,charset(UTF16)] uint16 computer_name[], - [in,out,ref] netr_Credential *credentials, + [in,ref] netr_Credential *credentials, + [out,ref] netr_Credential *return_credentials, [in,out,ref] uint32 *negotiate_flags ); -- cgit From bc69f754001f6c999b1f914bde97648abe8f488d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 23:32:02 +0100 Subject: Re-run make idl. Guenther (This used to be commit b7818ec598fc942ba9c86dac0d47e239a6953301) --- source3/librpc/gen_ndr/cli_netlogon.c | 13 ++++--- source3/librpc/gen_ndr/cli_netlogon.h | 7 +++- source3/librpc/gen_ndr/ndr_netlogon.c | 69 ++++++++++++++++++----------------- source3/librpc/gen_ndr/ndr_winreg.c | 2 +- source3/librpc/gen_ndr/netlogon.h | 6 +-- source3/librpc/gen_ndr/srv_netlogon.c | 21 +++++++++-- 6 files changed, 71 insertions(+), 47 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_netlogon.c b/source3/librpc/gen_ndr/cli_netlogon.c index ef9eeaf7c2..e8b4243713 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.c +++ b/source3/librpc/gen_ndr/cli_netlogon.c @@ -220,7 +220,8 @@ NTSTATUS rpccli_netr_ServerReqChallenge(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_name, const char *computer_name, - struct netr_Credential *credentials) + struct netr_Credential *credentials, + struct netr_Credential *return_credentials) { struct netr_ServerReqChallenge r; NTSTATUS status; @@ -254,7 +255,7 @@ NTSTATUS rpccli_netr_ServerReqChallenge(struct rpc_pipe_client *cli, } /* Return variables */ - *credentials = *r.out.credentials; + *return_credentials = *r.out.return_credentials; /* Return result */ return r.out.result; @@ -266,7 +267,8 @@ NTSTATUS rpccli_netr_ServerAuthenticate(struct rpc_pipe_client *cli, const char *account_name, enum netr_SchannelType secure_channel_type, const char *computer_name, - struct netr_Credential *credentials) + struct netr_Credential *credentials, + struct netr_Credential *return_credentials) { struct netr_ServerAuthenticate r; NTSTATUS status; @@ -302,7 +304,7 @@ NTSTATUS rpccli_netr_ServerAuthenticate(struct rpc_pipe_client *cli, } /* Return variables */ - *credentials = *r.out.credentials; + *return_credentials = *r.out.return_credentials; /* Return result */ return r.out.result; @@ -799,6 +801,7 @@ NTSTATUS rpccli_netr_ServerAuthenticate2(struct rpc_pipe_client *cli, enum netr_SchannelType secure_channel_type, const char *computer_name, struct netr_Credential *credentials, + struct netr_Credential *return_credentials, uint32_t *negotiate_flags) { struct netr_ServerAuthenticate2 r; @@ -836,7 +839,7 @@ NTSTATUS rpccli_netr_ServerAuthenticate2(struct rpc_pipe_client *cli, } /* Return variables */ - *credentials = *r.out.credentials; + *return_credentials = *r.out.return_credentials; *negotiate_flags = *r.out.negotiate_flags; /* Return result */ diff --git a/source3/librpc/gen_ndr/cli_netlogon.h b/source3/librpc/gen_ndr/cli_netlogon.h index 35f903267d..706b7942b6 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.h +++ b/source3/librpc/gen_ndr/cli_netlogon.h @@ -38,14 +38,16 @@ NTSTATUS rpccli_netr_ServerReqChallenge(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_name, const char *computer_name, - struct netr_Credential *credentials); + struct netr_Credential *credentials, + struct netr_Credential *return_credentials); NTSTATUS rpccli_netr_ServerAuthenticate(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_name, const char *account_name, enum netr_SchannelType secure_channel_type, const char *computer_name, - struct netr_Credential *credentials); + struct netr_Credential *credentials, + struct netr_Credential *return_credentials); NTSTATUS rpccli_netr_ServerPasswordSet(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_name, @@ -137,6 +139,7 @@ NTSTATUS rpccli_netr_ServerAuthenticate2(struct rpc_pipe_client *cli, enum netr_SchannelType secure_channel_type, const char *computer_name, struct netr_Credential *credentials, + struct netr_Credential *return_credentials, uint32_t *negotiate_flags); NTSTATUS rpccli_netr_DatabaseSync2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index e5766487b3..a81ae097d6 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -8608,10 +8608,10 @@ static enum ndr_err_code ndr_push_netr_ServerReqChallenge(struct ndr_push *ndr, NDR_CHECK(ndr_push_netr_Credential(ndr, NDR_SCALARS, r->in.credentials)); } if (flags & NDR_OUT) { - if (r->out.credentials == NULL) { + if (r->out.return_credentials == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_netr_Credential(ndr, NDR_SCALARS, r->out.credentials)); + NDR_CHECK(ndr_push_netr_Credential(ndr, NDR_SCALARS, r->out.return_credentials)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -8622,6 +8622,7 @@ static enum ndr_err_code ndr_pull_netr_ServerReqChallenge(struct ndr_pull *ndr, uint32_t _ptr_server_name; TALLOC_CTX *_mem_save_server_name_0; TALLOC_CTX *_mem_save_credentials_0; + TALLOC_CTX *_mem_save_return_credentials_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -8657,17 +8658,17 @@ static enum ndr_err_code ndr_pull_netr_ServerReqChallenge(struct ndr_pull *ndr, NDR_PULL_SET_MEM_CTX(ndr, r->in.credentials, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_netr_Credential(ndr, NDR_SCALARS, r->in.credentials)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_credentials_0, LIBNDR_FLAG_REF_ALLOC); - NDR_PULL_ALLOC(ndr, r->out.credentials); - *r->out.credentials = *r->in.credentials; + NDR_PULL_ALLOC(ndr, r->out.return_credentials); + ZERO_STRUCTP(r->out.return_credentials); } if (flags & NDR_OUT) { if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.credentials); + NDR_PULL_ALLOC(ndr, r->out.return_credentials); } - _mem_save_credentials_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.credentials, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_netr_Credential(ndr, NDR_SCALARS, r->out.credentials)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_credentials_0, LIBNDR_FLAG_REF_ALLOC); + _mem_save_return_credentials_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.return_credentials, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_netr_Credential(ndr, NDR_SCALARS, r->out.return_credentials)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_return_credentials_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -8699,9 +8700,9 @@ _PUBLIC_ void ndr_print_netr_ServerReqChallenge(struct ndr_print *ndr, const cha if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "netr_ServerReqChallenge"); ndr->depth++; - ndr_print_ptr(ndr, "credentials", r->out.credentials); + ndr_print_ptr(ndr, "return_credentials", r->out.return_credentials); ndr->depth++; - ndr_print_netr_Credential(ndr, "credentials", r->out.credentials); + ndr_print_netr_Credential(ndr, "return_credentials", r->out.return_credentials); ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; @@ -8734,10 +8735,10 @@ static enum ndr_err_code ndr_push_netr_ServerAuthenticate(struct ndr_push *ndr, NDR_CHECK(ndr_push_netr_Credential(ndr, NDR_SCALARS, r->in.credentials)); } if (flags & NDR_OUT) { - if (r->out.credentials == NULL) { + if (r->out.return_credentials == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_netr_Credential(ndr, NDR_SCALARS, r->out.credentials)); + NDR_CHECK(ndr_push_netr_Credential(ndr, NDR_SCALARS, r->out.return_credentials)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -8748,6 +8749,7 @@ static enum ndr_err_code ndr_pull_netr_ServerAuthenticate(struct ndr_pull *ndr, uint32_t _ptr_server_name; TALLOC_CTX *_mem_save_server_name_0; TALLOC_CTX *_mem_save_credentials_0; + TALLOC_CTX *_mem_save_return_credentials_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -8791,17 +8793,17 @@ static enum ndr_err_code ndr_pull_netr_ServerAuthenticate(struct ndr_pull *ndr, NDR_PULL_SET_MEM_CTX(ndr, r->in.credentials, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_netr_Credential(ndr, NDR_SCALARS, r->in.credentials)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_credentials_0, LIBNDR_FLAG_REF_ALLOC); - NDR_PULL_ALLOC(ndr, r->out.credentials); - *r->out.credentials = *r->in.credentials; + NDR_PULL_ALLOC(ndr, r->out.return_credentials); + ZERO_STRUCTP(r->out.return_credentials); } if (flags & NDR_OUT) { if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.credentials); + NDR_PULL_ALLOC(ndr, r->out.return_credentials); } - _mem_save_credentials_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.credentials, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_netr_Credential(ndr, NDR_SCALARS, r->out.credentials)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_credentials_0, LIBNDR_FLAG_REF_ALLOC); + _mem_save_return_credentials_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.return_credentials, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_netr_Credential(ndr, NDR_SCALARS, r->out.return_credentials)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_return_credentials_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -8835,9 +8837,9 @@ _PUBLIC_ void ndr_print_netr_ServerAuthenticate(struct ndr_print *ndr, const cha if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "netr_ServerAuthenticate"); ndr->depth++; - ndr_print_ptr(ndr, "credentials", r->out.credentials); + ndr_print_ptr(ndr, "return_credentials", r->out.return_credentials); ndr->depth++; - ndr_print_netr_Credential(ndr, "credentials", r->out.credentials); + ndr_print_netr_Credential(ndr, "return_credentials", r->out.return_credentials); ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; @@ -10365,10 +10367,10 @@ static enum ndr_err_code ndr_push_netr_ServerAuthenticate2(struct ndr_push *ndr, NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.negotiate_flags)); } if (flags & NDR_OUT) { - if (r->out.credentials == NULL) { + if (r->out.return_credentials == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_netr_Credential(ndr, NDR_SCALARS, r->out.credentials)); + NDR_CHECK(ndr_push_netr_Credential(ndr, NDR_SCALARS, r->out.return_credentials)); if (r->out.negotiate_flags == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -10383,6 +10385,7 @@ static enum ndr_err_code ndr_pull_netr_ServerAuthenticate2(struct ndr_pull *ndr, uint32_t _ptr_server_name; TALLOC_CTX *_mem_save_server_name_0; TALLOC_CTX *_mem_save_credentials_0; + TALLOC_CTX *_mem_save_return_credentials_0; TALLOC_CTX *_mem_save_negotiate_flags_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -10434,19 +10437,19 @@ static enum ndr_err_code ndr_pull_netr_ServerAuthenticate2(struct ndr_pull *ndr, NDR_PULL_SET_MEM_CTX(ndr, r->in.negotiate_flags, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.negotiate_flags)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_negotiate_flags_0, LIBNDR_FLAG_REF_ALLOC); - NDR_PULL_ALLOC(ndr, r->out.credentials); - *r->out.credentials = *r->in.credentials; + NDR_PULL_ALLOC(ndr, r->out.return_credentials); + ZERO_STRUCTP(r->out.return_credentials); NDR_PULL_ALLOC(ndr, r->out.negotiate_flags); *r->out.negotiate_flags = *r->in.negotiate_flags; } if (flags & NDR_OUT) { if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.credentials); + NDR_PULL_ALLOC(ndr, r->out.return_credentials); } - _mem_save_credentials_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.credentials, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_netr_Credential(ndr, NDR_SCALARS, r->out.credentials)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_credentials_0, LIBNDR_FLAG_REF_ALLOC); + _mem_save_return_credentials_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.return_credentials, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_netr_Credential(ndr, NDR_SCALARS, r->out.return_credentials)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_return_credentials_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.negotiate_flags); } @@ -10491,9 +10494,9 @@ _PUBLIC_ void ndr_print_netr_ServerAuthenticate2(struct ndr_print *ndr, const ch if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "netr_ServerAuthenticate2"); ndr->depth++; - ndr_print_ptr(ndr, "credentials", r->out.credentials); + ndr_print_ptr(ndr, "return_credentials", r->out.return_credentials); ndr->depth++; - ndr_print_netr_Credential(ndr, "credentials", r->out.credentials); + ndr_print_netr_Credential(ndr, "return_credentials", r->out.return_credentials); ndr->depth--; ndr_print_ptr(ndr, "negotiate_flags", r->out.negotiate_flags); ndr->depth++; diff --git a/source3/librpc/gen_ndr/ndr_winreg.c b/source3/librpc/gen_ndr/ndr_winreg.c index b63d410587..ed511a62db 100644 --- a/source3/librpc/gen_ndr/ndr_winreg.c +++ b/source3/librpc/gen_ndr/ndr_winreg.c @@ -3700,7 +3700,7 @@ static enum ndr_err_code ndr_pull_winreg_QueryMultipleValues(struct ndr_pull *nd NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.buffer_size)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_size_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC_N(ndr, r->out.values, r->in.num_values); - memcpy(r->out.values, r->in.values, r->in.num_values * sizeof(*r->in.values)); + memcpy(r->out.values, r->in.values, (r->in.num_values) * sizeof(*r->in.values)); NDR_PULL_ALLOC(ndr, r->out.buffer_size); *r->out.buffer_size = *r->in.buffer_size; if (r->in.values) { diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index c18527da00..80434a1578 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -890,7 +890,7 @@ struct netr_ServerReqChallenge { } in; struct { - struct netr_Credential *credentials;/* [ref] */ + struct netr_Credential *return_credentials;/* [ref] */ NTSTATUS result; } out; @@ -907,7 +907,7 @@ struct netr_ServerAuthenticate { } in; struct { - struct netr_Credential *credentials;/* [ref] */ + struct netr_Credential *return_credentials;/* [ref] */ NTSTATUS result; } out; @@ -1093,7 +1093,7 @@ struct netr_ServerAuthenticate2 { } in; struct { - struct netr_Credential *credentials;/* [ref] */ + struct netr_Credential *return_credentials;/* [ref] */ uint32_t *negotiate_flags;/* [ref] */ NTSTATUS result; } out; diff --git a/source3/librpc/gen_ndr/srv_netlogon.c b/source3/librpc/gen_ndr/srv_netlogon.c index 98ba48aa17..67876f11ef 100644 --- a/source3/librpc/gen_ndr/srv_netlogon.c +++ b/source3/librpc/gen_ndr/srv_netlogon.c @@ -367,7 +367,12 @@ static bool api_netr_ServerReqChallenge(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.credentials = r->in.credentials; + r->out.return_credentials = talloc_zero(r, struct netr_Credential); + if (r->out.return_credentials == NULL) { + talloc_free(r); + return false; + } + r->out.result = _netr_ServerReqChallenge(p, r); if (p->rng_fault_state) { @@ -442,7 +447,12 @@ static bool api_netr_ServerAuthenticate(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.credentials = r->in.credentials; + r->out.return_credentials = talloc_zero(r, struct netr_Credential); + if (r->out.return_credentials == NULL) { + talloc_free(r); + return false; + } + r->out.result = _netr_ServerAuthenticate(p, r); if (p->rng_fault_state) { @@ -1280,7 +1290,12 @@ static bool api_netr_ServerAuthenticate2(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.credentials = r->in.credentials; + r->out.return_credentials = talloc_zero(r, struct netr_Credential); + if (r->out.return_credentials == NULL) { + talloc_free(r); + return false; + } + r->out.negotiate_flags = r->in.negotiate_flags; r->out.result = _netr_ServerAuthenticate2(p, r); -- cgit From ea1443efff60cbcaa0548bcc547ef3e5c35a178e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 23:36:31 +0100 Subject: Fix the netlogon rpc_server build. Guenther (This used to be commit 47806386e5cb12919615bb3075c9ed613efa4fdb) --- source3/rpc_server/srv_netlog_nt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 30066dc58f..3e15d38043 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -390,7 +390,7 @@ NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, generate_random_buffer(p->dc->srv_chal.data, 8); /* set up the LSA REQUEST CHALLENGE response */ - init_net_r_req_chal(r->out.credentials, &p->dc->srv_chal); + init_net_r_req_chal(r->out.return_credentials, &p->dc->srv_chal); p->dc->challenge_sent = True; @@ -450,8 +450,8 @@ NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, /* set up the LSA AUTH response */ /* Return the server credentials. */ - memcpy(r->out.credentials->data, &srv_chal_out.data, - sizeof(r->out.credentials->data)); + memcpy(r->out.return_credentials->data, &srv_chal_out.data, + sizeof(r->out.return_credentials->data)); return NT_STATUS_OK; } @@ -521,8 +521,8 @@ NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, } /* set up the LSA AUTH 2 response */ - memcpy(r->out.credentials->data, &srv_chal_out.data, - sizeof(r->out.credentials->data)); + memcpy(r->out.return_credentials->data, &srv_chal_out.data, + sizeof(r->out.return_credentials->data)); *r->out.negotiate_flags = srv_flgs; fstrcpy(p->dc->mach_acct, r->in.account_name); -- cgit From 3f24ef18481417fd7d52856b3d68bec099a7b643 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 23:57:19 +0100 Subject: Replace DOM_CHAL with "struct netr_Credential" where we can right now. This allows to remove some more old netlogon client calls. Guenther (This used to be commit c0b1a876583230a5130f5df1965d6c742961bcdc) --- source3/include/ntdomain.h | 6 ++--- source3/libsmb/credentials.c | 32 ++++++++++++----------- source3/rpc_client/cli_netlogon.c | 52 ++++++++++++++++++-------------------- source3/rpc_server/srv_netlog_nt.c | 6 ++--- 4 files changed, 47 insertions(+), 49 deletions(-) (limited to 'source3') diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h index 6537d5a7fb..b89b0fea3a 100644 --- a/source3/include/ntdomain.h +++ b/source3/include/ntdomain.h @@ -135,9 +135,9 @@ struct handle_list { /* Domain controller authentication protocol info */ struct dcinfo { uint32 sequence; /* "timestamp" from client. */ - DOM_CHAL seed_chal; - DOM_CHAL clnt_chal; /* Client credential */ - DOM_CHAL srv_chal; /* Server credential */ + struct netr_Credential seed_chal; + struct netr_Credential clnt_chal; /* Client credential */ + struct netr_Credential srv_chal; /* Server credential */ unsigned char sess_key[16]; /* Session key - 8 bytes followed by 8 zero bytes */ unsigned char mach_pw[16]; /* md4(machine password) */ diff --git a/source3/libsmb/credentials.c b/source3/libsmb/credentials.c index 0043f4e6a9..328b931df0 100644 --- a/source3/libsmb/credentials.c +++ b/source3/libsmb/credentials.c @@ -42,9 +42,9 @@ char *credstr(const unsigned char *cred) ****************************************************************************/ static void creds_init_128(struct dcinfo *dc, - const DOM_CHAL *clnt_chal_in, - const DOM_CHAL *srv_chal_in, - const unsigned char mach_pw[16]) + const struct netr_Credential *clnt_chal_in, + const struct netr_Credential *srv_chal_in, + const unsigned char mach_pw[16]) { unsigned char zero[4], tmp[16]; HMACMD5Context ctx; @@ -94,9 +94,9 @@ static void creds_init_128(struct dcinfo *dc, ****************************************************************************/ static void creds_init_64(struct dcinfo *dc, - const DOM_CHAL *clnt_chal_in, - const DOM_CHAL *srv_chal_in, - const unsigned char mach_pw[16]) + const struct netr_Credential *clnt_chal_in, + const struct netr_Credential *srv_chal_in, + const unsigned char mach_pw[16]) { uint32 sum[2]; unsigned char sum2[8]; @@ -177,10 +177,10 @@ static void creds_step(struct dcinfo *dc) void creds_server_init(uint32 neg_flags, struct dcinfo *dc, - DOM_CHAL *clnt_chal, - DOM_CHAL *srv_chal, + struct netr_Credential *clnt_chal, + struct netr_Credential *srv_chal, const unsigned char mach_pw[16], - DOM_CHAL *init_chal_out) + struct netr_Credential *init_chal_out) { DEBUG(10,("creds_server_init: neg_flags : %x\n", (unsigned int)neg_flags)); DEBUG(10,("creds_server_init: client chal : %s\n", credstr(clnt_chal->data) )); @@ -246,7 +246,7 @@ bool netlogon_creds_server_check(const struct dcinfo *dc, static void creds_reseed(struct dcinfo *dc) { - DOM_CHAL time_chal; + struct netr_Credential time_chal; SIVAL(time_chal.data, 0, IVAL(dc->seed_chal.data, 0) + dc->sequence + 1); SIVAL(time_chal.data, 4, IVAL(dc->seed_chal.data, 4)); @@ -274,7 +274,8 @@ bool creds_server_step(struct dcinfo *dc, const DOM_CRED *received_cred, DOM_CRE /* Create the outgoing credentials */ cred_out->timestamp.time = tmp_dc.sequence + 1; - cred_out->challenge = tmp_dc.srv_chal; + memcpy(&cred_out->challenge.data, tmp_dc.srv_chal.data, + sizeof(cred_out->challenge.data)); creds_reseed(&tmp_dc); @@ -324,10 +325,10 @@ bool netlogon_creds_server_step(struct dcinfo *dc, void creds_client_init(uint32 neg_flags, struct dcinfo *dc, - DOM_CHAL *clnt_chal, - DOM_CHAL *srv_chal, + struct netr_Credential *clnt_chal, + struct netr_Credential *srv_chal, const unsigned char mach_pw[16], - DOM_CHAL *init_chal_out) + struct netr_Credential *init_chal_out) { dc->sequence = time(NULL); @@ -406,7 +407,8 @@ void creds_client_step(struct dcinfo *dc, DOM_CRED *next_cred_out) creds_step(dc); creds_reseed(dc); - next_cred_out->challenge = dc->clnt_chal; + memcpy(&next_cred_out->challenge.data, dc->clnt_chal.data, + sizeof(next_cred_out->challenge.data)); next_cred_out->timestamp.time = dc->sequence; } diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index f15340ffec..5d6f32980d 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -251,17 +251,17 @@ static NTSTATUS rpccli_net_auth3(struct rpc_pipe_client *cli, ****************************************************************************/ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli, - const char *server_name, - const char *domain, - const char *clnt_name, - const char *machine_account, - const unsigned char machine_pwd[16], - uint32 sec_chan_type, - uint32 *neg_flags_inout) + const char *server_name, + const char *domain, + const char *clnt_name, + const char *machine_account, + const unsigned char machine_pwd[16], + enum netr_SchannelType sec_chan_type, + uint32_t *neg_flags_inout) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_CHAL clnt_chal_send; - DOM_CHAL srv_chal_recv; + struct netr_Credential clnt_chal_send; + struct netr_Credential srv_chal_recv; struct dcinfo *dc; SMB_ASSERT(cli->pipe_idx == PI_NETLOGON); @@ -288,13 +288,11 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli, generate_random_buffer(clnt_chal_send.data, 8); /* Get the server challenge. */ - result = rpccli_net_req_chal(cli, - cli->mem_ctx, - dc->remote_machine, - clnt_name, - &clnt_chal_send, - &srv_chal_recv); - + result = rpccli_netr_ServerReqChallenge(cli, cli->mem_ctx, + dc->remote_machine, + clnt_name, + &clnt_chal_send, + &srv_chal_recv); if (!NT_STATUS_IS_OK(result)) { return result; } @@ -307,20 +305,18 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli, machine_pwd, &clnt_chal_send); - /* + /* * Send client auth-2 challenge and receive server repy. */ - result = rpccli_net_auth2(cli, - cli->mem_ctx, - dc->remote_machine, - dc->mach_acct, - sec_chan_type, - clnt_name, - neg_flags_inout, - &clnt_chal_send, /* input. */ - &srv_chal_recv); /* output */ - + result = rpccli_netr_ServerAuthenticate2(cli, cli->mem_ctx, + dc->remote_machine, + dc->mach_acct, + sec_chan_type, + clnt_name, + &clnt_chal_send, /* input. */ + &srv_chal_recv, /* output. */ + neg_flags_inout); if (!NT_STATUS_IS_OK(result)) { return result; } @@ -330,7 +326,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli, * server received challenge. */ - if (!creds_client_check(dc, &srv_chal_recv)) { + if (!netlogon_creds_client_check(dc, &srv_chal_recv)) { /* * Server replied with bad credential. Fail. */ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 3e15d38043..017c4fe046 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -35,7 +35,7 @@ extern userdom_struct current_user_info; *************************************************************************/ static void init_net_r_req_chal(struct netr_Credential *r, - DOM_CHAL *srv_chal) + struct netr_Credential *srv_chal) { DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__)); @@ -406,7 +406,7 @@ NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, struct netr_ServerAuthenticate *r) { NTSTATUS status; - DOM_CHAL srv_chal_out; + struct netr_Credential srv_chal_out; if (!p->dc || !p->dc->challenge_sent) { return NT_STATUS_ACCESS_DENIED; @@ -465,7 +465,7 @@ NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, { NTSTATUS status; uint32_t srv_flgs; - DOM_CHAL srv_chal_out; + struct netr_Credential srv_chal_out; /* We use this as the key to store the creds: */ /* r->in.computer_name */ -- cgit From 26106d2e39bd09e85aab81735bd901b2c438f155 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 00:05:45 +0100 Subject: Remove unused marshalling for NET_REQ_CHAL and NET_AUTH2. Guenther (This used to be commit 2123aff75c8db431cb37d132058902287e740a85) --- source3/include/rpc_netlogon.h | 32 --------- source3/rpc_client/cli_netlogon.c | 84 +--------------------- source3/rpc_parse/parse_net.c | 142 -------------------------------------- 3 files changed, 2 insertions(+), 256 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index 3d7e11d1d6..e8414edd90 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -281,22 +281,6 @@ typedef struct neg_flags_info { uint32 neg_flags; /* negotiated flags */ } NEG_FLAGS; - -/* NET_Q_REQ_CHAL */ -typedef struct net_q_req_chal_info { - uint32 undoc_buffer; /* undocumented buffer pointer */ - UNISTR2 uni_logon_srv; /* logon server unicode string */ - UNISTR2 uni_logon_clnt; /* logon client unicode string */ - DOM_CHAL clnt_chal; /* client challenge */ -} NET_Q_REQ_CHAL; - - -/* NET_R_REQ_CHAL */ -typedef struct net_r_req_chal_info { - DOM_CHAL srv_chal; /* server challenge */ - NTSTATUS status; /* return code */ -} NET_R_REQ_CHAL; - /* NET_Q_AUTH */ typedef struct net_q_auth_info { DOM_LOG_INFO clnt_id; /* client identification info */ @@ -309,22 +293,6 @@ typedef struct net_r_auth_info { NTSTATUS status; /* return code */ } NET_R_AUTH; -/* NET_Q_AUTH_2 */ -typedef struct net_q_auth2_info { - DOM_LOG_INFO clnt_id; /* client identification info */ - DOM_CHAL clnt_chal; /* client-calculated credentials */ - - NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */ -} NET_Q_AUTH_2; - - -/* NET_R_AUTH_2 */ -typedef struct net_r_auth2_info { - DOM_CHAL srv_chal; /* server-calculated credentials */ - NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */ - NTSTATUS status; /* return code */ -} NET_R_AUTH_2; - /* NET_Q_AUTH_3 */ typedef struct net_q_auth3_info { DOM_LOG_INFO clnt_id; /* client identification info */ diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index 5d6f32980d..d84eb0173d 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -27,45 +27,7 @@ private data. Only call this via rpccli_netlogon_setup_creds(). JRA. */ -static NTSTATUS rpccli_net_req_chal(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *server_name, - const char *clnt_name, - const DOM_CHAL *clnt_chal_in, - DOM_CHAL *srv_chal_out) -{ - prs_struct qbuf, rbuf; - NET_Q_REQ_CHAL q; - NET_R_REQ_CHAL r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - /* create and send a MSRPC command with api NET_REQCHAL */ - - DEBUG(4,("cli_net_req_chal: LSA Request Challenge from %s to %s\n", - clnt_name, server_name)); - - /* store the parameters */ - init_q_req_chal(&q, server_name, clnt_name, clnt_chal_in); - - /* Marshall data and send request */ - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_REQCHAL, - q, r, - qbuf, rbuf, - net_io_q_req_chal, - net_io_r_req_chal, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - /* Return result */ - - if (NT_STATUS_IS_OK(result)) { - /* Store the returned server challenge. */ - *srv_chal_out = r.srv_chal; - } - - return result; -} +/* instead of rpccli_net_req_chal() we use rpccli_netr_ServerReqChallenge() now - gd */ #if 0 /**************************************************************************** @@ -147,50 +109,8 @@ password ?).\n", cli->cli->desthost )); encrypt of the server challenge originally received. JRA. ****************************************************************************/ -static NTSTATUS rpccli_net_auth2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *server_name, - const char *account_name, - uint16 sec_chan_type, - const char *computer_name, - uint32 *neg_flags_inout, - const DOM_CHAL *clnt_chal_in, - DOM_CHAL *srv_chal_out) -{ - prs_struct qbuf, rbuf; - NET_Q_AUTH_2 q; - NET_R_AUTH_2 r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - /* create and send a MSRPC command with api NET_AUTH2 */ - - DEBUG(4,("cli_net_auth2: srv:%s acct:%s sc:%x mc: %s neg: %x\n", - server_name, account_name, sec_chan_type, computer_name, - *neg_flags_inout)); - - /* store the parameters */ - - init_q_auth_2(&q, server_name, account_name, sec_chan_type, - computer_name, clnt_chal_in, *neg_flags_inout); - - /* turn parameters into data stream */ +/* instead of rpccli_net_auth2() we use rpccli_netr_ServerAuthenticate2() now - gd */ - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_AUTH2, - q, r, - qbuf, rbuf, - net_io_q_auth_2, - net_io_r_auth_2, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (NT_STATUS_IS_OK(result)) { - *srv_chal_out = r.srv_chal; - *neg_flags_inout = r.srv_flgs.neg_flags; - } - - return result; -} #if 0 /* not currebntly used */ /**************************************************************************** diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index b3a0997c7a..1de6c9d163 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -46,80 +46,6 @@ static bool net_io_neg_flags(const char *desc, NEG_FLAGS *neg, prs_struct *ps, i return True; } -/******************************************************************* - Inits an NET_Q_REQ_CHAL structure. -********************************************************************/ - -void init_q_req_chal(NET_Q_REQ_CHAL *q_c, - const char *logon_srv, const char *logon_clnt, - const DOM_CHAL *clnt_chal) -{ - DEBUG(5,("init_q_req_chal: %d\n", __LINE__)); - - q_c->undoc_buffer = 1; /* don't know what this buffer is */ - - init_unistr2(&q_c->uni_logon_srv, logon_srv , UNI_STR_TERMINATE); - init_unistr2(&q_c->uni_logon_clnt, logon_clnt, UNI_STR_TERMINATE); - - memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data)); - - DEBUG(5,("init_q_req_chal: %d\n", __LINE__)); -} - -/******************************************************************* - Reads or writes an NET_Q_REQ_CHAL structure. -********************************************************************/ - -bool net_io_q_req_chal(const char *desc, NET_Q_REQ_CHAL *q_c, prs_struct *ps, int depth) -{ - if (q_c == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_req_chal"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("undoc_buffer", ps, depth, &q_c->undoc_buffer)) - return False; - - if(!smb_io_unistr2("", &q_c->uni_logon_srv, True, ps, depth)) /* logon server unicode string */ - return False; - if(!smb_io_unistr2("", &q_c->uni_logon_clnt, True, ps, depth)) /* logon client unicode string */ - return False; - - if(!smb_io_chal("", &q_c->clnt_chal, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_r_req_chal(const char *desc, NET_R_REQ_CHAL *r_c, prs_struct *ps, int depth) -{ - if (r_c == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_req_chal"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal("", &r_c->srv_chal, ps, depth)) /* server challenge */ - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - - /******************************************************************* Reads or writes a structure. ********************************************************************/ @@ -167,74 +93,6 @@ bool net_io_r_auth(const char *desc, NET_R_AUTH *r_a, prs_struct *ps, int depth) return True; } -/******************************************************************* - Inits a NET_Q_AUTH_2 struct. -********************************************************************/ - -void init_q_auth_2(NET_Q_AUTH_2 *q_a, - const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name, - const DOM_CHAL *clnt_chal, uint32 clnt_flgs) -{ - DEBUG(5,("init_q_auth_2: %d\n", __LINE__)); - - init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name); - memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data)); - q_a->clnt_flgs.neg_flags = clnt_flgs; - - DEBUG(5,("init_q_auth_2: %d\n", __LINE__)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_q_auth_2(const char *desc, NET_Q_AUTH_2 *q_a, prs_struct *ps, int depth) -{ - if (q_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_auth_2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */ - return False; - if(!smb_io_chal("", &q_a->clnt_chal, ps, depth)) - return False; - if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_r_auth_2(const char *desc, NET_R_AUTH_2 *r_a, prs_struct *ps, int depth) -{ - if (r_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_auth_2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */ - return False; - if(!net_io_neg_flags("", &r_a->srv_flgs, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_a->status)) - return False; - - return True; -} - /******************************************************************* Inits a NET_Q_AUTH_3 struct. ********************************************************************/ -- cgit From c164f1dd804c6c554dd7f60b7000061da49a6879 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 13:27:10 +0100 Subject: Add init_netr_SamInfo3 routine. Guenther (This used to be commit bf598744c5af1a14abd25c316c243d00b94cbbe0) --- source3/Makefile.in | 3 +- source3/rpc_client/init_netlogon.c | 138 +++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 source3/rpc_client/init_netlogon.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index c3840d788d..5257c68403 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -411,7 +411,8 @@ LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \ rpc_client/cli_spoolss.o rpc_client/cli_spoolss_notify.o \ rpc_client/cli_svcctl.o \ rpc_client/init_samr.o \ - rpc_client/init_lsa.o + rpc_client/init_lsa.o \ + rpc_client/init_netlogon.o LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \ librpc/gen_ndr/cli_dfs.o \ diff --git a/source3/rpc_client/init_netlogon.c b/source3/rpc_client/init_netlogon.c new file mode 100644 index 0000000000..73e8717b46 --- /dev/null +++ b/source3/rpc_client/init_netlogon.c @@ -0,0 +1,138 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * 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 "includes.h" + +/******************************************************************* + inits a structure. +********************************************************************/ + +void init_netr_SamBaseInfo(struct netr_SamBaseInfo *r, + NTTIME last_logon, + NTTIME last_logoff, + NTTIME acct_expiry, + NTTIME last_password_change, + NTTIME allow_password_change, + NTTIME force_password_change, + const char *account_name, + const char *full_name, + const char *logon_script, + const char *profile_path, + const char *home_directory, + const char *home_drive, + uint16_t logon_count, + uint16_t bad_password_count, + uint32_t rid, + uint32_t primary_gid, + struct samr_RidWithAttributeArray groups, + uint32_t user_flags, + struct netr_UserSessionKey key, + const char *logon_server, + const char *domain, + struct dom_sid2 *domain_sid, + struct netr_LMSessionKey LMSessKey, + uint32_t acct_flags) +{ + r->last_logon = last_logon; + r->last_logoff = last_logoff; + r->acct_expiry = acct_expiry; + r->last_password_change = last_password_change; + r->allow_password_change = allow_password_change; + r->force_password_change = force_password_change; + init_lsa_String(&r->account_name, account_name); + init_lsa_String(&r->full_name, full_name); + init_lsa_String(&r->logon_script, logon_script); + init_lsa_String(&r->profile_path, profile_path); + init_lsa_String(&r->home_directory, home_directory); + init_lsa_String(&r->home_drive, home_drive); + r->logon_count = logon_count; + r->bad_password_count = bad_password_count; + r->rid = rid; + r->primary_gid = primary_gid; + r->groups = groups; + r->user_flags = user_flags; + r->key = key; + init_lsa_StringLarge(&r->logon_server, logon_server); + init_lsa_StringLarge(&r->domain, domain); + r->domain_sid = domain_sid; + r->LMSessKey = LMSessKey; + r->acct_flags = acct_flags; +} + +/******************************************************************* + inits a structure. +********************************************************************/ + +void init_netr_SamInfo3(struct netr_SamInfo3 *r, + NTTIME last_logon, + NTTIME last_logoff, + NTTIME acct_expiry, + NTTIME last_password_change, + NTTIME allow_password_change, + NTTIME force_password_change, + const char *account_name, + const char *full_name, + const char *logon_script, + const char *profile_path, + const char *home_directory, + const char *home_drive, + uint16_t logon_count, + uint16_t bad_password_count, + uint32_t rid, + uint32_t primary_gid, + struct samr_RidWithAttributeArray groups, + uint32_t user_flags, + struct netr_UserSessionKey key, + const char *logon_server, + const char *domain, + struct dom_sid2 *domain_sid, + struct netr_LMSessionKey LMSessKey, + uint32_t acct_flags, + uint32_t sidcount, + struct netr_SidAttr *sids) +{ + init_netr_SamBaseInfo(&r->base, + last_logon, + last_logoff, + acct_expiry, + last_password_change, + allow_password_change, + force_password_change, + account_name, + full_name, + logon_script, + profile_path, + home_directory, + home_drive, + logon_count, + bad_password_count, + rid, + primary_gid, + groups, + user_flags, + key, + logon_server, + domain, + domain_sid, + LMSessKey, + acct_flags); + r->sidcount = sidcount; + r->sids = sids; +} + -- cgit From f4b7d78d1165ecc4cf404ad2915432c7af12ddb3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 13:57:12 +0100 Subject: Fix IDL for netr_LogonSamLogon. Guenther (This used to be commit 188b81b3e053bbcb01bb13d9f185a45b75ac6365) --- source3/librpc/idl/netlogon.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index e5e789c965..be95652eb3 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -245,7 +245,7 @@ interface netlogon [in,unique] netr_Authenticator *credential, [in,out,unique] netr_Authenticator *return_authenticator, [in] uint16 logon_level, - [in] [switch_is(logon_level)] netr_LogonLevel logon, + [in,ref] [switch_is(logon_level)] netr_LogonLevel *logon, [in] uint16 validation_level, [out,ref] [switch_is(validation_level)] netr_Validation *validation, [out,ref] uint8 *authoritative -- cgit From 6df300bfb26e8d038c86779f205d2b6cf33d3336 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 13:58:38 +0100 Subject: Fix IDL for netr_LogonSamLogonEx. Guenther (This used to be commit 6564d78c4504c0191c25dba03c381a8b3591aab5) --- source3/librpc/idl/netlogon.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index be95652eb3..6095160ec7 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -1256,7 +1256,7 @@ interface netlogon [in,unique] [string,charset(UTF16)] uint16 *server_name, [in,unique] [string,charset(UTF16)] uint16 *computer_name, [in] uint16 logon_level, - [in] [switch_is(logon_level)] netr_LogonLevel logon, + [in,ref] [switch_is(logon_level)] netr_LogonLevel *logon, [in] uint16 validation_level, [out,ref] [switch_is(validation_level)] netr_Validation *validation, [out,ref] uint8 *authoritative, -- cgit From 0e70c5eea86138f24452db80e39a8d1d1b505c33 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 13:59:55 +0100 Subject: Re-run make idl. Guenther (This used to be commit 3a200957b2028198b9ee59f71da0f0b6601c95e2) --- source3/librpc/gen_ndr/cli_netlogon.c | 4 +-- source3/librpc/gen_ndr/cli_netlogon.h | 4 +-- source3/librpc/gen_ndr/ndr_netlogon.c | 50 ++++++++++++++++++++++++++--------- source3/librpc/gen_ndr/netlogon.h | 4 +-- 4 files changed, 44 insertions(+), 18 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_netlogon.c b/source3/librpc/gen_ndr/cli_netlogon.c index e8b4243713..2937cc09b9 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.c +++ b/source3/librpc/gen_ndr/cli_netlogon.c @@ -113,7 +113,7 @@ NTSTATUS rpccli_netr_LogonSamLogon(struct rpc_pipe_client *cli, struct netr_Authenticator *credential, struct netr_Authenticator *return_authenticator, uint16_t logon_level, - union netr_LogonLevel logon, + union netr_LogonLevel *logon, uint16_t validation_level, union netr_Validation *validation, uint8_t *authoritative) @@ -1974,7 +1974,7 @@ NTSTATUS rpccli_netr_LogonSamLogonEx(struct rpc_pipe_client *cli, const char *server_name, const char *computer_name, uint16_t logon_level, - union netr_LogonLevel logon, + union netr_LogonLevel *logon, uint16_t validation_level, union netr_Validation *validation, uint8_t *authoritative, diff --git a/source3/librpc/gen_ndr/cli_netlogon.h b/source3/librpc/gen_ndr/cli_netlogon.h index 706b7942b6..1fdc1f6c46 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.h +++ b/source3/librpc/gen_ndr/cli_netlogon.h @@ -22,7 +22,7 @@ NTSTATUS rpccli_netr_LogonSamLogon(struct rpc_pipe_client *cli, struct netr_Authenticator *credential, struct netr_Authenticator *return_authenticator, uint16_t logon_level, - union netr_LogonLevel logon, + union netr_LogonLevel *logon, uint16_t validation_level, union netr_Validation *validation, uint8_t *authoritative); @@ -298,7 +298,7 @@ NTSTATUS rpccli_netr_LogonSamLogonEx(struct rpc_pipe_client *cli, const char *server_name, const char *computer_name, uint16_t logon_level, - union netr_LogonLevel logon, + union netr_LogonLevel *logon, uint16_t validation_level, union netr_Validation *validation, uint8_t *authoritative, diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index a81ae097d6..3968bcd2ae 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -8196,8 +8196,11 @@ static enum ndr_err_code ndr_push_netr_LogonSamLogon(struct ndr_push *ndr, int f NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, r->in.return_authenticator)); } NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.logon_level)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); + if (r->in.logon == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.logon, r->in.logon_level)); + NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.validation_level)); } if (flags & NDR_OUT) { @@ -8229,6 +8232,7 @@ static enum ndr_err_code ndr_pull_netr_LogonSamLogon(struct ndr_pull *ndr, int f TALLOC_CTX *_mem_save_computer_name_0; TALLOC_CTX *_mem_save_credential_0; TALLOC_CTX *_mem_save_return_authenticator_0; + TALLOC_CTX *_mem_save_logon_0; TALLOC_CTX *_mem_save_validation_0; TALLOC_CTX *_mem_save_authoritative_0; if (flags & NDR_IN) { @@ -8295,8 +8299,14 @@ static enum ndr_err_code ndr_pull_netr_LogonSamLogon(struct ndr_pull *ndr, int f NDR_PULL_SET_MEM_CTX(ndr, _mem_save_return_authenticator_0, 0); } NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.logon_level)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.logon); + } + _mem_save_logon_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.logon, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.logon, r->in.logon_level)); + NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_logon_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.validation_level)); NDR_PULL_ALLOC(ndr, r->out.validation); ZERO_STRUCTP(r->out.validation); @@ -8371,8 +8381,11 @@ _PUBLIC_ void ndr_print_netr_LogonSamLogon(struct ndr_print *ndr, const char *na } ndr->depth--; ndr_print_uint16(ndr, "logon_level", r->in.logon_level); - ndr_print_set_switch_value(ndr, &r->in.logon, r->in.logon_level); - ndr_print_netr_LogonLevel(ndr, "logon", &r->in.logon); + ndr_print_ptr(ndr, "logon", r->in.logon); + ndr->depth++; + ndr_print_set_switch_value(ndr, r->in.logon, r->in.logon_level); + ndr_print_netr_LogonLevel(ndr, "logon", r->in.logon); + ndr->depth--; ndr_print_uint16(ndr, "validation_level", r->in.validation_level); ndr->depth--; } @@ -13382,8 +13395,11 @@ static enum ndr_err_code ndr_push_netr_LogonSamLogonEx(struct ndr_push *ndr, int NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.computer_name, ndr_charset_length(r->in.computer_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); } NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.logon_level)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); + if (r->in.logon == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.logon, r->in.logon_level)); + NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.validation_level)); if (r->in.flags == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -13415,6 +13431,7 @@ static enum ndr_err_code ndr_pull_netr_LogonSamLogonEx(struct ndr_pull *ndr, int uint32_t _ptr_computer_name; TALLOC_CTX *_mem_save_server_name_0; TALLOC_CTX *_mem_save_computer_name_0; + TALLOC_CTX *_mem_save_logon_0; TALLOC_CTX *_mem_save_validation_0; TALLOC_CTX *_mem_save_authoritative_0; TALLOC_CTX *_mem_save_flags_0; @@ -13458,8 +13475,14 @@ static enum ndr_err_code ndr_pull_netr_LogonSamLogonEx(struct ndr_pull *ndr, int NDR_PULL_SET_MEM_CTX(ndr, _mem_save_computer_name_0, 0); } NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.logon_level)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.logon); + } + _mem_save_logon_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.logon, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.logon, r->in.logon_level)); + NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_logon_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.validation_level)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.flags); @@ -13526,8 +13549,11 @@ _PUBLIC_ void ndr_print_netr_LogonSamLogonEx(struct ndr_print *ndr, const char * } ndr->depth--; ndr_print_uint16(ndr, "logon_level", r->in.logon_level); - ndr_print_set_switch_value(ndr, &r->in.logon, r->in.logon_level); - ndr_print_netr_LogonLevel(ndr, "logon", &r->in.logon); + ndr_print_ptr(ndr, "logon", r->in.logon); + ndr->depth++; + ndr_print_set_switch_value(ndr, r->in.logon, r->in.logon_level); + ndr_print_netr_LogonLevel(ndr, "logon", r->in.logon); + ndr->depth--; ndr_print_uint16(ndr, "validation_level", r->in.validation_level); ndr_print_ptr(ndr, "flags", r->in.flags); ndr->depth++; diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index 80434a1578..bff2d91a03 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -849,7 +849,7 @@ struct netr_LogonSamLogon { const char *computer_name;/* [unique,charset(UTF16)] */ struct netr_Authenticator *credential;/* [unique] */ uint16_t logon_level; - union netr_LogonLevel logon;/* [switch_is(logon_level)] */ + union netr_LogonLevel *logon;/* [ref,switch_is(logon_level)] */ uint16_t validation_level; struct netr_Authenticator *return_authenticator;/* [unique] */ } in; @@ -1435,7 +1435,7 @@ struct netr_LogonSamLogonEx { const char *server_name;/* [unique,charset(UTF16)] */ const char *computer_name;/* [unique,charset(UTF16)] */ uint16_t logon_level; - union netr_LogonLevel logon;/* [switch_is(logon_level)] */ + union netr_LogonLevel *logon;/* [ref,switch_is(logon_level)] */ uint16_t validation_level; uint32_t *flags;/* [ref] */ } in; -- cgit From 9416ec9e54f69a5bdf303f1c5551e4de138b6c08 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 14:02:03 +0100 Subject: Add generated ndr_eventlog leftover produced by recent pidl changes. Guenther (This used to be commit 0efaf76eecacd26edbc6e020230159eb5dd44b15) --- source3/librpc/gen_ndr/ndr_eventlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/ndr_eventlog.c b/source3/librpc/gen_ndr/ndr_eventlog.c index c6a77c54e5..1b58eb66b8 100644 --- a/source3/librpc/gen_ndr/ndr_eventlog.c +++ b/source3/librpc/gen_ndr/ndr_eventlog.c @@ -878,7 +878,7 @@ static enum ndr_err_code ndr_pull_eventlog_ReadEventLogW(struct ndr_pull *ndr, i return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); } NDR_PULL_ALLOC_N(ndr, r->out.data, r->in.number_of_bytes); - memset(r->out.data, 0, r->in.number_of_bytes * sizeof(*r->out.data)); + memset(r->out.data, 0, (r->in.number_of_bytes) * sizeof(*r->out.data)); NDR_PULL_ALLOC(ndr, r->out.sent_size); ZERO_STRUCTP(r->out.sent_size); NDR_PULL_ALLOC(ndr, r->out.real_size); -- cgit From 185842df528c9d39489f5ad629aa3b02b660f909 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 13:28:03 +0100 Subject: Use pidl for _netr_LogonSamLogon() and _netr_LogonSamLogonEx(). Guenther (This used to be commit 0d0b93995399bba0acf891fab107fd93ecec321f) --- source3/rpc_server/srv_netlog.c | 46 +----- source3/rpc_server/srv_netlog_nt.c | 291 ++++++++++++++++++------------------- 2 files changed, 147 insertions(+), 190 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 0e386c0de3..ea9408a2cf 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -100,28 +100,7 @@ static bool api_net_sam_logoff(pipes_struct *p) static bool api_net_sam_logon(pipes_struct *p) { - NET_Q_SAM_LOGON q_u; - NET_R_SAM_LOGON r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!net_io_q_sam_logon("", &q_u, data, 0)) { - DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); - return False; - } - - r_u.status = _net_sam_logon(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_sam_logon("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_sam_logon: Failed to marshall NET_R_SAM_LOGON.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGON); } /************************************************************************* @@ -157,28 +136,7 @@ static bool api_net_logon_ctrl(pipes_struct *p) static bool api_net_sam_logon_ex(pipes_struct *p) { - NET_Q_SAM_LOGON_EX q_u; - NET_R_SAM_LOGON_EX r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!net_io_q_sam_logon_ex("", &q_u, data, 0)) { - DEBUG(0, ("api_net_sam_logon_ex: Failed to unmarshall NET_Q_SAM_LOGON_EX.\n")); - return False; - } - - r_u.status = _net_sam_logon_ex(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_sam_logon_ex("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_sam_logon_ex: Failed to marshall NET_R_SAM_LOGON_EX.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGONEX); } /******************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 017c4fe046..c64e5b8d10 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -771,52 +771,53 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, } /************************************************************************* - _net_sam_logon + _netr_LogonSamLogon *************************************************************************/ -static NTSTATUS _net_sam_logon_internal(pipes_struct *p, - NET_Q_SAM_LOGON *q_u, - NET_R_SAM_LOGON *r_u, - bool process_creds) +NTSTATUS _netr_LogonSamLogon(pipes_struct *p, + struct netr_LogonSamLogon *r) { NTSTATUS status = NT_STATUS_OK; - NET_USER_INFO_3 *usr_info = NULL; - NET_ID_INFO_CTR *ctr = q_u->sam_id.ctr; - UNISTR2 *uni_samlogon_user = NULL; - UNISTR2 *uni_samlogon_domain = NULL; - UNISTR2 *uni_samlogon_workstation = NULL; + struct netr_SamInfo3 *sam3 = NULL; + union netr_LogonLevel *logon = r->in.logon; fstring nt_username, nt_domain, nt_workstation; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; struct samu *sampw; struct auth_context *auth_context = NULL; + bool process_creds = true; + + switch (p->hdr_req.opnum) { + case NDR_NETR_LOGONSAMLOGON: + process_creds = true; + break; + case NDR_NETR_LOGONSAMLOGONEX: + default: + process_creds = false; + } if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but obviously did not use it. */ - DEBUG(0,("_net_sam_logon_internal: client %s not using schannel for netlogon\n", + DEBUG(0,("_netr_LogonSamLogon: client %s not using schannel for netlogon\n", get_remote_machine_name() )); return NT_STATUS_ACCESS_DENIED; } - usr_info = TALLOC_P(p->mem_ctx, NET_USER_INFO_3); - if (!usr_info) { + sam3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo3); + if (!sam3) { return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP(usr_info); - /* store the user information, if there is any. */ - r_u->user = usr_info; - r_u->auth_resp = 1; /* authoritative response */ - if (q_u->validation_level != 2 && q_u->validation_level != 3) { - DEBUG(0,("_net_sam_logon: bad validation_level value %d.\n", (int)q_u->validation_level )); + r->out.validation->sam3 = sam3; + *r->out.authoritative = true; /* authoritative response */ + if (r->in.validation_level != 2 && r->in.validation_level != 3) { + DEBUG(0,("_netr_LogonSamLogon: bad validation_level value %d.\n", + (int)r->in.validation_level)); return NT_STATUS_ACCESS_DENIED; } - /* We handle the return of USER_INFO_2 instead of 3 in the parse return. Sucks, I know... */ - r_u->switch_value = q_u->validation_level; /* indicates type of validation user info */ - r_u->buffer_creds = 1; /* Ensure we always return server creds. */ if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; @@ -828,8 +829,8 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, /* Note this is the remote machine this request is coming from (member server), not neccessarily the workstation name the user is logging onto. */ - rpcstr_pull(remote_machine,q_u->sam_id.client.login.uni_comp_name.buffer, - sizeof(remote_machine),q_u->sam_id.client.login.uni_comp_name.uni_str_len*2,0); + + fstrcpy(remote_machine, r->in.computer_name); if (!p->dc) { /* Restore the saved state of the netlogon creds. */ @@ -850,8 +851,8 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } /* checks and updates credentials. creates reply credentials */ - if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " + if (!netlogon_creds_server_step(p->dc, r->in.credential, r->out.return_authenticator)) { + DEBUG(2,("_netr_LogonSamLogon: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", remote_machine, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; @@ -865,19 +866,24 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, unbecome_root(); } - switch (q_u->sam_id.logon_level) { + switch (r->in.logon_level) { case INTERACTIVE_LOGON_TYPE: - uni_samlogon_user = &ctr->auth.id1.uni_user_name; - uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; - - uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; + fstrcpy(nt_username, + logon->password->identity_info.account_name.string); + fstrcpy(nt_domain, + logon->password->identity_info.domain_name.string); + fstrcpy(nt_workstation, + logon->password->identity_info.workstation.string); DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; case NET_LOGON_TYPE: - uni_samlogon_user = &ctr->auth.id2.uni_user_name; - uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; - uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; + fstrcpy(nt_username, + logon->network->identity_info.account_name.string); + fstrcpy(nt_domain, + logon->network->identity_info.domain_name.string); + fstrcpy(nt_workstation, + logon->network->identity_info.workstation.string); DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); break; @@ -886,24 +892,23 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ - rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); - rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); - rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); - DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); - DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); + DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", + r->in.validation_level, nt_username)); status = NT_STATUS_OK; - switch (ctr->switch_value) { + switch (r->in.logon_level) { case NET_LOGON_TYPE: { const char *wksname = nt_workstation; - if (!NT_STATUS_IS_OK(status = make_auth_context_fixed(&auth_context, ctr->auth.id2.lm_chal))) { + status = make_auth_context_fixed(&auth_context, + logon->network->challenge); + if (!NT_STATUS_IS_OK(status)) { return status; } @@ -917,11 +922,11 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!make_user_info_netlogon_network(&user_info, nt_username, nt_domain, wksname, - ctr->auth.id2.param_ctrl, - ctr->auth.id2.lm_chal_resp.buffer, - ctr->auth.id2.lm_chal_resp.str_str_len, - ctr->auth.id2.nt_chal_resp.buffer, - ctr->auth.id2.nt_chal_resp.str_str_len)) { + logon->network->identity_info.parameter_control, + logon->network->lm.data, + logon->network->lm.length, + logon->network->nt.data, + logon->network->nt.length)) { status = NT_STATUS_NO_MEMORY; } break; @@ -943,10 +948,10 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!make_user_info_netlogon_interactive(&user_info, nt_username, nt_domain, nt_workstation, - ctr->auth.id1.param_ctrl, + logon->password->identity_info.parameter_control, chal, - ctr->auth.id1.lm_owf.data, - ctr->auth.id1.nt_owf.data, + logon->password->lmpassword.hash, + logon->password->ntpassword.hash, p->dc->sess_key)) { status = NT_STATUS_NO_MEMORY; } @@ -965,7 +970,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, (auth_context->free)(&auth_context); free_user_info(&user_info); - DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", + DEBUG(5,("_netr_LogonSamLogon: check_password returned status %s\n", nt_errstr(status))); /* Check account and password */ @@ -978,7 +983,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER) && !strequal(nt_domain, get_global_sam_name()) && !is_trusted_domain(nt_domain) ) - r_u->auth_resp = 0; /* We are not authoritative */ + *r->out.authoritative = false; /* We are not authoritative */ TALLOC_FREE(server_info); return status; @@ -986,7 +991,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (server_info->guest) { /* We don't like guest domain logons... */ - DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST " + DEBUG(5,("_netr_LogonSamLogon: Attempted domain logon as GUEST " "denied.\n")); TALLOC_FREE(server_info); return NT_STATUS_LOGON_FAILURE; @@ -1005,29 +1010,40 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, int num_gids = 0; const char *my_name; - unsigned char user_session_key[16]; - unsigned char lm_session_key[16]; + + struct netr_UserSessionKey user_session_key; + struct netr_LMSessionKey lm_session_key; unsigned char pipe_session_key[16]; - sampw = server_info->sam_account; + NTTIME last_logon, last_logoff, acct_expiry, last_password_change; + NTTIME allow_password_change, force_password_change; + struct samr_RidWithAttributeArray groups; + int i; + struct dom_sid2 *sid = NULL; - /* set up pointer indicating user/password failed to be - * found */ - usr_info->ptr_user_info = 0; + ZERO_STRUCT(user_session_key); + ZERO_STRUCT(lm_session_key); + + sampw = server_info->sam_account; user_sid = pdb_get_user_sid(sampw); group_sid = pdb_get_group_sid(sampw); if ((user_sid == NULL) || (group_sid == NULL)) { - DEBUG(1, ("_net_sam_logon: User without group or user SID\n")); + DEBUG(1, ("_netr_LogonSamLogon: User without group or user SID\n")); return NT_STATUS_UNSUCCESSFUL; } sid_copy(&domain_sid, user_sid); sid_split_rid(&domain_sid, &user_rid); + sid = sid_dup_talloc(p->mem_ctx, &domain_sid); + if (!sid) { + return NT_STATUS_NO_MEMORY; + } + if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) { - DEBUG(1, ("_net_sam_logon: user %s\\%s has user sid " + DEBUG(1, ("_netr_LogonSamLogon: user %s\\%s has user sid " "%s\n but group sid %s.\n" "The conflicting domain portions are not " "supported for NETLOGON calls\n", @@ -1054,9 +1070,9 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } if (server_info->user_session_key.length) { - memcpy(user_session_key, + memcpy(user_session_key.key, server_info->user_session_key.data, - MIN(sizeof(user_session_key), + MIN(sizeof(user_session_key.key), server_info->user_session_key.length)); if (process_creds) { /* Get the pipe session key from the creds. */ @@ -1068,13 +1084,13 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); } - SamOEMhash(user_session_key, pipe_session_key, 16); + SamOEMhash(user_session_key.key, pipe_session_key, 16); memset(pipe_session_key, '\0', 16); } if (server_info->lm_session_key.length) { - memcpy(lm_session_key, + memcpy(lm_session_key.key, server_info->lm_session_key.data, - MIN(sizeof(lm_session_key), + MIN(sizeof(lm_session_key.key), server_info->lm_session_key.length)); if (process_creds) { /* Get the pipe session key from the creds. */ @@ -1086,36 +1102,56 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); } - SamOEMhash(lm_session_key, pipe_session_key, 16); + SamOEMhash(lm_session_key.key, pipe_session_key, 16); memset(pipe_session_key, '\0', 16); } - init_net_user_info3(p->mem_ctx, usr_info, - user_rid, - group_rid, - pdb_get_username(sampw), - pdb_get_fullname(sampw), - pdb_get_homedir(sampw), - pdb_get_dir_drive(sampw), - pdb_get_logon_script(sampw), - pdb_get_profile_path(sampw), - pdb_get_logon_time(sampw), - get_time_t_max(), - get_time_t_max(), - pdb_get_pass_last_set_time(sampw), - pdb_get_pass_can_change_time(sampw), - pdb_get_pass_must_change_time(sampw), - 0, /* logon_count */ - 0, /* bad_pw_count */ - num_gids, /* uint32 num_groups */ - gids , /* DOM_GID *gids */ - NETLOGON_EXTRA_SIDS, /* uint32 user_flgs (?) */ - pdb_get_acct_ctrl(sampw), - server_info->user_session_key.length ? user_session_key : NULL, - server_info->lm_session_key.length ? lm_session_key : NULL, - my_name , /* char *logon_srv */ - pdb_get_domain(sampw), - &domain_sid); /* DOM_SID *dom_sid */ + groups.count = num_gids; + groups.rids = TALLOC_ARRAY(p->mem_ctx, struct samr_RidWithAttribute, + groups.count); + if (!groups.rids) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i < groups.count; i++) { + groups.rids[i].rid = gids[i].g_rid; + groups.rids[i].attributes = gids[i].attr; + } + + unix_to_nt_time(&last_logon, pdb_get_logon_time(sampw)); + unix_to_nt_time(&last_logoff, get_time_t_max()); + unix_to_nt_time(&acct_expiry, get_time_t_max()); + unix_to_nt_time(&last_password_change, pdb_get_pass_last_set_time(sampw)); + unix_to_nt_time(&allow_password_change, pdb_get_pass_can_change_time(sampw)); + unix_to_nt_time(&force_password_change, pdb_get_pass_must_change_time(sampw)); + + init_netr_SamInfo3(sam3, + last_logon, + last_logoff, + acct_expiry, + last_password_change, + allow_password_change, + force_password_change, + talloc_strdup(p->mem_ctx, pdb_get_username(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_fullname(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_logon_script(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_profile_path(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_homedir(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_dir_drive(sampw)), + 0, /* logon_count */ + 0, /* bad_password_count */ + user_rid, + group_rid, + groups, + NETLOGON_EXTRA_SIDS, + user_session_key, + my_name, + talloc_strdup(p->mem_ctx, pdb_get_domain(sampw)), + sid, + lm_session_key, + pdb_get_acct_ctrl(sampw), + 0, /* sidcount */ + NULL); /* struct netr_SidAttr *sids */ ZERO_STRUCT(user_session_key); ZERO_STRUCT(lm_session_key); } @@ -1124,25 +1160,14 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } /************************************************************************* - _net_sam_logon + _netr_LogonSamLogonEx + - no credential chaining. Map into net sam logon. *************************************************************************/ -NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) -{ - return _net_sam_logon_internal(p, q_u, r_u, True); -} - -/************************************************************************* - _net_sam_logon_ex - no credential chaining. Map into net sam logon. - *************************************************************************/ - -NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_LOGON_EX *r_u) +NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p, + struct netr_LogonSamLogonEx *r) { - NET_Q_SAM_LOGON q; - NET_R_SAM_LOGON r; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); + struct netr_LogonSamLogon q; /* Only allow this if the pipe is protected. */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { @@ -1151,26 +1176,20 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L return NT_STATUS_INVALID_PARAMETER; } - /* Map a NET_Q_SAM_LOGON_EX to NET_Q_SAM_LOGON. */ - q.validation_level = q_u->validation_level; - - /* Map a DOM_SAM_INFO_EX into a DOM_SAM_INFO with no creds. */ - q.sam_id.client.login = q_u->sam_id.client; - q.sam_id.logon_level = q_u->sam_id.logon_level; - q.sam_id.ctr = q_u->sam_id.ctr; - - r_u->status = _net_sam_logon_internal(p, &q, &r, False); + q.in.server_name = r->in.server_name; + q.in.computer_name = r->in.computer_name; + q.in.logon_level = r->in.logon_level; + q.in.logon = r->in.logon; + q.in.validation_level = r->in.validation_level; + /* we do not handle the flags */ + /* = r->in.flags; */ - if (!NT_STATUS_IS_OK(r_u->status)) { - return r_u->status; - } + q.out.validation = r->out.validation; + q.out.authoritative = r->out.authoritative; + /* we do not handle the flags */ + /* = r->out.flags; */ - /* Map the NET_R_SAM_LOGON to NET_R_SAM_LOGON_EX. */ - r_u->switch_value = r.switch_value; - r_u->user = r.user; - r_u->auth_resp = r.auth_resp; - r_u->flags = 0; /* FIXME ! */ - return r_u->status; + return _netr_LogonSamLogon(p, &q); } /************************************************************************* @@ -1216,16 +1235,6 @@ WERROR _netr_LogonUasLogoff(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_LogonSamLogon(pipes_struct *p, - struct netr_LogonSamLogon *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, struct netr_DatabaseDeltas *r) { @@ -1506,16 +1515,6 @@ WERROR _netr_DsrGetDcSiteCoverageW(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p, - struct netr_LogonSamLogonEx *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _netr_DsrEnumerateDomainTrusts(pipes_struct *p, struct netr_DsrEnumerateDomainTrusts *r) { -- cgit From b4989afbab6e795c08bda37e500898d86a943b94 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 13:42:12 +0100 Subject: YES! NETLOGON rpc server side migration to pidl finished. Guenther (This used to be commit 7845a0d9a8f938c1be888ab2d9aa6c35d6f1dbad) --- source3/Makefile.in | 2 +- source3/configure.in | 4 +- source3/rpc_server/srv_netlog.c | 169 ---------------------------------------- source3/rpc_server/srv_pipe.c | 2 +- 4 files changed, 4 insertions(+), 173 deletions(-) delete mode 100644 source3/rpc_server/srv_netlog.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 5257c68403..210db6f0ff 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -482,7 +482,7 @@ REG_API_OBJ = registry/reg_api.o \ RPC_LSA_OBJ = rpc_server/srv_lsa.o rpc_server/srv_lsa_nt.o librpc/gen_ndr/srv_lsa.o -RPC_NETLOG_OBJ = rpc_server/srv_netlog.o rpc_server/srv_netlog_nt.o \ +RPC_NETLOG_OBJ = rpc_server/srv_netlog_nt.o \ librpc/gen_ndr/srv_netlogon.o RPC_SAMR_OBJ = rpc_server/srv_samr_nt.o \ diff --git a/source3/configure.in b/source3/configure.in index aa024c6e59..1f8efb9675 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -745,7 +745,7 @@ AC_SUBST(DYNEXP) dnl Add modules that have to be built by default here dnl These have to be built static: -default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template" +default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template" dnl These are preferably build shared, and static if dlopen() is not available default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_syncops vfs_xattr_tdb vfs_streams_xattr" @@ -6616,7 +6616,7 @@ SMB_MODULE(rpc_dssetup, \$(RPC_DSSETUP_OBJ), "bin/librpc_dssetup.$SHLIBEXT", RPC SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC) SMB_MODULE(rpc_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$SHLIBEXT", RPC) SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC) -SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC) +SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC) SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC) SMB_MODULE(rpc_srvsvc2, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc2.$SHLIBEXT", RPC) SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC) diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c deleted file mode 100644 index ea9408a2cf..0000000000 --- a/source3/rpc_server/srv_netlog.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jeremy Allison 1998-2001, - * Copyright (C) Jim McDonough 2003. - * - * 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 . - */ - -/* This is the interface to the netlogon pipe. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - ********************************************************************/ - -static bool proxy_netr_call(pipes_struct *p, uint8 opnum) -{ - struct api_struct *fns; - int n_fns; - - netlogon_get_pipe_fns(&fns, &n_fns); - - if (opnum >= n_fns) { - return false; - } - - if (fns[opnum].opnum != opnum) { - smb_panic("NETLOGON function table not sorted"); - } - - return fns[opnum].fn(p); -} - -/************************************************************************* - api_net_req_chal: - *************************************************************************/ - -static bool api_net_req_chal(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_SERVERREQCHALLENGE); -} - -/************************************************************************* - api_net_auth: - *************************************************************************/ - -static bool api_net_auth(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_SERVERAUTHENTICATE); -} - -/************************************************************************* - api_net_auth_2: - *************************************************************************/ - -static bool api_net_auth_2(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_SERVERAUTHENTICATE2); -} - -/************************************************************************* - api_net_srv_pwset: - *************************************************************************/ - -static bool api_net_srv_pwset(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_SERVERPASSWORDSET); -} - -/************************************************************************* - api_net_sam_logoff: - *************************************************************************/ - -static bool api_net_sam_logoff(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGOFF); -} - -/************************************************************************* - api_net_sam_logon: - *************************************************************************/ - -static bool api_net_sam_logon(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGON); -} - -/************************************************************************* - api_net_trust_dom_list: - *************************************************************************/ - -static bool api_net_trust_dom_list(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_NETRENUMERATETRUSTEDDOMAINS); -} - -/************************************************************************* - api_net_logon_ctrl2: - *************************************************************************/ - -static bool api_net_logon_ctrl2(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONCONTROL2); -} - -/************************************************************************* - api_net_logon_ctrl: - *************************************************************************/ - -static bool api_net_logon_ctrl(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONCONTROL); -} - -/************************************************************************* - api_net_sam_logon_ex: - *************************************************************************/ - -static bool api_net_sam_logon_ex(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGONEX); -} - -/******************************************************************* - array of \PIPE\NETLOGON operations - ********************************************************************/ -static struct api_struct api_net_cmds [] = - { - { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, - { "NET_AUTH" , NET_AUTH , api_net_auth }, - { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, - { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, - { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, - { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, - { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, - { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, - { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }, - { "NET_SAMLOGON_EX" , NET_SAMLOGON_EX , api_net_sam_logon_ex }, - }; - -void netlog_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_net_cmds; - *n_fns = sizeof(api_net_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_net_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "NETLOGON", "lsass", api_net_cmds, - sizeof(api_net_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a671f89238..de9f22da1d 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2385,7 +2385,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) samr_get_pipe_fns( &cmds, &n_cmds ); break; case PI_NETLOGON: - netlog_get_pipe_fns( &cmds, &n_cmds ); + netlogon_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SRVSVC: srvsvc2_get_pipe_fns( &cmds, &n_cmds ); -- cgit From b6285fc0526ff15250242489047bb8d49a1948e6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 15:14:04 +0100 Subject: Remove unused creds_server_check and creds_server_step. Guenther (This used to be commit 2fb73a3545634982d17d3823cb629f06c5779fc0) --- source3/libsmb/credentials.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/credentials.c b/source3/libsmb/credentials.c index 328b931df0..2dcbdf3cf9 100644 --- a/source3/libsmb/credentials.c +++ b/source3/libsmb/credentials.c @@ -213,18 +213,6 @@ void creds_server_init(uint32 neg_flags, Check a credential sent by the client. ****************************************************************************/ -bool creds_server_check(const struct dcinfo *dc, const DOM_CHAL *rcv_cli_chal_in) -{ - if (memcmp(dc->clnt_chal.data, rcv_cli_chal_in->data, 8)) { - DEBUG(5,("creds_server_check: challenge : %s\n", credstr(rcv_cli_chal_in->data))); - DEBUG(5,("calculated: %s\n", credstr(dc->clnt_chal.data))); - DEBUG(2,("creds_server_check: credentials check failed.\n")); - return False; - } - DEBUG(10,("creds_server_check: credentials check OK.\n")); - return True; -} - bool netlogon_creds_server_check(const struct dcinfo *dc, const struct netr_Credential *rcv_cli_chal_in) { @@ -260,35 +248,6 @@ static void creds_reseed(struct dcinfo *dc) Step the server credential chain one forward. ****************************************************************************/ -bool creds_server_step(struct dcinfo *dc, const DOM_CRED *received_cred, DOM_CRED *cred_out) -{ - bool ret; - struct dcinfo tmp_dc = *dc; - - /* Do all operations on a temporary copy of the dc, - which we throw away if the checks fail. */ - - tmp_dc.sequence = received_cred->timestamp.time; - - creds_step(&tmp_dc); - - /* Create the outgoing credentials */ - cred_out->timestamp.time = tmp_dc.sequence + 1; - memcpy(&cred_out->challenge.data, tmp_dc.srv_chal.data, - sizeof(cred_out->challenge.data)); - - creds_reseed(&tmp_dc); - - ret = creds_server_check(&tmp_dc, &received_cred->challenge); - if (!ret) { - return False; - } - - /* creds step succeeded - replace the current creds. */ - *dc = tmp_dc; - return True; -} - bool netlogon_creds_server_step(struct dcinfo *dc, const struct netr_Authenticator *received_cred, struct netr_Authenticator *cred_out) -- cgit From dd65a349350717eb17257ccf281561dd878ead12 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 16:04:01 +0100 Subject: Use rpccli_netr_ServerPasswordSet in "just_change_the_password()". Guenther (This used to be commit 33f91c894488687a42500e751eb9016d99d9129c) --- source3/libsmb/trusts_util.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/trusts_util.c b/source3/libsmb/trusts_util.c index 11f691bee6..1e92bf21de 100644 --- a/source3/libsmb/trusts_util.c +++ b/source3/libsmb/trusts_util.c @@ -58,7 +58,32 @@ static NTSTATUS just_change_the_password(struct rpc_pipe_client *cli, TALLOC_CTX } } - result = rpccli_net_srv_pwset(cli, mem_ctx, global_myname(), new_trust_passwd_hash); + { + struct netr_Authenticator clnt_creds, srv_cred; + struct samr_Password new_password; + + netlogon_creds_client_step(cli->dc, &clnt_creds); + + cred_hash3(new_password.hash, + new_trust_passwd_hash, + cli->dc->sess_key, 1); + + result = rpccli_netr_ServerPasswordSet(cli, mem_ctx, + cli->dc->remote_machine, + cli->dc->mach_acct, + sec_channel_type, + global_myname(), + &clnt_creds, + &srv_cred, + &new_password); + + /* Always check returned credentials. */ + if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) { + DEBUG(0,("rpccli_netr_ServerPasswordSet: " + "credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } + } if (!NT_STATUS_IS_OK(result)) { DEBUG(0,("just_change_the_password: unable to change password (%s)!\n", -- cgit From 697f8904e7ec90aa5817c7903bf266e8d04c96b0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 16:06:55 +0100 Subject: Remove unused marshalling for NET_SRV_PWSET. Guenther (This used to be commit e48737f04d2324b604f3290904ec6163a6242ae5) --- source3/include/rpc_netlogon.h | 13 -------- source3/rpc_client/cli_netlogon.c | 48 --------------------------- source3/rpc_parse/parse_net.c | 68 --------------------------------------- 3 files changed, 129 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index e8414edd90..044368d613 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -309,19 +309,6 @@ typedef struct net_r_auth3_info { } NET_R_AUTH_3; -/* NET_Q_SRV_PWSET */ -typedef struct net_q_srv_pwset_info { - DOM_CLNT_INFO clnt_id; /* client identification/authentication info */ - uint8 pwd[16]; /* new password - undocumented. */ -} NET_Q_SRV_PWSET; - -/* NET_R_SRV_PWSET */ -typedef struct net_r_srv_pwset_info { - DOM_CRED srv_cred; /* server-calculated credentials */ - - NTSTATUS status; /* return code */ -} NET_R_SRV_PWSET; - /* NET_ID_INFO_2 */ typedef struct net_network_info_2 { uint32 ptr_id_info2; /* pointer to id_info_2 */ diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index d84eb0173d..b50a03359e 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -577,51 +577,3 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, return result; } - -/*************************************************************************** -LSA Server Password Set. -****************************************************************************/ - -NTSTATUS rpccli_net_srv_pwset(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - const char *machine_name, const uint8 hashed_mach_pwd[16]) -{ - prs_struct rbuf; - prs_struct qbuf; - DOM_CRED clnt_creds; - NET_Q_SRV_PWSET q; - NET_R_SRV_PWSET r; - uint16 sec_chan_type = 2; - NTSTATUS result; - - creds_client_step(cli->dc, &clnt_creds); - - DEBUG(4,("cli_net_srv_pwset: srv:%s acct:%s sc: %d mc: %s\n", - cli->dc->remote_machine, cli->dc->mach_acct, sec_chan_type, machine_name)); - - /* store the parameters */ - init_q_srv_pwset(&q, cli->dc->remote_machine, (const char *)cli->dc->sess_key, - cli->dc->mach_acct, sec_chan_type, machine_name, - &clnt_creds, hashed_mach_pwd); - - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_SRVPWSET, - q, r, - qbuf, rbuf, - net_io_q_srv_pwset, - net_io_r_srv_pwset, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - - if (!NT_STATUS_IS_OK(result)) { - /* report error code */ - DEBUG(0,("cli_net_srv_pwset: %s\n", nt_errstr(result))); - } - - /* Always check returned credentials. */ - if (!creds_client_check(cli->dc, &r.srv_cred.challenge)) { - DEBUG(0,("rpccli_net_srv_pwset: credentials chain check failed\n")); - return NT_STATUS_ACCESS_DENIED; - } - - return result; -} diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index 1de6c9d163..eab8e9b00d 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -164,74 +164,6 @@ bool net_io_r_auth_3(const char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int de } -/******************************************************************* - Inits a NET_Q_SRV_PWSET. -********************************************************************/ - -void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s, - const char *logon_srv, const char *sess_key, const char *acct_name, - uint16 sec_chan, const char *comp_name, - DOM_CRED *cred, const uchar hashed_mach_pwd[16]) -{ - unsigned char nt_cypher[16]; - - DEBUG(5,("init_q_srv_pwset\n")); - - /* Process the new password. */ - cred_hash3( nt_cypher, hashed_mach_pwd, (const unsigned char *)sess_key, 1); - - init_clnt_info(&q_s->clnt_id, logon_srv, acct_name, sec_chan, comp_name, cred); - - memcpy(q_s->pwd, nt_cypher, sizeof(q_s->pwd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_q_srv_pwset(const char *desc, NET_Q_SRV_PWSET *q_s, prs_struct *ps, int depth) -{ - if (q_s == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_srv_pwset"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_clnt_info("", &q_s->clnt_id, ps, depth)) /* client identification/authentication info */ - return False; - if(!prs_uint8s (False, "pwd", ps, depth, q_s->pwd, 16)) /* new password - undocumented */ - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_r_srv_pwset(const char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int depth) -{ - if (r_s == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_srv_pwset"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_cred("", &r_s->srv_cred, ps, depth)) /* server challenge */ - return False; - - if(!prs_ntstatus("status", ps, depth, &r_s->status)) - return False; - - return True; -} - /************************************************************************* Init DOM_SID2 array from a string containing multiple sids *************************************************************************/ -- cgit From 033dd7b08bbb4c0817e1c3fb0876f34af839359d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 16:08:34 +0100 Subject: Remove unused netlogon delta defines. Guenther (This used to be commit 2c235d2f37522e3a836524a6a165a930bff099a4) --- source3/include/rpc_netlogon.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index 044368d613..e9d9c30497 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -45,24 +45,6 @@ #define NET_DSR_GETDCNAMEEX2 0x22 #define NET_SAMLOGON_EX 0x27 -/* Returned delta types */ -#define SAM_DELTA_DOMAIN_INFO 0x01 -#define SAM_DELTA_GROUP_INFO 0x02 -#define SAM_DELTA_RENAME_GROUP 0x04 -#define SAM_DELTA_ACCOUNT_INFO 0x05 -#define SAM_DELTA_RENAME_USER 0x07 -#define SAM_DELTA_GROUP_MEM 0x08 -#define SAM_DELTA_ALIAS_INFO 0x09 -#define SAM_DELTA_RENAME_ALIAS 0x0b -#define SAM_DELTA_ALIAS_MEM 0x0c -#define SAM_DELTA_POLICY_INFO 0x0d -#define SAM_DELTA_TRUST_DOMS 0x0e -#define SAM_DELTA_PRIVS_INFO 0x10 /* DT_DELTA_ACCOUNTS */ -#define SAM_DELTA_SECRET_INFO 0x12 -#define SAM_DELTA_DELETE_GROUP 0x14 -#define SAM_DELTA_DELETE_USER 0x15 -#define SAM_DELTA_MODIFIED_COUNT 0x16 - /* flags use when sending a NETLOGON_CONTROL request */ #define NETLOGON_CONTROL_SYNC 0x2 -- cgit From 44bf22911a785c8d28caa26f40bd35ae84cef3f4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 16 Feb 2008 20:29:49 +0100 Subject: Remove unused code, make fns static (This used to be commit 5c762c6d57dce1016ebe2613a75b492eeac84c3d) --- source3/rpc_parse/parse_sec.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'source3') diff --git a/source3/rpc_parse/parse_sec.c b/source3/rpc_parse/parse_sec.c index 6ea128d3a4..c71b31086a 100644 --- a/source3/rpc_parse/parse_sec.c +++ b/source3/rpc_parse/parse_sec.c @@ -26,29 +26,12 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_PARSE -/******************************************************************* - Reads or writes a SEC_ACCESS structure. -********************************************************************/ - -bool sec_io_access(const char *desc, SEC_ACCESS *t, prs_struct *ps, int depth) -{ - if (t == NULL) - return False; - - prs_debug(ps, depth, desc, "sec_io_access"); - depth++; - - if(!prs_uint32("mask", ps, depth, t)) - return False; - - return True; -} - /******************************************************************* Reads or writes a SEC_ACE structure. ********************************************************************/ -bool sec_io_ace(const char *desc, SEC_ACE *psa, prs_struct *ps, int depth) +static bool sec_io_ace(const char *desc, SEC_ACE *psa, prs_struct *ps, + int depth) { uint32 old_offset; uint32 offset_ace_size; @@ -130,7 +113,8 @@ bool sec_io_ace(const char *desc, SEC_ACE *psa, prs_struct *ps, int depth) for you as it reads them. ********************************************************************/ -bool sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth) +static bool sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, + int depth) { unsigned int i; uint32 old_offset; -- cgit From c013ff7902981f3720d7a55e446a310623ca7bfc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 17 Feb 2008 01:09:15 +0100 Subject: Add missing dependency to libtdb to libnss_wins.so Michael (This used to be commit 05e63993184f084139cd9536ae1a6445b601fa1f) --- source3/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 210db6f0ff..6a7ad28324 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1631,10 +1631,10 @@ bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARE @$(SHLD) $(WINBIND_NSS_LDSHFLAGS) -o $@ $(WINBIND_NSS_OBJ) \ @WINBIND_NSS_EXTRA_LIBS@ @WINBIND_NSS_PTHREAD@ @SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@ -@WINBIND_WINS_NSS@: $(BINARY_PREREQS) $(WINBIND_WINS_NSS_OBJ) +@WINBIND_WINS_NSS@: $(BINARY_PREREQS) $(WINBIND_WINS_NSS_OBJ) @LIBTDB_SHARED@ @echo "Linking $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_WINS_NSS_OBJ) \ - $(LDAP_LIBS) $(KRB5LIBS) $(LIBS) \ + $(LDAP_LIBS) $(KRB5LIBS) $(LIBS) @LIBTDB_LIBS@ \ @SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@ bin/winbind_krb5_locator.@SHLIBEXT@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OBJ) -- cgit From f47d642ca71ff5e257638f77c826cc213969a005 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 17:06:23 +0100 Subject: Add krb5pac IDL from samba4. Guenther (This used to be commit dc2e563e1fe5a18dc799e195d89199a59e3e05a7) --- source3/Makefile.in | 6 +- source3/include/smb.h | 1 + source3/librpc/gen_ndr/krb5pac.h | 116 +++++ source3/librpc/gen_ndr/ndr_krb5pac.c | 840 +++++++++++++++++++++++++++++++++++ source3/librpc/idl/krb5pac.idl | 98 ++++ source3/librpc/ndr/ndr_krb5pac.c | 141 ++++++ 6 files changed, 1200 insertions(+), 2 deletions(-) create mode 100644 source3/librpc/gen_ndr/krb5pac.h create mode 100644 source3/librpc/gen_ndr/ndr_krb5pac.c create mode 100644 source3/librpc/idl/krb5pac.idl create mode 100644 source3/librpc/ndr/ndr_krb5pac.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 6a7ad28324..a1b8089d82 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -382,7 +382,9 @@ LIBADS_OBJ = libads/ldap.o libads/ldap_printer.o \ libads/disp_sec.o libads/ads_utils.o libads/ldap_utils.o \ libads/cldap.o libads/ldap_schema.o libads/util.o libads/ndr.o -LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o +LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o \ + librpc/ndr/ndr_krb5pac.o \ + librpc/gen_ndr/ndr_krb5pac.o SECRETS_OBJ = passdb/secrets.o passdb/machine_sid.o @@ -1118,7 +1120,7 @@ modules: SHOWFLAGS $(MODULES) IDL_FILES = unixinfo.idl lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \ epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \ - dssetup.idl + dssetup.idl krb5pac.idl idl: @IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \ diff --git a/source3/include/smb.h b/source3/include/smb.h index 3e0c997997..5e524eed01 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -308,6 +308,7 @@ extern const DATA_BLOB data_blob_null; #include "librpc/gen_ndr/samr.h" #include "librpc/gen_ndr/dssetup.h" #include "librpc/gen_ndr/libnet_join.h" +#include "librpc/gen_ndr/krb5pac.h" struct lsa_dom_info { bool valid; diff --git a/source3/librpc/gen_ndr/krb5pac.h b/source3/librpc/gen_ndr/krb5pac.h new file mode 100644 index 0000000000..a0d75fdd88 --- /dev/null +++ b/source3/librpc/gen_ndr/krb5pac.h @@ -0,0 +1,116 @@ +/* header auto-generated by pidl */ + +#include + +#include "librpc/gen_ndr/security.h" +#include "librpc/gen_ndr/netlogon.h" +#include "librpc/gen_ndr/samr.h" +#ifndef _HEADER_krb5pac +#define _HEADER_krb5pac + +struct PAC_LOGON_NAME { + NTTIME logon_time; + uint16_t size;/* [value(2*strlen_m(account_name))] */ + const char *account_name;/* [charset(UTF16)] */ +}; + +struct PAC_SIGNATURE_DATA { + uint32_t type; + DATA_BLOB signature;/* [flag(LIBNDR_FLAG_REMAINING)] */ +}/* [public,flag(LIBNDR_PRINT_ARRAY_HEX)] */; + +struct PAC_LOGON_INFO { + struct netr_SamInfo3 info3; + struct dom_sid2 *res_group_dom_sid;/* [unique] */ + struct samr_RidWithAttributeArray res_groups; +}/* [gensize] */; + +struct PAC_LOGON_INFO_CTR { + uint32_t unknown1;/* [value(0x00081001)] */ + uint32_t unknown2;/* [value(0xCCCCCCCC)] */ + uint32_t _ndr_size;/* [value(NDR_ROUND(ndr_size_PAC_LOGON_INFO(info,ndr->flags)+4,8))] */ + uint32_t unknown3;/* [value(0x00000000)] */ + struct PAC_LOGON_INFO *info;/* [unique] */ +}/* [public] */; + +enum PAC_TYPE +#ifndef USE_UINT_ENUMS + { + PAC_TYPE_LOGON_INFO=1, + PAC_TYPE_SRV_CHECKSUM=6, + PAC_TYPE_KDC_CHECKSUM=7, + PAC_TYPE_LOGON_NAME=10, + PAC_TYPE_CONSTRAINED_DELEGATION=11 +} +#else + { __donnot_use_enum_PAC_TYPE=0x7FFFFFFF} +#define PAC_TYPE_LOGON_INFO ( 1 ) +#define PAC_TYPE_SRV_CHECKSUM ( 6 ) +#define PAC_TYPE_KDC_CHECKSUM ( 7 ) +#define PAC_TYPE_LOGON_NAME ( 10 ) +#define PAC_TYPE_CONSTRAINED_DELEGATION ( 11 ) +#endif +; + +union PAC_INFO { + struct PAC_LOGON_INFO_CTR logon_info;/* [case(PAC_TYPE_LOGON_INFO)] */ + struct PAC_SIGNATURE_DATA srv_cksum;/* [case(PAC_TYPE_SRV_CHECKSUM)] */ + struct PAC_SIGNATURE_DATA kdc_cksum;/* [case(PAC_TYPE_KDC_CHECKSUM)] */ + struct PAC_LOGON_NAME logon_name;/* [case(PAC_TYPE_LOGON_NAME)] */ +}/* [gensize,nodiscriminant,public] */; + +struct PAC_BUFFER { + enum PAC_TYPE type; + uint32_t _ndr_size;/* [value(_ndr_size_PAC_INFO(info,type,0))] */ + union PAC_INFO *info;/* [relative,subcontext_size(_subcontext_size_PAC_INFO(r,ndr->flags)),subcontext(0),switch_is(type),flag(LIBNDR_FLAG_ALIGN8)] */ + uint32_t _pad;/* [value(0)] */ +}/* [noprint,nopull,public,nopush] */; + +struct PAC_DATA { + uint32_t num_buffers; + uint32_t version; + struct PAC_BUFFER *buffers; +}/* [public] */; + +struct DATA_BLOB_REM { + DATA_BLOB remaining;/* [flag(LIBNDR_FLAG_REMAINING)] */ +}; + +struct PAC_BUFFER_RAW { + enum PAC_TYPE type; + uint32_t ndr_size; + struct DATA_BLOB_REM *info;/* [relative,subcontext_size(NDR_ROUND(ndr_size,8)),subcontext(0),flag(LIBNDR_FLAG_ALIGN8)] */ + uint32_t _pad;/* [value(0)] */ +}/* [public] */; + +struct PAC_DATA_RAW { + uint32_t num_buffers; + uint32_t version; + struct PAC_BUFFER_RAW *buffers; +}/* [public] */; + + +struct decode_pac { + struct { + struct PAC_DATA pac; + } in; + +}; + + +struct decode_pac_raw { + struct { + struct PAC_DATA_RAW pac; + } in; + +}; + + +struct decode_login_info { + struct { + struct PAC_LOGON_INFO logon_info; + } in; + +}; + +#endif /* _HEADER_krb5pac */ diff --git a/source3/librpc/gen_ndr/ndr_krb5pac.c b/source3/librpc/gen_ndr/ndr_krb5pac.c new file mode 100644 index 0000000000..722e7acf84 --- /dev/null +++ b/source3/librpc/gen_ndr/ndr_krb5pac.c @@ -0,0 +1,840 @@ +/* parser auto-generated by pidl */ + +#include "includes.h" +#include "librpc/gen_ndr/ndr_krb5pac.h" + +#include "librpc/gen_ndr/ndr_security.h" +#include "librpc/gen_ndr/ndr_netlogon.h" +#include "librpc/gen_ndr/ndr_samr.h" +static enum ndr_err_code ndr_push_PAC_LOGON_NAME(struct ndr_push *ndr, int ndr_flags, const struct PAC_LOGON_NAME *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->logon_time)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 2 * strlen_m(r->account_name))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->account_name, 2 * strlen_m(r->account_name), sizeof(uint8_t), CH_UTF16)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PAC_LOGON_NAME(struct ndr_pull *ndr, int ndr_flags, struct PAC_LOGON_NAME *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->logon_time)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->account_name, r->size, sizeof(uint8_t), CH_UTF16)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_LOGON_NAME(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_NAME *r) +{ + ndr_print_struct(ndr, name, "PAC_LOGON_NAME"); + ndr->depth++; + ndr_print_NTTIME(ndr, "logon_time", r->logon_time); + ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * strlen_m(r->account_name):r->size); + ndr_print_string(ndr, "account_name", r->account_name); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_PAC_SIGNATURE_DATA(struct ndr_push *ndr, int ndr_flags, const struct PAC_SIGNATURE_DATA *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->type)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->signature)); + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_PAC_SIGNATURE_DATA(struct ndr_pull *ndr, int ndr_flags, struct PAC_SIGNATURE_DATA *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->type)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->signature)); + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_SIGNATURE_DATA(struct ndr_print *ndr, const char *name, const struct PAC_SIGNATURE_DATA *r) +{ + ndr_print_struct(ndr, name, "PAC_SIGNATURE_DATA"); + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + ndr->depth++; + ndr_print_uint32(ndr, "type", r->type); + ndr_print_DATA_BLOB(ndr, "signature", r->signature); + ndr->depth--; + ndr->flags = _flags_save_STRUCT; + } +} + +static enum ndr_err_code ndr_push_PAC_LOGON_INFO(struct ndr_push *ndr, int ndr_flags, const struct PAC_LOGON_INFO *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_netr_SamInfo3(ndr, NDR_SCALARS, &r->info3)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->res_group_dom_sid)); + NDR_CHECK(ndr_push_samr_RidWithAttributeArray(ndr, NDR_SCALARS, &r->res_groups)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_netr_SamInfo3(ndr, NDR_BUFFERS, &r->info3)); + if (r->res_group_dom_sid) { + NDR_CHECK(ndr_push_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->res_group_dom_sid)); + } + NDR_CHECK(ndr_push_samr_RidWithAttributeArray(ndr, NDR_BUFFERS, &r->res_groups)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PAC_LOGON_INFO(struct ndr_pull *ndr, int ndr_flags, struct PAC_LOGON_INFO *r) +{ + uint32_t _ptr_res_group_dom_sid; + TALLOC_CTX *_mem_save_res_group_dom_sid_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_netr_SamInfo3(ndr, NDR_SCALARS, &r->info3)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_res_group_dom_sid)); + if (_ptr_res_group_dom_sid) { + NDR_PULL_ALLOC(ndr, r->res_group_dom_sid); + } else { + r->res_group_dom_sid = NULL; + } + NDR_CHECK(ndr_pull_samr_RidWithAttributeArray(ndr, NDR_SCALARS, &r->res_groups)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_netr_SamInfo3(ndr, NDR_BUFFERS, &r->info3)); + if (r->res_group_dom_sid) { + _mem_save_res_group_dom_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->res_group_dom_sid, 0); + NDR_CHECK(ndr_pull_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->res_group_dom_sid)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_res_group_dom_sid_0, 0); + } + NDR_CHECK(ndr_pull_samr_RidWithAttributeArray(ndr, NDR_BUFFERS, &r->res_groups)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_LOGON_INFO(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_INFO *r) +{ + ndr_print_struct(ndr, name, "PAC_LOGON_INFO"); + ndr->depth++; + ndr_print_netr_SamInfo3(ndr, "info3", &r->info3); + ndr_print_ptr(ndr, "res_group_dom_sid", r->res_group_dom_sid); + ndr->depth++; + if (r->res_group_dom_sid) { + ndr_print_dom_sid2(ndr, "res_group_dom_sid", r->res_group_dom_sid); + } + ndr->depth--; + ndr_print_samr_RidWithAttributeArray(ndr, "res_groups", &r->res_groups); + ndr->depth--; +} + +static size_t ndr_size_PAC_LOGON_INFO(const struct PAC_LOGON_INFO *r, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_PAC_LOGON_INFO); +} + +_PUBLIC_ enum ndr_err_code ndr_push_PAC_LOGON_INFO_CTR(struct ndr_push *ndr, int ndr_flags, const struct PAC_LOGON_INFO_CTR *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x00081001)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0xCCCCCCCC)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, NDR_ROUND(ndr_size_PAC_LOGON_INFO(r->info, ndr->flags) + 4, 8))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x00000000)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->info) { + NDR_CHECK(ndr_push_PAC_LOGON_INFO(ndr, NDR_SCALARS|NDR_BUFFERS, r->info)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_PAC_LOGON_INFO_CTR(struct ndr_pull *ndr, int ndr_flags, struct PAC_LOGON_INFO_CTR *r) +{ + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_info_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown1)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown2)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown3)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->info); + } else { + r->info = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info, 0); + NDR_CHECK(ndr_pull_PAC_LOGON_INFO(ndr, NDR_SCALARS|NDR_BUFFERS, r->info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_LOGON_INFO_CTR(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_INFO_CTR *r) +{ + ndr_print_struct(ndr, name, "PAC_LOGON_INFO_CTR"); + ndr->depth++; + ndr_print_uint32(ndr, "unknown1", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x00081001:r->unknown1); + ndr_print_uint32(ndr, "unknown2", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0xCCCCCCCC:r->unknown2); + ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?NDR_ROUND(ndr_size_PAC_LOGON_INFO(r->info, ndr->flags) + 4, 8):r->_ndr_size); + ndr_print_uint32(ndr, "unknown3", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x00000000:r->unknown3); + ndr_print_ptr(ndr, "info", r->info); + ndr->depth++; + if (r->info) { + ndr_print_PAC_LOGON_INFO(ndr, "info", r->info); + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_PAC_TYPE(struct ndr_push *ndr, int ndr_flags, enum PAC_TYPE r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_PAC_TYPE(struct ndr_pull *ndr, int ndr_flags, enum PAC_TYPE *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_TYPE(struct ndr_print *ndr, const char *name, enum PAC_TYPE r) +{ + const char *val = NULL; + + switch (r) { + case PAC_TYPE_LOGON_INFO: val = "PAC_TYPE_LOGON_INFO"; break; + case PAC_TYPE_SRV_CHECKSUM: val = "PAC_TYPE_SRV_CHECKSUM"; break; + case PAC_TYPE_KDC_CHECKSUM: val = "PAC_TYPE_KDC_CHECKSUM"; break; + case PAC_TYPE_LOGON_NAME: val = "PAC_TYPE_LOGON_NAME"; break; + case PAC_TYPE_CONSTRAINED_DELEGATION: val = "PAC_TYPE_CONSTRAINED_DELEGATION"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +_PUBLIC_ enum ndr_err_code ndr_push_PAC_INFO(struct ndr_push *ndr, int ndr_flags, const union PAC_INFO *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case PAC_TYPE_LOGON_INFO: { + NDR_CHECK(ndr_push_PAC_LOGON_INFO_CTR(ndr, NDR_SCALARS, &r->logon_info)); + break; } + + case PAC_TYPE_SRV_CHECKSUM: { + NDR_CHECK(ndr_push_PAC_SIGNATURE_DATA(ndr, NDR_SCALARS, &r->srv_cksum)); + break; } + + case PAC_TYPE_KDC_CHECKSUM: { + NDR_CHECK(ndr_push_PAC_SIGNATURE_DATA(ndr, NDR_SCALARS, &r->kdc_cksum)); + break; } + + case PAC_TYPE_LOGON_NAME: { + NDR_CHECK(ndr_push_PAC_LOGON_NAME(ndr, NDR_SCALARS, &r->logon_name)); + break; } + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case PAC_TYPE_LOGON_INFO: + NDR_CHECK(ndr_push_PAC_LOGON_INFO_CTR(ndr, NDR_BUFFERS, &r->logon_info)); + break; + + case PAC_TYPE_SRV_CHECKSUM: + break; + + case PAC_TYPE_KDC_CHECKSUM: + break; + + case PAC_TYPE_LOGON_NAME: + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_PAC_INFO(struct ndr_pull *ndr, int ndr_flags, union PAC_INFO *r) +{ + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case PAC_TYPE_LOGON_INFO: { + NDR_CHECK(ndr_pull_PAC_LOGON_INFO_CTR(ndr, NDR_SCALARS, &r->logon_info)); + break; } + + case PAC_TYPE_SRV_CHECKSUM: { + NDR_CHECK(ndr_pull_PAC_SIGNATURE_DATA(ndr, NDR_SCALARS, &r->srv_cksum)); + break; } + + case PAC_TYPE_KDC_CHECKSUM: { + NDR_CHECK(ndr_pull_PAC_SIGNATURE_DATA(ndr, NDR_SCALARS, &r->kdc_cksum)); + break; } + + case PAC_TYPE_LOGON_NAME: { + NDR_CHECK(ndr_pull_PAC_LOGON_NAME(ndr, NDR_SCALARS, &r->logon_name)); + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case PAC_TYPE_LOGON_INFO: + NDR_CHECK(ndr_pull_PAC_LOGON_INFO_CTR(ndr, NDR_BUFFERS, &r->logon_info)); + break; + + case PAC_TYPE_SRV_CHECKSUM: + break; + + case PAC_TYPE_KDC_CHECKSUM: + break; + + case PAC_TYPE_LOGON_NAME: + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_INFO(struct ndr_print *ndr, const char *name, const union PAC_INFO *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "PAC_INFO"); + switch (level) { + case PAC_TYPE_LOGON_INFO: + ndr_print_PAC_LOGON_INFO_CTR(ndr, "logon_info", &r->logon_info); + break; + + case PAC_TYPE_SRV_CHECKSUM: + ndr_print_PAC_SIGNATURE_DATA(ndr, "srv_cksum", &r->srv_cksum); + break; + + case PAC_TYPE_KDC_CHECKSUM: + ndr_print_PAC_SIGNATURE_DATA(ndr, "kdc_cksum", &r->kdc_cksum); + break; + + case PAC_TYPE_LOGON_NAME: + ndr_print_PAC_LOGON_NAME(ndr, "logon_name", &r->logon_name); + break; + + default: + ndr_print_bad_level(ndr, name, level); + } +} + +_PUBLIC_ size_t ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags) +{ + return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_PAC_INFO); +} + +_PUBLIC_ enum ndr_err_code ndr_push_PAC_DATA(struct ndr_push *ndr, int ndr_flags, const struct PAC_DATA *r) +{ + uint32_t cntr_buffers_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_buffers)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->version)); + for (cntr_buffers_0 = 0; cntr_buffers_0 < r->num_buffers; cntr_buffers_0++) { + NDR_CHECK(ndr_push_PAC_BUFFER(ndr, NDR_SCALARS, &r->buffers[cntr_buffers_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + for (cntr_buffers_0 = 0; cntr_buffers_0 < r->num_buffers; cntr_buffers_0++) { + NDR_CHECK(ndr_push_PAC_BUFFER(ndr, NDR_BUFFERS, &r->buffers[cntr_buffers_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_PAC_DATA(struct ndr_pull *ndr, int ndr_flags, struct PAC_DATA *r) +{ + uint32_t cntr_buffers_0; + TALLOC_CTX *_mem_save_buffers_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_buffers)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->version)); + NDR_PULL_ALLOC_N(ndr, r->buffers, r->num_buffers); + _mem_save_buffers_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->buffers, 0); + for (cntr_buffers_0 = 0; cntr_buffers_0 < r->num_buffers; cntr_buffers_0++) { + NDR_CHECK(ndr_pull_PAC_BUFFER(ndr, NDR_SCALARS, &r->buffers[cntr_buffers_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffers_0, 0); + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_buffers_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->buffers, 0); + for (cntr_buffers_0 = 0; cntr_buffers_0 < r->num_buffers; cntr_buffers_0++) { + NDR_CHECK(ndr_pull_PAC_BUFFER(ndr, NDR_BUFFERS, &r->buffers[cntr_buffers_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffers_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_DATA(struct ndr_print *ndr, const char *name, const struct PAC_DATA *r) +{ + uint32_t cntr_buffers_0; + ndr_print_struct(ndr, name, "PAC_DATA"); + ndr->depth++; + ndr_print_uint32(ndr, "num_buffers", r->num_buffers); + ndr_print_uint32(ndr, "version", r->version); + ndr->print(ndr, "%s: ARRAY(%d)", "buffers", r->num_buffers); + ndr->depth++; + for (cntr_buffers_0=0;cntr_buffers_0num_buffers;cntr_buffers_0++) { + char *idx_0=NULL; + asprintf(&idx_0, "[%d]", cntr_buffers_0); + if (idx_0) { + ndr_print_PAC_BUFFER(ndr, "buffers", &r->buffers[cntr_buffers_0]); + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_DATA_BLOB_REM(struct ndr_push *ndr, int ndr_flags, const struct DATA_BLOB_REM *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->remaining)); + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_DATA_BLOB_REM(struct ndr_pull *ndr, int ndr_flags, struct DATA_BLOB_REM *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->remaining)); + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_DATA_BLOB_REM(struct ndr_print *ndr, const char *name, const struct DATA_BLOB_REM *r) +{ + ndr_print_struct(ndr, name, "DATA_BLOB_REM"); + ndr->depth++; + ndr_print_DATA_BLOB(ndr, "remaining", r->remaining); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_PAC_BUFFER_RAW(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER_RAW *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ndr_size)); + { + uint32_t _flags_save_DATA_BLOB_REM = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->info)); + ndr->flags = _flags_save_DATA_BLOB_REM; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_DATA_BLOB_REM = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); + if (r->info) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->info)); + { + struct ndr_push *_ndr_info; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 0, NDR_ROUND(r->ndr_size, 8))); + NDR_CHECK(ndr_push_DATA_BLOB_REM(_ndr_info, NDR_SCALARS, r->info)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 0, NDR_ROUND(r->ndr_size, 8))); + } + } + ndr->flags = _flags_save_DATA_BLOB_REM; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_PAC_BUFFER_RAW(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER_RAW *r) +{ + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_info_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_PAC_TYPE(ndr, NDR_SCALARS, &r->type)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ndr_size)); + { + uint32_t _flags_save_DATA_BLOB_REM = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->info); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->info, _ptr_info)); + } else { + r->info = NULL; + } + ndr->flags = _flags_save_DATA_BLOB_REM; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_pad)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_DATA_BLOB_REM = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); + if (r->info) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->info)); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info, 0); + { + struct ndr_pull *_ndr_info; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 0, NDR_ROUND(r->ndr_size, 8))); + NDR_CHECK(ndr_pull_DATA_BLOB_REM(_ndr_info, NDR_SCALARS, r->info)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 0, NDR_ROUND(r->ndr_size, 8))); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_DATA_BLOB_REM; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_BUFFER_RAW(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER_RAW *r) +{ + ndr_print_struct(ndr, name, "PAC_BUFFER_RAW"); + ndr->depth++; + ndr_print_PAC_TYPE(ndr, "type", r->type); + ndr_print_uint32(ndr, "ndr_size", r->ndr_size); + ndr_print_ptr(ndr, "info", r->info); + ndr->depth++; + if (r->info) { + ndr_print_DATA_BLOB_REM(ndr, "info", r->info); + } + ndr->depth--; + ndr_print_uint32(ndr, "_pad", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0:r->_pad); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_PAC_DATA_RAW(struct ndr_push *ndr, int ndr_flags, const struct PAC_DATA_RAW *r) +{ + uint32_t cntr_buffers_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_buffers)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->version)); + for (cntr_buffers_0 = 0; cntr_buffers_0 < r->num_buffers; cntr_buffers_0++) { + NDR_CHECK(ndr_push_PAC_BUFFER_RAW(ndr, NDR_SCALARS, &r->buffers[cntr_buffers_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + for (cntr_buffers_0 = 0; cntr_buffers_0 < r->num_buffers; cntr_buffers_0++) { + NDR_CHECK(ndr_push_PAC_BUFFER_RAW(ndr, NDR_BUFFERS, &r->buffers[cntr_buffers_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_PAC_DATA_RAW(struct ndr_pull *ndr, int ndr_flags, struct PAC_DATA_RAW *r) +{ + uint32_t cntr_buffers_0; + TALLOC_CTX *_mem_save_buffers_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_buffers)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->version)); + NDR_PULL_ALLOC_N(ndr, r->buffers, r->num_buffers); + _mem_save_buffers_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->buffers, 0); + for (cntr_buffers_0 = 0; cntr_buffers_0 < r->num_buffers; cntr_buffers_0++) { + NDR_CHECK(ndr_pull_PAC_BUFFER_RAW(ndr, NDR_SCALARS, &r->buffers[cntr_buffers_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffers_0, 0); + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_buffers_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->buffers, 0); + for (cntr_buffers_0 = 0; cntr_buffers_0 < r->num_buffers; cntr_buffers_0++) { + NDR_CHECK(ndr_pull_PAC_BUFFER_RAW(ndr, NDR_BUFFERS, &r->buffers[cntr_buffers_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffers_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_DATA_RAW(struct ndr_print *ndr, const char *name, const struct PAC_DATA_RAW *r) +{ + uint32_t cntr_buffers_0; + ndr_print_struct(ndr, name, "PAC_DATA_RAW"); + ndr->depth++; + ndr_print_uint32(ndr, "num_buffers", r->num_buffers); + ndr_print_uint32(ndr, "version", r->version); + ndr->print(ndr, "%s: ARRAY(%d)", "buffers", r->num_buffers); + ndr->depth++; + for (cntr_buffers_0=0;cntr_buffers_0num_buffers;cntr_buffers_0++) { + char *idx_0=NULL; + asprintf(&idx_0, "[%d]", cntr_buffers_0); + if (idx_0) { + ndr_print_PAC_BUFFER_RAW(ndr, "buffers", &r->buffers[cntr_buffers_0]); + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_decode_pac(struct ndr_push *ndr, int flags, const struct decode_pac *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_PAC_DATA(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.pac)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_decode_pac(struct ndr_pull *ndr, int flags, struct decode_pac *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_pull_PAC_DATA(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.pac)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_decode_pac(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac *r) +{ + ndr_print_struct(ndr, name, "decode_pac"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "decode_pac"); + ndr->depth++; + ndr_print_PAC_DATA(ndr, "pac", &r->in.pac); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "decode_pac"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_decode_pac_raw(struct ndr_push *ndr, int flags, const struct decode_pac_raw *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_PAC_DATA_RAW(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.pac)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_decode_pac_raw(struct ndr_pull *ndr, int flags, struct decode_pac_raw *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_pull_PAC_DATA_RAW(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.pac)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_decode_pac_raw(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac_raw *r) +{ + ndr_print_struct(ndr, name, "decode_pac_raw"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "decode_pac_raw"); + ndr->depth++; + ndr_print_PAC_DATA_RAW(ndr, "pac", &r->in.pac); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "decode_pac_raw"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_decode_login_info(struct ndr_push *ndr, int flags, const struct decode_login_info *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_PAC_LOGON_INFO(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon_info)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_decode_login_info(struct ndr_pull *ndr, int flags, struct decode_login_info *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_pull_PAC_LOGON_INFO(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon_info)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_decode_login_info(struct ndr_print *ndr, const char *name, int flags, const struct decode_login_info *r) +{ + ndr_print_struct(ndr, name, "decode_login_info"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "decode_login_info"); + ndr->depth++; + ndr_print_PAC_LOGON_INFO(ndr, "logon_info", &r->in.logon_info); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "decode_login_info"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static const struct ndr_interface_call krb5pac_calls[] = { + { + "decode_pac", + sizeof(struct decode_pac), + (ndr_push_flags_fn_t) ndr_push_decode_pac, + (ndr_pull_flags_fn_t) ndr_pull_decode_pac, + (ndr_print_function_t) ndr_print_decode_pac, + false, + }, + { + "decode_pac_raw", + sizeof(struct decode_pac_raw), + (ndr_push_flags_fn_t) ndr_push_decode_pac_raw, + (ndr_pull_flags_fn_t) ndr_pull_decode_pac_raw, + (ndr_print_function_t) ndr_print_decode_pac_raw, + false, + }, + { + "decode_login_info", + sizeof(struct decode_login_info), + (ndr_push_flags_fn_t) ndr_push_decode_login_info, + (ndr_pull_flags_fn_t) ndr_pull_decode_login_info, + (ndr_print_function_t) ndr_print_decode_login_info, + false, + }, + { NULL, 0, NULL, NULL, NULL, false } +}; + +static const char * const krb5pac_endpoint_strings[] = { + "ncacn_np:[\\pipe\\krb5pac]", +}; + +static const struct ndr_interface_string_array krb5pac_endpoints = { + .count = 1, + .names = krb5pac_endpoint_strings +}; + +static const char * const krb5pac_authservice_strings[] = { + "host", +}; + +static const struct ndr_interface_string_array krb5pac_authservices = { + .count = 1, + .names = krb5pac_authservice_strings +}; + + +const struct ndr_interface_table ndr_table_krb5pac = { + .name = "krb5pac", + .syntax_id = { + {0x12345778,0x1234,0xabcd,{0x00,0x00},{0x00,0x00,0x00,0x00}}, + NDR_KRB5PAC_VERSION + }, + .helpstring = NDR_KRB5PAC_HELPSTRING, + .num_calls = 3, + .calls = krb5pac_calls, + .endpoints = &krb5pac_endpoints, + .authservices = &krb5pac_authservices +}; + diff --git a/source3/librpc/idl/krb5pac.idl b/source3/librpc/idl/krb5pac.idl new file mode 100644 index 0000000000..39042727da --- /dev/null +++ b/source3/librpc/idl/krb5pac.idl @@ -0,0 +1,98 @@ +/* + krb5 PAC +*/ + +#include "idl_types.h" + +import "security.idl", "netlogon.idl", "samr.idl"; + +[ + uuid("12345778-1234-abcd-0000-00000000"), + version(0.0), + pointer_default(unique), + helpstring("Active Directory KRB5 PAC") +] +interface krb5pac +{ + typedef struct { + NTTIME logon_time; + [value(2*strlen_m(account_name))] uint16 size; + [charset(UTF16)] uint8 account_name[size]; + } PAC_LOGON_NAME; + + typedef [public,flag(NDR_PAHEX)] struct { + uint32 type; + [flag(NDR_REMAINING)] DATA_BLOB signature; + } PAC_SIGNATURE_DATA; + + typedef [gensize] struct { + netr_SamInfo3 info3; + dom_sid2 *res_group_dom_sid; + samr_RidWithAttributeArray res_groups; + } PAC_LOGON_INFO; + + typedef [public] struct { + [value(0x00081001)] uint32 unknown1; + [value(0xCCCCCCCC)] uint32 unknown2; + [value(NDR_ROUND(ndr_size_PAC_LOGON_INFO(info, ndr->flags)+4,8))] uint32 _ndr_size; + [value(0x00000000)] uint32 unknown3; + PAC_LOGON_INFO *info; + } PAC_LOGON_INFO_CTR; + + typedef [public,v1_enum] enum { + PAC_TYPE_LOGON_INFO = 1, + PAC_TYPE_SRV_CHECKSUM = 6, + PAC_TYPE_KDC_CHECKSUM = 7, + PAC_TYPE_LOGON_NAME = 10, + PAC_TYPE_CONSTRAINED_DELEGATION = 11 + } PAC_TYPE; + + typedef [public,nodiscriminant,gensize] union { + [case(PAC_TYPE_LOGON_INFO)] PAC_LOGON_INFO_CTR logon_info; + [case(PAC_TYPE_SRV_CHECKSUM)] PAC_SIGNATURE_DATA srv_cksum; + [case(PAC_TYPE_KDC_CHECKSUM)] PAC_SIGNATURE_DATA kdc_cksum; + [case(PAC_TYPE_LOGON_NAME)] PAC_LOGON_NAME logon_name; + } PAC_INFO; + + typedef [public,nopush,nopull,noprint] struct { + PAC_TYPE type; + [value(_ndr_size_PAC_INFO(info, type, 0))] uint32 _ndr_size; + [relative,switch_is(type),subcontext(0),subcontext_size(_subcontext_size_PAC_INFO(r, ndr->flags)),flag(NDR_ALIGN8)] PAC_INFO *info; + [value(0)] uint32 _pad; /* Top half of a 64 bit pointer? */ + } PAC_BUFFER; + + typedef [public] struct { + uint32 num_buffers; + uint32 version; + PAC_BUFFER buffers[num_buffers]; + } PAC_DATA; + + typedef struct { + [flag(NDR_REMAINING)] DATA_BLOB remaining; + } DATA_BLOB_REM; + + typedef [public] struct { + PAC_TYPE type; + uint32 ndr_size; + [relative,subcontext(0),subcontext_size(NDR_ROUND(ndr_size,8)),flag(NDR_ALIGN8)] DATA_BLOB_REM *info; + [value(0)] uint32 _pad; /* Top half of a 64 bit pointer? */ + } PAC_BUFFER_RAW; + + typedef [public] struct { + uint32 num_buffers; + uint32 version; + PAC_BUFFER_RAW buffers[num_buffers]; + } PAC_DATA_RAW; + + void decode_pac( + [in] PAC_DATA pac + ); + + void decode_pac_raw( + [in] PAC_DATA_RAW pac + ); + + void decode_login_info( + [in] PAC_LOGON_INFO logon_info + ); +} diff --git a/source3/librpc/ndr/ndr_krb5pac.c b/source3/librpc/ndr/ndr_krb5pac.c new file mode 100644 index 0000000000..b0eab44012 --- /dev/null +++ b/source3/librpc/ndr/ndr_krb5pac.c @@ -0,0 +1,141 @@ +/* + Unix SMB/CIFS implementation. + + routines for marshalling/unmarshalling spoolss subcontext buffer structures + + Copyright (C) Stefan Metzmacher 2005 + + 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 "includes.h" + +#include "librpc/gen_ndr/ndr_krb5pac.h" + +static size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags) +{ + size_t s = ndr_size_PAC_INFO(r, level, flags); + switch (level) { + case PAC_TYPE_LOGON_INFO: + return NDR_ROUND(s,8); + default: + return s; + } +} + +static size_t _subcontext_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags) +{ + size_t s = ndr_size_PAC_INFO(r, level, flags); + return NDR_ROUND(s,8); +} + +enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,0))); + { + uint32_t _flags_save_PAC_INFO = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->info)); + ndr->flags = _flags_save_PAC_INFO; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_PAC_INFO = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); + if (r->info) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->info)); + { + struct ndr_push *_ndr_info; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,0))); + NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type)); + NDR_CHECK(ndr_push_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,0))); + } + } + ndr->flags = _flags_save_PAC_INFO; + } + } + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER *r) +{ + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_info_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_PAC_TYPE(ndr, NDR_SCALARS, &r->type)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size)); + { + uint32_t _flags_save_PAC_INFO = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->info); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->info, _ptr_info)); + } else { + r->info = NULL; + } + ndr->flags = _flags_save_PAC_INFO; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_pad)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_PAC_INFO = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); + if (r->info) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->info)); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info, 0); + { + struct ndr_pull *_ndr_info; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 0, r->_ndr_size)); + NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->info, r->type)); + NDR_CHECK(ndr_pull_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 0, r->_ndr_size)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_PAC_INFO; + } + } + return NDR_ERR_SUCCESS; +} + +void ndr_print_PAC_BUFFER(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER *r) +{ + ndr_print_struct(ndr, name, "PAC_BUFFER"); + ndr->depth++; + ndr_print_PAC_TYPE(ndr, "type", r->type); + ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?_ndr_size_PAC_INFO(r->info,r->type,0):r->_ndr_size); + ndr_print_ptr(ndr, "info", r->info); + ndr->depth++; + if (r->info) { + ndr_print_set_switch_value(ndr, r->info, r->type); + ndr_print_PAC_INFO(ndr, "info", r->info); + } + ndr->depth--; + ndr_print_uint32(ndr, "_pad", r->_pad); + ndr->depth--; +} -- cgit From a0f081ff4f052ce1b160a7e8fe32256fd08edc15 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 01:33:03 +0100 Subject: Add netsamlogoncache_entry to krb5pac IDL, probably not the most accurate place... Guenther (This used to be commit 1bc35cf592f3e5d5873320f8669424a2bbaaa073) --- source3/librpc/idl/krb5pac.idl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3') diff --git a/source3/librpc/idl/krb5pac.idl b/source3/librpc/idl/krb5pac.idl index 39042727da..601e3e1a27 100644 --- a/source3/librpc/idl/krb5pac.idl +++ b/source3/librpc/idl/krb5pac.idl @@ -95,4 +95,10 @@ interface krb5pac void decode_login_info( [in] PAC_LOGON_INFO logon_info ); + + /* used for samba3 netsamlogon cache */ + typedef [public] struct { + time_t timestamp; + netr_SamInfo3 info3; + } netsamlogoncache_entry; } -- cgit From 46a3beefde93a5c4dd4e256b4a8938caac117787 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 01:33:46 +0100 Subject: Re-run make idl. Guenther (This used to be commit d0ceb482eb3ee1f8d8253152bab9de8b086ee76e) --- source3/librpc/gen_ndr/krb5pac.h | 5 +++++ source3/librpc/gen_ndr/ndr_krb5pac.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/krb5pac.h b/source3/librpc/gen_ndr/krb5pac.h index a0d75fdd88..b8b9054bb6 100644 --- a/source3/librpc/gen_ndr/krb5pac.h +++ b/source3/librpc/gen_ndr/krb5pac.h @@ -89,6 +89,11 @@ struct PAC_DATA_RAW { struct PAC_BUFFER_RAW *buffers; }/* [public] */; +struct netsamlogoncache_entry { + time_t timestamp; + struct netr_SamInfo3 info3; +}/* [public] */; + struct decode_pac { struct { diff --git a/source3/librpc/gen_ndr/ndr_krb5pac.c b/source3/librpc/gen_ndr/ndr_krb5pac.c index 722e7acf84..82b7803f80 100644 --- a/source3/librpc/gen_ndr/ndr_krb5pac.c +++ b/source3/librpc/gen_ndr/ndr_krb5pac.c @@ -655,6 +655,41 @@ _PUBLIC_ void ndr_print_PAC_DATA_RAW(struct ndr_print *ndr, const char *name, co ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_netsamlogoncache_entry(struct ndr_push *ndr, int ndr_flags, const struct netsamlogoncache_entry *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_time_t(ndr, NDR_SCALARS, r->timestamp)); + NDR_CHECK(ndr_push_netr_SamInfo3(ndr, NDR_SCALARS, &r->info3)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_netr_SamInfo3(ndr, NDR_BUFFERS, &r->info3)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_netsamlogoncache_entry(struct ndr_pull *ndr, int ndr_flags, struct netsamlogoncache_entry *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_time_t(ndr, NDR_SCALARS, &r->timestamp)); + NDR_CHECK(ndr_pull_netr_SamInfo3(ndr, NDR_SCALARS, &r->info3)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_netr_SamInfo3(ndr, NDR_BUFFERS, &r->info3)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netsamlogoncache_entry(struct ndr_print *ndr, const char *name, const struct netsamlogoncache_entry *r) +{ + ndr_print_struct(ndr, name, "netsamlogoncache_entry"); + ndr->depth++; + ndr_print_time_t(ndr, "timestamp", r->timestamp); + ndr_print_netr_SamInfo3(ndr, "info3", &r->info3); + ndr->depth--; +} + static enum ndr_err_code ndr_push_decode_pac(struct ndr_push *ndr, int flags, const struct decode_pac *r) { if (flags & NDR_IN) { -- cgit From 38da19f7f24f4cab6ffd32baf3e49ca851d64d71 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 01:44:39 +0100 Subject: Add missing header file. Guenther (This used to be commit 5095c59f8930212c20a0713464c9620220388aeb) --- source3/librpc/gen_ndr/ndr_krb5pac.h | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 source3/librpc/gen_ndr/ndr_krb5pac.h (limited to 'source3') diff --git a/source3/librpc/gen_ndr/ndr_krb5pac.h b/source3/librpc/gen_ndr/ndr_krb5pac.h new file mode 100644 index 0000000000..f23505d4f0 --- /dev/null +++ b/source3/librpc/gen_ndr/ndr_krb5pac.h @@ -0,0 +1,55 @@ +/* header auto-generated by pidl */ + +#include "librpc/ndr/libndr.h" +#include "librpc/gen_ndr/krb5pac.h" + +#ifndef _HEADER_NDR_krb5pac +#define _HEADER_NDR_krb5pac + +#define NDR_KRB5PAC_UUID "12345778-1234-abcd-0000-00000000" +#define NDR_KRB5PAC_VERSION 0.0 +#define NDR_KRB5PAC_NAME "krb5pac" +#define NDR_KRB5PAC_HELPSTRING "Active Directory KRB5 PAC" +extern const struct ndr_interface_table ndr_table_krb5pac; +#define NDR_DECODE_PAC (0x00) + +#define NDR_DECODE_PAC_RAW (0x01) + +#define NDR_DECODE_LOGIN_INFO (0x02) + +#define NDR_KRB5PAC_CALL_COUNT (3) +void ndr_print_PAC_LOGON_NAME(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_NAME *r); +enum ndr_err_code ndr_push_PAC_SIGNATURE_DATA(struct ndr_push *ndr, int ndr_flags, const struct PAC_SIGNATURE_DATA *r); +enum ndr_err_code ndr_pull_PAC_SIGNATURE_DATA(struct ndr_pull *ndr, int ndr_flags, struct PAC_SIGNATURE_DATA *r); +void ndr_print_PAC_SIGNATURE_DATA(struct ndr_print *ndr, const char *name, const struct PAC_SIGNATURE_DATA *r); +void ndr_print_PAC_LOGON_INFO(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_INFO *r); +enum ndr_err_code ndr_push_PAC_LOGON_INFO_CTR(struct ndr_push *ndr, int ndr_flags, const struct PAC_LOGON_INFO_CTR *r); +enum ndr_err_code ndr_pull_PAC_LOGON_INFO_CTR(struct ndr_pull *ndr, int ndr_flags, struct PAC_LOGON_INFO_CTR *r); +void ndr_print_PAC_LOGON_INFO_CTR(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_INFO_CTR *r); +enum ndr_err_code ndr_push_PAC_TYPE(struct ndr_push *ndr, int ndr_flags, enum PAC_TYPE r); +enum ndr_err_code ndr_pull_PAC_TYPE(struct ndr_pull *ndr, int ndr_flags, enum PAC_TYPE *r); +void ndr_print_PAC_TYPE(struct ndr_print *ndr, const char *name, enum PAC_TYPE r); +enum ndr_err_code ndr_push_PAC_INFO(struct ndr_push *ndr, int ndr_flags, const union PAC_INFO *r); +enum ndr_err_code ndr_pull_PAC_INFO(struct ndr_pull *ndr, int ndr_flags, union PAC_INFO *r); +void ndr_print_PAC_INFO(struct ndr_print *ndr, const char *name, const union PAC_INFO *r); +size_t ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags); +enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER *r); +enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER *r); +void ndr_print_PAC_BUFFER(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER *r); +enum ndr_err_code ndr_push_PAC_DATA(struct ndr_push *ndr, int ndr_flags, const struct PAC_DATA *r); +enum ndr_err_code ndr_pull_PAC_DATA(struct ndr_pull *ndr, int ndr_flags, struct PAC_DATA *r); +void ndr_print_PAC_DATA(struct ndr_print *ndr, const char *name, const struct PAC_DATA *r); +void ndr_print_DATA_BLOB_REM(struct ndr_print *ndr, const char *name, const struct DATA_BLOB_REM *r); +enum ndr_err_code ndr_push_PAC_BUFFER_RAW(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER_RAW *r); +enum ndr_err_code ndr_pull_PAC_BUFFER_RAW(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER_RAW *r); +void ndr_print_PAC_BUFFER_RAW(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER_RAW *r); +enum ndr_err_code ndr_push_PAC_DATA_RAW(struct ndr_push *ndr, int ndr_flags, const struct PAC_DATA_RAW *r); +enum ndr_err_code ndr_pull_PAC_DATA_RAW(struct ndr_pull *ndr, int ndr_flags, struct PAC_DATA_RAW *r); +void ndr_print_PAC_DATA_RAW(struct ndr_print *ndr, const char *name, const struct PAC_DATA_RAW *r); +enum ndr_err_code ndr_push_netsamlogoncache_entry(struct ndr_push *ndr, int ndr_flags, const struct netsamlogoncache_entry *r); +enum ndr_err_code ndr_pull_netsamlogoncache_entry(struct ndr_pull *ndr, int ndr_flags, struct netsamlogoncache_entry *r); +void ndr_print_netsamlogoncache_entry(struct ndr_print *ndr, const char *name, const struct netsamlogoncache_entry *r); +void ndr_print_decode_pac(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac *r); +void ndr_print_decode_pac_raw(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac_raw *r); +void ndr_print_decode_login_info(struct ndr_print *ndr, const char *name, int flags, const struct decode_login_info *r); +#endif /* _HEADER_NDR_krb5pac */ -- cgit From b1d09a82f44dfebe3317d96ec69eaf81dfa452be Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 18:51:01 +0100 Subject: Use netr_SamInfo3 in sid_array_from_info3. Guenther (This used to be commit 06095e8c705fc292323fa8d0110ae3aaeccab949) --- source3/lib/util_sid.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 37865238a5..fd2e93a697 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -665,7 +665,7 @@ bool is_null_sid(const DOM_SID *sid) } NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx, - const NET_USER_INFO_3 *info3, + const struct netr_SamInfo3 *info3, DOM_SID **user_sids, size_t *num_user_sids, bool include_user_group_rid) @@ -678,45 +678,45 @@ NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx, if (include_user_group_rid) { - if (!sid_compose(&sid, &(info3->dom_sid.sid), info3->user_rid)) + if (!sid_compose(&sid, info3->base.domain_sid, info3->base.rid)) { DEBUG(3, ("could not compose user SID from rid 0x%x\n", - info3->user_rid)); + info3->base.rid)); return NT_STATUS_INVALID_PARAMETER; } status = add_sid_to_array(mem_ctx, &sid, &sid_array, &num_sids); if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("could not append user SID from rid 0x%x\n", - info3->user_rid)); + info3->base.rid)); return status; } - if (!sid_compose(&sid, &(info3->dom_sid.sid), info3->group_rid)) + if (!sid_compose(&sid, info3->base.domain_sid, info3->base.primary_gid)) { DEBUG(3, ("could not compose group SID from rid 0x%x\n", - info3->group_rid)); + info3->base.primary_gid)); return NT_STATUS_INVALID_PARAMETER; } status = add_sid_to_array(mem_ctx, &sid, &sid_array, &num_sids); if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("could not append group SID from rid 0x%x\n", - info3->group_rid)); + info3->base.rid)); return status; } } - for (i = 0; i < info3->num_groups2; i++) { - if (!sid_compose(&sid, &(info3->dom_sid.sid), - info3->gids[i].g_rid)) + for (i = 0; i < info3->base.groups.count; i++) { + if (!sid_compose(&sid, info3->base.domain_sid, + info3->base.groups.rids[i].rid)) { DEBUG(3, ("could not compose SID from additional group " - "rid 0x%x\n", info3->gids[i].g_rid)); + "rid 0x%x\n", info3->base.groups.rids[i].rid)); return NT_STATUS_INVALID_PARAMETER; } status = add_sid_to_array(mem_ctx, &sid, &sid_array, &num_sids); if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("could not append SID from additional group " - "rid 0x%x\n", info3->gids[i].g_rid)); + "rid 0x%x\n", info3->base.groups.rids[i].rid)); return status; } } @@ -727,12 +727,12 @@ NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx, http://www.microsoft.com/windows2000/techinfo/administration/security/sidfilter.asp */ - for (i = 0; i < info3->num_other_sids; i++) { - status = add_sid_to_array(mem_ctx, &info3->other_sids[i].sid, + for (i = 0; i < info3->sidcount; i++) { + status = add_sid_to_array(mem_ctx, info3->sids[i].sid, &sid_array, &num_sids); if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("could not add SID to array: %s\n", - sid_string_dbg(&info3->other_sids[i].sid))); + sid_string_dbg(info3->sids[i].sid))); return status; } } -- cgit From 65fc3ae0701dba3d8c336abd236716413b1f634d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 18:55:08 +0100 Subject: Use new structs in reply_spnego_kerberos(). Guenther (This used to be commit c55160f8e866d9b24a4dad234af78ae46c236a37) --- source3/smbd/sesssetup.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c index 3e04da35df..9baa02977a 100644 --- a/source3/smbd/sesssetup.c +++ b/source3/smbd/sesssetup.c @@ -259,7 +259,7 @@ static void reply_spnego_kerberos(struct smb_request *req, fstring user; int sess_vuid = req->vuid; NTSTATUS ret = NT_STATUS_OK; - PAC_DATA *pac_data = NULL; + struct PAC_DATA *pac_data = NULL; DATA_BLOB ap_rep, ap_rep_wrapped, response; auth_serversupplied_info *server_info = NULL; DATA_BLOB session_key = data_blob_null; @@ -268,7 +268,7 @@ static void reply_spnego_kerberos(struct smb_request *req, fstring real_username; bool map_domainuser_to_guest = False; bool username_was_mapped; - PAC_LOGON_INFO *logon_info = NULL; + struct PAC_LOGON_INFO *logon_info = NULL; ZERO_STRUCT(ticket); ZERO_STRUCT(ap_rep); @@ -394,10 +394,9 @@ static void reply_spnego_kerberos(struct smb_request *req, domain = p+1; - if (logon_info && logon_info->info3.hdr_logon_dom.uni_str_len) { - unistr2_to_ascii(netbios_domain_name, - &logon_info->info3.uni_logon_dom, - sizeof(netbios_domain_name)); + if (logon_info && logon_info->info3.base.domain.string) { + fstrcpy(netbios_domain_name, + logon_info->info3.base.domain.string); domain = netbios_domain_name; DEBUG(10, ("Mapped to [%s] (using PAC)\n", domain)); -- cgit From c52dcc7b92ce96e5d3804f839f7464432902bf3a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 19:08:22 +0100 Subject: Use netr_SamInfo3 in make_server_info_info3(). Guenther (This used to be commit 5866c11b288c217f0c38240c44f8bfeff185890d) --- source3/auth/auth_util.c | 52 +++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'source3') diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index 6efd31d574..a95a59ea46 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -1422,7 +1422,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, const char *sent_nt_username, const char *domain, auth_serversupplied_info **server_info, - NET_USER_INFO_3 *info3) + struct netr_SamInfo3 *info3) { char zeros[16]; @@ -1446,23 +1446,25 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, matches. */ - sid_copy(&user_sid, &info3->dom_sid.sid); - if (!sid_append_rid(&user_sid, info3->user_rid)) { + sid_copy(&user_sid, info3->base.domain_sid); + if (!sid_append_rid(&user_sid, info3->base.rid)) { return NT_STATUS_INVALID_PARAMETER; } - sid_copy(&group_sid, &info3->dom_sid.sid); - if (!sid_append_rid(&group_sid, info3->group_rid)) { + sid_copy(&group_sid, info3->base.domain_sid); + if (!sid_append_rid(&group_sid, info3->base.primary_gid)) { return NT_STATUS_INVALID_PARAMETER; } - if (!(nt_username = unistr2_to_ascii_talloc(mem_ctx, &(info3->uni_user_name)))) { + nt_username = talloc_strdup(mem_ctx, info3->base.account_name.string); + if (!nt_username) { /* If the server didn't give us one, just use the one we sent * them */ nt_username = sent_nt_username; } - if (!(nt_domain = unistr2_to_ascii_talloc(mem_ctx, &(info3->uni_logon_dom)))) { + nt_domain = talloc_strdup(mem_ctx, info3->base.domain.string); + if (!nt_domain) { /* If the server didn't give us one, just use the one we sent * them */ nt_domain = domain; @@ -1527,50 +1529,50 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, TALLOC_FREE(sam_account); return NT_STATUS_UNSUCCESSFUL; } - + if (!pdb_set_fullname(sam_account, - unistr2_static(&(info3->uni_full_name)), + info3->base.full_name.string, PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_logon_script(sam_account, - unistr2_static(&(info3->uni_logon_script)), + info3->base.logon_script.string, PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_profile_path(sam_account, - unistr2_static(&(info3->uni_profile_path)), + info3->base.profile_path.string, PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_homedir(sam_account, - unistr2_static(&(info3->uni_home_dir)), + info3->base.home_directory.string, PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_dir_drive(sam_account, - unistr2_static(&(info3->uni_dir_drive)), + info3->base.home_drive.string, PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } - if (!pdb_set_acct_ctrl(sam_account, info3->acct_flags, PDB_CHANGED)) { + if (!pdb_set_acct_ctrl(sam_account, info3->base.acct_flags, PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_pass_last_set_time( sam_account, - nt_time_to_unix(info3->pass_last_set_time), + nt_time_to_unix(info3->base.last_password_change), PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; @@ -1578,7 +1580,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, if (!pdb_set_pass_can_change_time( sam_account, - nt_time_to_unix(info3->pass_can_change_time), + nt_time_to_unix(info3->base.allow_password_change), PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; @@ -1586,7 +1588,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, if (!pdb_set_pass_must_change_time( sam_account, - nt_time_to_unix(info3->pass_must_change_time), + nt_time_to_unix(info3->base.force_password_change), PDB_CHANGED)) { TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; @@ -1624,27 +1626,27 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, return nt_status; } - result->login_server = unistr2_to_ascii_talloc(result, - &(info3->uni_logon_srv)); + result->login_server = talloc_strdup(result, + info3->base.logon_server.string); /* ensure we are never given NULL session keys */ ZERO_STRUCT(zeros); - if (memcmp(info3->user_sess_key, zeros, sizeof(zeros)) == 0) { + if (memcmp(info3->base.key.key, zeros, sizeof(zeros)) == 0) { result->user_session_key = data_blob_null; } else { result->user_session_key = data_blob_talloc( - result, info3->user_sess_key, - sizeof(info3->user_sess_key)); + result, info3->base.key.key, + sizeof(info3->base.key.key)); } - if (memcmp(info3->lm_sess_key, zeros, 8) == 0) { + if (memcmp(info3->base.LMSessKey.key, zeros, 8) == 0) { result->lm_session_key = data_blob_null; } else { result->lm_session_key = data_blob_talloc( - result, info3->lm_sess_key, - sizeof(info3->lm_sess_key)); + result, info3->base.LMSessKey.key, + sizeof(info3->base.LMSessKey.key)); } result->was_mapped = username_was_mapped; -- cgit From 8027b7c25dfa5b4617c4fafbf1e4aaf4f7fee43a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 01:47:01 +0100 Subject: Use netr_SamInfo3 in samlogon cache and use ndr functions for storing the blob. Guenther (This used to be commit bf860ae1ac6765b1eb6e2ca9b667b19b4e661fda) --- source3/libsmb/samlogon_cache.c | 217 ++++++++++++++++++++++------------------ 1 file changed, 119 insertions(+), 98 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index 4f791f66f6..e2a4b3898f 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -1,21 +1,21 @@ -/* +/* Unix SMB/CIFS implementation. Net_sam_logon info3 helpers Copyright (C) Alexander Bokovoy 2002. Copyright (C) Andrew Bartlett 2002. Copyright (C) Gerald Carter 2003. Copyright (C) Tim Potter 2003. - + 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 . */ @@ -29,12 +29,12 @@ static TDB_CONTEXT *netsamlogon_tdb = NULL; /*********************************************************************** open the tdb ***********************************************************************/ - + bool netsamlogon_cache_init(void) { if (!netsamlogon_tdb) { netsamlogon_tdb = tdb_open_log(lock_path(NETSAMLOGON_TDB), 0, - TDB_DEFAULT, O_RDWR | O_CREAT, 0600); + TDB_DEFAULT, O_RDWR | O_CREAT, 0600); } return (netsamlogon_tdb != NULL); @@ -47,37 +47,39 @@ bool netsamlogon_cache_init(void) bool netsamlogon_cache_shutdown(void) { - if(netsamlogon_tdb) + if (netsamlogon_tdb) { return (tdb_close(netsamlogon_tdb) == 0); - - return True; + } + + return true; } /*********************************************************************** Clear cache getpwnam and getgroups entries from the winbindd cache ***********************************************************************/ -void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, NET_USER_INFO_3 *user) + +void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, struct netr_SamInfo3 *info3) { - bool got_tdb = False; + bool got_tdb = false; DOM_SID sid; fstring key_str, sid_string; /* We may need to call this function from smbd which will not have - winbindd_cache.tdb open. Open the tdb if a NULL is passed. */ + winbindd_cache.tdb open. Open the tdb if a NULL is passed. */ if (!tdb) { - tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), + tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE, TDB_DEFAULT, O_RDWR, 0600); if (!tdb) { DEBUG(5, ("netsamlogon_clear_cached_user: failed to open cache\n")); return; } - got_tdb = True; + got_tdb = true; } - sid_copy(&sid, &user->dom_sid.sid); - sid_append_rid(&sid, user->user_rid); + sid_copy(&sid, info3->base.domain_sid); + sid_append_rid(&sid, info3->base.rid); /* Clear U/SID cache entry */ @@ -95,157 +97,176 @@ void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, NET_USER_INFO_3 *user) tdb_delete(tdb, string_tdb_data(key_str)); - if (got_tdb) + if (got_tdb) { tdb_close(tdb); + } } /*********************************************************************** - Store a NET_USER_INFO_3 structure in a tdb for later user + Store a netr_SamInfo3 structure in a tdb for later user username should be in UTF-8 format ***********************************************************************/ -bool netsamlogon_cache_store( const char *username, NET_USER_INFO_3 *user ) +bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3) { - TDB_DATA data; - fstring keystr, tmp; - prs_struct ps; - bool result = False; - DOM_SID user_sid; - time_t t = time(NULL); - TALLOC_CTX *mem_ctx; - + TDB_DATA data; + fstring keystr, tmp; + bool result = false; + DOM_SID user_sid; + time_t t = time(NULL); + TALLOC_CTX *mem_ctx; + DATA_BLOB blob; + enum ndr_err_code ndr_err; + struct netsamlogoncache_entry r; + + if (!info3) { + return false; + } if (!netsamlogon_cache_init()) { - DEBUG(0,("netsamlogon_cache_store: cannot open %s for write!\n", NETSAMLOGON_TDB)); - return False; + DEBUG(0,("netsamlogon_cache_store: cannot open %s for write!\n", + NETSAMLOGON_TDB)); + return false; } - sid_copy( &user_sid, &user->dom_sid.sid ); - sid_append_rid( &user_sid, user->user_rid ); + sid_copy(&user_sid, info3->base.domain_sid); + sid_append_rid(&user_sid, info3->base.rid); /* Prepare key as DOMAIN-SID/USER-RID string */ slprintf(keystr, sizeof(keystr), "%s", sid_to_fstring(tmp, &user_sid)); DEBUG(10,("netsamlogon_cache_store: SID [%s]\n", keystr)); - + + /* Prepare data */ + + if (!(mem_ctx = TALLOC_P( NULL, int))) { + DEBUG(0,("netsamlogon_cache_store: talloc() failed!\n")); + return false; + } + /* only Samba fills in the username, not sure why NT doesn't */ /* so we fill it in since winbindd_getpwnam() makes use of it */ - - if ( !user->uni_user_name.buffer ) { - init_unistr2( &user->uni_user_name, username, UNI_STR_TERMINATE ); - init_uni_hdr( &user->hdr_user_name, &user->uni_user_name ); + + if (!info3->base.account_name.string) { + info3->base.account_name.string = talloc_strdup(mem_ctx, username); } - - /* Prepare data */ - - if ( !(mem_ctx = TALLOC_P( NULL, int )) ) { - DEBUG(0,("netsamlogon_cache_store: talloc() failed!\n")); - return False; + + r.timestamp = t; + r.info3 = *info3; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(netsamlogoncache_entry, &r); } - prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); - - { - uint32 ts = (uint32)t; - if ( !prs_uint32( "timestamp", &ps, 0, &ts ) ) - return False; + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &r, + (ndr_push_flags_fn_t)ndr_push_netsamlogoncache_entry); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(0,("netsamlogon_cache_store: failed to push entry to cache\n")); + TALLOC_FREE(mem_ctx); + return false; } - - if ( net_io_user_info3("", user, &ps, 0, 3, 0) ) - { - data.dsize = prs_offset( &ps ); - data.dptr = (uint8 *)prs_data_p( &ps ); - if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) != -1) - result = True; - - prs_mem_free( &ps ); + data.dsize = blob.length; + data.dptr = blob.data; + + if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) != -1) { + result = true; } - TALLOC_FREE( mem_ctx ); - + TALLOC_FREE(mem_ctx); + return result; } /*********************************************************************** - Retrieves a NET_USER_INFO_3 structure from a tdb. Caller must + Retrieves a netr_SamInfo3 structure from a tdb. Caller must free the user_info struct (malloc()'d memory) ***********************************************************************/ -NET_USER_INFO_3* netsamlogon_cache_get( TALLOC_CTX *mem_ctx, const DOM_SID *user_sid) +struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid) { - NET_USER_INFO_3 *user = NULL; - TDB_DATA data; - prs_struct ps; - fstring keystr, tmp; - uint32 t; - + struct netr_SamInfo3 *info3 = NULL; + TDB_DATA data; + fstring keystr, tmp; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct netsamlogoncache_entry r; + if (!netsamlogon_cache_init()) { - DEBUG(0,("netsamlogon_cache_get: cannot open %s for write!\n", NETSAMLOGON_TDB)); - return False; + DEBUG(0,("netsamlogon_cache_get: cannot open %s for write!\n", + NETSAMLOGON_TDB)); + return false; } /* Prepare key as DOMAIN-SID/USER-RID string */ slprintf(keystr, sizeof(keystr), "%s", sid_to_fstring(tmp, user_sid)); DEBUG(10,("netsamlogon_cache_get: SID [%s]\n", keystr)); data = tdb_fetch_bystring( netsamlogon_tdb, keystr ); - - if ( data.dptr ) { - user = TALLOC_ZERO_P(mem_ctx, NET_USER_INFO_3); - if (user == NULL) { - return NULL; - } + if (!data.dptr) { + return NULL; + } - prs_init( &ps, 0, mem_ctx, UNMARSHALL ); - prs_give_memory( &ps, (char *)data.dptr, data.dsize, True ); - - if ( !prs_uint32( "timestamp", &ps, 0, &t ) ) { - prs_mem_free( &ps ); - TALLOC_FREE(user); - return False; - } - - if ( !net_io_user_info3("", user, &ps, 0, 3, 0) ) { - TALLOC_FREE( user ); - } - - prs_mem_free( &ps ); + info3 = TALLOC_ZERO_P(mem_ctx, struct netr_SamInfo3); + if (!info3) { + goto done; + } + + blob.data = (uint8 *)data.dptr; + blob.length = data.dsize; + + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, + (ndr_pull_flags_fn_t)ndr_pull_netsamlogoncache_entry); -#if 0 /* The netsamlogon cache needs to hang around. Something about + if (DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(netsamlogoncache_entry, &r); + } + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(0,("netsamlogon_cache_get: failed to pull entry from cache\n")); + tdb_delete(netsamlogon_tdb, data); + goto done; + } + + info3 = talloc_memdup(mem_ctx, &r.info3, sizeof(r.info3)); + + done: + SAFE_FREE(data.dptr); + + return info3; + +#if 0 /* The netsamlogon cache needs to hang around. Something about this feels wrong, but it is the only way we can get all of the groups. The old universal groups cache didn't expire either. --jerry */ { time_t now = time(NULL); uint32 time_diff; - + /* is the entry expired? */ time_diff = now - t; - + if ( (time_diff < 0 ) || (time_diff > lp_winbind_cache_time()) ) { DEBUG(10,("netsamlogon_cache_get: cache entry expired \n")); tdb_delete( netsamlogon_tdb, key ); TALLOC_FREE( user ); } -#endif } - - return user; +#endif } bool netsamlogon_cache_have(const DOM_SID *user_sid) { TALLOC_CTX *mem_ctx = talloc_init("netsamlogon_cache_have"); - NET_USER_INFO_3 *user = NULL; + struct netr_SamInfo3 *info3 = NULL; bool result; if (!mem_ctx) return False; - user = netsamlogon_cache_get(mem_ctx, user_sid); + info3 = netsamlogon_cache_get(mem_ctx, user_sid); - result = (user != NULL); + result = (info3 != NULL); talloc_destroy(mem_ctx); -- cgit From 86843631a2bf533d869be693e1b049ce634c0f6e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 01:57:20 +0100 Subject: Align our krb5 PAC decoding routines to the samba4 ones. (while keeping all the trans krb5 lib support) Guenther (This used to be commit c06e507737bb07ff995876e49341de3f60b0da35) --- source3/libads/authdata.c | 458 +++++++++++++++++++++++----------------------- 1 file changed, 224 insertions(+), 234 deletions(-) (limited to 'source3') diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c index 644f8515bc..1f90f76267 100644 --- a/source3/libads/authdata.c +++ b/source3/libads/authdata.c @@ -643,11 +643,11 @@ static bool pac_io_pac_data(const char *desc, PAC_DATA *data, return True; } -static NTSTATUS check_pac_checksum(TALLOC_CTX *mem_ctx, - DATA_BLOB pac_data, - PAC_SIGNATURE_DATA *sig, - krb5_context context, - krb5_keyblock *keyblock) +static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, + DATA_BLOB pac_data, + struct PAC_SIGNATURE_DATA *sig, + krb5_context context, + krb5_keyblock *keyblock) { krb5_error_code ret; krb5_checksum cksum; @@ -663,299 +663,289 @@ static NTSTATUS check_pac_checksum(TALLOC_CTX *mem_ctx, #error UNKNOWN_KRB5_KEYUSAGE #endif - ret = smb_krb5_verify_checksum(context, - keyblock, - usage, + ret = smb_krb5_verify_checksum(context, + keyblock, + usage, &cksum, - pac_data.data, + pac_data.data, pac_data.length); if (ret) { - DEBUG(2,("check_pac_checksum: PAC Verification failed: %s (%d)\n", + DEBUG(2,("check_pac_checksum: PAC Verification failed: %s (%d)\n", error_message(ret), ret)); - return NT_STATUS_ACCESS_DENIED; + return ret; } - return NT_STATUS_OK; -} - -static NTSTATUS parse_pac_data(TALLOC_CTX *mem_ctx, DATA_BLOB *pac_data_blob, PAC_DATA *pac_data) -{ - prs_struct ps; - PAC_DATA *my_pac; - - if (!prs_init(&ps, pac_data_blob->length, mem_ctx, UNMARSHALL)) - return NT_STATUS_NO_MEMORY; - - if (!prs_copy_data_in(&ps, (char *)pac_data_blob->data, pac_data_blob->length)) - return NT_STATUS_INVALID_PARAMETER; - - prs_set_offset(&ps, 0); - - my_pac = TALLOC_ZERO_P(mem_ctx, PAC_DATA); - if (!pac_io_pac_data("pac data", my_pac, &ps, 0)) - return NT_STATUS_INVALID_PARAMETER; - - prs_mem_free(&ps); - - *pac_data = *my_pac; - - return NT_STATUS_OK; -} - -/* just for debugging, will be removed later - Guenther */ -char *pac_group_attr_string(uint32 attr) -{ - fstring name = ""; - - if (!attr) - return NULL; - - if (attr & SE_GROUP_MANDATORY) fstrcat(name, "SE_GROUP_MANDATORY "); - if (attr & SE_GROUP_ENABLED_BY_DEFAULT) fstrcat(name, "SE_GROUP_ENABLED_BY_DEFAULT "); - if (attr & SE_GROUP_ENABLED) fstrcat(name, "SE_GROUP_ENABLED "); - if (attr & SE_GROUP_OWNER) fstrcat(name, "SE_GROUP_OWNER "); - if (attr & SE_GROUP_USE_FOR_DENY_ONLY) fstrcat(name, "SE_GROUP_USE_FOR_DENY_ONLY "); - if (attr & SE_GROUP_LOGON_ID) fstrcat(name, "SE_GROUP_LOGON_ID "); - if (attr & SE_GROUP_RESOURCE) fstrcat(name, "SE_GROUP_RESOURCE "); - - return SMB_STRDUP(name); + return ret; } -/* just for debugging, will be removed later - Guenther */ -void dump_pac_logon_info(int lvl, PAC_LOGON_INFO *logon_info) -{ - DOM_SID dom_sid, res_group_dom_sid; - int i; - char *attr_string; - uint32 user_flgs = logon_info->info3.user_flgs; - - if (logon_info->info3.ptr_res_group_dom_sid) { - sid_copy(&res_group_dom_sid, &logon_info->res_group_dom_sid.sid); - } - sid_copy(&dom_sid, &logon_info->info3.dom_sid.sid); - - DEBUG(lvl,("The PAC:\n")); - - DEBUGADD(lvl,("\tUser Flags: 0x%x (%d)\n", user_flgs, user_flgs)); - if (user_flgs & NETLOGON_EXTRA_SIDS) - DEBUGADD(lvl,("\tUser Flags: NETLOGON_EXTRA_SIDS 0x%x (%d)\n", NETLOGON_EXTRA_SIDS, NETLOGON_EXTRA_SIDS)); - if (user_flgs & NETLOGON_RESOURCE_GROUPS) - DEBUGADD(lvl,("\tUser Flags: NETLOGON_RESOURCE_GROUPS 0x%x (%d)\n", NETLOGON_RESOURCE_GROUPS, NETLOGON_RESOURCE_GROUPS)); - DEBUGADD(lvl,("\tUser SID: %s-%d\n", sid_string_dbg(&dom_sid), - logon_info->info3.user_rid)); - DEBUGADD(lvl,("\tGroup SID: %s-%d\n", sid_string_dbg(&dom_sid), - logon_info->info3.group_rid)); - - DEBUGADD(lvl,("\tGroup Membership (Global and Universal Groups of own domain):\n")); - for (i = 0; i < logon_info->info3.num_groups; i++) { - attr_string = pac_group_attr_string(logon_info->info3.gids[i].attr); - DEBUGADD(lvl,("\t\t%d: sid: %s-%d\n\t\t attr: 0x%x == %s\n", - i, sid_string_dbg(&dom_sid), - logon_info->info3.gids[i].g_rid, - logon_info->info3.gids[i].attr, - attr_string)); - SAFE_FREE(attr_string); - } - - DEBUGADD(lvl,("\tGroup Membership (Domain Local Groups and Groups from Trusted Domains):\n")); - for (i = 0; i < logon_info->info3.num_other_sids; i++) { - attr_string = pac_group_attr_string(logon_info->info3.other_sids_attrib[i]); - DEBUGADD(lvl,("\t\t%d: sid: %s\n\t\t attr: 0x%x == %s\n", - i, sid_string_dbg( - &logon_info->info3.other_sids[i].sid), - logon_info->info3.other_sids_attrib[i], - attr_string)); - SAFE_FREE(attr_string); - } - - DEBUGADD(lvl,("\tGroup Membership (Resource Groups (SID History ?)):\n")); - for (i = 0; i < logon_info->info3.res_group_count; i++) { - attr_string = pac_group_attr_string(logon_info->res_groups.group_membership[i].attrs); - DEBUGADD(lvl,("\t\t%d: sid: %s-%d\n\t\t attr: 0x%x == %s\n", - i, sid_string_dbg(&res_group_dom_sid), - logon_info->res_groups.group_membership[i].rid, - logon_info->res_groups.group_membership[i].attrs, - attr_string)); - SAFE_FREE(attr_string); - } -} +/**************************************************************** +****************************************************************/ NTSTATUS decode_pac_data(TALLOC_CTX *mem_ctx, DATA_BLOB *pac_data_blob, - krb5_context context, + krb5_context context, krb5_keyblock *service_keyblock, krb5_const_principal client_principal, time_t tgs_authtime, - PAC_DATA **pac_data) - + struct PAC_DATA **pac_data_out) { - DATA_BLOB modified_pac_blob; - PAC_DATA *my_pac; - NTSTATUS nt_status; + NTSTATUS status; + enum ndr_err_code ndr_err; krb5_error_code ret; - PAC_SIGNATURE_DATA *srv_sig = NULL; - PAC_SIGNATURE_DATA *kdc_sig = NULL; - PAC_LOGON_NAME *logon_name = NULL; - PAC_LOGON_INFO *logon_info = NULL; - krb5_principal client_principal_pac = NULL; - NTTIME tgs_authtime_nttime; - int i, srv_sig_pos = 0, kdc_sig_pos = 0; - fstring username; + DATA_BLOB modified_pac_blob; - *pac_data = NULL; + NTTIME tgs_authtime_nttime; + krb5_principal client_principal_pac = NULL; + int i; - my_pac = talloc(mem_ctx, PAC_DATA); - if (!my_pac) { + struct PAC_SIGNATURE_DATA *srv_sig_ptr = NULL; + struct PAC_SIGNATURE_DATA *kdc_sig_ptr = NULL; + struct PAC_SIGNATURE_DATA *srv_sig_wipe = NULL; + struct PAC_SIGNATURE_DATA *kdc_sig_wipe = NULL; + struct PAC_LOGON_NAME *logon_name = NULL; + struct PAC_LOGON_INFO *logon_info = NULL; + struct PAC_DATA *pac_data = NULL; + struct PAC_DATA_RAW *pac_data_raw = NULL; + + DATA_BLOB *srv_sig_blob = NULL; + DATA_BLOB *kdc_sig_blob = NULL; + + *pac_data_out = NULL; + + pac_data = TALLOC_ZERO_P(mem_ctx, struct PAC_DATA); + pac_data_raw = TALLOC_ZERO_P(mem_ctx, struct PAC_DATA_RAW); + kdc_sig_wipe = TALLOC_ZERO_P(mem_ctx, struct PAC_SIGNATURE_DATA); + srv_sig_wipe = TALLOC_ZERO_P(mem_ctx, struct PAC_SIGNATURE_DATA); + if (!pac_data_raw || !pac_data || !kdc_sig_wipe || !srv_sig_wipe) { return NT_STATUS_NO_MEMORY; } - nt_status = parse_pac_data(mem_ctx, pac_data_blob, my_pac); - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(0,("decode_pac_data: failed to parse PAC\n")); - return nt_status; + ndr_err = ndr_pull_struct_blob(pac_data_blob, pac_data, + pac_data, + (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("can't parse the PAC: %s\n", + nt_errstr(status))); + return status; } - modified_pac_blob = data_blob_talloc(mem_ctx, pac_data_blob->data, pac_data_blob->length); + if (pac_data->num_buffers < 4) { + /* we need logon_ingo, service_key and kdc_key */ + DEBUG(0,("less than 4 PAC buffers\n")); + return NT_STATUS_INVALID_PARAMETER; + } - if (my_pac->num_buffers < 4) { - nt_status = NT_STATUS_INVALID_PARAMETER; - goto out; + ndr_err = ndr_pull_struct_blob(pac_data_blob, pac_data_raw, + pac_data_raw, + (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA_RAW); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("can't parse the PAC: %s\n", + nt_errstr(status))); + return status; } - /* store signatures */ - for (i=0; i < my_pac->num_buffers; i++) { - - switch (my_pac->pac_buffer[i].type) { - - case PAC_TYPE_SERVER_CHECKSUM: - if (!my_pac->pac_buffer[i].ctr->pac.srv_cksum) { + if (pac_data_raw->num_buffers < 4) { + /* we need logon_ingo, service_key and kdc_key */ + DEBUG(0,("less than 4 PAC buffers\n")); + return NT_STATUS_INVALID_PARAMETER; + } + + if (pac_data->num_buffers != pac_data_raw->num_buffers) { + /* we need logon_ingo, service_key and kdc_key */ + DEBUG(0,("misparse! PAC_DATA has %d buffers while PAC_DATA_RAW has %d\n", + pac_data->num_buffers, pac_data_raw->num_buffers)); + return NT_STATUS_INVALID_PARAMETER; + } + + for (i=0; i < pac_data->num_buffers; i++) { + if (pac_data->buffers[i].type != pac_data_raw->buffers[i].type) { + DEBUG(0,("misparse! PAC_DATA buffer %d has type %d while PAC_DATA_RAW has %d\n", + i, pac_data->buffers[i].type, pac_data->buffers[i].type)); + return NT_STATUS_INVALID_PARAMETER; + } + switch (pac_data->buffers[i].type) { + case PAC_TYPE_LOGON_INFO: + if (!pac_data->buffers[i].info) { break; } - - srv_sig = my_pac->pac_buffer[i].ctr->pac.srv_cksum; - - /* get position of signature buffer */ - srv_sig_pos = my_pac->pac_buffer[i].offset; - srv_sig_pos += sizeof(uint32); - + logon_info = pac_data->buffers[i].info->logon_info.info; break; - - case PAC_TYPE_PRIVSVR_CHECKSUM: - if (!my_pac->pac_buffer[i].ctr->pac.privsrv_cksum) { + case PAC_TYPE_SRV_CHECKSUM: + if (!pac_data->buffers[i].info) { break; } - - kdc_sig = my_pac->pac_buffer[i].ctr->pac.privsrv_cksum; - - /* get position of signature buffer */ - kdc_sig_pos = my_pac->pac_buffer[i].offset; - kdc_sig_pos += sizeof(uint32); - + srv_sig_ptr = &pac_data->buffers[i].info->srv_cksum; + srv_sig_blob = &pac_data_raw->buffers[i].info->remaining; break; - - case PAC_TYPE_LOGON_NAME: - if (!my_pac->pac_buffer[i].ctr->pac.logon_name) { + case PAC_TYPE_KDC_CHECKSUM: + if (!pac_data->buffers[i].info) { break; } - - logon_name = my_pac->pac_buffer[i].ctr->pac.logon_name; + kdc_sig_ptr = &pac_data->buffers[i].info->kdc_cksum; + kdc_sig_blob = &pac_data_raw->buffers[i].info->remaining; + break; + case PAC_TYPE_LOGON_NAME: + logon_name = &pac_data->buffers[i].info->logon_name; break; + default: + break; + } + } - case PAC_TYPE_LOGON_INFO: - if (!my_pac->pac_buffer[i].ctr->pac.logon_info) { - break; - } + if (!logon_info) { + DEBUG(0,("PAC no logon_info\n")); + return NT_STATUS_INVALID_PARAMETER; + } - logon_info = my_pac->pac_buffer[i].ctr->pac.logon_info; - break; - } + if (!logon_name) { + DEBUG(0,("PAC no logon_name\n")); + return NT_STATUS_INVALID_PARAMETER; + } + if (!srv_sig_ptr || !srv_sig_blob) { + DEBUG(0,("PAC no srv_key\n")); + return NT_STATUS_INVALID_PARAMETER; } - if (!srv_sig || !kdc_sig || !logon_name || !logon_info) { - nt_status = NT_STATUS_INVALID_PARAMETER; - goto out; + if (!kdc_sig_ptr || !kdc_sig_blob) { + DEBUG(0,("PAC no kdc_key\n")); + return NT_STATUS_INVALID_PARAMETER; } - /* zero PAC_SIGNATURE_DATA signature buffer */ - memset(&modified_pac_blob.data[srv_sig_pos], '\0', srv_sig->signature.buf_len); - memset(&modified_pac_blob.data[kdc_sig_pos], '\0', kdc_sig->signature.buf_len); + /* Find and zero out the signatures, as required by the signing algorithm */ - /* check server signature */ - nt_status = check_pac_checksum(mem_ctx, modified_pac_blob, srv_sig, context, service_keyblock); - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(0,("decode_pac_data: failed to verify PAC server signature\n")); - goto out; + /* We find the data blobs above, now we parse them to get at the exact portion we should zero */ + ndr_err = ndr_pull_struct_blob(kdc_sig_blob, kdc_sig_wipe, + kdc_sig_wipe, + (ndr_pull_flags_fn_t)ndr_pull_PAC_SIGNATURE_DATA); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("can't parse the KDC signature: %s\n", + nt_errstr(status))); + return status; } - /* Convert to NT time, so as not to loose accuracy in comparison */ - unix_to_nt_time(&tgs_authtime_nttime, tgs_authtime); + ndr_err = ndr_pull_struct_blob(srv_sig_blob, srv_sig_wipe, + srv_sig_wipe, + (ndr_pull_flags_fn_t)ndr_pull_PAC_SIGNATURE_DATA); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("can't parse the SRV signature: %s\n", + nt_errstr(status))); + return status; + } - if (!nt_time_equals(&tgs_authtime_nttime, &logon_name->logon_time)) { - - DEBUG(2,("decode_pac_data: Logon time mismatch between ticket and PAC!\n")); - DEBUGADD(2, ("decode_pac_data: PAC: %s\n", - http_timestring(nt_time_to_unix(logon_name->logon_time)))); - DEBUGADD(2, ("decode_pac_data: Ticket: %s\n", - http_timestring(nt_time_to_unix(tgs_authtime_nttime)))); - - nt_status = NT_STATUS_ACCESS_DENIED; - goto out; + /* Now zero the decoded structure */ + memset(kdc_sig_wipe->signature.data, '\0', kdc_sig_wipe->signature.length); + memset(srv_sig_wipe->signature.data, '\0', srv_sig_wipe->signature.length); + + /* and reencode, back into the same place it came from */ + ndr_err = ndr_push_struct_blob(kdc_sig_blob, pac_data_raw, + kdc_sig_wipe, + (ndr_push_flags_fn_t)ndr_push_PAC_SIGNATURE_DATA); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("can't repack the KDC signature: %s\n", + nt_errstr(status))); + return status; + } + ndr_err = ndr_push_struct_blob(srv_sig_blob, pac_data_raw, + srv_sig_wipe, + (ndr_push_flags_fn_t)ndr_push_PAC_SIGNATURE_DATA); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("can't repack the SRV signature: %s\n", + nt_errstr(status))); + return status; } - if (!logon_name->len) { - DEBUG(2,("decode_pac_data: No Logon Name available\n")); - nt_status = NT_STATUS_INVALID_PARAMETER; - goto out; + /* push out the whole structure, but now with zero'ed signatures */ + ndr_err = ndr_push_struct_blob(&modified_pac_blob, pac_data_raw, + pac_data_raw, + (ndr_push_flags_fn_t)ndr_push_PAC_DATA_RAW); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("can't repack the RAW PAC: %s\n", + nt_errstr(status))); + return status; } - rpcstr_pull(username, logon_name->username, sizeof(username), logon_name->len, 0); - ret = smb_krb5_parse_name_norealm(context, username, &client_principal_pac); + /* verify by service_key */ + ret = check_pac_checksum(mem_ctx, + modified_pac_blob, srv_sig_ptr, + context, + service_keyblock); if (ret) { - DEBUG(2,("decode_pac_data: Could not parse name from incoming PAC: [%s]: %s\n", - username, error_message(ret))); - nt_status = NT_STATUS_INVALID_PARAMETER; - goto out; + DEBUG(1, ("PAC Decode: Failed to verify the service signature: %s\n", + error_message(ret))); + return NT_STATUS_ACCESS_DENIED; } - if (!smb_krb5_principal_compare_any_realm(context, client_principal, client_principal_pac)) { - DEBUG(2,("decode_pac_data: Name in PAC [%s] does not match principal name in ticket\n", - username)); - nt_status = NT_STATUS_ACCESS_DENIED; - goto out; + /* Convert to NT time, so as not to loose accuracy in comparison */ + unix_to_nt_time(&tgs_authtime_nttime, tgs_authtime); + + if (tgs_authtime_nttime != logon_name->logon_time) { + DEBUG(2, ("PAC Decode: Logon time mismatch between ticket and PAC!\n")); + DEBUG(2, ("PAC Decode: PAC: %s\n", nt_time_string(mem_ctx, logon_name->logon_time))); + DEBUG(2, ("PAC Decode: Ticket: %s\n", nt_time_string(mem_ctx, tgs_authtime_nttime))); + return NT_STATUS_ACCESS_DENIED; } - DEBUG(10,("Successfully validated Kerberos PAC\n")); + ret = smb_krb5_parse_name_norealm(context, logon_name->account_name, + &client_principal_pac); + if (ret) { + DEBUG(2, ("Could not parse name from incoming PAC: [%s]: %s\n", + logon_name->account_name, + error_message(ret))); + return NT_STATUS_INVALID_PARAMETER; + } - dump_pac_logon_info(10, logon_info); + if (!smb_krb5_principal_compare_any_realm(context, client_principal, client_principal_pac)) { + DEBUG(2, ("Name in PAC [%s] does not match principal name in ticket\n", + logon_name->account_name)); + krb5_free_principal(context, client_principal_pac); + return NT_STATUS_ACCESS_DENIED; + } - *pac_data = my_pac; + DEBUG(3,("Found account name from PAC: %s [%s]\n", + logon_info->info3.base.account_name.string, + logon_info->info3.base.full_name.string)); - nt_status = NT_STATUS_OK; + DEBUG(10,("Successfully validated Kerberos PAC\n")); -out: - if (client_principal_pac) { - krb5_free_principal(context, client_principal_pac); + if (DEBUGLEVEL >= 10) { + const char *s; + s = NDR_PRINT_STRUCT_STRING(mem_ctx, PAC_DATA, pac_data); + if (s) { + DEBUGADD(10,("%s\n", s)); + } } - return nt_status; + *pac_data_out = pac_data; + + return NT_STATUS_OK; } - PAC_LOGON_INFO *get_logon_info_from_pac(PAC_DATA *pac_data) +/**************************************************************** +****************************************************************/ + +struct PAC_LOGON_INFO *get_logon_info_from_pac(struct PAC_DATA *pac_data) { - PAC_LOGON_INFO *logon_info = NULL; int i; - + for (i=0; i < pac_data->num_buffers; i++) { - if (pac_data->pac_buffer[i].type != PAC_TYPE_LOGON_INFO) + if (pac_data->buffers[i].type != PAC_TYPE_LOGON_INFO) { continue; + } - logon_info = pac_data->pac_buffer[i].ctr->pac.logon_info; - break; + return pac_data->buffers[i].info->logon_info.info; } - return logon_info; + + return NULL; } /**************************************************************** @@ -971,12 +961,12 @@ NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx, bool request_pac, bool add_netbios_addr, time_t renewable_time, - PAC_DATA **pac_ret) + struct PAC_DATA **pac_ret) { krb5_error_code ret; NTSTATUS status = NT_STATUS_INVALID_PARAMETER; DATA_BLOB tkt, ap_rep, sesskey1, sesskey2; - PAC_DATA *pac_data = NULL; + struct PAC_DATA *pac_data = NULL; char *client_princ_out = NULL; const char *auth_princ = NULL; const char *local_service = NULL; @@ -1110,11 +1100,11 @@ static NTSTATUS kerberos_return_pac_logon_info(TALLOC_CTX *mem_ctx, bool request_pac, bool add_netbios_addr, time_t renewable_time, - PAC_LOGON_INFO **logon_info) + struct PAC_LOGON_INFO **logon_info) { NTSTATUS status; - PAC_DATA *pac_data = NULL; - PAC_LOGON_INFO *info = NULL; + struct PAC_DATA *pac_data = NULL; + struct PAC_LOGON_INFO *info = NULL; status = kerberos_return_pac(mem_ctx, name, @@ -1160,10 +1150,10 @@ NTSTATUS kerberos_return_info3_from_pac(TALLOC_CTX *mem_ctx, bool request_pac, bool add_netbios_addr, time_t renewable_time, - NET_USER_INFO_3 **info3) + struct netr_SamInfo3 **info3) { NTSTATUS status; - PAC_LOGON_INFO *logon_info = NULL; + struct PAC_LOGON_INFO *logon_info = NULL; status = kerberos_return_pac_logon_info(mem_ctx, name, -- cgit From 3ea40eda9435d91d9672fc054739cf1c926f2d2c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 01:57:57 +0100 Subject: Some more cleanup in authdata.c. Guenther (This used to be commit 5483f5fb44bb2138a1348c05845a2b8f3588697a) --- source3/libads/authdata.c | 628 +--------------------------------------------- 1 file changed, 7 insertions(+), 621 deletions(-) (limited to 'source3') diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c index 1f90f76267..79972875ac 100644 --- a/source3/libads/authdata.c +++ b/source3/libads/authdata.c @@ -1,23 +1,23 @@ -/* +/* Unix SMB/CIFS implementation. kerberos authorization data (PAC) utility library - Copyright (C) Jim McDonough 2003 + Copyright (C) Jim McDonough 2003 Copyright (C) Andrew Bartlett 2004-2005 Copyright (C) Andrew Tridgell 2001 Copyright (C) Luke Howard 2002-2003 Copyright (C) Stefan Metzmacher 2004-2005 Copyright (C) Guenther Deschner 2005,2007 - + 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 . */ @@ -26,622 +26,8 @@ #ifdef HAVE_KRB5 -static bool pac_io_logon_name(const char *desc, PAC_LOGON_NAME *logon_name, - prs_struct *ps, int depth) -{ - if (NULL == logon_name) - return False; - - prs_debug(ps, depth, desc, "pac_io_logon_name"); - depth++; - - if (!smb_io_time("logon_time", &logon_name->logon_time, ps, depth)) - return False; - - if (!prs_uint16("len", ps, depth, &logon_name->len)) - return False; - - /* The following string is always in little endian 16 bit values, - copy as 8 bits to avoid endian reversal on big-endian machines. - len is the length in bytes. */ - - if (UNMARSHALLING(ps) && logon_name->len) { - logon_name->username = PRS_ALLOC_MEM(ps, uint8, logon_name->len); - if (!logon_name->username) { - DEBUG(3, ("No memory available\n")); - return False; - } - } - - if (!prs_uint8s(True, "name", ps, depth, logon_name->username, logon_name->len)) - return False; - - return True; -} - -#if 0 /* Unused (handled now in net_io_user_info3()) - Guenther */ -static bool pac_io_krb_sids(const char *desc, KRB_SID_AND_ATTRS *sid_and_attr, - prs_struct *ps, int depth) -{ - if (NULL == sid_and_attr) - return False; - - prs_debug(ps, depth, desc, "pac_io_krb_sids"); - depth++; - - if (UNMARSHALLING(ps)) { - sid_and_attr->sid = PRS_ALLOC_MEM(ps, DOM_SID2, 1); - if (!sid_and_attr->sid) { - DEBUG(3, ("No memory available\n")); - return False; - } - } - - if(!smb_io_dom_sid2("sid", sid_and_attr->sid, ps, depth)) - return False; - - return True; -} - - -static bool pac_io_krb_attrs(const char *desc, KRB_SID_AND_ATTRS *sid_and_attr, - prs_struct *ps, int depth) -{ - if (NULL == sid_and_attr) - return False; - - prs_debug(ps, depth, desc, "pac_io_krb_attrs"); - depth++; - - if (!prs_uint32("sid_ptr", ps, depth, &sid_and_attr->sid_ptr)) - return False; - if (!prs_uint32("attrs", ps, depth, &sid_and_attr->attrs)) - return False; - - return True; -} - -static bool pac_io_krb_sid_and_attr_array(const char *desc, - KRB_SID_AND_ATTR_ARRAY *array, - uint32 num, - prs_struct *ps, int depth) -{ - int i; - - if (NULL == array) - return False; - - prs_debug(ps, depth, desc, "pac_io_krb_sid_and_attr_array"); - depth++; - - - if (!prs_uint32("count", ps, depth, &array->count)) - return False; - - if (UNMARSHALLING(ps)) { - if (num) { - array->krb_sid_and_attrs = PRS_ALLOC_MEM(ps, KRB_SID_AND_ATTRS, num); - if (!array->krb_sid_and_attrs) { - DEBUG(3, ("No memory available\n")); - return False; - } - } else { - array->krb_sid_and_attrs = NULL; - } - } - - for (i=0; ikrb_sid_and_attrs[i], - ps, depth)) - return False; - - } - for (i=0; ikrb_sid_and_attrs[i], - ps, depth)) - return False; - - } - - return True; - -} -#endif - -static bool pac_io_group_membership(const char *desc, - GROUP_MEMBERSHIP *membership, - prs_struct *ps, int depth) -{ - if (NULL == membership) - return False; - - prs_debug(ps, depth, desc, "pac_io_group_membership"); - depth++; - - if (!prs_uint32("rid", ps, depth, &membership->rid)) - return False; - if (!prs_uint32("attrs", ps, depth, &membership->attrs)) - return False; - - return True; -} - - -static bool pac_io_group_membership_array(const char *desc, - GROUP_MEMBERSHIP_ARRAY *array, - uint32 num, - prs_struct *ps, int depth) -{ - int i; - - if (NULL == array) - return False; - - prs_debug(ps, depth, desc, "pac_io_group_membership_array"); - depth++; - - - if (!prs_uint32("count", ps, depth, &array->count)) - return False; - - if (UNMARSHALLING(ps)) { - if (num) { - array->group_membership = PRS_ALLOC_MEM(ps, GROUP_MEMBERSHIP, num); - if (!array->group_membership) { - DEBUG(3, ("No memory available\n")); - return False; - } - } else { - array->group_membership = NULL; - } - } - - for (i=0; igroup_membership[i], - ps, depth)) - return False; - - } - - return True; - -} - -#if 0 /* Unused, replaced using an expanded net_io_user_info3() now - Guenther */ -static bool pac_io_pac_logon_info(const char *desc, PAC_LOGON_INFO *info, - prs_struct *ps, int depth) -{ - uint32 garbage = 0, i; - - if (NULL == info) - return False; - - prs_debug(ps, depth, desc, "pac_io_pac_logon_info"); - depth++; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("unknown", ps, depth, &garbage)) /* 00081001 */ - return False; - if (!prs_uint32("unknown", ps, depth, &garbage)) /* cccccccc */ - return False; - if (!prs_uint32("bufferlen", ps, depth, &garbage)) - return False; - if (!prs_uint32("bufferlenhi", ps, depth, &garbage)) /* 00000000 */ - return False; - - if (!prs_uint32("pointer", ps, depth, &garbage)) - return False; - - if (!prs_align(ps)) - return False; - if (!smb_io_time("logon_time", &info->logon_time, ps, depth)) - return False; - if (!smb_io_time("logoff_time", &info->logoff_time, ps, depth)) - return False; - if (!smb_io_time("kickoff_time", &info->kickoff_time, ps, depth)) - return False; - if (!smb_io_time("pass_last_set_time", &info->pass_last_set_time, - ps, depth)) - return False; - if (!smb_io_time("pass_can_change_time", &info->pass_can_change_time, - ps, depth)) - return False; - if (!smb_io_time("pass_must_change_time", &info->pass_must_change_time, - ps, depth)) - return False; - - if (!smb_io_unihdr("hdr_user_name", &info->hdr_user_name, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_full_name", &info->hdr_full_name, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_logon_script", &info->hdr_logon_script, - ps, depth)) - return False; - if (!smb_io_unihdr("hdr_profile_path", &info->hdr_profile_path, - ps, depth)) - return False; - if (!smb_io_unihdr("hdr_home_dir", &info->hdr_home_dir, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_dir_drive", &info->hdr_dir_drive, ps, depth)) - return False; - - if (!prs_uint16("logon_count", ps, depth, &info->logon_count)) - return False; - if (!prs_uint16("bad_password_count", ps, depth, &info->bad_password_count)) - return False; - if (!prs_uint32("user_rid", ps, depth, &info->user_rid)) - return False; - if (!prs_uint32("group_rid", ps, depth, &info->group_rid)) - return False; - if (!prs_uint32("group_count", ps, depth, &info->group_count)) - return False; - /* I haven't seen this contain anything yet, but when it does - we will have to make sure we decode the contents in the middle - all the unistr2s ... */ - if (!prs_uint32("group_mem_ptr", ps, depth, - &info->group_membership_ptr)) - return False; - if (!prs_uint32("user_flags", ps, depth, &info->user_flags)) - return False; - - if (!prs_uint8s(False, "session_key", ps, depth, info->session_key, 16)) - return False; - - if (!smb_io_unihdr("hdr_dom_controller", - &info->hdr_dom_controller, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth)) - return False; - - /* this should be followed, but just get ptr for now */ - if (!prs_uint32("ptr_dom_sid", ps, depth, &info->ptr_dom_sid)) - return False; - - if (!prs_uint8s(False, "lm_session_key", ps, depth, info->lm_session_key, 8)) - return False; - - if (!prs_uint32("acct_flags", ps, depth, &info->acct_flags)) - return False; - - for (i = 0; i < 7; i++) - { - if (!prs_uint32("unkown", ps, depth, &info->unknown[i])) /* unknown */ - return False; - } - - if (!prs_uint32("sid_count", ps, depth, &info->sid_count)) - return False; - if (!prs_uint32("ptr_extra_sids", ps, depth, &info->ptr_extra_sids)) - return False; - if (!prs_uint32("ptr_res_group_dom_sid", ps, depth, - &info->ptr_res_group_dom_sid)) - return False; - if (!prs_uint32("res_group_count", ps, depth, &info->res_group_count)) - return False; - if (!prs_uint32("ptr_res_groups", ps, depth, &info->ptr_res_groups)) - return False; - - if(!smb_io_unistr2("uni_user_name", &info->uni_user_name, - info->hdr_user_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_full_name", &info->uni_full_name, - info->hdr_full_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_logon_script", &info->uni_logon_script, - info->hdr_logon_script.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_profile_path", &info->uni_profile_path, - info->hdr_profile_path.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_home_dir", &info->uni_home_dir, - info->hdr_home_dir.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_dir_drive", &info->uni_dir_drive, - info->hdr_dir_drive.buffer, ps, depth)) - return False; - - if (info->group_membership_ptr) { - if (!pac_io_group_membership_array("group membership", - &info->groups, - info->group_count, - ps, depth)) - return False; - } - - - if(!smb_io_unistr2("uni_dom_controller", &info->uni_dom_controller, - info->hdr_dom_controller.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_dom_name", &info->uni_dom_name, - info->hdr_dom_name.buffer, ps, depth)) - return False; - - if(info->ptr_dom_sid) - if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth)) - return False; - - - if (info->sid_count && info->ptr_extra_sids) - if (!pac_io_krb_sid_and_attr_array("extra_sids", - &info->extra_sids, - info->sid_count, - ps, depth)) - return False; - - if (info->ptr_res_group_dom_sid) - if (!smb_io_dom_sid2("res_group_dom_sid", - &info->res_group_dom_sid, ps, depth)) - return False; - - if (info->ptr_res_groups) { - - if (!(info->user_flgs & LOGON_RESOURCE_GROUPS)) { - DEBUG(0,("user_flgs attribute does not have LOGON_RESOURCE_GROUPS\n")); - /* return False; */ - } - - if (!pac_io_group_membership_array("res group membership", - &info->res_groups, - info->res_group_count, - ps, depth)) - return False; - } - - return True; -} -#endif - -static bool pac_io_pac_logon_info(const char *desc, PAC_LOGON_INFO *info, - prs_struct *ps, int depth) -{ - uint32 garbage = 0; - bool kerb_validation_info = True; - - if (NULL == info) - return False; - - prs_debug(ps, depth, desc, "pac_io_pac_logon_info"); - depth++; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("unknown", ps, depth, &garbage)) /* 00081001 */ - return False; - if (!prs_uint32("unknown", ps, depth, &garbage)) /* cccccccc */ - return False; - if (!prs_uint32("bufferlen", ps, depth, &garbage)) - return False; - if (!prs_uint32("bufferlenhi", ps, depth, &garbage)) /* 00000000 */ - return False; - - if(!net_io_user_info3("", &info->info3, ps, depth, 3, kerb_validation_info)) - return False; - - if (info->info3.ptr_res_group_dom_sid) { - if (!smb_io_dom_sid2("res_group_dom_sid", - &info->res_group_dom_sid, ps, depth)) - return False; - } - - if (info->info3.ptr_res_groups) { - - if (!(info->info3.user_flgs & NETLOGON_RESOURCE_GROUPS)) { - DEBUG(0,("user_flgs attribute does not have NETLOGON_RESOURCE_GROUPS\n")); - /* return False; */ - } - - if (!pac_io_group_membership_array("res group membership", - &info->res_groups, - info->info3.res_group_count, - ps, depth)) - return False; - } - - return True; -} - - - -static bool pac_io_pac_signature_data(const char *desc, - PAC_SIGNATURE_DATA *data, uint32 length, - prs_struct *ps, int depth) -{ - uint32 siglen = 0; - - prs_debug(ps, depth, desc, "pac_io_pac_signature_data"); - depth++; - - if (data == NULL) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("type", ps, depth, &data->type)) - return False; - - if ( length > sizeof(uint32) ) - siglen = length - sizeof(uint32); - - if (UNMARSHALLING(ps) && length) { - if (siglen) { - data->signature.buffer = PRS_ALLOC_MEM(ps, uint8, siglen); - if (!data->signature.buffer) { - DEBUG(3, ("No memory available\n")); - return False; - } - } else { - data->signature.buffer = NULL; - } - } - - data->signature.buf_len = siglen; - - if (!prs_uint8s(False, "signature", ps, depth, data->signature.buffer, data->signature.buf_len)) - return False; - - - return True; -} - -static bool pac_io_pac_info_hdr_ctr(const char *desc, PAC_BUFFER *hdr, - prs_struct *ps, int depth) -{ - if (NULL == hdr) - return False; - - prs_debug(ps, depth, desc, "pac_io_pac_info_hdr_ctr"); - depth++; - - if (!prs_align(ps)) - return False; - - if (hdr->offset != prs_offset(ps)) { - DEBUG(5,("offset in header(x%x) and data(x%x) do not match, correcting\n", - hdr->offset, prs_offset(ps))); - prs_set_offset(ps, hdr->offset); - } - - if (UNMARSHALLING(ps) && hdr->size > 0) { - hdr->ctr = PRS_ALLOC_MEM(ps, PAC_INFO_CTR, 1); - if (!hdr->ctr) { - DEBUG(3, ("No memory available\n")); - return False; - } - } - - switch(hdr->type) { - case PAC_TYPE_LOGON_INFO: - DEBUG(5, ("PAC_TYPE_LOGON_INFO\n")); - if (UNMARSHALLING(ps)) - hdr->ctr->pac.logon_info = PRS_ALLOC_MEM(ps, PAC_LOGON_INFO, 1); - if (!hdr->ctr->pac.logon_info) { - DEBUG(3, ("No memory available\n")); - return False; - } - if (!pac_io_pac_logon_info(desc, hdr->ctr->pac.logon_info, - ps, depth)) - return False; - break; - - case PAC_TYPE_SERVER_CHECKSUM: - DEBUG(5, ("PAC_TYPE_SERVER_CHECKSUM\n")); - if (UNMARSHALLING(ps)) - hdr->ctr->pac.srv_cksum = PRS_ALLOC_MEM(ps, PAC_SIGNATURE_DATA, 1); - if (!hdr->ctr->pac.srv_cksum) { - DEBUG(3, ("No memory available\n")); - return False; - } - if (!pac_io_pac_signature_data(desc, hdr->ctr->pac.srv_cksum, - hdr->size, ps, depth)) - return False; - break; - - case PAC_TYPE_PRIVSVR_CHECKSUM: - DEBUG(5, ("PAC_TYPE_PRIVSVR_CHECKSUM\n")); - if (UNMARSHALLING(ps)) - hdr->ctr->pac.privsrv_cksum = PRS_ALLOC_MEM(ps, PAC_SIGNATURE_DATA, 1); - if (!hdr->ctr->pac.privsrv_cksum) { - DEBUG(3, ("No memory available\n")); - return False; - } - if (!pac_io_pac_signature_data(desc, - hdr->ctr->pac.privsrv_cksum, - hdr->size, ps, depth)) - return False; - break; - - case PAC_TYPE_LOGON_NAME: - DEBUG(5, ("PAC_TYPE_LOGON_NAME\n")); - if (UNMARSHALLING(ps)) - hdr->ctr->pac.logon_name = PRS_ALLOC_MEM(ps, PAC_LOGON_NAME, 1); - if (!hdr->ctr->pac.logon_name) { - DEBUG(3, ("No memory available\n")); - return False; - } - if (!pac_io_logon_name(desc, hdr->ctr->pac.logon_name, - ps, depth)) - return False; - break; - - default: - /* dont' know, so we need to skip it */ - DEBUG(3, ("unknown PAC type %d\n", hdr->type)); - prs_set_offset(ps, prs_offset(ps) + hdr->size); - } - -#if 0 - /* obscure pad */ - if (!prs_uint32("pad", ps, depth, &hdr->pad)) - return False; -#endif - return True; -} - -static bool pac_io_pac_info_hdr(const char *desc, PAC_BUFFER *hdr, - prs_struct *ps, int depth) -{ - if (NULL == hdr) - return False; - - prs_debug(ps, depth, desc, "pac_io_pac_info_hdr"); - depth++; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("type", ps, depth, &hdr->type)) - return False; - if (!prs_uint32("size", ps, depth, &hdr->size)) - return False; - if (!prs_uint32("offset", ps, depth, &hdr->offset)) - return False; - if (!prs_uint32("offsethi", ps, depth, &hdr->offsethi)) - return False; - - return True; -} - -static bool pac_io_pac_data(const char *desc, PAC_DATA *data, - prs_struct *ps, int depth) -{ - int i; - - if (NULL == data) - return False; - - prs_debug(ps, depth, desc, "pac_io_pac_data"); - depth++; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("num_buffers", ps, depth, &data->num_buffers)) - return False; - if (!prs_uint32("version", ps, depth, &data->version)) - return False; - - if (UNMARSHALLING(ps) && data->num_buffers > 0) { - if ((data->pac_buffer = PRS_ALLOC_MEM(ps, PAC_BUFFER, data->num_buffers)) == NULL) { - return False; - } - } - - for (i=0; inum_buffers; i++) { - if (!pac_io_pac_info_hdr(desc, &data->pac_buffer[i], ps, - depth)) - return False; - } - - for (i=0; inum_buffers; i++) { - if (!pac_io_pac_info_hdr_ctr(desc, &data->pac_buffer[i], - ps, depth)) - return False; - } - - return True; -} +/**************************************************************** +****************************************************************/ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, DATA_BLOB pac_data, -- cgit From c1793b2b316a8f912dde14f806c84ac7d1491bf3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 01:59:02 +0100 Subject: Use new IDL based PAC structures in clikrb5.c Guenther (This used to be commit 3b0135d57e1e70175a5eec49b603a2e5f700c770) --- source3/include/includes.h | 9 ++++----- source3/libsmb/clikrb5.c | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'source3') diff --git a/source3/include/includes.h b/source3/include/includes.h index 041c431a58..02edbb0401 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -1170,15 +1170,15 @@ bool kerberos_compatible_enctypes(krb5_context context, krb5_enctype enctype1, k void kerberos_free_data_contents(krb5_context context, krb5_data *pdata); NTSTATUS decode_pac_data(TALLOC_CTX *mem_ctx, DATA_BLOB *pac_data_blob, - krb5_context context, + krb5_context context, krb5_keyblock *service_keyblock, krb5_const_principal client_principal, time_t tgs_authtime, - PAC_DATA **pac_data); + struct PAC_DATA **pac_data_out); void smb_krb5_checksum_from_pac_sig(krb5_checksum *cksum, - PAC_SIGNATURE_DATA *sig); + struct PAC_SIGNATURE_DATA *sig); krb5_error_code smb_krb5_verify_checksum(krb5_context context, - krb5_keyblock *keyblock, + const krb5_keyblock *keyblock, krb5_keyusage usage, krb5_checksum *cksum, uint8 *data, @@ -1206,7 +1206,6 @@ bool smb_krb5_principal_compare_any_realm(krb5_context context, krb5_const_principal princ2); int cli_krb5_get_ticket(const char *principal, time_t time_offset, DATA_BLOB *ticket, DATA_BLOB *session_key_krb5, uint32 extra_ap_opts, const char *ccname, time_t *tgs_expire); -PAC_LOGON_INFO *get_logon_info_from_pac(PAC_DATA *pac_data); krb5_error_code smb_krb5_renew_ticket(const char *ccache_string, const char *client_string, const char *service_string, time_t *expire_time); krb5_error_code kpasswd_err_to_krb5_err(krb5_error_code res_code); krb5_error_code smb_krb5_gen_netbios_krb5_address(smb_krb5_addresses **kerb_addr); diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c index 844a3b35c0..c289740ab2 100644 --- a/source3/libsmb/clikrb5.c +++ b/source3/libsmb/clikrb5.c @@ -835,22 +835,22 @@ failed: #endif } - void smb_krb5_checksum_from_pac_sig(krb5_checksum *cksum, - PAC_SIGNATURE_DATA *sig) + void smb_krb5_checksum_from_pac_sig(krb5_checksum *cksum, + struct PAC_SIGNATURE_DATA *sig) { #ifdef HAVE_CHECKSUM_IN_KRB5_CHECKSUM cksum->cksumtype = (krb5_cksumtype)sig->type; - cksum->checksum.length = sig->signature.buf_len; - cksum->checksum.data = sig->signature.buffer; + cksum->checksum.length = sig->signature.length; + cksum->checksum.data = sig->signature.data; #else cksum->checksum_type = (krb5_cksumtype)sig->type; - cksum->length = sig->signature.buf_len; - cksum->contents = sig->signature.buffer; + cksum->length = sig->signature.length; + cksum->contents = sig->signature.data; #endif } krb5_error_code smb_krb5_verify_checksum(krb5_context context, - krb5_keyblock *keyblock, + const krb5_keyblock *keyblock, krb5_keyusage usage, krb5_checksum *cksum, uint8 *data, -- cgit From 965774fa8f78a6b0f3306d356fd0d17a2a8943df Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:01:30 +0100 Subject: Fix some more callers of PAC_DATA. Guenther (This used to be commit ea609d1b0e82d7c366dd73013228003136264b64) --- source3/libads/kerberos_verify.c | 2 +- source3/utils/net_ads.c | 8 +++++--- source3/utils/ntlm_auth.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c index 5ce7aa6b45..f112dd34e3 100644 --- a/source3/libads/kerberos_verify.c +++ b/source3/libads/kerberos_verify.c @@ -309,7 +309,7 @@ NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx, time_t time_offset, const DATA_BLOB *ticket, char **principal, - PAC_DATA **pac_data, + struct PAC_DATA **pac_data, DATA_BLOB *ap_rep, DATA_BLOB *session_key, bool use_replay_cache) diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 732ba8d8b6..fb644ba55e 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -2519,8 +2519,8 @@ static int net_ads_kerberos_renew(int argc, const char **argv) static int net_ads_kerberos_pac(int argc, const char **argv) { - PAC_DATA *pac = NULL; - PAC_LOGON_INFO *info = NULL; + struct PAC_DATA *pac = NULL; + struct PAC_LOGON_INFO *info = NULL; TALLOC_CTX *mem_ctx = NULL; NTSTATUS status; int ret = -1; @@ -2551,7 +2551,9 @@ static int net_ads_kerberos_pac(int argc, const char **argv) info = get_logon_info_from_pac(pac); if (info) { - dump_pac_logon_info(0, info); + const char *s; + s = NDR_PRINT_STRUCT_STRING(mem_ctx, PAC_LOGON_INFO, info); + d_printf("The Pac: %s\n", s); } ret = 0; diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index a3a403d7bd..9e9da2a66f 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -1215,7 +1215,7 @@ static void manage_gss_spnego_request(struct ntlm_auth_state *state, char *principal; DATA_BLOB ap_rep; DATA_BLOB session_key; - PAC_DATA *pac_data = NULL; + struct PAC_DATA *pac_data = NULL; if ( request.negTokenInit.mechToken.data == NULL ) { DEBUG(1, ("Client did not provide Kerberos data\n")); -- cgit From c6f82f1cc4a08138e5b78d1504ac4f9ea44f81ee Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:04:52 +0100 Subject: Getting rid of net_io_user_info3() when sending an NDR encoded netr_SamInfo3. Guenther (This used to be commit f22ba8aee2ff90e9e34db066d506fec24c52379f) --- source3/winbindd/winbindd_pam.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'source3') diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c index e3574bbcd6..ad87fd2c67 100644 --- a/source3/winbindd/winbindd_pam.c +++ b/source3/winbindd/winbindd_pam.c @@ -128,29 +128,31 @@ static NTSTATUS append_info3_as_txt(TALLOC_CTX *mem_ctx, static NTSTATUS append_info3_as_ndr(TALLOC_CTX *mem_ctx, struct winbindd_cli_state *state, - NET_USER_INFO_3 *info3) + struct netr_SamInfo3 *info3) { - prs_struct ps; - uint32 size; - if (!prs_init(&ps, 256 /* Random, non-zero number */, mem_ctx, MARSHALL)) { - return NT_STATUS_NO_MEMORY; - } - if (!net_io_user_info3("", info3, &ps, 1, 3, False)) { - prs_mem_free(&ps); - return NT_STATUS_UNSUCCESSFUL; + DATA_BLOB blob; + enum ndr_err_code ndr_err; + + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, info3, + (ndr_push_flags_fn_t)ndr_push_netr_SamInfo3); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(0,("append_info3_as_ndr: failed to append\n")); + return ndr_map_error2ntstatus(ndr_err); } - size = prs_data_size(&ps); SAFE_FREE(state->response.extra_data.data); - state->response.extra_data.data = SMB_MALLOC(size); + state->response.extra_data.data = SMB_MALLOC(blob.length); if (!state->response.extra_data.data) { - prs_mem_free(&ps); + data_blob_free(&blob); return NT_STATUS_NO_MEMORY; } - memset( state->response.extra_data.data, '\0', size ); - prs_copy_all_data_out((char *)state->response.extra_data.data, &ps); - state->response.length += size; - prs_mem_free(&ps); + + memset(state->response.extra_data.data, '\0', blob.length); + memcpy(state->response.extra_data.data, blob.data, blob.length); + state->response.length += blob.length; + + data_blob_free(&blob); + return NT_STATUS_OK; } -- cgit From c35ae5943d5622351f447a5c2a1311c05d4af0c7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:06:17 +0100 Subject: Add some more samlogon related netlogon init functions. Guenther (This used to be commit df90a37c3e765faf69a77522d58e3a5f7f70b418) --- source3/rpc_client/init_netlogon.c | 71 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'source3') diff --git a/source3/rpc_client/init_netlogon.c b/source3/rpc_client/init_netlogon.c index 73e8717b46..f63c54999f 100644 --- a/source3/rpc_client/init_netlogon.c +++ b/source3/rpc_client/init_netlogon.c @@ -136,3 +136,74 @@ void init_netr_SamInfo3(struct netr_SamInfo3 *r, r->sids = sids; } +/******************************************************************* + inits a structure. +********************************************************************/ + +void init_netr_IdentityInfo(struct netr_IdentityInfo *r, + const char *domain_name, + uint32_t parameter_control, + uint32_t logon_id_low, + uint32_t logon_id_high, + const char *account_name, + const char *workstation) +{ + init_lsa_String(&r->domain_name, domain_name); + r->parameter_control = parameter_control; + r->logon_id_low = logon_id_low; + r->logon_id_high = logon_id_high; + init_lsa_String(&r->account_name, account_name); + init_lsa_String(&r->workstation, workstation); +} + +/******************************************************************* + inits a structure. +********************************************************************/ + +void init_netr_NetworkInfo(struct netr_NetworkInfo *r, + const char *domain_name, + uint32_t parameter_control, + uint32_t logon_id_low, + uint32_t logon_id_high, + const char *account_name, + const char *workstation, + uint8_t challenge[8], + struct netr_ChallengeResponse nt, + struct netr_ChallengeResponse lm) +{ + init_netr_IdentityInfo(&r->identity_info, + domain_name, + parameter_control, + logon_id_low, + logon_id_high, + account_name, + workstation); + memcpy(r->challenge, challenge, 8); + r->nt = nt; + r->lm = lm; +} + +/******************************************************************* + inits a structure. +********************************************************************/ + +void init_netr_PasswordInfo(struct netr_PasswordInfo *r, + const char *domain_name, + uint32_t parameter_control, + uint32_t logon_id_low, + uint32_t logon_id_high, + const char *account_name, + const char *workstation, + struct samr_Password lmpassword, + struct samr_Password ntpassword) +{ + init_netr_IdentityInfo(&r->identity_info, + domain_name, + parameter_control, + logon_id_low, + logon_id_high, + account_name, + workstation); + r->lmpassword = lmpassword; + r->ntpassword = ntpassword; +} -- cgit From c25958a046bbcfc13db200430e505ac4ee9b3f27 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:08:12 +0100 Subject: Use netr_SamInfo3 everywhere in winbindd. Guenther (This used to be commit d9502eb75395131d5a8130ff2c4ebace106cb974) --- source3/winbindd/winbindd_ads.c | 10 +- source3/winbindd/winbindd_cache.c | 2 +- source3/winbindd/winbindd_creds.c | 14 +-- source3/winbindd/winbindd_pam.c | 203 +++++++++++++++++--------------------- source3/winbindd/winbindd_rpc.c | 14 +-- source3/winbindd/winbindd_util.c | 18 ++-- 6 files changed, 122 insertions(+), 139 deletions(-) (limited to 'source3') diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c index db7ceca04d..0900d56987 100644 --- a/source3/winbindd/winbindd_ads.c +++ b/source3/winbindd/winbindd_ads.c @@ -421,7 +421,7 @@ static NTSTATUS query_user(struct winbindd_domain *domain, char *sidstr; uint32 group_rid; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - NET_USER_INFO_3 *user; + struct netr_SamInfo3 *user = NULL; DEBUG(3,("ads: query_user\n")); @@ -437,11 +437,11 @@ static NTSTATUS query_user(struct winbindd_domain *domain, DEBUG(5,("query_user: Cache lookup succeeded for %s\n", sid_string_dbg(sid))); - sid_compose(&info->user_sid, &domain->sid, user->user_rid); - sid_compose(&info->group_sid, &domain->sid, user->group_rid); + sid_compose(&info->user_sid, &domain->sid, user->base.rid); + sid_compose(&info->group_sid, &domain->sid, user->base.primary_gid); - info->acct_name = unistr2_to_ascii_talloc(mem_ctx, &user->uni_user_name); - info->full_name = unistr2_to_ascii_talloc(mem_ctx, &user->uni_full_name); + info->acct_name = talloc_strdup(mem_ctx, user->base.account_name.string); + info->full_name = talloc_strdup(mem_ctx, user->base.full_name.string); nss_get_info_cached( domain, sid, mem_ctx, NULL, NULL, &info->homedir, &info->shell, &info->full_name, diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index f235e401e8..4d81ee3960 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -2248,7 +2248,7 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, /* Invalidate the getpwnam and getgroups entries for a winbindd domain */ void wcache_invalidate_samlogon(struct winbindd_domain *domain, - NET_USER_INFO_3 *info3) + struct netr_SamInfo3 *info3) { struct winbind_cache *cache; diff --git a/source3/winbindd/winbindd_creds.c b/source3/winbindd/winbindd_creds.c index 4dbace5bcc..9c7acd64e6 100644 --- a/source3/winbindd/winbindd_creds.c +++ b/source3/winbindd/winbindd_creds.c @@ -29,11 +29,11 @@ NTSTATUS winbindd_get_creds(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *sid, - NET_USER_INFO_3 **info3, + struct netr_SamInfo3 **info3, const uint8 *cached_nt_pass[NT_HASH_LEN], const uint8 *cred_salt[NT_HASH_LEN]) { - NET_USER_INFO_3 *info; + struct netr_SamInfo3 *info; NTSTATUS status; status = wcache_get_creds(domain, mem_ctx, sid, cached_nt_pass, cred_salt); @@ -56,7 +56,7 @@ NTSTATUS winbindd_store_creds(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const char *user, const char *pass, - NET_USER_INFO_3 *info3, + struct netr_SamInfo3 *info3, const DOM_SID *user_sid) { NTSTATUS status; @@ -66,10 +66,10 @@ NTSTATUS winbindd_store_creds(struct winbindd_domain *domain, if (info3 != NULL) { DOM_SID sid; - sid_copy(&sid, &(info3->dom_sid.sid)); - sid_append_rid(&sid, info3->user_rid); + sid_copy(&sid, info3->base.domain_sid); + sid_append_rid(&sid, info3->base.rid); sid_copy(&cred_sid, &sid); - info3->user_flgs |= NETLOGON_CACHED_ACCOUNT; + info3->base.user_flags |= NETLOGON_CACHED_ACCOUNT; } else if (user_sid != NULL) { @@ -138,7 +138,7 @@ NTSTATUS winbindd_update_creds_by_info3(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const char *user, const char *pass, - NET_USER_INFO_3 *info3) + struct netr_SamInfo3 *info3) { return winbindd_store_creds(domain, mem_ctx, user, pass, info3, NULL); } diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c index ad87fd2c67..79b4c764c3 100644 --- a/source3/winbindd/winbindd_pam.c +++ b/source3/winbindd/winbindd_pam.c @@ -29,83 +29,75 @@ static NTSTATUS append_info3_as_txt(TALLOC_CTX *mem_ctx, struct winbindd_cli_state *state, - NET_USER_INFO_3 *info3) + struct netr_SamInfo3 *info3) { char *ex; size_t size; uint32_t i; state->response.data.auth.info3.logon_time = - nt_time_to_unix(info3->logon_time); + nt_time_to_unix(info3->base.last_logon); state->response.data.auth.info3.logoff_time = - nt_time_to_unix(info3->logoff_time); + nt_time_to_unix(info3->base.last_logoff); state->response.data.auth.info3.kickoff_time = - nt_time_to_unix(info3->kickoff_time); + nt_time_to_unix(info3->base.acct_expiry); state->response.data.auth.info3.pass_last_set_time = - nt_time_to_unix(info3->pass_last_set_time); + nt_time_to_unix(info3->base.last_password_change); state->response.data.auth.info3.pass_can_change_time = - nt_time_to_unix(info3->pass_can_change_time); + nt_time_to_unix(info3->base.allow_password_change); state->response.data.auth.info3.pass_must_change_time = - nt_time_to_unix(info3->pass_must_change_time); - - state->response.data.auth.info3.logon_count = info3->logon_count; - state->response.data.auth.info3.bad_pw_count = info3->bad_pw_count; - - state->response.data.auth.info3.user_rid = info3->user_rid; - state->response.data.auth.info3.group_rid = info3->group_rid; - sid_to_fstring(state->response.data.auth.info3.dom_sid, &(info3->dom_sid.sid)); - - state->response.data.auth.info3.num_groups = info3->num_groups; - state->response.data.auth.info3.user_flgs = info3->user_flgs; - - state->response.data.auth.info3.acct_flags = info3->acct_flags; - state->response.data.auth.info3.num_other_sids = info3->num_other_sids; - - unistr2_to_ascii(state->response.data.auth.info3.user_name, - &info3->uni_user_name, - sizeof(state->response.data.auth.info3.user_name)); - unistr2_to_ascii(state->response.data.auth.info3.full_name, - &info3->uni_full_name, - sizeof(state->response.data.auth.info3.full_name)); - unistr2_to_ascii(state->response.data.auth.info3.logon_script, - &info3->uni_logon_script, - sizeof(state->response.data.auth.info3.logon_script)); - unistr2_to_ascii(state->response.data.auth.info3.profile_path, - &info3->uni_profile_path, - sizeof(state->response.data.auth.info3.profile_path)); - unistr2_to_ascii(state->response.data.auth.info3.home_dir, - &info3->uni_home_dir, - sizeof(state->response.data.auth.info3.home_dir)); - unistr2_to_ascii(state->response.data.auth.info3.dir_drive, - &info3->uni_dir_drive, - sizeof(state->response.data.auth.info3.dir_drive)); - - unistr2_to_ascii(state->response.data.auth.info3.logon_srv, - &info3->uni_logon_srv, - sizeof(state->response.data.auth.info3.logon_srv)); - unistr2_to_ascii(state->response.data.auth.info3.logon_dom, - &info3->uni_logon_dom, - sizeof(state->response.data.auth.info3.logon_dom)); + nt_time_to_unix(info3->base.force_password_change); + + state->response.data.auth.info3.logon_count = info3->base.logon_count; + state->response.data.auth.info3.bad_pw_count = info3->base.bad_password_count; + + state->response.data.auth.info3.user_rid = info3->base.rid; + state->response.data.auth.info3.group_rid = info3->base.primary_gid; + sid_to_fstring(state->response.data.auth.info3.dom_sid, info3->base.domain_sid); + + state->response.data.auth.info3.num_groups = info3->base.groups.count; + state->response.data.auth.info3.user_flgs = info3->base.user_flags; + + state->response.data.auth.info3.acct_flags = info3->base.acct_flags; + state->response.data.auth.info3.num_other_sids = info3->sidcount; + + fstrcpy(state->response.data.auth.info3.user_name, + info3->base.account_name.string); + fstrcpy(state->response.data.auth.info3.full_name, + info3->base.full_name.string); + fstrcpy(state->response.data.auth.info3.logon_script, + info3->base.logon_script.string); + fstrcpy(state->response.data.auth.info3.profile_path, + info3->base.profile_path.string); + fstrcpy(state->response.data.auth.info3.home_dir, + info3->base.home_directory.string); + fstrcpy(state->response.data.auth.info3.dir_drive, + info3->base.home_drive.string); + + fstrcpy(state->response.data.auth.info3.logon_srv, + info3->base.logon_server.string); + fstrcpy(state->response.data.auth.info3.logon_dom, + info3->base.domain.string); ex = talloc_strdup(mem_ctx, ""); NT_STATUS_HAVE_NO_MEMORY(ex); - for (i=0; i < info3->num_groups; i++) { + for (i=0; i < info3->base.groups.count; i++) { ex = talloc_asprintf_append_buffer(ex, "0x%08X:0x%08X\n", - info3->gids[i].g_rid, - info3->gids[i].attr); + info3->base.groups.rids[i].rid, + info3->base.groups.rids[i].attributes); NT_STATUS_HAVE_NO_MEMORY(ex); } - for (i=0; i < info3->num_other_sids; i++) { + for (i=0; i < info3->sidcount; i++) { char *sid; - sid = dom_sid_string(mem_ctx, &info3->other_sids[i].sid); + sid = dom_sid_string(mem_ctx, info3->sids[i].sid); NT_STATUS_HAVE_NO_MEMORY(sid); ex = talloc_asprintf_append_buffer(ex, "%s:0x%08X\n", sid, - info3->other_sids_attrib[i]); + info3->sids[i].attributes); NT_STATUS_HAVE_NO_MEMORY(ex); talloc_free(sid); @@ -158,7 +150,7 @@ static NTSTATUS append_info3_as_ndr(TALLOC_CTX *mem_ctx, static NTSTATUS append_unix_username(TALLOC_CTX *mem_ctx, struct winbindd_cli_state *state, - const NET_USER_INFO_3 *info3, + const struct netr_SamInfo3 *info3, const char *name_domain, const char *name_user) { @@ -168,15 +160,15 @@ static NTSTATUS append_unix_username(TALLOC_CTX *mem_ctx, fstring username_out; const char *nt_username, *nt_domain; - if (!(nt_domain = unistr2_to_ascii_talloc(mem_ctx, - &info3->uni_logon_dom))) { + nt_domain = talloc_strdup(mem_ctx, info3->base.domain.string); + if (!nt_domain) { /* If the server didn't give us one, just use the one * we sent them */ nt_domain = name_domain; } - if (!(nt_username = unistr2_to_ascii_talloc(mem_ctx, - &info3->uni_user_name))) { + nt_username = talloc_strdup(mem_ctx, info3->base.account_name.string); + if (!nt_username) { /* If the server didn't give us one, just use the one * we sent them */ nt_username = name_user; @@ -200,7 +192,7 @@ static NTSTATUS append_unix_username(TALLOC_CTX *mem_ctx, static NTSTATUS append_afs_token(TALLOC_CTX *mem_ctx, struct winbindd_cli_state *state, - const NET_USER_INFO_3 *info3, + const struct netr_SamInfo3 *info3, const char *name_domain, const char *name_user) { @@ -224,8 +216,8 @@ static NTSTATUS append_afs_token(TALLOC_CTX *mem_ctx, DOM_SID user_sid; fstring sidstr; - sid_copy(&user_sid, &info3->dom_sid.sid); - sid_append_rid(&user_sid, info3->user_rid); + sid_copy(&user_sid, info3->base.domain_sid); + sid_append_rid(&user_sid, info3->base.rid); sid_to_fstring(sidstr, &user_sid); afsname = talloc_string_sub(mem_ctx, afsname, "%s", sidstr); @@ -262,7 +254,7 @@ static NTSTATUS append_afs_token(TALLOC_CTX *mem_ctx, } static NTSTATUS check_info3_in_group(TALLOC_CTX *mem_ctx, - NET_USER_INFO_3 *info3, + struct netr_SamInfo3 *info3, const char *group_sid) /** * Check whether a user belongs to a group or list of groups. @@ -576,7 +568,7 @@ static uid_t get_uid_from_state(struct winbindd_cli_state *state) static NTSTATUS winbindd_raw_kerberos_login(struct winbindd_domain *domain, struct winbindd_cli_state *state, - NET_USER_INFO_3 **info3) + struct netr_SamInfo3 **info3) { #ifdef HAVE_KRB5 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; @@ -765,7 +757,7 @@ static bool check_request_flags(uint32_t flags) ****************************************************************/ static NTSTATUS append_data(struct winbindd_cli_state *state, - NET_USER_INFO_3 *info3, + struct netr_SamInfo3 *info3, const char *name_domain, const char *name_user) { @@ -774,14 +766,14 @@ static NTSTATUS append_data(struct winbindd_cli_state *state, if (flags & WBFLAG_PAM_USER_SESSION_KEY) { memcpy(state->response.data.auth.user_session_key, - info3->user_sess_key, + info3->base.key.key, sizeof(state->response.data.auth.user_session_key) /* 16 */); } if (flags & WBFLAG_PAM_LMKEY) { memcpy(state->response.data.auth.first_8_lm_hash, - info3->lm_sess_key, + info3->base.LMSessKey.key, sizeof(state->response.data.auth.first_8_lm_hash) /* 8 */); } @@ -882,7 +874,7 @@ void winbindd_pam_auth(struct winbindd_cli_state *state) NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain, struct winbindd_cli_state *state, - NET_USER_INFO_3 **info3) + struct netr_SamInfo3 **info3) { NTSTATUS result = NT_STATUS_LOGON_FAILURE; uint16 max_allowed_bad_attempts; @@ -892,7 +884,7 @@ NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain, uchar new_nt_pass[NT_HASH_LEN]; const uint8 *cached_nt_pass; const uint8 *cached_salt; - NET_USER_INFO_3 *my_info3; + struct netr_SamInfo3 *my_info3; time_t kickoff_time, must_change_time; bool password_good = False; #ifdef HAVE_KRB5 @@ -964,43 +956,43 @@ NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain, /* User *DOES* know the password, update logon_time and reset * bad_pw_count */ - my_info3->user_flgs |= NETLOGON_CACHED_ACCOUNT; + my_info3->base.user_flags |= NETLOGON_CACHED_ACCOUNT; - if (my_info3->acct_flags & ACB_AUTOLOCK) { + if (my_info3->base.acct_flags & ACB_AUTOLOCK) { return NT_STATUS_ACCOUNT_LOCKED_OUT; } - if (my_info3->acct_flags & ACB_DISABLED) { + if (my_info3->base.acct_flags & ACB_DISABLED) { return NT_STATUS_ACCOUNT_DISABLED; } - if (my_info3->acct_flags & ACB_WSTRUST) { + if (my_info3->base.acct_flags & ACB_WSTRUST) { return NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; } - if (my_info3->acct_flags & ACB_SVRTRUST) { + if (my_info3->base.acct_flags & ACB_SVRTRUST) { return NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT; } - if (my_info3->acct_flags & ACB_DOMTRUST) { + if (my_info3->base.acct_flags & ACB_DOMTRUST) { return NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT; } - if (!(my_info3->acct_flags & ACB_NORMAL)) { + if (!(my_info3->base.acct_flags & ACB_NORMAL)) { DEBUG(0,("winbindd_dual_pam_auth_cached: whats wrong with that one?: 0x%08x\n", - my_info3->acct_flags)); + my_info3->base.acct_flags)); return NT_STATUS_LOGON_FAILURE; } - kickoff_time = nt_time_to_unix(my_info3->kickoff_time); + kickoff_time = nt_time_to_unix(my_info3->base.acct_expiry); if (kickoff_time != 0 && time(NULL) > kickoff_time) { return NT_STATUS_ACCOUNT_EXPIRED; } - must_change_time = nt_time_to_unix(my_info3->pass_must_change_time); + must_change_time = nt_time_to_unix(my_info3->base.force_password_change); if (must_change_time != 0 && must_change_time < time(NULL)) { /* we allow grace logons when the password has expired */ - my_info3->user_flgs |= NETLOGON_GRACE_LOGON; + my_info3->base.user_flags |= NETLOGON_GRACE_LOGON; /* return NT_STATUS_PASSWORD_EXPIRED; */ goto success; } @@ -1071,8 +1063,8 @@ NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain, /* FIXME: we possibly should handle logon hours as well (does xp when * offline?) see auth/auth_sam.c:sam_account_ok for details */ - unix_to_nt_time(&my_info3->logon_time, time(NULL)); - my_info3->bad_pw_count = 0; + unix_to_nt_time(&my_info3->base.last_logon, time(NULL)); + my_info3->base.bad_password_count = 0; result = winbindd_update_creds_by_info3(domain, state->mem_ctx, @@ -1099,14 +1091,14 @@ NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain, } /* increase counter */ - my_info3->bad_pw_count++; + my_info3->base.bad_password_count++; if (max_allowed_bad_attempts == 0) { goto failed; } /* lockout user */ - if (my_info3->bad_pw_count >= max_allowed_bad_attempts) { + if (my_info3->base.bad_password_count >= max_allowed_bad_attempts) { uint32 password_properties; @@ -1115,9 +1107,9 @@ NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain, DEBUG(10,("winbindd_dual_pam_auth_cached: failed to get password properties.\n")); } - if ((my_info3->user_rid != DOMAIN_USER_RID_ADMIN) || + if ((my_info3->base.rid != DOMAIN_USER_RID_ADMIN) || (password_properties & DOMAIN_PASSWORD_LOCKOUT_ADMINS)) { - my_info3->acct_flags |= ACB_AUTOLOCK; + my_info3->base.acct_flags |= ACB_AUTOLOCK; } } @@ -1138,7 +1130,7 @@ failed: NTSTATUS winbindd_dual_pam_auth_kerberos(struct winbindd_domain *domain, struct winbindd_cli_state *state, - NET_USER_INFO_3 **info3) + struct netr_SamInfo3 **info3) { struct winbindd_domain *contact_domain; fstring name_domain, name_user; @@ -1197,7 +1189,7 @@ done: NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain, struct winbindd_cli_state *state, - NET_USER_INFO_3 **info3) + struct netr_SamInfo3 **info3) { struct rpc_pipe_client *netlogon_pipe; @@ -1211,18 +1203,10 @@ NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain, fstring name_domain, name_user; bool retry; NTSTATUS result; - NET_USER_INFO_3 *my_info3; - - ZERO_STRUCTP(info3); + struct netr_SamInfo3 *my_info3 = NULL; *info3 = NULL; - my_info3 = TALLOC_ZERO_P(state->mem_ctx, NET_USER_INFO_3); - if (my_info3 == NULL) { - return NT_STATUS_NO_MEMORY; - } - - DEBUG(10,("winbindd_dual_pam_auth_samlogon\n")); /* Parse domain and username */ @@ -1330,7 +1314,7 @@ NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain, chal, lm_resp, nt_resp, - my_info3); + &my_info3); attempts += 1; /* We have to try a second time as cm_connect_netlogon @@ -1364,7 +1348,7 @@ NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain, * caller, we look up the account flags ourselve - gd */ if ((state->request.flags & WBFLAG_PAM_INFO3_TEXT) && - (my_info3->acct_flags == 0) && NT_STATUS_IS_OK(result)) { + (my_info3->base.acct_flags == 0) && NT_STATUS_IS_OK(result)) { struct rpc_pipe_client *samr_pipe; POLICY_HND samr_domain_handle, user_pol; @@ -1384,7 +1368,7 @@ NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain, status_tmp = rpccli_samr_OpenUser(samr_pipe, state->mem_ctx, &samr_domain_handle, MAXIMUM_ALLOWED_ACCESS, - my_info3->user_rid, + my_info3->base.rid, &user_pol); if (!NT_STATUS_IS_OK(status_tmp)) { @@ -1412,7 +1396,7 @@ NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain, goto done; } - my_info3->acct_flags = acct_flags; + my_info3->base.acct_flags = acct_flags; DEBUG(10,("successfully retrieved acct_flags 0x%x\n", acct_flags)); @@ -1430,8 +1414,8 @@ enum winbindd_result winbindd_dual_pam_auth(struct winbindd_domain *domain, NTSTATUS result = NT_STATUS_LOGON_FAILURE; NTSTATUS krb5_result = NT_STATUS_OK; fstring name_domain, name_user; - NET_USER_INFO_3 *info3 = NULL; - + struct netr_SamInfo3 *info3 = NULL; + /* Ensure null termination */ state->request.data.auth.user[sizeof(state->request.data.auth.user)-1]='\0'; @@ -1526,7 +1510,7 @@ sam_logon: DEBUG(10,("winbindd_dual_pam_auth_samlogon succeeded\n")); /* add the Krb5 err if we have one */ if ( NT_STATUS_EQUAL(krb5_result, NT_STATUS_TIME_DIFFERENCE_AT_DC ) ) { - info3->user_flgs |= LOGON_KRB5_FAIL_CLOCK_SKEW; + info3->base.user_flags |= LOGON_KRB5_FAIL_CLOCK_SKEW; } goto process_result; } @@ -1586,8 +1570,8 @@ process_result: the cache entry by storing the seq_num for the wrong domain). */ if ( domain->primary ) { - sid_compose(&user_sid, &info3->dom_sid.sid, - info3->user_rid); + sid_compose(&user_sid, info3->base.domain_sid, + info3->base.rid); cache_name2sid(domain, name_domain, name_user, SID_NAME_USER, &user_sid); } @@ -1752,7 +1736,7 @@ enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain, struct winbindd_cli_state *state) { NTSTATUS result; - NET_USER_INFO_3 info3; + struct netr_SamInfo3 *info3 = NULL; struct rpc_pipe_client *netlogon_pipe; const char *name_user = NULL; const char *name_domain = NULL; @@ -1830,7 +1814,6 @@ enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain, } do { - ZERO_STRUCT(info3); retry = False; netlogon_pipe = NULL; @@ -1884,12 +1867,12 @@ enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain, if (NT_STATUS_IS_OK(result)) { - netsamlogon_cache_store(name_user, &info3); - wcache_invalidate_samlogon(find_domain_from_name(name_domain), &info3); + netsamlogon_cache_store(name_user, info3); + wcache_invalidate_samlogon(find_domain_from_name(name_domain), info3); /* Check if the user is in the right group */ - if (!NT_STATUS_IS_OK(result = check_info3_in_group(state->mem_ctx, &info3, + if (!NT_STATUS_IS_OK(result = check_info3_in_group(state->mem_ctx, info3, state->request.data.auth_crap.require_membership_of_sid))) { DEBUG(3, ("User %s is not in the required group (%s), so " "crap authentication is rejected\n", @@ -1898,7 +1881,7 @@ enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain, goto done; } - result = append_data(state, &info3, name_domain, name_user); + result = append_data(state, info3, name_domain, name_user); if (!NT_STATUS_IS_OK(result)) { goto done; } diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index 585923410f..f818772ce7 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -429,7 +429,7 @@ static NTSTATUS query_user(struct winbindd_domain *domain, POLICY_HND dom_pol, user_pol; union samr_UserInfo *info = NULL; uint32 user_rid; - NET_USER_INFO_3 *user; + struct netr_SamInfo3 *user; struct rpc_pipe_client *cli; DEBUG(3,("rpc: query_user sid=%s\n", sid_string_dbg(user_sid))); @@ -449,14 +449,14 @@ static NTSTATUS query_user(struct winbindd_domain *domain, DEBUG(5,("query_user: Cache lookup succeeded for %s\n", sid_string_dbg(user_sid))); - sid_compose(&user_info->user_sid, &domain->sid, user->user_rid); + sid_compose(&user_info->user_sid, &domain->sid, user->base.rid); sid_compose(&user_info->group_sid, &domain->sid, - user->group_rid); + user->base.primary_gid); - user_info->acct_name = unistr2_to_ascii_talloc(mem_ctx, - &user->uni_user_name); - user_info->full_name = unistr2_to_ascii_talloc(mem_ctx, - &user->uni_full_name); + user_info->acct_name = talloc_strdup(mem_ctx, + user->base.account_name.string); + user_info->full_name = talloc_strdup(mem_ctx, + user->base.full_name.string); TALLOC_FREE(user); diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c index 7933ecf63e..038bafbe4e 100644 --- a/source3/winbindd/winbindd_util.c +++ b/source3/winbindd/winbindd_util.c @@ -1272,7 +1272,7 @@ NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain, const DOM_SID *user_sid, uint32 *p_num_groups, DOM_SID **user_sids) { - NET_USER_INFO_3 *info3 = NULL; + struct netr_SamInfo3 *info3 = NULL; NTSTATUS status = NT_STATUS_NO_MEMORY; int i; size_t num_groups = 0; @@ -1290,13 +1290,13 @@ NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain, return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - if (info3->num_groups == 0) { + if (info3->base.groups.count == 0) { TALLOC_FREE(info3); return NT_STATUS_UNSUCCESSFUL; } /* always add the primary group to the sid array */ - sid_compose(&primary_group, &info3->dom_sid.sid, info3->user_rid); + sid_compose(&primary_group, info3->base.domain_sid, info3->base.rid); status = add_sid_to_array(mem_ctx, &primary_group, user_sids, &num_groups); @@ -1305,9 +1305,9 @@ NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain, return status; } - for (i=0; inum_groups; i++) { - sid_copy(&group_sid, &info3->dom_sid.sid); - sid_append_rid(&group_sid, info3->gids[i].g_rid); + for (i=0; i < info3->base.groups.count; i++) { + sid_copy(&group_sid, info3->base.domain_sid); + sid_append_rid(&group_sid, info3->base.groups.rids[i].rid); status = add_sid_to_array(mem_ctx, &group_sid, user_sids, &num_groups); @@ -1319,13 +1319,13 @@ NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain, /* Add any Universal groups in the other_sids list */ - for (i=0; inum_other_sids; i++) { + for (i=0; i < info3->sidcount; i++) { /* Skip Domain local groups outside our domain. We'll get these from the getsidaliases() RPC call. */ - if (info3->other_sids_attrib[i] & SE_GROUP_RESOURCE) + if (info3->sids[i].attributes & SE_GROUP_RESOURCE) continue; - status = add_sid_to_array(mem_ctx, &info3->other_sids[i].sid, + status = add_sid_to_array(mem_ctx, info3->sids[i].sid, user_sids, &num_groups); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(info3); -- cgit From 7dfeae6073b31c04f6bdc33e9e835f256ba4f8d2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:09:35 +0100 Subject: Use netr_SamInfo3 in remaining places. Guenther (This used to be commit 92fca97951bf7adf8caaeabdaff21682b18dd91f) --- source3/auth/auth_domain.c | 10 +++++----- source3/passdb/passdb.c | 2 +- source3/passdb/pdb_get_set.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c index 40a2985600..df51966f4c 100644 --- a/source3/auth/auth_domain.c +++ b/source3/auth/auth_domain.c @@ -189,7 +189,7 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx, struct sockaddr_storage *dc_ss) { - NET_USER_INFO_3 info3; + struct netr_SamInfo3 *info3 = NULL; struct cli_state *cli = NULL; struct rpc_pipe_client *netlogon_pipe = NULL; NTSTATUS nt_status = NT_STATUS_NO_LOGON_SERVERS; @@ -227,8 +227,6 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx, saf_store( domain, cli->desthost ); - ZERO_STRUCT(info3); - /* * If this call succeeds, we now have lots of info about the user * in the info3 structure. @@ -267,7 +265,7 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx, user_info->smb_name, domain, server_info, - &info3); + info3); if (NT_STATUS_IS_OK(nt_status)) { if (user_info->was_mapped) { @@ -281,12 +279,14 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx, if ( !NT_STATUS_IS_OK(nt_status)) { DEBUG(1, ("PAM account restriction prevents user login\n")); cli_shutdown(cli); + TALLOC_FREE(info3); return nt_status; } } } - netsamlogon_cache_store( user_info->smb_name, &info3 ); + netsamlogon_cache_store(user_info->smb_name, info3); + TALLOC_FREE(info3); } /* Note - once the cli stream is shutdown the mem_ctx used diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index 70b9dcd3b5..46dab156ee 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -206,7 +206,7 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p /* Now deal with the user SID. If we have a backend that can generate RIDs, then do so. But sometimes the caller just wanted a structure initialized and will fill in these fields later (such as from a - NET_USER_INFO_3 structure) */ + netr_SamInfo3 structure) */ if ( create && !pdb_rid_algorithm() ) { uint32 user_rid; diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c index 3b55dd478f..c427d41e23 100644 --- a/source3/passdb/pdb_get_set.c +++ b/source3/passdb/pdb_get_set.c @@ -538,7 +538,7 @@ bool pdb_set_user_sid_from_string(struct samu *sampass, fstring u_sid, enum pdb_ We never fill this in from a passdb backend but rather set is based on the user's primary group membership. However, the struct samu* is overloaded and reused in domain memship code - as well and built from the NET_USER_INFO_3 or PAC so we + as well and built from the netr_SamInfo3 or PAC so we have to allow the explicitly setting of a group SID here. ********************************************************************/ -- cgit From 9f8f9c1483207b8cf265fefb2a31fc65bdcc416e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:10:43 +0100 Subject: Finally let our samlogon routines call rpccli_netr_LogonSamLogon internally and return netr_SamInfo3. Guenther (This used to be commit 9e5b732d451f6a2f09d2a71e5a3aec59c771db01) --- source3/Makefile.in | 16 +- source3/rpc_client/cli_netlogon.c | 353 +++++++++++++++++++++++--------------- 2 files changed, 223 insertions(+), 146 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index a1b8089d82..c0e4578ef4 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -297,6 +297,9 @@ RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o RPC_PARSE_OBJ1 = $(RPC_PARSE_OBJ0) rpc_parse/parse_sec.o RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_net.o rpc_parse/parse_srv.o +RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_net.o rpc_parse/parse_srv.o \ + rpc_client/init_netlogon.o \ + rpc_client/init_lsa.o LIBREPLACE_OBJ = @LIBREPLACE_OBJS@ @@ -412,9 +415,7 @@ LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \ $(RPC_CLIENT_OBJ1) rpc_client/cli_reg.o $(RPC_CLIENT_OBJ) \ rpc_client/cli_spoolss.o rpc_client/cli_spoolss_notify.o \ rpc_client/cli_svcctl.o \ - rpc_client/init_samr.o \ - rpc_client/init_lsa.o \ - rpc_client/init_netlogon.o + rpc_client/init_samr.o LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \ librpc/gen_ndr/cli_dfs.o \ @@ -1049,10 +1050,13 @@ NTLM_AUTH_OBJ1 = utils/ntlm_auth.o utils/ntlm_auth_diagnostics.o NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ) \ libsmb/asn1.o libsmb/spnego.o libsmb/clikrb5.o libads/kerberos.o \ - libads/kerberos_verify.o $(SECRETS_OBJ) $(SERVER_MUTEX_OBJ) \ - libads/authdata.o $(RPC_PARSE_OBJ1) $(PASSDB_OBJ) $(GROUPDB_OBJ) \ + $(SECRETS_OBJ) $(SERVER_MUTEX_OBJ) $(LIBADS_SERVER_OBJ) \ + $(RPC_PARSE_OBJ1) $(PASSDB_OBJ) $(GROUPDB_OBJ) \ $(SMBLDAP_OBJ) $(DOSERR_OBJ) rpc_parse/parse_net.o $(LIBNMB_OBJ) \ - $(LDB_OBJ) $(ERRORMAP_OBJ) $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ + $(LDB_OBJ) $(ERRORMAP_OBJ) $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ \ + librpc/gen_ndr/ndr_samr.o \ + librpc/gen_ndr/ndr_lsa.o \ + librpc/gen_ndr/ndr_netlogon.o VLP_OBJ1 = ../testsuite/printing/vlp.o $(RPC_CLIENT_OBJ1) $(RPC_PARSE_OBJ2) $(RPC_CLIENT_OBJ) diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index b50a03359e..c3d1360ed8 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. NT Domain Authentication SMB / MSRPC client Copyright (C) Andrew Tridgell 1992-2000 @@ -9,12 +9,12 @@ 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 . */ @@ -34,12 +34,12 @@ LSA Authenticate 2 Send the client credential, receive back a server credential. -Ensure that the server credential returned matches the session key +Ensure that the server credential returned matches the session key encrypt of the server challenge originally received. JRA. ****************************************************************************/ - NTSTATUS rpccli_net_auth2(struct rpc_pipe_client *cli, - uint16 sec_chan, + NTSTATUS rpccli_net_auth2(struct rpc_pipe_client *cli, + uint16 sec_chan, uint32 *neg_flags, DOM_CHAL *srv_chal) { prs_struct qbuf, rbuf; @@ -52,7 +52,7 @@ encrypt of the server challenge originally received. JRA. fstr_sprintf( machine_acct, "%s$", lp_workgroup() ); else fstrcpy( machine_acct, cli->mach_acct ); - + /* create and send a MSRPC command with api NET_AUTH2 */ DEBUG(4,("cli_net_auth2: srv:%s acct:%s sc:%x mc: %s chal %s neg: %x\n", @@ -61,8 +61,8 @@ encrypt of the server challenge originally received. JRA. /* store the parameters */ - init_q_auth_2(&q, cli->srv_name_slash, machine_acct, - sec_chan, global_myname(), &cli->clnt_cred.challenge, + init_q_auth_2(&q, cli->srv_name_slash, machine_acct, + sec_chan, global_myname(), &cli->clnt_cred.challenge, *neg_flags); /* turn parameters into data stream */ @@ -78,7 +78,7 @@ encrypt of the server challenge originally received. JRA. if (NT_STATUS_IS_OK(result)) { UTIME zerotime; - + /* * Check the returned value using the initial * server received challenge. @@ -105,7 +105,7 @@ password ?).\n", cli->cli->desthost )); LSA Authenticate 2 Send the client credential, receive back a server credential. - The caller *must* ensure that the server credential returned matches the session key + The caller *must* ensure that the server credential returned matches the session key encrypt of the server challenge originally received. JRA. ****************************************************************************/ @@ -117,11 +117,11 @@ password ?).\n", cli->cli->desthost )); LSA Authenticate 3 Send the client credential, receive back a server credential. - The caller *must* ensure that the server credential returned matches the session key + The caller *must* ensure that the server credential returned matches the session key encrypt of the server challenge originally received. JRA. ****************************************************************************/ -static NTSTATUS rpccli_net_auth3(struct rpc_pipe_client *cli, +static NTSTATUS rpccli_net_auth3(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_name, const char *account_name, @@ -225,9 +225,9 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli, machine_pwd, &clnt_chal_send); - /* - * Send client auth-2 challenge and receive server repy. - */ + /* + * Send client auth-2 challenge and receive server repy. + */ result = rpccli_netr_ServerAuthenticate2(cli, cli->mem_ctx, dc->remote_machine, @@ -274,20 +274,23 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, const char *workstation, int logon_type) { - prs_struct qbuf, rbuf; - NET_Q_SAM_LOGON q; - NET_R_SAM_LOGON r; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_CRED clnt_creds; - DOM_CRED ret_creds; - NET_ID_INFO_CTR ctr; - NET_USER_INFO_3 user; - int validation_level = 3; + struct netr_Authenticator clnt_creds; + struct netr_Authenticator ret_creds; + union netr_LogonLevel *logon; + union netr_Validation validation; + uint8_t authoritative; + int validation_level = 3; fstring clnt_name_slash; + uint8 zeros[16]; - ZERO_STRUCT(q); - ZERO_STRUCT(r); ZERO_STRUCT(ret_creds); + ZERO_STRUCT(zeros); + + logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); + if (!logon) { + return NT_STATUS_NO_MEMORY; + } if (workstation) { fstr_sprintf( clnt_name_slash, "\\\\%s", workstation ); @@ -295,85 +298,140 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, fstr_sprintf( clnt_name_slash, "\\\\%s", global_myname() ); } - /* Initialise input parameters */ + /* Initialise input parameters */ - creds_client_step(cli->dc, &clnt_creds); + netlogon_creds_client_step(cli->dc, &clnt_creds); - q.validation_level = validation_level; + switch (logon_type) { + case INTERACTIVE_LOGON_TYPE: { - ctr.switch_value = logon_type; + struct netr_PasswordInfo *password_info; - switch (logon_type) { - case INTERACTIVE_LOGON_TYPE: { - unsigned char lm_owf_user_pwd[16], nt_owf_user_pwd[16]; + struct samr_Password lmpassword; + struct samr_Password ntpassword; - nt_lm_owf_gen(password, nt_owf_user_pwd, lm_owf_user_pwd); + unsigned char lm_owf_user_pwd[16], nt_owf_user_pwd[16]; - init_id_info1(&ctr.auth.id1, domain, - logon_parameters, /* param_ctrl */ - 0xdead, 0xbeef, /* LUID? */ - username, clnt_name_slash, - (const char *)cli->dc->sess_key, lm_owf_user_pwd, - nt_owf_user_pwd); + unsigned char lm_owf[16]; + unsigned char nt_owf[16]; + unsigned char key[16]; - break; - } - case NET_LOGON_TYPE: { - uint8 chal[8]; - unsigned char local_lm_response[24]; - unsigned char local_nt_response[24]; - - generate_random_buffer(chal, 8); - - SMBencrypt(password, chal, local_lm_response); - SMBNTencrypt(password, chal, local_nt_response); - - init_id_info2(&ctr.auth.id2, domain, - logon_parameters, /* param_ctrl */ - 0xdead, 0xbeef, /* LUID? */ - username, clnt_name_slash, chal, - local_lm_response, 24, local_nt_response, 24); - break; - } - default: - DEBUG(0, ("switch value %d not supported\n", - ctr.switch_value)); - return NT_STATUS_INVALID_INFO_CLASS; - } + password_info = TALLOC_ZERO_P(mem_ctx, struct netr_PasswordInfo); + if (!password_info) { + return NT_STATUS_NO_MEMORY; + } - r.user = &user; + nt_lm_owf_gen(password, nt_owf_user_pwd, lm_owf_user_pwd); - init_sam_info(&q.sam_id, cli->dc->remote_machine, global_myname(), - &clnt_creds, &ret_creds, logon_type, - &ctr); +#ifdef DEBUG_PASSWORD + DEBUG(100,("lm cypher:")); + dump_data(100, lm_owf_user_pwd, 16); - /* Marshall data and send request */ + DEBUG(100,("nt cypher:")); + dump_data(100, nt_owf_user_pwd, 16); +#endif + memset(key, 0, 16); + memcpy(key, cli->dc->sess_key, 8); - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_SAMLOGON, - q, r, - qbuf, rbuf, - net_io_q_sam_logon, - net_io_r_sam_logon, - NT_STATUS_UNSUCCESSFUL); + memcpy(lm_owf, lm_owf_user_pwd, 16); + SamOEMhash(lm_owf, key, 16); + memcpy(nt_owf, nt_owf_user_pwd, 16); + SamOEMhash(nt_owf, key, 16); - /* Return results */ +#ifdef DEBUG_PASSWORD + DEBUG(100,("encrypt of lm owf password:")); + dump_data(100, lm_owf, 16); - result = r.status; + DEBUG(100,("encrypt of nt owf password:")); + dump_data(100, nt_owf, 16); +#endif + memcpy(lmpassword.hash, lm_owf, 16); + memcpy(ntpassword.hash, nt_owf, 16); + + init_netr_PasswordInfo(password_info, + domain, + logon_parameters, + 0xdead, + 0xbeef, + username, + clnt_name_slash, + lmpassword, + ntpassword); + + logon->password = password_info; + + break; + } + case NET_LOGON_TYPE: { + struct netr_NetworkInfo *network_info; + uint8 chal[8]; + unsigned char local_lm_response[24]; + unsigned char local_nt_response[24]; + struct netr_ChallengeResponse lm; + struct netr_ChallengeResponse nt; + + network_info = TALLOC_ZERO_P(mem_ctx, struct netr_NetworkInfo); + if (!network_info) { + return NT_STATUS_NO_MEMORY; + } + + generate_random_buffer(chal, 8); + + SMBencrypt(password, chal, local_lm_response); + SMBNTencrypt(password, chal, local_nt_response); + + lm.length = 24; + lm.data = local_lm_response; - if (r.buffer_creds) { + nt.length = 24; + nt.data = local_nt_response; + + init_netr_NetworkInfo(network_info, + domain, + logon_parameters, + 0xdead, + 0xbeef, + username, + clnt_name_slash, + chal, + nt, + lm); + + logon->network = network_info; + + break; + } + default: + DEBUG(0, ("switch value %d not supported\n", + logon_type)); + return NT_STATUS_INVALID_INFO_CLASS; + } + + result = rpccli_netr_LogonSamLogon(cli, mem_ctx, + cli->dc->remote_machine, + global_myname(), + &clnt_creds, + &ret_creds, + logon_type, + logon, + validation_level, + &validation, + &authoritative); + + if (memcmp(zeros, &ret_creds.cred.data, sizeof(ret_creds.cred.data)) != 0) { /* Check returned credentials if present. */ - if (!creds_client_check(cli->dc, &r.srv_creds.challenge)) { + if (!netlogon_creds_client_check(cli->dc, &ret_creds.cred)) { DEBUG(0,("rpccli_netlogon_sam_logon: credentials chain check failed\n")); return NT_STATUS_ACCESS_DENIED; } } - return result; + return result; } -/** - * Logon domain user with an 'network' SAM logon +/** + * Logon domain user with an 'network' SAM logon * * @param info3 Pointer to a NET_USER_INFO_3 already allocated by the caller. **/ @@ -384,31 +442,44 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli, const char *server, const char *username, const char *domain, - const char *workstation, - const uint8 chal[8], + const char *workstation, + const uint8 chal[8], DATA_BLOB lm_response, DATA_BLOB nt_response, - NET_USER_INFO_3 *info3) + struct netr_SamInfo3 **info3) { - prs_struct qbuf, rbuf; - NET_Q_SAM_LOGON q; - NET_R_SAM_LOGON r; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - NET_ID_INFO_CTR ctr; int validation_level = 3; const char *workstation_name_slash; const char *server_name_slash; uint8 zeros[16]; - DOM_CRED clnt_creds; - DOM_CRED ret_creds; - int i; + struct netr_Authenticator clnt_creds; + struct netr_Authenticator ret_creds; + union netr_LogonLevel *logon = NULL; + struct netr_NetworkInfo *network_info; + uint8_t authoritative; + union netr_Validation validation; + struct netr_ChallengeResponse lm; + struct netr_ChallengeResponse nt; + struct netr_UserSessionKey user_session_key; + struct netr_LMSessionKey lmsesskey; + + *info3 = NULL; ZERO_STRUCT(zeros); - ZERO_STRUCT(q); - ZERO_STRUCT(r); ZERO_STRUCT(ret_creds); - creds_client_step(cli->dc, &clnt_creds); + logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); + if (!logon) { + return NT_STATUS_NO_MEMORY; + } + + network_info = TALLOC_ZERO_P(mem_ctx, struct netr_NetworkInfo); + if (!network_info) { + return NT_STATUS_NO_MEMORY; + } + + netlogon_creds_client_step(cli->dc, &clnt_creds); if (server[0] != '\\' && server[1] != '\\') { server_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", server); @@ -429,60 +500,62 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli, /* Initialise input parameters */ - q.validation_level = validation_level; - - ctr.switch_value = NET_LOGON_TYPE; - - init_id_info2(&ctr.auth.id2, domain, - logon_parameters, /* param_ctrl */ - 0xdead, 0xbeef, /* LUID? */ - username, workstation_name_slash, (const uchar*)chal, - lm_response.data, lm_response.length, nt_response.data, nt_response.length); - - init_sam_info(&q.sam_id, server_name_slash, global_myname(), - &clnt_creds, &ret_creds, NET_LOGON_TYPE, - &ctr); - - r.user = info3; - - /* Marshall data and send request */ - - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_SAMLOGON, - q, r, - qbuf, rbuf, - net_io_q_sam_logon, - net_io_r_sam_logon, - NT_STATUS_UNSUCCESSFUL); - - if (memcmp(zeros, info3->user_sess_key, 16) != 0) { - SamOEMhash(info3->user_sess_key, cli->dc->sess_key, 16); - } else { - memset(info3->user_sess_key, '\0', 16); + lm.data = lm_response.data; + lm.length = lm_response.length; + nt.data = nt_response.data; + nt.length = nt_response.length; + + init_netr_NetworkInfo(network_info, + domain, + logon_parameters, + 0xdead, + 0xbeef, + username, + workstation_name_slash, + (uint8_t *) chal, + nt, + lm); + + logon->network = network_info; + + /* Marshall data and send request */ + + result = rpccli_netr_LogonSamLogon(cli, mem_ctx, + server_name_slash, + global_myname(), + &clnt_creds, + &ret_creds, + NET_LOGON_TYPE, + logon, + validation_level, + &validation, + &authoritative); + if (!NT_STATUS_IS_OK(result)) { + return result; } - if (memcmp(zeros, info3->lm_sess_key, 8) != 0) { - SamOEMhash(info3->lm_sess_key, cli->dc->sess_key, 8); - } else { - memset(info3->lm_sess_key, '\0', 8); - } + user_session_key = validation.sam3->base.key; + lmsesskey = validation.sam3->base.LMSessKey; - for (i=0; i < 7; i++) { - memset(&info3->unknown[i], '\0', 4); + if (memcmp(zeros, user_session_key.key, 16) != 0) { + SamOEMhash(user_session_key.key, cli->dc->sess_key, 16); } - /* Return results */ - - result = r.status; + if (memcmp(zeros, lmsesskey.key, 8) != 0) { + SamOEMhash(lmsesskey.key, cli->dc->sess_key, 8); + } - if (r.buffer_creds) { + if (memcmp(zeros, ret_creds.cred.data, sizeof(ret_creds.cred.data)) != 0) { /* Check returned credentials if present. */ - if (!creds_client_check(cli->dc, &r.srv_creds.challenge)) { + if (!netlogon_creds_client_check(cli->dc, &ret_creds.cred)) { DEBUG(0,("rpccli_netlogon_sam_network_logon: credentials chain check failed\n")); return NT_STATUS_ACCESS_DENIED; } } - return result; + *info3 = validation.sam3; + + return result; } NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, @@ -491,8 +564,8 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, const char *server, const char *username, const char *domain, - const char *workstation, - const uint8 chal[8], + const char *workstation, + const uint8 chal[8], DATA_BLOB lm_response, DATA_BLOB nt_response, NET_USER_INFO_3 *info3) @@ -541,7 +614,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, username, workstation_name_slash, (const uchar*)chal, lm_response.data, lm_response.length, nt_response.data, nt_response.length); - + init_sam_info_ex(&q.sam_id, server_name_slash, global_myname(), NET_LOGON_TYPE, &ctr); -- cgit From 966333e744f02cd1d3347d087686255d3ac9489f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:25:33 +0100 Subject: Remove unused marshalling for NET_SAM_LOGON. Guenther (This used to be commit eefc6bb86fb9196818da9d5c6384c85355794981) --- source3/include/rpc_netlogon.h | 28 ---- source3/rpc_parse/parse_net.c | 322 ----------------------------------------- 2 files changed, 350 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index e9d9c30497..ed69cf7722 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -338,15 +338,6 @@ typedef struct net_id_info_ctr_info { } auth; } NET_ID_INFO_CTR; -/* SAM_INFO - sam logon/off id structure */ -typedef struct sam_info { - DOM_CLNT_INFO2 client; - uint32 ptr_rtn_cred; /* pointer to return credentials */ - DOM_CRED rtn_cred; /* return credentials */ - uint16 logon_level; - NET_ID_INFO_CTR *ctr; -} DOM_SAM_INFO; - /* SAM_INFO - sam logon/off id structure - no creds */ typedef struct sam_info_ex { DOM_CLNT_SRV client; @@ -354,12 +345,6 @@ typedef struct sam_info_ex { NET_ID_INFO_CTR *ctr; } DOM_SAM_INFO_EX; -/* NET_Q_SAM_LOGON */ -typedef struct net_q_sam_logon_info { - DOM_SAM_INFO sam_id; - uint16 validation_level; -} NET_Q_SAM_LOGON; - /* NET_Q_SAM_LOGON_EX */ typedef struct net_q_sam_logon_info_ex { DOM_SAM_INFO_EX sam_id; @@ -367,19 +352,6 @@ typedef struct net_q_sam_logon_info_ex { uint32 flags; } NET_Q_SAM_LOGON_EX; -/* NET_R_SAM_LOGON */ -typedef struct net_r_sam_logon_info { - uint32 buffer_creds; /* undocumented buffer pointer */ - DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */ - - uint16 switch_value; /* 3 - indicates type of USER INFO */ - NET_USER_INFO_3 *user; - - uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */ - - NTSTATUS status; /* return code */ -} NET_R_SAM_LOGON; - /* NET_R_SAM_LOGON_EX */ typedef struct net_r_sam_logon_info_ex { uint16 switch_value; /* 3 - indicates type of USER INFO */ diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index eab8e9b00d..70dc505c78 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -163,62 +163,6 @@ bool net_io_r_auth_3(const char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int de return True; } - -/************************************************************************* - Init DOM_SID2 array from a string containing multiple sids - *************************************************************************/ - -static int init_dom_sid2s(TALLOC_CTX *ctx, const char *sids_str, DOM_SID2 **ppsids) -{ - const char *ptr; - char *s2; - int count = 0; - - DEBUG(4,("init_dom_sid2s: %s\n", sids_str ? sids_str:"")); - - *ppsids = NULL; - - if(sids_str) { - int number; - DOM_SID2 *sids; - TALLOC_CTX *frame = talloc_stackframe(); - - /* Count the number of valid SIDs. */ - for (count = 0, ptr = sids_str; - next_token_talloc(frame,&ptr, &s2, NULL); ) { - DOM_SID tmpsid; - if (string_to_sid(&tmpsid, s2)) - count++; - } - - /* Now allocate space for them. */ - if (count) { - *ppsids = TALLOC_ZERO_ARRAY(ctx, DOM_SID2, count); - if (*ppsids == NULL) { - TALLOC_FREE(frame); - return 0; - } - } else { - *ppsids = NULL; - } - - sids = *ppsids; - - for (number = 0, ptr = sids_str; - next_token_talloc(frame, &ptr, &s2, NULL); ) { - DOM_SID tmpsid; - if (string_to_sid(&tmpsid, s2)) { - /* count only valid sids */ - init_dom_sid2(&sids[number], &tmpsid); - number++; - } - } - TALLOC_FREE(frame); - } - - return count; -} - /******************************************************************* Inits a NET_ID_INFO_1 structure. ********************************************************************/ @@ -439,32 +383,6 @@ static bool net_io_id_info2(const char *desc, NET_ID_INFO_2 *id, prs_struct *ps return True; } - -/******************************************************************* - Inits a DOM_SAM_INFO structure. -********************************************************************/ - -void init_sam_info(DOM_SAM_INFO *sam, - const char *logon_srv, const char *comp_name, - DOM_CRED *clnt_cred, - DOM_CRED *rtn_cred, uint16 logon_level, - NET_ID_INFO_CTR *ctr) -{ - DEBUG(5,("init_sam_info: %d\n", __LINE__)); - - init_clnt_info2(&sam->client, logon_srv, comp_name, clnt_cred); - - if (rtn_cred != NULL) { - sam->ptr_rtn_cred = 1; - memcpy(&sam->rtn_cred, rtn_cred, sizeof(sam->rtn_cred)); - } else { - sam->ptr_rtn_cred = 0; - } - - sam->logon_level = logon_level; - sam->ctr = ctr; -} - /******************************************************************* Inits a DOM_SAM_INFO structure. ********************************************************************/ @@ -523,42 +441,6 @@ static bool net_io_id_info_ctr(const char *desc, NET_ID_INFO_CTR **pp_ctr, prs_s return True; } -/******************************************************************* - Reads or writes a DOM_SAM_INFO structure. - ********************************************************************/ - -static bool smb_io_sam_info(const char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_sam_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_clnt_info2("", &sam->client, ps, depth)) - return False; - - if(!prs_uint32("ptr_rtn_cred ", ps, depth, &sam->ptr_rtn_cred)) - return False; - if (sam->ptr_rtn_cred) { - if(!smb_io_cred("", &sam->rtn_cred, ps, depth)) - return False; - } - - if(!prs_uint16("logon_level ", ps, depth, &sam->logon_level)) - return False; - - if (sam->logon_level != 0) { - if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth)) - return False; - } - - return True; -} - /******************************************************************* Reads or writes a DOM_SAM_INFO_EX structure. ********************************************************************/ @@ -588,137 +470,6 @@ static bool smb_io_sam_info_ex(const char *desc, DOM_SAM_INFO_EX *sam, prs_struc return True; } -/************************************************************************* - Inits a NET_USER_INFO_3 structure. - - This is a network logon reply packet, and contains much information about - the user. This information is passed as a (very long) paramater list - to avoid having to link in the PASSDB code to every program that deals - with this file. - *************************************************************************/ - -void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr, - uint32 user_rid, - uint32 group_rid, - - const char* user_name, - const char* full_name, - const char* home_dir, - const char* dir_drive, - const char* logon_script, - const char* profile_path, - - time_t unix_logon_time, - time_t unix_logoff_time, - time_t unix_kickoff_time, - time_t unix_pass_last_set_time, - time_t unix_pass_can_change_time, - time_t unix_pass_must_change_time, - - uint16 logon_count, uint16 bad_pw_count, - uint32 num_groups, const DOM_GID *gids, - uint32 user_flgs, uint32 acct_flags, - uchar user_session_key[16], - uchar lm_session_key[16], - const char *logon_srv, const char *logon_dom, - const DOM_SID *dom_sid) -{ - /* only cope with one "other" sid, right now. */ - /* need to count the number of space-delimited sids */ - unsigned int i; - int num_other_sids = 0; - - NTTIME logon_time, logoff_time, kickoff_time, - pass_last_set_time, pass_can_change_time, - pass_must_change_time; - - ZERO_STRUCTP(usr); - - usr->ptr_user_info = 1; /* yes, we're bothering to put USER_INFO data here */ - - /* Create NTTIME structs */ - unix_to_nt_time (&logon_time, unix_logon_time); - unix_to_nt_time (&logoff_time, unix_logoff_time); - unix_to_nt_time (&kickoff_time, unix_kickoff_time); - unix_to_nt_time (&pass_last_set_time, unix_pass_last_set_time); - unix_to_nt_time (&pass_can_change_time, unix_pass_can_change_time); - unix_to_nt_time (&pass_must_change_time, unix_pass_must_change_time); - - usr->logon_time = logon_time; - usr->logoff_time = logoff_time; - usr->kickoff_time = kickoff_time; - usr->pass_last_set_time = pass_last_set_time; - usr->pass_can_change_time = pass_can_change_time; - usr->pass_must_change_time = pass_must_change_time; - - usr->logon_count = logon_count; - usr->bad_pw_count = bad_pw_count; - - usr->user_rid = user_rid; - usr->group_rid = group_rid; - usr->num_groups = num_groups; - - usr->buffer_groups = 1; /* indicates fill in groups, below, even if there are none */ - usr->user_flgs = user_flgs; - usr->acct_flags = acct_flags; - - if (user_session_key != NULL) - memcpy(usr->user_sess_key, user_session_key, sizeof(usr->user_sess_key)); - else - memset((char *)usr->user_sess_key, '\0', sizeof(usr->user_sess_key)); - - usr->buffer_dom_id = dom_sid ? 1 : 0; /* yes, we're bothering to put a domain SID in */ - - memset((char *)usr->lm_sess_key, '\0', sizeof(usr->lm_sess_key)); - - for (i=0; i<7; i++) { - memset(&usr->unknown[i], '\0', sizeof(usr->unknown)); - } - - if (lm_session_key != NULL) { - memcpy(usr->lm_sess_key, lm_session_key, sizeof(usr->lm_sess_key)); - } - - num_other_sids = init_dom_sid2s(ctx, NULL, &usr->other_sids); - - usr->num_other_sids = num_other_sids; - usr->buffer_other_sids = (num_other_sids != 0) ? 1 : 0; - - init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE); - init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name); - init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE); - init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name); - init_unistr2(&usr->uni_logon_script, logon_script, UNI_FLAGS_NONE); - init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script); - init_unistr2(&usr->uni_profile_path, profile_path, UNI_FLAGS_NONE); - init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path); - init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE); - init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir); - init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE); - init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive); - - usr->num_groups2 = num_groups; - - if (num_groups) { - usr->gids = TALLOC_ZERO_ARRAY(ctx,DOM_GID,num_groups); - if (usr->gids == NULL) - return; - } else { - usr->gids = NULL; - } - - for (i = 0; i < num_groups; i++) - usr->gids[i] = gids[i]; - - init_unistr2(&usr->uni_logon_srv, logon_srv, UNI_FLAGS_NONE); - init_uni_hdr(&usr->hdr_logon_srv, &usr->uni_logon_srv); - init_unistr2(&usr->uni_logon_dom, logon_dom, UNI_FLAGS_NONE); - init_uni_hdr(&usr->hdr_logon_dom, &usr->uni_logon_dom); - - init_dom_sid2(&usr->dom_sid, dom_sid); - /* "other" sids are set up above */ -} - static void dump_acct_flags(uint32 acct_flags) { int lvl = 10; @@ -1005,79 +756,6 @@ bool net_io_user_info3(const char *desc, NET_USER_INFO_3 *usr, prs_struct *ps, Reads or writes a structure. ********************************************************************/ -bool net_io_q_sam_logon(const char *desc, NET_Q_SAM_LOGON *q_l, prs_struct *ps, int depth) -{ - if (q_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_sam_logon"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_sam_info("", &q_l->sam_id, ps, depth)) - return False; - - if(!prs_align_uint16(ps)) - return False; - - if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_r_sam_logon(const char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth) -{ - if (r_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_sam_logon"); - depth++; - - if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */ - return False; - if (&r_l->buffer_creds) { - if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */ - return False; - } - - if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value)) - return False; - if(!prs_align(ps)) - return False; - -#if 1 /* W2k always needs this - even for bad passwd. JRA */ - if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False)) - return False; -#else - if (r_l->switch_value != 0) { - if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False)) - return False; - } -#endif - - if(!prs_uint32("auth_resp ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */ - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - bool net_io_q_sam_logon_ex(const char *desc, NET_Q_SAM_LOGON_EX *q_l, prs_struct *ps, int depth) { if (q_l == NULL) -- cgit From 9519d95c4adbcc44abaf1288bcda0972d625036c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:37:12 +0100 Subject: Use rpccli_netr_LogonSamLogonEx in rpccli wrapping function. Guenther (This used to be commit 51a664cd5fc1cecc21a8a515bb959cac87296bcb) --- source3/rpc_client/cli_netlogon.c | 96 +++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 39 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index c3d1360ed8..064de5e4ea 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -568,22 +568,36 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, const uint8 chal[8], DATA_BLOB lm_response, DATA_BLOB nt_response, - NET_USER_INFO_3 *info3) + struct netr_SamInfo3 **info3) { - prs_struct qbuf, rbuf; - NET_Q_SAM_LOGON_EX q; - NET_R_SAM_LOGON_EX r; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - NET_ID_INFO_CTR ctr; int validation_level = 3; const char *workstation_name_slash; const char *server_name_slash; uint8 zeros[16]; - int i; + union netr_LogonLevel *logon = NULL; + struct netr_NetworkInfo *network_info; + uint8_t authoritative; + union netr_Validation validation; + struct netr_ChallengeResponse lm; + struct netr_ChallengeResponse nt; + struct netr_UserSessionKey user_session_key; + struct netr_LMSessionKey lmsesskey; + uint32_t flags = 0; + + *info3 = NULL; ZERO_STRUCT(zeros); - ZERO_STRUCT(q); - ZERO_STRUCT(r); + + logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); + if (!logon) { + return NT_STATUS_NO_MEMORY; + } + + network_info = TALLOC_ZERO_P(mem_ctx, struct netr_NetworkInfo); + if (!network_info) { + return NT_STATUS_NO_MEMORY; + } if (server[0] != '\\' && server[1] != '\\') { server_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", server); @@ -604,49 +618,53 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, /* Initialise input parameters */ - q.validation_level = validation_level; - - ctr.switch_value = NET_LOGON_TYPE; - - init_id_info2(&ctr.auth.id2, domain, - logon_parameters, /* param_ctrl */ - 0xdead, 0xbeef, /* LUID? */ - username, workstation_name_slash, (const uchar*)chal, - lm_response.data, lm_response.length, nt_response.data, - nt_response.length); + lm.data = lm_response.data; + lm.length = lm_response.length; + nt.data = nt_response.data; + nt.length = nt_response.length; - init_sam_info_ex(&q.sam_id, server_name_slash, global_myname(), - NET_LOGON_TYPE, &ctr); + init_netr_NetworkInfo(network_info, + domain, + logon_parameters, + 0xdead, + 0xbeef, + username, + workstation_name_slash, + (uint8_t *) chal, + nt, + lm); - r.user = info3; + logon->network = network_info; /* Marshall data and send request */ - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_SAMLOGON_EX, - q, r, qbuf, rbuf, - net_io_q_sam_logon_ex, - net_io_r_sam_logon_ex, - NT_STATUS_UNSUCCESSFUL); - - if (memcmp(zeros, info3->user_sess_key, 16) != 0) { - SamOEMhash(info3->user_sess_key, cli->dc->sess_key, 16); - } else { - memset(info3->user_sess_key, '\0', 16); + result = rpccli_netr_LogonSamLogonEx(cli, mem_ctx, + server_name_slash, + global_myname(), + NET_LOGON_TYPE, + logon, + validation_level, + &validation, + &authoritative, + &flags); + if (!NT_STATUS_IS_OK(result)) { + return result; } - if (memcmp(zeros, info3->lm_sess_key, 8) != 0) { - SamOEMhash(info3->lm_sess_key, cli->dc->sess_key, 8); - } else { - memset(info3->lm_sess_key, '\0', 8); + user_session_key = validation.sam3->base.key; + lmsesskey = validation.sam3->base.LMSessKey; + + if (memcmp(zeros, user_session_key.key, 16) != 0) { + SamOEMhash(user_session_key.key, cli->dc->sess_key, 16); } - for (i=0; i < 7; i++) { - memset(&info3->unknown[i], '\0', 4); + if (memcmp(zeros, lmsesskey.key, 8) != 0) { + SamOEMhash(lmsesskey.key, cli->dc->sess_key, 8); } - /* Return results */ + *info3 = validation.sam3; - result = r.status; + return result; return result; } -- cgit From 41e93135cf23e86660ec64430b8765c405505c08 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:39:36 +0100 Subject: Remove unused marshalling for NET_AUTH. This must have been forgotten. Guenther (This used to be commit 7bbd64c16f8dda85275ddca0fd00849f890c6e4f) --- source3/include/rpc_netlogon.h | 12 ----------- source3/rpc_parse/parse_net.c | 47 ------------------------------------------ 2 files changed, 59 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index ed69cf7722..c6d5651a9c 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -263,18 +263,6 @@ typedef struct neg_flags_info { uint32 neg_flags; /* negotiated flags */ } NEG_FLAGS; -/* NET_Q_AUTH */ -typedef struct net_q_auth_info { - DOM_LOG_INFO clnt_id; /* client identification info */ - DOM_CHAL clnt_chal; /* client-calculated credentials */ -} NET_Q_AUTH; - -/* NET_R_AUTH */ -typedef struct net_r_auth_info { - DOM_CHAL srv_chal; /* server-calculated credentials */ - NTSTATUS status; /* return code */ -} NET_R_AUTH; - /* NET_Q_AUTH_3 */ typedef struct net_q_auth3_info { DOM_LOG_INFO clnt_id; /* client identification info */ diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index 70dc505c78..38ea7846b7 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -46,53 +46,6 @@ static bool net_io_neg_flags(const char *desc, NEG_FLAGS *neg, prs_struct *ps, i return True; } -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_q_auth(const char *desc, NET_Q_AUTH *q_a, prs_struct *ps, int depth) -{ - if (q_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_auth"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */ - return False; - if(!smb_io_chal("", &q_a->clnt_chal, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_r_auth(const char *desc, NET_R_AUTH *r_a, prs_struct *ps, int depth) -{ - if (r_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_auth"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */ - return False; - - if(!prs_ntstatus("status", ps, depth, &r_a->status)) - return False; - - return True; -} - /******************************************************************* Inits a NET_Q_AUTH_3 struct. ********************************************************************/ -- cgit From 95b6f33da6277e3a3a8114f31cbe150524c4a7a8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:50:11 +0100 Subject: Remove unused marshalling for NET_SAM_LOGON_EX and finally NET_USER_INFO_3. Guenther (This used to be commit ead1f11dd21b1df9a595295b3513c5f6088397c9) --- source3/include/authdata.h | 134 +------- source3/include/rpc_netlogon.h | 246 -------------- source3/rpc_client/init_netlogon.c | 11 + source3/rpc_parse/parse_net.c | 664 ------------------------------------- 4 files changed, 12 insertions(+), 1043 deletions(-) (limited to 'source3') diff --git a/source3/include/authdata.h b/source3/include/authdata.h index 8125f05639..59f07fb42d 100644 --- a/source3/include/authdata.h +++ b/source3/include/authdata.h @@ -19,7 +19,7 @@ */ #ifndef _AUTHDATA_H -#define _AUTHDATA_H +#define _AUTHDATA_H #include "rpc_misc.h" #include "rpc_netlogon.h" @@ -37,136 +37,4 @@ #define KRB5_AUTHDATA_IF_RELEVANT 1 #endif - -typedef struct pac_logon_name { - NTTIME logon_time; - uint16 len; - uint8 *username; /* Actually always little-endian. might not be null terminated, so not UNISTR */ -} PAC_LOGON_NAME; - -typedef struct pac_signature_data { - uint32 type; - RPC_DATA_BLOB signature; /* this not the on-wire-format (!) */ -} PAC_SIGNATURE_DATA; - -typedef struct group_membership { - uint32 rid; - uint32 attrs; -} GROUP_MEMBERSHIP; - -typedef struct group_membership_array { - uint32 count; - GROUP_MEMBERSHIP *group_membership; -} GROUP_MEMBERSHIP_ARRAY; - -#if 0 /* Unused, replaced by NET_USER_INFO_3 - Guenther */ - -typedef struct krb_sid_and_attrs { - uint32 sid_ptr; - uint32 attrs; - DOM_SID2 *sid; -} KRB_SID_AND_ATTRS; - -typedef struct krb_sid_and_attr_array { - uint32 count; - KRB_SID_AND_ATTRS *krb_sid_and_attrs; -} KRB_SID_AND_ATTR_ARRAY; - - -/* This is awfully similar to a samr_user_info_23, but not identical. - Many of the field names have been swiped from there, because it is - so similar that they are likely the same, but many have been verified. - Some are in a different order, though... */ -typedef struct pac_logon_info { - NTTIME logon_time; /* logon time */ - NTTIME logoff_time; /* logoff time */ - NTTIME kickoff_time; /* kickoff time */ - NTTIME pass_last_set_time; /* password last set time */ - NTTIME pass_can_change_time; /* password can change time */ - NTTIME pass_must_change_time; /* password must change time */ - - UNIHDR hdr_user_name; /* user name unicode string header */ - UNIHDR hdr_full_name; /* user's full name unicode string header */ - UNIHDR hdr_logon_script; /* these last 4 appear to be in a different */ - UNIHDR hdr_profile_path; /* order than in the info23 */ - UNIHDR hdr_home_dir; - UNIHDR hdr_dir_drive; - - uint16 logon_count; /* number of times user has logged onto domain */ - uint16 bad_password_count; /* samba4 idl */ - - uint32 user_rid; - uint32 group_rid; - uint32 group_count; - uint32 group_membership_ptr; - uint32 user_flags; - - uint8 session_key[16]; /* samba4 idl */ - UNIHDR hdr_dom_controller; - UNIHDR hdr_dom_name; - - uint32 ptr_dom_sid; - - uint8 lm_session_key[8]; /* samba4 idl */ - uint32 acct_flags; /* samba4 idl */ - uint32 unknown[7]; - - uint32 sid_count; - uint32 ptr_extra_sids; - - uint32 ptr_res_group_dom_sid; - uint32 res_group_count; - uint32 ptr_res_groups; - - UNISTR2 uni_user_name; /* user name unicode string header */ - UNISTR2 uni_full_name; /* user's full name unicode string header */ - UNISTR2 uni_logon_script; /* these last 4 appear to be in a different*/ - UNISTR2 uni_profile_path; /* order than in the info23 */ - UNISTR2 uni_home_dir; - UNISTR2 uni_dir_drive; - UNISTR2 uni_dom_controller; - UNISTR2 uni_dom_name; - DOM_SID2 dom_sid; - GROUP_MEMBERSHIP_ARRAY groups; - KRB_SID_AND_ATTR_ARRAY extra_sids; - DOM_SID2 res_group_dom_sid; - GROUP_MEMBERSHIP_ARRAY res_groups; - -} PAC_LOGON_INFO; -#endif - -typedef struct pac_logon_info { - NET_USER_INFO_3 info3; - DOM_SID2 res_group_dom_sid; - GROUP_MEMBERSHIP_ARRAY res_groups; - -} PAC_LOGON_INFO; - -typedef struct pac_info_ctr -{ - union - { - PAC_LOGON_INFO *logon_info; - PAC_SIGNATURE_DATA *srv_cksum; - PAC_SIGNATURE_DATA *privsrv_cksum; - PAC_LOGON_NAME *logon_name; - } pac; -} PAC_INFO_CTR; - -typedef struct pac_buffer { - uint32 type; - uint32 size; - uint32 offset; - uint32 offsethi; - PAC_INFO_CTR *ctr; - uint32 pad; -} PAC_BUFFER; - -typedef struct pac_data { - uint32 num_buffers; - uint32 version; - PAC_BUFFER *pac_buffer; -} PAC_DATA; - - #endif diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index c6d5651a9c..8058b71e80 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -81,183 +81,6 @@ #define MSV1_0_RETURN_PROFILE_PATH 0x00000200 #endif -#if 0 -/* I think this is correct - it's what gets parsed on the wire. JRA. */ -/* NET_USER_INFO_2 */ -typedef struct net_user_info_2 { - uint32 ptr_user_info; - - NTTIME logon_time; /* logon time */ - NTTIME logoff_time; /* logoff time */ - NTTIME kickoff_time; /* kickoff time */ - NTTIME pass_last_set_time; /* password last set time */ - NTTIME pass_can_change_time; /* password can change time */ - NTTIME pass_must_change_time; /* password must change time */ - - UNIHDR hdr_user_name; /* username unicode string header */ - UNIHDR hdr_full_name; /* user's full name unicode string header */ - UNIHDR hdr_logon_script; /* logon script unicode string header */ - UNIHDR hdr_profile_path; /* profile path unicode string header */ - UNIHDR hdr_home_dir; /* home directory unicode string header */ - UNIHDR hdr_dir_drive; /* home directory drive unicode string header */ - - uint16 logon_count; /* logon count */ - uint16 bad_pw_count; /* bad password count */ - - uint32 user_id; /* User ID */ - uint32 group_id; /* Group ID */ - uint32 num_groups; /* num groups */ - uint32 buffer_groups; /* undocumented buffer pointer to groups. */ - uint32 user_flgs; /* user flags */ - - uint8 user_sess_key[16]; /* unused user session key */ - - UNIHDR hdr_logon_srv; /* logon server unicode string header */ - UNIHDR hdr_logon_dom; /* logon domain unicode string header */ - - uint32 buffer_dom_id; /* undocumented logon domain id pointer */ - uint8 padding[40]; /* unused padding bytes. expansion room */ - - UNISTR2 uni_user_name; /* username unicode string */ - UNISTR2 uni_full_name; /* user's full name unicode string */ - UNISTR2 uni_logon_script; /* logon script unicode string */ - UNISTR2 uni_profile_path; /* profile path unicode string */ - UNISTR2 uni_home_dir; /* home directory unicode string */ - UNISTR2 uni_dir_drive; /* home directory drive unicode string */ - - uint32 num_groups2; /* num groups */ - DOM_GID *gids; /* group info */ - - UNISTR2 uni_logon_srv; /* logon server unicode string */ - UNISTR2 uni_logon_dom; /* logon domain unicode string */ - - DOM_SID2 dom_sid; /* domain SID */ - - uint32 num_other_groups; /* other groups */ - DOM_GID *other_gids; /* group info */ - DOM_SID2 *other_sids; /* undocumented - domain SIDs */ - -} NET_USER_INFO_2; -#endif - -/* NET_USER_INFO_2 */ -typedef struct net_user_info_2 { - uint32 ptr_user_info; - - NTTIME logon_time; /* logon time */ - NTTIME logoff_time; /* logoff time */ - NTTIME kickoff_time; /* kickoff time */ - NTTIME pass_last_set_time; /* password last set time */ - NTTIME pass_can_change_time; /* password can change time */ - NTTIME pass_must_change_time; /* password must change time */ - - UNIHDR hdr_user_name; /* username unicode string header */ - UNIHDR hdr_full_name; /* user's full name unicode string header */ - UNIHDR hdr_logon_script; /* logon script unicode string header */ - UNIHDR hdr_profile_path; /* profile path unicode string header */ - UNIHDR hdr_home_dir; /* home directory unicode string header */ - UNIHDR hdr_dir_drive; /* home directory drive unicode string header */ - - uint16 logon_count; /* logon count */ - uint16 bad_pw_count; /* bad password count */ - - uint32 user_rid; /* User RID */ - uint32 group_rid; /* Group RID */ - - uint32 num_groups; /* num groups */ - uint32 buffer_groups; /* undocumented buffer pointer to groups. */ - uint32 user_flgs; /* user flags */ - - uint8 user_sess_key[16]; /* user session key */ - - UNIHDR hdr_logon_srv; /* logon server unicode string header */ - UNIHDR hdr_logon_dom; /* logon domain unicode string header */ - - uint32 buffer_dom_id; /* undocumented logon domain id pointer */ - uint8 lm_sess_key[8]; /* lm session key */ - uint32 acct_flags; /* account flags */ - uint32 unknown[7]; /* unknown */ - - UNISTR2 uni_user_name; /* username unicode string */ - UNISTR2 uni_full_name; /* user's full name unicode string */ - UNISTR2 uni_logon_script; /* logon script unicode string */ - UNISTR2 uni_profile_path; /* profile path unicode string */ - UNISTR2 uni_home_dir; /* home directory unicode string */ - UNISTR2 uni_dir_drive; /* home directory drive unicode string */ - - UNISTR2 uni_logon_srv; /* logon server unicode string */ - UNISTR2 uni_logon_dom; /* logon domain unicode string */ - - DOM_SID2 dom_sid; /* domain SID */ -} NET_USER_INFO_2; - -/* NET_USER_INFO_3 */ -typedef struct net_user_info_3 { - uint32 ptr_user_info; - - NTTIME logon_time; /* logon time */ - NTTIME logoff_time; /* logoff time */ - NTTIME kickoff_time; /* kickoff time */ - NTTIME pass_last_set_time; /* password last set time */ - NTTIME pass_can_change_time; /* password can change time */ - NTTIME pass_must_change_time; /* password must change time */ - - UNIHDR hdr_user_name; /* username unicode string header */ - UNIHDR hdr_full_name; /* user's full name unicode string header */ - UNIHDR hdr_logon_script; /* logon script unicode string header */ - UNIHDR hdr_profile_path; /* profile path unicode string header */ - UNIHDR hdr_home_dir; /* home directory unicode string header */ - UNIHDR hdr_dir_drive; /* home directory drive unicode string header */ - - uint16 logon_count; /* logon count */ - uint16 bad_pw_count; /* bad password count */ - - uint32 user_rid; /* User RID */ - uint32 group_rid; /* Group RID */ - - uint32 num_groups; /* num groups */ - uint32 buffer_groups; /* undocumented buffer pointer to groups. */ - uint32 user_flgs; /* user flags */ - - uint8 user_sess_key[16]; /* user session key */ - - UNIHDR hdr_logon_srv; /* logon server unicode string header */ - UNIHDR hdr_logon_dom; /* logon domain unicode string header */ - - uint32 buffer_dom_id; /* undocumented logon domain id pointer */ - uint8 lm_sess_key[8]; /* lm session key */ - uint32 acct_flags; /* account flags */ - uint32 unknown[7]; /* unknown */ - - uint32 num_other_sids; /* number of foreign/trusted domain sids */ - uint32 buffer_other_sids; - - /* The next three uint32 are not really part of user_info_3 but here - * for parsing convenience. They are only valid in Kerberos PAC - * parsing - Guenther */ - uint32 ptr_res_group_dom_sid; - uint32 res_group_count; - uint32 ptr_res_groups; - - UNISTR2 uni_user_name; /* username unicode string */ - UNISTR2 uni_full_name; /* user's full name unicode string */ - UNISTR2 uni_logon_script; /* logon script unicode string */ - UNISTR2 uni_profile_path; /* profile path unicode string */ - UNISTR2 uni_home_dir; /* home directory unicode string */ - UNISTR2 uni_dir_drive; /* home directory drive unicode string */ - - uint32 num_groups2; /* num groups */ - DOM_GID *gids; /* group info */ - - UNISTR2 uni_logon_srv; /* logon server unicode string */ - UNISTR2 uni_logon_dom; /* logon domain unicode string */ - - DOM_SID2 dom_sid; /* domain SID */ - - DOM_SID2 *other_sids; /* foreign/trusted domain SIDs */ - uint32 *other_sids_attrib; -} NET_USER_INFO_3; - /* NEG_FLAGS */ typedef struct neg_flags_info { uint32 neg_flags; /* negotiated flags */ @@ -279,78 +102,9 @@ typedef struct net_r_auth3_info { } NET_R_AUTH_3; -/* NET_ID_INFO_2 */ -typedef struct net_network_info_2 { - uint32 ptr_id_info2; /* pointer to id_info_2 */ - UNIHDR hdr_domain_name; /* domain name unicode header */ - uint32 param_ctrl; /* param control (0x2) */ - DOM_LOGON_ID logon_id; /* logon ID */ - UNIHDR hdr_user_name; /* user name unicode header */ - UNIHDR hdr_wksta_name; /* workstation name unicode header */ - uint8 lm_chal[8]; /* lan manager 8 byte challenge */ - STRHDR hdr_nt_chal_resp; /* nt challenge response */ - STRHDR hdr_lm_chal_resp; /* lm challenge response */ - - UNISTR2 uni_domain_name; /* domain name unicode string */ - UNISTR2 uni_user_name; /* user name unicode string */ - UNISTR2 uni_wksta_name; /* workgroup name unicode string */ - STRING2 nt_chal_resp; /* nt challenge response */ - STRING2 lm_chal_resp; /* lm challenge response */ -} NET_ID_INFO_2; - -/* NET_ID_INFO_1 */ -typedef struct id_info_1 { - uint32 ptr_id_info1; /* pointer to id_info_1 */ - UNIHDR hdr_domain_name; /* domain name unicode header */ - uint32 param_ctrl; /* param control */ - DOM_LOGON_ID logon_id; /* logon ID */ - UNIHDR hdr_user_name; /* user name unicode header */ - UNIHDR hdr_wksta_name; /* workstation name unicode header */ - OWF_INFO lm_owf; /* LM OWF Password */ - OWF_INFO nt_owf; /* NT OWF Password */ - UNISTR2 uni_domain_name; /* domain name unicode string */ - UNISTR2 uni_user_name; /* user name unicode string */ - UNISTR2 uni_wksta_name; /* workgroup name unicode string */ -} NET_ID_INFO_1; - #define INTERACTIVE_LOGON_TYPE 1 #define NET_LOGON_TYPE 2 -/* NET_ID_INFO_CTR */ -typedef struct net_id_info_ctr_info { - uint16 switch_value; - - union { - NET_ID_INFO_1 id1; /* auth-level 1 - interactive user login */ - NET_ID_INFO_2 id2; /* auth-level 2 - workstation referred login */ - } auth; -} NET_ID_INFO_CTR; - -/* SAM_INFO - sam logon/off id structure - no creds */ -typedef struct sam_info_ex { - DOM_CLNT_SRV client; - uint16 logon_level; - NET_ID_INFO_CTR *ctr; -} DOM_SAM_INFO_EX; - -/* NET_Q_SAM_LOGON_EX */ -typedef struct net_q_sam_logon_info_ex { - DOM_SAM_INFO_EX sam_id; - uint16 validation_level; - uint32 flags; -} NET_Q_SAM_LOGON_EX; - -/* NET_R_SAM_LOGON_EX */ -typedef struct net_r_sam_logon_info_ex { - uint16 switch_value; /* 3 - indicates type of USER INFO */ - NET_USER_INFO_3 *user; - - uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */ - uint32 flags; - - NTSTATUS status; /* return code */ -} NET_R_SAM_LOGON_EX; - /* LOCKOUT_STRING */ typedef struct account_lockout_string { uint32 array_size; diff --git a/source3/rpc_client/init_netlogon.c b/source3/rpc_client/init_netlogon.c index f63c54999f..62f1fac626 100644 --- a/source3/rpc_client/init_netlogon.c +++ b/source3/rpc_client/init_netlogon.c @@ -158,6 +158,17 @@ void init_netr_IdentityInfo(struct netr_IdentityInfo *r, /******************************************************************* inits a structure. + This is a network logon packet. The log_id parameters + are what an NT server would generate for LUID once the + user is logged on. I don't think we care about them. + + Note that this has no access to the NT and LM hashed passwords, + so it forwards the challenge, and the NT and LM responses (24 + bytes each) over the secure channel to the Domain controller + for it to say yea or nay. This is the preferred method of + checking for a logon as it doesn't export the password + hashes to anyone who has compromised the secure channel. JRA. + ********************************************************************/ void init_netr_NetworkInfo(struct netr_NetworkInfo *r, diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index 38ea7846b7..c8f4862fc7 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -115,667 +115,3 @@ bool net_io_r_auth_3(const char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int de return True; } - -/******************************************************************* - Inits a NET_ID_INFO_1 structure. -********************************************************************/ - -void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name, - uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high, - const char *user_name, const char *wksta_name, - const char *sess_key, - unsigned char lm_cypher[16], unsigned char nt_cypher[16]) -{ - unsigned char lm_owf[16]; - unsigned char nt_owf[16]; - - DEBUG(5,("init_id_info1: %d\n", __LINE__)); - - id->ptr_id_info1 = 1; - - id->param_ctrl = param_ctrl; - init_logon_id(&id->logon_id, log_id_low, log_id_high); - - - if (lm_cypher && nt_cypher) { - unsigned char key[16]; -#ifdef DEBUG_PASSWORD - DEBUG(100,("lm cypher:")); - dump_data(100, lm_cypher, 16); - - DEBUG(100,("nt cypher:")); - dump_data(100, nt_cypher, 16); -#endif - - memset(key, 0, 16); - memcpy(key, sess_key, 8); - - memcpy(lm_owf, lm_cypher, 16); - SamOEMhash(lm_owf, key, 16); - memcpy(nt_owf, nt_cypher, 16); - SamOEMhash(nt_owf, key, 16); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("encrypt of lm owf password:")); - dump_data(100, lm_owf, 16); - - DEBUG(100,("encrypt of nt owf password:")); - dump_data(100, nt_owf, 16); -#endif - /* set up pointers to cypher blocks */ - lm_cypher = lm_owf; - nt_cypher = nt_owf; - } - - init_owf_info(&id->lm_owf, lm_cypher); - init_owf_info(&id->nt_owf, nt_cypher); - - init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE); - init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name); - init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE); - init_uni_hdr(&id->hdr_user_name, &id->uni_user_name); - init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE); - init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name); -} - -/******************************************************************* - Reads or writes an NET_ID_INFO_1 structure. -********************************************************************/ - -static bool net_io_id_info1(const char *desc, NET_ID_INFO_1 *id, prs_struct *ps, int depth) -{ - if (id == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_id_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_id_info1", ps, depth, &id->ptr_id_info1)) - return False; - - if (id->ptr_id_info1 != 0) { - if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth)) - return False; - - if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl)) - return False; - if(!smb_io_logon_id("", &id->logon_id, ps, depth)) - return False; - - if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth)) - return False; - if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth)) - return False; - - if(!smb_io_owf_info("", &id->lm_owf, ps, depth)) - return False; - if(!smb_io_owf_info("", &id->nt_owf, ps, depth)) - return False; - - if(!smb_io_unistr2("unistr2", &id->uni_domain_name, - id->hdr_domain_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("unistr2", &id->uni_user_name, - id->hdr_user_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("unistr2", &id->uni_wksta_name, - id->hdr_wksta_name.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -Inits a NET_ID_INFO_2 structure. - -This is a network logon packet. The log_id parameters -are what an NT server would generate for LUID once the -user is logged on. I don't think we care about them. - -Note that this has no access to the NT and LM hashed passwords, -so it forwards the challenge, and the NT and LM responses (24 -bytes each) over the secure channel to the Domain controller -for it to say yea or nay. This is the preferred method of -checking for a logon as it doesn't export the password -hashes to anyone who has compromised the secure channel. JRA. -********************************************************************/ - -void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name, - uint32 param_ctrl, - uint32 log_id_low, uint32 log_id_high, - const char *user_name, const char *wksta_name, - const uchar lm_challenge[8], - const uchar * lm_chal_resp, size_t lm_chal_resp_len, - const uchar * nt_chal_resp, size_t nt_chal_resp_len) -{ - - DEBUG(5,("init_id_info2: %d\n", __LINE__)); - - id->ptr_id_info2 = 1; - - id->param_ctrl = param_ctrl; - init_logon_id(&id->logon_id, log_id_low, log_id_high); - - memcpy(id->lm_chal, lm_challenge, sizeof(id->lm_chal)); - init_str_hdr(&id->hdr_nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0); - init_str_hdr(&id->hdr_lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0); - - init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE); - init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name); - init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE); - init_uni_hdr(&id->hdr_user_name, &id->uni_user_name); - init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE); - init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name); - - init_string2(&id->nt_chal_resp, (const char *)nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len); - init_string2(&id->lm_chal_resp, (const char *)lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len); - -} - -/******************************************************************* - Reads or writes an NET_ID_INFO_2 structure. -********************************************************************/ - -static bool net_io_id_info2(const char *desc, NET_ID_INFO_2 *id, prs_struct *ps, int depth) -{ - if (id == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_id_info2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_id_info2", ps, depth, &id->ptr_id_info2)) - return False; - - if (id->ptr_id_info2 != 0) { - if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth)) - return False; - - if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl)) - return False; - if(!smb_io_logon_id("", &id->logon_id, ps, depth)) - return False; - - if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth)) - return False; - if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth)) - return False; - - if(!prs_uint8s (False, "lm_chal", ps, depth, id->lm_chal, 8)) /* lm 8 byte challenge */ - return False; - - if(!smb_io_strhdr("hdr_nt_chal_resp", &id->hdr_nt_chal_resp, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_lm_chal_resp", &id->hdr_lm_chal_resp, ps, depth)) - return False; - - if(!smb_io_unistr2("uni_domain_name", &id->uni_domain_name, - id->hdr_domain_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_user_name ", &id->uni_user_name, - id->hdr_user_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_wksta_name ", &id->uni_wksta_name, - id->hdr_wksta_name.buffer, ps, depth)) - return False; - if(!smb_io_string2("nt_chal_resp", &id->nt_chal_resp, - id->hdr_nt_chal_resp.buffer, ps, depth)) - return False; - if(!smb_io_string2("lm_chal_resp", &id->lm_chal_resp, - id->hdr_lm_chal_resp.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a DOM_SAM_INFO structure. -********************************************************************/ - -void init_sam_info_ex(DOM_SAM_INFO_EX *sam, - const char *logon_srv, const char *comp_name, - uint16 logon_level, NET_ID_INFO_CTR *ctr) -{ - DEBUG(5,("init_sam_info_ex: %d\n", __LINE__)); - - init_clnt_srv(&sam->client, logon_srv, comp_name); - sam->logon_level = logon_level; - sam->ctr = ctr; -} - -/******************************************************************* - Reads or writes a DOM_SAM_INFO structure. -********************************************************************/ - -static bool net_io_id_info_ctr(const char *desc, NET_ID_INFO_CTR **pp_ctr, prs_struct *ps, int depth) -{ - NET_ID_INFO_CTR *ctr = *pp_ctr; - - prs_debug(ps, depth, desc, "smb_io_sam_info_ctr"); - depth++; - - if (UNMARSHALLING(ps)) { - ctr = *pp_ctr = PRS_ALLOC_MEM(ps, NET_ID_INFO_CTR, 1); - if (ctr == NULL) - return False; - } - - if (ctr == NULL) - return False; - - /* don't 4-byte align here! */ - - if(!prs_uint16("switch_value ", ps, depth, &ctr->switch_value)) - return False; - - switch (ctr->switch_value) { - case 1: - if(!net_io_id_info1("", &ctr->auth.id1, ps, depth)) - return False; - break; - case 2: - if(!net_io_id_info2("", &ctr->auth.id2, ps, depth)) - return False; - break; - default: - /* PANIC! */ - DEBUG(4,("smb_io_sam_info_ctr: unknown switch_value!\n")); - break; - } - - return True; -} - -/******************************************************************* - Reads or writes a DOM_SAM_INFO_EX structure. - ********************************************************************/ - -static bool smb_io_sam_info_ex(const char *desc, DOM_SAM_INFO_EX *sam, prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_sam_info_ex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_clnt_srv("", &sam->client, ps, depth)) - return False; - - if(!prs_uint16("logon_level ", ps, depth, &sam->logon_level)) - return False; - - if (sam->logon_level != 0) { - if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth)) - return False; - } - - return True; -} - -static void dump_acct_flags(uint32 acct_flags) { - - int lvl = 10; - DEBUG(lvl,("dump_acct_flags\n")); - if (acct_flags & ACB_NORMAL) { - DEBUGADD(lvl,("\taccount has ACB_NORMAL\n")); - } - if (acct_flags & ACB_PWNOEXP) { - DEBUGADD(lvl,("\taccount has ACB_PWNOEXP\n")); - } - if (acct_flags & ACB_ENC_TXT_PWD_ALLOWED) { - DEBUGADD(lvl,("\taccount has ACB_ENC_TXT_PWD_ALLOWED\n")); - } - if (acct_flags & ACB_NOT_DELEGATED) { - DEBUGADD(lvl,("\taccount has ACB_NOT_DELEGATED\n")); - } - if (acct_flags & ACB_USE_DES_KEY_ONLY) { - DEBUGADD(lvl,("\taccount has ACB_USE_DES_KEY_ONLY set, sig verify wont work\n")); - } - if (acct_flags & ACB_NO_AUTH_DATA_REQD) { - DEBUGADD(lvl,("\taccount has ACB_NO_AUTH_DATA_REQD set\n")); - } - if (acct_flags & ACB_PW_EXPIRED) { - DEBUGADD(lvl,("\taccount has ACB_PW_EXPIRED set\n")); - } -} - -static void dump_user_flgs(uint32 user_flags) { - - int lvl = 10; - DEBUG(lvl,("dump_user_flgs\n")); - if (user_flags & NETLOGON_EXTRA_SIDS) { - DEBUGADD(lvl,("\taccount has NETLOGON_EXTRA_SIDS\n")); - } - if (user_flags & NETLOGON_RESOURCE_GROUPS) { - DEBUGADD(lvl,("\taccount has NETLOGON_RESOURCE_GROUPS\n")); - } - if (user_flags & NETLOGON_NTLMV2_ENABLED) { - DEBUGADD(lvl,("\taccount has NETLOGON_NTLMV2_ENABLED\n")); - } - if (user_flags & NETLOGON_CACHED_ACCOUNT) { - DEBUGADD(lvl,("\taccount has NETLOGON_CACHED_ACCOUNT\n")); - } - if (user_flags & NETLOGON_PROFILE_PATH_RETURNED) { - DEBUGADD(lvl,("\taccount has NETLOGON_PROFILE_PATH_RETURNED\n")); - } - if (user_flags & NETLOGON_SERVER_TRUST_ACCOUNT) { - DEBUGADD(lvl,("\taccount has NETLOGON_SERVER_TRUST_ACCOUNT\n")); - } - - -} - -/******************************************************************* - This code has been modified to cope with a NET_USER_INFO_2 - which is - exactly the same as a NET_USER_INFO_3, minus the other sids parameters. - We use validation level to determine if we're marshalling a info 2 or - INFO_3 - be we always return an INFO_3. Based on code donated by Marc - Jacobsen at HP. JRA. -********************************************************************/ - -bool net_io_user_info3(const char *desc, NET_USER_INFO_3 *usr, prs_struct *ps, - int depth, uint16 validation_level, bool kerb_validation_level) -{ - unsigned int i; - - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_user_info3"); - depth++; - - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(usr); - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_user_info ", ps, depth, &usr->ptr_user_info)) - return False; - - if (usr->ptr_user_info == 0) - return True; - - if(!smb_io_time("logon time", &usr->logon_time, ps, depth)) /* logon time */ - return False; - if(!smb_io_time("logoff time", &usr->logoff_time, ps, depth)) /* logoff time */ - return False; - if(!smb_io_time("kickoff time", &usr->kickoff_time, ps, depth)) /* kickoff time */ - return False; - if(!smb_io_time("last set time", &usr->pass_last_set_time, ps, depth)) /* password last set time */ - return False; - if(!smb_io_time("can change time", &usr->pass_can_change_time , ps, depth)) /* password can change time */ - return False; - if(!smb_io_time("must change time", &usr->pass_must_change_time, ps, depth)) /* password must change time */ - return False; - - if(!smb_io_unihdr("hdr_user_name", &usr->hdr_user_name, ps, depth)) /* username unicode string header */ - return False; - if(!smb_io_unihdr("hdr_full_name", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */ - return False; - if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */ - return False; - if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */ - return False; - if(!smb_io_unihdr("hdr_home_dir", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */ - return False; - if(!smb_io_unihdr("hdr_dir_drive", &usr->hdr_dir_drive, ps, depth)) /* home directory drive unicode string header */ - return False; - - if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count)) /* logon count */ - return False; - if(!prs_uint16("bad_pw_count ", ps, depth, &usr->bad_pw_count)) /* bad password count */ - return False; - - if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User RID */ - return False; - if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group RID */ - return False; - if(!prs_uint32("num_groups ", ps, depth, &usr->num_groups)) /* num groups */ - return False; - if(!prs_uint32("buffer_groups ", ps, depth, &usr->buffer_groups)) /* undocumented buffer pointer to groups. */ - return False; - if(!prs_uint32("user_flgs ", ps, depth, &usr->user_flgs)) /* user flags */ - return False; - dump_user_flgs(usr->user_flgs); - if(!prs_uint8s(False, "user_sess_key", ps, depth, usr->user_sess_key, 16)) /* user session key */ - return False; - - if(!smb_io_unihdr("hdr_logon_srv", &usr->hdr_logon_srv, ps, depth)) /* logon server unicode string header */ - return False; - if(!smb_io_unihdr("hdr_logon_dom", &usr->hdr_logon_dom, ps, depth)) /* logon domain unicode string header */ - return False; - - if(!prs_uint32("buffer_dom_id ", ps, depth, &usr->buffer_dom_id)) /* undocumented logon domain id pointer */ - return False; - - if(!prs_uint8s(False, "lm_sess_key", ps, depth, usr->lm_sess_key, 8)) /* lm session key */ - return False; - - if(!prs_uint32("acct_flags ", ps, depth, &usr->acct_flags)) /* Account flags */ - return False; - dump_acct_flags(usr->acct_flags); - for (i = 0; i < 7; i++) - { - if (!prs_uint32("unkown", ps, depth, &usr->unknown[i])) /* unknown */ - return False; - } - - if (validation_level == 3) { - if(!prs_uint32("num_other_sids", ps, depth, &usr->num_other_sids)) /* 0 - num_sids */ - return False; - if(!prs_uint32("buffer_other_sids", ps, depth, &usr->buffer_other_sids)) /* NULL - undocumented pointer to SIDs. */ - return False; - } else { - if (UNMARSHALLING(ps)) { - usr->num_other_sids = 0; - usr->buffer_other_sids = 0; - } - } - - /* get kerb validation info (not really part of user_info_3) - Guenther */ - - if (kerb_validation_level) { - - if(!prs_uint32("ptr_res_group_dom_sid", ps, depth, &usr->ptr_res_group_dom_sid)) - return False; - if(!prs_uint32("res_group_count", ps, depth, &usr->res_group_count)) - return False; - if(!prs_uint32("ptr_res_groups", ps, depth, &usr->ptr_res_groups)) - return False; - } - - if(!smb_io_unistr2("uni_user_name", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */ - return False; - if(!smb_io_unistr2("uni_full_name", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */ - return False; - if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */ - return False; - if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */ - return False; - if(!smb_io_unistr2("uni_home_dir", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */ - return False; - if(!smb_io_unistr2("uni_dir_drive", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */ - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_groups2 ", ps, depth, &usr->num_groups2)) /* num groups2 */ - return False; - - if (usr->num_groups != usr->num_groups2) { - DEBUG(3,("net_io_user_info3: num_groups mismatch! (%d != %d)\n", - usr->num_groups, usr->num_groups2)); - return False; - } - - if (UNMARSHALLING(ps)) { - if (usr->num_groups) { - usr->gids = PRS_ALLOC_MEM(ps, DOM_GID, usr->num_groups); - if (usr->gids == NULL) - return False; - } else { - usr->gids = NULL; - } - } - - for (i = 0; i < usr->num_groups; i++) { - if(!smb_io_gid("", &usr->gids[i], ps, depth)) /* group info */ - return False; - } - - if(!smb_io_unistr2("uni_logon_srv", &usr->uni_logon_srv, usr->hdr_logon_srv.buffer, ps, depth)) /* logon server unicode string */ - return False; - if(!smb_io_unistr2("uni_logon_dom", &usr->uni_logon_dom, usr->hdr_logon_dom.buffer, ps, depth)) /* logon domain unicode string */ - return False; - - if(!smb_io_dom_sid2("", &usr->dom_sid, ps, depth)) /* domain SID */ - return False; - - if (validation_level == 3 && usr->buffer_other_sids) { - - uint32 num_other_sids = usr->num_other_sids; - - if (!(usr->user_flgs & NETLOGON_EXTRA_SIDS)) { - DEBUG(10,("net_io_user_info3: user_flgs attribute does not have NETLOGON_EXTRA_SIDS\n")); - /* return False; */ - } - - if (!prs_uint32("num_other_sids", ps, depth, - &num_other_sids)) - return False; - - if (num_other_sids != usr->num_other_sids) - return False; - - if (UNMARSHALLING(ps)) { - if (usr->num_other_sids) { - usr->other_sids = PRS_ALLOC_MEM(ps, DOM_SID2, usr->num_other_sids); - usr->other_sids_attrib = - PRS_ALLOC_MEM(ps, uint32, usr->num_other_sids); - } else { - usr->other_sids = NULL; - usr->other_sids_attrib = NULL; - } - - if ((num_other_sids != 0) && - ((usr->other_sids == NULL) || - (usr->other_sids_attrib == NULL))) - return False; - } - - /* First the pointers to the SIDS and attributes */ - - depth++; - - for (i=0; inum_other_sids; i++) { - uint32 ptr = 1; - - if (!prs_uint32("sid_ptr", ps, depth, &ptr)) - return False; - - if (UNMARSHALLING(ps) && (ptr == 0)) - return False; - - if (!prs_uint32("attribute", ps, depth, - &usr->other_sids_attrib[i])) - return False; - } - - for (i = 0; i < usr->num_other_sids; i++) { - if(!smb_io_dom_sid2("", &usr->other_sids[i], ps, depth)) /* other domain SIDs */ - return False; - } - - depth--; - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_q_sam_logon_ex(const char *desc, NET_Q_SAM_LOGON_EX *q_l, prs_struct *ps, int depth) -{ - if (q_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_sam_logon_ex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_sam_info_ex("", &q_l->sam_id, ps, depth)) - return False; - - if(!prs_align_uint16(ps)) - return False; - - if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level)) - return False; - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &q_l->flags)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_r_sam_logon_ex(const char *desc, NET_R_SAM_LOGON_EX *r_l, prs_struct *ps, int depth) -{ - if (r_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_sam_logon_ex"); - depth++; - - if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value)) - return False; - if(!prs_align(ps)) - return False; - -#if 1 /* W2k always needs this - even for bad passwd. JRA */ - if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False)) - return False; -#else - if (r_l->switch_value != 0) { - if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False)) - return False; - } -#endif - - if(!prs_uint32("auth_resp ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */ - return False; - - if(!prs_uint32("flags ", ps, depth, &r_l->flags)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - if(!prs_align(ps)) - return False; - - return True; -} -- cgit From 95cd28299ec3764cc12c7ffb29b764d1a7cc4bee Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:53:23 +0100 Subject: Remove unused marshalling for NET_AUTH3. Guenther (This used to be commit ccf3ba0f5ce30d45a3d644552d1245391bf01754) --- source3/include/rpc_netlogon.h | 21 --------- source3/rpc_client/cli_netlogon.c | 52 ---------------------- source3/rpc_parse/parse_net.c | 91 --------------------------------------- 3 files changed, 164 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index 8058b71e80..958078d5ca 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -81,27 +81,6 @@ #define MSV1_0_RETURN_PROFILE_PATH 0x00000200 #endif -/* NEG_FLAGS */ -typedef struct neg_flags_info { - uint32 neg_flags; /* negotiated flags */ -} NEG_FLAGS; - -/* NET_Q_AUTH_3 */ -typedef struct net_q_auth3_info { - DOM_LOG_INFO clnt_id; /* client identification info */ - DOM_CHAL clnt_chal; /* client-calculated credentials */ - NEG_FLAGS clnt_flgs; /* usually 0x6007 ffff */ -} NET_Q_AUTH_3; - -/* NET_R_AUTH_3 */ -typedef struct net_r_auth3_info { - DOM_CHAL srv_chal; /* server-calculated credentials */ - NEG_FLAGS srv_flgs; /* usually 0x6007 ffff */ - uint32 unknown; /* 0x0000045b */ - NTSTATUS status; /* return code */ -} NET_R_AUTH_3; - - #define INTERACTIVE_LOGON_TYPE 1 #define NET_LOGON_TYPE 2 diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index 064de5e4ea..cdf51c6241 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -112,58 +112,6 @@ password ?).\n", cli->cli->desthost )); /* instead of rpccli_net_auth2() we use rpccli_netr_ServerAuthenticate2() now - gd */ -#if 0 /* not currebntly used */ -/**************************************************************************** - LSA Authenticate 3 - - Send the client credential, receive back a server credential. - The caller *must* ensure that the server credential returned matches the session key - encrypt of the server challenge originally received. JRA. -****************************************************************************/ - -static NTSTATUS rpccli_net_auth3(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *server_name, - const char *account_name, - uint16 sec_chan_type, - const char *computer_name, - uint32 *neg_flags_inout, - const DOM_CHAL *clnt_chal_in, - DOM_CHAL *srv_chal_out) -{ - prs_struct qbuf, rbuf; - NET_Q_AUTH_3 q; - NET_R_AUTH_3 r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - - /* create and send a MSRPC command with api NET_AUTH2 */ - - DEBUG(4,("cli_net_auth3: srv:%s acct:%s sc:%x mc: %s chal %s neg: %x\n", - server_name, account_name, sec_chan_type, computer_name, - credstr(clnt_chal_in->data), *neg_flags_inout)); - - /* store the parameters */ - init_q_auth_3(&q, server_name, account_name, sec_chan_type, - computer_name, clnt_chal_in, *neg_flags_inout); - - /* turn parameters into data stream */ - - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_AUTH3, - q, r, - qbuf, rbuf, - net_io_q_auth_3, - net_io_r_auth_3, - NT_STATUS_UNSUCCESSFUL); - - if (NT_STATUS_IS_OK(result)) { - *srv_chal_out = r.srv_chal; - *neg_flags_inout = r.srv_flgs.neg_flags; - } - - return result; -} -#endif /* not currebntly used */ - /**************************************************************************** Wrapper function that uses the auth and auth2 calls to set up a NETLOGON credentials chain. Stores the credentials in the struct dcinfo in the diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index c8f4862fc7..5dcaccf1c3 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -24,94 +24,3 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_PARSE - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static bool net_io_neg_flags(const char *desc, NEG_FLAGS *neg, prs_struct *ps, int depth) -{ - if (neg == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_neg_flags"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("neg_flags", ps, depth, &neg->neg_flags)) - return False; - - return True; -} - -/******************************************************************* - Inits a NET_Q_AUTH_3 struct. -********************************************************************/ - -void init_q_auth_3(NET_Q_AUTH_3 *q_a, - const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name, - const DOM_CHAL *clnt_chal, uint32 clnt_flgs) -{ - DEBUG(5,("init_q_auth_3: %d\n", __LINE__)); - - init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name); - memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data)); - q_a->clnt_flgs.neg_flags = clnt_flgs; - - DEBUG(5,("init_q_auth_3: %d\n", __LINE__)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_q_auth_3(const char *desc, NET_Q_AUTH_3 *q_a, prs_struct *ps, int depth) -{ - if (q_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_auth_3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */ - return False; - if(!smb_io_chal("", &q_a->clnt_chal, ps, depth)) - return False; - if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool net_io_r_auth_3(const char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int depth) -{ - if (r_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_auth_3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal("srv_chal", &r_a->srv_chal, ps, depth)) /* server challenge */ - return False; - if(!net_io_neg_flags("srv_flgs", &r_a->srv_flgs, ps, depth)) - return False; - if (!prs_uint32("unknown", ps, depth, &r_a->unknown)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_a->status)) - return False; - - return True; -} -- cgit From 7d1f1681063ddddbf9ace00585604ca5f283ae6d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:55:22 +0100 Subject: Add sync netr_LogonControlCode from samba3. Guenther (This used to be commit 584b2453530deeaa0260d78818fbcf30cea5b702) --- source3/librpc/idl/netlogon.idl | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index 6095160ec7..5979701703 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -798,6 +798,7 @@ interface netlogon /* function_code values */ typedef [v1_enum] enum { + NETLOGON_CONTROL_SYNC = 2, NETLOGON_CONTROL_REDISCOVER = 5, NETLOGON_CONTROL_TC_QUERY = 6, NETLOGON_CONTROL_TRANSPORT_NOTIFY = 7, -- cgit From 59163ba5153a82a621c6e194c7d654fdacab64c3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:56:09 +0100 Subject: Re-run make idl. Guenther (This used to be commit ee22ac6bb8e8c5281fc3dd35cb724f6c7a610933) --- source3/librpc/gen_ndr/ndr_netlogon.c | 1 + source3/librpc/gen_ndr/netlogon.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index 3968bcd2ae..fb5c4603ee 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -5714,6 +5714,7 @@ _PUBLIC_ void ndr_print_netr_LogonControlCode(struct ndr_print *ndr, const char const char *val = NULL; switch (r) { + case NETLOGON_CONTROL_SYNC: val = "NETLOGON_CONTROL_SYNC"; break; case NETLOGON_CONTROL_REDISCOVER: val = "NETLOGON_CONTROL_REDISCOVER"; break; case NETLOGON_CONTROL_TC_QUERY: val = "NETLOGON_CONTROL_TC_QUERY"; break; case NETLOGON_CONTROL_TRANSPORT_NOTIFY: val = "NETLOGON_CONTROL_TRANSPORT_NOTIFY"; break; diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index bff2d91a03..058e5e7fb0 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -603,6 +603,7 @@ union netr_CONTROL_QUERY_INFORMATION { enum netr_LogonControlCode #ifndef USE_UINT_ENUMS { + NETLOGON_CONTROL_SYNC=2, NETLOGON_CONTROL_REDISCOVER=5, NETLOGON_CONTROL_TC_QUERY=6, NETLOGON_CONTROL_TRANSPORT_NOTIFY=7, @@ -610,6 +611,7 @@ enum netr_LogonControlCode } #else { __donnot_use_enum_netr_LogonControlCode=0x7FFFFFFF} +#define NETLOGON_CONTROL_SYNC ( 2 ) #define NETLOGON_CONTROL_REDISCOVER ( 5 ) #define NETLOGON_CONTROL_TC_QUERY ( 6 ) #define NETLOGON_CONTROL_TRANSPORT_NOTIFY ( 7 ) -- cgit From f68ddb1a1aa4209b5c79b81489b6f6fe9f319c25 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 02:57:16 +0100 Subject: Remove rpc_parse/parse_net.c and some last unused netlogon headers. Guenther (This used to be commit b9cc5cfaf9a87d342c23fa0f68f29050947b5102) --- source3/Makefile.in | 6 +++--- source3/include/rpc_netlogon.h | 30 ------------------------------ source3/rpc_parse/parse_net.c | 26 -------------------------- 3 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 source3/rpc_parse/parse_net.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index c0e4578ef4..a28972f22d 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -296,8 +296,8 @@ RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o # that requires knowledge of security contexts RPC_PARSE_OBJ1 = $(RPC_PARSE_OBJ0) rpc_parse/parse_sec.o -RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_net.o rpc_parse/parse_srv.o -RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_net.o rpc_parse/parse_srv.o \ +RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_srv.o +RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_srv.o \ rpc_client/init_netlogon.o \ rpc_client/init_lsa.o @@ -1052,7 +1052,7 @@ NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ) \ libsmb/asn1.o libsmb/spnego.o libsmb/clikrb5.o libads/kerberos.o \ $(SECRETS_OBJ) $(SERVER_MUTEX_OBJ) $(LIBADS_SERVER_OBJ) \ $(RPC_PARSE_OBJ1) $(PASSDB_OBJ) $(GROUPDB_OBJ) \ - $(SMBLDAP_OBJ) $(DOSERR_OBJ) rpc_parse/parse_net.o $(LIBNMB_OBJ) \ + $(SMBLDAP_OBJ) $(DOSERR_OBJ) $(LIBNMB_OBJ) \ $(LDB_OBJ) $(ERRORMAP_OBJ) $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ \ librpc/gen_ndr/ndr_samr.o \ librpc/gen_ndr/ndr_lsa.o \ diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index 958078d5ca..cd88ffef59 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -23,36 +23,6 @@ #ifndef _RPC_NETLOGON_H /* _RPC_NETLOGON_H */ #define _RPC_NETLOGON_H - -/* NETLOGON pipe */ -#define NET_SAMLOGON 0x02 -#define NET_SAMLOGOFF 0x03 -#define NET_REQCHAL 0x04 -#define NET_AUTH 0x05 -#define NET_SRVPWSET 0x06 -#define NET_SAM_DELTAS 0x07 -#define NET_GETDCNAME 0x0b -#define NET_LOGON_CTRL 0x0c -#define NET_GETANYDCNAME 0x0d -#define NET_AUTH2 0x0f -#define NET_LOGON_CTRL2 0x0e -#define NET_SAM_SYNC 0x10 -#define NET_TRUST_DOM_LIST 0x13 -#define NET_DSR_GETDCNAME 0x14 -#define NET_AUTH3 0x1a -#define NET_DSR_GETDCNAMEEX 0x1b -#define NET_DSR_GETSITENAME 0x1c -#define NET_DSR_GETDCNAMEEX2 0x22 -#define NET_SAMLOGON_EX 0x27 - -/* flags use when sending a NETLOGON_CONTROL request */ - -#define NETLOGON_CONTROL_SYNC 0x2 -#define NETLOGON_CONTROL_REDISCOVER 0x5 -#define NETLOGON_CONTROL_TC_QUERY 0x6 -#define NETLOGON_CONTROL_TRANSPORT_NOTIFY 0x7 -#define NETLOGON_CONTROL_SET_DBFLAG 0xfffe - /* Some flag values reverse engineered from NLTEST.EXE */ /* used in the NETLOGON_CONTROL[2] reply */ diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c deleted file mode 100644 index 5dcaccf1c3..0000000000 --- a/source3/rpc_parse/parse_net.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jean Francois Micouleau 2002. - * - * 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 "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE -- cgit From 5b8ebcf397e40bf1f9555c34fadbab2d7b5bf717 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 03:08:42 +0100 Subject: Remove unused creds_client_check and creds_client_step. Guenther (This used to be commit 1dcb32424d16cff968a8713352c93c48dec58674) --- source3/libsmb/credentials.c | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/credentials.c b/source3/libsmb/credentials.c index 2dcbdf3cf9..9d33e6d93d 100644 --- a/source3/libsmb/credentials.c +++ b/source3/libsmb/credentials.c @@ -322,18 +322,6 @@ void creds_client_init(uint32 neg_flags, Check a credential returned by the server. ****************************************************************************/ -bool creds_client_check(const struct dcinfo *dc, const DOM_CHAL *rcv_srv_chal_in) -{ - if (memcmp(dc->srv_chal.data, rcv_srv_chal_in->data, 8)) { - DEBUG(5,("creds_client_check: challenge : %s\n", credstr(rcv_srv_chal_in->data))); - DEBUG(5,("calculated: %s\n", credstr(dc->srv_chal.data))); - DEBUG(0,("creds_client_check: credentials check failed.\n")); - return False; - } - DEBUG(10,("creds_client_check: credentials check OK.\n")); - return True; -} - bool netlogon_creds_client_check(const struct dcinfo *dc, const struct netr_Credential *rcv_srv_chal_in) { @@ -360,17 +348,6 @@ bool netlogon_creds_client_check(const struct dcinfo *dc, the server ****************************************************************************/ -void creds_client_step(struct dcinfo *dc, DOM_CRED *next_cred_out) -{ - dc->sequence += 2; - creds_step(dc); - creds_reseed(dc); - - memcpy(&next_cred_out->challenge.data, dc->clnt_chal.data, - sizeof(next_cred_out->challenge.data)); - next_cred_out->timestamp.time = dc->sequence; -} - void netlogon_creds_client_step(struct dcinfo *dc, struct netr_Authenticator *next_cred_out) { -- cgit From 10c3957d040235b66be1de611aa66aed75e8bef3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 03:10:21 +0100 Subject: Move policy_handle_is_valid out of parse_lsa.c Guenther (This used to be commit c396f45e7ddc8d6ce0efa0cda2996ca513ecbdb7) --- source3/rpc_parse/parse_lsa.c | 12 ------------ source3/rpc_parse/parse_misc.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'source3') diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index 80e90a8265..3d65b9ca3b 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -1206,15 +1206,3 @@ bool lsa_io_r_lookup_names4(const char *desc, LSA_R_LOOKUP_NAMES4 *out, prs_stru return True; } - -/******************************************************************* - Reads or writes an LUID_ATTR structure. -********************************************************************/ - -bool policy_handle_is_valid(const POLICY_HND *hnd) -{ - POLICY_HND zero_pol; - - ZERO_STRUCT(zero_pol); - return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True ); -} diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index 9e1937ea32..418f857df8 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -1859,4 +1859,14 @@ uint32 str_len_uni(UNISTR *source) return i; } +/******************************************************************* + Verifies policy handle +********************************************************************/ +bool policy_handle_is_valid(const POLICY_HND *hnd) +{ + POLICY_HND zero_pol; + + ZERO_STRUCT(zero_pol); + return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? false : true ); +} -- cgit From fa00695d46f195155e13ad47f3f402e28be2ca4a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 19:55:35 +0100 Subject: Fix IDL for lsa_LookupNames. Guenther (This used to be commit 684de849c8f3847b1ba389f4e15225c9ca5924f9) --- source3/librpc/idl/lsa.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 47fa9f43b6..62169bafe5 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -387,10 +387,10 @@ import "security.idl"; [in] policy_handle *handle, [in,range(0,1000)] uint32 num_names, [in,size_is(num_names)] lsa_String names[], - [out,unique] lsa_RefDomainList *domains, - [in,out] lsa_TransSidArray *sids, + [out,ref] lsa_RefDomainList **domains, + [in,out,ref] lsa_TransSidArray *sids, [in] lsa_LookupNamesLevel level, - [in,out] uint32 *count + [in,out,ref] uint32 *count ); -- cgit From 10e93a92d335788adb98c8609f9dc672149977a9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 19:58:18 +0100 Subject: Fix IDL for lsa_LookupSids. Guenther (This used to be commit 10f2cddfd529fcd538a09cc92eb3f99619742c44) --- source3/librpc/idl/lsa.idl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 62169bafe5..c480ed1cc4 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -410,11 +410,11 @@ import "security.idl"; [public] NTSTATUS lsa_LookupSids ( [in] policy_handle *handle, - [in] lsa_SidArray *sids, - [out,unique] lsa_RefDomainList *domains, - [in,out] lsa_TransNameArray *names, + [in,ref] lsa_SidArray *sids, + [out,ref] lsa_RefDomainList **domains, + [in,out,ref] lsa_TransNameArray *names, [in] uint16 level, - [in,out] uint32 *count + [in,out,ref] uint32 *count ); -- cgit From c0dc198c6075de7b88c511810dba5194bf54bf0f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 19:58:48 +0100 Subject: Fix IDL for lsa_LookupSids2. Guenther (This used to be commit 4d5d2fc8d537c5aaa4d1196cc145cb223e4ced4d) --- source3/librpc/idl/lsa.idl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index c480ed1cc4..8d49f6084f 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -879,11 +879,11 @@ import "security.idl"; [public] NTSTATUS lsa_LookupSids2( [in] policy_handle *handle, - [in] lsa_SidArray *sids, - [out,unique] lsa_RefDomainList *domains, - [in,out] lsa_TransNameArray2 *names, + [in,ref] lsa_SidArray *sids, + [out,ref] lsa_RefDomainList **domains, + [in,out,ref] lsa_TransNameArray2 *names, [in] uint16 level, - [in,out] uint32 *count, + [in,out,ref] uint32 *count, [in] uint32 unknown1, [in] uint32 unknown2 ); -- cgit From 6bff54c02e2fac2ea3eb46a8f357139fe55137b8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 20:03:12 +0100 Subject: Fix IDL for lsa_LookupNames2. Guenther (This used to be commit 088a9f21b2a37acdf9a43128252db23d3222ec7c) --- source3/librpc/idl/lsa.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 8d49f6084f..aaee35e1d6 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -907,10 +907,10 @@ import "security.idl"; [in] policy_handle *handle, [in,range(0,1000)] uint32 num_names, [in,size_is(num_names)] lsa_String names[], - [out,unique] lsa_RefDomainList *domains, - [in,out] lsa_TransSidArray2 *sids, + [out,ref] lsa_RefDomainList **domains, + [in,out,ref] lsa_TransSidArray2 *sids, [in] lsa_LookupNamesLevel level, - [in,out] uint32 *count, + [in,out,ref] uint32 *count, [in] uint32 unknown1, [in] uint32 unknown2 ); -- cgit From b1cc1db24707d6e27c19d3d65e92924523eb6704 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 20:03:53 +0100 Subject: Fix IDL for lsa_LookupNames3. Guenther (This used to be commit 6e21a5c3bb6e88ee9c9743094822fb7161f09952) --- source3/librpc/idl/lsa.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index aaee35e1d6..773f36106c 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -960,10 +960,10 @@ import "security.idl"; [in] policy_handle *handle, [in,range(0,1000)] uint32 num_names, [in,size_is(num_names)] lsa_String names[], - [out,unique] lsa_RefDomainList *domains, - [in,out] lsa_TransSidArray3 *sids, + [out,ref] lsa_RefDomainList *domains, + [in,out,ref] lsa_TransSidArray3 *sids, [in] lsa_LookupNamesLevel level, - [in,out] uint32 *count, + [in,out,ref] uint32 *count, [in] uint32 unknown1, [in] uint32 unknown2 ); -- cgit From 3f809ef84059912d3dd3cfbbd81eccea4562f582 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 20:04:14 +0100 Subject: Fix IDL for lsa_LookupSids3. Guenther (This used to be commit 4fe468786bedfb8bc03d5db1396a70379111f188) --- source3/librpc/idl/lsa.idl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 773f36106c..3d8b68812f 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -1035,11 +1035,11 @@ import "security.idl"; /* Function 0x4c */ [public] NTSTATUS lsa_LookupSids3( - [in] lsa_SidArray *sids, - [out,unique] lsa_RefDomainList *domains, - [in,out] lsa_TransNameArray2 *names, + [in,ref] lsa_SidArray *sids, + [out,ref] lsa_RefDomainList **domains, + [in,out,ref] lsa_TransNameArray2 *names, [in] uint16 level, - [in,out] uint32 *count, + [in,out,ref] uint32 *count, [in] uint32 unknown1, [in] uint32 unknown2 ); -- cgit From 9d7f2490fe6b7565884de658c7fe5fa33097156d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 20:04:40 +0100 Subject: Fix IDL for lsa_LookupNames4. Guenther (This used to be commit 8d79684d6cebdf1995c37255b42594522071a910) --- source3/librpc/idl/lsa.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 3d8b68812f..ccac66b172 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -1048,10 +1048,10 @@ import "security.idl"; NTSTATUS lsa_LookupNames4( [in,range(0,1000)] uint32 num_names, [in,size_is(num_names)] lsa_String names[], - [out,unique] lsa_RefDomainList *domains, - [in,out] lsa_TransSidArray3 *sids, + [out,ref] lsa_RefDomainList *domains, + [in,out,ref] lsa_TransSidArray3 *sids, [in] lsa_LookupNamesLevel level, - [in,out] uint32 *count, + [in,out,ref] uint32 *count, [in] uint32 unknown1, [in] uint32 unknown2 ); -- cgit From 0ad7db900e376229e7e7fe17f3103354e401797a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 20:10:54 +0100 Subject: Re-run make idl. Guenther (This used to be commit 66e6f97e8bb3ba18055ecd33a5ddb8aab7080236) --- source3/librpc/gen_ndr/cli_lsa.c | 38 ++---- source3/librpc/gen_ndr/cli_lsa.h | 10 +- source3/librpc/gen_ndr/lsa.h | 14 +-- source3/librpc/gen_ndr/ndr_lsa.c | 251 ++++++++++++++++++++++++--------------- source3/librpc/gen_ndr/srv_lsa.c | 10 +- 5 files changed, 186 insertions(+), 137 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 7484edca49..7f784622b5 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -609,7 +609,7 @@ NTSTATUS rpccli_lsa_LookupNames(struct rpc_pipe_client *cli, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransSidArray *sids, enum lsa_LookupNamesLevel level, uint32_t *count) @@ -649,9 +649,7 @@ NTSTATUS rpccli_lsa_LookupNames(struct rpc_pipe_client *cli, } /* Return variables */ - if (domains && r.out.domains) { - *domains = *r.out.domains; - } + *domains = *r.out.domains; *sids = *r.out.sids; *count = *r.out.count; @@ -663,7 +661,7 @@ NTSTATUS rpccli_lsa_LookupSids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_SidArray *sids, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransNameArray *names, uint16_t level, uint32_t *count) @@ -702,9 +700,7 @@ NTSTATUS rpccli_lsa_LookupSids(struct rpc_pipe_client *cli, } /* Return variables */ - if (domains && r.out.domains) { - *domains = *r.out.domains; - } + *domains = *r.out.domains; *names = *r.out.names; *count = *r.out.count; @@ -2472,7 +2468,7 @@ NTSTATUS rpccli_lsa_LookupSids2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_SidArray *sids, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransNameArray2 *names, uint16_t level, uint32_t *count, @@ -2515,9 +2511,7 @@ NTSTATUS rpccli_lsa_LookupSids2(struct rpc_pipe_client *cli, } /* Return variables */ - if (domains && r.out.domains) { - *domains = *r.out.domains; - } + *domains = *r.out.domains; *names = *r.out.names; *count = *r.out.count; @@ -2530,7 +2524,7 @@ NTSTATUS rpccli_lsa_LookupNames2(struct rpc_pipe_client *cli, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransSidArray2 *sids, enum lsa_LookupNamesLevel level, uint32_t *count, @@ -2574,9 +2568,7 @@ NTSTATUS rpccli_lsa_LookupNames2(struct rpc_pipe_client *cli, } /* Return variables */ - if (domains && r.out.domains) { - *domains = *r.out.domains; - } + *domains = *r.out.domains; *sids = *r.out.sids; *count = *r.out.count; @@ -2966,9 +2958,7 @@ NTSTATUS rpccli_lsa_LookupNames3(struct rpc_pipe_client *cli, } /* Return variables */ - if (domains && r.out.domains) { - *domains = *r.out.domains; - } + *domains = *r.out.domains; *sids = *r.out.sids; *count = *r.out.count; @@ -3246,7 +3236,7 @@ NTSTATUS rpccli_lsa_CREDRRENAME(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_LookupSids3(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct lsa_SidArray *sids, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransNameArray2 *names, uint16_t level, uint32_t *count, @@ -3288,9 +3278,7 @@ NTSTATUS rpccli_lsa_LookupSids3(struct rpc_pipe_client *cli, } /* Return variables */ - if (domains && r.out.domains) { - *domains = *r.out.domains; - } + *domains = *r.out.domains; *names = *r.out.names; *count = *r.out.count; @@ -3345,9 +3333,7 @@ NTSTATUS rpccli_lsa_LookupNames4(struct rpc_pipe_client *cli, } /* Return variables */ - if (domains && r.out.domains) { - *domains = *r.out.domains; - } + *domains = *r.out.domains; *sids = *r.out.sids; *count = *r.out.count; diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index e4bf43a1e8..8513a9d035 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -72,7 +72,7 @@ NTSTATUS rpccli_lsa_LookupNames(struct rpc_pipe_client *cli, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransSidArray *sids, enum lsa_LookupNamesLevel level, uint32_t *count); @@ -80,7 +80,7 @@ NTSTATUS rpccli_lsa_LookupSids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_SidArray *sids, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransNameArray *names, uint16_t level, uint32_t *count); @@ -276,7 +276,7 @@ NTSTATUS rpccli_lsa_LookupSids2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_SidArray *sids, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransNameArray2 *names, uint16_t level, uint32_t *count, @@ -287,7 +287,7 @@ NTSTATUS rpccli_lsa_LookupNames2(struct rpc_pipe_client *cli, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransSidArray2 *sids, enum lsa_LookupNamesLevel level, uint32_t *count, @@ -343,7 +343,7 @@ NTSTATUS rpccli_lsa_CREDRRENAME(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_LookupSids3(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct lsa_SidArray *sids, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransNameArray2 *names, uint16_t level, uint32_t *count, diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 4a1ebdb7a9..62f8f2c74a 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -774,7 +774,7 @@ struct lsa_LookupNames { } in; struct { - struct lsa_RefDomainList *domains;/* [unique] */ + struct lsa_RefDomainList **domains;/* [ref] */ struct lsa_TransSidArray *sids;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; @@ -793,7 +793,7 @@ struct lsa_LookupSids { } in; struct { - struct lsa_RefDomainList *domains;/* [unique] */ + struct lsa_RefDomainList **domains;/* [ref] */ struct lsa_TransNameArray *names;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; @@ -1356,7 +1356,7 @@ struct lsa_LookupSids2 { } in; struct { - struct lsa_RefDomainList *domains;/* [unique] */ + struct lsa_RefDomainList **domains;/* [ref] */ struct lsa_TransNameArray2 *names;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; @@ -1378,7 +1378,7 @@ struct lsa_LookupNames2 { } in; struct { - struct lsa_RefDomainList *domains;/* [unique] */ + struct lsa_RefDomainList **domains;/* [ref] */ struct lsa_TransSidArray2 *sids;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; @@ -1472,7 +1472,7 @@ struct lsa_LookupNames3 { } in; struct { - struct lsa_RefDomainList *domains;/* [unique] */ + struct lsa_RefDomainList *domains;/* [ref] */ struct lsa_TransSidArray3 *sids;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; @@ -1555,7 +1555,7 @@ struct lsa_LookupSids3 { } in; struct { - struct lsa_RefDomainList *domains;/* [unique] */ + struct lsa_RefDomainList **domains;/* [ref] */ struct lsa_TransNameArray2 *names;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; @@ -1576,7 +1576,7 @@ struct lsa_LookupNames4 { } in; struct { - struct lsa_RefDomainList *domains;/* [unique] */ + struct lsa_RefDomainList *domains;/* [ref] */ struct lsa_TransSidArray3 *sids;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index 74d8a314e1..d5cbc0ec21 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -5704,9 +5704,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames(struct ndr_push *ndr, int fl NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.count)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.domains)); - if (r->out.domains) { - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + if (r->out.domains == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.domains)); + if (*r->out.domains) { + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); } if (r->out.sids == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -5728,6 +5731,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames(struct ndr_pull *ndr, int fl TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_domains_0; + TALLOC_CTX *_mem_save_domains_1; TALLOC_CTX *_mem_save_sids_0; TALLOC_CTX *_mem_save_count_0; if (flags & NDR_IN) { @@ -5770,6 +5774,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames(struct ndr_pull *ndr, int fl NDR_PULL_SET_MEM_CTX(ndr, r->in.count, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.count)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.domains); + ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.sids); *r->out.sids = *r->in.sids; NDR_PULL_ALLOC(ndr, r->out.count); @@ -5779,18 +5785,24 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames(struct ndr_pull *ndr, int fl } } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.domains); + } + _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); if (_ptr_domains) { - NDR_PULL_ALLOC(ndr, r->out.domains); + NDR_PULL_ALLOC(ndr, *r->out.domains); } else { - r->out.domains = NULL; + *r->out.domains = NULL; } - if (r->out.domains) { - _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, 0); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, 0); + if (*r->out.domains) { + _mem_save_domains_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.domains, 0); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_1, 0); } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.sids); } @@ -5853,10 +5865,13 @@ _PUBLIC_ void ndr_print_lsa_LookupNames(struct ndr_print *ndr, const char *name, ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - if (r->out.domains) { - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); + ndr_print_ptr(ndr, "domains", *r->out.domains); + ndr->depth++; + if (*r->out.domains) { + ndr_print_lsa_RefDomainList(ndr, "domains", *r->out.domains); } ndr->depth--; + ndr->depth--; ndr_print_ptr(ndr, "sids", r->out.sids); ndr->depth++; ndr_print_lsa_TransSidArray(ndr, "sids", r->out.sids); @@ -5893,9 +5908,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupSids(struct ndr_push *ndr, int fla NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.count)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.domains)); - if (r->out.domains) { - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + if (r->out.domains == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.domains)); + if (*r->out.domains) { + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); } if (r->out.names == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -5916,6 +5934,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids(struct ndr_pull *ndr, int fla TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_sids_0; TALLOC_CTX *_mem_save_domains_0; + TALLOC_CTX *_mem_save_domains_1; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_count_0; if (flags & NDR_IN) { @@ -5950,24 +5969,32 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids(struct ndr_pull *ndr, int fla NDR_PULL_SET_MEM_CTX(ndr, r->in.count, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.count)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.domains); + ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.names); *r->out.names = *r->in.names; NDR_PULL_ALLOC(ndr, r->out.count); *r->out.count = *r->in.count; } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.domains); + } + _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); if (_ptr_domains) { - NDR_PULL_ALLOC(ndr, r->out.domains); + NDR_PULL_ALLOC(ndr, *r->out.domains); } else { - r->out.domains = NULL; + *r->out.domains = NULL; } - if (r->out.domains) { - _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, 0); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, 0); + if (*r->out.domains) { + _mem_save_domains_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.domains, 0); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_1, 0); } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.names); } @@ -6021,10 +6048,13 @@ _PUBLIC_ void ndr_print_lsa_LookupSids(struct ndr_print *ndr, const char *name, ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - if (r->out.domains) { - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); + ndr_print_ptr(ndr, "domains", *r->out.domains); + ndr->depth++; + if (*r->out.domains) { + ndr_print_lsa_RefDomainList(ndr, "domains", *r->out.domains); } ndr->depth--; + ndr->depth--; ndr_print_ptr(ndr, "names", r->out.names); ndr->depth++; ndr_print_lsa_TransNameArray(ndr, "names", r->out.names); @@ -9704,9 +9734,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupSids2(struct ndr_push *ndr, int fl NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.domains)); - if (r->out.domains) { - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + if (r->out.domains == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.domains)); + if (*r->out.domains) { + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); } if (r->out.names == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -9727,6 +9760,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids2(struct ndr_pull *ndr, int fl TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_sids_0; TALLOC_CTX *_mem_save_domains_0; + TALLOC_CTX *_mem_save_domains_1; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_count_0; if (flags & NDR_IN) { @@ -9763,24 +9797,32 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids2(struct ndr_pull *ndr, int fl NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_PULL_ALLOC(ndr, r->out.domains); + ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.names); *r->out.names = *r->in.names; NDR_PULL_ALLOC(ndr, r->out.count); *r->out.count = *r->in.count; } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.domains); + } + _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); if (_ptr_domains) { - NDR_PULL_ALLOC(ndr, r->out.domains); + NDR_PULL_ALLOC(ndr, *r->out.domains); } else { - r->out.domains = NULL; + *r->out.domains = NULL; } - if (r->out.domains) { - _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, 0); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, 0); + if (*r->out.domains) { + _mem_save_domains_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.domains, 0); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_1, 0); } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.names); } @@ -9836,10 +9878,13 @@ _PUBLIC_ void ndr_print_lsa_LookupSids2(struct ndr_print *ndr, const char *name, ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - if (r->out.domains) { - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); + ndr_print_ptr(ndr, "domains", *r->out.domains); + ndr->depth++; + if (*r->out.domains) { + ndr_print_lsa_RefDomainList(ndr, "domains", *r->out.domains); } ndr->depth--; + ndr->depth--; ndr_print_ptr(ndr, "names", r->out.names); ndr->depth++; ndr_print_lsa_TransNameArray2(ndr, "names", r->out.names); @@ -9883,9 +9928,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames2(struct ndr_push *ndr, int f NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.domains)); - if (r->out.domains) { - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + if (r->out.domains == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.domains)); + if (*r->out.domains) { + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); } if (r->out.sids == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -9907,6 +9955,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames2(struct ndr_pull *ndr, int f TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_domains_0; + TALLOC_CTX *_mem_save_domains_1; TALLOC_CTX *_mem_save_sids_0; TALLOC_CTX *_mem_save_count_0; if (flags & NDR_IN) { @@ -9951,6 +10000,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames2(struct ndr_pull *ndr, int f NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_PULL_ALLOC(ndr, r->out.domains); + ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.sids); *r->out.sids = *r->in.sids; NDR_PULL_ALLOC(ndr, r->out.count); @@ -9960,18 +10011,24 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames2(struct ndr_pull *ndr, int f } } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.domains); + } + _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); if (_ptr_domains) { - NDR_PULL_ALLOC(ndr, r->out.domains); + NDR_PULL_ALLOC(ndr, *r->out.domains); } else { - r->out.domains = NULL; + *r->out.domains = NULL; } - if (r->out.domains) { - _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, 0); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, 0); + if (*r->out.domains) { + _mem_save_domains_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.domains, 0); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_1, 0); } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.sids); } @@ -10036,10 +10093,13 @@ _PUBLIC_ void ndr_print_lsa_LookupNames2(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - if (r->out.domains) { - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); + ndr_print_ptr(ndr, "domains", *r->out.domains); + ndr->depth++; + if (*r->out.domains) { + ndr_print_lsa_RefDomainList(ndr, "domains", *r->out.domains); } ndr->depth--; + ndr->depth--; ndr_print_ptr(ndr, "sids", r->out.sids); ndr->depth++; ndr_print_lsa_TransSidArray2(ndr, "sids", r->out.sids); @@ -10452,10 +10512,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames3(struct ndr_push *ndr, int f NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.domains)); - if (r->out.domains) { - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + if (r->out.domains == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); if (r->out.sids == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -10472,7 +10532,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames3(struct ndr_push *ndr, int f _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames3(struct ndr_pull *ndr, int flags, struct lsa_LookupNames3 *r) { uint32_t cntr_names_0; - uint32_t _ptr_domains; TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_domains_0; @@ -10520,6 +10579,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames3(struct ndr_pull *ndr, int f NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_PULL_ALLOC(ndr, r->out.domains); + ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.sids); *r->out.sids = *r->in.sids; NDR_PULL_ALLOC(ndr, r->out.count); @@ -10529,18 +10590,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames3(struct ndr_pull *ndr, int f } } if (flags & NDR_OUT) { - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); - if (_ptr_domains) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.domains); - } else { - r->out.domains = NULL; - } - if (r->out.domains) { - _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, 0); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, 0); } + _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.sids); } @@ -10605,9 +10661,7 @@ _PUBLIC_ void ndr_print_lsa_LookupNames3(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - if (r->out.domains) { - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); - } + ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); ndr->depth--; ndr_print_ptr(ndr, "sids", r->out.sids); ndr->depth++; @@ -11006,9 +11060,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupSids3(struct ndr_push *ndr, int fl NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.domains)); - if (r->out.domains) { - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + if (r->out.domains == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.domains)); + if (*r->out.domains) { + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); } if (r->out.names == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -11028,6 +11085,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids3(struct ndr_pull *ndr, int fl uint32_t _ptr_domains; TALLOC_CTX *_mem_save_sids_0; TALLOC_CTX *_mem_save_domains_0; + TALLOC_CTX *_mem_save_domains_1; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_count_0; if (flags & NDR_IN) { @@ -11057,24 +11115,32 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids3(struct ndr_pull *ndr, int fl NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_PULL_ALLOC(ndr, r->out.domains); + ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.names); *r->out.names = *r->in.names; NDR_PULL_ALLOC(ndr, r->out.count); *r->out.count = *r->in.count; } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.domains); + } + _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); if (_ptr_domains) { - NDR_PULL_ALLOC(ndr, r->out.domains); + NDR_PULL_ALLOC(ndr, *r->out.domains); } else { - r->out.domains = NULL; + *r->out.domains = NULL; } - if (r->out.domains) { - _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, 0); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, 0); + if (*r->out.domains) { + _mem_save_domains_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.domains, 0); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_1, 0); } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.names); } @@ -11126,10 +11192,13 @@ _PUBLIC_ void ndr_print_lsa_LookupSids3(struct ndr_print *ndr, const char *name, ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - if (r->out.domains) { - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); + ndr_print_ptr(ndr, "domains", *r->out.domains); + ndr->depth++; + if (*r->out.domains) { + ndr_print_lsa_RefDomainList(ndr, "domains", *r->out.domains); } ndr->depth--; + ndr->depth--; ndr_print_ptr(ndr, "names", r->out.names); ndr->depth++; ndr_print_lsa_TransNameArray2(ndr, "names", r->out.names); @@ -11169,10 +11238,10 @@ static enum ndr_err_code ndr_push_lsa_LookupNames4(struct ndr_push *ndr, int fla NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.domains)); - if (r->out.domains) { - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + if (r->out.domains == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); if (r->out.sids == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -11189,7 +11258,6 @@ static enum ndr_err_code ndr_push_lsa_LookupNames4(struct ndr_push *ndr, int fla static enum ndr_err_code ndr_pull_lsa_LookupNames4(struct ndr_pull *ndr, int flags, struct lsa_LookupNames4 *r) { uint32_t cntr_names_0; - uint32_t _ptr_domains; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_domains_0; TALLOC_CTX *_mem_save_sids_0; @@ -11229,6 +11297,8 @@ static enum ndr_err_code ndr_pull_lsa_LookupNames4(struct ndr_pull *ndr, int fla NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_PULL_ALLOC(ndr, r->out.domains); + ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.sids); *r->out.sids = *r->in.sids; NDR_PULL_ALLOC(ndr, r->out.count); @@ -11238,18 +11308,13 @@ static enum ndr_err_code ndr_pull_lsa_LookupNames4(struct ndr_pull *ndr, int fla } } if (flags & NDR_OUT) { - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); - if (_ptr_domains) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.domains); - } else { - r->out.domains = NULL; - } - if (r->out.domains) { - _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, 0); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, 0); } + _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.sids); } @@ -11310,9 +11375,7 @@ _PUBLIC_ void ndr_print_lsa_LookupNames4(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - if (r->out.domains) { - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); - } + ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); ndr->depth--; ndr_print_ptr(ndr, "sids", r->out.sids); ndr->depth++; diff --git a/source3/librpc/gen_ndr/srv_lsa.c b/source3/librpc/gen_ndr/srv_lsa.c index 183cd355c0..b21a825682 100644 --- a/source3/librpc/gen_ndr/srv_lsa.c +++ b/source3/librpc/gen_ndr/srv_lsa.c @@ -1128,7 +1128,7 @@ static bool api_lsa_LookupNames(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.domains = talloc_zero(r, struct lsa_RefDomainList); + r->out.domains = talloc_zero(r, struct lsa_RefDomainList *); if (r->out.domains == NULL) { talloc_free(r); return false; @@ -1210,7 +1210,7 @@ static bool api_lsa_LookupSids(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.domains = talloc_zero(r, struct lsa_RefDomainList); + r->out.domains = talloc_zero(r, struct lsa_RefDomainList *); if (r->out.domains == NULL) { talloc_free(r); return false; @@ -4437,7 +4437,7 @@ static bool api_lsa_LookupSids2(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.domains = talloc_zero(r, struct lsa_RefDomainList); + r->out.domains = talloc_zero(r, struct lsa_RefDomainList *); if (r->out.domains == NULL) { talloc_free(r); return false; @@ -4519,7 +4519,7 @@ static bool api_lsa_LookupNames2(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.domains = talloc_zero(r, struct lsa_RefDomainList); + r->out.domains = talloc_zero(r, struct lsa_RefDomainList *); if (r->out.domains == NULL) { talloc_free(r); return false; @@ -5858,7 +5858,7 @@ static bool api_lsa_LookupSids3(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.domains = talloc_zero(r, struct lsa_RefDomainList); + r->out.domains = talloc_zero(r, struct lsa_RefDomainList *); if (r->out.domains == NULL) { talloc_free(r); return false; -- cgit From 082392d975808747ce1f485e6abf3a796e7ae233 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 20:25:05 +0100 Subject: Use pidl for NTSVCS. Guenther (This used to be commit 84a9bf0b7372bd7b7d4a1490c45e68b69889af8a) --- source3/Makefile.in | 6 +- source3/include/rpc_client.h | 1 + source3/include/smb.h | 1 + source3/librpc/gen_ndr/cli_ntsvcs.c | 2413 +++++++++++++++++ source3/librpc/gen_ndr/cli_ntsvcs.h | 134 + source3/librpc/gen_ndr/ndr_ntsvcs.c | 3031 ++++++++++++++++++++++ source3/librpc/gen_ndr/ndr_ntsvcs.h | 210 ++ source3/librpc/gen_ndr/ntsvcs.h | 333 +++ source3/librpc/gen_ndr/srv_ntsvcs.c | 4834 +++++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/srv_ntsvcs.h | 71 + 10 files changed, 11032 insertions(+), 2 deletions(-) create mode 100644 source3/librpc/gen_ndr/cli_ntsvcs.c create mode 100644 source3/librpc/gen_ndr/cli_ntsvcs.h create mode 100644 source3/librpc/gen_ndr/ndr_ntsvcs.c create mode 100644 source3/librpc/gen_ndr/ndr_ntsvcs.h create mode 100644 source3/librpc/gen_ndr/ntsvcs.h create mode 100644 source3/librpc/gen_ndr/srv_ntsvcs.c create mode 100644 source3/librpc/gen_ndr/srv_ntsvcs.h (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index a28972f22d..250d3f98c5 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -288,7 +288,8 @@ LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_wkssvc.o \ librpc/gen_ndr/ndr_samr.o \ librpc/gen_ndr/ndr_dssetup.o \ librpc/gen_ndr/ndr_notify.o \ - librpc/gen_ndr/ndr_xattr.o + librpc/gen_ndr/ndr_xattr.o \ + librpc/gen_ndr/ndr_ntsvcs.o RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o @@ -429,6 +430,7 @@ LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \ librpc/gen_ndr/cli_netlogon.o \ librpc/gen_ndr/cli_samr.o \ librpc/gen_ndr/cli_dssetup.o \ + librpc/gen_ndr/cli_ntsvcs.o \ $(LIBNDR_GEN_OBJ) \ $(RPCCLIENT_NDR_OBJ) @@ -1124,7 +1126,7 @@ modules: SHOWFLAGS $(MODULES) IDL_FILES = unixinfo.idl lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \ epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \ - dssetup.idl krb5pac.idl + dssetup.idl krb5pac.idl ntsvcs.idl idl: @IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \ diff --git a/source3/include/rpc_client.h b/source3/include/rpc_client.h index c560fd0909..e1ebb2509d 100644 --- a/source3/include/rpc_client.h +++ b/source3/include/rpc_client.h @@ -34,6 +34,7 @@ #include "librpc/gen_ndr/cli_samr.h" #include "librpc/gen_ndr/cli_netlogon.h" #include "librpc/gen_ndr/cli_dssetup.h" +#include "librpc/gen_ndr/cli_ntsvcs.h" /* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */ diff --git a/source3/include/smb.h b/source3/include/smb.h index 5e524eed01..c582a97e5c 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -309,6 +309,7 @@ extern const DATA_BLOB data_blob_null; #include "librpc/gen_ndr/dssetup.h" #include "librpc/gen_ndr/libnet_join.h" #include "librpc/gen_ndr/krb5pac.h" +#include "librpc/gen_ndr/ntsvcs.h" struct lsa_dom_info { bool valid; diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.c b/source3/librpc/gen_ndr/cli_ntsvcs.c new file mode 100644 index 0000000000..7795962c3f --- /dev/null +++ b/source3/librpc/gen_ndr/cli_ntsvcs.c @@ -0,0 +1,2413 @@ +/* + * Unix SMB/CIFS implementation. + * client auto-generated by pidl. DO NOT MODIFY! + */ + +#include "includes.h" +#include "librpc/gen_ndr/cli_ntsvcs.h" + +NTSTATUS rpccli_PNP_Disconnect(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_Disconnect r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_Disconnect, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_DISCONNECT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_Disconnect, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_Connect(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_Connect r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_Connect, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_CONNECT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_Connect, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetVersion(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetVersion r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetVersion, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETVERSION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetVersion, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetGlobalState(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetGlobalState r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetGlobalState, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETGLOBALSTATE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetGlobalState, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_InitDetection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_InitDetection r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_InitDetection, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_INITDETECTION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_InitDetection, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_ReportLogOn(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_ReportLogOn r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_ReportLogOn, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_REPORTLOGON, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_ReportLogOn, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_ValidateDeviceInstance(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_ValidateDeviceInstance r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_ValidateDeviceInstance, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_VALIDATEDEVICEINSTANCE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_ValidateDeviceInstance, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetRootDeviceInstance(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetRootDeviceInstance r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetRootDeviceInstance, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETROOTDEVICEINSTANCE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetRootDeviceInstance, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetRelatedDeviceInstance(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetRelatedDeviceInstance r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetRelatedDeviceInstance, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETRELATEDDEVICEINSTANCE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetRelatedDeviceInstance, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_EnumerateSubKeys(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_EnumerateSubKeys r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_EnumerateSubKeys, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_ENUMERATESUBKEYS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_EnumerateSubKeys, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetDeviceList r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDeviceList, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETDEVICELIST, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDeviceList, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetDeviceListSize r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDeviceListSize, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETDEVICELISTSIZE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDeviceListSize, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetDepth(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetDepth r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDepth, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETDEPTH, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDepth, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetDeviceRegProp r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDeviceRegProp, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETDEVICEREGPROP, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDeviceRegProp, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_SetDeviceRegProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_SetDeviceRegProp r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_SetDeviceRegProp, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_SETDEVICEREGPROP, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_SetDeviceRegProp, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetClassInstance(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetClassInstance r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetClassInstance, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETCLASSINSTANCE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetClassInstance, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_CreateKey(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_CreateKey r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_CreateKey, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_CREATEKEY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_CreateKey, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_DeleteRegistryKey(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_DeleteRegistryKey r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DeleteRegistryKey, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_DELETEREGISTRYKEY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DeleteRegistryKey, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetClassCount(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetClassCount r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetClassCount, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETCLASSCOUNT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetClassCount, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetClassName(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetClassName r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetClassName, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETCLASSNAME, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetClassName, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_DeleteClassKey(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_DeleteClassKey r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DeleteClassKey, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_DELETECLASSKEY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DeleteClassKey, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetInterfaceDeviceAlias(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetInterfaceDeviceAlias r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceAlias, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETINTERFACEDEVICEALIAS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceAlias, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetInterfaceDeviceList(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetInterfaceDeviceList r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceList, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETINTERFACEDEVICELIST, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceList, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetInterfaceDeviceListSize(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetInterfaceDeviceListSize r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceListSize, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETINTERFACEDEVICELISTSIZE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceListSize, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_RegisterDeviceClassAssociation(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_RegisterDeviceClassAssociation r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RegisterDeviceClassAssociation, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_REGISTERDEVICECLASSASSOCIATION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RegisterDeviceClassAssociation, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_UnregisterDeviceClassAssociation(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_UnregisterDeviceClassAssociation r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_UnregisterDeviceClassAssociation, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_UNREGISTERDEVICECLASSASSOCIATION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_UnregisterDeviceClassAssociation, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetClassRegProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetClassRegProp r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetClassRegProp, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETCLASSREGPROP, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetClassRegProp, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_SetClassRegProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_SetClassRegProp r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_SetClassRegProp, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_SETCLASSREGPROP, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_SetClassRegProp, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_CreateDevInst(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_CreateDevInst r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_CreateDevInst, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_CREATEDEVINST, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_CreateDevInst, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_DeviceInstanceAction(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_DeviceInstanceAction r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DeviceInstanceAction, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_DEVICEINSTANCEACTION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DeviceInstanceAction, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetDeviceStatus(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetDeviceStatus r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDeviceStatus, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETDEVICESTATUS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDeviceStatus, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_SetDeviceProblem(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_SetDeviceProblem r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_SetDeviceProblem, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_SETDEVICEPROBLEM, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_SetDeviceProblem, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_DisableDevInst(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_DisableDevInst r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DisableDevInst, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_DISABLEDEVINST, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DisableDevInst, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_UninstallDevInst(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_UninstallDevInst r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_UninstallDevInst, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_UNINSTALLDEVINST, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_UninstallDevInst, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_AddID(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_AddID r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_AddID, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_ADDID, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_AddID, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_RegisterDriver(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_RegisterDriver r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RegisterDriver, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_REGISTERDRIVER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RegisterDriver, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_QueryRemove(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_QueryRemove r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_QueryRemove, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_QUERYREMOVE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_QueryRemove, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_RequestDeviceEject(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_RequestDeviceEject r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RequestDeviceEject, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_REQUESTDEVICEEJECT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RequestDeviceEject, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_IsDockStationPresent(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_IsDockStationPresent r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_IsDockStationPresent, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_ISDOCKSTATIONPRESENT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_IsDockStationPresent, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_RequestEjectPC(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_RequestEjectPC r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RequestEjectPC, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_REQUESTEJECTPC, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RequestEjectPC, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_HwProfFlags r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_HwProfFlags, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_HWPROFFLAGS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_HwProfFlags, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetHwProfInfo r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetHwProfInfo, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETHWPROFINFO, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetHwProfInfo, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_AddEmptyLogConf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_AddEmptyLogConf r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_AddEmptyLogConf, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_ADDEMPTYLOGCONF, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_AddEmptyLogConf, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_FreeLogConf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_FreeLogConf r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_FreeLogConf, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_FREELOGCONF, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_FreeLogConf, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetFirstLogConf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetFirstLogConf r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetFirstLogConf, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETFIRSTLOGCONF, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetFirstLogConf, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetNextLogConf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetNextLogConf r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetNextLogConf, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETNEXTLOGCONF, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetNextLogConf, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetLogConfPriority(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetLogConfPriority r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetLogConfPriority, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETLOGCONFPRIORITY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetLogConfPriority, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_AddResDes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_AddResDes r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_AddResDes, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_ADDRESDES, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_AddResDes, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_FreeResDes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_FreeResDes r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_FreeResDes, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_FREERESDES, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_FreeResDes, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetNextResDes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetNextResDes r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetNextResDes, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETNEXTRESDES, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetNextResDes, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetResDesData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetResDesData r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetResDesData, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETRESDESDATA, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetResDesData, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetResDesDataSize(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetResDesDataSize r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetResDesDataSize, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETRESDESDATASIZE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetResDesDataSize, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_ModifyResDes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_ModifyResDes r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_ModifyResDes, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_MODIFYRESDES, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_ModifyResDes, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_DetectResourceLimit(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_DetectResourceLimit r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DetectResourceLimit, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_DETECTRESOURCELIMIT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DetectResourceLimit, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_QueryResConfList(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_QueryResConfList r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_QueryResConfList, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_QUERYRESCONFLIST, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_QueryResConfList, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_SetHwProf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_SetHwProf r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_SetHwProf, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_SETHWPROF, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_SetHwProf, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_QueryArbitratorFreeData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_QueryArbitratorFreeData r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_QueryArbitratorFreeData, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_QUERYARBITRATORFREEDATA, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_QueryArbitratorFreeData, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_QueryArbitratorFreeSize(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_QueryArbitratorFreeSize r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_QueryArbitratorFreeSize, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_QUERYARBITRATORFREESIZE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_QueryArbitratorFreeSize, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_RunDetection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_RunDetection r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RunDetection, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_RUNDETECTION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RunDetection, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_RegisterNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_RegisterNotification r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RegisterNotification, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_REGISTERNOTIFICATION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RegisterNotification, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_UnregisterNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_UnregisterNotification r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_UnregisterNotification, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_UNREGISTERNOTIFICATION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_UnregisterNotification, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetCustomDevProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetCustomDevProp r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetCustomDevProp, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETCUSTOMDEVPROP, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetCustomDevProp, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetVersionInternal(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetVersionInternal r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetVersionInternal, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETVERSIONINTERNAL, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetVersionInternal, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetBlockedDriverInfo(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetBlockedDriverInfo r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetBlockedDriverInfo, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETBLOCKEDDRIVERINFO, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetBlockedDriverInfo, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + +NTSTATUS rpccli_PNP_GetServerSideDeviceInstallFlags(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) +{ + struct PNP_GetServerSideDeviceInstallFlags r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetServerSideDeviceInstallFlags, &r); + } + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_NTSVCS, + &ndr_table_ntsvcs, + NDR_PNP_GETSERVERSIDEDEVICEINSTALLFLAGS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetServerSideDeviceInstallFlags, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return NT_STATUS_OK; +} + diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.h b/source3/librpc/gen_ndr/cli_ntsvcs.h new file mode 100644 index 0000000000..ab2aead1ea --- /dev/null +++ b/source3/librpc/gen_ndr/cli_ntsvcs.h @@ -0,0 +1,134 @@ +#include "librpc/gen_ndr/ndr_ntsvcs.h" +#ifndef __CLI_NTSVCS__ +#define __CLI_NTSVCS__ +NTSTATUS rpccli_PNP_Disconnect(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_Connect(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetVersion(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetGlobalState(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_InitDetection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_ReportLogOn(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_ValidateDeviceInstance(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetRootDeviceInstance(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetRelatedDeviceInstance(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_EnumerateSubKeys(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetDepth(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_SetDeviceRegProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetClassInstance(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_CreateKey(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_DeleteRegistryKey(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetClassCount(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetClassName(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_DeleteClassKey(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetInterfaceDeviceAlias(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetInterfaceDeviceList(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetInterfaceDeviceListSize(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_RegisterDeviceClassAssociation(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_UnregisterDeviceClassAssociation(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetClassRegProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_SetClassRegProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_CreateDevInst(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_DeviceInstanceAction(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetDeviceStatus(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_SetDeviceProblem(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_DisableDevInst(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_UninstallDevInst(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_AddID(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_RegisterDriver(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_QueryRemove(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_RequestDeviceEject(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_IsDockStationPresent(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_RequestEjectPC(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_AddEmptyLogConf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_FreeLogConf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetFirstLogConf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetNextLogConf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetLogConfPriority(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_AddResDes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_FreeResDes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetNextResDes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetResDesData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetResDesDataSize(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_ModifyResDes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_DetectResourceLimit(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_QueryResConfList(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_SetHwProf(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_QueryArbitratorFreeData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_QueryArbitratorFreeSize(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_RunDetection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_RegisterNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_UnregisterNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetCustomDevProp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetVersionInternal(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetBlockedDriverInfo(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +NTSTATUS rpccli_PNP_GetServerSideDeviceInstallFlags(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx); +#endif /* __CLI_NTSVCS__ */ diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.c b/source3/librpc/gen_ndr/ndr_ntsvcs.c new file mode 100644 index 0000000000..8e6176c56c --- /dev/null +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c @@ -0,0 +1,3031 @@ +/* parser auto-generated by pidl */ + +#include "includes.h" +#include "librpc/gen_ndr/ndr_ntsvcs.h" + +static enum ndr_err_code ndr_push_PNP_Disconnect(struct ndr_push *ndr, int flags, const struct PNP_Disconnect *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_Disconnect(struct ndr_pull *ndr, int flags, struct PNP_Disconnect *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_Disconnect(struct ndr_print *ndr, const char *name, int flags, const struct PNP_Disconnect *r) +{ + ndr_print_struct(ndr, name, "PNP_Disconnect"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_Disconnect"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_Disconnect"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_Connect(struct ndr_push *ndr, int flags, const struct PNP_Connect *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_Connect(struct ndr_pull *ndr, int flags, struct PNP_Connect *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_Connect(struct ndr_print *ndr, const char *name, int flags, const struct PNP_Connect *r) +{ + ndr_print_struct(ndr, name, "PNP_Connect"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_Connect"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_Connect"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetVersion(struct ndr_push *ndr, int flags, const struct PNP_GetVersion *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetVersion(struct ndr_pull *ndr, int flags, struct PNP_GetVersion *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetVersion(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetVersion *r) +{ + ndr_print_struct(ndr, name, "PNP_GetVersion"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetVersion"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetVersion"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetGlobalState(struct ndr_push *ndr, int flags, const struct PNP_GetGlobalState *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetGlobalState(struct ndr_pull *ndr, int flags, struct PNP_GetGlobalState *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetGlobalState(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetGlobalState *r) +{ + ndr_print_struct(ndr, name, "PNP_GetGlobalState"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetGlobalState"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetGlobalState"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_InitDetection(struct ndr_push *ndr, int flags, const struct PNP_InitDetection *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_InitDetection(struct ndr_pull *ndr, int flags, struct PNP_InitDetection *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_InitDetection(struct ndr_print *ndr, const char *name, int flags, const struct PNP_InitDetection *r) +{ + ndr_print_struct(ndr, name, "PNP_InitDetection"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_InitDetection"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_InitDetection"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_ReportLogOn(struct ndr_push *ndr, int flags, const struct PNP_ReportLogOn *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_ReportLogOn(struct ndr_pull *ndr, int flags, struct PNP_ReportLogOn *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_ReportLogOn(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ReportLogOn *r) +{ + ndr_print_struct(ndr, name, "PNP_ReportLogOn"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_ReportLogOn"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_ReportLogOn"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_ValidateDeviceInstance(struct ndr_push *ndr, int flags, const struct PNP_ValidateDeviceInstance *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_ValidateDeviceInstance(struct ndr_pull *ndr, int flags, struct PNP_ValidateDeviceInstance *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_ValidateDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ValidateDeviceInstance *r) +{ + ndr_print_struct(ndr, name, "PNP_ValidateDeviceInstance"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_ValidateDeviceInstance"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_ValidateDeviceInstance"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetRootDeviceInstance(struct ndr_push *ndr, int flags, const struct PNP_GetRootDeviceInstance *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetRootDeviceInstance(struct ndr_pull *ndr, int flags, struct PNP_GetRootDeviceInstance *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetRootDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetRootDeviceInstance *r) +{ + ndr_print_struct(ndr, name, "PNP_GetRootDeviceInstance"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetRootDeviceInstance"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetRootDeviceInstance"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetRelatedDeviceInstance(struct ndr_push *ndr, int flags, const struct PNP_GetRelatedDeviceInstance *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetRelatedDeviceInstance(struct ndr_pull *ndr, int flags, struct PNP_GetRelatedDeviceInstance *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetRelatedDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetRelatedDeviceInstance *r) +{ + ndr_print_struct(ndr, name, "PNP_GetRelatedDeviceInstance"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetRelatedDeviceInstance"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetRelatedDeviceInstance"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_EnumerateSubKeys(struct ndr_push *ndr, int flags, const struct PNP_EnumerateSubKeys *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_EnumerateSubKeys(struct ndr_pull *ndr, int flags, struct PNP_EnumerateSubKeys *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_EnumerateSubKeys(struct ndr_print *ndr, const char *name, int flags, const struct PNP_EnumerateSubKeys *r) +{ + ndr_print_struct(ndr, name, "PNP_EnumerateSubKeys"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_EnumerateSubKeys"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_EnumerateSubKeys"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetDeviceList(struct ndr_push *ndr, int flags, const struct PNP_GetDeviceList *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetDeviceList(struct ndr_pull *ndr, int flags, struct PNP_GetDeviceList *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetDeviceList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceList *r) +{ + ndr_print_struct(ndr, name, "PNP_GetDeviceList"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetDeviceList"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetDeviceList"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetDeviceListSize(struct ndr_push *ndr, int flags, const struct PNP_GetDeviceListSize *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetDeviceListSize(struct ndr_pull *ndr, int flags, struct PNP_GetDeviceListSize *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetDeviceListSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceListSize *r) +{ + ndr_print_struct(ndr, name, "PNP_GetDeviceListSize"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetDeviceListSize"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetDeviceListSize"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetDepth(struct ndr_push *ndr, int flags, const struct PNP_GetDepth *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetDepth(struct ndr_pull *ndr, int flags, struct PNP_GetDepth *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetDepth(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDepth *r) +{ + ndr_print_struct(ndr, name, "PNP_GetDepth"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetDepth"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetDepth"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetDeviceRegProp(struct ndr_push *ndr, int flags, const struct PNP_GetDeviceRegProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetDeviceRegProp(struct ndr_pull *ndr, int flags, struct PNP_GetDeviceRegProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetDeviceRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceRegProp *r) +{ + ndr_print_struct(ndr, name, "PNP_GetDeviceRegProp"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetDeviceRegProp"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetDeviceRegProp"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_SetDeviceRegProp(struct ndr_push *ndr, int flags, const struct PNP_SetDeviceRegProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_SetDeviceRegProp(struct ndr_pull *ndr, int flags, struct PNP_SetDeviceRegProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_SetDeviceRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetDeviceRegProp *r) +{ + ndr_print_struct(ndr, name, "PNP_SetDeviceRegProp"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_SetDeviceRegProp"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_SetDeviceRegProp"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetClassInstance(struct ndr_push *ndr, int flags, const struct PNP_GetClassInstance *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetClassInstance(struct ndr_pull *ndr, int flags, struct PNP_GetClassInstance *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetClassInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassInstance *r) +{ + ndr_print_struct(ndr, name, "PNP_GetClassInstance"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetClassInstance"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetClassInstance"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_CreateKey(struct ndr_push *ndr, int flags, const struct PNP_CreateKey *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_CreateKey(struct ndr_pull *ndr, int flags, struct PNP_CreateKey *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_CreateKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_CreateKey *r) +{ + ndr_print_struct(ndr, name, "PNP_CreateKey"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_CreateKey"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_CreateKey"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_DeleteRegistryKey(struct ndr_push *ndr, int flags, const struct PNP_DeleteRegistryKey *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_DeleteRegistryKey(struct ndr_pull *ndr, int flags, struct PNP_DeleteRegistryKey *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_DeleteRegistryKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeleteRegistryKey *r) +{ + ndr_print_struct(ndr, name, "PNP_DeleteRegistryKey"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_DeleteRegistryKey"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_DeleteRegistryKey"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetClassCount(struct ndr_push *ndr, int flags, const struct PNP_GetClassCount *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetClassCount(struct ndr_pull *ndr, int flags, struct PNP_GetClassCount *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetClassCount(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassCount *r) +{ + ndr_print_struct(ndr, name, "PNP_GetClassCount"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetClassCount"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetClassCount"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetClassName(struct ndr_push *ndr, int flags, const struct PNP_GetClassName *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetClassName(struct ndr_pull *ndr, int flags, struct PNP_GetClassName *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetClassName(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassName *r) +{ + ndr_print_struct(ndr, name, "PNP_GetClassName"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetClassName"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetClassName"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_DeleteClassKey(struct ndr_push *ndr, int flags, const struct PNP_DeleteClassKey *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_DeleteClassKey(struct ndr_pull *ndr, int flags, struct PNP_DeleteClassKey *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_DeleteClassKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeleteClassKey *r) +{ + ndr_print_struct(ndr, name, "PNP_DeleteClassKey"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_DeleteClassKey"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_DeleteClassKey"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetInterfaceDeviceAlias(struct ndr_push *ndr, int flags, const struct PNP_GetInterfaceDeviceAlias *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetInterfaceDeviceAlias(struct ndr_pull *ndr, int flags, struct PNP_GetInterfaceDeviceAlias *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceAlias(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceAlias *r) +{ + ndr_print_struct(ndr, name, "PNP_GetInterfaceDeviceAlias"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetInterfaceDeviceAlias"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetInterfaceDeviceAlias"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetInterfaceDeviceList(struct ndr_push *ndr, int flags, const struct PNP_GetInterfaceDeviceList *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetInterfaceDeviceList(struct ndr_pull *ndr, int flags, struct PNP_GetInterfaceDeviceList *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceList *r) +{ + ndr_print_struct(ndr, name, "PNP_GetInterfaceDeviceList"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetInterfaceDeviceList"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetInterfaceDeviceList"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetInterfaceDeviceListSize(struct ndr_push *ndr, int flags, const struct PNP_GetInterfaceDeviceListSize *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetInterfaceDeviceListSize(struct ndr_pull *ndr, int flags, struct PNP_GetInterfaceDeviceListSize *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceListSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceListSize *r) +{ + ndr_print_struct(ndr, name, "PNP_GetInterfaceDeviceListSize"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetInterfaceDeviceListSize"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetInterfaceDeviceListSize"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_RegisterDeviceClassAssociation(struct ndr_push *ndr, int flags, const struct PNP_RegisterDeviceClassAssociation *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_RegisterDeviceClassAssociation(struct ndr_pull *ndr, int flags, struct PNP_RegisterDeviceClassAssociation *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_RegisterDeviceClassAssociation(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterDeviceClassAssociation *r) +{ + ndr_print_struct(ndr, name, "PNP_RegisterDeviceClassAssociation"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_RegisterDeviceClassAssociation"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_RegisterDeviceClassAssociation"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_UnregisterDeviceClassAssociation(struct ndr_push *ndr, int flags, const struct PNP_UnregisterDeviceClassAssociation *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_UnregisterDeviceClassAssociation(struct ndr_pull *ndr, int flags, struct PNP_UnregisterDeviceClassAssociation *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_UnregisterDeviceClassAssociation(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UnregisterDeviceClassAssociation *r) +{ + ndr_print_struct(ndr, name, "PNP_UnregisterDeviceClassAssociation"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_UnregisterDeviceClassAssociation"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_UnregisterDeviceClassAssociation"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetClassRegProp(struct ndr_push *ndr, int flags, const struct PNP_GetClassRegProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetClassRegProp(struct ndr_pull *ndr, int flags, struct PNP_GetClassRegProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetClassRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassRegProp *r) +{ + ndr_print_struct(ndr, name, "PNP_GetClassRegProp"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetClassRegProp"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetClassRegProp"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_SetClassRegProp(struct ndr_push *ndr, int flags, const struct PNP_SetClassRegProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_SetClassRegProp(struct ndr_pull *ndr, int flags, struct PNP_SetClassRegProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_SetClassRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetClassRegProp *r) +{ + ndr_print_struct(ndr, name, "PNP_SetClassRegProp"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_SetClassRegProp"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_SetClassRegProp"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_CreateDevInst(struct ndr_push *ndr, int flags, const struct PNP_CreateDevInst *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_CreateDevInst(struct ndr_pull *ndr, int flags, struct PNP_CreateDevInst *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_CreateDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_CreateDevInst *r) +{ + ndr_print_struct(ndr, name, "PNP_CreateDevInst"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_CreateDevInst"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_CreateDevInst"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_DeviceInstanceAction(struct ndr_push *ndr, int flags, const struct PNP_DeviceInstanceAction *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_DeviceInstanceAction(struct ndr_pull *ndr, int flags, struct PNP_DeviceInstanceAction *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_DeviceInstanceAction(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeviceInstanceAction *r) +{ + ndr_print_struct(ndr, name, "PNP_DeviceInstanceAction"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_DeviceInstanceAction"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_DeviceInstanceAction"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetDeviceStatus(struct ndr_push *ndr, int flags, const struct PNP_GetDeviceStatus *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetDeviceStatus(struct ndr_pull *ndr, int flags, struct PNP_GetDeviceStatus *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetDeviceStatus(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceStatus *r) +{ + ndr_print_struct(ndr, name, "PNP_GetDeviceStatus"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetDeviceStatus"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetDeviceStatus"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_SetDeviceProblem(struct ndr_push *ndr, int flags, const struct PNP_SetDeviceProblem *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_SetDeviceProblem(struct ndr_pull *ndr, int flags, struct PNP_SetDeviceProblem *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_SetDeviceProblem(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetDeviceProblem *r) +{ + ndr_print_struct(ndr, name, "PNP_SetDeviceProblem"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_SetDeviceProblem"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_SetDeviceProblem"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_DisableDevInst(struct ndr_push *ndr, int flags, const struct PNP_DisableDevInst *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_DisableDevInst(struct ndr_pull *ndr, int flags, struct PNP_DisableDevInst *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_DisableDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DisableDevInst *r) +{ + ndr_print_struct(ndr, name, "PNP_DisableDevInst"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_DisableDevInst"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_DisableDevInst"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_UninstallDevInst(struct ndr_push *ndr, int flags, const struct PNP_UninstallDevInst *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_UninstallDevInst(struct ndr_pull *ndr, int flags, struct PNP_UninstallDevInst *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_UninstallDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UninstallDevInst *r) +{ + ndr_print_struct(ndr, name, "PNP_UninstallDevInst"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_UninstallDevInst"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_UninstallDevInst"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_AddID(struct ndr_push *ndr, int flags, const struct PNP_AddID *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_AddID(struct ndr_pull *ndr, int flags, struct PNP_AddID *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_AddID(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddID *r) +{ + ndr_print_struct(ndr, name, "PNP_AddID"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_AddID"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_AddID"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_RegisterDriver(struct ndr_push *ndr, int flags, const struct PNP_RegisterDriver *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_RegisterDriver(struct ndr_pull *ndr, int flags, struct PNP_RegisterDriver *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_RegisterDriver(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterDriver *r) +{ + ndr_print_struct(ndr, name, "PNP_RegisterDriver"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_RegisterDriver"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_RegisterDriver"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_QueryRemove(struct ndr_push *ndr, int flags, const struct PNP_QueryRemove *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_QueryRemove(struct ndr_pull *ndr, int flags, struct PNP_QueryRemove *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_QueryRemove(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryRemove *r) +{ + ndr_print_struct(ndr, name, "PNP_QueryRemove"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_QueryRemove"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_QueryRemove"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_RequestDeviceEject(struct ndr_push *ndr, int flags, const struct PNP_RequestDeviceEject *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_RequestDeviceEject(struct ndr_pull *ndr, int flags, struct PNP_RequestDeviceEject *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_RequestDeviceEject(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RequestDeviceEject *r) +{ + ndr_print_struct(ndr, name, "PNP_RequestDeviceEject"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_RequestDeviceEject"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_RequestDeviceEject"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_IsDockStationPresent(struct ndr_push *ndr, int flags, const struct PNP_IsDockStationPresent *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_IsDockStationPresent(struct ndr_pull *ndr, int flags, struct PNP_IsDockStationPresent *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_IsDockStationPresent(struct ndr_print *ndr, const char *name, int flags, const struct PNP_IsDockStationPresent *r) +{ + ndr_print_struct(ndr, name, "PNP_IsDockStationPresent"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_IsDockStationPresent"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_IsDockStationPresent"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_RequestEjectPC(struct ndr_push *ndr, int flags, const struct PNP_RequestEjectPC *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_RequestEjectPC(struct ndr_pull *ndr, int flags, struct PNP_RequestEjectPC *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_RequestEjectPC(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RequestEjectPC *r) +{ + ndr_print_struct(ndr, name, "PNP_RequestEjectPC"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_RequestEjectPC"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_RequestEjectPC"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_HwProfFlags(struct ndr_push *ndr, int flags, const struct PNP_HwProfFlags *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_HwProfFlags(struct ndr_pull *ndr, int flags, struct PNP_HwProfFlags *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_HwProfFlags(struct ndr_print *ndr, const char *name, int flags, const struct PNP_HwProfFlags *r) +{ + ndr_print_struct(ndr, name, "PNP_HwProfFlags"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_HwProfFlags"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_HwProfFlags"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetHwProfInfo(struct ndr_push *ndr, int flags, const struct PNP_GetHwProfInfo *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetHwProfInfo(struct ndr_pull *ndr, int flags, struct PNP_GetHwProfInfo *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetHwProfInfo(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetHwProfInfo *r) +{ + ndr_print_struct(ndr, name, "PNP_GetHwProfInfo"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetHwProfInfo"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetHwProfInfo"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_AddEmptyLogConf(struct ndr_push *ndr, int flags, const struct PNP_AddEmptyLogConf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_AddEmptyLogConf(struct ndr_pull *ndr, int flags, struct PNP_AddEmptyLogConf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_AddEmptyLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddEmptyLogConf *r) +{ + ndr_print_struct(ndr, name, "PNP_AddEmptyLogConf"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_AddEmptyLogConf"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_AddEmptyLogConf"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_FreeLogConf(struct ndr_push *ndr, int flags, const struct PNP_FreeLogConf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_FreeLogConf(struct ndr_pull *ndr, int flags, struct PNP_FreeLogConf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_FreeLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_FreeLogConf *r) +{ + ndr_print_struct(ndr, name, "PNP_FreeLogConf"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_FreeLogConf"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_FreeLogConf"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetFirstLogConf(struct ndr_push *ndr, int flags, const struct PNP_GetFirstLogConf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetFirstLogConf(struct ndr_pull *ndr, int flags, struct PNP_GetFirstLogConf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetFirstLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetFirstLogConf *r) +{ + ndr_print_struct(ndr, name, "PNP_GetFirstLogConf"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetFirstLogConf"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetFirstLogConf"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetNextLogConf(struct ndr_push *ndr, int flags, const struct PNP_GetNextLogConf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetNextLogConf(struct ndr_pull *ndr, int flags, struct PNP_GetNextLogConf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetNextLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetNextLogConf *r) +{ + ndr_print_struct(ndr, name, "PNP_GetNextLogConf"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetNextLogConf"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetNextLogConf"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetLogConfPriority(struct ndr_push *ndr, int flags, const struct PNP_GetLogConfPriority *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetLogConfPriority(struct ndr_pull *ndr, int flags, struct PNP_GetLogConfPriority *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetLogConfPriority(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetLogConfPriority *r) +{ + ndr_print_struct(ndr, name, "PNP_GetLogConfPriority"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetLogConfPriority"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetLogConfPriority"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_AddResDes(struct ndr_push *ndr, int flags, const struct PNP_AddResDes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_AddResDes(struct ndr_pull *ndr, int flags, struct PNP_AddResDes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_AddResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddResDes *r) +{ + ndr_print_struct(ndr, name, "PNP_AddResDes"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_AddResDes"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_AddResDes"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_FreeResDes(struct ndr_push *ndr, int flags, const struct PNP_FreeResDes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_FreeResDes(struct ndr_pull *ndr, int flags, struct PNP_FreeResDes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_FreeResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_FreeResDes *r) +{ + ndr_print_struct(ndr, name, "PNP_FreeResDes"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_FreeResDes"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_FreeResDes"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetNextResDes(struct ndr_push *ndr, int flags, const struct PNP_GetNextResDes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetNextResDes(struct ndr_pull *ndr, int flags, struct PNP_GetNextResDes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetNextResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetNextResDes *r) +{ + ndr_print_struct(ndr, name, "PNP_GetNextResDes"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetNextResDes"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetNextResDes"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetResDesData(struct ndr_push *ndr, int flags, const struct PNP_GetResDesData *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetResDesData(struct ndr_pull *ndr, int flags, struct PNP_GetResDesData *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetResDesData(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetResDesData *r) +{ + ndr_print_struct(ndr, name, "PNP_GetResDesData"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetResDesData"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetResDesData"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetResDesDataSize(struct ndr_push *ndr, int flags, const struct PNP_GetResDesDataSize *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetResDesDataSize(struct ndr_pull *ndr, int flags, struct PNP_GetResDesDataSize *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetResDesDataSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetResDesDataSize *r) +{ + ndr_print_struct(ndr, name, "PNP_GetResDesDataSize"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetResDesDataSize"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetResDesDataSize"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_ModifyResDes(struct ndr_push *ndr, int flags, const struct PNP_ModifyResDes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_ModifyResDes(struct ndr_pull *ndr, int flags, struct PNP_ModifyResDes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_ModifyResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ModifyResDes *r) +{ + ndr_print_struct(ndr, name, "PNP_ModifyResDes"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_ModifyResDes"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_ModifyResDes"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_DetectResourceLimit(struct ndr_push *ndr, int flags, const struct PNP_DetectResourceLimit *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_DetectResourceLimit(struct ndr_pull *ndr, int flags, struct PNP_DetectResourceLimit *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_DetectResourceLimit(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DetectResourceLimit *r) +{ + ndr_print_struct(ndr, name, "PNP_DetectResourceLimit"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_DetectResourceLimit"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_DetectResourceLimit"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_QueryResConfList(struct ndr_push *ndr, int flags, const struct PNP_QueryResConfList *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_QueryResConfList(struct ndr_pull *ndr, int flags, struct PNP_QueryResConfList *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_QueryResConfList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryResConfList *r) +{ + ndr_print_struct(ndr, name, "PNP_QueryResConfList"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_QueryResConfList"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_QueryResConfList"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_SetHwProf(struct ndr_push *ndr, int flags, const struct PNP_SetHwProf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_SetHwProf(struct ndr_pull *ndr, int flags, struct PNP_SetHwProf *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_SetHwProf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetHwProf *r) +{ + ndr_print_struct(ndr, name, "PNP_SetHwProf"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_SetHwProf"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_SetHwProf"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_QueryArbitratorFreeData(struct ndr_push *ndr, int flags, const struct PNP_QueryArbitratorFreeData *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_QueryArbitratorFreeData(struct ndr_pull *ndr, int flags, struct PNP_QueryArbitratorFreeData *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_QueryArbitratorFreeData(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryArbitratorFreeData *r) +{ + ndr_print_struct(ndr, name, "PNP_QueryArbitratorFreeData"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_QueryArbitratorFreeData"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_QueryArbitratorFreeData"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_QueryArbitratorFreeSize(struct ndr_push *ndr, int flags, const struct PNP_QueryArbitratorFreeSize *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_QueryArbitratorFreeSize(struct ndr_pull *ndr, int flags, struct PNP_QueryArbitratorFreeSize *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_QueryArbitratorFreeSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryArbitratorFreeSize *r) +{ + ndr_print_struct(ndr, name, "PNP_QueryArbitratorFreeSize"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_QueryArbitratorFreeSize"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_QueryArbitratorFreeSize"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_RunDetection(struct ndr_push *ndr, int flags, const struct PNP_RunDetection *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_RunDetection(struct ndr_pull *ndr, int flags, struct PNP_RunDetection *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_RunDetection(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RunDetection *r) +{ + ndr_print_struct(ndr, name, "PNP_RunDetection"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_RunDetection"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_RunDetection"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_RegisterNotification(struct ndr_push *ndr, int flags, const struct PNP_RegisterNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_RegisterNotification(struct ndr_pull *ndr, int flags, struct PNP_RegisterNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_RegisterNotification(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterNotification *r) +{ + ndr_print_struct(ndr, name, "PNP_RegisterNotification"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_RegisterNotification"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_RegisterNotification"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_UnregisterNotification(struct ndr_push *ndr, int flags, const struct PNP_UnregisterNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_UnregisterNotification(struct ndr_pull *ndr, int flags, struct PNP_UnregisterNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_UnregisterNotification(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UnregisterNotification *r) +{ + ndr_print_struct(ndr, name, "PNP_UnregisterNotification"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_UnregisterNotification"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_UnregisterNotification"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetCustomDevProp(struct ndr_push *ndr, int flags, const struct PNP_GetCustomDevProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetCustomDevProp(struct ndr_pull *ndr, int flags, struct PNP_GetCustomDevProp *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetCustomDevProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetCustomDevProp *r) +{ + ndr_print_struct(ndr, name, "PNP_GetCustomDevProp"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetCustomDevProp"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetCustomDevProp"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetVersionInternal(struct ndr_push *ndr, int flags, const struct PNP_GetVersionInternal *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetVersionInternal(struct ndr_pull *ndr, int flags, struct PNP_GetVersionInternal *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetVersionInternal(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetVersionInternal *r) +{ + ndr_print_struct(ndr, name, "PNP_GetVersionInternal"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetVersionInternal"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetVersionInternal"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetBlockedDriverInfo(struct ndr_push *ndr, int flags, const struct PNP_GetBlockedDriverInfo *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetBlockedDriverInfo(struct ndr_pull *ndr, int flags, struct PNP_GetBlockedDriverInfo *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetBlockedDriverInfo(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetBlockedDriverInfo *r) +{ + ndr_print_struct(ndr, name, "PNP_GetBlockedDriverInfo"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetBlockedDriverInfo"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetBlockedDriverInfo"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_PNP_GetServerSideDeviceInstallFlags(struct ndr_push *ndr, int flags, const struct PNP_GetServerSideDeviceInstallFlags *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_GetServerSideDeviceInstallFlags(struct ndr_pull *ndr, int flags, struct PNP_GetServerSideDeviceInstallFlags *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_GetServerSideDeviceInstallFlags(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetServerSideDeviceInstallFlags *r) +{ + ndr_print_struct(ndr, name, "PNP_GetServerSideDeviceInstallFlags"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "PNP_GetServerSideDeviceInstallFlags"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "PNP_GetServerSideDeviceInstallFlags"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static const struct ndr_interface_call ntsvcs_calls[] = { + { + "PNP_Disconnect", + sizeof(struct PNP_Disconnect), + (ndr_push_flags_fn_t) ndr_push_PNP_Disconnect, + (ndr_pull_flags_fn_t) ndr_pull_PNP_Disconnect, + (ndr_print_function_t) ndr_print_PNP_Disconnect, + false, + }, + { + "PNP_Connect", + sizeof(struct PNP_Connect), + (ndr_push_flags_fn_t) ndr_push_PNP_Connect, + (ndr_pull_flags_fn_t) ndr_pull_PNP_Connect, + (ndr_print_function_t) ndr_print_PNP_Connect, + false, + }, + { + "PNP_GetVersion", + sizeof(struct PNP_GetVersion), + (ndr_push_flags_fn_t) ndr_push_PNP_GetVersion, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetVersion, + (ndr_print_function_t) ndr_print_PNP_GetVersion, + false, + }, + { + "PNP_GetGlobalState", + sizeof(struct PNP_GetGlobalState), + (ndr_push_flags_fn_t) ndr_push_PNP_GetGlobalState, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetGlobalState, + (ndr_print_function_t) ndr_print_PNP_GetGlobalState, + false, + }, + { + "PNP_InitDetection", + sizeof(struct PNP_InitDetection), + (ndr_push_flags_fn_t) ndr_push_PNP_InitDetection, + (ndr_pull_flags_fn_t) ndr_pull_PNP_InitDetection, + (ndr_print_function_t) ndr_print_PNP_InitDetection, + false, + }, + { + "PNP_ReportLogOn", + sizeof(struct PNP_ReportLogOn), + (ndr_push_flags_fn_t) ndr_push_PNP_ReportLogOn, + (ndr_pull_flags_fn_t) ndr_pull_PNP_ReportLogOn, + (ndr_print_function_t) ndr_print_PNP_ReportLogOn, + false, + }, + { + "PNP_ValidateDeviceInstance", + sizeof(struct PNP_ValidateDeviceInstance), + (ndr_push_flags_fn_t) ndr_push_PNP_ValidateDeviceInstance, + (ndr_pull_flags_fn_t) ndr_pull_PNP_ValidateDeviceInstance, + (ndr_print_function_t) ndr_print_PNP_ValidateDeviceInstance, + false, + }, + { + "PNP_GetRootDeviceInstance", + sizeof(struct PNP_GetRootDeviceInstance), + (ndr_push_flags_fn_t) ndr_push_PNP_GetRootDeviceInstance, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetRootDeviceInstance, + (ndr_print_function_t) ndr_print_PNP_GetRootDeviceInstance, + false, + }, + { + "PNP_GetRelatedDeviceInstance", + sizeof(struct PNP_GetRelatedDeviceInstance), + (ndr_push_flags_fn_t) ndr_push_PNP_GetRelatedDeviceInstance, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetRelatedDeviceInstance, + (ndr_print_function_t) ndr_print_PNP_GetRelatedDeviceInstance, + false, + }, + { + "PNP_EnumerateSubKeys", + sizeof(struct PNP_EnumerateSubKeys), + (ndr_push_flags_fn_t) ndr_push_PNP_EnumerateSubKeys, + (ndr_pull_flags_fn_t) ndr_pull_PNP_EnumerateSubKeys, + (ndr_print_function_t) ndr_print_PNP_EnumerateSubKeys, + false, + }, + { + "PNP_GetDeviceList", + sizeof(struct PNP_GetDeviceList), + (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceList, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceList, + (ndr_print_function_t) ndr_print_PNP_GetDeviceList, + false, + }, + { + "PNP_GetDeviceListSize", + sizeof(struct PNP_GetDeviceListSize), + (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceListSize, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceListSize, + (ndr_print_function_t) ndr_print_PNP_GetDeviceListSize, + false, + }, + { + "PNP_GetDepth", + sizeof(struct PNP_GetDepth), + (ndr_push_flags_fn_t) ndr_push_PNP_GetDepth, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDepth, + (ndr_print_function_t) ndr_print_PNP_GetDepth, + false, + }, + { + "PNP_GetDeviceRegProp", + sizeof(struct PNP_GetDeviceRegProp), + (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceRegProp, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceRegProp, + (ndr_print_function_t) ndr_print_PNP_GetDeviceRegProp, + false, + }, + { + "PNP_SetDeviceRegProp", + sizeof(struct PNP_SetDeviceRegProp), + (ndr_push_flags_fn_t) ndr_push_PNP_SetDeviceRegProp, + (ndr_pull_flags_fn_t) ndr_pull_PNP_SetDeviceRegProp, + (ndr_print_function_t) ndr_print_PNP_SetDeviceRegProp, + false, + }, + { + "PNP_GetClassInstance", + sizeof(struct PNP_GetClassInstance), + (ndr_push_flags_fn_t) ndr_push_PNP_GetClassInstance, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassInstance, + (ndr_print_function_t) ndr_print_PNP_GetClassInstance, + false, + }, + { + "PNP_CreateKey", + sizeof(struct PNP_CreateKey), + (ndr_push_flags_fn_t) ndr_push_PNP_CreateKey, + (ndr_pull_flags_fn_t) ndr_pull_PNP_CreateKey, + (ndr_print_function_t) ndr_print_PNP_CreateKey, + false, + }, + { + "PNP_DeleteRegistryKey", + sizeof(struct PNP_DeleteRegistryKey), + (ndr_push_flags_fn_t) ndr_push_PNP_DeleteRegistryKey, + (ndr_pull_flags_fn_t) ndr_pull_PNP_DeleteRegistryKey, + (ndr_print_function_t) ndr_print_PNP_DeleteRegistryKey, + false, + }, + { + "PNP_GetClassCount", + sizeof(struct PNP_GetClassCount), + (ndr_push_flags_fn_t) ndr_push_PNP_GetClassCount, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassCount, + (ndr_print_function_t) ndr_print_PNP_GetClassCount, + false, + }, + { + "PNP_GetClassName", + sizeof(struct PNP_GetClassName), + (ndr_push_flags_fn_t) ndr_push_PNP_GetClassName, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassName, + (ndr_print_function_t) ndr_print_PNP_GetClassName, + false, + }, + { + "PNP_DeleteClassKey", + sizeof(struct PNP_DeleteClassKey), + (ndr_push_flags_fn_t) ndr_push_PNP_DeleteClassKey, + (ndr_pull_flags_fn_t) ndr_pull_PNP_DeleteClassKey, + (ndr_print_function_t) ndr_print_PNP_DeleteClassKey, + false, + }, + { + "PNP_GetInterfaceDeviceAlias", + sizeof(struct PNP_GetInterfaceDeviceAlias), + (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceAlias, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceAlias, + (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceAlias, + false, + }, + { + "PNP_GetInterfaceDeviceList", + sizeof(struct PNP_GetInterfaceDeviceList), + (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceList, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceList, + (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceList, + false, + }, + { + "PNP_GetInterfaceDeviceListSize", + sizeof(struct PNP_GetInterfaceDeviceListSize), + (ndr_push_flags_fn_t) ndr_push_PNP_GetInterfaceDeviceListSize, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetInterfaceDeviceListSize, + (ndr_print_function_t) ndr_print_PNP_GetInterfaceDeviceListSize, + false, + }, + { + "PNP_RegisterDeviceClassAssociation", + sizeof(struct PNP_RegisterDeviceClassAssociation), + (ndr_push_flags_fn_t) ndr_push_PNP_RegisterDeviceClassAssociation, + (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterDeviceClassAssociation, + (ndr_print_function_t) ndr_print_PNP_RegisterDeviceClassAssociation, + false, + }, + { + "PNP_UnregisterDeviceClassAssociation", + sizeof(struct PNP_UnregisterDeviceClassAssociation), + (ndr_push_flags_fn_t) ndr_push_PNP_UnregisterDeviceClassAssociation, + (ndr_pull_flags_fn_t) ndr_pull_PNP_UnregisterDeviceClassAssociation, + (ndr_print_function_t) ndr_print_PNP_UnregisterDeviceClassAssociation, + false, + }, + { + "PNP_GetClassRegProp", + sizeof(struct PNP_GetClassRegProp), + (ndr_push_flags_fn_t) ndr_push_PNP_GetClassRegProp, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetClassRegProp, + (ndr_print_function_t) ndr_print_PNP_GetClassRegProp, + false, + }, + { + "PNP_SetClassRegProp", + sizeof(struct PNP_SetClassRegProp), + (ndr_push_flags_fn_t) ndr_push_PNP_SetClassRegProp, + (ndr_pull_flags_fn_t) ndr_pull_PNP_SetClassRegProp, + (ndr_print_function_t) ndr_print_PNP_SetClassRegProp, + false, + }, + { + "PNP_CreateDevInst", + sizeof(struct PNP_CreateDevInst), + (ndr_push_flags_fn_t) ndr_push_PNP_CreateDevInst, + (ndr_pull_flags_fn_t) ndr_pull_PNP_CreateDevInst, + (ndr_print_function_t) ndr_print_PNP_CreateDevInst, + false, + }, + { + "PNP_DeviceInstanceAction", + sizeof(struct PNP_DeviceInstanceAction), + (ndr_push_flags_fn_t) ndr_push_PNP_DeviceInstanceAction, + (ndr_pull_flags_fn_t) ndr_pull_PNP_DeviceInstanceAction, + (ndr_print_function_t) ndr_print_PNP_DeviceInstanceAction, + false, + }, + { + "PNP_GetDeviceStatus", + sizeof(struct PNP_GetDeviceStatus), + (ndr_push_flags_fn_t) ndr_push_PNP_GetDeviceStatus, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetDeviceStatus, + (ndr_print_function_t) ndr_print_PNP_GetDeviceStatus, + false, + }, + { + "PNP_SetDeviceProblem", + sizeof(struct PNP_SetDeviceProblem), + (ndr_push_flags_fn_t) ndr_push_PNP_SetDeviceProblem, + (ndr_pull_flags_fn_t) ndr_pull_PNP_SetDeviceProblem, + (ndr_print_function_t) ndr_print_PNP_SetDeviceProblem, + false, + }, + { + "PNP_DisableDevInst", + sizeof(struct PNP_DisableDevInst), + (ndr_push_flags_fn_t) ndr_push_PNP_DisableDevInst, + (ndr_pull_flags_fn_t) ndr_pull_PNP_DisableDevInst, + (ndr_print_function_t) ndr_print_PNP_DisableDevInst, + false, + }, + { + "PNP_UninstallDevInst", + sizeof(struct PNP_UninstallDevInst), + (ndr_push_flags_fn_t) ndr_push_PNP_UninstallDevInst, + (ndr_pull_flags_fn_t) ndr_pull_PNP_UninstallDevInst, + (ndr_print_function_t) ndr_print_PNP_UninstallDevInst, + false, + }, + { + "PNP_AddID", + sizeof(struct PNP_AddID), + (ndr_push_flags_fn_t) ndr_push_PNP_AddID, + (ndr_pull_flags_fn_t) ndr_pull_PNP_AddID, + (ndr_print_function_t) ndr_print_PNP_AddID, + false, + }, + { + "PNP_RegisterDriver", + sizeof(struct PNP_RegisterDriver), + (ndr_push_flags_fn_t) ndr_push_PNP_RegisterDriver, + (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterDriver, + (ndr_print_function_t) ndr_print_PNP_RegisterDriver, + false, + }, + { + "PNP_QueryRemove", + sizeof(struct PNP_QueryRemove), + (ndr_push_flags_fn_t) ndr_push_PNP_QueryRemove, + (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryRemove, + (ndr_print_function_t) ndr_print_PNP_QueryRemove, + false, + }, + { + "PNP_RequestDeviceEject", + sizeof(struct PNP_RequestDeviceEject), + (ndr_push_flags_fn_t) ndr_push_PNP_RequestDeviceEject, + (ndr_pull_flags_fn_t) ndr_pull_PNP_RequestDeviceEject, + (ndr_print_function_t) ndr_print_PNP_RequestDeviceEject, + false, + }, + { + "PNP_IsDockStationPresent", + sizeof(struct PNP_IsDockStationPresent), + (ndr_push_flags_fn_t) ndr_push_PNP_IsDockStationPresent, + (ndr_pull_flags_fn_t) ndr_pull_PNP_IsDockStationPresent, + (ndr_print_function_t) ndr_print_PNP_IsDockStationPresent, + false, + }, + { + "PNP_RequestEjectPC", + sizeof(struct PNP_RequestEjectPC), + (ndr_push_flags_fn_t) ndr_push_PNP_RequestEjectPC, + (ndr_pull_flags_fn_t) ndr_pull_PNP_RequestEjectPC, + (ndr_print_function_t) ndr_print_PNP_RequestEjectPC, + false, + }, + { + "PNP_HwProfFlags", + sizeof(struct PNP_HwProfFlags), + (ndr_push_flags_fn_t) ndr_push_PNP_HwProfFlags, + (ndr_pull_flags_fn_t) ndr_pull_PNP_HwProfFlags, + (ndr_print_function_t) ndr_print_PNP_HwProfFlags, + false, + }, + { + "PNP_GetHwProfInfo", + sizeof(struct PNP_GetHwProfInfo), + (ndr_push_flags_fn_t) ndr_push_PNP_GetHwProfInfo, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetHwProfInfo, + (ndr_print_function_t) ndr_print_PNP_GetHwProfInfo, + false, + }, + { + "PNP_AddEmptyLogConf", + sizeof(struct PNP_AddEmptyLogConf), + (ndr_push_flags_fn_t) ndr_push_PNP_AddEmptyLogConf, + (ndr_pull_flags_fn_t) ndr_pull_PNP_AddEmptyLogConf, + (ndr_print_function_t) ndr_print_PNP_AddEmptyLogConf, + false, + }, + { + "PNP_FreeLogConf", + sizeof(struct PNP_FreeLogConf), + (ndr_push_flags_fn_t) ndr_push_PNP_FreeLogConf, + (ndr_pull_flags_fn_t) ndr_pull_PNP_FreeLogConf, + (ndr_print_function_t) ndr_print_PNP_FreeLogConf, + false, + }, + { + "PNP_GetFirstLogConf", + sizeof(struct PNP_GetFirstLogConf), + (ndr_push_flags_fn_t) ndr_push_PNP_GetFirstLogConf, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetFirstLogConf, + (ndr_print_function_t) ndr_print_PNP_GetFirstLogConf, + false, + }, + { + "PNP_GetNextLogConf", + sizeof(struct PNP_GetNextLogConf), + (ndr_push_flags_fn_t) ndr_push_PNP_GetNextLogConf, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetNextLogConf, + (ndr_print_function_t) ndr_print_PNP_GetNextLogConf, + false, + }, + { + "PNP_GetLogConfPriority", + sizeof(struct PNP_GetLogConfPriority), + (ndr_push_flags_fn_t) ndr_push_PNP_GetLogConfPriority, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetLogConfPriority, + (ndr_print_function_t) ndr_print_PNP_GetLogConfPriority, + false, + }, + { + "PNP_AddResDes", + sizeof(struct PNP_AddResDes), + (ndr_push_flags_fn_t) ndr_push_PNP_AddResDes, + (ndr_pull_flags_fn_t) ndr_pull_PNP_AddResDes, + (ndr_print_function_t) ndr_print_PNP_AddResDes, + false, + }, + { + "PNP_FreeResDes", + sizeof(struct PNP_FreeResDes), + (ndr_push_flags_fn_t) ndr_push_PNP_FreeResDes, + (ndr_pull_flags_fn_t) ndr_pull_PNP_FreeResDes, + (ndr_print_function_t) ndr_print_PNP_FreeResDes, + false, + }, + { + "PNP_GetNextResDes", + sizeof(struct PNP_GetNextResDes), + (ndr_push_flags_fn_t) ndr_push_PNP_GetNextResDes, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetNextResDes, + (ndr_print_function_t) ndr_print_PNP_GetNextResDes, + false, + }, + { + "PNP_GetResDesData", + sizeof(struct PNP_GetResDesData), + (ndr_push_flags_fn_t) ndr_push_PNP_GetResDesData, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetResDesData, + (ndr_print_function_t) ndr_print_PNP_GetResDesData, + false, + }, + { + "PNP_GetResDesDataSize", + sizeof(struct PNP_GetResDesDataSize), + (ndr_push_flags_fn_t) ndr_push_PNP_GetResDesDataSize, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetResDesDataSize, + (ndr_print_function_t) ndr_print_PNP_GetResDesDataSize, + false, + }, + { + "PNP_ModifyResDes", + sizeof(struct PNP_ModifyResDes), + (ndr_push_flags_fn_t) ndr_push_PNP_ModifyResDes, + (ndr_pull_flags_fn_t) ndr_pull_PNP_ModifyResDes, + (ndr_print_function_t) ndr_print_PNP_ModifyResDes, + false, + }, + { + "PNP_DetectResourceLimit", + sizeof(struct PNP_DetectResourceLimit), + (ndr_push_flags_fn_t) ndr_push_PNP_DetectResourceLimit, + (ndr_pull_flags_fn_t) ndr_pull_PNP_DetectResourceLimit, + (ndr_print_function_t) ndr_print_PNP_DetectResourceLimit, + false, + }, + { + "PNP_QueryResConfList", + sizeof(struct PNP_QueryResConfList), + (ndr_push_flags_fn_t) ndr_push_PNP_QueryResConfList, + (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryResConfList, + (ndr_print_function_t) ndr_print_PNP_QueryResConfList, + false, + }, + { + "PNP_SetHwProf", + sizeof(struct PNP_SetHwProf), + (ndr_push_flags_fn_t) ndr_push_PNP_SetHwProf, + (ndr_pull_flags_fn_t) ndr_pull_PNP_SetHwProf, + (ndr_print_function_t) ndr_print_PNP_SetHwProf, + false, + }, + { + "PNP_QueryArbitratorFreeData", + sizeof(struct PNP_QueryArbitratorFreeData), + (ndr_push_flags_fn_t) ndr_push_PNP_QueryArbitratorFreeData, + (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryArbitratorFreeData, + (ndr_print_function_t) ndr_print_PNP_QueryArbitratorFreeData, + false, + }, + { + "PNP_QueryArbitratorFreeSize", + sizeof(struct PNP_QueryArbitratorFreeSize), + (ndr_push_flags_fn_t) ndr_push_PNP_QueryArbitratorFreeSize, + (ndr_pull_flags_fn_t) ndr_pull_PNP_QueryArbitratorFreeSize, + (ndr_print_function_t) ndr_print_PNP_QueryArbitratorFreeSize, + false, + }, + { + "PNP_RunDetection", + sizeof(struct PNP_RunDetection), + (ndr_push_flags_fn_t) ndr_push_PNP_RunDetection, + (ndr_pull_flags_fn_t) ndr_pull_PNP_RunDetection, + (ndr_print_function_t) ndr_print_PNP_RunDetection, + false, + }, + { + "PNP_RegisterNotification", + sizeof(struct PNP_RegisterNotification), + (ndr_push_flags_fn_t) ndr_push_PNP_RegisterNotification, + (ndr_pull_flags_fn_t) ndr_pull_PNP_RegisterNotification, + (ndr_print_function_t) ndr_print_PNP_RegisterNotification, + false, + }, + { + "PNP_UnregisterNotification", + sizeof(struct PNP_UnregisterNotification), + (ndr_push_flags_fn_t) ndr_push_PNP_UnregisterNotification, + (ndr_pull_flags_fn_t) ndr_pull_PNP_UnregisterNotification, + (ndr_print_function_t) ndr_print_PNP_UnregisterNotification, + false, + }, + { + "PNP_GetCustomDevProp", + sizeof(struct PNP_GetCustomDevProp), + (ndr_push_flags_fn_t) ndr_push_PNP_GetCustomDevProp, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetCustomDevProp, + (ndr_print_function_t) ndr_print_PNP_GetCustomDevProp, + false, + }, + { + "PNP_GetVersionInternal", + sizeof(struct PNP_GetVersionInternal), + (ndr_push_flags_fn_t) ndr_push_PNP_GetVersionInternal, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetVersionInternal, + (ndr_print_function_t) ndr_print_PNP_GetVersionInternal, + false, + }, + { + "PNP_GetBlockedDriverInfo", + sizeof(struct PNP_GetBlockedDriverInfo), + (ndr_push_flags_fn_t) ndr_push_PNP_GetBlockedDriverInfo, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetBlockedDriverInfo, + (ndr_print_function_t) ndr_print_PNP_GetBlockedDriverInfo, + false, + }, + { + "PNP_GetServerSideDeviceInstallFlags", + sizeof(struct PNP_GetServerSideDeviceInstallFlags), + (ndr_push_flags_fn_t) ndr_push_PNP_GetServerSideDeviceInstallFlags, + (ndr_pull_flags_fn_t) ndr_pull_PNP_GetServerSideDeviceInstallFlags, + (ndr_print_function_t) ndr_print_PNP_GetServerSideDeviceInstallFlags, + false, + }, + { NULL, 0, NULL, NULL, NULL, false } +}; + +static const char * const ntsvcs_endpoint_strings[] = { + "ncacn_np:[\\pipe\\ntsvcs]", +}; + +static const struct ndr_interface_string_array ntsvcs_endpoints = { + .count = 1, + .names = ntsvcs_endpoint_strings +}; + +static const char * const ntsvcs_authservice_strings[] = { + "host", +}; + +static const struct ndr_interface_string_array ntsvcs_authservices = { + .count = 1, + .names = ntsvcs_authservice_strings +}; + + +const struct ndr_interface_table ndr_table_ntsvcs = { + .name = "ntsvcs", + .syntax_id = { + {0x8d9f4e40,0xa03d,0x11ce,{0x8f,0x69},{0x08,0x00,0x3e,0x30,0x05,0x1b}}, + NDR_NTSVCS_VERSION + }, + .helpstring = NDR_NTSVCS_HELPSTRING, + .num_calls = 65, + .calls = ntsvcs_calls, + .endpoints = &ntsvcs_endpoints, + .authservices = &ntsvcs_authservices +}; + diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.h b/source3/librpc/gen_ndr/ndr_ntsvcs.h new file mode 100644 index 0000000000..b415d6056b --- /dev/null +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.h @@ -0,0 +1,210 @@ +/* header auto-generated by pidl */ + +#include "librpc/ndr/libndr.h" +#include "librpc/gen_ndr/ntsvcs.h" + +#ifndef _HEADER_NDR_ntsvcs +#define _HEADER_NDR_ntsvcs + +#define NDR_NTSVCS_UUID "8d9f4e40-a03d-11ce-8f69-08003e30051b" +#define NDR_NTSVCS_VERSION 1.0 +#define NDR_NTSVCS_NAME "ntsvcs" +#define NDR_NTSVCS_HELPSTRING "Plug and Play services" +extern const struct ndr_interface_table ndr_table_ntsvcs; +#define NDR_PNP_DISCONNECT (0x00) + +#define NDR_PNP_CONNECT (0x01) + +#define NDR_PNP_GETVERSION (0x02) + +#define NDR_PNP_GETGLOBALSTATE (0x03) + +#define NDR_PNP_INITDETECTION (0x04) + +#define NDR_PNP_REPORTLOGON (0x05) + +#define NDR_PNP_VALIDATEDEVICEINSTANCE (0x06) + +#define NDR_PNP_GETROOTDEVICEINSTANCE (0x07) + +#define NDR_PNP_GETRELATEDDEVICEINSTANCE (0x08) + +#define NDR_PNP_ENUMERATESUBKEYS (0x09) + +#define NDR_PNP_GETDEVICELIST (0x0a) + +#define NDR_PNP_GETDEVICELISTSIZE (0x0b) + +#define NDR_PNP_GETDEPTH (0x0c) + +#define NDR_PNP_GETDEVICEREGPROP (0x0d) + +#define NDR_PNP_SETDEVICEREGPROP (0x0e) + +#define NDR_PNP_GETCLASSINSTANCE (0x0f) + +#define NDR_PNP_CREATEKEY (0x10) + +#define NDR_PNP_DELETEREGISTRYKEY (0x11) + +#define NDR_PNP_GETCLASSCOUNT (0x12) + +#define NDR_PNP_GETCLASSNAME (0x13) + +#define NDR_PNP_DELETECLASSKEY (0x14) + +#define NDR_PNP_GETINTERFACEDEVICEALIAS (0x15) + +#define NDR_PNP_GETINTERFACEDEVICELIST (0x16) + +#define NDR_PNP_GETINTERFACEDEVICELISTSIZE (0x17) + +#define NDR_PNP_REGISTERDEVICECLASSASSOCIATION (0x18) + +#define NDR_PNP_UNREGISTERDEVICECLASSASSOCIATION (0x19) + +#define NDR_PNP_GETCLASSREGPROP (0x1a) + +#define NDR_PNP_SETCLASSREGPROP (0x1b) + +#define NDR_PNP_CREATEDEVINST (0x1c) + +#define NDR_PNP_DEVICEINSTANCEACTION (0x1d) + +#define NDR_PNP_GETDEVICESTATUS (0x1e) + +#define NDR_PNP_SETDEVICEPROBLEM (0x1f) + +#define NDR_PNP_DISABLEDEVINST (0x20) + +#define NDR_PNP_UNINSTALLDEVINST (0x21) + +#define NDR_PNP_ADDID (0x22) + +#define NDR_PNP_REGISTERDRIVER (0x23) + +#define NDR_PNP_QUERYREMOVE (0x24) + +#define NDR_PNP_REQUESTDEVICEEJECT (0x25) + +#define NDR_PNP_ISDOCKSTATIONPRESENT (0x26) + +#define NDR_PNP_REQUESTEJECTPC (0x27) + +#define NDR_PNP_HWPROFFLAGS (0x28) + +#define NDR_PNP_GETHWPROFINFO (0x29) + +#define NDR_PNP_ADDEMPTYLOGCONF (0x2a) + +#define NDR_PNP_FREELOGCONF (0x2b) + +#define NDR_PNP_GETFIRSTLOGCONF (0x2c) + +#define NDR_PNP_GETNEXTLOGCONF (0x2d) + +#define NDR_PNP_GETLOGCONFPRIORITY (0x2e) + +#define NDR_PNP_ADDRESDES (0x2f) + +#define NDR_PNP_FREERESDES (0x30) + +#define NDR_PNP_GETNEXTRESDES (0x31) + +#define NDR_PNP_GETRESDESDATA (0x32) + +#define NDR_PNP_GETRESDESDATASIZE (0x33) + +#define NDR_PNP_MODIFYRESDES (0x34) + +#define NDR_PNP_DETECTRESOURCELIMIT (0x35) + +#define NDR_PNP_QUERYRESCONFLIST (0x36) + +#define NDR_PNP_SETHWPROF (0x37) + +#define NDR_PNP_QUERYARBITRATORFREEDATA (0x38) + +#define NDR_PNP_QUERYARBITRATORFREESIZE (0x39) + +#define NDR_PNP_RUNDETECTION (0x3a) + +#define NDR_PNP_REGISTERNOTIFICATION (0x3b) + +#define NDR_PNP_UNREGISTERNOTIFICATION (0x3c) + +#define NDR_PNP_GETCUSTOMDEVPROP (0x3d) + +#define NDR_PNP_GETVERSIONINTERNAL (0x3e) + +#define NDR_PNP_GETBLOCKEDDRIVERINFO (0x3f) + +#define NDR_PNP_GETSERVERSIDEDEVICEINSTALLFLAGS (0x40) + +#define NDR_NTSVCS_CALL_COUNT (65) +void ndr_print_PNP_Disconnect(struct ndr_print *ndr, const char *name, int flags, const struct PNP_Disconnect *r); +void ndr_print_PNP_Connect(struct ndr_print *ndr, const char *name, int flags, const struct PNP_Connect *r); +void ndr_print_PNP_GetVersion(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetVersion *r); +void ndr_print_PNP_GetGlobalState(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetGlobalState *r); +void ndr_print_PNP_InitDetection(struct ndr_print *ndr, const char *name, int flags, const struct PNP_InitDetection *r); +void ndr_print_PNP_ReportLogOn(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ReportLogOn *r); +void ndr_print_PNP_ValidateDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ValidateDeviceInstance *r); +void ndr_print_PNP_GetRootDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetRootDeviceInstance *r); +void ndr_print_PNP_GetRelatedDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetRelatedDeviceInstance *r); +void ndr_print_PNP_EnumerateSubKeys(struct ndr_print *ndr, const char *name, int flags, const struct PNP_EnumerateSubKeys *r); +void ndr_print_PNP_GetDeviceList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceList *r); +void ndr_print_PNP_GetDeviceListSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceListSize *r); +void ndr_print_PNP_GetDepth(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDepth *r); +void ndr_print_PNP_GetDeviceRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceRegProp *r); +void ndr_print_PNP_SetDeviceRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetDeviceRegProp *r); +void ndr_print_PNP_GetClassInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassInstance *r); +void ndr_print_PNP_CreateKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_CreateKey *r); +void ndr_print_PNP_DeleteRegistryKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeleteRegistryKey *r); +void ndr_print_PNP_GetClassCount(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassCount *r); +void ndr_print_PNP_GetClassName(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassName *r); +void ndr_print_PNP_DeleteClassKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeleteClassKey *r); +void ndr_print_PNP_GetInterfaceDeviceAlias(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceAlias *r); +void ndr_print_PNP_GetInterfaceDeviceList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceList *r); +void ndr_print_PNP_GetInterfaceDeviceListSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceListSize *r); +void ndr_print_PNP_RegisterDeviceClassAssociation(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterDeviceClassAssociation *r); +void ndr_print_PNP_UnregisterDeviceClassAssociation(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UnregisterDeviceClassAssociation *r); +void ndr_print_PNP_GetClassRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassRegProp *r); +void ndr_print_PNP_SetClassRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetClassRegProp *r); +void ndr_print_PNP_CreateDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_CreateDevInst *r); +void ndr_print_PNP_DeviceInstanceAction(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeviceInstanceAction *r); +void ndr_print_PNP_GetDeviceStatus(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceStatus *r); +void ndr_print_PNP_SetDeviceProblem(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetDeviceProblem *r); +void ndr_print_PNP_DisableDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DisableDevInst *r); +void ndr_print_PNP_UninstallDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UninstallDevInst *r); +void ndr_print_PNP_AddID(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddID *r); +void ndr_print_PNP_RegisterDriver(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterDriver *r); +void ndr_print_PNP_QueryRemove(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryRemove *r); +void ndr_print_PNP_RequestDeviceEject(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RequestDeviceEject *r); +void ndr_print_PNP_IsDockStationPresent(struct ndr_print *ndr, const char *name, int flags, const struct PNP_IsDockStationPresent *r); +void ndr_print_PNP_RequestEjectPC(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RequestEjectPC *r); +void ndr_print_PNP_HwProfFlags(struct ndr_print *ndr, const char *name, int flags, const struct PNP_HwProfFlags *r); +void ndr_print_PNP_GetHwProfInfo(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetHwProfInfo *r); +void ndr_print_PNP_AddEmptyLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddEmptyLogConf *r); +void ndr_print_PNP_FreeLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_FreeLogConf *r); +void ndr_print_PNP_GetFirstLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetFirstLogConf *r); +void ndr_print_PNP_GetNextLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetNextLogConf *r); +void ndr_print_PNP_GetLogConfPriority(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetLogConfPriority *r); +void ndr_print_PNP_AddResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddResDes *r); +void ndr_print_PNP_FreeResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_FreeResDes *r); +void ndr_print_PNP_GetNextResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetNextResDes *r); +void ndr_print_PNP_GetResDesData(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetResDesData *r); +void ndr_print_PNP_GetResDesDataSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetResDesDataSize *r); +void ndr_print_PNP_ModifyResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ModifyResDes *r); +void ndr_print_PNP_DetectResourceLimit(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DetectResourceLimit *r); +void ndr_print_PNP_QueryResConfList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryResConfList *r); +void ndr_print_PNP_SetHwProf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetHwProf *r); +void ndr_print_PNP_QueryArbitratorFreeData(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryArbitratorFreeData *r); +void ndr_print_PNP_QueryArbitratorFreeSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryArbitratorFreeSize *r); +void ndr_print_PNP_RunDetection(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RunDetection *r); +void ndr_print_PNP_RegisterNotification(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterNotification *r); +void ndr_print_PNP_UnregisterNotification(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UnregisterNotification *r); +void ndr_print_PNP_GetCustomDevProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetCustomDevProp *r); +void ndr_print_PNP_GetVersionInternal(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetVersionInternal *r); +void ndr_print_PNP_GetBlockedDriverInfo(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetBlockedDriverInfo *r); +void ndr_print_PNP_GetServerSideDeviceInstallFlags(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetServerSideDeviceInstallFlags *r); +#endif /* _HEADER_NDR_ntsvcs */ diff --git a/source3/librpc/gen_ndr/ntsvcs.h b/source3/librpc/gen_ndr/ntsvcs.h new file mode 100644 index 0000000000..43867c1bea --- /dev/null +++ b/source3/librpc/gen_ndr/ntsvcs.h @@ -0,0 +1,333 @@ +/* header auto-generated by pidl */ + +#include + +#ifndef _HEADER_ntsvcs +#define _HEADER_ntsvcs + + +struct PNP_Disconnect { + int _dummy_element; +}; + + +struct PNP_Connect { + int _dummy_element; +}; + + +struct PNP_GetVersion { + int _dummy_element; +}; + + +struct PNP_GetGlobalState { + int _dummy_element; +}; + + +struct PNP_InitDetection { + int _dummy_element; +}; + + +struct PNP_ReportLogOn { + int _dummy_element; +}; + + +struct PNP_ValidateDeviceInstance { + int _dummy_element; +}; + + +struct PNP_GetRootDeviceInstance { + int _dummy_element; +}; + + +struct PNP_GetRelatedDeviceInstance { + int _dummy_element; +}; + + +struct PNP_EnumerateSubKeys { + int _dummy_element; +}; + + +struct PNP_GetDeviceList { + int _dummy_element; +}; + + +struct PNP_GetDeviceListSize { + int _dummy_element; +}; + + +struct PNP_GetDepth { + int _dummy_element; +}; + + +struct PNP_GetDeviceRegProp { + int _dummy_element; +}; + + +struct PNP_SetDeviceRegProp { + int _dummy_element; +}; + + +struct PNP_GetClassInstance { + int _dummy_element; +}; + + +struct PNP_CreateKey { + int _dummy_element; +}; + + +struct PNP_DeleteRegistryKey { + int _dummy_element; +}; + + +struct PNP_GetClassCount { + int _dummy_element; +}; + + +struct PNP_GetClassName { + int _dummy_element; +}; + + +struct PNP_DeleteClassKey { + int _dummy_element; +}; + + +struct PNP_GetInterfaceDeviceAlias { + int _dummy_element; +}; + + +struct PNP_GetInterfaceDeviceList { + int _dummy_element; +}; + + +struct PNP_GetInterfaceDeviceListSize { + int _dummy_element; +}; + + +struct PNP_RegisterDeviceClassAssociation { + int _dummy_element; +}; + + +struct PNP_UnregisterDeviceClassAssociation { + int _dummy_element; +}; + + +struct PNP_GetClassRegProp { + int _dummy_element; +}; + + +struct PNP_SetClassRegProp { + int _dummy_element; +}; + + +struct PNP_CreateDevInst { + int _dummy_element; +}; + + +struct PNP_DeviceInstanceAction { + int _dummy_element; +}; + + +struct PNP_GetDeviceStatus { + int _dummy_element; +}; + + +struct PNP_SetDeviceProblem { + int _dummy_element; +}; + + +struct PNP_DisableDevInst { + int _dummy_element; +}; + + +struct PNP_UninstallDevInst { + int _dummy_element; +}; + + +struct PNP_AddID { + int _dummy_element; +}; + + +struct PNP_RegisterDriver { + int _dummy_element; +}; + + +struct PNP_QueryRemove { + int _dummy_element; +}; + + +struct PNP_RequestDeviceEject { + int _dummy_element; +}; + + +struct PNP_IsDockStationPresent { + int _dummy_element; +}; + + +struct PNP_RequestEjectPC { + int _dummy_element; +}; + + +struct PNP_HwProfFlags { + int _dummy_element; +}; + + +struct PNP_GetHwProfInfo { + int _dummy_element; +}; + + +struct PNP_AddEmptyLogConf { + int _dummy_element; +}; + + +struct PNP_FreeLogConf { + int _dummy_element; +}; + + +struct PNP_GetFirstLogConf { + int _dummy_element; +}; + + +struct PNP_GetNextLogConf { + int _dummy_element; +}; + + +struct PNP_GetLogConfPriority { + int _dummy_element; +}; + + +struct PNP_AddResDes { + int _dummy_element; +}; + + +struct PNP_FreeResDes { + int _dummy_element; +}; + + +struct PNP_GetNextResDes { + int _dummy_element; +}; + + +struct PNP_GetResDesData { + int _dummy_element; +}; + + +struct PNP_GetResDesDataSize { + int _dummy_element; +}; + + +struct PNP_ModifyResDes { + int _dummy_element; +}; + + +struct PNP_DetectResourceLimit { + int _dummy_element; +}; + + +struct PNP_QueryResConfList { + int _dummy_element; +}; + + +struct PNP_SetHwProf { + int _dummy_element; +}; + + +struct PNP_QueryArbitratorFreeData { + int _dummy_element; +}; + + +struct PNP_QueryArbitratorFreeSize { + int _dummy_element; +}; + + +struct PNP_RunDetection { + int _dummy_element; +}; + + +struct PNP_RegisterNotification { + int _dummy_element; +}; + + +struct PNP_UnregisterNotification { + int _dummy_element; +}; + + +struct PNP_GetCustomDevProp { + int _dummy_element; +}; + + +struct PNP_GetVersionInternal { + int _dummy_element; +}; + + +struct PNP_GetBlockedDriverInfo { + int _dummy_element; +}; + + +struct PNP_GetServerSideDeviceInstallFlags { + int _dummy_element; +}; + +#endif /* _HEADER_ntsvcs */ diff --git a/source3/librpc/gen_ndr/srv_ntsvcs.c b/source3/librpc/gen_ndr/srv_ntsvcs.c new file mode 100644 index 0000000000..f4689e0bbb --- /dev/null +++ b/source3/librpc/gen_ndr/srv_ntsvcs.c @@ -0,0 +1,4834 @@ +/* + * Unix SMB/CIFS implementation. + * server auto-generated by pidl. DO NOT MODIFY! + */ + +#include "includes.h" +#include "librpc/gen_ndr/srv_ntsvcs.h" + +static bool api_PNP_Disconnect(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_Disconnect *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_DISCONNECT]; + + r = talloc(talloc_tos(), struct PNP_Disconnect); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_Disconnect, r); + } + + _PNP_Disconnect(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_Disconnect, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_Connect(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_Connect *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_CONNECT]; + + r = talloc(talloc_tos(), struct PNP_Connect); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_Connect, r); + } + + _PNP_Connect(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_Connect, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetVersion(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetVersion *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETVERSION]; + + r = talloc(talloc_tos(), struct PNP_GetVersion); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetVersion, r); + } + + _PNP_GetVersion(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetVersion, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetGlobalState(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetGlobalState *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETGLOBALSTATE]; + + r = talloc(talloc_tos(), struct PNP_GetGlobalState); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetGlobalState, r); + } + + _PNP_GetGlobalState(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetGlobalState, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_InitDetection(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_InitDetection *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_INITDETECTION]; + + r = talloc(talloc_tos(), struct PNP_InitDetection); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_InitDetection, r); + } + + _PNP_InitDetection(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_InitDetection, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_ReportLogOn(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_ReportLogOn *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_REPORTLOGON]; + + r = talloc(talloc_tos(), struct PNP_ReportLogOn); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_ReportLogOn, r); + } + + _PNP_ReportLogOn(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_ReportLogOn, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_ValidateDeviceInstance(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_ValidateDeviceInstance *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_VALIDATEDEVICEINSTANCE]; + + r = talloc(talloc_tos(), struct PNP_ValidateDeviceInstance); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_ValidateDeviceInstance, r); + } + + _PNP_ValidateDeviceInstance(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_ValidateDeviceInstance, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetRootDeviceInstance(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetRootDeviceInstance *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETROOTDEVICEINSTANCE]; + + r = talloc(talloc_tos(), struct PNP_GetRootDeviceInstance); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetRootDeviceInstance, r); + } + + _PNP_GetRootDeviceInstance(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetRootDeviceInstance, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetRelatedDeviceInstance(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetRelatedDeviceInstance *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETRELATEDDEVICEINSTANCE]; + + r = talloc(talloc_tos(), struct PNP_GetRelatedDeviceInstance); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetRelatedDeviceInstance, r); + } + + _PNP_GetRelatedDeviceInstance(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetRelatedDeviceInstance, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_EnumerateSubKeys(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_EnumerateSubKeys *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_ENUMERATESUBKEYS]; + + r = talloc(talloc_tos(), struct PNP_EnumerateSubKeys); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_EnumerateSubKeys, r); + } + + _PNP_EnumerateSubKeys(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_EnumerateSubKeys, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetDeviceList(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetDeviceList *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETDEVICELIST]; + + r = talloc(talloc_tos(), struct PNP_GetDeviceList); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDeviceList, r); + } + + _PNP_GetDeviceList(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDeviceList, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetDeviceListSize(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetDeviceListSize *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETDEVICELISTSIZE]; + + r = talloc(talloc_tos(), struct PNP_GetDeviceListSize); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDeviceListSize, r); + } + + _PNP_GetDeviceListSize(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDeviceListSize, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetDepth(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetDepth *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETDEPTH]; + + r = talloc(talloc_tos(), struct PNP_GetDepth); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDepth, r); + } + + _PNP_GetDepth(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDepth, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetDeviceRegProp(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetDeviceRegProp *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETDEVICEREGPROP]; + + r = talloc(talloc_tos(), struct PNP_GetDeviceRegProp); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDeviceRegProp, r); + } + + _PNP_GetDeviceRegProp(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDeviceRegProp, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_SetDeviceRegProp(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_SetDeviceRegProp *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_SETDEVICEREGPROP]; + + r = talloc(talloc_tos(), struct PNP_SetDeviceRegProp); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_SetDeviceRegProp, r); + } + + _PNP_SetDeviceRegProp(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_SetDeviceRegProp, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetClassInstance(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetClassInstance *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETCLASSINSTANCE]; + + r = talloc(talloc_tos(), struct PNP_GetClassInstance); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetClassInstance, r); + } + + _PNP_GetClassInstance(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetClassInstance, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_CreateKey(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_CreateKey *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_CREATEKEY]; + + r = talloc(talloc_tos(), struct PNP_CreateKey); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_CreateKey, r); + } + + _PNP_CreateKey(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_CreateKey, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_DeleteRegistryKey(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_DeleteRegistryKey *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_DELETEREGISTRYKEY]; + + r = talloc(talloc_tos(), struct PNP_DeleteRegistryKey); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DeleteRegistryKey, r); + } + + _PNP_DeleteRegistryKey(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DeleteRegistryKey, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetClassCount(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetClassCount *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETCLASSCOUNT]; + + r = talloc(talloc_tos(), struct PNP_GetClassCount); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetClassCount, r); + } + + _PNP_GetClassCount(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetClassCount, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetClassName(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetClassName *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETCLASSNAME]; + + r = talloc(talloc_tos(), struct PNP_GetClassName); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetClassName, r); + } + + _PNP_GetClassName(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetClassName, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_DeleteClassKey(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_DeleteClassKey *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_DELETECLASSKEY]; + + r = talloc(talloc_tos(), struct PNP_DeleteClassKey); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DeleteClassKey, r); + } + + _PNP_DeleteClassKey(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DeleteClassKey, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetInterfaceDeviceAlias(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetInterfaceDeviceAlias *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETINTERFACEDEVICEALIAS]; + + r = talloc(talloc_tos(), struct PNP_GetInterfaceDeviceAlias); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceAlias, r); + } + + _PNP_GetInterfaceDeviceAlias(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceAlias, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetInterfaceDeviceList(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetInterfaceDeviceList *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETINTERFACEDEVICELIST]; + + r = talloc(talloc_tos(), struct PNP_GetInterfaceDeviceList); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceList, r); + } + + _PNP_GetInterfaceDeviceList(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceList, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetInterfaceDeviceListSize(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetInterfaceDeviceListSize *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETINTERFACEDEVICELISTSIZE]; + + r = talloc(talloc_tos(), struct PNP_GetInterfaceDeviceListSize); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceListSize, r); + } + + _PNP_GetInterfaceDeviceListSize(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceListSize, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_RegisterDeviceClassAssociation(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_RegisterDeviceClassAssociation *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_REGISTERDEVICECLASSASSOCIATION]; + + r = talloc(talloc_tos(), struct PNP_RegisterDeviceClassAssociation); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RegisterDeviceClassAssociation, r); + } + + _PNP_RegisterDeviceClassAssociation(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RegisterDeviceClassAssociation, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_UnregisterDeviceClassAssociation(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_UnregisterDeviceClassAssociation *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_UNREGISTERDEVICECLASSASSOCIATION]; + + r = talloc(talloc_tos(), struct PNP_UnregisterDeviceClassAssociation); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_UnregisterDeviceClassAssociation, r); + } + + _PNP_UnregisterDeviceClassAssociation(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_UnregisterDeviceClassAssociation, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetClassRegProp(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetClassRegProp *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETCLASSREGPROP]; + + r = talloc(talloc_tos(), struct PNP_GetClassRegProp); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetClassRegProp, r); + } + + _PNP_GetClassRegProp(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetClassRegProp, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_SetClassRegProp(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_SetClassRegProp *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_SETCLASSREGPROP]; + + r = talloc(talloc_tos(), struct PNP_SetClassRegProp); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_SetClassRegProp, r); + } + + _PNP_SetClassRegProp(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_SetClassRegProp, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_CreateDevInst(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_CreateDevInst *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_CREATEDEVINST]; + + r = talloc(talloc_tos(), struct PNP_CreateDevInst); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_CreateDevInst, r); + } + + _PNP_CreateDevInst(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_CreateDevInst, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_DeviceInstanceAction(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_DeviceInstanceAction *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_DEVICEINSTANCEACTION]; + + r = talloc(talloc_tos(), struct PNP_DeviceInstanceAction); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DeviceInstanceAction, r); + } + + _PNP_DeviceInstanceAction(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DeviceInstanceAction, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetDeviceStatus(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetDeviceStatus *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETDEVICESTATUS]; + + r = talloc(talloc_tos(), struct PNP_GetDeviceStatus); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetDeviceStatus, r); + } + + _PNP_GetDeviceStatus(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetDeviceStatus, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_SetDeviceProblem(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_SetDeviceProblem *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_SETDEVICEPROBLEM]; + + r = talloc(talloc_tos(), struct PNP_SetDeviceProblem); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_SetDeviceProblem, r); + } + + _PNP_SetDeviceProblem(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_SetDeviceProblem, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_DisableDevInst(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_DisableDevInst *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_DISABLEDEVINST]; + + r = talloc(talloc_tos(), struct PNP_DisableDevInst); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DisableDevInst, r); + } + + _PNP_DisableDevInst(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DisableDevInst, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_UninstallDevInst(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_UninstallDevInst *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_UNINSTALLDEVINST]; + + r = talloc(talloc_tos(), struct PNP_UninstallDevInst); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_UninstallDevInst, r); + } + + _PNP_UninstallDevInst(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_UninstallDevInst, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_AddID(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_AddID *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_ADDID]; + + r = talloc(talloc_tos(), struct PNP_AddID); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_AddID, r); + } + + _PNP_AddID(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_AddID, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_RegisterDriver(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_RegisterDriver *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_REGISTERDRIVER]; + + r = talloc(talloc_tos(), struct PNP_RegisterDriver); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RegisterDriver, r); + } + + _PNP_RegisterDriver(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RegisterDriver, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_QueryRemove(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_QueryRemove *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_QUERYREMOVE]; + + r = talloc(talloc_tos(), struct PNP_QueryRemove); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_QueryRemove, r); + } + + _PNP_QueryRemove(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_QueryRemove, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_RequestDeviceEject(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_RequestDeviceEject *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_REQUESTDEVICEEJECT]; + + r = talloc(talloc_tos(), struct PNP_RequestDeviceEject); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RequestDeviceEject, r); + } + + _PNP_RequestDeviceEject(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RequestDeviceEject, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_IsDockStationPresent(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_IsDockStationPresent *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_ISDOCKSTATIONPRESENT]; + + r = talloc(talloc_tos(), struct PNP_IsDockStationPresent); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_IsDockStationPresent, r); + } + + _PNP_IsDockStationPresent(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_IsDockStationPresent, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_RequestEjectPC(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_RequestEjectPC *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_REQUESTEJECTPC]; + + r = talloc(talloc_tos(), struct PNP_RequestEjectPC); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RequestEjectPC, r); + } + + _PNP_RequestEjectPC(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RequestEjectPC, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_HwProfFlags(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_HwProfFlags *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_HWPROFFLAGS]; + + r = talloc(talloc_tos(), struct PNP_HwProfFlags); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_HwProfFlags, r); + } + + _PNP_HwProfFlags(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_HwProfFlags, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetHwProfInfo(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetHwProfInfo *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETHWPROFINFO]; + + r = talloc(talloc_tos(), struct PNP_GetHwProfInfo); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetHwProfInfo, r); + } + + _PNP_GetHwProfInfo(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetHwProfInfo, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_AddEmptyLogConf(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_AddEmptyLogConf *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_ADDEMPTYLOGCONF]; + + r = talloc(talloc_tos(), struct PNP_AddEmptyLogConf); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_AddEmptyLogConf, r); + } + + _PNP_AddEmptyLogConf(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_AddEmptyLogConf, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_FreeLogConf(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_FreeLogConf *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_FREELOGCONF]; + + r = talloc(talloc_tos(), struct PNP_FreeLogConf); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_FreeLogConf, r); + } + + _PNP_FreeLogConf(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_FreeLogConf, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetFirstLogConf(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetFirstLogConf *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETFIRSTLOGCONF]; + + r = talloc(talloc_tos(), struct PNP_GetFirstLogConf); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetFirstLogConf, r); + } + + _PNP_GetFirstLogConf(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetFirstLogConf, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetNextLogConf(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetNextLogConf *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETNEXTLOGCONF]; + + r = talloc(talloc_tos(), struct PNP_GetNextLogConf); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetNextLogConf, r); + } + + _PNP_GetNextLogConf(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetNextLogConf, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetLogConfPriority(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetLogConfPriority *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETLOGCONFPRIORITY]; + + r = talloc(talloc_tos(), struct PNP_GetLogConfPriority); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetLogConfPriority, r); + } + + _PNP_GetLogConfPriority(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetLogConfPriority, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_AddResDes(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_AddResDes *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_ADDRESDES]; + + r = talloc(talloc_tos(), struct PNP_AddResDes); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_AddResDes, r); + } + + _PNP_AddResDes(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_AddResDes, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_FreeResDes(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_FreeResDes *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_FREERESDES]; + + r = talloc(talloc_tos(), struct PNP_FreeResDes); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_FreeResDes, r); + } + + _PNP_FreeResDes(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_FreeResDes, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetNextResDes(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetNextResDes *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETNEXTRESDES]; + + r = talloc(talloc_tos(), struct PNP_GetNextResDes); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetNextResDes, r); + } + + _PNP_GetNextResDes(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetNextResDes, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetResDesData(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetResDesData *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETRESDESDATA]; + + r = talloc(talloc_tos(), struct PNP_GetResDesData); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetResDesData, r); + } + + _PNP_GetResDesData(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetResDesData, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetResDesDataSize(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetResDesDataSize *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETRESDESDATASIZE]; + + r = talloc(talloc_tos(), struct PNP_GetResDesDataSize); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetResDesDataSize, r); + } + + _PNP_GetResDesDataSize(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetResDesDataSize, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_ModifyResDes(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_ModifyResDes *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_MODIFYRESDES]; + + r = talloc(talloc_tos(), struct PNP_ModifyResDes); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_ModifyResDes, r); + } + + _PNP_ModifyResDes(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_ModifyResDes, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_DetectResourceLimit(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_DetectResourceLimit *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_DETECTRESOURCELIMIT]; + + r = talloc(talloc_tos(), struct PNP_DetectResourceLimit); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_DetectResourceLimit, r); + } + + _PNP_DetectResourceLimit(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_DetectResourceLimit, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_QueryResConfList(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_QueryResConfList *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_QUERYRESCONFLIST]; + + r = talloc(talloc_tos(), struct PNP_QueryResConfList); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_QueryResConfList, r); + } + + _PNP_QueryResConfList(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_QueryResConfList, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_SetHwProf(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_SetHwProf *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_SETHWPROF]; + + r = talloc(talloc_tos(), struct PNP_SetHwProf); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_SetHwProf, r); + } + + _PNP_SetHwProf(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_SetHwProf, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_QueryArbitratorFreeData(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_QueryArbitratorFreeData *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_QUERYARBITRATORFREEDATA]; + + r = talloc(talloc_tos(), struct PNP_QueryArbitratorFreeData); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_QueryArbitratorFreeData, r); + } + + _PNP_QueryArbitratorFreeData(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_QueryArbitratorFreeData, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_QueryArbitratorFreeSize(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_QueryArbitratorFreeSize *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_QUERYARBITRATORFREESIZE]; + + r = talloc(talloc_tos(), struct PNP_QueryArbitratorFreeSize); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_QueryArbitratorFreeSize, r); + } + + _PNP_QueryArbitratorFreeSize(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_QueryArbitratorFreeSize, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_RunDetection(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_RunDetection *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_RUNDETECTION]; + + r = talloc(talloc_tos(), struct PNP_RunDetection); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RunDetection, r); + } + + _PNP_RunDetection(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RunDetection, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_RegisterNotification(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_RegisterNotification *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_REGISTERNOTIFICATION]; + + r = talloc(talloc_tos(), struct PNP_RegisterNotification); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_RegisterNotification, r); + } + + _PNP_RegisterNotification(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_RegisterNotification, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_UnregisterNotification(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_UnregisterNotification *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_UNREGISTERNOTIFICATION]; + + r = talloc(talloc_tos(), struct PNP_UnregisterNotification); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_UnregisterNotification, r); + } + + _PNP_UnregisterNotification(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_UnregisterNotification, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetCustomDevProp(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetCustomDevProp *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETCUSTOMDEVPROP]; + + r = talloc(talloc_tos(), struct PNP_GetCustomDevProp); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetCustomDevProp, r); + } + + _PNP_GetCustomDevProp(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetCustomDevProp, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetVersionInternal(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetVersionInternal *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETVERSIONINTERNAL]; + + r = talloc(talloc_tos(), struct PNP_GetVersionInternal); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetVersionInternal, r); + } + + _PNP_GetVersionInternal(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetVersionInternal, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetBlockedDriverInfo(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetBlockedDriverInfo *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETBLOCKEDDRIVERINFO]; + + r = talloc(talloc_tos(), struct PNP_GetBlockedDriverInfo); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetBlockedDriverInfo, r); + } + + _PNP_GetBlockedDriverInfo(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetBlockedDriverInfo, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_PNP_GetServerSideDeviceInstallFlags(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct PNP_GetServerSideDeviceInstallFlags *r; + + call = &ndr_table_ntsvcs.calls[NDR_PNP_GETSERVERSIDEDEVICEINSTALLFLAGS]; + + r = talloc(talloc_tos(), struct PNP_GetServerSideDeviceInstallFlags); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(PNP_GetServerSideDeviceInstallFlags, r); + } + + _PNP_GetServerSideDeviceInstallFlags(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(PNP_GetServerSideDeviceInstallFlags, r); + } + + push = ndr_push_init_ctx(r); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + + +/* Tables */ +static struct api_struct api_ntsvcs_cmds[] = +{ + {"PNP_DISCONNECT", NDR_PNP_DISCONNECT, api_PNP_Disconnect}, + {"PNP_CONNECT", NDR_PNP_CONNECT, api_PNP_Connect}, + {"PNP_GETVERSION", NDR_PNP_GETVERSION, api_PNP_GetVersion}, + {"PNP_GETGLOBALSTATE", NDR_PNP_GETGLOBALSTATE, api_PNP_GetGlobalState}, + {"PNP_INITDETECTION", NDR_PNP_INITDETECTION, api_PNP_InitDetection}, + {"PNP_REPORTLOGON", NDR_PNP_REPORTLOGON, api_PNP_ReportLogOn}, + {"PNP_VALIDATEDEVICEINSTANCE", NDR_PNP_VALIDATEDEVICEINSTANCE, api_PNP_ValidateDeviceInstance}, + {"PNP_GETROOTDEVICEINSTANCE", NDR_PNP_GETROOTDEVICEINSTANCE, api_PNP_GetRootDeviceInstance}, + {"PNP_GETRELATEDDEVICEINSTANCE", NDR_PNP_GETRELATEDDEVICEINSTANCE, api_PNP_GetRelatedDeviceInstance}, + {"PNP_ENUMERATESUBKEYS", NDR_PNP_ENUMERATESUBKEYS, api_PNP_EnumerateSubKeys}, + {"PNP_GETDEVICELIST", NDR_PNP_GETDEVICELIST, api_PNP_GetDeviceList}, + {"PNP_GETDEVICELISTSIZE", NDR_PNP_GETDEVICELISTSIZE, api_PNP_GetDeviceListSize}, + {"PNP_GETDEPTH", NDR_PNP_GETDEPTH, api_PNP_GetDepth}, + {"PNP_GETDEVICEREGPROP", NDR_PNP_GETDEVICEREGPROP, api_PNP_GetDeviceRegProp}, + {"PNP_SETDEVICEREGPROP", NDR_PNP_SETDEVICEREGPROP, api_PNP_SetDeviceRegProp}, + {"PNP_GETCLASSINSTANCE", NDR_PNP_GETCLASSINSTANCE, api_PNP_GetClassInstance}, + {"PNP_CREATEKEY", NDR_PNP_CREATEKEY, api_PNP_CreateKey}, + {"PNP_DELETEREGISTRYKEY", NDR_PNP_DELETEREGISTRYKEY, api_PNP_DeleteRegistryKey}, + {"PNP_GETCLASSCOUNT", NDR_PNP_GETCLASSCOUNT, api_PNP_GetClassCount}, + {"PNP_GETCLASSNAME", NDR_PNP_GETCLASSNAME, api_PNP_GetClassName}, + {"PNP_DELETECLASSKEY", NDR_PNP_DELETECLASSKEY, api_PNP_DeleteClassKey}, + {"PNP_GETINTERFACEDEVICEALIAS", NDR_PNP_GETINTERFACEDEVICEALIAS, api_PNP_GetInterfaceDeviceAlias}, + {"PNP_GETINTERFACEDEVICELIST", NDR_PNP_GETINTERFACEDEVICELIST, api_PNP_GetInterfaceDeviceList}, + {"PNP_GETINTERFACEDEVICELISTSIZE", NDR_PNP_GETINTERFACEDEVICELISTSIZE, api_PNP_GetInterfaceDeviceListSize}, + {"PNP_REGISTERDEVICECLASSASSOCIATION", NDR_PNP_REGISTERDEVICECLASSASSOCIATION, api_PNP_RegisterDeviceClassAssociation}, + {"PNP_UNREGISTERDEVICECLASSASSOCIATION", NDR_PNP_UNREGISTERDEVICECLASSASSOCIATION, api_PNP_UnregisterDeviceClassAssociation}, + {"PNP_GETCLASSREGPROP", NDR_PNP_GETCLASSREGPROP, api_PNP_GetClassRegProp}, + {"PNP_SETCLASSREGPROP", NDR_PNP_SETCLASSREGPROP, api_PNP_SetClassRegProp}, + {"PNP_CREATEDEVINST", NDR_PNP_CREATEDEVINST, api_PNP_CreateDevInst}, + {"PNP_DEVICEINSTANCEACTION", NDR_PNP_DEVICEINSTANCEACTION, api_PNP_DeviceInstanceAction}, + {"PNP_GETDEVICESTATUS", NDR_PNP_GETDEVICESTATUS, api_PNP_GetDeviceStatus}, + {"PNP_SETDEVICEPROBLEM", NDR_PNP_SETDEVICEPROBLEM, api_PNP_SetDeviceProblem}, + {"PNP_DISABLEDEVINST", NDR_PNP_DISABLEDEVINST, api_PNP_DisableDevInst}, + {"PNP_UNINSTALLDEVINST", NDR_PNP_UNINSTALLDEVINST, api_PNP_UninstallDevInst}, + {"PNP_ADDID", NDR_PNP_ADDID, api_PNP_AddID}, + {"PNP_REGISTERDRIVER", NDR_PNP_REGISTERDRIVER, api_PNP_RegisterDriver}, + {"PNP_QUERYREMOVE", NDR_PNP_QUERYREMOVE, api_PNP_QueryRemove}, + {"PNP_REQUESTDEVICEEJECT", NDR_PNP_REQUESTDEVICEEJECT, api_PNP_RequestDeviceEject}, + {"PNP_ISDOCKSTATIONPRESENT", NDR_PNP_ISDOCKSTATIONPRESENT, api_PNP_IsDockStationPresent}, + {"PNP_REQUESTEJECTPC", NDR_PNP_REQUESTEJECTPC, api_PNP_RequestEjectPC}, + {"PNP_HWPROFFLAGS", NDR_PNP_HWPROFFLAGS, api_PNP_HwProfFlags}, + {"PNP_GETHWPROFINFO", NDR_PNP_GETHWPROFINFO, api_PNP_GetHwProfInfo}, + {"PNP_ADDEMPTYLOGCONF", NDR_PNP_ADDEMPTYLOGCONF, api_PNP_AddEmptyLogConf}, + {"PNP_FREELOGCONF", NDR_PNP_FREELOGCONF, api_PNP_FreeLogConf}, + {"PNP_GETFIRSTLOGCONF", NDR_PNP_GETFIRSTLOGCONF, api_PNP_GetFirstLogConf}, + {"PNP_GETNEXTLOGCONF", NDR_PNP_GETNEXTLOGCONF, api_PNP_GetNextLogConf}, + {"PNP_GETLOGCONFPRIORITY", NDR_PNP_GETLOGCONFPRIORITY, api_PNP_GetLogConfPriority}, + {"PNP_ADDRESDES", NDR_PNP_ADDRESDES, api_PNP_AddResDes}, + {"PNP_FREERESDES", NDR_PNP_FREERESDES, api_PNP_FreeResDes}, + {"PNP_GETNEXTRESDES", NDR_PNP_GETNEXTRESDES, api_PNP_GetNextResDes}, + {"PNP_GETRESDESDATA", NDR_PNP_GETRESDESDATA, api_PNP_GetResDesData}, + {"PNP_GETRESDESDATASIZE", NDR_PNP_GETRESDESDATASIZE, api_PNP_GetResDesDataSize}, + {"PNP_MODIFYRESDES", NDR_PNP_MODIFYRESDES, api_PNP_ModifyResDes}, + {"PNP_DETECTRESOURCELIMIT", NDR_PNP_DETECTRESOURCELIMIT, api_PNP_DetectResourceLimit}, + {"PNP_QUERYRESCONFLIST", NDR_PNP_QUERYRESCONFLIST, api_PNP_QueryResConfList}, + {"PNP_SETHWPROF", NDR_PNP_SETHWPROF, api_PNP_SetHwProf}, + {"PNP_QUERYARBITRATORFREEDATA", NDR_PNP_QUERYARBITRATORFREEDATA, api_PNP_QueryArbitratorFreeData}, + {"PNP_QUERYARBITRATORFREESIZE", NDR_PNP_QUERYARBITRATORFREESIZE, api_PNP_QueryArbitratorFreeSize}, + {"PNP_RUNDETECTION", NDR_PNP_RUNDETECTION, api_PNP_RunDetection}, + {"PNP_REGISTERNOTIFICATION", NDR_PNP_REGISTERNOTIFICATION, api_PNP_RegisterNotification}, + {"PNP_UNREGISTERNOTIFICATION", NDR_PNP_UNREGISTERNOTIFICATION, api_PNP_UnregisterNotification}, + {"PNP_GETCUSTOMDEVPROP", NDR_PNP_GETCUSTOMDEVPROP, api_PNP_GetCustomDevProp}, + {"PNP_GETVERSIONINTERNAL", NDR_PNP_GETVERSIONINTERNAL, api_PNP_GetVersionInternal}, + {"PNP_GETBLOCKEDDRIVERINFO", NDR_PNP_GETBLOCKEDDRIVERINFO, api_PNP_GetBlockedDriverInfo}, + {"PNP_GETSERVERSIDEDEVICEINSTALLFLAGS", NDR_PNP_GETSERVERSIDEDEVICEINSTALLFLAGS, api_PNP_GetServerSideDeviceInstallFlags}, +}; + +void ntsvcs_get_pipe_fns(struct api_struct **fns, int *n_fns) +{ + *fns = api_ntsvcs_cmds; + *n_fns = sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_ntsvcs_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "ntsvcs", "ntsvcs", api_ntsvcs_cmds, sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct)); +} diff --git a/source3/librpc/gen_ndr/srv_ntsvcs.h b/source3/librpc/gen_ndr/srv_ntsvcs.h new file mode 100644 index 0000000000..0bcd09183e --- /dev/null +++ b/source3/librpc/gen_ndr/srv_ntsvcs.h @@ -0,0 +1,71 @@ +#include "librpc/gen_ndr/ndr_ntsvcs.h" +#ifndef __SRV_NTSVCS__ +#define __SRV_NTSVCS__ +void _PNP_Disconnect(pipes_struct *p, struct PNP_Disconnect *r); +void _PNP_Connect(pipes_struct *p, struct PNP_Connect *r); +void _PNP_GetVersion(pipes_struct *p, struct PNP_GetVersion *r); +void _PNP_GetGlobalState(pipes_struct *p, struct PNP_GetGlobalState *r); +void _PNP_InitDetection(pipes_struct *p, struct PNP_InitDetection *r); +void _PNP_ReportLogOn(pipes_struct *p, struct PNP_ReportLogOn *r); +void _PNP_ValidateDeviceInstance(pipes_struct *p, struct PNP_ValidateDeviceInstance *r); +void _PNP_GetRootDeviceInstance(pipes_struct *p, struct PNP_GetRootDeviceInstance *r); +void _PNP_GetRelatedDeviceInstance(pipes_struct *p, struct PNP_GetRelatedDeviceInstance *r); +void _PNP_EnumerateSubKeys(pipes_struct *p, struct PNP_EnumerateSubKeys *r); +void _PNP_GetDeviceList(pipes_struct *p, struct PNP_GetDeviceList *r); +void _PNP_GetDeviceListSize(pipes_struct *p, struct PNP_GetDeviceListSize *r); +void _PNP_GetDepth(pipes_struct *p, struct PNP_GetDepth *r); +void _PNP_GetDeviceRegProp(pipes_struct *p, struct PNP_GetDeviceRegProp *r); +void _PNP_SetDeviceRegProp(pipes_struct *p, struct PNP_SetDeviceRegProp *r); +void _PNP_GetClassInstance(pipes_struct *p, struct PNP_GetClassInstance *r); +void _PNP_CreateKey(pipes_struct *p, struct PNP_CreateKey *r); +void _PNP_DeleteRegistryKey(pipes_struct *p, struct PNP_DeleteRegistryKey *r); +void _PNP_GetClassCount(pipes_struct *p, struct PNP_GetClassCount *r); +void _PNP_GetClassName(pipes_struct *p, struct PNP_GetClassName *r); +void _PNP_DeleteClassKey(pipes_struct *p, struct PNP_DeleteClassKey *r); +void _PNP_GetInterfaceDeviceAlias(pipes_struct *p, struct PNP_GetInterfaceDeviceAlias *r); +void _PNP_GetInterfaceDeviceList(pipes_struct *p, struct PNP_GetInterfaceDeviceList *r); +void _PNP_GetInterfaceDeviceListSize(pipes_struct *p, struct PNP_GetInterfaceDeviceListSize *r); +void _PNP_RegisterDeviceClassAssociation(pipes_struct *p, struct PNP_RegisterDeviceClassAssociation *r); +void _PNP_UnregisterDeviceClassAssociation(pipes_struct *p, struct PNP_UnregisterDeviceClassAssociation *r); +void _PNP_GetClassRegProp(pipes_struct *p, struct PNP_GetClassRegProp *r); +void _PNP_SetClassRegProp(pipes_struct *p, struct PNP_SetClassRegProp *r); +void _PNP_CreateDevInst(pipes_struct *p, struct PNP_CreateDevInst *r); +void _PNP_DeviceInstanceAction(pipes_struct *p, struct PNP_DeviceInstanceAction *r); +void _PNP_GetDeviceStatus(pipes_struct *p, struct PNP_GetDeviceStatus *r); +void _PNP_SetDeviceProblem(pipes_struct *p, struct PNP_SetDeviceProblem *r); +void _PNP_DisableDevInst(pipes_struct *p, struct PNP_DisableDevInst *r); +void _PNP_UninstallDevInst(pipes_struct *p, struct PNP_UninstallDevInst *r); +void _PNP_AddID(pipes_struct *p, struct PNP_AddID *r); +void _PNP_RegisterDriver(pipes_struct *p, struct PNP_RegisterDriver *r); +void _PNP_QueryRemove(pipes_struct *p, struct PNP_QueryRemove *r); +void _PNP_RequestDeviceEject(pipes_struct *p, struct PNP_RequestDeviceEject *r); +void _PNP_IsDockStationPresent(pipes_struct *p, struct PNP_IsDockStationPresent *r); +void _PNP_RequestEjectPC(pipes_struct *p, struct PNP_RequestEjectPC *r); +void _PNP_HwProfFlags(pipes_struct *p, struct PNP_HwProfFlags *r); +void _PNP_GetHwProfInfo(pipes_struct *p, struct PNP_GetHwProfInfo *r); +void _PNP_AddEmptyLogConf(pipes_struct *p, struct PNP_AddEmptyLogConf *r); +void _PNP_FreeLogConf(pipes_struct *p, struct PNP_FreeLogConf *r); +void _PNP_GetFirstLogConf(pipes_struct *p, struct PNP_GetFirstLogConf *r); +void _PNP_GetNextLogConf(pipes_struct *p, struct PNP_GetNextLogConf *r); +void _PNP_GetLogConfPriority(pipes_struct *p, struct PNP_GetLogConfPriority *r); +void _PNP_AddResDes(pipes_struct *p, struct PNP_AddResDes *r); +void _PNP_FreeResDes(pipes_struct *p, struct PNP_FreeResDes *r); +void _PNP_GetNextResDes(pipes_struct *p, struct PNP_GetNextResDes *r); +void _PNP_GetResDesData(pipes_struct *p, struct PNP_GetResDesData *r); +void _PNP_GetResDesDataSize(pipes_struct *p, struct PNP_GetResDesDataSize *r); +void _PNP_ModifyResDes(pipes_struct *p, struct PNP_ModifyResDes *r); +void _PNP_DetectResourceLimit(pipes_struct *p, struct PNP_DetectResourceLimit *r); +void _PNP_QueryResConfList(pipes_struct *p, struct PNP_QueryResConfList *r); +void _PNP_SetHwProf(pipes_struct *p, struct PNP_SetHwProf *r); +void _PNP_QueryArbitratorFreeData(pipes_struct *p, struct PNP_QueryArbitratorFreeData *r); +void _PNP_QueryArbitratorFreeSize(pipes_struct *p, struct PNP_QueryArbitratorFreeSize *r); +void _PNP_RunDetection(pipes_struct *p, struct PNP_RunDetection *r); +void _PNP_RegisterNotification(pipes_struct *p, struct PNP_RegisterNotification *r); +void _PNP_UnregisterNotification(pipes_struct *p, struct PNP_UnregisterNotification *r); +void _PNP_GetCustomDevProp(pipes_struct *p, struct PNP_GetCustomDevProp *r); +void _PNP_GetVersionInternal(pipes_struct *p, struct PNP_GetVersionInternal *r); +void _PNP_GetBlockedDriverInfo(pipes_struct *p, struct PNP_GetBlockedDriverInfo *r); +void _PNP_GetServerSideDeviceInstallFlags(pipes_struct *p, struct PNP_GetServerSideDeviceInstallFlags *r); +void ntsvcs_get_pipe_fns(struct api_struct **fns, int *n_fns); +NTSTATUS rpc_ntsvcs_init(void); +#endif /* __SRV_NTSVCS__ */ -- cgit From d8fcfb161540d3cb6d64f04b82dbf9590c1d5c9b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:03:22 +0100 Subject: Build the generated ntsvcs server (not at all useable yet). Guenther (This used to be commit acce1092d90db1f90265de44fd340d7df73e4e0e) --- source3/Makefile.in | 3 +- source3/configure.in | 4 +- source3/rpc_server/srv_ntsvcs.c | 25 +- source3/rpc_server/srv_ntsvcs_nt.c | 650 +++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_pipe.c | 2 +- 5 files changed, 678 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 250d3f98c5..f2971ff176 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -512,7 +512,8 @@ RPC_SVCCTL_OBJ = rpc_server/srv_svcctl.o rpc_server/srv_svcctl_nt.o \ services/svc_netlogon.o services/svc_winreg.o \ services/svc_wins.o -RPC_NTSVCS_OBJ = rpc_server/srv_ntsvcs.o rpc_server/srv_ntsvcs_nt.o +RPC_NTSVCS_OBJ = rpc_server/srv_ntsvcs.o rpc_server/srv_ntsvcs_nt.o \ + librpc/gen_ndr/srv_ntsvcs.o RPC_DFS_OBJ = librpc/gen_ndr/srv_dfs.o rpc_server/srv_dfs_nt.o diff --git a/source3/configure.in b/source3/configure.in index 1f8efb9675..16c9ed916b 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -745,7 +745,7 @@ AC_SUBST(DYNEXP) dnl Add modules that have to be built by default here dnl These have to be built static: -default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template" +default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs2 rpc_netlogon rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template" dnl These are preferably build shared, and static if dlopen() is not available default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_syncops vfs_xattr_tdb vfs_streams_xattr" @@ -6615,7 +6615,7 @@ SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown. SMB_MODULE(rpc_dssetup, \$(RPC_DSSETUP_OBJ), "bin/librpc_dssetup.$SHLIBEXT", RPC) SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC) SMB_MODULE(rpc_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$SHLIBEXT", RPC) -SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC) +SMB_MODULE(rpc_ntsvcs2, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs2.$SHLIBEXT", RPC) SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC) SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC) SMB_MODULE(rpc_srvsvc2, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc2.$SHLIBEXT", RPC) diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index b3e93ac459..0734a60b4d 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -22,6 +22,27 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +/******************************************************************* + ********************************************************************/ + +static bool proxy_ntsvcs_call(pipes_struct *p, uint8_t opnum) +{ + struct api_struct *fns; + int n_fns; + + ntsvcs_get_pipe_fns(&fns, &n_fns); + + if (opnum >= n_fns) { + return false; + } + + if (fns[opnum].opnum != opnum) { + smb_panic("NTSVCS function table not sorted"); + } + + return fns[opnum].fn(p); +} + /******************************************************************* ********************************************************************/ @@ -206,13 +227,13 @@ static struct api_struct api_ntsvcs_cmds[] = }; -void ntsvcs_get_pipe_fns( struct api_struct **fns, int *n_fns ) +void ntsvcs2_get_pipe_fns( struct api_struct **fns, int *n_fns ) { *fns = api_ntsvcs_cmds; *n_fns = sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct); } -NTSTATUS rpc_ntsvcs_init(void) +NTSTATUS rpc_ntsvcs2_init(void) { return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "ntsvcs", "ntsvcs", api_ntsvcs_cmds, sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct)); diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 16c74c5d6d..c7ca0df097 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -174,3 +174,653 @@ WERROR _ntsvcs_hw_profile_flags( pipes_struct *p, NTSVCS_Q_HW_PROFILE_FLAGS *q_u return WERR_OK; } +/**************************************************************** +****************************************************************/ + +WERROR _PNP_Disconnect(pipes_struct *p, + struct PNP_Disconnect *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_Connect(pipes_struct *p, + struct PNP_Connect *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetVersion(pipes_struct *p, + struct PNP_GetVersion *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetGlobalState(pipes_struct *p, + struct PNP_GetGlobalState *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_InitDetection(pipes_struct *p, + struct PNP_InitDetection *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_ReportLogOn(pipes_struct *p, + struct PNP_ReportLogOn *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, + struct PNP_ValidateDeviceInstance *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetRootDeviceInstance(pipes_struct *p, + struct PNP_GetRootDeviceInstance *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetRelatedDeviceInstance(pipes_struct *p, + struct PNP_GetRelatedDeviceInstance *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_EnumerateSubKeys(pipes_struct *p, + struct PNP_EnumerateSubKeys *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDeviceList(pipes_struct *p, + struct PNP_GetDeviceList *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDeviceListSize(pipes_struct *p, + struct PNP_GetDeviceListSize *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDepth(pipes_struct *p, + struct PNP_GetDepth *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDeviceRegProp(pipes_struct *p, + struct PNP_GetDeviceRegProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_SetDeviceRegProp(pipes_struct *p, + struct PNP_SetDeviceRegProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetClassInstance(pipes_struct *p, + struct PNP_GetClassInstance *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_CreateKey(pipes_struct *p, + struct PNP_CreateKey *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DeleteRegistryKey(pipes_struct *p, + struct PNP_DeleteRegistryKey *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetClassCount(pipes_struct *p, + struct PNP_GetClassCount *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetClassName(pipes_struct *p, + struct PNP_GetClassName *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DeleteClassKey(pipes_struct *p, + struct PNP_DeleteClassKey *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetInterfaceDeviceAlias(pipes_struct *p, + struct PNP_GetInterfaceDeviceAlias *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetInterfaceDeviceList(pipes_struct *p, + struct PNP_GetInterfaceDeviceList *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetInterfaceDeviceListSize(pipes_struct *p, + struct PNP_GetInterfaceDeviceListSize *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RegisterDeviceClassAssociation(pipes_struct *p, + struct PNP_RegisterDeviceClassAssociation *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_UnregisterDeviceClassAssociation(pipes_struct *p, + struct PNP_UnregisterDeviceClassAssociation *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetClassRegProp(pipes_struct *p, + struct PNP_GetClassRegProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_SetClassRegProp(pipes_struct *p, + struct PNP_SetClassRegProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_CreateDevInst(pipes_struct *p, + struct PNP_CreateDevInst *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DeviceInstanceAction(pipes_struct *p, + struct PNP_DeviceInstanceAction *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDeviceStatus(pipes_struct *p, + struct PNP_GetDeviceStatus *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_SetDeviceProblem(pipes_struct *p, + struct PNP_SetDeviceProblem *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DisableDevInst(pipes_struct *p, + struct PNP_DisableDevInst *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_UninstallDevInst(pipes_struct *p, + struct PNP_UninstallDevInst *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_AddID(pipes_struct *p, + struct PNP_AddID *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RegisterDriver(pipes_struct *p, + struct PNP_RegisterDriver *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_QueryRemove(pipes_struct *p, + struct PNP_QueryRemove *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RequestDeviceEject(pipes_struct *p, + struct PNP_RequestDeviceEject *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_IsDockStationPresent(pipes_struct *p, + struct PNP_IsDockStationPresent *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RequestEjectPC(pipes_struct *p, + struct PNP_RequestEjectPC *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_HwProfFlags(pipes_struct *p, + struct PNP_HwProfFlags *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetHwProfInfo(pipes_struct *p, + struct PNP_GetHwProfInfo *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_AddEmptyLogConf(pipes_struct *p, + struct PNP_AddEmptyLogConf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_FreeLogConf(pipes_struct *p, + struct PNP_FreeLogConf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetFirstLogConf(pipes_struct *p, + struct PNP_GetFirstLogConf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetNextLogConf(pipes_struct *p, + struct PNP_GetNextLogConf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetLogConfPriority(pipes_struct *p, + struct PNP_GetLogConfPriority *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_AddResDes(pipes_struct *p, + struct PNP_AddResDes *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_FreeResDes(pipes_struct *p, + struct PNP_FreeResDes *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetNextResDes(pipes_struct *p, + struct PNP_GetNextResDes *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetResDesData(pipes_struct *p, + struct PNP_GetResDesData *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetResDesDataSize(pipes_struct *p, + struct PNP_GetResDesDataSize *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_ModifyResDes(pipes_struct *p, + struct PNP_ModifyResDes *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DetectResourceLimit(pipes_struct *p, + struct PNP_DetectResourceLimit *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_QueryResConfList(pipes_struct *p, + struct PNP_QueryResConfList *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_SetHwProf(pipes_struct *p, + struct PNP_SetHwProf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_QueryArbitratorFreeData(pipes_struct *p, + struct PNP_QueryArbitratorFreeData *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_QueryArbitratorFreeSize(pipes_struct *p, + struct PNP_QueryArbitratorFreeSize *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RunDetection(pipes_struct *p, + struct PNP_RunDetection *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RegisterNotification(pipes_struct *p, + struct PNP_RegisterNotification *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_UnregisterNotification(pipes_struct *p, + struct PNP_UnregisterNotification *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetCustomDevProp(pipes_struct *p, + struct PNP_GetCustomDevProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetVersionInternal(pipes_struct *p, + struct PNP_GetVersionInternal *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetBlockedDriverInfo(pipes_struct *p, + struct PNP_GetBlockedDriverInfo *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetServerSideDeviceInstallFlags(pipes_struct *p, + struct PNP_GetServerSideDeviceInstallFlags *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index de9f22da1d..a7a7f9a389 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2409,7 +2409,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) eventlog2_get_pipe_fns( &cmds, &n_cmds ); break; case PI_NTSVCS: - ntsvcs_get_pipe_fns( &cmds, &n_cmds ); + ntsvcs2_get_pipe_fns( &cmds, &n_cmds ); break; #ifdef DEVELOPER case PI_RPCECHO: -- cgit From 6a98db8f954b15fb027404288061aa048e79c4f6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:13:38 +0100 Subject: Move all dummy ntsvcs calls to WERROR. Guenther (This used to be commit 76bc44ecfb550a1d2aac003d2131aa145897b31c) --- source3/librpc/idl/ntsvcs.idl | 389 +++++++++++++++++++++++++++++++++++------- 1 file changed, 324 insertions(+), 65 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/ntsvcs.idl b/source3/librpc/idl/ntsvcs.idl index 05ba68e727..1c4850b4c3 100644 --- a/source3/librpc/idl/ntsvcs.idl +++ b/source3/librpc/idl/ntsvcs.idl @@ -9,69 +9,328 @@ ] interface ntsvcs { - void PNP_Disconnect(); - void PNP_Connect(); - void PNP_GetVersion(); - void PNP_GetGlobalState(); - void PNP_InitDetection(); - void PNP_ReportLogOn(); - void PNP_ValidateDeviceInstance(); - void PNP_GetRootDeviceInstance(); - void PNP_GetRelatedDeviceInstance(); - void PNP_EnumerateSubKeys(); - void PNP_GetDeviceList(); - void PNP_GetDeviceListSize(); - void PNP_GetDepth(); - void PNP_GetDeviceRegProp(); - void PNP_SetDeviceRegProp(); - void PNP_GetClassInstance(); - void PNP_CreateKey(); - void PNP_DeleteRegistryKey(); - void PNP_GetClassCount(); - void PNP_GetClassName(); - void PNP_DeleteClassKey(); - void PNP_GetInterfaceDeviceAlias(); - void PNP_GetInterfaceDeviceList(); - void PNP_GetInterfaceDeviceListSize(); - void PNP_RegisterDeviceClassAssociation(); - void PNP_UnregisterDeviceClassAssociation(); - void PNP_GetClassRegProp(); - void PNP_SetClassRegProp(); - void PNP_CreateDevInst(); - void PNP_DeviceInstanceAction(); - void PNP_GetDeviceStatus(); - void PNP_SetDeviceProblem(); - void PNP_DisableDevInst(); - void PNP_UninstallDevInst(); - void PNP_AddID(); - void PNP_RegisterDriver(); - void PNP_QueryRemove(); - void PNP_RequestDeviceEject(); - void PNP_IsDockStationPresent(); - void PNP_RequestEjectPC(); - void PNP_HwProfFlags(); - void PNP_GetHwProfInfo(); - void PNP_AddEmptyLogConf(); - void PNP_FreeLogConf(); - void PNP_GetFirstLogConf(); - void PNP_GetNextLogConf(); - void PNP_GetLogConfPriority(); - void PNP_AddResDes(); - void PNP_FreeResDes(); - void PNP_GetNextResDes(); - void PNP_GetResDesData(); - void PNP_GetResDesDataSize(); - void PNP_ModifyResDes(); - void PNP_DetectResourceLimit(); - void PNP_QueryResConfList(); - void PNP_SetHwProf(); - void PNP_QueryArbitratorFreeData(); - void PNP_QueryArbitratorFreeSize(); - void PNP_RunDetection(); - void PNP_RegisterNotification(); - void PNP_UnregisterNotification(); - void PNP_GetCustomDevProp(); - void PNP_GetVersionInternal(); - void PNP_GetBlockedDriverInfo(); - void PNP_GetServerSideDeviceInstallFlags(); + /******************/ + /* Function: 0x00 */ + + WERROR PNP_Disconnect(); + + /******************/ + /* Function: 0x01 */ + + WERROR PNP_Connect(); + + /******************/ + /* Function: 0x02 */ + + WERROR PNP_GetVersion(); + + /******************/ + /* Function: 0x03 */ + + WERROR PNP_GetGlobalState(); + + /******************/ + /* Function: 0x04 */ + + WERROR PNP_InitDetection(); + + /******************/ + /* Function: 0x05 */ + + WERROR PNP_ReportLogOn(); + + /******************/ + /* Function: 0x06 */ + + WERROR PNP_ValidateDeviceInstance(); + + /******************/ + /* Function: 0x07 */ + + WERROR PNP_GetRootDeviceInstance(); + + /******************/ + /* Function: 0x08 */ + + WERROR PNP_GetRelatedDeviceInstance(); + + /******************/ + /* Function: 0x09 */ + + WERROR PNP_EnumerateSubKeys(); + + /******************/ + /* Function: 0x0a */ + + WERROR PNP_GetDeviceList(); + + /******************/ + /* Function: 0x0b */ + + WERROR PNP_GetDeviceListSize(); + + /******************/ + /* Function: 0x0c */ + + WERROR PNP_GetDepth(); + + /******************/ + /* Function: 0x0d */ + + WERROR PNP_GetDeviceRegProp(); + + /******************/ + /* Function: 0x0e */ + + WERROR PNP_SetDeviceRegProp(); + + /******************/ + /* Function: 0x0f */ + + WERROR PNP_GetClassInstance(); + + /******************/ + /* Function: 0x10 */ + + WERROR PNP_CreateKey(); + + /******************/ + /* Function: 0x11 */ + + WERROR PNP_DeleteRegistryKey(); + + /******************/ + /* Function: 0x12 */ + + WERROR PNP_GetClassCount(); + + /******************/ + /* Function: 0x13 */ + + WERROR PNP_GetClassName(); + + /******************/ + /* Function: 0x14 */ + + WERROR PNP_DeleteClassKey(); + + /******************/ + /* Function: 0x15 */ + + WERROR PNP_GetInterfaceDeviceAlias(); + + /******************/ + /* Function: 0x16 */ + + WERROR PNP_GetInterfaceDeviceList(); + + /******************/ + /* Function: 0x17 */ + + WERROR PNP_GetInterfaceDeviceListSize(); + + /******************/ + /* Function: 0x18 */ + + WERROR PNP_RegisterDeviceClassAssociation(); + + /******************/ + /* Function: 0x19 */ + + WERROR PNP_UnregisterDeviceClassAssociation(); + + /******************/ + /* Function: 0x1a */ + + WERROR PNP_GetClassRegProp(); + + /******************/ + /* Function: 0x1b */ + + WERROR PNP_SetClassRegProp(); + + /******************/ + /* Function: 0x1c */ + + WERROR PNP_CreateDevInst(); + + /******************/ + /* Function: 0x1d */ + + WERROR PNP_DeviceInstanceAction(); + + /******************/ + /* Function: 0x1e */ + + WERROR PNP_GetDeviceStatus(); + + /******************/ + /* Function: 0x1f */ + + WERROR PNP_SetDeviceProblem(); + + /******************/ + /* Function: 0x20 */ + + WERROR PNP_DisableDevInst(); + + /******************/ + /* Function: 0x21 */ + + WERROR PNP_UninstallDevInst(); + + /******************/ + /* Function: 0x22 */ + + WERROR PNP_AddID(); + + /******************/ + /* Function: 0x23 */ + + WERROR PNP_RegisterDriver(); + + /******************/ + /* Function: 0x24 */ + + WERROR PNP_QueryRemove(); + + /******************/ + /* Function: 0x25 */ + + WERROR PNP_RequestDeviceEject(); + + /******************/ + /* Function: 0x26 */ + + WERROR PNP_IsDockStationPresent(); + + /******************/ + /* Function: 0x27 */ + + WERROR PNP_RequestEjectPC(); + + /******************/ + /* Function: 0x28 */ + + WERROR PNP_HwProfFlags(); + + /******************/ + /* Function: 0x29 */ + + WERROR PNP_GetHwProfInfo(); + + /******************/ + /* Function: 0x2a */ + + WERROR PNP_AddEmptyLogConf(); + + /******************/ + /* Function: 0x2b */ + + WERROR PNP_FreeLogConf(); + + /******************/ + /* Function: 0x2c */ + + WERROR PNP_GetFirstLogConf(); + + /******************/ + /* Function: 0x2d */ + + WERROR PNP_GetNextLogConf(); + + /******************/ + /* Function: 0x2e */ + + WERROR PNP_GetLogConfPriority(); + + /******************/ + /* Function: 0x2f */ + + WERROR PNP_AddResDes(); + + /******************/ + /* Function: 0x30 */ + + WERROR PNP_FreeResDes(); + + /******************/ + /* Function: 0x31 */ + + WERROR PNP_GetNextResDes(); + + /******************/ + /* Function: 0x32 */ + + WERROR PNP_GetResDesData(); + + /******************/ + /* Function: 0x33 */ + + WERROR PNP_GetResDesDataSize(); + + /******************/ + /* Function: 0x34 */ + + WERROR PNP_ModifyResDes(); + + /******************/ + /* Function: 0x35 */ + + WERROR PNP_DetectResourceLimit(); + + /******************/ + /* Function: 0x36 */ + + WERROR PNP_QueryResConfList(); + + /******************/ + /* Function: 0x37 */ + + WERROR PNP_SetHwProf(); + + /******************/ + /* Function: 0x38 */ + + WERROR PNP_QueryArbitratorFreeData(); + + /******************/ + /* Function: 0x39 */ + + WERROR PNP_QueryArbitratorFreeSize(); + + /******************/ + /* Function: 0x3a */ + + WERROR PNP_RunDetection(); + + /******************/ + /* Function: 0x3b */ + + WERROR PNP_RegisterNotification(); + + /******************/ + /* Function: 0x3c */ + + WERROR PNP_UnregisterNotification(); + + /******************/ + /* Function: 0x3d */ + + WERROR PNP_GetCustomDevProp(); + + /******************/ + /* Function: 0x3e */ + + WERROR PNP_GetVersionInternal(); + + /******************/ + /* Function: 0x3f */ + + WERROR PNP_GetBlockedDriverInfo(); + + /******************/ + /* Function: 0x40 */ + + WERROR PNP_GetServerSideDeviceInstallFlags(); } -- cgit From addc906df5d978452a363c1e48e4b78701f66676 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:14:47 +0100 Subject: Fill in IDL for PNP_GetVersion (based from samba3). Guenther (This used to be commit fc438c7ad684acdfb074e5eb7a1a102a41535240) --- source3/librpc/idl/ntsvcs.idl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/ntsvcs.idl b/source3/librpc/idl/ntsvcs.idl index 1c4850b4c3..3c38bc3b91 100644 --- a/source3/librpc/idl/ntsvcs.idl +++ b/source3/librpc/idl/ntsvcs.idl @@ -22,7 +22,9 @@ interface ntsvcs /******************/ /* Function: 0x02 */ - WERROR PNP_GetVersion(); + WERROR PNP_GetVersion( + [out,ref] uint16 *version + ); /******************/ /* Function: 0x03 */ -- cgit From 95103fe6383614c364ed745b3c09a743bc52e060 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:29:35 +0100 Subject: Re-run make idl. Guenther (This used to be commit 2a86e2f2d26886cfe87149dfc4f17049b21cb109) --- source3/librpc/gen_ndr/cli_ntsvcs.c | 587 ++++++++++++++++++++++++++++-------- source3/librpc/gen_ndr/cli_ntsvcs.h | 196 ++++++++---- source3/librpc/gen_ndr/ndr_ntsvcs.c | 215 +++++++++++++ source3/librpc/gen_ndr/ntsvcs.h | 326 ++++++++++++++++---- source3/librpc/gen_ndr/srv_ntsvcs.c | 137 +++++---- source3/librpc/gen_ndr/srv_ntsvcs.h | 130 ++++---- 6 files changed, 1201 insertions(+), 390 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.c b/source3/librpc/gen_ndr/cli_ntsvcs.c index 7795962c3f..da43d451e6 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.c +++ b/source3/librpc/gen_ndr/cli_ntsvcs.c @@ -7,7 +7,8 @@ #include "librpc/gen_ndr/cli_ntsvcs.h" NTSTATUS rpccli_PNP_Disconnect(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_Disconnect r; NTSTATUS status; @@ -40,11 +41,16 @@ NTSTATUS rpccli_PNP_Disconnect(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_Connect(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_Connect r; NTSTATUS status; @@ -77,11 +83,17 @@ NTSTATUS rpccli_PNP_Connect(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetVersion(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + uint16_t *version, + WERROR *werror) { struct PNP_GetVersion r; NTSTATUS status; @@ -112,13 +124,19 @@ NTSTATUS rpccli_PNP_GetVersion(struct rpc_pipe_client *cli, } /* Return variables */ + *version = *r.out.version; /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetGlobalState(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetGlobalState r; NTSTATUS status; @@ -151,11 +169,16 @@ NTSTATUS rpccli_PNP_GetGlobalState(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_InitDetection(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_InitDetection r; NTSTATUS status; @@ -188,11 +211,16 @@ NTSTATUS rpccli_PNP_InitDetection(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_ReportLogOn(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_ReportLogOn r; NTSTATUS status; @@ -225,11 +253,16 @@ NTSTATUS rpccli_PNP_ReportLogOn(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_ValidateDeviceInstance(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_ValidateDeviceInstance r; NTSTATUS status; @@ -262,11 +295,16 @@ NTSTATUS rpccli_PNP_ValidateDeviceInstance(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetRootDeviceInstance(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetRootDeviceInstance r; NTSTATUS status; @@ -299,11 +337,16 @@ NTSTATUS rpccli_PNP_GetRootDeviceInstance(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetRelatedDeviceInstance(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetRelatedDeviceInstance r; NTSTATUS status; @@ -336,11 +379,16 @@ NTSTATUS rpccli_PNP_GetRelatedDeviceInstance(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_EnumerateSubKeys(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_EnumerateSubKeys r; NTSTATUS status; @@ -373,11 +421,16 @@ NTSTATUS rpccli_PNP_EnumerateSubKeys(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetDeviceList r; NTSTATUS status; @@ -410,11 +463,16 @@ NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetDeviceListSize r; NTSTATUS status; @@ -447,11 +505,16 @@ NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetDepth(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetDepth r; NTSTATUS status; @@ -484,11 +547,16 @@ NTSTATUS rpccli_PNP_GetDepth(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetDeviceRegProp r; NTSTATUS status; @@ -521,11 +589,16 @@ NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_SetDeviceRegProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_SetDeviceRegProp r; NTSTATUS status; @@ -558,11 +631,16 @@ NTSTATUS rpccli_PNP_SetDeviceRegProp(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetClassInstance(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetClassInstance r; NTSTATUS status; @@ -595,11 +673,16 @@ NTSTATUS rpccli_PNP_GetClassInstance(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_CreateKey(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_CreateKey r; NTSTATUS status; @@ -632,11 +715,16 @@ NTSTATUS rpccli_PNP_CreateKey(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_DeleteRegistryKey(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_DeleteRegistryKey r; NTSTATUS status; @@ -669,11 +757,16 @@ NTSTATUS rpccli_PNP_DeleteRegistryKey(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetClassCount(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetClassCount r; NTSTATUS status; @@ -706,11 +799,16 @@ NTSTATUS rpccli_PNP_GetClassCount(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetClassName(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetClassName r; NTSTATUS status; @@ -743,11 +841,16 @@ NTSTATUS rpccli_PNP_GetClassName(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_DeleteClassKey(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_DeleteClassKey r; NTSTATUS status; @@ -780,11 +883,16 @@ NTSTATUS rpccli_PNP_DeleteClassKey(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetInterfaceDeviceAlias(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetInterfaceDeviceAlias r; NTSTATUS status; @@ -817,11 +925,16 @@ NTSTATUS rpccli_PNP_GetInterfaceDeviceAlias(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetInterfaceDeviceList(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetInterfaceDeviceList r; NTSTATUS status; @@ -854,11 +967,16 @@ NTSTATUS rpccli_PNP_GetInterfaceDeviceList(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetInterfaceDeviceListSize(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetInterfaceDeviceListSize r; NTSTATUS status; @@ -891,11 +1009,16 @@ NTSTATUS rpccli_PNP_GetInterfaceDeviceListSize(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_RegisterDeviceClassAssociation(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_RegisterDeviceClassAssociation r; NTSTATUS status; @@ -928,11 +1051,16 @@ NTSTATUS rpccli_PNP_RegisterDeviceClassAssociation(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_UnregisterDeviceClassAssociation(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_UnregisterDeviceClassAssociation r; NTSTATUS status; @@ -965,11 +1093,16 @@ NTSTATUS rpccli_PNP_UnregisterDeviceClassAssociation(struct rpc_pipe_client *cli /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetClassRegProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetClassRegProp r; NTSTATUS status; @@ -1002,11 +1135,16 @@ NTSTATUS rpccli_PNP_GetClassRegProp(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_SetClassRegProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_SetClassRegProp r; NTSTATUS status; @@ -1039,11 +1177,16 @@ NTSTATUS rpccli_PNP_SetClassRegProp(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_CreateDevInst(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_CreateDevInst r; NTSTATUS status; @@ -1076,11 +1219,16 @@ NTSTATUS rpccli_PNP_CreateDevInst(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_DeviceInstanceAction(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_DeviceInstanceAction r; NTSTATUS status; @@ -1113,11 +1261,16 @@ NTSTATUS rpccli_PNP_DeviceInstanceAction(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetDeviceStatus(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetDeviceStatus r; NTSTATUS status; @@ -1150,11 +1303,16 @@ NTSTATUS rpccli_PNP_GetDeviceStatus(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_SetDeviceProblem(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_SetDeviceProblem r; NTSTATUS status; @@ -1187,11 +1345,16 @@ NTSTATUS rpccli_PNP_SetDeviceProblem(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_DisableDevInst(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_DisableDevInst r; NTSTATUS status; @@ -1224,11 +1387,16 @@ NTSTATUS rpccli_PNP_DisableDevInst(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_UninstallDevInst(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_UninstallDevInst r; NTSTATUS status; @@ -1261,11 +1429,16 @@ NTSTATUS rpccli_PNP_UninstallDevInst(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_AddID(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_AddID r; NTSTATUS status; @@ -1298,11 +1471,16 @@ NTSTATUS rpccli_PNP_AddID(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_RegisterDriver(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_RegisterDriver r; NTSTATUS status; @@ -1335,11 +1513,16 @@ NTSTATUS rpccli_PNP_RegisterDriver(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_QueryRemove(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_QueryRemove r; NTSTATUS status; @@ -1372,11 +1555,16 @@ NTSTATUS rpccli_PNP_QueryRemove(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_RequestDeviceEject(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_RequestDeviceEject r; NTSTATUS status; @@ -1409,11 +1597,16 @@ NTSTATUS rpccli_PNP_RequestDeviceEject(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_IsDockStationPresent(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_IsDockStationPresent r; NTSTATUS status; @@ -1446,11 +1639,16 @@ NTSTATUS rpccli_PNP_IsDockStationPresent(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_RequestEjectPC(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_RequestEjectPC r; NTSTATUS status; @@ -1483,11 +1681,16 @@ NTSTATUS rpccli_PNP_RequestEjectPC(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_HwProfFlags r; NTSTATUS status; @@ -1520,11 +1723,16 @@ NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetHwProfInfo r; NTSTATUS status; @@ -1557,11 +1765,16 @@ NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_AddEmptyLogConf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_AddEmptyLogConf r; NTSTATUS status; @@ -1594,11 +1807,16 @@ NTSTATUS rpccli_PNP_AddEmptyLogConf(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_FreeLogConf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_FreeLogConf r; NTSTATUS status; @@ -1631,11 +1849,16 @@ NTSTATUS rpccli_PNP_FreeLogConf(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetFirstLogConf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetFirstLogConf r; NTSTATUS status; @@ -1668,11 +1891,16 @@ NTSTATUS rpccli_PNP_GetFirstLogConf(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetNextLogConf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetNextLogConf r; NTSTATUS status; @@ -1705,11 +1933,16 @@ NTSTATUS rpccli_PNP_GetNextLogConf(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetLogConfPriority(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetLogConfPriority r; NTSTATUS status; @@ -1742,11 +1975,16 @@ NTSTATUS rpccli_PNP_GetLogConfPriority(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_AddResDes(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_AddResDes r; NTSTATUS status; @@ -1779,11 +2017,16 @@ NTSTATUS rpccli_PNP_AddResDes(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_FreeResDes(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_FreeResDes r; NTSTATUS status; @@ -1816,11 +2059,16 @@ NTSTATUS rpccli_PNP_FreeResDes(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetNextResDes(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetNextResDes r; NTSTATUS status; @@ -1853,11 +2101,16 @@ NTSTATUS rpccli_PNP_GetNextResDes(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetResDesData(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetResDesData r; NTSTATUS status; @@ -1890,11 +2143,16 @@ NTSTATUS rpccli_PNP_GetResDesData(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetResDesDataSize(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetResDesDataSize r; NTSTATUS status; @@ -1927,11 +2185,16 @@ NTSTATUS rpccli_PNP_GetResDesDataSize(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_ModifyResDes(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_ModifyResDes r; NTSTATUS status; @@ -1964,11 +2227,16 @@ NTSTATUS rpccli_PNP_ModifyResDes(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_DetectResourceLimit(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_DetectResourceLimit r; NTSTATUS status; @@ -2001,11 +2269,16 @@ NTSTATUS rpccli_PNP_DetectResourceLimit(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_QueryResConfList(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_QueryResConfList r; NTSTATUS status; @@ -2038,11 +2311,16 @@ NTSTATUS rpccli_PNP_QueryResConfList(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_SetHwProf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_SetHwProf r; NTSTATUS status; @@ -2075,11 +2353,16 @@ NTSTATUS rpccli_PNP_SetHwProf(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_QueryArbitratorFreeData(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_QueryArbitratorFreeData r; NTSTATUS status; @@ -2112,11 +2395,16 @@ NTSTATUS rpccli_PNP_QueryArbitratorFreeData(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_QueryArbitratorFreeSize(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_QueryArbitratorFreeSize r; NTSTATUS status; @@ -2149,11 +2437,16 @@ NTSTATUS rpccli_PNP_QueryArbitratorFreeSize(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_RunDetection(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_RunDetection r; NTSTATUS status; @@ -2186,11 +2479,16 @@ NTSTATUS rpccli_PNP_RunDetection(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_RegisterNotification(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_RegisterNotification r; NTSTATUS status; @@ -2223,11 +2521,16 @@ NTSTATUS rpccli_PNP_RegisterNotification(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_UnregisterNotification(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_UnregisterNotification r; NTSTATUS status; @@ -2260,11 +2563,16 @@ NTSTATUS rpccli_PNP_UnregisterNotification(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetCustomDevProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetCustomDevProp r; NTSTATUS status; @@ -2297,11 +2605,16 @@ NTSTATUS rpccli_PNP_GetCustomDevProp(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetVersionInternal(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetVersionInternal r; NTSTATUS status; @@ -2334,11 +2647,16 @@ NTSTATUS rpccli_PNP_GetVersionInternal(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetBlockedDriverInfo(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetBlockedDriverInfo r; NTSTATUS status; @@ -2371,11 +2689,16 @@ NTSTATUS rpccli_PNP_GetBlockedDriverInfo(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } NTSTATUS rpccli_PNP_GetServerSideDeviceInstallFlags(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + WERROR *werror) { struct PNP_GetServerSideDeviceInstallFlags r; NTSTATUS status; @@ -2408,6 +2731,10 @@ NTSTATUS rpccli_PNP_GetServerSideDeviceInstallFlags(struct rpc_pipe_client *cli, /* Return variables */ /* Return result */ - return NT_STATUS_OK; + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); } diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.h b/source3/librpc/gen_ndr/cli_ntsvcs.h index ab2aead1ea..852cc812e9 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.h +++ b/source3/librpc/gen_ndr/cli_ntsvcs.h @@ -2,133 +2,199 @@ #ifndef __CLI_NTSVCS__ #define __CLI_NTSVCS__ NTSTATUS rpccli_PNP_Disconnect(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_Connect(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetVersion(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + uint16_t *version, + WERROR *werror); NTSTATUS rpccli_PNP_GetGlobalState(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_InitDetection(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_ReportLogOn(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_ValidateDeviceInstance(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetRootDeviceInstance(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetRelatedDeviceInstance(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_EnumerateSubKeys(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetDepth(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_SetDeviceRegProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetClassInstance(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_CreateKey(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_DeleteRegistryKey(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetClassCount(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetClassName(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_DeleteClassKey(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetInterfaceDeviceAlias(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetInterfaceDeviceList(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetInterfaceDeviceListSize(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_RegisterDeviceClassAssociation(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_UnregisterDeviceClassAssociation(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetClassRegProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_SetClassRegProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_CreateDevInst(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_DeviceInstanceAction(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetDeviceStatus(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_SetDeviceProblem(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_DisableDevInst(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_UninstallDevInst(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_AddID(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_RegisterDriver(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_QueryRemove(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_RequestDeviceEject(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_IsDockStationPresent(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_RequestEjectPC(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_AddEmptyLogConf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_FreeLogConf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetFirstLogConf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetNextLogConf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetLogConfPriority(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_AddResDes(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_FreeResDes(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetNextResDes(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetResDesData(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetResDesDataSize(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_ModifyResDes(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_DetectResourceLimit(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_QueryResConfList(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_SetHwProf(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_QueryArbitratorFreeData(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_QueryArbitratorFreeSize(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_RunDetection(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_RegisterNotification(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_UnregisterNotification(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetCustomDevProp(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetVersionInternal(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetBlockedDriverInfo(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); NTSTATUS rpccli_PNP_GetServerSideDeviceInstallFlags(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + WERROR *werror); #endif /* __CLI_NTSVCS__ */ diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.c b/source3/librpc/gen_ndr/ndr_ntsvcs.c index 8e6176c56c..73dd4d346c 100644 --- a/source3/librpc/gen_ndr/ndr_ntsvcs.c +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c @@ -8,6 +8,7 @@ static enum ndr_err_code ndr_push_PNP_Disconnect(struct ndr_push *ndr, int flags if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -17,6 +18,7 @@ static enum ndr_err_code ndr_pull_PNP_Disconnect(struct ndr_pull *ndr, int flags if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -36,6 +38,7 @@ _PUBLIC_ void ndr_print_PNP_Disconnect(struct ndr_print *ndr, const char *name, if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_Disconnect"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -46,6 +49,7 @@ static enum ndr_err_code ndr_push_PNP_Connect(struct ndr_push *ndr, int flags, c if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -55,6 +59,7 @@ static enum ndr_err_code ndr_pull_PNP_Connect(struct ndr_pull *ndr, int flags, s if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -74,6 +79,7 @@ _PUBLIC_ void ndr_print_PNP_Connect(struct ndr_print *ndr, const char *name, int if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_Connect"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -84,15 +90,33 @@ static enum ndr_err_code ndr_push_PNP_GetVersion(struct ndr_push *ndr, int flags if (flags & NDR_IN) { } if (flags & NDR_OUT) { + if (r->out.version == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, *r->out.version)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } static enum ndr_err_code ndr_pull_PNP_GetVersion(struct ndr_pull *ndr, int flags, struct PNP_GetVersion *r) { + TALLOC_CTX *_mem_save_version_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_PULL_ALLOC(ndr, r->out.version); + ZERO_STRUCTP(r->out.version); } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.version); + } + _mem_save_version_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.version, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, r->out.version)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_version_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -112,6 +136,11 @@ _PUBLIC_ void ndr_print_PNP_GetVersion(struct ndr_print *ndr, const char *name, if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetVersion"); ndr->depth++; + ndr_print_ptr(ndr, "version", r->out.version); + ndr->depth++; + ndr_print_uint16(ndr, "version", *r->out.version); + ndr->depth--; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -122,6 +151,7 @@ static enum ndr_err_code ndr_push_PNP_GetGlobalState(struct ndr_push *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -131,6 +161,7 @@ static enum ndr_err_code ndr_pull_PNP_GetGlobalState(struct ndr_pull *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -150,6 +181,7 @@ _PUBLIC_ void ndr_print_PNP_GetGlobalState(struct ndr_print *ndr, const char *na if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetGlobalState"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -160,6 +192,7 @@ static enum ndr_err_code ndr_push_PNP_InitDetection(struct ndr_push *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -169,6 +202,7 @@ static enum ndr_err_code ndr_pull_PNP_InitDetection(struct ndr_pull *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -188,6 +222,7 @@ _PUBLIC_ void ndr_print_PNP_InitDetection(struct ndr_print *ndr, const char *nam if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_InitDetection"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -198,6 +233,7 @@ static enum ndr_err_code ndr_push_PNP_ReportLogOn(struct ndr_push *ndr, int flag if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -207,6 +243,7 @@ static enum ndr_err_code ndr_pull_PNP_ReportLogOn(struct ndr_pull *ndr, int flag if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -226,6 +263,7 @@ _PUBLIC_ void ndr_print_PNP_ReportLogOn(struct ndr_print *ndr, const char *name, if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_ReportLogOn"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -236,6 +274,7 @@ static enum ndr_err_code ndr_push_PNP_ValidateDeviceInstance(struct ndr_push *nd if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -245,6 +284,7 @@ static enum ndr_err_code ndr_pull_PNP_ValidateDeviceInstance(struct ndr_pull *nd if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -264,6 +304,7 @@ _PUBLIC_ void ndr_print_PNP_ValidateDeviceInstance(struct ndr_print *ndr, const if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_ValidateDeviceInstance"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -274,6 +315,7 @@ static enum ndr_err_code ndr_push_PNP_GetRootDeviceInstance(struct ndr_push *ndr if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -283,6 +325,7 @@ static enum ndr_err_code ndr_pull_PNP_GetRootDeviceInstance(struct ndr_pull *ndr if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -302,6 +345,7 @@ _PUBLIC_ void ndr_print_PNP_GetRootDeviceInstance(struct ndr_print *ndr, const c if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetRootDeviceInstance"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -312,6 +356,7 @@ static enum ndr_err_code ndr_push_PNP_GetRelatedDeviceInstance(struct ndr_push * if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -321,6 +366,7 @@ static enum ndr_err_code ndr_pull_PNP_GetRelatedDeviceInstance(struct ndr_pull * if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -340,6 +386,7 @@ _PUBLIC_ void ndr_print_PNP_GetRelatedDeviceInstance(struct ndr_print *ndr, cons if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetRelatedDeviceInstance"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -350,6 +397,7 @@ static enum ndr_err_code ndr_push_PNP_EnumerateSubKeys(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -359,6 +407,7 @@ static enum ndr_err_code ndr_pull_PNP_EnumerateSubKeys(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -378,6 +427,7 @@ _PUBLIC_ void ndr_print_PNP_EnumerateSubKeys(struct ndr_print *ndr, const char * if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_EnumerateSubKeys"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -388,6 +438,7 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceList(struct ndr_push *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -397,6 +448,7 @@ static enum ndr_err_code ndr_pull_PNP_GetDeviceList(struct ndr_pull *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -416,6 +468,7 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceList(struct ndr_print *ndr, const char *nam if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetDeviceList"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -426,6 +479,7 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceListSize(struct ndr_push *ndr, in if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -435,6 +489,7 @@ static enum ndr_err_code ndr_pull_PNP_GetDeviceListSize(struct ndr_pull *ndr, in if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -454,6 +509,7 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceListSize(struct ndr_print *ndr, const char if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetDeviceListSize"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -464,6 +520,7 @@ static enum ndr_err_code ndr_push_PNP_GetDepth(struct ndr_push *ndr, int flags, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -473,6 +530,7 @@ static enum ndr_err_code ndr_pull_PNP_GetDepth(struct ndr_pull *ndr, int flags, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -492,6 +550,7 @@ _PUBLIC_ void ndr_print_PNP_GetDepth(struct ndr_print *ndr, const char *name, in if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetDepth"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -502,6 +561,7 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceRegProp(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -511,6 +571,7 @@ static enum ndr_err_code ndr_pull_PNP_GetDeviceRegProp(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -530,6 +591,7 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceRegProp(struct ndr_print *ndr, const char * if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetDeviceRegProp"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -540,6 +602,7 @@ static enum ndr_err_code ndr_push_PNP_SetDeviceRegProp(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -549,6 +612,7 @@ static enum ndr_err_code ndr_pull_PNP_SetDeviceRegProp(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -568,6 +632,7 @@ _PUBLIC_ void ndr_print_PNP_SetDeviceRegProp(struct ndr_print *ndr, const char * if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_SetDeviceRegProp"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -578,6 +643,7 @@ static enum ndr_err_code ndr_push_PNP_GetClassInstance(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -587,6 +653,7 @@ static enum ndr_err_code ndr_pull_PNP_GetClassInstance(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -606,6 +673,7 @@ _PUBLIC_ void ndr_print_PNP_GetClassInstance(struct ndr_print *ndr, const char * if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetClassInstance"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -616,6 +684,7 @@ static enum ndr_err_code ndr_push_PNP_CreateKey(struct ndr_push *ndr, int flags, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -625,6 +694,7 @@ static enum ndr_err_code ndr_pull_PNP_CreateKey(struct ndr_pull *ndr, int flags, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -644,6 +714,7 @@ _PUBLIC_ void ndr_print_PNP_CreateKey(struct ndr_print *ndr, const char *name, i if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_CreateKey"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -654,6 +725,7 @@ static enum ndr_err_code ndr_push_PNP_DeleteRegistryKey(struct ndr_push *ndr, in if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -663,6 +735,7 @@ static enum ndr_err_code ndr_pull_PNP_DeleteRegistryKey(struct ndr_pull *ndr, in if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -682,6 +755,7 @@ _PUBLIC_ void ndr_print_PNP_DeleteRegistryKey(struct ndr_print *ndr, const char if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_DeleteRegistryKey"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -692,6 +766,7 @@ static enum ndr_err_code ndr_push_PNP_GetClassCount(struct ndr_push *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -701,6 +776,7 @@ static enum ndr_err_code ndr_pull_PNP_GetClassCount(struct ndr_pull *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -720,6 +796,7 @@ _PUBLIC_ void ndr_print_PNP_GetClassCount(struct ndr_print *ndr, const char *nam if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetClassCount"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -730,6 +807,7 @@ static enum ndr_err_code ndr_push_PNP_GetClassName(struct ndr_push *ndr, int fla if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -739,6 +817,7 @@ static enum ndr_err_code ndr_pull_PNP_GetClassName(struct ndr_pull *ndr, int fla if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -758,6 +837,7 @@ _PUBLIC_ void ndr_print_PNP_GetClassName(struct ndr_print *ndr, const char *name if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetClassName"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -768,6 +848,7 @@ static enum ndr_err_code ndr_push_PNP_DeleteClassKey(struct ndr_push *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -777,6 +858,7 @@ static enum ndr_err_code ndr_pull_PNP_DeleteClassKey(struct ndr_pull *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -796,6 +878,7 @@ _PUBLIC_ void ndr_print_PNP_DeleteClassKey(struct ndr_print *ndr, const char *na if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_DeleteClassKey"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -806,6 +889,7 @@ static enum ndr_err_code ndr_push_PNP_GetInterfaceDeviceAlias(struct ndr_push *n if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -815,6 +899,7 @@ static enum ndr_err_code ndr_pull_PNP_GetInterfaceDeviceAlias(struct ndr_pull *n if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -834,6 +919,7 @@ _PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceAlias(struct ndr_print *ndr, const if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetInterfaceDeviceAlias"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -844,6 +930,7 @@ static enum ndr_err_code ndr_push_PNP_GetInterfaceDeviceList(struct ndr_push *nd if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -853,6 +940,7 @@ static enum ndr_err_code ndr_pull_PNP_GetInterfaceDeviceList(struct ndr_pull *nd if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -872,6 +960,7 @@ _PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceList(struct ndr_print *ndr, const if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetInterfaceDeviceList"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -882,6 +971,7 @@ static enum ndr_err_code ndr_push_PNP_GetInterfaceDeviceListSize(struct ndr_push if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -891,6 +981,7 @@ static enum ndr_err_code ndr_pull_PNP_GetInterfaceDeviceListSize(struct ndr_pull if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -910,6 +1001,7 @@ _PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceListSize(struct ndr_print *ndr, co if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetInterfaceDeviceListSize"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -920,6 +1012,7 @@ static enum ndr_err_code ndr_push_PNP_RegisterDeviceClassAssociation(struct ndr_ if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -929,6 +1022,7 @@ static enum ndr_err_code ndr_pull_PNP_RegisterDeviceClassAssociation(struct ndr_ if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -948,6 +1042,7 @@ _PUBLIC_ void ndr_print_PNP_RegisterDeviceClassAssociation(struct ndr_print *ndr if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_RegisterDeviceClassAssociation"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -958,6 +1053,7 @@ static enum ndr_err_code ndr_push_PNP_UnregisterDeviceClassAssociation(struct nd if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -967,6 +1063,7 @@ static enum ndr_err_code ndr_pull_PNP_UnregisterDeviceClassAssociation(struct nd if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -986,6 +1083,7 @@ _PUBLIC_ void ndr_print_PNP_UnregisterDeviceClassAssociation(struct ndr_print *n if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_UnregisterDeviceClassAssociation"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -996,6 +1094,7 @@ static enum ndr_err_code ndr_push_PNP_GetClassRegProp(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1005,6 +1104,7 @@ static enum ndr_err_code ndr_pull_PNP_GetClassRegProp(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1024,6 +1124,7 @@ _PUBLIC_ void ndr_print_PNP_GetClassRegProp(struct ndr_print *ndr, const char *n if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetClassRegProp"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1034,6 +1135,7 @@ static enum ndr_err_code ndr_push_PNP_SetClassRegProp(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1043,6 +1145,7 @@ static enum ndr_err_code ndr_pull_PNP_SetClassRegProp(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1062,6 +1165,7 @@ _PUBLIC_ void ndr_print_PNP_SetClassRegProp(struct ndr_print *ndr, const char *n if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_SetClassRegProp"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1072,6 +1176,7 @@ static enum ndr_err_code ndr_push_PNP_CreateDevInst(struct ndr_push *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1081,6 +1186,7 @@ static enum ndr_err_code ndr_pull_PNP_CreateDevInst(struct ndr_pull *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1100,6 +1206,7 @@ _PUBLIC_ void ndr_print_PNP_CreateDevInst(struct ndr_print *ndr, const char *nam if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_CreateDevInst"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1110,6 +1217,7 @@ static enum ndr_err_code ndr_push_PNP_DeviceInstanceAction(struct ndr_push *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1119,6 +1227,7 @@ static enum ndr_err_code ndr_pull_PNP_DeviceInstanceAction(struct ndr_pull *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1138,6 +1247,7 @@ _PUBLIC_ void ndr_print_PNP_DeviceInstanceAction(struct ndr_print *ndr, const ch if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_DeviceInstanceAction"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1148,6 +1258,7 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceStatus(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1157,6 +1268,7 @@ static enum ndr_err_code ndr_pull_PNP_GetDeviceStatus(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1176,6 +1288,7 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceStatus(struct ndr_print *ndr, const char *n if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetDeviceStatus"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1186,6 +1299,7 @@ static enum ndr_err_code ndr_push_PNP_SetDeviceProblem(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1195,6 +1309,7 @@ static enum ndr_err_code ndr_pull_PNP_SetDeviceProblem(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1214,6 +1329,7 @@ _PUBLIC_ void ndr_print_PNP_SetDeviceProblem(struct ndr_print *ndr, const char * if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_SetDeviceProblem"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1224,6 +1340,7 @@ static enum ndr_err_code ndr_push_PNP_DisableDevInst(struct ndr_push *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1233,6 +1350,7 @@ static enum ndr_err_code ndr_pull_PNP_DisableDevInst(struct ndr_pull *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1252,6 +1370,7 @@ _PUBLIC_ void ndr_print_PNP_DisableDevInst(struct ndr_print *ndr, const char *na if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_DisableDevInst"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1262,6 +1381,7 @@ static enum ndr_err_code ndr_push_PNP_UninstallDevInst(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1271,6 +1391,7 @@ static enum ndr_err_code ndr_pull_PNP_UninstallDevInst(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1290,6 +1411,7 @@ _PUBLIC_ void ndr_print_PNP_UninstallDevInst(struct ndr_print *ndr, const char * if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_UninstallDevInst"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1300,6 +1422,7 @@ static enum ndr_err_code ndr_push_PNP_AddID(struct ndr_push *ndr, int flags, con if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1309,6 +1432,7 @@ static enum ndr_err_code ndr_pull_PNP_AddID(struct ndr_pull *ndr, int flags, str if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1328,6 +1452,7 @@ _PUBLIC_ void ndr_print_PNP_AddID(struct ndr_print *ndr, const char *name, int f if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_AddID"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1338,6 +1463,7 @@ static enum ndr_err_code ndr_push_PNP_RegisterDriver(struct ndr_push *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1347,6 +1473,7 @@ static enum ndr_err_code ndr_pull_PNP_RegisterDriver(struct ndr_pull *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1366,6 +1493,7 @@ _PUBLIC_ void ndr_print_PNP_RegisterDriver(struct ndr_print *ndr, const char *na if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_RegisterDriver"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1376,6 +1504,7 @@ static enum ndr_err_code ndr_push_PNP_QueryRemove(struct ndr_push *ndr, int flag if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1385,6 +1514,7 @@ static enum ndr_err_code ndr_pull_PNP_QueryRemove(struct ndr_pull *ndr, int flag if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1404,6 +1534,7 @@ _PUBLIC_ void ndr_print_PNP_QueryRemove(struct ndr_print *ndr, const char *name, if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_QueryRemove"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1414,6 +1545,7 @@ static enum ndr_err_code ndr_push_PNP_RequestDeviceEject(struct ndr_push *ndr, i if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1423,6 +1555,7 @@ static enum ndr_err_code ndr_pull_PNP_RequestDeviceEject(struct ndr_pull *ndr, i if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1442,6 +1575,7 @@ _PUBLIC_ void ndr_print_PNP_RequestDeviceEject(struct ndr_print *ndr, const char if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_RequestDeviceEject"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1452,6 +1586,7 @@ static enum ndr_err_code ndr_push_PNP_IsDockStationPresent(struct ndr_push *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1461,6 +1596,7 @@ static enum ndr_err_code ndr_pull_PNP_IsDockStationPresent(struct ndr_pull *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1480,6 +1616,7 @@ _PUBLIC_ void ndr_print_PNP_IsDockStationPresent(struct ndr_print *ndr, const ch if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_IsDockStationPresent"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1490,6 +1627,7 @@ static enum ndr_err_code ndr_push_PNP_RequestEjectPC(struct ndr_push *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1499,6 +1637,7 @@ static enum ndr_err_code ndr_pull_PNP_RequestEjectPC(struct ndr_pull *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1518,6 +1657,7 @@ _PUBLIC_ void ndr_print_PNP_RequestEjectPC(struct ndr_print *ndr, const char *na if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_RequestEjectPC"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1528,6 +1668,7 @@ static enum ndr_err_code ndr_push_PNP_HwProfFlags(struct ndr_push *ndr, int flag if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1537,6 +1678,7 @@ static enum ndr_err_code ndr_pull_PNP_HwProfFlags(struct ndr_pull *ndr, int flag if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1556,6 +1698,7 @@ _PUBLIC_ void ndr_print_PNP_HwProfFlags(struct ndr_print *ndr, const char *name, if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_HwProfFlags"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1566,6 +1709,7 @@ static enum ndr_err_code ndr_push_PNP_GetHwProfInfo(struct ndr_push *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1575,6 +1719,7 @@ static enum ndr_err_code ndr_pull_PNP_GetHwProfInfo(struct ndr_pull *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1594,6 +1739,7 @@ _PUBLIC_ void ndr_print_PNP_GetHwProfInfo(struct ndr_print *ndr, const char *nam if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetHwProfInfo"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1604,6 +1750,7 @@ static enum ndr_err_code ndr_push_PNP_AddEmptyLogConf(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1613,6 +1760,7 @@ static enum ndr_err_code ndr_pull_PNP_AddEmptyLogConf(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1632,6 +1780,7 @@ _PUBLIC_ void ndr_print_PNP_AddEmptyLogConf(struct ndr_print *ndr, const char *n if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_AddEmptyLogConf"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1642,6 +1791,7 @@ static enum ndr_err_code ndr_push_PNP_FreeLogConf(struct ndr_push *ndr, int flag if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1651,6 +1801,7 @@ static enum ndr_err_code ndr_pull_PNP_FreeLogConf(struct ndr_pull *ndr, int flag if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1670,6 +1821,7 @@ _PUBLIC_ void ndr_print_PNP_FreeLogConf(struct ndr_print *ndr, const char *name, if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_FreeLogConf"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1680,6 +1832,7 @@ static enum ndr_err_code ndr_push_PNP_GetFirstLogConf(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1689,6 +1842,7 @@ static enum ndr_err_code ndr_pull_PNP_GetFirstLogConf(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1708,6 +1862,7 @@ _PUBLIC_ void ndr_print_PNP_GetFirstLogConf(struct ndr_print *ndr, const char *n if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetFirstLogConf"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1718,6 +1873,7 @@ static enum ndr_err_code ndr_push_PNP_GetNextLogConf(struct ndr_push *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1727,6 +1883,7 @@ static enum ndr_err_code ndr_pull_PNP_GetNextLogConf(struct ndr_pull *ndr, int f if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1746,6 +1903,7 @@ _PUBLIC_ void ndr_print_PNP_GetNextLogConf(struct ndr_print *ndr, const char *na if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetNextLogConf"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1756,6 +1914,7 @@ static enum ndr_err_code ndr_push_PNP_GetLogConfPriority(struct ndr_push *ndr, i if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1765,6 +1924,7 @@ static enum ndr_err_code ndr_pull_PNP_GetLogConfPriority(struct ndr_pull *ndr, i if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1784,6 +1944,7 @@ _PUBLIC_ void ndr_print_PNP_GetLogConfPriority(struct ndr_print *ndr, const char if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetLogConfPriority"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1794,6 +1955,7 @@ static enum ndr_err_code ndr_push_PNP_AddResDes(struct ndr_push *ndr, int flags, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1803,6 +1965,7 @@ static enum ndr_err_code ndr_pull_PNP_AddResDes(struct ndr_pull *ndr, int flags, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1822,6 +1985,7 @@ _PUBLIC_ void ndr_print_PNP_AddResDes(struct ndr_print *ndr, const char *name, i if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_AddResDes"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1832,6 +1996,7 @@ static enum ndr_err_code ndr_push_PNP_FreeResDes(struct ndr_push *ndr, int flags if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1841,6 +2006,7 @@ static enum ndr_err_code ndr_pull_PNP_FreeResDes(struct ndr_pull *ndr, int flags if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1860,6 +2026,7 @@ _PUBLIC_ void ndr_print_PNP_FreeResDes(struct ndr_print *ndr, const char *name, if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_FreeResDes"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1870,6 +2037,7 @@ static enum ndr_err_code ndr_push_PNP_GetNextResDes(struct ndr_push *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1879,6 +2047,7 @@ static enum ndr_err_code ndr_pull_PNP_GetNextResDes(struct ndr_pull *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1898,6 +2067,7 @@ _PUBLIC_ void ndr_print_PNP_GetNextResDes(struct ndr_print *ndr, const char *nam if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetNextResDes"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1908,6 +2078,7 @@ static enum ndr_err_code ndr_push_PNP_GetResDesData(struct ndr_push *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1917,6 +2088,7 @@ static enum ndr_err_code ndr_pull_PNP_GetResDesData(struct ndr_pull *ndr, int fl if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1936,6 +2108,7 @@ _PUBLIC_ void ndr_print_PNP_GetResDesData(struct ndr_print *ndr, const char *nam if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetResDesData"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1946,6 +2119,7 @@ static enum ndr_err_code ndr_push_PNP_GetResDesDataSize(struct ndr_push *ndr, in if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1955,6 +2129,7 @@ static enum ndr_err_code ndr_pull_PNP_GetResDesDataSize(struct ndr_pull *ndr, in if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1974,6 +2149,7 @@ _PUBLIC_ void ndr_print_PNP_GetResDesDataSize(struct ndr_print *ndr, const char if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetResDesDataSize"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -1984,6 +2160,7 @@ static enum ndr_err_code ndr_push_PNP_ModifyResDes(struct ndr_push *ndr, int fla if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -1993,6 +2170,7 @@ static enum ndr_err_code ndr_pull_PNP_ModifyResDes(struct ndr_pull *ndr, int fla if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2012,6 +2190,7 @@ _PUBLIC_ void ndr_print_PNP_ModifyResDes(struct ndr_print *ndr, const char *name if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_ModifyResDes"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2022,6 +2201,7 @@ static enum ndr_err_code ndr_push_PNP_DetectResourceLimit(struct ndr_push *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2031,6 +2211,7 @@ static enum ndr_err_code ndr_pull_PNP_DetectResourceLimit(struct ndr_pull *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2050,6 +2231,7 @@ _PUBLIC_ void ndr_print_PNP_DetectResourceLimit(struct ndr_print *ndr, const cha if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_DetectResourceLimit"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2060,6 +2242,7 @@ static enum ndr_err_code ndr_push_PNP_QueryResConfList(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2069,6 +2252,7 @@ static enum ndr_err_code ndr_pull_PNP_QueryResConfList(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2088,6 +2272,7 @@ _PUBLIC_ void ndr_print_PNP_QueryResConfList(struct ndr_print *ndr, const char * if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_QueryResConfList"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2098,6 +2283,7 @@ static enum ndr_err_code ndr_push_PNP_SetHwProf(struct ndr_push *ndr, int flags, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2107,6 +2293,7 @@ static enum ndr_err_code ndr_pull_PNP_SetHwProf(struct ndr_pull *ndr, int flags, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2126,6 +2313,7 @@ _PUBLIC_ void ndr_print_PNP_SetHwProf(struct ndr_print *ndr, const char *name, i if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_SetHwProf"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2136,6 +2324,7 @@ static enum ndr_err_code ndr_push_PNP_QueryArbitratorFreeData(struct ndr_push *n if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2145,6 +2334,7 @@ static enum ndr_err_code ndr_pull_PNP_QueryArbitratorFreeData(struct ndr_pull *n if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2164,6 +2354,7 @@ _PUBLIC_ void ndr_print_PNP_QueryArbitratorFreeData(struct ndr_print *ndr, const if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_QueryArbitratorFreeData"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2174,6 +2365,7 @@ static enum ndr_err_code ndr_push_PNP_QueryArbitratorFreeSize(struct ndr_push *n if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2183,6 +2375,7 @@ static enum ndr_err_code ndr_pull_PNP_QueryArbitratorFreeSize(struct ndr_pull *n if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2202,6 +2395,7 @@ _PUBLIC_ void ndr_print_PNP_QueryArbitratorFreeSize(struct ndr_print *ndr, const if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_QueryArbitratorFreeSize"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2212,6 +2406,7 @@ static enum ndr_err_code ndr_push_PNP_RunDetection(struct ndr_push *ndr, int fla if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2221,6 +2416,7 @@ static enum ndr_err_code ndr_pull_PNP_RunDetection(struct ndr_pull *ndr, int fla if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2240,6 +2436,7 @@ _PUBLIC_ void ndr_print_PNP_RunDetection(struct ndr_print *ndr, const char *name if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_RunDetection"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2250,6 +2447,7 @@ static enum ndr_err_code ndr_push_PNP_RegisterNotification(struct ndr_push *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2259,6 +2457,7 @@ static enum ndr_err_code ndr_pull_PNP_RegisterNotification(struct ndr_pull *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2278,6 +2477,7 @@ _PUBLIC_ void ndr_print_PNP_RegisterNotification(struct ndr_print *ndr, const ch if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_RegisterNotification"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2288,6 +2488,7 @@ static enum ndr_err_code ndr_push_PNP_UnregisterNotification(struct ndr_push *nd if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2297,6 +2498,7 @@ static enum ndr_err_code ndr_pull_PNP_UnregisterNotification(struct ndr_pull *nd if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2316,6 +2518,7 @@ _PUBLIC_ void ndr_print_PNP_UnregisterNotification(struct ndr_print *ndr, const if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_UnregisterNotification"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2326,6 +2529,7 @@ static enum ndr_err_code ndr_push_PNP_GetCustomDevProp(struct ndr_push *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2335,6 +2539,7 @@ static enum ndr_err_code ndr_pull_PNP_GetCustomDevProp(struct ndr_pull *ndr, int if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2354,6 +2559,7 @@ _PUBLIC_ void ndr_print_PNP_GetCustomDevProp(struct ndr_print *ndr, const char * if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetCustomDevProp"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2364,6 +2570,7 @@ static enum ndr_err_code ndr_push_PNP_GetVersionInternal(struct ndr_push *ndr, i if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2373,6 +2580,7 @@ static enum ndr_err_code ndr_pull_PNP_GetVersionInternal(struct ndr_pull *ndr, i if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2392,6 +2600,7 @@ _PUBLIC_ void ndr_print_PNP_GetVersionInternal(struct ndr_print *ndr, const char if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetVersionInternal"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2402,6 +2611,7 @@ static enum ndr_err_code ndr_push_PNP_GetBlockedDriverInfo(struct ndr_push *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2411,6 +2621,7 @@ static enum ndr_err_code ndr_pull_PNP_GetBlockedDriverInfo(struct ndr_pull *ndr, if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2430,6 +2641,7 @@ _PUBLIC_ void ndr_print_PNP_GetBlockedDriverInfo(struct ndr_print *ndr, const ch if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetBlockedDriverInfo"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; @@ -2440,6 +2652,7 @@ static enum ndr_err_code ndr_push_PNP_GetServerSideDeviceInstallFlags(struct ndr if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2449,6 +2662,7 @@ static enum ndr_err_code ndr_pull_PNP_GetServerSideDeviceInstallFlags(struct ndr if (flags & NDR_IN) { } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } @@ -2468,6 +2682,7 @@ _PUBLIC_ void ndr_print_PNP_GetServerSideDeviceInstallFlags(struct ndr_print *nd if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetServerSideDeviceInstallFlags"); ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } ndr->depth--; diff --git a/source3/librpc/gen_ndr/ntsvcs.h b/source3/librpc/gen_ndr/ntsvcs.h index 43867c1bea..571b7466c2 100644 --- a/source3/librpc/gen_ndr/ntsvcs.h +++ b/source3/librpc/gen_ndr/ntsvcs.h @@ -7,327 +7,523 @@ struct PNP_Disconnect { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_Connect { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetVersion { - int _dummy_element; + struct { + uint16_t *version;/* [ref] */ + WERROR result; + } out; + }; struct PNP_GetGlobalState { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_InitDetection { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_ReportLogOn { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_ValidateDeviceInstance { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetRootDeviceInstance { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetRelatedDeviceInstance { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_EnumerateSubKeys { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetDeviceList { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetDeviceListSize { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetDepth { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetDeviceRegProp { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_SetDeviceRegProp { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetClassInstance { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_CreateKey { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_DeleteRegistryKey { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetClassCount { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetClassName { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_DeleteClassKey { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetInterfaceDeviceAlias { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetInterfaceDeviceList { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetInterfaceDeviceListSize { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_RegisterDeviceClassAssociation { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_UnregisterDeviceClassAssociation { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetClassRegProp { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_SetClassRegProp { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_CreateDevInst { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_DeviceInstanceAction { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetDeviceStatus { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_SetDeviceProblem { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_DisableDevInst { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_UninstallDevInst { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_AddID { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_RegisterDriver { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_QueryRemove { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_RequestDeviceEject { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_IsDockStationPresent { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_RequestEjectPC { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_HwProfFlags { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetHwProfInfo { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_AddEmptyLogConf { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_FreeLogConf { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetFirstLogConf { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetNextLogConf { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetLogConfPriority { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_AddResDes { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_FreeResDes { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetNextResDes { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetResDesData { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetResDesDataSize { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_ModifyResDes { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_DetectResourceLimit { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_QueryResConfList { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_SetHwProf { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_QueryArbitratorFreeData { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_QueryArbitratorFreeSize { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_RunDetection { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_RegisterNotification { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_UnregisterNotification { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetCustomDevProp { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetVersionInternal { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetBlockedDriverInfo { - int _dummy_element; + struct { + WERROR result; + } out; + }; struct PNP_GetServerSideDeviceInstallFlags { - int _dummy_element; + struct { + WERROR result; + } out; + }; #endif /* _HEADER_ntsvcs */ diff --git a/source3/librpc/gen_ndr/srv_ntsvcs.c b/source3/librpc/gen_ndr/srv_ntsvcs.c index f4689e0bbb..7bbf9d1bfa 100644 --- a/source3/librpc/gen_ndr/srv_ntsvcs.c +++ b/source3/librpc/gen_ndr/srv_ntsvcs.c @@ -44,7 +44,7 @@ static bool api_PNP_Disconnect(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_Disconnect, r); } - _PNP_Disconnect(p, r); + r->out.result = _PNP_Disconnect(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -117,7 +117,7 @@ static bool api_PNP_Connect(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_Connect, r); } - _PNP_Connect(p, r); + r->out.result = _PNP_Connect(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -190,7 +190,14 @@ static bool api_PNP_GetVersion(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetVersion, r); } - _PNP_GetVersion(p, r); + ZERO_STRUCT(r->out); + r->out.version = talloc_zero(r, uint16_t); + if (r->out.version == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _PNP_GetVersion(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -263,7 +270,7 @@ static bool api_PNP_GetGlobalState(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetGlobalState, r); } - _PNP_GetGlobalState(p, r); + r->out.result = _PNP_GetGlobalState(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -336,7 +343,7 @@ static bool api_PNP_InitDetection(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_InitDetection, r); } - _PNP_InitDetection(p, r); + r->out.result = _PNP_InitDetection(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -409,7 +416,7 @@ static bool api_PNP_ReportLogOn(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_ReportLogOn, r); } - _PNP_ReportLogOn(p, r); + r->out.result = _PNP_ReportLogOn(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -482,7 +489,7 @@ static bool api_PNP_ValidateDeviceInstance(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_ValidateDeviceInstance, r); } - _PNP_ValidateDeviceInstance(p, r); + r->out.result = _PNP_ValidateDeviceInstance(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -555,7 +562,7 @@ static bool api_PNP_GetRootDeviceInstance(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetRootDeviceInstance, r); } - _PNP_GetRootDeviceInstance(p, r); + r->out.result = _PNP_GetRootDeviceInstance(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -628,7 +635,7 @@ static bool api_PNP_GetRelatedDeviceInstance(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetRelatedDeviceInstance, r); } - _PNP_GetRelatedDeviceInstance(p, r); + r->out.result = _PNP_GetRelatedDeviceInstance(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -701,7 +708,7 @@ static bool api_PNP_EnumerateSubKeys(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_EnumerateSubKeys, r); } - _PNP_EnumerateSubKeys(p, r); + r->out.result = _PNP_EnumerateSubKeys(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -774,7 +781,7 @@ static bool api_PNP_GetDeviceList(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetDeviceList, r); } - _PNP_GetDeviceList(p, r); + r->out.result = _PNP_GetDeviceList(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -847,7 +854,7 @@ static bool api_PNP_GetDeviceListSize(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetDeviceListSize, r); } - _PNP_GetDeviceListSize(p, r); + r->out.result = _PNP_GetDeviceListSize(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -920,7 +927,7 @@ static bool api_PNP_GetDepth(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetDepth, r); } - _PNP_GetDepth(p, r); + r->out.result = _PNP_GetDepth(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -993,7 +1000,7 @@ static bool api_PNP_GetDeviceRegProp(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetDeviceRegProp, r); } - _PNP_GetDeviceRegProp(p, r); + r->out.result = _PNP_GetDeviceRegProp(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1066,7 +1073,7 @@ static bool api_PNP_SetDeviceRegProp(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_SetDeviceRegProp, r); } - _PNP_SetDeviceRegProp(p, r); + r->out.result = _PNP_SetDeviceRegProp(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1139,7 +1146,7 @@ static bool api_PNP_GetClassInstance(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetClassInstance, r); } - _PNP_GetClassInstance(p, r); + r->out.result = _PNP_GetClassInstance(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1212,7 +1219,7 @@ static bool api_PNP_CreateKey(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_CreateKey, r); } - _PNP_CreateKey(p, r); + r->out.result = _PNP_CreateKey(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1285,7 +1292,7 @@ static bool api_PNP_DeleteRegistryKey(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_DeleteRegistryKey, r); } - _PNP_DeleteRegistryKey(p, r); + r->out.result = _PNP_DeleteRegistryKey(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1358,7 +1365,7 @@ static bool api_PNP_GetClassCount(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetClassCount, r); } - _PNP_GetClassCount(p, r); + r->out.result = _PNP_GetClassCount(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1431,7 +1438,7 @@ static bool api_PNP_GetClassName(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetClassName, r); } - _PNP_GetClassName(p, r); + r->out.result = _PNP_GetClassName(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1504,7 +1511,7 @@ static bool api_PNP_DeleteClassKey(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_DeleteClassKey, r); } - _PNP_DeleteClassKey(p, r); + r->out.result = _PNP_DeleteClassKey(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1577,7 +1584,7 @@ static bool api_PNP_GetInterfaceDeviceAlias(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceAlias, r); } - _PNP_GetInterfaceDeviceAlias(p, r); + r->out.result = _PNP_GetInterfaceDeviceAlias(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1650,7 +1657,7 @@ static bool api_PNP_GetInterfaceDeviceList(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceList, r); } - _PNP_GetInterfaceDeviceList(p, r); + r->out.result = _PNP_GetInterfaceDeviceList(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1723,7 +1730,7 @@ static bool api_PNP_GetInterfaceDeviceListSize(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetInterfaceDeviceListSize, r); } - _PNP_GetInterfaceDeviceListSize(p, r); + r->out.result = _PNP_GetInterfaceDeviceListSize(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1796,7 +1803,7 @@ static bool api_PNP_RegisterDeviceClassAssociation(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_RegisterDeviceClassAssociation, r); } - _PNP_RegisterDeviceClassAssociation(p, r); + r->out.result = _PNP_RegisterDeviceClassAssociation(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1869,7 +1876,7 @@ static bool api_PNP_UnregisterDeviceClassAssociation(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_UnregisterDeviceClassAssociation, r); } - _PNP_UnregisterDeviceClassAssociation(p, r); + r->out.result = _PNP_UnregisterDeviceClassAssociation(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -1942,7 +1949,7 @@ static bool api_PNP_GetClassRegProp(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetClassRegProp, r); } - _PNP_GetClassRegProp(p, r); + r->out.result = _PNP_GetClassRegProp(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2015,7 +2022,7 @@ static bool api_PNP_SetClassRegProp(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_SetClassRegProp, r); } - _PNP_SetClassRegProp(p, r); + r->out.result = _PNP_SetClassRegProp(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2088,7 +2095,7 @@ static bool api_PNP_CreateDevInst(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_CreateDevInst, r); } - _PNP_CreateDevInst(p, r); + r->out.result = _PNP_CreateDevInst(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2161,7 +2168,7 @@ static bool api_PNP_DeviceInstanceAction(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_DeviceInstanceAction, r); } - _PNP_DeviceInstanceAction(p, r); + r->out.result = _PNP_DeviceInstanceAction(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2234,7 +2241,7 @@ static bool api_PNP_GetDeviceStatus(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetDeviceStatus, r); } - _PNP_GetDeviceStatus(p, r); + r->out.result = _PNP_GetDeviceStatus(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2307,7 +2314,7 @@ static bool api_PNP_SetDeviceProblem(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_SetDeviceProblem, r); } - _PNP_SetDeviceProblem(p, r); + r->out.result = _PNP_SetDeviceProblem(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2380,7 +2387,7 @@ static bool api_PNP_DisableDevInst(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_DisableDevInst, r); } - _PNP_DisableDevInst(p, r); + r->out.result = _PNP_DisableDevInst(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2453,7 +2460,7 @@ static bool api_PNP_UninstallDevInst(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_UninstallDevInst, r); } - _PNP_UninstallDevInst(p, r); + r->out.result = _PNP_UninstallDevInst(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2526,7 +2533,7 @@ static bool api_PNP_AddID(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_AddID, r); } - _PNP_AddID(p, r); + r->out.result = _PNP_AddID(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2599,7 +2606,7 @@ static bool api_PNP_RegisterDriver(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_RegisterDriver, r); } - _PNP_RegisterDriver(p, r); + r->out.result = _PNP_RegisterDriver(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2672,7 +2679,7 @@ static bool api_PNP_QueryRemove(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_QueryRemove, r); } - _PNP_QueryRemove(p, r); + r->out.result = _PNP_QueryRemove(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2745,7 +2752,7 @@ static bool api_PNP_RequestDeviceEject(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_RequestDeviceEject, r); } - _PNP_RequestDeviceEject(p, r); + r->out.result = _PNP_RequestDeviceEject(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2818,7 +2825,7 @@ static bool api_PNP_IsDockStationPresent(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_IsDockStationPresent, r); } - _PNP_IsDockStationPresent(p, r); + r->out.result = _PNP_IsDockStationPresent(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2891,7 +2898,7 @@ static bool api_PNP_RequestEjectPC(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_RequestEjectPC, r); } - _PNP_RequestEjectPC(p, r); + r->out.result = _PNP_RequestEjectPC(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -2964,7 +2971,7 @@ static bool api_PNP_HwProfFlags(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_HwProfFlags, r); } - _PNP_HwProfFlags(p, r); + r->out.result = _PNP_HwProfFlags(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3037,7 +3044,7 @@ static bool api_PNP_GetHwProfInfo(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetHwProfInfo, r); } - _PNP_GetHwProfInfo(p, r); + r->out.result = _PNP_GetHwProfInfo(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3110,7 +3117,7 @@ static bool api_PNP_AddEmptyLogConf(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_AddEmptyLogConf, r); } - _PNP_AddEmptyLogConf(p, r); + r->out.result = _PNP_AddEmptyLogConf(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3183,7 +3190,7 @@ static bool api_PNP_FreeLogConf(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_FreeLogConf, r); } - _PNP_FreeLogConf(p, r); + r->out.result = _PNP_FreeLogConf(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3256,7 +3263,7 @@ static bool api_PNP_GetFirstLogConf(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetFirstLogConf, r); } - _PNP_GetFirstLogConf(p, r); + r->out.result = _PNP_GetFirstLogConf(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3329,7 +3336,7 @@ static bool api_PNP_GetNextLogConf(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetNextLogConf, r); } - _PNP_GetNextLogConf(p, r); + r->out.result = _PNP_GetNextLogConf(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3402,7 +3409,7 @@ static bool api_PNP_GetLogConfPriority(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetLogConfPriority, r); } - _PNP_GetLogConfPriority(p, r); + r->out.result = _PNP_GetLogConfPriority(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3475,7 +3482,7 @@ static bool api_PNP_AddResDes(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_AddResDes, r); } - _PNP_AddResDes(p, r); + r->out.result = _PNP_AddResDes(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3548,7 +3555,7 @@ static bool api_PNP_FreeResDes(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_FreeResDes, r); } - _PNP_FreeResDes(p, r); + r->out.result = _PNP_FreeResDes(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3621,7 +3628,7 @@ static bool api_PNP_GetNextResDes(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetNextResDes, r); } - _PNP_GetNextResDes(p, r); + r->out.result = _PNP_GetNextResDes(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3694,7 +3701,7 @@ static bool api_PNP_GetResDesData(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetResDesData, r); } - _PNP_GetResDesData(p, r); + r->out.result = _PNP_GetResDesData(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3767,7 +3774,7 @@ static bool api_PNP_GetResDesDataSize(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetResDesDataSize, r); } - _PNP_GetResDesDataSize(p, r); + r->out.result = _PNP_GetResDesDataSize(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3840,7 +3847,7 @@ static bool api_PNP_ModifyResDes(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_ModifyResDes, r); } - _PNP_ModifyResDes(p, r); + r->out.result = _PNP_ModifyResDes(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3913,7 +3920,7 @@ static bool api_PNP_DetectResourceLimit(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_DetectResourceLimit, r); } - _PNP_DetectResourceLimit(p, r); + r->out.result = _PNP_DetectResourceLimit(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -3986,7 +3993,7 @@ static bool api_PNP_QueryResConfList(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_QueryResConfList, r); } - _PNP_QueryResConfList(p, r); + r->out.result = _PNP_QueryResConfList(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4059,7 +4066,7 @@ static bool api_PNP_SetHwProf(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_SetHwProf, r); } - _PNP_SetHwProf(p, r); + r->out.result = _PNP_SetHwProf(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4132,7 +4139,7 @@ static bool api_PNP_QueryArbitratorFreeData(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_QueryArbitratorFreeData, r); } - _PNP_QueryArbitratorFreeData(p, r); + r->out.result = _PNP_QueryArbitratorFreeData(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4205,7 +4212,7 @@ static bool api_PNP_QueryArbitratorFreeSize(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_QueryArbitratorFreeSize, r); } - _PNP_QueryArbitratorFreeSize(p, r); + r->out.result = _PNP_QueryArbitratorFreeSize(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4278,7 +4285,7 @@ static bool api_PNP_RunDetection(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_RunDetection, r); } - _PNP_RunDetection(p, r); + r->out.result = _PNP_RunDetection(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4351,7 +4358,7 @@ static bool api_PNP_RegisterNotification(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_RegisterNotification, r); } - _PNP_RegisterNotification(p, r); + r->out.result = _PNP_RegisterNotification(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4424,7 +4431,7 @@ static bool api_PNP_UnregisterNotification(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_UnregisterNotification, r); } - _PNP_UnregisterNotification(p, r); + r->out.result = _PNP_UnregisterNotification(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4497,7 +4504,7 @@ static bool api_PNP_GetCustomDevProp(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetCustomDevProp, r); } - _PNP_GetCustomDevProp(p, r); + r->out.result = _PNP_GetCustomDevProp(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4570,7 +4577,7 @@ static bool api_PNP_GetVersionInternal(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetVersionInternal, r); } - _PNP_GetVersionInternal(p, r); + r->out.result = _PNP_GetVersionInternal(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4643,7 +4650,7 @@ static bool api_PNP_GetBlockedDriverInfo(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetBlockedDriverInfo, r); } - _PNP_GetBlockedDriverInfo(p, r); + r->out.result = _PNP_GetBlockedDriverInfo(p, r); if (p->rng_fault_state) { talloc_free(r); @@ -4716,7 +4723,7 @@ static bool api_PNP_GetServerSideDeviceInstallFlags(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetServerSideDeviceInstallFlags, r); } - _PNP_GetServerSideDeviceInstallFlags(p, r); + r->out.result = _PNP_GetServerSideDeviceInstallFlags(p, r); if (p->rng_fault_state) { talloc_free(r); diff --git a/source3/librpc/gen_ndr/srv_ntsvcs.h b/source3/librpc/gen_ndr/srv_ntsvcs.h index 0bcd09183e..c3969b11da 100644 --- a/source3/librpc/gen_ndr/srv_ntsvcs.h +++ b/source3/librpc/gen_ndr/srv_ntsvcs.h @@ -1,71 +1,71 @@ #include "librpc/gen_ndr/ndr_ntsvcs.h" #ifndef __SRV_NTSVCS__ #define __SRV_NTSVCS__ -void _PNP_Disconnect(pipes_struct *p, struct PNP_Disconnect *r); -void _PNP_Connect(pipes_struct *p, struct PNP_Connect *r); -void _PNP_GetVersion(pipes_struct *p, struct PNP_GetVersion *r); -void _PNP_GetGlobalState(pipes_struct *p, struct PNP_GetGlobalState *r); -void _PNP_InitDetection(pipes_struct *p, struct PNP_InitDetection *r); -void _PNP_ReportLogOn(pipes_struct *p, struct PNP_ReportLogOn *r); -void _PNP_ValidateDeviceInstance(pipes_struct *p, struct PNP_ValidateDeviceInstance *r); -void _PNP_GetRootDeviceInstance(pipes_struct *p, struct PNP_GetRootDeviceInstance *r); -void _PNP_GetRelatedDeviceInstance(pipes_struct *p, struct PNP_GetRelatedDeviceInstance *r); -void _PNP_EnumerateSubKeys(pipes_struct *p, struct PNP_EnumerateSubKeys *r); -void _PNP_GetDeviceList(pipes_struct *p, struct PNP_GetDeviceList *r); -void _PNP_GetDeviceListSize(pipes_struct *p, struct PNP_GetDeviceListSize *r); -void _PNP_GetDepth(pipes_struct *p, struct PNP_GetDepth *r); -void _PNP_GetDeviceRegProp(pipes_struct *p, struct PNP_GetDeviceRegProp *r); -void _PNP_SetDeviceRegProp(pipes_struct *p, struct PNP_SetDeviceRegProp *r); -void _PNP_GetClassInstance(pipes_struct *p, struct PNP_GetClassInstance *r); -void _PNP_CreateKey(pipes_struct *p, struct PNP_CreateKey *r); -void _PNP_DeleteRegistryKey(pipes_struct *p, struct PNP_DeleteRegistryKey *r); -void _PNP_GetClassCount(pipes_struct *p, struct PNP_GetClassCount *r); -void _PNP_GetClassName(pipes_struct *p, struct PNP_GetClassName *r); -void _PNP_DeleteClassKey(pipes_struct *p, struct PNP_DeleteClassKey *r); -void _PNP_GetInterfaceDeviceAlias(pipes_struct *p, struct PNP_GetInterfaceDeviceAlias *r); -void _PNP_GetInterfaceDeviceList(pipes_struct *p, struct PNP_GetInterfaceDeviceList *r); -void _PNP_GetInterfaceDeviceListSize(pipes_struct *p, struct PNP_GetInterfaceDeviceListSize *r); -void _PNP_RegisterDeviceClassAssociation(pipes_struct *p, struct PNP_RegisterDeviceClassAssociation *r); -void _PNP_UnregisterDeviceClassAssociation(pipes_struct *p, struct PNP_UnregisterDeviceClassAssociation *r); -void _PNP_GetClassRegProp(pipes_struct *p, struct PNP_GetClassRegProp *r); -void _PNP_SetClassRegProp(pipes_struct *p, struct PNP_SetClassRegProp *r); -void _PNP_CreateDevInst(pipes_struct *p, struct PNP_CreateDevInst *r); -void _PNP_DeviceInstanceAction(pipes_struct *p, struct PNP_DeviceInstanceAction *r); -void _PNP_GetDeviceStatus(pipes_struct *p, struct PNP_GetDeviceStatus *r); -void _PNP_SetDeviceProblem(pipes_struct *p, struct PNP_SetDeviceProblem *r); -void _PNP_DisableDevInst(pipes_struct *p, struct PNP_DisableDevInst *r); -void _PNP_UninstallDevInst(pipes_struct *p, struct PNP_UninstallDevInst *r); -void _PNP_AddID(pipes_struct *p, struct PNP_AddID *r); -void _PNP_RegisterDriver(pipes_struct *p, struct PNP_RegisterDriver *r); -void _PNP_QueryRemove(pipes_struct *p, struct PNP_QueryRemove *r); -void _PNP_RequestDeviceEject(pipes_struct *p, struct PNP_RequestDeviceEject *r); -void _PNP_IsDockStationPresent(pipes_struct *p, struct PNP_IsDockStationPresent *r); -void _PNP_RequestEjectPC(pipes_struct *p, struct PNP_RequestEjectPC *r); -void _PNP_HwProfFlags(pipes_struct *p, struct PNP_HwProfFlags *r); -void _PNP_GetHwProfInfo(pipes_struct *p, struct PNP_GetHwProfInfo *r); -void _PNP_AddEmptyLogConf(pipes_struct *p, struct PNP_AddEmptyLogConf *r); -void _PNP_FreeLogConf(pipes_struct *p, struct PNP_FreeLogConf *r); -void _PNP_GetFirstLogConf(pipes_struct *p, struct PNP_GetFirstLogConf *r); -void _PNP_GetNextLogConf(pipes_struct *p, struct PNP_GetNextLogConf *r); -void _PNP_GetLogConfPriority(pipes_struct *p, struct PNP_GetLogConfPriority *r); -void _PNP_AddResDes(pipes_struct *p, struct PNP_AddResDes *r); -void _PNP_FreeResDes(pipes_struct *p, struct PNP_FreeResDes *r); -void _PNP_GetNextResDes(pipes_struct *p, struct PNP_GetNextResDes *r); -void _PNP_GetResDesData(pipes_struct *p, struct PNP_GetResDesData *r); -void _PNP_GetResDesDataSize(pipes_struct *p, struct PNP_GetResDesDataSize *r); -void _PNP_ModifyResDes(pipes_struct *p, struct PNP_ModifyResDes *r); -void _PNP_DetectResourceLimit(pipes_struct *p, struct PNP_DetectResourceLimit *r); -void _PNP_QueryResConfList(pipes_struct *p, struct PNP_QueryResConfList *r); -void _PNP_SetHwProf(pipes_struct *p, struct PNP_SetHwProf *r); -void _PNP_QueryArbitratorFreeData(pipes_struct *p, struct PNP_QueryArbitratorFreeData *r); -void _PNP_QueryArbitratorFreeSize(pipes_struct *p, struct PNP_QueryArbitratorFreeSize *r); -void _PNP_RunDetection(pipes_struct *p, struct PNP_RunDetection *r); -void _PNP_RegisterNotification(pipes_struct *p, struct PNP_RegisterNotification *r); -void _PNP_UnregisterNotification(pipes_struct *p, struct PNP_UnregisterNotification *r); -void _PNP_GetCustomDevProp(pipes_struct *p, struct PNP_GetCustomDevProp *r); -void _PNP_GetVersionInternal(pipes_struct *p, struct PNP_GetVersionInternal *r); -void _PNP_GetBlockedDriverInfo(pipes_struct *p, struct PNP_GetBlockedDriverInfo *r); -void _PNP_GetServerSideDeviceInstallFlags(pipes_struct *p, struct PNP_GetServerSideDeviceInstallFlags *r); +WERROR _PNP_Disconnect(pipes_struct *p, struct PNP_Disconnect *r); +WERROR _PNP_Connect(pipes_struct *p, struct PNP_Connect *r); +WERROR _PNP_GetVersion(pipes_struct *p, struct PNP_GetVersion *r); +WERROR _PNP_GetGlobalState(pipes_struct *p, struct PNP_GetGlobalState *r); +WERROR _PNP_InitDetection(pipes_struct *p, struct PNP_InitDetection *r); +WERROR _PNP_ReportLogOn(pipes_struct *p, struct PNP_ReportLogOn *r); +WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, struct PNP_ValidateDeviceInstance *r); +WERROR _PNP_GetRootDeviceInstance(pipes_struct *p, struct PNP_GetRootDeviceInstance *r); +WERROR _PNP_GetRelatedDeviceInstance(pipes_struct *p, struct PNP_GetRelatedDeviceInstance *r); +WERROR _PNP_EnumerateSubKeys(pipes_struct *p, struct PNP_EnumerateSubKeys *r); +WERROR _PNP_GetDeviceList(pipes_struct *p, struct PNP_GetDeviceList *r); +WERROR _PNP_GetDeviceListSize(pipes_struct *p, struct PNP_GetDeviceListSize *r); +WERROR _PNP_GetDepth(pipes_struct *p, struct PNP_GetDepth *r); +WERROR _PNP_GetDeviceRegProp(pipes_struct *p, struct PNP_GetDeviceRegProp *r); +WERROR _PNP_SetDeviceRegProp(pipes_struct *p, struct PNP_SetDeviceRegProp *r); +WERROR _PNP_GetClassInstance(pipes_struct *p, struct PNP_GetClassInstance *r); +WERROR _PNP_CreateKey(pipes_struct *p, struct PNP_CreateKey *r); +WERROR _PNP_DeleteRegistryKey(pipes_struct *p, struct PNP_DeleteRegistryKey *r); +WERROR _PNP_GetClassCount(pipes_struct *p, struct PNP_GetClassCount *r); +WERROR _PNP_GetClassName(pipes_struct *p, struct PNP_GetClassName *r); +WERROR _PNP_DeleteClassKey(pipes_struct *p, struct PNP_DeleteClassKey *r); +WERROR _PNP_GetInterfaceDeviceAlias(pipes_struct *p, struct PNP_GetInterfaceDeviceAlias *r); +WERROR _PNP_GetInterfaceDeviceList(pipes_struct *p, struct PNP_GetInterfaceDeviceList *r); +WERROR _PNP_GetInterfaceDeviceListSize(pipes_struct *p, struct PNP_GetInterfaceDeviceListSize *r); +WERROR _PNP_RegisterDeviceClassAssociation(pipes_struct *p, struct PNP_RegisterDeviceClassAssociation *r); +WERROR _PNP_UnregisterDeviceClassAssociation(pipes_struct *p, struct PNP_UnregisterDeviceClassAssociation *r); +WERROR _PNP_GetClassRegProp(pipes_struct *p, struct PNP_GetClassRegProp *r); +WERROR _PNP_SetClassRegProp(pipes_struct *p, struct PNP_SetClassRegProp *r); +WERROR _PNP_CreateDevInst(pipes_struct *p, struct PNP_CreateDevInst *r); +WERROR _PNP_DeviceInstanceAction(pipes_struct *p, struct PNP_DeviceInstanceAction *r); +WERROR _PNP_GetDeviceStatus(pipes_struct *p, struct PNP_GetDeviceStatus *r); +WERROR _PNP_SetDeviceProblem(pipes_struct *p, struct PNP_SetDeviceProblem *r); +WERROR _PNP_DisableDevInst(pipes_struct *p, struct PNP_DisableDevInst *r); +WERROR _PNP_UninstallDevInst(pipes_struct *p, struct PNP_UninstallDevInst *r); +WERROR _PNP_AddID(pipes_struct *p, struct PNP_AddID *r); +WERROR _PNP_RegisterDriver(pipes_struct *p, struct PNP_RegisterDriver *r); +WERROR _PNP_QueryRemove(pipes_struct *p, struct PNP_QueryRemove *r); +WERROR _PNP_RequestDeviceEject(pipes_struct *p, struct PNP_RequestDeviceEject *r); +WERROR _PNP_IsDockStationPresent(pipes_struct *p, struct PNP_IsDockStationPresent *r); +WERROR _PNP_RequestEjectPC(pipes_struct *p, struct PNP_RequestEjectPC *r); +WERROR _PNP_HwProfFlags(pipes_struct *p, struct PNP_HwProfFlags *r); +WERROR _PNP_GetHwProfInfo(pipes_struct *p, struct PNP_GetHwProfInfo *r); +WERROR _PNP_AddEmptyLogConf(pipes_struct *p, struct PNP_AddEmptyLogConf *r); +WERROR _PNP_FreeLogConf(pipes_struct *p, struct PNP_FreeLogConf *r); +WERROR _PNP_GetFirstLogConf(pipes_struct *p, struct PNP_GetFirstLogConf *r); +WERROR _PNP_GetNextLogConf(pipes_struct *p, struct PNP_GetNextLogConf *r); +WERROR _PNP_GetLogConfPriority(pipes_struct *p, struct PNP_GetLogConfPriority *r); +WERROR _PNP_AddResDes(pipes_struct *p, struct PNP_AddResDes *r); +WERROR _PNP_FreeResDes(pipes_struct *p, struct PNP_FreeResDes *r); +WERROR _PNP_GetNextResDes(pipes_struct *p, struct PNP_GetNextResDes *r); +WERROR _PNP_GetResDesData(pipes_struct *p, struct PNP_GetResDesData *r); +WERROR _PNP_GetResDesDataSize(pipes_struct *p, struct PNP_GetResDesDataSize *r); +WERROR _PNP_ModifyResDes(pipes_struct *p, struct PNP_ModifyResDes *r); +WERROR _PNP_DetectResourceLimit(pipes_struct *p, struct PNP_DetectResourceLimit *r); +WERROR _PNP_QueryResConfList(pipes_struct *p, struct PNP_QueryResConfList *r); +WERROR _PNP_SetHwProf(pipes_struct *p, struct PNP_SetHwProf *r); +WERROR _PNP_QueryArbitratorFreeData(pipes_struct *p, struct PNP_QueryArbitratorFreeData *r); +WERROR _PNP_QueryArbitratorFreeSize(pipes_struct *p, struct PNP_QueryArbitratorFreeSize *r); +WERROR _PNP_RunDetection(pipes_struct *p, struct PNP_RunDetection *r); +WERROR _PNP_RegisterNotification(pipes_struct *p, struct PNP_RegisterNotification *r); +WERROR _PNP_UnregisterNotification(pipes_struct *p, struct PNP_UnregisterNotification *r); +WERROR _PNP_GetCustomDevProp(pipes_struct *p, struct PNP_GetCustomDevProp *r); +WERROR _PNP_GetVersionInternal(pipes_struct *p, struct PNP_GetVersionInternal *r); +WERROR _PNP_GetBlockedDriverInfo(pipes_struct *p, struct PNP_GetBlockedDriverInfo *r); +WERROR _PNP_GetServerSideDeviceInstallFlags(pipes_struct *p, struct PNP_GetServerSideDeviceInstallFlags *r); void ntsvcs_get_pipe_fns(struct api_struct **fns, int *n_fns); NTSTATUS rpc_ntsvcs_init(void); #endif /* __SRV_NTSVCS__ */ -- cgit From e99f740b0ab5eef11cb3ae1f432dc9669b0a753a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:16:56 +0100 Subject: Add very basic ntsvcs client to rpcclient. Guenther (This used to be commit 0358ad7e933f6a0859000ba56e4bb88506d70610) --- source3/Makefile.in | 4 ++-- source3/rpcclient/cmd_ntsvcs.c | 51 ++++++++++++++++++++++++++++++++++++++++++ source3/rpcclient/rpcclient.c | 2 ++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 source3/rpcclient/cmd_ntsvcs.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index f2971ff176..e380ad2028 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -740,8 +740,8 @@ RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_lsarpc.o \ rpcclient/cmd_dfs.o \ rpcclient/cmd_dssetup.o rpcclient/cmd_echo.o \ rpcclient/cmd_shutdown.o rpcclient/cmd_test.o \ - rpcclient/cmd_wkssvc.o \ - $(DISPLAY_SEC_OBJ) $(DISPLAY_DSDCINFO_OBJ) + rpcclient/cmd_wkssvc.o rpcclient/cmd_ntsvcs.o \ + $(DISPLAY_SEC_OBJ) RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \ $(PARAM_OBJ) $(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) \ diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c new file mode 100644 index 0000000000..a595948c35 --- /dev/null +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -0,0 +1,51 @@ +/* + Unix SMB/CIFS implementation. + RPC pipe client + + Copyright (C) Günther 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 "includes.h" +#include "rpcclient.h" + +static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + uint16_t version; + + status = rpccli_PNP_GetVersion(cli, mem_ctx, + &version, &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (W_ERROR_IS_OK(werr)) { + printf("version: %d\n", version); + } + + return werr; +} + +struct cmd_set ntsvcs_commands[] = { + + { "NTSVCS" }, + { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" }, + { NULL } +}; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 4a9b4acb7d..5e87058111 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -503,6 +503,7 @@ extern struct cmd_set echo_commands[]; extern struct cmd_set shutdown_commands[]; extern struct cmd_set test_commands[]; extern struct cmd_set wkssvc_commands[]; +extern struct cmd_set ntsvcs_commands[]; static struct cmd_set *rpcclient_command_list[] = { rpcclient_commands, @@ -517,6 +518,7 @@ static struct cmd_set *rpcclient_command_list[] = { shutdown_commands, test_commands, wkssvc_commands, + ntsvcs_commands, NULL }; -- cgit From 3758f06d0f56a1ff86073e91c584e0153d53fd9e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:17:51 +0100 Subject: Use pidl for _PNP_GetVersion(). Guenther (This used to be commit 5300ff01b9098ccd78cb38b4d6abc85b2d340a55) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 17 ++++------------- 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 0734a60b4d..ec65919646 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -48,23 +48,7 @@ static bool proxy_ntsvcs_call(pipes_struct *p, uint8_t opnum) static bool api_ntsvcs_get_version(pipes_struct *p) { - NTSVCS_Q_GET_VERSION q_u; - NTSVCS_R_GET_VERSION r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_get_version("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_get_version(p, &q_u, &r_u); - - if(!ntsvcs_io_r_get_version("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_GETVERSION); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index c7ca0df097..0cf2e5cc19 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -34,10 +34,11 @@ static char* get_device_path(TALLOC_CTX *mem_ctx, const char *device ) /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_get_version( pipes_struct *p, NTSVCS_Q_GET_VERSION *q_u, NTSVCS_R_GET_VERSION *r_u ) +WERROR _PNP_GetVersion(pipes_struct *p, + struct PNP_GetVersion *r) { - r_u->version = 0x00000400; /* no idea what this means */ - + *r->out.version = 0x0400; /* no idea what this means */ + return WERR_OK; } @@ -197,16 +198,6 @@ WERROR _PNP_Connect(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_GetVersion(pipes_struct *p, - struct PNP_GetVersion *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_GetGlobalState(pipes_struct *p, struct PNP_GetGlobalState *r) { -- cgit From dbcd8b76a63f99e746c4f238e021a7692c29fa48 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:37:45 +0100 Subject: Remove unused marshalling for NTSVCS_GET_VERSION. Guenther (This used to be commit 58970cc6a8761c30bc4b772b28bb25a112cb684f) --- source3/include/rpc_ntsvcs.h | 13 ------------- source3/rpc_parse/parse_ntsvcs.c | 37 ------------------------------------- 2 files changed, 50 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_ntsvcs.h b/source3/include/rpc_ntsvcs.h index 045d9b4e92..a2c40384f7 100644 --- a/source3/include/rpc_ntsvcs.h +++ b/source3/include/rpc_ntsvcs.h @@ -33,19 +33,6 @@ #define NTSVCS_GET_VERSION_INTERNAL 0x3e -/**************************/ - -typedef struct { - /* nothing in the request */ - uint32 dummy; -} NTSVCS_Q_GET_VERSION; - -typedef struct { - uint32 version; - WERROR status; -} NTSVCS_R_GET_VERSION; - - /**************************/ typedef struct { diff --git a/source3/rpc_parse/parse_ntsvcs.c b/source3/rpc_parse/parse_ntsvcs.c index 5758517ca0..89ba2030fb 100644 --- a/source3/rpc_parse/parse_ntsvcs.c +++ b/source3/rpc_parse/parse_ntsvcs.c @@ -25,43 +25,6 @@ /******************************************************************* ********************************************************************/ -bool ntsvcs_io_q_get_version(const char *desc, NTSVCS_Q_GET_VERSION *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_q_get_version"); - depth++; - - /* there is nothing to parse in this PDU */ - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool ntsvcs_io_r_get_version(const char *desc, NTSVCS_R_GET_VERSION *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_r_get_version"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("version", ps, depth, &r_u->version)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - /******************************************************************* ********************************************************************/ -- cgit From 75a2503a3250f619bb1c669349ef982e85898cc2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:40:14 +0100 Subject: Fill in IDL for PNP_ValidateDeviceInstance (based on samba3). Guenther (This used to be commit 3ebece24eb7c1898963fd95b4ab4d66d3c5d1d49) --- source3/librpc/idl/ntsvcs.idl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/ntsvcs.idl b/source3/librpc/idl/ntsvcs.idl index 3c38bc3b91..a9c41cc21e 100644 --- a/source3/librpc/idl/ntsvcs.idl +++ b/source3/librpc/idl/ntsvcs.idl @@ -44,7 +44,10 @@ interface ntsvcs /******************/ /* Function: 0x06 */ - WERROR PNP_ValidateDeviceInstance(); + WERROR PNP_ValidateDeviceInstance( + [in,ref] [string,charset(UTF16)] uint16 *devicepath, + [in] uint32 flags + ); /******************/ /* Function: 0x07 */ -- cgit From d7382054d7a82cf85505205370996d2abf1e62ae Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:44:50 +0100 Subject: Re-run make idl. Guenther (This used to be commit 6f396608bda65c98dfbb13f6e8661a8246c649a2) --- source3/librpc/gen_ndr/cli_ntsvcs.c | 4 ++++ source3/librpc/gen_ndr/cli_ntsvcs.h | 2 ++ source3/librpc/gen_ndr/ndr_ntsvcs.c | 21 +++++++++++++++++++++ source3/librpc/gen_ndr/ntsvcs.h | 5 +++++ 4 files changed, 32 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.c b/source3/librpc/gen_ndr/cli_ntsvcs.c index da43d451e6..c21910c95b 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.c +++ b/source3/librpc/gen_ndr/cli_ntsvcs.c @@ -262,12 +262,16 @@ NTSTATUS rpccli_PNP_ReportLogOn(struct rpc_pipe_client *cli, NTSTATUS rpccli_PNP_ValidateDeviceInstance(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *devicepath, + uint32_t flags, WERROR *werror) { struct PNP_ValidateDeviceInstance r; NTSTATUS status; /* In parameters */ + r.in.devicepath = devicepath; + r.in.flags = flags; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(PNP_ValidateDeviceInstance, &r); diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.h b/source3/librpc/gen_ndr/cli_ntsvcs.h index 852cc812e9..666ea9bac8 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.h +++ b/source3/librpc/gen_ndr/cli_ntsvcs.h @@ -22,6 +22,8 @@ NTSTATUS rpccli_PNP_ReportLogOn(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_PNP_ValidateDeviceInstance(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *devicepath, + uint32_t flags, WERROR *werror); NTSTATUS rpccli_PNP_GetRootDeviceInstance(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.c b/source3/librpc/gen_ndr/ndr_ntsvcs.c index 73dd4d346c..be55319947 100644 --- a/source3/librpc/gen_ndr/ndr_ntsvcs.c +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c @@ -272,6 +272,14 @@ _PUBLIC_ void ndr_print_PNP_ReportLogOn(struct ndr_print *ndr, const char *name, static enum ndr_err_code ndr_push_PNP_ValidateDeviceInstance(struct ndr_push *ndr, int flags, const struct PNP_ValidateDeviceInstance *r) { if (flags & NDR_IN) { + if (r->in.devicepath == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicepath, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicepath, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.devicepath, ndr_charset_length(r->in.devicepath, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.flags)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); @@ -282,6 +290,14 @@ static enum ndr_err_code ndr_push_PNP_ValidateDeviceInstance(struct ndr_push *nd static enum ndr_err_code ndr_pull_PNP_ValidateDeviceInstance(struct ndr_pull *ndr, int flags, struct PNP_ValidateDeviceInstance *r) { if (flags & NDR_IN) { + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.devicepath)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.devicepath)); + if (ndr_get_array_length(ndr, &r->in.devicepath) > ndr_get_array_size(ndr, &r->in.devicepath)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.devicepath), ndr_get_array_length(ndr, &r->in.devicepath)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.devicepath), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.devicepath, ndr_get_array_length(ndr, &r->in.devicepath), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); @@ -299,6 +315,11 @@ _PUBLIC_ void ndr_print_PNP_ValidateDeviceInstance(struct ndr_print *ndr, const if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "PNP_ValidateDeviceInstance"); ndr->depth++; + ndr_print_ptr(ndr, "devicepath", r->in.devicepath); + ndr->depth++; + ndr_print_string(ndr, "devicepath", r->in.devicepath); + ndr->depth--; + ndr_print_uint32(ndr, "flags", r->in.flags); ndr->depth--; } if (flags & NDR_OUT) { diff --git a/source3/librpc/gen_ndr/ntsvcs.h b/source3/librpc/gen_ndr/ntsvcs.h index 571b7466c2..477d6adf7f 100644 --- a/source3/librpc/gen_ndr/ntsvcs.h +++ b/source3/librpc/gen_ndr/ntsvcs.h @@ -56,6 +56,11 @@ struct PNP_ReportLogOn { struct PNP_ValidateDeviceInstance { + struct { + const char *devicepath;/* [ref,charset(UTF16)] */ + uint32_t flags; + } in; + struct { WERROR result; } out; -- cgit From 948bfd629eec03bac3715c17f9d30b3995a2e2e1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:41:31 +0100 Subject: Add ValidateDeviceInstance command to rpcclient. Guenther (This used to be commit a2e6727ff7d75b50a33c4186f48477ca35b3fbb9) --- source3/rpcclient/cmd_ntsvcs.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source3') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c index a595948c35..f7648061c2 100644 --- a/source3/rpcclient/cmd_ntsvcs.c +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -43,9 +43,42 @@ static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + const char *devicepath = NULL; + uint32_t flags = 0; + + if (argc < 2 || argc > 3) { + printf("usage: %s [devicepath] \n", argv[0]); + return WERR_OK; + } + + devicepath = argv[1]; + + if (argc >= 3) { + flags = atoi(argv[2]); + } + + status = rpccli_PNP_ValidateDeviceInstance(cli, mem_ctx, + devicepath, + flags, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + return werr; +} + struct cmd_set ntsvcs_commands[] = { { "NTSVCS" }, { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" }, + { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" }, { NULL } }; -- cgit From 45c6af356ee071f65ce98a7c88ddcd2393c907b1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:42:20 +0100 Subject: Use pidl for _PNP_ValidateDeviceInstance(). Guenther (This used to be commit 7973a103aa91497807cb0e3bf19dba172ae613b8) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 13 ++----------- 2 files changed, 3 insertions(+), 28 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index ec65919646..cd2248926c 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -104,23 +104,7 @@ static bool api_ntsvcs_get_device_list(pipes_struct *p) static bool api_ntsvcs_validate_device_instance(pipes_struct *p) { - NTSVCS_Q_VALIDATE_DEVICE_INSTANCE q_u; - NTSVCS_R_VALIDATE_DEVICE_INSTANCE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_validate_device_instance("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_validate_device_instance(p, &q_u, &r_u); - - if(!ntsvcs_io_r_validate_device_instance("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_VALIDATEDEVICEINSTANCE); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 0cf2e5cc19..b6e0126fa6 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -144,7 +144,8 @@ WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_validate_device_instance( pipes_struct *p, NTSVCS_Q_VALIDATE_DEVICE_INSTANCE *q_u, NTSVCS_R_VALIDATE_DEVICE_INSTANCE *r_u ) +WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, + struct PNP_ValidateDeviceInstance *r) { /* whatever dude */ return WERR_OK; @@ -228,16 +229,6 @@ WERROR _PNP_ReportLogOn(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, - struct PNP_ValidateDeviceInstance *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_GetRootDeviceInstance(pipes_struct *p, struct PNP_GetRootDeviceInstance *r) { -- cgit From 342d7fd099eb23a5fa8e416197f8f08e121ae86b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:42:52 +0100 Subject: Remove unused marshalling for NTSVCS_VALIDATE_DEVICE_INSTANCE. Guenther (This used to be commit 8971afaf744e5124d4b82cad76e368ccd05be394) --- source3/include/rpc_ntsvcs.h | 11 ---------- source3/rpc_parse/parse_ntsvcs.c | 43 ---------------------------------------- 2 files changed, 54 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_ntsvcs.h b/source3/include/rpc_ntsvcs.h index a2c40384f7..12224fe957 100644 --- a/source3/include/rpc_ntsvcs.h +++ b/source3/include/rpc_ntsvcs.h @@ -62,17 +62,6 @@ typedef struct { /**************************/ -typedef struct { - UNISTR2 devicepath; - uint32 flags; -} NTSVCS_Q_VALIDATE_DEVICE_INSTANCE; - -typedef struct { - WERROR status; -} NTSVCS_R_VALIDATE_DEVICE_INSTANCE; - -/**************************/ - #define DEV_REGPROP_DESC 1 typedef struct { diff --git a/source3/rpc_parse/parse_ntsvcs.c b/source3/rpc_parse/parse_ntsvcs.c index 89ba2030fb..86e8d9d952 100644 --- a/source3/rpc_parse/parse_ntsvcs.c +++ b/source3/rpc_parse/parse_ntsvcs.c @@ -134,49 +134,6 @@ bool ntsvcs_io_r_get_device_list(const char *desc, NTSVCS_R_GET_DEVICE_LIST *r_u /******************************************************************* ********************************************************************/ -bool ntsvcs_io_q_validate_device_instance(const char *desc, NTSVCS_Q_VALIDATE_DEVICE_INSTANCE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_q_validate_device_instance"); - depth++; - - if(!prs_align(ps)) - return False; - - if ( !prs_io_unistr2("devicepath", ps, depth, &q_u->devicepath) ) - return False; - if( !prs_align(ps) ) - return False; - - if ( !prs_uint32("flags", ps, depth, &q_u->flags) ) - return False; - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool ntsvcs_io_r_validate_device_instance(const char *desc, NTSVCS_R_VALIDATE_DEVICE_INSTANCE *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_r_validate_device_instance"); - depth++; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - bool ntsvcs_io_q_get_device_reg_property(const char *desc, NTSVCS_Q_GET_DEVICE_REG_PROPERTY *q_u, prs_struct *ps, int depth) { if (q_u == NULL) -- cgit From 9a1881598cd4f91485f7b44471b883ede9c3a73f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 00:22:45 +0100 Subject: Fill in IDL PNP_GetDeviceListSize() based on samba3. Guenther (This used to be commit 9d7699cbe4ba3536d7acf8e06374e33c036a2d2a) --- source3/librpc/idl/ntsvcs.idl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/ntsvcs.idl b/source3/librpc/idl/ntsvcs.idl index a9c41cc21e..78ac30783b 100644 --- a/source3/librpc/idl/ntsvcs.idl +++ b/source3/librpc/idl/ntsvcs.idl @@ -72,7 +72,11 @@ interface ntsvcs /******************/ /* Function: 0x0b */ - WERROR PNP_GetDeviceListSize(); + WERROR PNP_GetDeviceListSize( + [in,unique] [string,charset(UTF16)] uint16 *devicename, + [out,ref] uint32 *size, + [in] uint32 flags + ); /******************/ /* Function: 0x0c */ -- cgit From 560725930663e635b5b602dbb712b602d9c5f35b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 00:26:10 +0100 Subject: Re-run make idl. Guenther (This used to be commit c7c89317db3774e75013dec67e44100d7276c939) --- source3/librpc/gen_ndr/cli_ntsvcs.c | 6 ++++ source3/librpc/gen_ndr/cli_ntsvcs.h | 3 ++ source3/librpc/gen_ndr/ndr_ntsvcs.c | 56 +++++++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/ntsvcs.h | 6 ++++ source3/librpc/gen_ndr/srv_ntsvcs.c | 7 +++++ 5 files changed, 78 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.c b/source3/librpc/gen_ndr/cli_ntsvcs.c index c21910c95b..7f27580605 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.c +++ b/source3/librpc/gen_ndr/cli_ntsvcs.c @@ -476,12 +476,17 @@ NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *devicename, + uint32_t *size, + uint32_t flags, WERROR *werror) { struct PNP_GetDeviceListSize r; NTSTATUS status; /* In parameters */ + r.in.devicename = devicename; + r.in.flags = flags; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(PNP_GetDeviceListSize, &r); @@ -507,6 +512,7 @@ NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, } /* Return variables */ + *size = *r.out.size; /* Return result */ if (werror) { diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.h b/source3/librpc/gen_ndr/cli_ntsvcs.h index 666ea9bac8..911200055f 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.h +++ b/source3/librpc/gen_ndr/cli_ntsvcs.h @@ -39,6 +39,9 @@ NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *devicename, + uint32_t *size, + uint32_t flags, WERROR *werror); NTSTATUS rpccli_PNP_GetDepth(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.c b/source3/librpc/gen_ndr/ndr_ntsvcs.c index be55319947..c66ec2aa87 100644 --- a/source3/librpc/gen_ndr/ndr_ntsvcs.c +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c @@ -498,8 +498,20 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceList(struct ndr_print *ndr, const char *nam static enum ndr_err_code ndr_push_PNP_GetDeviceListSize(struct ndr_push *ndr, int flags, const struct PNP_GetDeviceListSize *r) { if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.devicename)); + if (r->in.devicename) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicename, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicename, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.devicename, ndr_charset_length(r->in.devicename, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.flags)); } if (flags & NDR_OUT) { + if (r->out.size == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.size)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -507,9 +519,42 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceListSize(struct ndr_push *ndr, in static enum ndr_err_code ndr_pull_PNP_GetDeviceListSize(struct ndr_pull *ndr, int flags, struct PNP_GetDeviceListSize *r) { + uint32_t _ptr_devicename; + TALLOC_CTX *_mem_save_devicename_0; + TALLOC_CTX *_mem_save_size_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devicename)); + if (_ptr_devicename) { + NDR_PULL_ALLOC(ndr, r->in.devicename); + } else { + r->in.devicename = NULL; + } + if (r->in.devicename) { + _mem_save_devicename_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.devicename, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.devicename)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.devicename)); + if (ndr_get_array_length(ndr, &r->in.devicename) > ndr_get_array_size(ndr, &r->in.devicename)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.devicename), ndr_get_array_length(ndr, &r->in.devicename)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.devicename), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.devicename, ndr_get_array_length(ndr, &r->in.devicename), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devicename_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags)); + NDR_PULL_ALLOC(ndr, r->out.size); + ZERO_STRUCTP(r->out.size); } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.size); + } + _mem_save_size_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.size, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.size)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_size_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -525,11 +570,22 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceListSize(struct ndr_print *ndr, const char if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "PNP_GetDeviceListSize"); ndr->depth++; + ndr_print_ptr(ndr, "devicename", r->in.devicename); + ndr->depth++; + if (r->in.devicename) { + ndr_print_string(ndr, "devicename", r->in.devicename); + } + ndr->depth--; + ndr_print_uint32(ndr, "flags", r->in.flags); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetDeviceListSize"); ndr->depth++; + ndr_print_ptr(ndr, "size", r->out.size); + ndr->depth++; + ndr_print_uint32(ndr, "size", *r->out.size); + ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/ntsvcs.h b/source3/librpc/gen_ndr/ntsvcs.h index 477d6adf7f..2384011789 100644 --- a/source3/librpc/gen_ndr/ntsvcs.h +++ b/source3/librpc/gen_ndr/ntsvcs.h @@ -102,6 +102,12 @@ struct PNP_GetDeviceList { struct PNP_GetDeviceListSize { struct { + const char *devicename;/* [unique,charset(UTF16)] */ + uint32_t flags; + } in; + + struct { + uint32_t *size;/* [ref] */ WERROR result; } out; diff --git a/source3/librpc/gen_ndr/srv_ntsvcs.c b/source3/librpc/gen_ndr/srv_ntsvcs.c index 7bbf9d1bfa..608353c480 100644 --- a/source3/librpc/gen_ndr/srv_ntsvcs.c +++ b/source3/librpc/gen_ndr/srv_ntsvcs.c @@ -854,6 +854,13 @@ static bool api_PNP_GetDeviceListSize(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetDeviceListSize, r); } + ZERO_STRUCT(r->out); + r->out.size = talloc_zero(r, uint32_t); + if (r->out.size == NULL) { + talloc_free(r); + return false; + } + r->out.result = _PNP_GetDeviceListSize(p, r); if (p->rng_fault_state) { -- cgit From 2e75900641b57d6a369d07efca817557650d9b8e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 00:23:25 +0100 Subject: Add ntsvcs_getdevlistsize command to rpcclient. Guenther (This used to be commit 9bc5068cc387cd02e53db6146db9b4ed0af3160d) --- source3/rpcclient/cmd_ntsvcs.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'source3') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c index f7648061c2..04e367abdb 100644 --- a/source3/rpcclient/cmd_ntsvcs.c +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -75,10 +75,50 @@ static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_ntsvcs_get_device_list_size(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + const char *devicename = NULL; + uint32_t flags = 0; + uint32_t size = 0; + + if (argc < 2 || argc > 4) { + printf("usage: %s [devicename] \n", argv[0]); + return WERR_OK; + } + + devicename = argv[1]; + + if (argc >= 3) { + flags = atoi(argv[2]); + } + + status = rpccli_PNP_GetDeviceListSize(cli, mem_ctx, + devicename, + &size, + flags, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (W_ERROR_IS_OK(werr)) { + printf("size: %d\n", size); + } + + return werr; +} + + struct cmd_set ntsvcs_commands[] = { { "NTSVCS" }, { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" }, { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" }, + { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_device_list_size, PI_NTSVCS, NULL, "Query NTSVCS get device list", "" }, { NULL } }; -- cgit From 3df6eedccfb1faeb778c4761594a6347bbf0b4b3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 00:21:56 +0100 Subject: Use pidl for _PNP_GetDeviceListSize(). Guenther (This used to be commit da6636577dbbdabd248ea87a07819c5e63577f86) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 23 ++++++----------------- 2 files changed, 7 insertions(+), 34 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index cd2248926c..73d4b4f4ed 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -56,23 +56,7 @@ static bool api_ntsvcs_get_version(pipes_struct *p) static bool api_ntsvcs_get_device_list_size(pipes_struct *p) { - NTSVCS_Q_GET_DEVICE_LIST_SIZE q_u; - NTSVCS_R_GET_DEVICE_LIST_SIZE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_get_device_list_size("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_get_device_list_size(p, &q_u, &r_u); - - if(!ntsvcs_io_r_get_device_list_size("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_GETDEVICELISTSIZE); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index b6e0126fa6..76bc24e7ba 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -45,21 +45,20 @@ WERROR _PNP_GetVersion(pipes_struct *p, /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u ) +WERROR _PNP_GetDeviceListSize(pipes_struct *p, + struct PNP_GetDeviceListSize *r) { - fstring device; char *devicepath; - if ( !q_u->devicename ) + if (!r->in.devicename) { return WERR_ACCESS_DENIED; + } - rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0); - - if (!(devicepath = get_device_path(p->mem_ctx, device))) { + if (!(devicepath = get_device_path(p->mem_ctx, r->in.devicename))) { return WERR_NOMEM; } - r_u->size = strlen(devicepath) + 2; + *r->out.size = strlen(devicepath) + 2; TALLOC_FREE(devicepath); @@ -269,16 +268,6 @@ WERROR _PNP_GetDeviceList(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_GetDeviceListSize(pipes_struct *p, - struct PNP_GetDeviceListSize *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_GetDepth(pipes_struct *p, struct PNP_GetDepth *r) { -- cgit From 9501a920c3b9c680bd0e16b941e084206afb1361 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 00:24:57 +0100 Subject: Remove unused marshalling for NTSVCS_GET_DEVICE_LIST_SIZE. Guenther (This used to be commit bc1df536fa04e004ccf177e0f3ba56f3c47709aa) --- source3/include/rpc_ntsvcs.h | 13 ---------- source3/rpc_parse/parse_ntsvcs.c | 53 ---------------------------------------- 2 files changed, 66 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_ntsvcs.h b/source3/include/rpc_ntsvcs.h index 12224fe957..55f36628aa 100644 --- a/source3/include/rpc_ntsvcs.h +++ b/source3/include/rpc_ntsvcs.h @@ -33,19 +33,6 @@ #define NTSVCS_GET_VERSION_INTERNAL 0x3e -/**************************/ - -typedef struct { - UNISTR2 *devicename; - uint32 flags; -} NTSVCS_Q_GET_DEVICE_LIST_SIZE; - -typedef struct { - uint32 size; - WERROR status; -} NTSVCS_R_GET_DEVICE_LIST_SIZE; - - /**************************/ typedef struct { diff --git a/source3/rpc_parse/parse_ntsvcs.c b/source3/rpc_parse/parse_ntsvcs.c index 86e8d9d952..faa7f8ddd3 100644 --- a/source3/rpc_parse/parse_ntsvcs.c +++ b/source3/rpc_parse/parse_ntsvcs.c @@ -22,59 +22,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_PARSE -/******************************************************************* -********************************************************************/ - -/******************************************************************* -********************************************************************/ - -bool ntsvcs_io_q_get_device_list_size(const char *desc, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_q_get_device_list_size"); - depth++; - - if(!prs_align(ps)) - return False; - - if ( !prs_pointer("devicename", ps, depth, (void*)&q_u->devicename, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2) ) - return False; - if ( !prs_align(ps) ) - return False; - - if ( !prs_uint32("flags", ps, depth, &q_u->flags) ) - return False; - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool ntsvcs_io_r_get_device_list_size(const char *desc, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_r_get_device_list_size"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("size", ps, depth, &r_u->size)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - /******************************************************************* ********************************************************************/ -- cgit From 2b141dec9819a434a4d200a39d37a7b5493c9a5c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:06:08 +0100 Subject: Fill in (very unfinished) IDL for PNP_HwProfFlags. Guenther (This used to be commit 121e73aa49a95b3cdb2b680c0ee30d8308bd5988) --- source3/librpc/idl/ntsvcs.idl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/ntsvcs.idl b/source3/librpc/idl/ntsvcs.idl index 78ac30783b..0b8f5c3e0b 100644 --- a/source3/librpc/idl/ntsvcs.idl +++ b/source3/librpc/idl/ntsvcs.idl @@ -221,7 +221,17 @@ interface ntsvcs /******************/ /* Function: 0x28 */ - WERROR PNP_HwProfFlags(); + WERROR PNP_HwProfFlags( + [in] uint32 unknown1, + [in,ref] [string,charset(UTF16)] uint16 *devicepath, + [in] uint32 unknown2, + [in,out,ref] uint32 *unknown3, + [in,out,unique] uint16 *unknown4, + [in,unique] [string,charset(UTF16)] uint16 *unknown5, + [out,unique] [string,charset(UTF16)] uint16 **unknown5a, + [in] uint32 unknown6, + [in] uint32 unknown7 + ); /******************/ /* Function: 0x29 */ -- cgit From b7e7de556cda6b6862f4569bf68e5b96896bf024 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:37:06 +0100 Subject: Re-run make idl. Guenther (This used to be commit 5e0f27c2a717ab2daa3b25c450c9cc560aad6218) --- source3/librpc/gen_ndr/cli_ntsvcs.c | 24 +++++ source3/librpc/gen_ndr/cli_ntsvcs.h | 9 ++ source3/librpc/gen_ndr/ndr_ntsvcs.c | 197 ++++++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/ntsvcs.h | 14 +++ source3/librpc/gen_ndr/srv_ntsvcs.c | 9 ++ 5 files changed, 253 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.c b/source3/librpc/gen_ndr/cli_ntsvcs.c index 7f27580605..2efcf6b6c9 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.c +++ b/source3/librpc/gen_ndr/cli_ntsvcs.c @@ -1700,12 +1700,29 @@ NTSTATUS rpccli_PNP_RequestEjectPC(struct rpc_pipe_client *cli, NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + uint32_t unknown1, + const char *devicepath, + uint32_t unknown2, + uint32_t *unknown3, + uint16_t *unknown4, + const char *unknown5, + const char **unknown5a, + uint32_t unknown6, + uint32_t unknown7, WERROR *werror) { struct PNP_HwProfFlags r; NTSTATUS status; /* In parameters */ + r.in.unknown1 = unknown1; + r.in.devicepath = devicepath; + r.in.unknown2 = unknown2; + r.in.unknown3 = unknown3; + r.in.unknown4 = unknown4; + r.in.unknown5 = unknown5; + r.in.unknown6 = unknown6; + r.in.unknown7 = unknown7; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(PNP_HwProfFlags, &r); @@ -1731,6 +1748,13 @@ NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, } /* Return variables */ + *unknown3 = *r.out.unknown3; + if (unknown4 && r.out.unknown4) { + *unknown4 = *r.out.unknown4; + } + if (unknown5a && r.out.unknown5a) { + *unknown5a = *r.out.unknown5a; + } /* Return result */ if (werror) { diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.h b/source3/librpc/gen_ndr/cli_ntsvcs.h index 911200055f..84aad76139 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.h +++ b/source3/librpc/gen_ndr/cli_ntsvcs.h @@ -129,6 +129,15 @@ NTSTATUS rpccli_PNP_RequestEjectPC(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + uint32_t unknown1, + const char *devicepath, + uint32_t unknown2, + uint32_t *unknown3, + uint16_t *unknown4, + const char *unknown5, + const char **unknown5a, + uint32_t unknown6, + uint32_t unknown7, WERROR *werror); NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.c b/source3/librpc/gen_ndr/ndr_ntsvcs.c index c66ec2aa87..2b299964e5 100644 --- a/source3/librpc/gen_ndr/ndr_ntsvcs.c +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c @@ -1743,8 +1743,52 @@ _PUBLIC_ void ndr_print_PNP_RequestEjectPC(struct ndr_print *ndr, const char *na static enum ndr_err_code ndr_push_PNP_HwProfFlags(struct ndr_push *ndr, int flags, const struct PNP_HwProfFlags *r) { if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown1)); + if (r->in.devicepath == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicepath, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicepath, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.devicepath, ndr_charset_length(r->in.devicepath, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); + if (r->in.unknown3 == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.unknown3)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.unknown4)); + if (r->in.unknown4) { + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, *r->in.unknown4)); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.unknown5)); + if (r->in.unknown5) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.unknown5, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.unknown5, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.unknown5, ndr_charset_length(r->in.unknown5, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown6)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown7)); } if (flags & NDR_OUT) { + if (r->out.unknown3 == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.unknown3)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.unknown4)); + if (r->out.unknown4) { + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, *r->out.unknown4)); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.unknown5a)); + if (r->out.unknown5a) { + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.unknown5a)); + if (*r->out.unknown5a) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(*r->out.unknown5a, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(*r->out.unknown5a, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, *r->out.unknown5a, ndr_charset_length(*r->out.unknown5a, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + } NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -1752,9 +1796,117 @@ static enum ndr_err_code ndr_push_PNP_HwProfFlags(struct ndr_push *ndr, int flag static enum ndr_err_code ndr_pull_PNP_HwProfFlags(struct ndr_pull *ndr, int flags, struct PNP_HwProfFlags *r) { + uint32_t _ptr_unknown4; + uint32_t _ptr_unknown5; + uint32_t _ptr_unknown5a; + TALLOC_CTX *_mem_save_unknown3_0; + TALLOC_CTX *_mem_save_unknown4_0; + TALLOC_CTX *_mem_save_unknown5_0; + TALLOC_CTX *_mem_save_unknown5a_0; + TALLOC_CTX *_mem_save_unknown5a_1; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.devicepath)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.devicepath)); + if (ndr_get_array_length(ndr, &r->in.devicepath) > ndr_get_array_size(ndr, &r->in.devicepath)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.devicepath), ndr_get_array_length(ndr, &r->in.devicepath)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.devicepath), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.devicepath, ndr_get_array_length(ndr, &r->in.devicepath), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.unknown3); + } + _mem_save_unknown3_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.unknown3, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.unknown3)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown3_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_unknown4)); + if (_ptr_unknown4) { + NDR_PULL_ALLOC(ndr, r->in.unknown4); + } else { + r->in.unknown4 = NULL; + } + if (r->in.unknown4) { + _mem_save_unknown4_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.unknown4, 0); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, r->in.unknown4)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown4_0, 0); + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_unknown5)); + if (_ptr_unknown5) { + NDR_PULL_ALLOC(ndr, r->in.unknown5); + } else { + r->in.unknown5 = NULL; + } + if (r->in.unknown5) { + _mem_save_unknown5_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.unknown5, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.unknown5)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.unknown5)); + if (ndr_get_array_length(ndr, &r->in.unknown5) > ndr_get_array_size(ndr, &r->in.unknown5)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.unknown5), ndr_get_array_length(ndr, &r->in.unknown5)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.unknown5), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.unknown5, ndr_get_array_length(ndr, &r->in.unknown5), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown5_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown6)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown7)); + NDR_PULL_ALLOC(ndr, r->out.unknown3); + *r->out.unknown3 = *r->in.unknown3; } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.unknown3); + } + _mem_save_unknown3_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.unknown3, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.unknown3)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown3_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_unknown4)); + if (_ptr_unknown4) { + NDR_PULL_ALLOC(ndr, r->out.unknown4); + } else { + r->out.unknown4 = NULL; + } + if (r->out.unknown4) { + _mem_save_unknown4_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.unknown4, 0); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, r->out.unknown4)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown4_0, 0); + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_unknown5a)); + if (_ptr_unknown5a) { + NDR_PULL_ALLOC(ndr, r->out.unknown5a); + } else { + r->out.unknown5a = NULL; + } + if (r->out.unknown5a) { + _mem_save_unknown5a_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.unknown5a, 0); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_unknown5a)); + if (_ptr_unknown5a) { + NDR_PULL_ALLOC(ndr, *r->out.unknown5a); + } else { + *r->out.unknown5a = NULL; + } + if (*r->out.unknown5a) { + _mem_save_unknown5a_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.unknown5a, 0); + NDR_CHECK(ndr_pull_array_size(ndr, r->out.unknown5a)); + NDR_CHECK(ndr_pull_array_length(ndr, r->out.unknown5a)); + if (ndr_get_array_length(ndr, r->out.unknown5a) > ndr_get_array_size(ndr, r->out.unknown5a)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, r->out.unknown5a), ndr_get_array_length(ndr, r->out.unknown5a)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, r->out.unknown5a), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, r->out.unknown5a, ndr_get_array_length(ndr, r->out.unknown5a), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown5a_1, 0); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown5a_0, 0); + } NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -1770,11 +1922,56 @@ _PUBLIC_ void ndr_print_PNP_HwProfFlags(struct ndr_print *ndr, const char *name, if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "PNP_HwProfFlags"); ndr->depth++; + ndr_print_uint32(ndr, "unknown1", r->in.unknown1); + ndr_print_ptr(ndr, "devicepath", r->in.devicepath); + ndr->depth++; + ndr_print_string(ndr, "devicepath", r->in.devicepath); + ndr->depth--; + ndr_print_uint32(ndr, "unknown2", r->in.unknown2); + ndr_print_ptr(ndr, "unknown3", r->in.unknown3); + ndr->depth++; + ndr_print_uint32(ndr, "unknown3", *r->in.unknown3); + ndr->depth--; + ndr_print_ptr(ndr, "unknown4", r->in.unknown4); + ndr->depth++; + if (r->in.unknown4) { + ndr_print_uint16(ndr, "unknown4", *r->in.unknown4); + } + ndr->depth--; + ndr_print_ptr(ndr, "unknown5", r->in.unknown5); + ndr->depth++; + if (r->in.unknown5) { + ndr_print_string(ndr, "unknown5", r->in.unknown5); + } + ndr->depth--; + ndr_print_uint32(ndr, "unknown6", r->in.unknown6); + ndr_print_uint32(ndr, "unknown7", r->in.unknown7); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_HwProfFlags"); ndr->depth++; + ndr_print_ptr(ndr, "unknown3", r->out.unknown3); + ndr->depth++; + ndr_print_uint32(ndr, "unknown3", *r->out.unknown3); + ndr->depth--; + ndr_print_ptr(ndr, "unknown4", r->out.unknown4); + ndr->depth++; + if (r->out.unknown4) { + ndr_print_uint16(ndr, "unknown4", *r->out.unknown4); + } + ndr->depth--; + ndr_print_ptr(ndr, "unknown5a", r->out.unknown5a); + ndr->depth++; + if (r->out.unknown5a) { + ndr_print_ptr(ndr, "unknown5a", *r->out.unknown5a); + ndr->depth++; + if (*r->out.unknown5a) { + ndr_print_string(ndr, "unknown5a", *r->out.unknown5a); + } + ndr->depth--; + } + ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/ntsvcs.h b/source3/librpc/gen_ndr/ntsvcs.h index 2384011789..8f8af699f3 100644 --- a/source3/librpc/gen_ndr/ntsvcs.h +++ b/source3/librpc/gen_ndr/ntsvcs.h @@ -340,6 +340,20 @@ struct PNP_RequestEjectPC { struct PNP_HwProfFlags { struct { + uint32_t unknown1; + const char *devicepath;/* [ref,charset(UTF16)] */ + uint32_t unknown2; + const char *unknown5;/* [unique,charset(UTF16)] */ + uint32_t unknown6; + uint32_t unknown7; + uint32_t *unknown3;/* [ref] */ + uint16_t *unknown4;/* [unique] */ + } in; + + struct { + const char **unknown5a;/* [unique,charset(UTF16)] */ + uint32_t *unknown3;/* [ref] */ + uint16_t *unknown4;/* [unique] */ WERROR result; } out; diff --git a/source3/librpc/gen_ndr/srv_ntsvcs.c b/source3/librpc/gen_ndr/srv_ntsvcs.c index 608353c480..b51f930414 100644 --- a/source3/librpc/gen_ndr/srv_ntsvcs.c +++ b/source3/librpc/gen_ndr/srv_ntsvcs.c @@ -2978,6 +2978,15 @@ static bool api_PNP_HwProfFlags(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_HwProfFlags, r); } + ZERO_STRUCT(r->out); + r->out.unknown3 = r->in.unknown3; + r->out.unknown4 = r->in.unknown4; + r->out.unknown5a = talloc_zero(r, const char *); + if (r->out.unknown5a == NULL) { + talloc_free(r); + return false; + } + r->out.result = _PNP_HwProfFlags(p, r); if (p->rng_fault_state) { -- cgit From 57814bccfbb936849488a0b46a7dcd65247856e1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:07:12 +0100 Subject: Add ntsvcs_hwprofflags command to rpcclient. Guenther (This used to be commit c184a711464d11ebb62989487d33d51d39c97092) --- source3/rpcclient/cmd_ntsvcs.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'source3') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c index 04e367abdb..922d03df54 100644 --- a/source3/rpcclient/cmd_ntsvcs.c +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -113,6 +113,43 @@ static WERROR cmd_ntsvcs_get_device_list_size(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + const char *devicepath = NULL; + uint32_t unk3 = 0; + uint16_t unk4 = 0; + const char *unk5 = NULL; + const char *unk5a = NULL; + + if (argc < 2) { + printf("usage: %s [devicepath]\n", argv[0]); + return WERR_OK; + } + + devicepath = argv[1]; + + status = rpccli_PNP_HwProfFlags(cli, mem_ctx, + 0, + devicepath, + 0, + &unk3, + &unk4, + unk5, + &unk5a, + 0, + 0, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + return werr; +} struct cmd_set ntsvcs_commands[] = { @@ -120,5 +157,6 @@ struct cmd_set ntsvcs_commands[] = { { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" }, { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" }, { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_device_list_size, PI_NTSVCS, NULL, "Query NTSVCS get device list", "" }, + { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_hw_prof_flags, PI_NTSVCS, NULL, "Query NTSVCS HW prof flags", "" }, { NULL } }; -- cgit From 1ce176c2b905b30c14ecde53e0898c343fe96cf9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:09:34 +0100 Subject: Use pidl for _PNP_HwProfFlags(). Guenther (This used to be commit b30d812b30b5a5b286db68fc94b09fff38db5306) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 17 ++++------------- 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 73d4b4f4ed..31d7408df0 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -144,23 +144,7 @@ static bool api_ntsvcs_get_hw_profile_info(pipes_struct *p) static bool api_ntsvcs_hw_profile_flags(pipes_struct *p) { - NTSVCS_Q_HW_PROFILE_FLAGS q_u; - NTSVCS_R_HW_PROFILE_FLAGS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_hw_profile_flags("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_hw_profile_flags(p, &q_u, &r_u); - - if(!ntsvcs_io_r_hw_profile_flags("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_HWPROFFLAGS); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 76bc24e7ba..3215f73f79 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -168,10 +168,11 @@ WERROR _ntsvcs_get_hw_profile_info( pipes_struct *p, NTSVCS_Q_GET_HW_PROFILE_INF /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_hw_profile_flags( pipes_struct *p, NTSVCS_Q_HW_PROFILE_FLAGS *q_u, NTSVCS_R_HW_PROFILE_FLAGS *r_u ) -{ +WERROR _PNP_HwProfFlags(pipes_struct *p, + struct PNP_HwProfFlags *r) +{ /* just nod your head */ - + return WERR_OK; } @@ -548,16 +549,6 @@ WERROR _PNP_RequestEjectPC(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_HwProfFlags(pipes_struct *p, - struct PNP_HwProfFlags *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_GetHwProfInfo(pipes_struct *p, struct PNP_GetHwProfInfo *r) { -- cgit From 7b5d9af374b432e52765dd23bb0b8e6a9696cf86 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:10:37 +0100 Subject: Remove unused marshalling for NTSVCS_HW_PROFILE_FLAGS. Guenther (This used to be commit ddb3838be1ab5080add4db060432dfd007b1fd73) --- source3/include/rpc_ntsvcs.h | 21 ------------ source3/rpc_parse/parse_ntsvcs.c | 73 ---------------------------------------- 2 files changed, 94 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_ntsvcs.h b/source3/include/rpc_ntsvcs.h index 55f36628aa..b678662c6c 100644 --- a/source3/include/rpc_ntsvcs.h +++ b/source3/include/rpc_ntsvcs.h @@ -85,25 +85,4 @@ typedef struct { WERROR status; } NTSVCS_R_GET_HW_PROFILE_INFO; - -/**************************/ - -typedef struct { - uint32 unknown1; - UNISTR2 devicepath; - uint32 unknown2; - uint32 unknown3; - uint32 unknown4; - uint32 unknown5; - uint32 unknown6; - uint32 unknown7; -} NTSVCS_Q_HW_PROFILE_FLAGS; - -typedef struct { - uint32 unknown1; - uint32 unknown2; - uint32 unknown3; - WERROR status; -} NTSVCS_R_HW_PROFILE_FLAGS; - #endif /* _RPC_NTSVCS_H */ diff --git a/source3/rpc_parse/parse_ntsvcs.c b/source3/rpc_parse/parse_ntsvcs.c index faa7f8ddd3..012b8fa0ef 100644 --- a/source3/rpc_parse/parse_ntsvcs.c +++ b/source3/rpc_parse/parse_ntsvcs.c @@ -218,76 +218,3 @@ bool ntsvcs_io_r_get_hw_profile_info(const char *desc, NTSVCS_R_GET_HW_PROFILE_I return True; } - -/******************************************************************* -********************************************************************/ - -bool ntsvcs_io_q_hw_profile_flags(const char *desc, NTSVCS_Q_HW_PROFILE_FLAGS *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_q_hw_profile_flags"); - depth++; - - if(!prs_align(ps)) - return False; - - if ( !prs_uint32("unknown1", ps, depth, &q_u->unknown1) ) - return False; - - - if ( !prs_io_unistr2("devicepath", ps, depth, &q_u->devicepath) ) - return False; - if( !prs_align(ps) ) - return False; - - if ( !prs_uint32("unknown2", ps, depth, &q_u->unknown2) ) - return False; - if ( !prs_uint32("unknown3", ps, depth, &q_u->unknown3) ) - return False; - if ( !prs_uint32("unknown4", ps, depth, &q_u->unknown4) ) - return False; - if ( !prs_uint32("unknown5", ps, depth, &q_u->unknown5) ) - return False; - if ( !prs_uint32("unknown6", ps, depth, &q_u->unknown6) ) - return False; - if ( !prs_uint32("unknown7", ps, depth, &q_u->unknown7) ) - return False; - - if ( !prs_uint32("unknown1", ps, depth, &q_u->unknown1) ) - return False; - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool ntsvcs_io_r_hw_profile_flags(const char *desc, NTSVCS_R_HW_PROFILE_FLAGS *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_r_hw_profile_flags"); - depth++; - - if ( !prs_align(ps) ) - return False; - - if ( !prs_uint32("unknown1", ps, depth, &r_u->unknown1) ) - return False; - if ( !prs_uint32("unknown2", ps, depth, &r_u->unknown2) ) - return False; - if ( !prs_uint32("unknown3", ps, depth, &r_u->unknown3) ) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - - - -- cgit From 3870cae33cd5de849b31093d8b1ee911545ac09b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:29:13 +0100 Subject: Add IDL for PNP_GetHwProfInfo. Guenther (This used to be commit 1ec619fd025cf0ba0b9af05bffa90b61e8ab0f97) --- source3/librpc/idl/ntsvcs.idl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/ntsvcs.idl b/source3/librpc/idl/ntsvcs.idl index 0b8f5c3e0b..af0c7032da 100644 --- a/source3/librpc/idl/ntsvcs.idl +++ b/source3/librpc/idl/ntsvcs.idl @@ -236,7 +236,18 @@ interface ntsvcs /******************/ /* Function: 0x29 */ - WERROR PNP_GetHwProfInfo(); + typedef struct { + uint32 unknown1; + uint16 unknown2[160]; + uint32 unknown3; + } PNP_HwProfInfo; + + WERROR PNP_GetHwProfInfo( + [in] uint32 idx, + [in,out,ref] PNP_HwProfInfo *info, + [in] uint32 unknown1, + [in] uint32 unknown2 + ); /******************/ /* Function: 0x2a */ -- cgit From 2a84f31e286299f93b5561d5b0b9f81e0733e13e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:38:08 +0100 Subject: Re-run make idl. Guenther (This used to be commit cbc3f328d0deecdb7a6c2ff6088ab10ce7d0fbd5) --- source3/librpc/gen_ndr/cli_ntsvcs.c | 9 ++++ source3/librpc/gen_ndr/cli_ntsvcs.h | 4 ++ source3/librpc/gen_ndr/ndr_ntsvcs.c | 97 +++++++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/ndr_ntsvcs.h | 1 + source3/librpc/gen_ndr/ntsvcs.h | 14 ++++++ source3/librpc/gen_ndr/srv_ntsvcs.c | 2 + 6 files changed, 127 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.c b/source3/librpc/gen_ndr/cli_ntsvcs.c index 2efcf6b6c9..5597fccdb5 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.c +++ b/source3/librpc/gen_ndr/cli_ntsvcs.c @@ -1766,12 +1766,20 @@ NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + uint32_t idx, + struct PNP_HwProfInfo *info, + uint32_t unknown1, + uint32_t unknown2, WERROR *werror) { struct PNP_GetHwProfInfo r; NTSTATUS status; /* In parameters */ + r.in.idx = idx; + r.in.info = info; + r.in.unknown1 = unknown1; + r.in.unknown2 = unknown2; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(PNP_GetHwProfInfo, &r); @@ -1797,6 +1805,7 @@ NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, } /* Return variables */ + *info = *r.out.info; /* Return result */ if (werror) { diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.h b/source3/librpc/gen_ndr/cli_ntsvcs.h index 84aad76139..33df63ee5d 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.h +++ b/source3/librpc/gen_ndr/cli_ntsvcs.h @@ -141,6 +141,10 @@ NTSTATUS rpccli_PNP_HwProfFlags(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_PNP_GetHwProfInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + uint32_t idx, + struct PNP_HwProfInfo *info, + uint32_t unknown1, + uint32_t unknown2, WERROR *werror); NTSTATUS rpccli_PNP_AddEmptyLogConf(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.c b/source3/librpc/gen_ndr/ndr_ntsvcs.c index 2b299964e5..058b78104a 100644 --- a/source3/librpc/gen_ndr/ndr_ntsvcs.c +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c @@ -3,6 +3,59 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_ntsvcs.h" +static enum ndr_err_code ndr_push_PNP_HwProfInfo(struct ndr_push *ndr, int ndr_flags, const struct PNP_HwProfInfo *r) +{ + uint32_t cntr_unknown2_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown1)); + for (cntr_unknown2_0 = 0; cntr_unknown2_0 < 160; cntr_unknown2_0++) { + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown2[cntr_unknown2_0])); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown3)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PNP_HwProfInfo(struct ndr_pull *ndr, int ndr_flags, struct PNP_HwProfInfo *r) +{ + uint32_t cntr_unknown2_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown1)); + for (cntr_unknown2_0 = 0; cntr_unknown2_0 < 160; cntr_unknown2_0++) { + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown2[cntr_unknown2_0])); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown3)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PNP_HwProfInfo(struct ndr_print *ndr, const char *name, const struct PNP_HwProfInfo *r) +{ + uint32_t cntr_unknown2_0; + ndr_print_struct(ndr, name, "PNP_HwProfInfo"); + ndr->depth++; + ndr_print_uint32(ndr, "unknown1", r->unknown1); + ndr->print(ndr, "%s: ARRAY(%d)", "unknown2", 160); + ndr->depth++; + for (cntr_unknown2_0=0;cntr_unknown2_0<160;cntr_unknown2_0++) { + char *idx_0=NULL; + asprintf(&idx_0, "[%d]", cntr_unknown2_0); + if (idx_0) { + ndr_print_uint16(ndr, "unknown2", r->unknown2[cntr_unknown2_0]); + free(idx_0); + } + } + ndr->depth--; + ndr_print_uint32(ndr, "unknown3", r->unknown3); + ndr->depth--; +} + static enum ndr_err_code ndr_push_PNP_Disconnect(struct ndr_push *ndr, int flags, const struct PNP_Disconnect *r) { if (flags & NDR_IN) { @@ -1981,8 +2034,19 @@ _PUBLIC_ void ndr_print_PNP_HwProfFlags(struct ndr_print *ndr, const char *name, static enum ndr_err_code ndr_push_PNP_GetHwProfInfo(struct ndr_push *ndr, int flags, const struct PNP_GetHwProfInfo *r) { if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.idx)); + if (r->in.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_PNP_HwProfInfo(ndr, NDR_SCALARS, r->in.info)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); } if (flags & NDR_OUT) { + if (r->out.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_PNP_HwProfInfo(ndr, NDR_SCALARS, r->out.info)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -1990,9 +2054,31 @@ static enum ndr_err_code ndr_push_PNP_GetHwProfInfo(struct ndr_push *ndr, int fl static enum ndr_err_code ndr_pull_PNP_GetHwProfInfo(struct ndr_pull *ndr, int flags, struct PNP_GetHwProfInfo *r) { + TALLOC_CTX *_mem_save_info_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.idx)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_PNP_HwProfInfo(ndr, NDR_SCALARS, r->in.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_PULL_ALLOC(ndr, r->out.info); + *r->out.info = *r->in.info; } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_PNP_HwProfInfo(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -2008,11 +2094,22 @@ _PUBLIC_ void ndr_print_PNP_GetHwProfInfo(struct ndr_print *ndr, const char *nam if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "PNP_GetHwProfInfo"); ndr->depth++; + ndr_print_uint32(ndr, "idx", r->in.idx); + ndr_print_ptr(ndr, "info", r->in.info); + ndr->depth++; + ndr_print_PNP_HwProfInfo(ndr, "info", r->in.info); + ndr->depth--; + ndr_print_uint32(ndr, "unknown1", r->in.unknown1); + ndr_print_uint32(ndr, "unknown2", r->in.unknown2); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetHwProfInfo"); ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + ndr_print_PNP_HwProfInfo(ndr, "info", r->out.info); + ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.h b/source3/librpc/gen_ndr/ndr_ntsvcs.h index b415d6056b..0e3b6b91c4 100644 --- a/source3/librpc/gen_ndr/ndr_ntsvcs.h +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.h @@ -142,6 +142,7 @@ extern const struct ndr_interface_table ndr_table_ntsvcs; #define NDR_PNP_GETSERVERSIDEDEVICEINSTALLFLAGS (0x40) #define NDR_NTSVCS_CALL_COUNT (65) +void ndr_print_PNP_HwProfInfo(struct ndr_print *ndr, const char *name, const struct PNP_HwProfInfo *r); void ndr_print_PNP_Disconnect(struct ndr_print *ndr, const char *name, int flags, const struct PNP_Disconnect *r); void ndr_print_PNP_Connect(struct ndr_print *ndr, const char *name, int flags, const struct PNP_Connect *r); void ndr_print_PNP_GetVersion(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetVersion *r); diff --git a/source3/librpc/gen_ndr/ntsvcs.h b/source3/librpc/gen_ndr/ntsvcs.h index 8f8af699f3..9cdfa656b4 100644 --- a/source3/librpc/gen_ndr/ntsvcs.h +++ b/source3/librpc/gen_ndr/ntsvcs.h @@ -5,6 +5,12 @@ #ifndef _HEADER_ntsvcs #define _HEADER_ntsvcs +struct PNP_HwProfInfo { + uint32_t unknown1; + uint16_t unknown2[160]; + uint32_t unknown3; +}; + struct PNP_Disconnect { struct { @@ -362,6 +368,14 @@ struct PNP_HwProfFlags { struct PNP_GetHwProfInfo { struct { + uint32_t idx; + uint32_t unknown1; + uint32_t unknown2; + struct PNP_HwProfInfo *info;/* [ref] */ + } in; + + struct { + struct PNP_HwProfInfo *info;/* [ref] */ WERROR result; } out; diff --git a/source3/librpc/gen_ndr/srv_ntsvcs.c b/source3/librpc/gen_ndr/srv_ntsvcs.c index b51f930414..339de6c747 100644 --- a/source3/librpc/gen_ndr/srv_ntsvcs.c +++ b/source3/librpc/gen_ndr/srv_ntsvcs.c @@ -3060,6 +3060,8 @@ static bool api_PNP_GetHwProfInfo(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetHwProfInfo, r); } + ZERO_STRUCT(r->out); + r->out.info = r->in.info; r->out.result = _PNP_GetHwProfInfo(p, r); if (p->rng_fault_state) { -- cgit From 4149868f8567a6735fde4b4fae807845e72473eb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:29:55 +0100 Subject: Add ntsvcs_hwprofinfo command to rpcclient. Guenther (This used to be commit 8d8cf915f793980bdd0d89fc8d53ea1c1e759065) --- source3/rpcclient/cmd_ntsvcs.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source3') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c index 922d03df54..b7b37e2fa6 100644 --- a/source3/rpcclient/cmd_ntsvcs.c +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -151,6 +151,32 @@ static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + uint32_t idx = 0; + struct PNP_HwProfInfo info; + uint32_t unknown1 = 0, unknown2 = 0; + + ZERO_STRUCT(info); + + status = rpccli_PNP_GetHwProfInfo(cli, mem_ctx, + idx, + &info, + unknown1, + unknown2, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + return werr; +} + struct cmd_set ntsvcs_commands[] = { { "NTSVCS" }, @@ -158,5 +184,6 @@ struct cmd_set ntsvcs_commands[] = { { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" }, { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_device_list_size, PI_NTSVCS, NULL, "Query NTSVCS get device list", "" }, { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_hw_prof_flags, PI_NTSVCS, NULL, "Query NTSVCS HW prof flags", "" }, + { "ntsvcs_hwprofinfo", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_hw_prof_info, PI_NTSVCS, NULL, "Query NTSVCS HW prof info", "" }, { NULL } }; -- cgit From 6dfca8485dd6f8cfa1f6079c092f45ac79f5b86c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:32:29 +0100 Subject: Use pidl for _PNP_GetHwProfInfo(). Guenther (This used to be commit 7b7ce50e4bd8bc1ac94e882acf412e69b652f7d0) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 16 +++------------- 2 files changed, 4 insertions(+), 30 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 31d7408df0..12fffc3e96 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -120,23 +120,7 @@ static bool api_ntsvcs_get_device_reg_property(pipes_struct *p) static bool api_ntsvcs_get_hw_profile_info(pipes_struct *p) { - NTSVCS_Q_GET_HW_PROFILE_INFO q_u; - NTSVCS_R_GET_HW_PROFILE_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_get_hw_profile_info("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_get_hw_profile_info(p, &q_u, &r_u); - - if(!ntsvcs_io_r_get_hw_profile_info("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_GETHWPROFINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 3215f73f79..11ea5d0cd1 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -153,12 +153,12 @@ WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_get_hw_profile_info( pipes_struct *p, NTSVCS_Q_GET_HW_PROFILE_INFO *q_u, NTSVCS_R_GET_HW_PROFILE_INFO *r_u ) +WERROR _PNP_GetHwProfInfo(pipes_struct *p, + struct PNP_GetHwProfInfo *r) { /* steal the incoming buffer */ - r_u->buffer_size = q_u->buffer_size; - r_u->buffer = q_u->buffer; + r->out.info = r->in.info; /* Take the 5th Ammentment */ @@ -549,16 +549,6 @@ WERROR _PNP_RequestEjectPC(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_GetHwProfInfo(pipes_struct *p, - struct PNP_GetHwProfInfo *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_AddEmptyLogConf(pipes_struct *p, struct PNP_AddEmptyLogConf *r) { -- cgit From f155008ca021d8f80eedbf4395a454d63193c524 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:34:13 +0100 Subject: Remove unused marshalling for NTSVCS_GET_HW_PROFILE_INFO. Guenther (This used to be commit 2ec2eefc703df882599b6eac9147350c4df33006) --- source3/include/rpc_ntsvcs.h | 17 ---------- source3/rpc_parse/parse_ntsvcs.c | 73 ---------------------------------------- 2 files changed, 90 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_ntsvcs.h b/source3/include/rpc_ntsvcs.h index b678662c6c..71274cc380 100644 --- a/source3/include/rpc_ntsvcs.h +++ b/source3/include/rpc_ntsvcs.h @@ -68,21 +68,4 @@ typedef struct { WERROR status; } NTSVCS_R_GET_DEVICE_REG_PROPERTY; - -/**************************/ - -typedef struct { - uint32 index; - uint8 *buffer; - uint32 buffer_size; - uint32 unknown1; -} NTSVCS_Q_GET_HW_PROFILE_INFO; - -typedef struct { - uint32 buffer_size; /* the size (not included in the reply) - if just matched from the request */ - uint8 *buffer; - WERROR status; -} NTSVCS_R_GET_HW_PROFILE_INFO; - #endif /* _RPC_NTSVCS_H */ diff --git a/source3/rpc_parse/parse_ntsvcs.c b/source3/rpc_parse/parse_ntsvcs.c index 012b8fa0ef..2b15a45506 100644 --- a/source3/rpc_parse/parse_ntsvcs.c +++ b/source3/rpc_parse/parse_ntsvcs.c @@ -145,76 +145,3 @@ bool ntsvcs_io_r_get_device_reg_property(const char *desc, NTSVCS_R_GET_DEVICE_R return True; } - -/******************************************************************* -********************************************************************/ - -bool ntsvcs_io_q_get_hw_profile_info(const char *desc, NTSVCS_Q_GET_HW_PROFILE_INFO *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_q_get_hw_profile_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if ( !prs_uint32("index", ps, depth, &q_u->index) ) - return False; - - q_u->buffer_size = 0x000000a8; - - if ( UNMARSHALLING(ps) ) { - q_u->buffer = TALLOC_ARRAY(talloc_tos(), uint8, q_u->buffer_size ); - if (!q_u->buffer) { - return False; - } - } - - if ( !prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size) ) - return False; - - if ( !prs_uint32("buffer_size", ps, depth, &q_u->buffer_size) ) - return False; - - if ( !prs_uint32("unknown1", ps, depth, &q_u->unknown1) ) - return False; - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool ntsvcs_io_r_get_hw_profile_info(const char *desc, NTSVCS_R_GET_HW_PROFILE_INFO *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "ntsvcs_io_r_get_device_reg_property"); - depth++; - - if ( !prs_align(ps) ) - return False; - - if ( UNMARSHALLING(ps) ) { - if (r_u->buffer_size) { - r_u->buffer = TALLOC_ARRAY(talloc_tos(), uint8, r_u->buffer_size ); - if (!r_u->buffer) { - return False; - } - } else { - r_u->buffer = NULL; - } - } - - if ( !prs_uint8s(True, "buffer", ps, depth, r_u->buffer, r_u->buffer_size) ) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} -- cgit From e655a1073641b580c55cbebac78f6205a5bd5efc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 04:30:57 +0100 Subject: Use rpccli_lsa_LookupNames() inside of rpccli_lsa_lookup_names. Guenther (This used to be commit 5c0a2d697f6a173e9627d7bc5567308a24613f46) --- source3/rpc_client/cli_lsarpc.c | 51 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index a4c5331008..b780d1df48 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -348,29 +348,32 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli, DOM_SID **sids, enum lsa_SidType **types) { - prs_struct qbuf, rbuf; - LSA_Q_LOOKUP_NAMES q; - LSA_R_LOOKUP_NAMES r; - DOM_R_REF ref; NTSTATUS result; int i; + struct lsa_String *lsa_names = NULL; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TransSidArray sid_array; + uint32_t count = 0; - ZERO_STRUCT(q); - ZERO_STRUCT(r); + ZERO_STRUCT(sid_array); - ZERO_STRUCT(ref); - r.dom_ref = &ref; - - init_q_lookup_names(mem_ctx, &q, pol, num_names, names, level); + lsa_names = TALLOC_ARRAY(mem_ctx, struct lsa_String, num_names); + if (!lsa_names) { + return NT_STATUS_NO_MEMORY; + } - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_LOOKUPNAMES, - q, r, - qbuf, rbuf, - lsa_io_q_lookup_names, - lsa_io_r_lookup_names, - NT_STATUS_UNSUCCESSFUL); + for (i=0; idomains[dom_idx].sid); if (dom_rid != 0xffffffff) { sid_append_rid(sid, dom_rid); } - (*types)[i] = t_rids[i].type; + (*types)[i] = sid_array.sids[i].sid_type; if (dom_names == NULL) { continue; } - (*dom_names)[i] = rpcstr_pull_unistr2_talloc( - *dom_names, &ref.ref_dom[dom_idx].uni_dom_name); + (*dom_names)[i] = domains->domains[dom_idx].name.string; } done: -- cgit From d9a465b8df6b4a6ddfc24b792b57f50aa4ac1931 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 10:03:19 +0100 Subject: Use rpccli_lsa_LookupSids() in rpccli_lsa_lookup_sids_noalloc(). Guenther (This used to be commit b62eddbc4e302d3849525d8f6af24b112a4fe483) --- source3/rpc_client/cli_lsarpc.c | 67 ++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 31 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index b780d1df48..1fb0205f29 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -128,13 +128,16 @@ static NTSTATUS rpccli_lsa_lookup_sids_noalloc(struct rpc_pipe_client *cli, char **names, enum lsa_SidType *types) { - prs_struct qbuf, rbuf; - LSA_Q_LOOKUP_SIDS q; - LSA_R_LOOKUP_SIDS r; - DOM_R_REF ref; NTSTATUS result = NT_STATUS_OK; TALLOC_CTX *tmp_ctx = NULL; int i; + struct lsa_SidArray sid_array; + struct lsa_RefDomainList *ref_domains = NULL; + struct lsa_TransNameArray lsa_names; + uint32_t count = 0; + uint16_t level = 1; + + ZERO_STRUCT(lsa_names); tmp_ctx = talloc_new(mem_ctx); if (!tmp_ctx) { @@ -143,38 +146,42 @@ static NTSTATUS rpccli_lsa_lookup_sids_noalloc(struct rpc_pipe_client *cli, goto done; } - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - init_q_lookup_sids(tmp_ctx, &q, pol, num_sids, sids, 1); - - ZERO_STRUCT(ref); + sid_array.num_sids = num_sids; + sid_array.sids = TALLOC_ARRAY(mem_ctx, struct lsa_SidPtr, num_sids); + if (!sid_array.sids) { + return NT_STATUS_NO_MEMORY; + } - r.dom_ref = &ref; + for (i = 0; idomains[dom_idx].name.string; + name = lsa_names.names[i].name.string; (names)[i] = talloc_strdup(mem_ctx, name); (domains)[i] = talloc_strdup(mem_ctx, dom_name); - (types)[i] = r.names.name[i].sid_name_use; + (types)[i] = lsa_names.names[i].sid_type; if (((names)[i] == NULL) || ((domains)[i] == NULL)) { DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n")); -- cgit From 2cd374db8d53cf9727da6c99a7fc48f4dd09fd4b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Feb 2008 10:21:17 +1100 Subject: Replace C++-style comments with C. (This used to be commit a1d07469236c06b65f14a59a27d7f7abcb106b5e) --- source3/client/smbmnt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/client/smbmnt.c b/source3/client/smbmnt.c index 198faca173..3d7de1b3c0 100644 --- a/source3/client/smbmnt.c +++ b/source3/client/smbmnt.c @@ -251,7 +251,7 @@ do_mount(char *share_name, unsigned int flags, struct smb_mount_data *data) return -1; } - data.uid = mount_uid; // truncates to 16-bits here!!! + data.uid = mount_uid; /* truncates to 16-bits here!!! */ data.gid = mount_gid; data.file_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & mount_fmask; data.dir_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & mount_dmask; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0db74c2a1b..df7bb9b206 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2535,10 +2535,10 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, logon_hours, pdb_get_bad_password_count(pw), pdb_get_logon_count(pw), - 0, //country_code, - 0, //code_page, - 0, //nt_password_set, - 0, //lm_password_set, + 0, /* country_code */ + 0, /* code_page */ + 0, /* nt_password_set */ + 0, /* lm_password_set */ password_expired); TALLOC_FREE(pw); -- cgit From a8fbb92146ddfe0b774f8385dfdea672447a1c46 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Feb 2008 10:21:50 +1100 Subject: Check return code of secrets_init() function. (This used to be commit 2b1eead269e95142576d0c8c259874324ba83502) --- source3/smbd/server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 7116027adf..7bf11abfbd 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -988,7 +988,8 @@ static bool init_structs(void ) init_dptrs(); - secrets_init(); + if (!secrets_init()) + return False; return True; } -- cgit From 9053bdf57c39102f0a9ec78cbbee3f7ff45d72e1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Feb 2008 10:24:51 +1100 Subject: Fix off-by-one bugs in subcommand argument passing. (This used to be commit d85a2782a483e563a8b68924d4897a145bc25896) --- source3/rpcclient/cmd_samr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index f8b8ba893c..8b4ee47a67 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -1044,8 +1044,8 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli, return NT_STATUS_OK; } - if (argc > 2) { - sscanf(argv[2], "%x", &access_mask); + if (argc > 1) { + sscanf(argv[1], "%x", &access_mask); } /* Get sam policy handle */ @@ -1194,11 +1194,11 @@ static NTSTATUS cmd_samr_query_aliasinfo(struct rpc_pipe_client *cli, sscanf(argv[2], "%i", &alias_rid); - if (argc > 3) { + if (argc > 2) { level = atoi(argv[3]); } - if (argc > 4) { + if (argc > 3) { sscanf(argv[4], "%x", &access_mask); } -- cgit From 50e31b9346a1d191a959e493a1e4f0f6fdc582b8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 11:48:51 +0100 Subject: Remove whitespace, no code changes. Guenther (This used to be commit d752d52f1a4b75d7d4934da66566bc62e14caf27) --- source3/rpc_server/srv_svcctl_nt.c | 322 ++++++++++++++++++------------------- source3/utils/net_rpc_service.c | 208 ++++++++++++------------ 2 files changed, 265 insertions(+), 265 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index ac45d8bf75..11b7ab6ca2 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -1,22 +1,22 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * * Copyright (C) Marcin Krzysztof Porwit 2005. - * + * * Largely Rewritten (Again) by: * Copyright (C) Gerald (Jerry) Carter 2005. - * + * * 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 . */ @@ -63,42 +63,42 @@ bool init_service_op_table( void ) const char **service_list = lp_svcctl_list(); int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_count( service_list ); int i; - + if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) { DEBUG(0,("init_service_op_table: talloc() failed!\n")); return False; } /* services listed in smb.conf get the rc.init interface */ - + for ( i=0; service_list && service_list[i]; i++ ) { svcctl_ops[i].name = talloc_strdup( svcctl_ops, service_list[i] ); svcctl_ops[i].ops = &rcinit_svc_ops; } - + /* add builtin services */ - + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "Spooler" ); svcctl_ops[i].ops = &spoolss_svc_ops; i++; - + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "NETLOGON" ); svcctl_ops[i].ops = &netlogon_svc_ops; i++; - + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" ); svcctl_ops[i].ops = &winreg_svc_ops; i++; - + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "WINS" ); svcctl_ops[i].ops = &wins_svc_ops; i++; - + /* NULL terminate the array */ - + svcctl_ops[i].name = NULL; svcctl_ops[i].ops = NULL; - + return True; } @@ -119,7 +119,7 @@ static struct service_control_op* find_service_by_name( const char *name ) /******************************************************************** ********************************************************************/ -static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, +static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, uint32 access_desired, uint32 *access_granted ) { NTSTATUS result; @@ -128,7 +128,7 @@ static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, DEBUG(5,("svcctl_access_check: using root's token\n")); token = get_root_nt_token(); } - + se_access_check( sec_desc, token, access_desired, access_granted, &result ); return result; @@ -139,7 +139,7 @@ static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) { - SEC_ACE ace[2]; + SEC_ACE ace[2]; SEC_ACCESS mask; size_t i = 0; SEC_DESC *sd; @@ -147,18 +147,18 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) size_t sd_size; /* basic access for Everyone */ - + init_sec_access(&mask, SC_MANAGER_READ_ACCESS ); init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - + /* Full Access 'BUILTIN\Administrators' */ - + init_sec_access(&mask,SC_MANAGER_ALL_ACCESS ); init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - + + /* create the security descriptor */ - + if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) return NULL; @@ -173,7 +173,7 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) /****************************************************************** free() function for REGISTRY_KEY *****************************************************************/ - + static void free_service_handle_info(void *ptr) { TALLOC_FREE( ptr ); @@ -197,21 +197,21 @@ static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) /****************************************************************** *****************************************************************/ - + static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, uint32 type, const char *service, uint32 access_granted ) { SERVICE_INFO *info = NULL; WERROR result = WERR_OK; struct service_control_op *s_op; - + if ( !(info = TALLOC_ZERO_P( NULL, SERVICE_INFO )) ) return WERR_NOMEM; /* the Service Manager has a NULL name */ - + info->type = SVC_HANDLE_IS_SCM; - + switch ( type ) { case SVC_HANDLE_IS_SCM: info->type = SVC_HANDLE_IS_SCM; @@ -220,17 +220,17 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, u case SVC_HANDLE_IS_DBLOCK: info->type = SVC_HANDLE_IS_DBLOCK; break; - + case SVC_HANDLE_IS_SERVICE: info->type = SVC_HANDLE_IS_SERVICE; - + /* lookup the SERVICE_CONTROL_OPS */ if ( !(s_op = find_service_by_name( service )) ) { result = WERR_NO_SUCH_SERVICE; goto done; } - + info->ops = s_op->ops; if ( !(info->name = talloc_strdup( info, s_op->name )) ) { @@ -244,15 +244,15 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, u goto done; } - info->access_granted = access_granted; - + info->access_granted = access_granted; + /* store the SERVICE_INFO and create an open handle */ - + if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) { result = WERR_ACCESS_DENIED; goto done; } - + done: if ( !W_ERROR_IS_OK(result) ) free_service_handle_info( info ); @@ -268,17 +268,17 @@ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVC SEC_DESC *sec_desc; uint32 access_granted = 0; NTSTATUS status; - + /* perform access checks */ - + if ( !(sec_desc = construct_scm_sd( p->mem_ctx )) ) return WERR_NOMEM; - + se_map_generic( &q_u->access, &scm_generic_map ); status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - + return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SCM, NULL, access_granted ); } @@ -307,7 +307,7 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ if ( !find_service_info_by_hnd( p, &q_u->handle ) ) return WERR_BADFID; - /* perform access checks. Use the root token in order to ensure that we + /* perform access checks. Use the root token in order to ensure that we retrieve the security descriptor */ if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, service, get_root_nt_token() )) ) @@ -329,7 +329,7 @@ WERROR _svcctl_CloseServiceHandle(pipes_struct *p, struct svcctl_CloseServiceHan if ( !close_policy_hnd( p, r->in.handle ) ) return WERR_BADFID; - return WERR_OK; + return WERR_OK; } /******************************************************************** @@ -340,14 +340,14 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, fstring service; const char *display_name; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* can only use an SCM handle here */ - + if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) return WERR_BADFID; - + rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - + display_name = svcctl_lookup_dispname(p->mem_ctx, service, p->pipe_user.nt_user_token ); init_svcctl_r_get_display_name( r_u, display_name ? display_name : ""); @@ -360,15 +360,15 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) return WERR_BADFID; - + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; - + /* try the service specific status call */ return info->ops->service_status( info->name, &r_u->svc_status ); @@ -383,7 +383,7 @@ static int enumerate_status( TALLOC_CTX *ctx, ENUM_SERVICES_STATUS **status, NT_ int i; ENUM_SERVICES_STATUS *st; const char *display_name; - + /* just count */ while ( svcctl_ops[num_services].name ) num_services++; @@ -392,16 +392,16 @@ static int enumerate_status( TALLOC_CTX *ctx, ENUM_SERVICES_STATUS **status, NT_ DEBUG(0,("enumerate_status: talloc() failed!\n")); return -1; } - + for ( i=0; iservice_status( svcctl_ops[i].name, &st[i].status ); } - + *status = st; return num_services; @@ -419,12 +419,12 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT WERROR result = WERR_OK; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); NT_USER_TOKEN *token = p->pipe_user.nt_user_token; - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) return WERR_BADFID; - + if ( !(info->access_granted & SC_RIGHT_MGR_ENUMERATE_SERVICE) ) { return WERR_ACCESS_DENIED; } @@ -469,15 +469,15 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCTL_R_START_SERVICE *r_u) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) return WERR_BADFID; - + if ( !(info->access_granted & SC_RIGHT_SVC_START) ) return WERR_ACCESS_DENIED; - + return info->ops->start_service( info->name ); } @@ -487,28 +487,28 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, SVCCTL_R_CONTROL_SERVICE *r_u) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ - + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + switch ( q_u->control ) { case SVCCTL_CONTROL_STOP: if ( !(info->access_granted & SC_RIGHT_SVC_STOP) ) return WERR_ACCESS_DENIED; - + return info->ops->stop_service( info->name, &r_u->svc_status ); - + case SVCCTL_CONTROL_INTERROGATE: if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; - + return info->ops->service_status( info->name, &r_u->svc_status ); } - + /* default control action */ - + return WERR_ACCESS_DENIED; } @@ -518,22 +518,22 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u ) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_SVC_ENUMERATE_DEPENDENTS) ) return WERR_ACCESS_DENIED; - - /* we have to set the outgoing buffer size to the same as the + + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); - + r_u->needed = q_u->buffer_size; - + /* no dependent services...basically a stub function */ r_u->returned = 0; @@ -547,21 +547,21 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); uint32 buffer_size; - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; - /* we have to set the outgoing buffer size to the same as the + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure) */ rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); r_u->needed = q_u->buffer_size; - + switch ( q_u->level ) { case SVC_STATUS_PROCESS_INFO: { @@ -576,18 +576,18 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ buffer_size = sizeof(SERVICE_STATUS_PROCESS); break; } - + default: - return WERR_UNKNOWN_LEVEL; + return WERR_UNKNOWN_LEVEL; } - + buffer_size += buffer_size % 4; r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - if (buffer_size > q_u->buffer_size ) + if (buffer_size > q_u->buffer_size ) return WERR_MORE_DATA; - + return WERR_OK; } @@ -600,12 +600,12 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG REGISTRY_VALUE *val; /* retrieve the registry values for this service */ - + if ( !(values = svcctl_fetch_regvalues( name, token )) ) return WERR_REG_CORRUPT; - + /* now fill in the individual values */ - + config->displayname = TALLOC_ZERO_P( ctx, UNISTR2 ); if ( (val = regval_ctr_getvalue( values, "DisplayName" )) != NULL ) init_unistr2( config->displayname, regval_sz( val ), UNI_STR_TERMINATE ); @@ -613,23 +613,23 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG init_unistr2( config->displayname, name, UNI_STR_TERMINATE ); if ( (val = regval_ctr_getvalue( values, "ObjectName" )) != NULL ) { - config->startname = TALLOC_ZERO_P( ctx, UNISTR2 ); + config->startname = TALLOC_ZERO_P( ctx, UNISTR2 ); init_unistr2( config->startname, regval_sz( val ), UNI_STR_TERMINATE ); } - + if ( (val = regval_ctr_getvalue( values, "ImagePath" )) != NULL ) { - config->executablepath = TALLOC_ZERO_P( ctx, UNISTR2 ); + config->executablepath = TALLOC_ZERO_P( ctx, UNISTR2 ); init_unistr2( config->executablepath, regval_sz( val ), UNI_STR_TERMINATE ); } /* a few hard coded values */ /* loadordergroup and dependencies are empty */ - + config->tag_id = 0x00000000; /* unassigned loadorder group */ config->service_type = SVCCTL_WIN32_OWN_PROC; config->error_control = SVCCTL_SVC_ERROR_NORMAL; - /* set the start type. NetLogon and WINS are disabled to prevent + /* set the start type. NetLogon and WINS are disabled to prevent the client from showing the "Start" button (if of course the services are not running */ @@ -639,7 +639,7 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG config->start_type = SVCCTL_DISABLED; else config->start_type = SVCCTL_DEMAND_START; - + TALLOC_FREE( values ); @@ -654,24 +654,24 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); uint32 buffer_size; WERROR wresult; - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_CONFIG) ) return WERR_ACCESS_DENIED; - /* we have to set the outgoing buffer size to the same as the + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ r_u->needed = q_u->buffer_size; - + wresult = fill_svc_config( p->mem_ctx, info->name, &r_u->config, p->pipe_user.nt_user_token ); if ( !W_ERROR_IS_OK(wresult) ) return wresult; - + buffer_size = svcctl_sizeof_service_config( &r_u->config ); r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; @@ -679,7 +679,7 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON ZERO_STRUCTP( &r_u->config ); return WERR_INSUFFICIENT_BUFFER; } - + return WERR_OK; } @@ -755,17 +755,17 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO WERROR _svcctl_lock_service_db( pipes_struct *p, SVCCTL_Q_LOCK_SERVICE_DB *q_u, SVCCTL_R_LOCK_SERVICE_DB *r_u ) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_MGR_LOCK) ) return WERR_ACCESS_DENIED; /* Just open a handle. Doesn't actually lock anything */ - + return create_open_service_handle( p, &r_u->h_lock, SVC_HANDLE_IS_DBLOCK, NULL, 0 ); ; } @@ -779,8 +779,8 @@ WERROR _svcctl_unlock_service_db( pipes_struct *p, SVCCTL_Q_UNLOCK_SERVICE_DB *q if ( !info || (info->type != SVC_HANDLE_IS_DBLOCK) ) - return WERR_BADFID; - + return WERR_BADFID; + return close_policy_hnd( p, &q_u->h_lock) ? WERR_OK : WERR_BADFID; } @@ -796,7 +796,7 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q /* only support the SCM and individual services */ if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) - return WERR_BADFID; + return WERR_BADFID; /* check access reights (according to MSDN) */ @@ -824,7 +824,7 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q if ( !sec_io_desc("", &sec_desc, &r_u->buffer.prs, 0 ) ) return WERR_NOMEM; - + return WERR_OK; } @@ -843,37 +843,37 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, /* can't set the security de4scriptor on the ServiceControlManager */ if ( info->type == SVC_HANDLE_IS_SCM ) - return WERR_ACCESS_DENIED; + return WERR_ACCESS_DENIED; /* check the access on the open handle */ - + switch ( q_u->security_flags ) { case DACL_SECURITY_INFORMATION: required_access = STD_RIGHT_WRITE_DAC_ACCESS; break; - + case OWNER_SECURITY_INFORMATION: case GROUP_SECURITY_INFORMATION: required_access = STD_RIGHT_WRITE_OWNER_ACCESS; break; - + case SACL_SECURITY_INFORMATION: return WERR_INVALID_PARAM; default: return WERR_INVALID_PARAM; } - + if ( !(info->access_granted & required_access) ) return WERR_ACCESS_DENIED; - + /* read the security descfriptor */ - + if ( !sec_io_desc("", &sec_desc, &q_u->buffer.prs, 0 ) ) return WERR_NOMEM; - + /* store the new SD */ - if ( !svcctl_set_secdesc( p->mem_ctx, info->name, sec_desc, p->pipe_user.nt_user_token ) ) + if ( !svcctl_set_secdesc( p->mem_ctx, info->name, sec_desc, p->pipe_user.nt_user_token ) ) return WERR_ACCESS_DENIED; return WERR_OK; @@ -883,258 +883,258 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, WERROR _svcctl_ControlService(pipes_struct *p, struct svcctl_ControlService *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_LockServiceDatabase(pipes_struct *p, struct svcctl_LockServiceDatabase *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, struct svcctl_QueryServiceObjectSecurity *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServiceObjectSecurity *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceStatus(pipes_struct *p, struct svcctl_QueryServiceStatus *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, struct svcctl_UnlockServiceDatabase *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_NotifyBootConfigStatus(pipes_struct *p, struct svcctl_NotifyBootConfigStatus *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SCSetServiceBitsW(pipes_struct *p, struct svcctl_SCSetServiceBitsW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_ChangeServiceConfigW(pipes_struct *p, struct svcctl_ChangeServiceConfigW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_CreateServiceW(pipes_struct *p, struct svcctl_CreateServiceW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumDependentServicesW(pipes_struct *p, struct svcctl_EnumDependentServicesW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesStatusW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_OpenSCManagerW(pipes_struct *p, struct svcctl_OpenSCManagerW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_OpenServiceW(pipes_struct *p, struct svcctl_OpenServiceW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceConfigW(pipes_struct *p, struct svcctl_QueryServiceConfigW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceLockStatusW(pipes_struct *p, struct svcctl_QueryServiceLockStatusW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_StartServiceW(pipes_struct *p, struct svcctl_StartServiceW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, struct svcctl_GetServiceDisplayNameW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetServiceKeyNameW(pipes_struct *p, struct svcctl_GetServiceKeyNameW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SCSetServiceBitsA(pipes_struct *p, struct svcctl_SCSetServiceBitsA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_ChangeServiceConfigA(pipes_struct *p, struct svcctl_ChangeServiceConfigA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_CreateServiceA(pipes_struct *p, struct svcctl_CreateServiceA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumDependentServicesA(pipes_struct *p, struct svcctl_EnumDependentServicesA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumServicesStatusA(pipes_struct *p, struct svcctl_EnumServicesStatusA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_OpenSCManagerA(pipes_struct *p, struct svcctl_OpenSCManagerA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_OpenServiceA(pipes_struct *p, struct svcctl_OpenServiceA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceConfigA(pipes_struct *p, struct svcctl_QueryServiceConfigA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceLockStatusA(pipes_struct *p, struct svcctl_QueryServiceLockStatusA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_StartServiceA(pipes_struct *p, struct svcctl_StartServiceA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetServiceDisplayNameA(pipes_struct *p, struct svcctl_GetServiceDisplayNameA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetServiceKeyNameA(pipes_struct *p, struct svcctl_GetServiceKeyNameA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetCurrentGroupeStateW(pipes_struct *p, struct svcctl_GetCurrentGroupeStateW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumServiceGroupW(pipes_struct *p, struct svcctl_EnumServiceGroupW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_ChangeServiceConfig2A(pipes_struct *p, struct svcctl_ChangeServiceConfig2A *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_ChangeServiceConfig2W(pipes_struct *p, struct svcctl_ChangeServiceConfig2W *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceConfig2A(pipes_struct *p, struct svcctl_QueryServiceConfig2A *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceConfig2W(pipes_struct *p, struct svcctl_QueryServiceConfig2W *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceStatusEx(pipes_struct *p, struct svcctl_QueryServiceStatusEx *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _EnumServicesStatusExA(pipes_struct *p, struct EnumServicesStatusExA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _EnumServicesStatusExW(pipes_struct *p, struct EnumServicesStatusExW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SCSendTSMessage(pipes_struct *p, struct svcctl_SCSendTSMessage *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c index a70ecf3c72..5ad907e8a6 100644 --- a/source3/utils/net_rpc_service.c +++ b/source3/utils/net_rpc_service.c @@ -1,21 +1,21 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility Copyright (C) Gerald (Jerry) Carter 2005 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 "includes.h" #include "utils/net.h" @@ -24,7 +24,7 @@ ********************************************************************/ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, const char *service, uint32 *state ) @@ -32,10 +32,10 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd, POLICY_HND hService; SERVICE_STATUS service_status; WERROR result = WERR_GENERAL_FAILURE; - + /* now cycle until the status is actually 'watch_state' */ - - result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, hSCM, &hService, + + result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, hSCM, &hService, service, SC_RIGHT_SVC_QUERY_STATUS ); if ( !W_ERROR_IS_OK(result) ) { @@ -47,9 +47,9 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd, if ( W_ERROR_IS_OK(result) ) { *state = service_status.state; } - + rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL); - + return result; } @@ -57,17 +57,17 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd, ********************************************************************/ static WERROR watch_service_state(struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, - const char *service, + const char *service, uint32 watch_state, uint32 *final_state ) { uint32 i; uint32 state = 0; WERROR result = WERR_GENERAL_FAILURE; - - + + i = 0; while ( (state != watch_state ) && i<30 ) { /* get the status */ @@ -76,15 +76,15 @@ static WERROR watch_service_state(struct rpc_pipe_client *pipe_hnd, if ( !W_ERROR_IS_OK(result) ) { break; } - + d_printf("."); i++; sys_usleep( 100 ); } d_printf("\n"); - + *final_state = state; - + return result; } @@ -92,9 +92,9 @@ static WERROR watch_service_state(struct rpc_pipe_client *pipe_hnd, ********************************************************************/ static WERROR control_service(struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, - const char *service, + const char *service, uint32 control, uint32 watch_state ) { @@ -102,47 +102,47 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd, WERROR result = WERR_GENERAL_FAILURE; SERVICE_STATUS service_status; uint32 state = 0; - + /* Open the Service */ - - result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, hSCM, &hService, + + result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, hSCM, &hService, service, (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE) ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } - + /* get the status */ - result = rpccli_svcctl_control_service(pipe_hnd, mem_ctx, &hService, + result = rpccli_svcctl_control_service(pipe_hnd, mem_ctx, &hService, control, &service_status ); - + if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Control service request failed. [%s]\n", dos_errstr(result)); goto done; } - + /* loop -- checking the state until we are where we want to be */ - + result = watch_service_state(pipe_hnd, mem_ctx, hSCM, service, watch_state, &state ); - + d_printf("%s service is %s.\n", service, svc_status_string(state)); -done: +done: rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL); - + return result; -} +} /******************************************************************** ********************************************************************/ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { @@ -153,7 +153,7 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid, fstring displayname; uint32 num_services = 0; int i; - + if (argc != 0 ) { d_printf("Usage: net rpc service list\n"); return NT_STATUS_OK; @@ -164,39 +164,39 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid, d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } - + result = rpccli_svcctl_enumerate_services(pipe_hnd, mem_ctx, &hSCM, SVCCTL_TYPE_WIN32, SVCCTL_STATE_ALL, &num_services, &services ); - + if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to enumerate services. [%s]\n", dos_errstr(result)); goto done; } - + if ( num_services == 0 ) d_printf("No services returned\n"); - + for ( i=0; i\n"); return NT_STATUS_OK; @@ -215,23 +215,23 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - + result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } - + /* Open the Service */ - - result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService, servicename, + + result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService, servicename, (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG) ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } - + /* get the status */ result = rpccli_svcctl_query_status(pipe_hnd, mem_ctx, &hService, &service_status ); @@ -239,7 +239,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, d_fprintf(stderr, "Query status request failed. [%s]\n", dos_errstr(result)); goto done; } - + d_printf("%s service is %s.\n", servicename, svc_status_string(service_status.state)); /* get the config */ @@ -284,28 +284,28 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, d_printf("\tDisplay Name = %s\n", ascii_string); } -done: +done: rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL); rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL); return werror_to_ntstatus(result); -} +} /******************************************************************** ********************************************************************/ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { POLICY_HND hSCM; WERROR result = WERR_GENERAL_FAILURE; fstring servicename; - + if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); return NT_STATUS_OK; @@ -314,36 +314,36 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - + result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } - - result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, + + result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, SVCCTL_CONTROL_STOP, SVCCTL_STOPPED ); - + rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL); - + return werror_to_ntstatus(result); -} +} /******************************************************************** ********************************************************************/ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { POLICY_HND hSCM; WERROR result = WERR_GENERAL_FAILURE; fstring servicename; - + if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); return NT_STATUS_OK; @@ -352,36 +352,36 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - + result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } - - result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, + + result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, SVCCTL_CONTROL_PAUSE, SVCCTL_PAUSED ); - + rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL); - + return werror_to_ntstatus(result); -} +} /******************************************************************** ********************************************************************/ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { POLICY_HND hSCM; WERROR result = WERR_GENERAL_FAILURE; fstring servicename; - + if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); return NT_STATUS_OK; @@ -390,29 +390,29 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - + result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } - - result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, + + result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename, SVCCTL_CONTROL_CONTINUE, SVCCTL_RUNNING ); - + rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL); - + return werror_to_ntstatus(result); -} +} /******************************************************************** ********************************************************************/ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv ) { @@ -420,7 +420,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, WERROR result = WERR_GENERAL_FAILURE; fstring servicename; uint32 state = 0; - + if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); return NT_STATUS_OK; @@ -429,23 +429,23 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - + result = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } - + /* Open the Service */ - - result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService, + + result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService, servicename, SC_RIGHT_SVC_START ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } - + /* get the status */ result = rpccli_svcctl_start_service(pipe_hnd, mem_ctx, &hService, NULL, 0 ); @@ -453,15 +453,15 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, d_fprintf(stderr, "Query status request failed. [%s]\n", dos_errstr(result)); goto done; } - + result = watch_service_state(pipe_hnd, mem_ctx, &hSCM, servicename, SVCCTL_RUNNING, &state ); - + if ( W_ERROR_IS_OK(result) && (state == SVCCTL_RUNNING) ) d_printf("Successfully started service: %s\n", servicename ); else d_fprintf(stderr, "Failed to start service: %s [%s]\n", servicename, dos_errstr(result) ); - -done: + +done: rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL); rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL); @@ -473,7 +473,7 @@ done: static int rpc_service_list( int argc, const char **argv ) { - return run_rpc_command( NULL, PI_SVCCTL, 0, + return run_rpc_command( NULL, PI_SVCCTL, 0, rpc_service_list_internal, argc, argv ); } @@ -482,7 +482,7 @@ static int rpc_service_list( int argc, const char **argv ) static int rpc_service_start( int argc, const char **argv ) { - return run_rpc_command( NULL, PI_SVCCTL, 0, + return run_rpc_command( NULL, PI_SVCCTL, 0, rpc_service_start_internal, argc, argv ); } @@ -491,7 +491,7 @@ static int rpc_service_start( int argc, const char **argv ) static int rpc_service_stop( int argc, const char **argv ) { - return run_rpc_command( NULL, PI_SVCCTL, 0, + return run_rpc_command( NULL, PI_SVCCTL, 0, rpc_service_stop_internal, argc, argv ); } @@ -500,7 +500,7 @@ static int rpc_service_stop( int argc, const char **argv ) static int rpc_service_resume( int argc, const char **argv ) { - return run_rpc_command( NULL, PI_SVCCTL, 0, + return run_rpc_command( NULL, PI_SVCCTL, 0, rpc_service_resume_internal, argc, argv ); } @@ -509,7 +509,7 @@ static int rpc_service_resume( int argc, const char **argv ) static int rpc_service_pause( int argc, const char **argv ) { - return run_rpc_command( NULL, PI_SVCCTL, 0, + return run_rpc_command( NULL, PI_SVCCTL, 0, rpc_service_pause_internal, argc, argv ); } @@ -518,7 +518,7 @@ static int rpc_service_pause( int argc, const char **argv ) static int rpc_service_status( int argc, const char **argv ) { - return run_rpc_command( NULL, PI_SVCCTL, 0, + return run_rpc_command( NULL, PI_SVCCTL, 0, rpc_service_status_internal, argc, argv ); } @@ -533,14 +533,14 @@ static int net_help_service( int argc, const char **argv ) d_printf("net rpc service pause Pause a service\n"); d_printf("net rpc service resume Resume a paused service\n"); d_printf("net rpc service status View the current status of a service\n"); - + return -1; } /******************************************************************** ********************************************************************/ -int net_rpc_service(int argc, const char **argv) +int net_rpc_service(int argc, const char **argv) { struct functable func[] = { {"list", rpc_service_list}, @@ -551,9 +551,9 @@ int net_rpc_service(int argc, const char **argv) {"status", rpc_service_status}, {NULL, NULL} }; - + if ( argc ) return net_run_function( argc, argv, func, net_help_service ); - + return net_help_service( argc, argv ); } -- cgit From 357bf008121f7cb8609b10d37501151adb34bd28 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 11:55:31 +0100 Subject: Use pidl for _svcctl_OpenSCManagerW(). Guenther (This used to be commit 1131e914df9c69b046f335999b7b62063e92fb9d) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 27 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index ce81a24202..ba939ac11a 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -53,23 +53,7 @@ static bool api_svcctl_close_service(pipes_struct *p) static bool api_svcctl_open_scmanager(pipes_struct *p) { - SVCCTL_Q_OPEN_SCMANAGER q_u; - SVCCTL_R_OPEN_SCMANAGER r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_open_scmanager("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_open_scmanager(p, &q_u, &r_u); - - if(!svcctl_io_r_open_scmanager("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_OPENSCMANAGERW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 11b7ab6ca2..459def11c7 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -263,7 +263,8 @@ done: /******************************************************************** ********************************************************************/ -WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) +WERROR _svcctl_OpenSCManagerW(pipes_struct *p, + struct svcctl_OpenSCManagerW *r) { SEC_DESC *sec_desc; uint32 access_granted = 0; @@ -274,12 +275,12 @@ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVC if ( !(sec_desc = construct_scm_sd( p->mem_ctx )) ) return WERR_NOMEM; - se_map_generic( &q_u->access, &scm_generic_map ); - status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + se_map_generic( &r->in.access_mask, &scm_generic_map ); + status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, r->in.access_mask, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SCM, NULL, access_granted ); + return create_open_service_handle( p, r->out.handle, SVC_HANDLE_IS_SCM, NULL, access_granted ); } /******************************************************************** @@ -964,12 +965,6 @@ WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesSt return WERR_NOT_SUPPORTED; } -WERROR _svcctl_OpenSCManagerW(pipes_struct *p, struct svcctl_OpenSCManagerW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_OpenServiceW(pipes_struct *p, struct svcctl_OpenServiceW *r) { p->rng_fault_state = True; -- cgit From 0ca295bb32d69711eb799d8f8323aa17e5928a10 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 12:10:54 +0100 Subject: Use rpccli_svcctl_OpenSCManagerW() in net. Guenther (This used to be commit 275ce92e277c0d30cfa098e62674111c994aeb4c) --- source3/utils/net_rpc_service.c | 92 +++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 17 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c index 5ad907e8a6..789afe234f 100644 --- a/source3/utils/net_rpc_service.c +++ b/source3/utils/net_rpc_service.c @@ -20,6 +20,9 @@ #include "utils/net.h" +#define CLI_SERVER_NAME_SLASH(_ctx, _p, _cli) \ + _p = talloc_asprintf(_ctx, "\\\\%s", _cli->cli->desthost); + /******************************************************************** ********************************************************************/ @@ -149,9 +152,11 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid, POLICY_HND hSCM; ENUM_SERVICES_STATUS *services; WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS status; fstring servicename; fstring displayname; uint32 num_services = 0; + const char *server_name; int i; if (argc != 0 ) { @@ -159,8 +164,16 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid, return NT_STATUS_OK; } - result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); - if ( !W_ERROR_IS_OK(result) ) { + CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd); + NT_STATUS_HAVE_NO_MEMORY(server_name); + + status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, + server_name, + NULL, + SC_RIGHT_MGR_ENUMERATE_SERVICE, + &hSCM, + &result); + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -202,10 +215,12 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, { POLICY_HND hSCM, hService; WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS status; fstring servicename; SERVICE_STATUS service_status; SERVICE_CONFIG config; fstring ascii_string; + const char *server_name; if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); @@ -215,9 +230,16 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - - result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); - if ( !W_ERROR_IS_OK(result) ) { + CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd); + NT_STATUS_HAVE_NO_MEMORY(server_name); + + status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, + server_name, + NULL, + SC_RIGHT_MGR_ENUMERATE_SERVICE, + &hSCM, + &result); + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -304,7 +326,9 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid, { POLICY_HND hSCM; WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS status; fstring servicename; + const char *server_name; if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); @@ -314,9 +338,16 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - - result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); - if ( !W_ERROR_IS_OK(result) ) { + CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd); + NT_STATUS_HAVE_NO_MEMORY(server_name); + + status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, + server_name, + NULL, + SC_RIGHT_MGR_ENUMERATE_SERVICE, + &hSCM, + &result); + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -342,7 +373,9 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid, { POLICY_HND hSCM; WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS status; fstring servicename; + const char *server_name; if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); @@ -352,9 +385,16 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - - result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); - if ( !W_ERROR_IS_OK(result) ) { + CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd); + NT_STATUS_HAVE_NO_MEMORY(server_name); + + status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, + server_name, + NULL, + SC_RIGHT_MGR_ENUMERATE_SERVICE, + &hSCM, + &result); + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -380,7 +420,9 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid, { POLICY_HND hSCM; WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS status; fstring servicename; + const char *server_name; if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); @@ -390,9 +432,16 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - - result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); - if ( !W_ERROR_IS_OK(result) ) { + CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd); + NT_STATUS_HAVE_NO_MEMORY(server_name); + + status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, + server_name, + NULL, + SC_RIGHT_MGR_ENUMERATE_SERVICE, + &hSCM, + &result); + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -418,8 +467,10 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, { POLICY_HND hSCM, hService; WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS status; fstring servicename; uint32 state = 0; + const char *server_name; if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); @@ -429,9 +480,16 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, fstrcpy( servicename, argv[0] ); /* Open the Service Control Manager */ - - result = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); - if ( !W_ERROR_IS_OK(result) ) { + CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd); + NT_STATUS_HAVE_NO_MEMORY(server_name); + + status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, + server_name, + NULL, + SC_RIGHT_MGR_ENUMERATE_SERVICE, + &hSCM, + &result); + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } -- cgit From 330fe0a62a29ff994e1520dae209eb4980a7259c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 12:12:43 +0100 Subject: Remove unused marshalling for SVCCTL_OPEN_SCMANAGER. Guenther (This used to be commit 1162b8a02d365b79f5a3e86c936bae80092f1869) --- source3/include/rpc_svcctl.h | 13 ---------- source3/rpc_client/cli_svcctl.c | 42 ------------------------------- source3/rpc_parse/parse_svcctl.c | 53 ---------------------------------------- 3 files changed, 108 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index 1e42aef20c..17e25903ef 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -196,19 +196,6 @@ typedef struct _ServiceInfo { /**************************/ -typedef struct { - UNISTR2 *servername; - UNISTR2 *database; - uint32 access; -} SVCCTL_Q_OPEN_SCMANAGER; - -typedef struct { - POLICY_HND handle; - WERROR status; -} SVCCTL_R_OPEN_SCMANAGER; - -/**************************/ - typedef struct { POLICY_HND handle; UNISTR2 servicename; diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 95673c1565..699db6cd77 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -60,48 +60,6 @@ const char* svc_status_string( uint32 state ) /******************************************************************** ********************************************************************/ -WERROR rpccli_svcctl_open_scm(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hSCM, uint32 access_desired ) -{ - SVCCTL_Q_OPEN_SCMANAGER in; - SVCCTL_R_OPEN_SCMANAGER out; - prs_struct qbuf, rbuf; - fstring server; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - /* leave the database name NULL to get the default service db */ - - in.database = NULL; - - /* set the server name */ - - if ( !(in.servername = TALLOC_P( mem_ctx, UNISTR2 )) ) - return WERR_NOMEM; - fstr_sprintf( server, "\\\\%s", cli->cli->desthost ); - init_unistr2( in.servername, server, UNI_STR_TERMINATE ); - - in.access = access_desired; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, - in, out, - qbuf, rbuf, - svcctl_io_q_open_scmanager, - svcctl_io_r_open_scmanager, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( hSCM, &out.handle, sizeof(POLICY_HND) ); - - return out.status; -} - -/******************************************************************** -********************************************************************/ - WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, POLICY_HND *hService, const char *servicename, uint32 access_desired ) diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index 18e12ef0a6..488f060e6e 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -198,59 +198,6 @@ uint32 svcctl_sizeof_service_config( SERVICE_CONFIG *config ) /******************************************************************* ********************************************************************/ -bool svcctl_io_q_open_scmanager(const char *desc, SVCCTL_Q_OPEN_SCMANAGER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_open_scmanager"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_pointer("servername", ps, depth, (void*)&q_u->servername, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_pointer("database", ps, depth, (void*)&q_u->database, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("access", ps, depth, &q_u->access)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_open_scmanager(const char *desc, SVCCTL_R_OPEN_SCMANAGER *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_open_scmanager"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("scm_pol", &r_u->handle, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - bool svcctl_io_q_get_display_name(const char *desc, SVCCTL_Q_GET_DISPLAY_NAME *q_u, prs_struct *ps, int depth) { if (q_u == NULL) -- cgit From 5943ff68e7838be67148b1c0eef91f3c1ab66230 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 12:55:35 +0100 Subject: Use pidl for _svcctl_OpenServiceW(). Note that this call did and still does panic in registry access. Michael has an idea how to fix this. Guenther (This used to be commit b2fa41072ddd2aba000a33eb32ccee408d8304db) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 32 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 37 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index ba939ac11a..a134df8597 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -61,23 +61,7 @@ static bool api_svcctl_open_scmanager(pipes_struct *p) static bool api_svcctl_open_service(pipes_struct *p) { - SVCCTL_Q_OPEN_SERVICE q_u; - SVCCTL_R_OPEN_SERVICE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_open_service("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_open_service(p, &q_u, &r_u); - - if(!svcctl_io_r_open_service("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_OPENSERVICEW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 459def11c7..40f3584e3e 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -284,28 +284,26 @@ WERROR _svcctl_OpenSCManagerW(pipes_struct *p, } /******************************************************************** + _svcctl_OpenServiceW ********************************************************************/ -WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_R_OPEN_SERVICE *r_u) +WERROR _svcctl_OpenServiceW(pipes_struct *p, + struct svcctl_OpenServiceW *r) { SEC_DESC *sec_desc; uint32 access_granted = 0; NTSTATUS status; - char *service = NULL; - size_t ret = rpcstr_pull_talloc(p->mem_ctx, - &service, - q_u->servicename.buffer, - q_u->servicename.uni_str_len*2, - 0); - - if (ret == (size_t)-1 || !service) { + const char *service = NULL; + + service = r->in.ServiceName; + if (!service) { return WERR_NOMEM; } - DEBUG(5, ("_svcctl_open_service: Attempting to open Service [%s], \n", service)); + DEBUG(5, ("_svcctl_OpenServiceW: Attempting to open Service [%s], \n", service)); /* based on my tests you can open a service if you have a valid scm handle */ - if ( !find_service_info_by_hnd( p, &q_u->handle ) ) + if ( !find_service_info_by_hnd( p, r->in.scmanager_handle) ) return WERR_BADFID; /* perform access checks. Use the root token in order to ensure that we @@ -314,12 +312,12 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, service, get_root_nt_token() )) ) return WERR_NOMEM; - se_map_generic( &q_u->access, &svc_generic_map ); - status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + se_map_generic( &r->in.access_mask, &svc_generic_map ); + status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, r->in.access_mask, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SERVICE, service, access_granted ); + return create_open_service_handle( p, r->out.handle, SVC_HANDLE_IS_SERVICE, service, access_granted ); } /******************************************************************** @@ -965,12 +963,6 @@ WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesSt return WERR_NOT_SUPPORTED; } -WERROR _svcctl_OpenServiceW(pipes_struct *p, struct svcctl_OpenServiceW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_QueryServiceConfigW(pipes_struct *p, struct svcctl_QueryServiceConfigW *r) { p->rng_fault_state = True; -- cgit From f40f80008d9a20d54c3a43b001929c3963c82d0a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 12:45:13 +0100 Subject: Use rpccli_svcctl_OpenServiceW() in net. Guenther (This used to be commit 1537a2ff36841fea7bd5d49283667dd02bae84b8) --- source3/utils/net_rpc_service.c | 57 ++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c index 789afe234f..74848b23a4 100644 --- a/source3/utils/net_rpc_service.c +++ b/source3/utils/net_rpc_service.c @@ -35,13 +35,17 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd, POLICY_HND hService; SERVICE_STATUS service_status; WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS status; /* now cycle until the status is actually 'watch_state' */ - result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, hSCM, &hService, - service, SC_RIGHT_SVC_QUERY_STATUS ); - - if ( !W_ERROR_IS_OK(result) ) { + status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx, + hSCM, + service, + SC_RIGHT_SVC_QUERY_STATUS, + &hService, + &result); + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); return result; } @@ -103,15 +107,20 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd, { POLICY_HND hService; WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS status; SERVICE_STATUS service_status; uint32 state = 0; /* Open the Service */ - result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, hSCM, &hService, - service, (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE) ); + status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx, + hSCM, + service, + (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE), + &hService, + &result); - if ( !W_ERROR_IS_OK(result) ) { + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } @@ -216,7 +225,6 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, POLICY_HND hSCM, hService; WERROR result = WERR_GENERAL_FAILURE; NTSTATUS status; - fstring servicename; SERVICE_STATUS service_status; SERVICE_CONFIG config; fstring ascii_string; @@ -227,8 +235,6 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, return NT_STATUS_OK; } - fstrcpy( servicename, argv[0] ); - /* Open the Service Control Manager */ CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd); NT_STATUS_HAVE_NO_MEMORY(server_name); @@ -246,10 +252,14 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, /* Open the Service */ - result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService, servicename, - (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG) ); + status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx, + &hSCM, + argv[0], + (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG), + &hService, + &result); - if ( !W_ERROR_IS_OK(result) ) { + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } @@ -262,7 +272,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, goto done; } - d_printf("%s service is %s.\n", servicename, svc_status_string(service_status.state)); + d_printf("%s service is %s.\n", argv[0], svc_status_string(service_status.state)); /* get the config */ @@ -468,7 +478,6 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, POLICY_HND hSCM, hService; WERROR result = WERR_GENERAL_FAILURE; NTSTATUS status; - fstring servicename; uint32 state = 0; const char *server_name; @@ -477,8 +486,6 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, return NT_STATUS_OK; } - fstrcpy( servicename, argv[0] ); - /* Open the Service Control Manager */ CLI_SERVER_NAME_SLASH(mem_ctx, server_name, pipe_hnd); NT_STATUS_HAVE_NO_MEMORY(server_name); @@ -496,10 +503,14 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, /* Open the Service */ - result = rpccli_svcctl_open_service(pipe_hnd, mem_ctx, &hSCM, &hService, - servicename, SC_RIGHT_SVC_START ); + status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx, + &hSCM, + argv[0], + SC_RIGHT_SVC_START, + &hService, + &result); - if ( !W_ERROR_IS_OK(result) ) { + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } @@ -512,12 +523,12 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, goto done; } - result = watch_service_state(pipe_hnd, mem_ctx, &hSCM, servicename, SVCCTL_RUNNING, &state ); + result = watch_service_state(pipe_hnd, mem_ctx, &hSCM, argv[0], SVCCTL_RUNNING, &state ); if ( W_ERROR_IS_OK(result) && (state == SVCCTL_RUNNING) ) - d_printf("Successfully started service: %s\n", servicename ); + d_printf("Successfully started service: %s\n", argv[0] ); else - d_fprintf(stderr, "Failed to start service: %s [%s]\n", servicename, dos_errstr(result) ); + d_fprintf(stderr, "Failed to start service: %s [%s]\n", argv[0], dos_errstr(result) ); done: rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL); -- cgit From 6d95d7d9b9277e3aba6b43869a31fd3226ac697c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 12:48:43 +0100 Subject: Remove unused marshalling for SVCCTL_OPEN_SERVICE. Guenther (This used to be commit e0a8818af0e3e82e9b70ff6c485090986b435fed) --- source3/include/rpc_svcctl.h | 13 ---------- source3/rpc_client/cli_svcctl.c | 33 ------------------------- source3/rpc_parse/parse_svcctl.c | 52 ---------------------------------------- 3 files changed, 98 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index 17e25903ef..14a9dd6498 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -210,19 +210,6 @@ typedef struct { /**************************/ -typedef struct { - POLICY_HND handle; - UNISTR2 servicename; - uint32 access; -} SVCCTL_Q_OPEN_SERVICE; - -typedef struct { - POLICY_HND handle; - WERROR status; -} SVCCTL_R_OPEN_SERVICE; - -/**************************/ - typedef struct { POLICY_HND handle; uint32 parmcount; diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 699db6cd77..0a5cf7674b 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -57,39 +57,6 @@ const char* svc_status_string( uint32 state ) return talloc_strdup(talloc_tos(), msg); } -/******************************************************************** -********************************************************************/ - -WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hSCM, POLICY_HND *hService, - const char *servicename, uint32 access_desired ) -{ - SVCCTL_Q_OPEN_SERVICE in; - SVCCTL_R_OPEN_SERVICE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hSCM, sizeof(POLICY_HND) ); - init_unistr2( &in.servicename, servicename, UNI_STR_TERMINATE ); - in.access = access_desired; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SERVICE_W, - in, out, - qbuf, rbuf, - svcctl_io_q_open_service, - svcctl_io_r_open_service, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( hService, &out.handle, sizeof(POLICY_HND) ); - - return out.status; -} - /******************************************************************* *******************************************************************/ diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index 488f060e6e..7fd13e8f21 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -266,58 +266,6 @@ bool svcctl_io_r_get_display_name(const char *desc, SVCCTL_R_GET_DISPLAY_NAME *r } -/******************************************************************* -********************************************************************/ - -bool svcctl_io_q_open_service(const char *desc, SVCCTL_Q_OPEN_SERVICE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_open_service"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth)) - return False; - - if(!smb_io_unistr2("servicename", &q_u->servicename, 1, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("access", ps, depth, &q_u->access)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_open_service(const char *desc, SVCCTL_R_OPEN_SERVICE *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_open_service"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("service_pol", &r_u->handle, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - /******************************************************************* ********************************************************************/ -- cgit From 1c298d59a670f1c1ccf7c492b5a29dc8bb15ed0c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 13:43:12 +0100 Subject: Use pidl for _svcctl_GetServiceDisplayNameW(). Guenther (This used to be commit 2746e88c5c4a9e859356d5c53106eba0c2cd7cbe) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 28 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index a134df8597..84c986dbfb 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -69,23 +69,7 @@ static bool api_svcctl_open_service(pipes_struct *p) static bool api_svcctl_get_display_name(pipes_struct *p) { - SVCCTL_Q_GET_DISPLAY_NAME q_u; - SVCCTL_R_GET_DISPLAY_NAME r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_get_display_name("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_get_display_name(p, &q_u, &r_u); - - if(!svcctl_io_r_get_display_name("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_GETSERVICEDISPLAYNAMEW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 40f3584e3e..bdd0f4ffe3 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -332,23 +332,30 @@ WERROR _svcctl_CloseServiceHandle(pipes_struct *p, struct svcctl_CloseServiceHan } /******************************************************************** + _svcctl_GetServiceDisplayNameW ********************************************************************/ -WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, SVCCTL_R_GET_DISPLAY_NAME *r_u) +WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, + struct svcctl_GetServiceDisplayNameW *r) { - fstring service; + const char *service; const char *display_name; - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* can only use an SCM handle here */ if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) return WERR_BADFID; - rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); + service = r->in.service_name; display_name = svcctl_lookup_dispname(p->mem_ctx, service, p->pipe_user.nt_user_token ); - init_svcctl_r_get_display_name( r_u, display_name ? display_name : ""); + if (!display_name) { + display_name = ""; + } + + *r->out.display_name = display_name; + *r->out.display_name_length = strlen(display_name); return WERR_OK; } @@ -981,12 +988,6 @@ WERROR _svcctl_StartServiceW(pipes_struct *p, struct svcctl_StartServiceW *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, struct svcctl_GetServiceDisplayNameW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_GetServiceKeyNameW(pipes_struct *p, struct svcctl_GetServiceKeyNameW *r) { p->rng_fault_state = True; -- cgit From 4673706e1d130555231b409baa270d7000267117 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 13:45:36 +0100 Subject: Remove unused marshalling for SVCCTL_GET_DISPLAY_NAME. Guenther (This used to be commit 144f41e7c3c97afede71ed771acd130f9018f0df) --- source3/include/rpc_svcctl.h | 14 -------- source3/rpc_client/cli_svcctl.c | 45 ------------------------- source3/rpc_parse/parse_svcctl.c | 71 ---------------------------------------- 3 files changed, 130 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index 14a9dd6498..c40ea8e8ce 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -196,20 +196,6 @@ typedef struct _ServiceInfo { /**************************/ -typedef struct { - POLICY_HND handle; - UNISTR2 servicename; - uint32 display_name_len; -} SVCCTL_Q_GET_DISPLAY_NAME; - -typedef struct { - UNISTR2 displayname; - uint32 display_name_len; - WERROR status; -} SVCCTL_R_GET_DISPLAY_NAME; - -/**************************/ - typedef struct { POLICY_HND handle; uint32 parmcount; diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 0a5cf7674b..cdd1b93aaa 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -290,48 +290,3 @@ WERROR rpccli_svcctl_control_service( struct rpc_pipe_client *cli, TALLOC_CTX *m return out.status; } - - -/******************************************************************* -*******************************************************************/ - -WERROR rpccli_svcctl_get_dispname( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, fstring displayname ) -{ - SVCCTL_Q_GET_DISPLAY_NAME in; - SVCCTL_R_GET_DISPLAY_NAME out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - in.display_name_len = 0; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, - in, out, - qbuf, rbuf, - svcctl_io_q_get_display_name, - svcctl_io_r_get_display_name, - WERR_GENERAL_FAILURE ); - - /* second time with correct buffer size...should be ok */ - - if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { - in.display_name_len = out.display_name_len; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, - in, out, - qbuf, rbuf, - svcctl_io_q_get_display_name, - svcctl_io_r_get_display_name, - WERR_GENERAL_FAILURE ); - } - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - rpcstr_pull( displayname, out.displayname.buffer, sizeof(displayname), -1, STR_TERMINATE ); - - return out.status; -} diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index 7fd13e8f21..f3ed8d1bf5 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -195,77 +195,6 @@ uint32 svcctl_sizeof_service_config( SERVICE_CONFIG *config ) return size; } -/******************************************************************* -********************************************************************/ - -bool svcctl_io_q_get_display_name(const char *desc, SVCCTL_Q_GET_DISPLAY_NAME *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_get_display_name"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("scm_pol", &q_u->handle, ps, depth)) - return False; - - if(!smb_io_unistr2("servicename", &q_u->servicename, 1, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("display_name_len", ps, depth, &q_u->display_name_len)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool init_svcctl_r_get_display_name( SVCCTL_R_GET_DISPLAY_NAME *r_u, const char *displayname ) -{ - r_u->display_name_len = strlen(displayname); - init_unistr2( &r_u->displayname, displayname, UNI_STR_TERMINATE ); - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_get_display_name(const char *desc, SVCCTL_R_GET_DISPLAY_NAME *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_get_display_name"); - depth++; - - if(!prs_align(ps)) - return False; - - - if(!smb_io_unistr2("displayname", &r_u->displayname, 1, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("display_name_len", ps, depth, &r_u->display_name_len)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - /******************************************************************* ********************************************************************/ -- cgit From 0349835b3439a2321c30220340aef44a5f13c719 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 14:40:34 +0100 Subject: Use pidl for _lsa_LookupNames() and _lsa_LookupNames2(). Hopefully I didn't screw this up. Please check :) Guenther (This used to be commit 01b733f10c1645668f2aea2841bbdc64b4bd5c51) --- source3/rpc_client/init_lsa.c | 14 +++ source3/rpc_server/srv_lsa.c | 48 +-------- source3/rpc_server/srv_lsa_nt.c | 230 +++++++++++++++++++++------------------- 3 files changed, 137 insertions(+), 155 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/init_lsa.c b/source3/rpc_client/init_lsa.c index 114e435945..43d0de501f 100644 --- a/source3/rpc_client/init_lsa.c +++ b/source3/rpc_client/init_lsa.c @@ -86,3 +86,17 @@ void init_lsa_obj_attr(struct lsa_ObjectAttribute *r, r->sec_qos = sec_qos; } +/******************************************************************* + Inits a lsa_TranslatedSid structure. +********************************************************************/ + +void init_lsa_translated_sid(struct lsa_TranslatedSid *r, + enum lsa_SidType sid_type, + uint32_t rid, + uint32_t sid_index) +{ + r->sid_type = sid_type; + r->rid = rid; + r->sid_index = sid_index; +} + diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index dfb3323873..dd4afcab52 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -118,29 +118,7 @@ static bool api_lsa_lookup_sids(pipes_struct *p) static bool api_lsa_lookup_names(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES q_u; - LSA_R_LOOKUP_NAMES r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n")); - return False; - } - - r_u.status = _lsa_lookup_names(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES); } /*************************************************************************** @@ -412,29 +390,7 @@ static bool api_lsa_lookup_sids3(pipes_struct *p) static bool api_lsa_lookup_names2(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES2 q_u; - LSA_R_LOOKUP_NAMES2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names2("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_names2: failed to unmarshall LSA_Q_LOOKUP_NAMES2.\n")); - return False; - } - - r_u.status = _lsa_lookup_names2(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names2("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_names2: Failed to marshall LSA_R_LOOKUP_NAMES2.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES2); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 027277e8d9..6cf26e7eb2 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -46,6 +46,51 @@ const struct generic_mapping lsa_generic_mapping = { POLICY_ALL_ACCESS }; +/*************************************************************************** + init_lsa_ref_domain_list - adds a domain if it's not already in, returns the index. +***************************************************************************/ + +static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx, + struct lsa_RefDomainList *ref, + const char *dom_name, + DOM_SID *dom_sid) +{ + int num = 0; + + if (dom_name != NULL) { + for (num = 0; num < ref->count; num++) { + if (sid_equal(dom_sid, ref->domains[num].sid)) { + return num; + } + } + } else { + num = ref->count; + } + + if (num >= MAX_REF_DOMAINS) { + /* index not found, already at maximum domain limit */ + return -1; + } + + ref->count = num + 1; + ref->max_size = MAX_REF_DOMAINS; + + ref->domains = TALLOC_REALLOC_ARRAY(mem_ctx, ref->domains, + struct lsa_DomainInfo, ref->count); + if (!ref->domains) { + return -1; + } + + init_lsa_StringLarge(&ref->domains[num].name, dom_name); + ref->domains[num].sid = sid_dup_talloc(mem_ctx, dom_sid); + if (!ref->domains[num].sid) { + return -1; + } + + return num; +} + + /******************************************************************* Function to free the per handle data. ********************************************************************/ @@ -123,12 +168,12 @@ static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) ***************************************************************************/ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, - DOM_R_REF *ref, - DOM_RID *prid, - uint32 num_entries, - const UNISTR2 *name, - int flags, - uint32 *pmapped_count) + struct lsa_RefDomainList *ref, + struct lsa_TranslatedSid *prid, + uint32_t num_entries, + struct lsa_String *name, + int flags, + uint32_t *pmapped_count) { uint32 mapped_count, i; @@ -141,15 +186,14 @@ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, DOM_SID sid; uint32 rid; int dom_idx; - char *full_name; + const char *full_name; const char *domain; enum lsa_SidType type = SID_NAME_UNKNOWN; /* Split name into domain and user component */ - full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]); + full_name = name[i].string; if (full_name == NULL) { - DEBUG(0, ("pull_ucs2_talloc failed\n")); return NT_STATUS_NO_MEMORY; } @@ -182,11 +226,11 @@ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, if (type != SID_NAME_UNKNOWN) { sid_split_rid(&sid, &rid); - dom_idx = init_dom_ref(ref, domain, &sid); + dom_idx = init_lsa_ref_domain_list(mem_ctx, ref, domain, &sid); mapped_count++; } - init_dom_rid(&prid[i], rid, type, dom_idx); + init_lsa_translated_sid(&prid[i], type, rid, dom_idx); } *pmapped_count = mapped_count; @@ -1068,33 +1112,37 @@ static int lsa_lookup_level_to_flags(uint16 level) } /*************************************************************************** -lsa_reply_lookup_names + _lsa_LookupNames ***************************************************************************/ -NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u) +NTSTATUS _lsa_LookupNames(pipes_struct *p, + struct lsa_LookupNames *r) { + NTSTATUS status = NT_STATUS_NONE_MAPPED; struct lsa_info *handle; - UNISTR2 *names = q_u->uni_name; - uint32 num_entries = q_u->num_entries; - DOM_R_REF *ref; - DOM_RID *rids; + struct lsa_String *names = r->in.names; + uint32 num_entries = r->in.num_names; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TranslatedSid *rids = NULL; uint32 mapped_count = 0; int flags = 0; if (num_entries > MAX_LOOKUP_SIDS) { num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); + DEBUG(5,("_lsa_LookupNames: truncating name lookup list to %d\n", + num_entries)); } - flags = lsa_lookup_level_to_flags(q_u->lookup_level); + flags = lsa_lookup_level_to_flags(r->in.level); - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (!ref) { + domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList); + if (!domains) { return NT_STATUS_NO_MEMORY; } if (num_entries) { - rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); + rids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid, + num_entries); if (!rids) { return NT_STATUS_NO_MEMORY; } @@ -1102,114 +1150,90 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP rids = NULL; } - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - r_u->status = NT_STATUS_INVALID_HANDLE; + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) { + status = NT_STATUS_INVALID_HANDLE; goto done; } /* check if the user have enough rights */ if (!(handle->access & POLICY_LOOKUP_NAMES)) { - r_u->status = NT_STATUS_ACCESS_DENIED; + status = NT_STATUS_ACCESS_DENIED; goto done; } /* set up the LSA Lookup RIDs response */ become_root(); /* lookup_name can require root privs */ - r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries, - names, flags, &mapped_count); + status = lookup_lsa_rids(p->mem_ctx, domains, rids, num_entries, + names, flags, &mapped_count); unbecome_root(); done: - if (NT_STATUS_IS_OK(r_u->status) && (num_entries != 0) ) { - if (mapped_count == 0) - r_u->status = NT_STATUS_NONE_MAPPED; - else if (mapped_count != num_entries) - r_u->status = STATUS_SOME_UNMAPPED; + if (NT_STATUS_IS_OK(status) && (num_entries != 0) ) { + if (mapped_count == 0) { + status = NT_STATUS_NONE_MAPPED; + } else if (mapped_count != num_entries) { + status = STATUS_SOME_UNMAPPED; + } } - init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); - return r_u->status; + *r->out.count = num_entries; + *r->out.domains = domains; + r->out.sids->sids = rids; + r->out.sids->count = mapped_count; + + return status; } /*************************************************************************** -lsa_reply_lookup_names2 + _lsa_LookupNames2 ***************************************************************************/ -NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOOKUP_NAMES2 *r_u) +NTSTATUS _lsa_LookupNames2(pipes_struct *p, + struct lsa_LookupNames2 *r) { - struct lsa_info *handle; - UNISTR2 *names = q_u->uni_name; - uint32 num_entries = q_u->num_entries; - DOM_R_REF *ref; - DOM_RID *rids; - DOM_RID2 *rids2; - int i; - uint32 mapped_count = 0; - int flags = 0; - - if (num_entries > MAX_LOOKUP_SIDS) { - num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries)); - } - - flags = lsa_lookup_level_to_flags(q_u->lookup_level); + NTSTATUS status; + struct lsa_LookupNames q; + struct lsa_TransSidArray2 *sid_array2 = r->in.sids; + struct lsa_TransSidArray *sid_array = NULL; + uint32_t i; - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (ref == NULL) { - r_u->status = NT_STATUS_NO_MEMORY; + sid_array = TALLOC_ZERO_P(p->mem_ctx, struct lsa_TransSidArray); + if (!sid_array) { return NT_STATUS_NO_MEMORY; } - if (num_entries) { - rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); - rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); - if ((rids == NULL) || (rids2 == NULL)) { - r_u->status = NT_STATUS_NO_MEMORY; - return NT_STATUS_NO_MEMORY; - } - } else { - rids = NULL; - rids2 = NULL; - } + q.in.handle = r->in.handle; + q.in.num_names = r->in.num_names; + q.in.names = r->in.names; + q.in.level = r->in.level; + q.in.sids = sid_array; + q.in.count = r->in.count; + /* we do not know what this is for */ + /* = r->in.unknown1; */ + /* = r->in.unknown2; */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - r_u->status = NT_STATUS_INVALID_HANDLE; - goto done; - } + q.out.domains = r->out.domains; + q.out.sids = sid_array; + q.out.count = r->out.count; - /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { - r_u->status = NT_STATUS_ACCESS_DENIED; - goto done; - } + status = _lsa_LookupNames(p, &q); - /* set up the LSA Lookup RIDs response */ - become_root(); /* lookup_name can require root privs */ - r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries, - names, flags, &mapped_count); - unbecome_root(); - -done: - - if (NT_STATUS_IS_OK(r_u->status)) { - if (mapped_count == 0) { - r_u->status = NT_STATUS_NONE_MAPPED; - } else if (mapped_count != num_entries) { - r_u->status = STATUS_SOME_UNMAPPED; - } + sid_array2->sids = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedSid2, sid_array->count); + if (!sid_array2->sids) { + return NT_STATUS_NO_MEMORY; } - /* Convert the rids array to rids2. */ - for (i = 0; i < num_entries; i++) { - rids2[i].type = rids[i].type; - rids2[i].rid = rids[i].rid; - rids2[i].rid_idx = rids[i].rid_idx; - rids2[i].unknown = 0; + for (i=0; icount; i++) { + sid_array2->sids[i].sid_type = sid_array->sids[i].sid_type; + sid_array2->sids[i].rid = sid_array->sids[i].rid; + sid_array2->sids[i].sid_index = sid_array->sids[i].sid_index; + sid_array2->sids[i].unknown = 0; } - init_reply_lookup_names2(r_u, ref, num_entries, rids2, mapped_count); - return r_u->status; + r->out.sids = sid_array2; + + return status; } /*************************************************************************** @@ -2294,12 +2318,6 @@ NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) { p->rng_fault_state = True; @@ -2450,12 +2468,6 @@ NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames2(pipes_struct *p, struct lsa_LookupNames2 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r) { p->rng_fault_state = True; -- cgit From 5c930e5a7b1bec99217b758f4825fa74884c73d0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 16:51:32 +0100 Subject: Fix IDL for lsa_LookupNames3 and lsa_LookupNames4. Guenther (This used to be commit 2eda5bcbfa8fccb121e5621b45c2bd1d86f6e71e) --- source3/librpc/idl/lsa.idl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index ccac66b172..38f3489a9f 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -960,7 +960,7 @@ import "security.idl"; [in] policy_handle *handle, [in,range(0,1000)] uint32 num_names, [in,size_is(num_names)] lsa_String names[], - [out,ref] lsa_RefDomainList *domains, + [out,ref] lsa_RefDomainList **domains, [in,out,ref] lsa_TransSidArray3 *sids, [in] lsa_LookupNamesLevel level, [in,out,ref] uint32 *count, @@ -1048,7 +1048,7 @@ import "security.idl"; NTSTATUS lsa_LookupNames4( [in,range(0,1000)] uint32 num_names, [in,size_is(num_names)] lsa_String names[], - [out,ref] lsa_RefDomainList *domains, + [out,ref] lsa_RefDomainList **domains, [in,out,ref] lsa_TransSidArray3 *sids, [in] lsa_LookupNamesLevel level, [in,out,ref] uint32 *count, -- cgit From 2bac665767804bd184878ad3cb54faa4da72d995 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 16:52:56 +0100 Subject: Re-run make idl. Guenther (This used to be commit 1cac7b0f626b418909a5e7a79a1c6d335c10fbf3) --- source3/librpc/gen_ndr/cli_lsa.c | 4 +-- source3/librpc/gen_ndr/cli_lsa.h | 4 +-- source3/librpc/gen_ndr/lsa.h | 4 +-- source3/librpc/gen_ndr/ndr_lsa.c | 54 +++++++++++++++++++++++++++++++++++----- source3/librpc/gen_ndr/srv_lsa.c | 4 +-- 5 files changed, 56 insertions(+), 14 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 7f784622b5..b1609ea97b 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -2914,7 +2914,7 @@ NTSTATUS rpccli_lsa_LookupNames3(struct rpc_pipe_client *cli, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransSidArray3 *sids, enum lsa_LookupNamesLevel level, uint32_t *count, @@ -3290,7 +3290,7 @@ NTSTATUS rpccli_lsa_LookupNames4(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32_t num_names, struct lsa_String *names, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransSidArray3 *sids, enum lsa_LookupNamesLevel level, uint32_t *count, diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index 8513a9d035..7d69926484 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -316,7 +316,7 @@ NTSTATUS rpccli_lsa_LookupNames3(struct rpc_pipe_client *cli, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransSidArray3 *sids, enum lsa_LookupNamesLevel level, uint32_t *count, @@ -353,7 +353,7 @@ NTSTATUS rpccli_lsa_LookupNames4(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32_t num_names, struct lsa_String *names, - struct lsa_RefDomainList *domains, + struct lsa_RefDomainList **domains, struct lsa_TransSidArray3 *sids, enum lsa_LookupNamesLevel level, uint32_t *count, diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 62f8f2c74a..cc7bca3150 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -1472,7 +1472,7 @@ struct lsa_LookupNames3 { } in; struct { - struct lsa_RefDomainList *domains;/* [ref] */ + struct lsa_RefDomainList **domains;/* [ref] */ struct lsa_TransSidArray3 *sids;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; @@ -1576,7 +1576,7 @@ struct lsa_LookupNames4 { } in; struct { - struct lsa_RefDomainList *domains;/* [ref] */ + struct lsa_RefDomainList **domains;/* [ref] */ struct lsa_TransSidArray3 *sids;/* [ref] */ uint32_t *count;/* [ref] */ NTSTATUS result; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index d5cbc0ec21..dc4918a6d7 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -10515,7 +10515,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames3(struct ndr_push *ndr, int f if (r->out.domains == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.domains)); + if (*r->out.domains) { + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + } if (r->out.sids == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -10532,9 +10535,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames3(struct ndr_push *ndr, int f _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames3(struct ndr_pull *ndr, int flags, struct lsa_LookupNames3 *r) { uint32_t cntr_names_0; + uint32_t _ptr_domains; TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_domains_0; + TALLOC_CTX *_mem_save_domains_1; TALLOC_CTX *_mem_save_sids_0; TALLOC_CTX *_mem_save_count_0; if (flags & NDR_IN) { @@ -10595,7 +10600,18 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames3(struct ndr_pull *ndr, int f } _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); + if (_ptr_domains) { + NDR_PULL_ALLOC(ndr, *r->out.domains); + } else { + *r->out.domains = NULL; + } + if (*r->out.domains) { + _mem_save_domains_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.domains, 0); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_1, 0); + } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.sids); @@ -10661,7 +10677,12 @@ _PUBLIC_ void ndr_print_lsa_LookupNames3(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); + ndr_print_ptr(ndr, "domains", *r->out.domains); + ndr->depth++; + if (*r->out.domains) { + ndr_print_lsa_RefDomainList(ndr, "domains", *r->out.domains); + } + ndr->depth--; ndr->depth--; ndr_print_ptr(ndr, "sids", r->out.sids); ndr->depth++; @@ -11241,7 +11262,10 @@ static enum ndr_err_code ndr_push_lsa_LookupNames4(struct ndr_push *ndr, int fla if (r->out.domains == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.domains)); + if (*r->out.domains) { + NDR_CHECK(ndr_push_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + } if (r->out.sids == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -11258,8 +11282,10 @@ static enum ndr_err_code ndr_push_lsa_LookupNames4(struct ndr_push *ndr, int fla static enum ndr_err_code ndr_pull_lsa_LookupNames4(struct ndr_pull *ndr, int flags, struct lsa_LookupNames4 *r) { uint32_t cntr_names_0; + uint32_t _ptr_domains; TALLOC_CTX *_mem_save_names_0; TALLOC_CTX *_mem_save_domains_0; + TALLOC_CTX *_mem_save_domains_1; TALLOC_CTX *_mem_save_sids_0; TALLOC_CTX *_mem_save_count_0; if (flags & NDR_IN) { @@ -11313,7 +11339,18 @@ static enum ndr_err_code ndr_pull_lsa_LookupNames4(struct ndr_pull *ndr, int fla } _mem_save_domains_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.domains, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domains)); + if (_ptr_domains) { + NDR_PULL_ALLOC(ndr, *r->out.domains); + } else { + *r->out.domains = NULL; + } + if (*r->out.domains) { + _mem_save_domains_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.domains, 0); + NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.domains)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_1, 0); + } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domains_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.sids); @@ -11375,7 +11412,12 @@ _PUBLIC_ void ndr_print_lsa_LookupNames4(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_ptr(ndr, "domains", r->out.domains); ndr->depth++; - ndr_print_lsa_RefDomainList(ndr, "domains", r->out.domains); + ndr_print_ptr(ndr, "domains", *r->out.domains); + ndr->depth++; + if (*r->out.domains) { + ndr_print_lsa_RefDomainList(ndr, "domains", *r->out.domains); + } + ndr->depth--; ndr->depth--; ndr_print_ptr(ndr, "sids", r->out.sids); ndr->depth++; diff --git a/source3/librpc/gen_ndr/srv_lsa.c b/source3/librpc/gen_ndr/srv_lsa.c index b21a825682..1ce0448469 100644 --- a/source3/librpc/gen_ndr/srv_lsa.c +++ b/source3/librpc/gen_ndr/srv_lsa.c @@ -5258,7 +5258,7 @@ static bool api_lsa_LookupNames3(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.domains = talloc_zero(r, struct lsa_RefDomainList); + r->out.domains = talloc_zero(r, struct lsa_RefDomainList *); if (r->out.domains == NULL) { talloc_free(r); return false; @@ -5940,7 +5940,7 @@ static bool api_lsa_LookupNames4(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.domains = talloc_zero(r, struct lsa_RefDomainList); + r->out.domains = talloc_zero(r, struct lsa_RefDomainList *); if (r->out.domains == NULL) { talloc_free(r); return false; -- cgit From 326196b51a9e72e531abd3081b40d85ea0b8aa0b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 16:57:02 +0100 Subject: Use pidl for _lsa_LookupNames3 and _lsa_LookupNames4. Guenther (This used to be commit 4e310a19f12ba7034f33247dca0a9e7a10aa98b7) --- source3/rpc_server/srv_lsa.c | 48 +---------- source3/rpc_server/srv_lsa_nt.c | 176 +++++++++++++++++----------------------- 2 files changed, 77 insertions(+), 147 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index dd4afcab52..c5c7ade1a4 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -399,29 +399,7 @@ static bool api_lsa_lookup_names2(pipes_struct *p) static bool api_lsa_lookup_names3(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES3 q_u; - LSA_R_LOOKUP_NAMES3 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names3("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_names3: failed to unmarshall LSA_Q_LOOKUP_NAMES3.\n")); - return False; - } - - r_u.status = _lsa_lookup_names3(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names3("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_names3: Failed to marshall LSA_R_LOOKUP_NAMES3.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES3); } /*************************************************************************** @@ -430,29 +408,7 @@ static bool api_lsa_lookup_names3(pipes_struct *p) static bool api_lsa_lookup_names4(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES4 q_u; - LSA_R_LOOKUP_NAMES4 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names4("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_names4: failed to unmarshall LSA_Q_LOOKUP_NAMES4.\n")); - return False; - } - - r_u.status = _lsa_lookup_names4(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names4("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_names4: Failed to marshall LSA_R_LOOKUP_NAMES4.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES4); } #if 0 /* AD DC work in ongoing in Samba 4 */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6cf26e7eb2..5a3ed28e88 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -242,12 +242,12 @@ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, ***************************************************************************/ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, - DOM_R_REF *ref, - LSA_TRANSLATED_SID3 *trans_sids, - uint32 num_entries, - const UNISTR2 *name, - int flags, - uint32 *pmapped_count) + struct lsa_RefDomainList *ref, + struct lsa_TranslatedSid3 *trans_sids, + uint32_t num_entries, + struct lsa_String *name, + int flags, + uint32 *pmapped_count) { uint32 mapped_count, i; @@ -260,15 +260,14 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, DOM_SID sid; uint32 rid; int dom_idx; - char *full_name; + const char *full_name; const char *domain; enum lsa_SidType type = SID_NAME_UNKNOWN; /* Split name into domain and user component */ - full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]); + full_name = name[i].string; if (full_name == NULL) { - DEBUG(0, ("pull_ucs2_talloc failed\n")); return NT_STATUS_NO_MEMORY; } @@ -303,18 +302,14 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, DOM_SID domain_sid; sid_copy(&domain_sid, &sid); sid_split_rid(&domain_sid, &rid); - dom_idx = init_dom_ref(ref, domain, &domain_sid); + dom_idx = init_lsa_ref_domain_list(mem_ctx, ref, domain, &domain_sid); mapped_count++; } - /* Initialize the LSA_TRANSLATED_SID3 return. */ + /* Initialize the lsa_TranslatedSid3 return. */ trans_sids[i].sid_type = type; - trans_sids[i].sid2 = TALLOC_P(mem_ctx, DOM_SID2); - if (trans_sids[i].sid2 == NULL) { - return NT_STATUS_NO_MEMORY; - } - init_dom_sid2(trans_sids[i].sid2, &sid); - trans_sids[i].sid_idx = dom_idx; + trans_sids[i].sid = sid_dup_talloc(mem_ctx, &sid); + trans_sids[i].sid_index = dom_idx; } *pmapped_count = mapped_count; @@ -1237,35 +1232,49 @@ NTSTATUS _lsa_LookupNames2(pipes_struct *p, } /*************************************************************************** -lsa_reply_lookup_names3. + _lsa_LookupNames3 ***************************************************************************/ -NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOOKUP_NAMES3 *r_u) +NTSTATUS _lsa_LookupNames3(pipes_struct *p, + struct lsa_LookupNames3 *r) { + NTSTATUS status; struct lsa_info *handle; - UNISTR2 *names = q_u->uni_name; - uint32 num_entries = q_u->num_entries; - DOM_R_REF *ref = NULL; - LSA_TRANSLATED_SID3 *trans_sids = NULL; + struct lsa_String *names = r->in.names; + uint32 num_entries = r->in.num_names; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TranslatedSid3 *trans_sids = NULL; uint32 mapped_count = 0; int flags = 0; + bool check_policy = true; + + switch (p->hdr_req.opnum) { + case NDR_LSA_LOOKUPNAMES4: + check_policy = false; + break; + case NDR_LSA_LOOKUPNAMES3: + default: + check_policy = true; + } if (num_entries > MAX_LOOKUP_SIDS) { num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names3: truncating name lookup list to %d\n", num_entries)); + DEBUG(5,("_lsa_LookupNames3: truncating name lookup list to %d\n", num_entries)); } /* Probably the lookup_level is some sort of bitmask. */ - if (q_u->lookup_level == 1) { + if (r->in.level == 1) { flags = LOOKUP_NAME_ALL; } - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (ref == NULL) { + domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList); + if (!domains) { return NT_STATUS_NO_MEMORY; } + if (num_entries) { - trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); + trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid3, + num_entries); if (!trans_sids) { return NT_STATUS_NO_MEMORY; } @@ -1273,59 +1282,52 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO trans_sids = NULL; } - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - r_u->status = NT_STATUS_INVALID_HANDLE; - goto done; - } + if (check_policy) { - /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { - r_u->status = NT_STATUS_ACCESS_DENIED; - goto done; + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) { + status = NT_STATUS_INVALID_HANDLE; + goto done; + } + + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + status = NT_STATUS_ACCESS_DENIED; + goto done; + } } /* set up the LSA Lookup SIDs response */ become_root(); /* lookup_name can require root privs */ - r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries, - names, flags, &mapped_count); + status = lookup_lsa_sids(p->mem_ctx, domains, trans_sids, num_entries, + names, flags, &mapped_count); unbecome_root(); done: - if (NT_STATUS_IS_OK(r_u->status)) { + if (NT_STATUS_IS_OK(status)) { if (mapped_count == 0) { - r_u->status = NT_STATUS_NONE_MAPPED; + status = NT_STATUS_NONE_MAPPED; } else if (mapped_count != num_entries) { - r_u->status = STATUS_SOME_UNMAPPED; + status = STATUS_SOME_UNMAPPED; } } - init_reply_lookup_names3(r_u, ref, num_entries, trans_sids, mapped_count); - return r_u->status; + *r->out.count = num_entries; + *r->out.domains = domains; + r->out.sids->sids = trans_sids; + r->out.sids->count = mapped_count; + + return status; } /*************************************************************************** -lsa_reply_lookup_names4. + _lsa_LookupNames4 ***************************************************************************/ -NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u) +NTSTATUS _lsa_LookupNames4(pipes_struct *p, + struct lsa_LookupNames4 *r) { - UNISTR2 *names = q_u->uni_name; - uint32 num_entries = q_u->num_entries; - DOM_R_REF *ref = NULL; - LSA_TRANSLATED_SID3 *trans_sids = NULL; - uint32 mapped_count = 0; - int flags = 0; - - if (num_entries > MAX_LOOKUP_SIDS) { - num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries)); - } - - /* Probably the lookup_level is some sort of bitmask. */ - if (q_u->lookup_level == 1) { - flags = LOOKUP_NAME_ALL; - } + struct lsa_LookupNames3 q; /* No policy handle on this call. Restrict to crypto connections. */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { @@ -1334,36 +1336,20 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO return NT_STATUS_INVALID_PARAMETER; } - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (!ref) { - return NT_STATUS_NO_MEMORY; - } - - if (num_entries) { - trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); - if (!trans_sids) { - return NT_STATUS_NO_MEMORY; - } - } else { - trans_sids = NULL; - } - - /* set up the LSA Lookup SIDs response */ - become_root(); /* lookup_name can require root privs */ - r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries, - names, flags, &mapped_count); - unbecome_root(); + q.in.handle = NULL; + q.in.num_names = r->in.num_names; + q.in.names = r->in.names; + q.in.level = r->in.level; + q.in.unknown1 = r->in.unknown1; + q.in.unknown2 = r->in.unknown2; + q.in.sids = r->in.sids; + q.in.count = r->in.count; - if (NT_STATUS_IS_OK(r_u->status)) { - if (mapped_count == 0) { - r_u->status = NT_STATUS_NONE_MAPPED; - } else if (mapped_count != num_entries) { - r_u->status = STATUS_SOME_UNMAPPED; - } - } + q.out.domains = r->out.domains; + q.out.sids = r->out.sids; + q.out.count = r->out.count; - init_reply_lookup_names4(r_u, ref, num_entries, trans_sids, mapped_count); - return r_u->status; + return _lsa_LookupNames3(p, &q); } /*************************************************************************** @@ -2522,12 +2508,6 @@ NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p, struct lsa_CREDRPROFILELOADED return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct lsa_LookupNames3 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p, struct lsa_CREDRGETSESSIONTYPES *r) { p->rng_fault_state = True; @@ -2576,12 +2556,6 @@ NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames4(pipes_struct *p, struct lsa_LookupNames4 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r) { p->rng_fault_state = True; -- cgit From 196d84ad6814ca2d4ffd9a51a5ac0bcd608c7445 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 17:04:50 +0100 Subject: Remove unused marshalling for LSA_LOOKUP_NAMES/2/3/4 Guenther (This used to be commit 6458ef3977b60f24b87eb88cf870a9f23929ca85) --- source3/include/rpc_lsa.h | 141 ---------- source3/rpc_parse/parse_lsa.c | 578 ---------------------------------------- source3/rpc_server/srv_lsa_nt.c | 76 ------ 3 files changed, 795 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index dde014a4cc..a92fca817d 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -305,145 +305,4 @@ typedef struct lsa_r_lookup_sids3 } LSA_R_LOOKUP_SIDS3; -/* LSA_Q_LOOKUP_NAMES - LSA Lookup NAMEs */ -typedef struct lsa_q_lookup_names -{ - POLICY_HND pol; /* policy handle */ - uint32 num_entries; - uint32 num_entries2; - UNIHDR *hdr_name; /* name buffer pointers */ - UNISTR2 *uni_name; /* names to be looked up */ - - uint32 num_trans_entries; - uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */ - uint16 lookup_level; - uint32 mapped_count; - -} LSA_Q_LOOKUP_NAMES; - -/* LSA_R_LOOKUP_NAMES - response to LSA Lookup NAMEs by name */ -typedef struct lsa_r_lookup_names -{ - uint32 ptr_dom_ref; - DOM_R_REF *dom_ref; /* domain reference info */ - - uint32 num_entries; - uint32 ptr_entries; - uint32 num_entries2; - DOM_RID *dom_rid; /* domain RIDs being looked up */ - - uint32 mapped_count; - - NTSTATUS status; /* return code */ -} LSA_R_LOOKUP_NAMES; - -/* LSA_Q_LOOKUP_NAMES2 - LSA Lookup NAMEs 2*/ -typedef struct lsa_q_lookup_names2 -{ - POLICY_HND pol; /* policy handle */ - uint32 num_entries; - uint32 num_entries2; - UNIHDR *hdr_name; /* name buffer pointers */ - UNISTR2 *uni_name; /* names to be looked up */ - - uint32 num_trans_entries; - uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */ - uint16 lookup_level; - uint32 mapped_count; - uint32 unknown1; - uint32 unknown2; - -} LSA_Q_LOOKUP_NAMES2; - -/* LSA_R_LOOKUP_NAMES2 - response to LSA Lookup NAMEs by name 2 */ -typedef struct lsa_r_lookup_names2 -{ - uint32 ptr_dom_ref; - DOM_R_REF *dom_ref; /* domain reference info */ - - uint32 num_entries; - uint32 ptr_entries; - uint32 num_entries2; - DOM_RID2 *dom_rid; /* domain RIDs being looked up */ - - uint32 mapped_count; - - NTSTATUS status; /* return code */ -} LSA_R_LOOKUP_NAMES2; - -/* LSA_Q_LOOKUP_NAMES3 - LSA Lookup NAMEs 3 */ -typedef struct lsa_q_lookup_names3 -{ - POLICY_HND pol; /* policy handle */ - uint32 num_entries; - uint32 num_entries2; - UNIHDR *hdr_name; /* name buffer pointers */ - UNISTR2 *uni_name; /* names to be looked up */ - - uint32 num_trans_entries; - uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */ - uint16 lookup_level; - uint32 mapped_count; - uint32 unknown1; - uint32 unknown2; - -} LSA_Q_LOOKUP_NAMES3; - -/* Sid type used in lookupnames3 and lookupnames4. */ -typedef struct lsa_translatedsid3 { - uint8 sid_type; - DOM_SID2 *sid2; - uint32 sid_idx; - uint32 unknown; -} LSA_TRANSLATED_SID3; - -/* LSA_R_LOOKUP_NAMES3 - response to LSA Lookup NAMEs by name 3 */ -typedef struct lsa_r_lookup_names3 -{ - uint32 ptr_dom_ref; - DOM_R_REF *dom_ref; /* domain reference info */ - - uint32 num_entries; - uint32 ptr_entries; - uint32 num_entries2; - LSA_TRANSLATED_SID3 *trans_sids; - - uint32 mapped_count; - - NTSTATUS status; /* return code */ -} LSA_R_LOOKUP_NAMES3; - -/* LSA_Q_LOOKUP_NAMES4 - LSA Lookup NAMEs 4 */ -typedef struct lsa_q_lookup_names4 -{ - uint32 num_entries; - uint32 num_entries2; - UNIHDR *hdr_name; /* name buffer pointers */ - UNISTR2 *uni_name; /* names to be looked up */ - - uint32 num_trans_entries; - uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */ - uint16 lookup_level; - uint32 mapped_count; - uint32 unknown1; - uint32 unknown2; - -} LSA_Q_LOOKUP_NAMES4; - -/* LSA_R_LOOKUP_NAMES3 - response to LSA Lookup NAMEs by name 4 */ -typedef struct lsa_r_lookup_names4 -{ - uint32 ptr_dom_ref; - DOM_R_REF *dom_ref; /* domain reference info */ - - uint32 num_entries; - uint32 ptr_entries; - uint32 num_entries2; - LSA_TRANSLATED_SID3 *trans_sids; - - uint32 mapped_count; - - NTSTATUS status; /* return code */ -} LSA_R_LOOKUP_NAMES4; - #endif /* _RPC_LSA_H */ diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index 3d65b9ca3b..81b6fc9e13 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -628,581 +628,3 @@ bool lsa_io_r_lookup_sids3(const char *desc, LSA_R_LOOKUP_SIDS3 *r_s, return True; } - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l, - POLICY_HND *hnd, int num_names, const char **names, - int level) -{ - unsigned int i; - - DEBUG(5, ("init_q_lookup_names\n")); - - ZERO_STRUCTP(q_l); - - q_l->pol = *hnd; - q_l->num_entries = num_names; - q_l->num_entries2 = num_names; - q_l->lookup_level = level; - - if (num_names) { - if ((q_l->uni_name = TALLOC_ZERO_ARRAY(mem_ctx, UNISTR2, num_names)) == NULL) { - DEBUG(3, ("init_q_lookup_names(): out of memory\n")); - return; - } - - if ((q_l->hdr_name = TALLOC_ZERO_ARRAY(mem_ctx, UNIHDR, num_names)) == NULL) { - DEBUG(3, ("init_q_lookup_names(): out of memory\n")); - return; - } - } else { - q_l->uni_name = NULL; - q_l->hdr_name = NULL; - } - - for (i = 0; i < num_names; i++) { - init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE); - init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]); - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -bool lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r, - prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_q_lookup_names"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */ - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries)) - return False; - if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2)) - return False; - - if (UNMARSHALLING(ps)) { - if (q_r->num_entries) { - if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL) - return False; - if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL) - return False; - } - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */ - return False; - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */ - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries)) - return False; - if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids)) - return False; - if(!prs_uint16("lookup_level ", ps, depth, &q_r->lookup_level)) - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -bool lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *out, prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_r_lookup_names"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref)) - return False; - - if (out->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth)) - return False; - - if(!prs_uint32("num_entries", ps, depth, &out->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries)) - return False; - - if (out->ptr_entries != 0) { - if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2)) - return False; - - if (out->num_entries2 != out->num_entries) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps) && out->num_entries2) { - if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID, out->num_entries2)) - == NULL) { - DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n")); - return False; - } - } - - for (i = 0; i < out->num_entries2; i++) - if(!smb_io_dom_rid("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */ - return False; - } - - if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &out->status)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -bool lsa_io_q_lookup_names2(const char *desc, LSA_Q_LOOKUP_NAMES2 *q_r, - prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_q_lookup_names2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */ - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries)) - return False; - if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2)) - return False; - - if (UNMARSHALLING(ps)) { - if (q_r->num_entries) { - if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL) - return False; - if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL) - return False; - } - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */ - return False; - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */ - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries)) - return False; - if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids)) - return False; - if(!prs_uint16("lookup_level ", ps, depth, &q_r->lookup_level)) - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count)) - return False; - if(!prs_uint32("unknown1 ", ps, depth, &q_r->unknown1)) - return False; - if(!prs_uint32("unknown2 ", ps, depth, &q_r->unknown2)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -bool lsa_io_r_lookup_names2(const char *desc, LSA_R_LOOKUP_NAMES2 *out, prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_r_lookup_names2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref)) - return False; - - if (out->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth)) - return False; - - if(!prs_uint32("num_entries", ps, depth, &out->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries)) - return False; - - if (out->ptr_entries != 0) { - if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2)) - return False; - - if (out->num_entries2 != out->num_entries) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps) && out->num_entries2) { - if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, out->num_entries2)) - == NULL) { - DEBUG(3, ("lsa_io_r_lookup_names2(): out of memory\n")); - return False; - } - } - - for (i = 0; i < out->num_entries2; i++) - if(!smb_io_dom_rid2("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */ - return False; - } - - if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &out->status)) - return False; - - return True; -} - -/******************************************************************* - Internal lsa data type io. - Following pass must read DOM_SID2 types. -********************************************************************/ - -bool smb_io_lsa_translated_sids3(const char *desc, LSA_TRANSLATED_SID3 *q_r, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_lsa_translated_sids3"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint8 ("sid_type ", ps, depth, &q_r->sid_type )) - return False; - if(!prs_align(ps)) - return False; - /* Second pass will read/write these. */ - if (!smb_io_dom_sid2_p("sid_header", ps, depth, &q_r->sid2)) - return False; - if(!prs_uint32("sid_idx ", ps, depth, &q_r->sid_idx )) - return False; - if(!prs_uint32("unknown ", ps, depth, &q_r->unknown )) - return False; - - return True; -} - -/******************************************************************* - Identical to lsa_io_q_lookup_names2. -********************************************************************/ - -bool lsa_io_q_lookup_names3(const char *desc, LSA_Q_LOOKUP_NAMES3 *q_r, - prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_q_lookup_names3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */ - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries)) - return False; - if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2)) - return False; - - if (UNMARSHALLING(ps)) { - if (q_r->num_entries) { - if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL) - return False; - if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL) - return False; - } - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */ - return False; - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */ - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries)) - return False; - if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids)) - return False; - if(!prs_uint16("lookup_level ", ps, depth, &q_r->lookup_level)) - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count)) - return False; - if(!prs_uint32("unknown1 ", ps, depth, &q_r->unknown1)) - return False; - if(!prs_uint32("unknown2 ", ps, depth, &q_r->unknown2)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -bool lsa_io_r_lookup_names3(const char *desc, LSA_R_LOOKUP_NAMES3 *out, prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_r_lookup_names3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref)) - return False; - - if (out->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth)) - return False; - - if(!prs_uint32("num_entries", ps, depth, &out->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries)) - return False; - - if (out->ptr_entries != 0) { - if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2)) - return False; - - if (out->num_entries2 != out->num_entries) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps) && out->num_entries2) { - if ((out->trans_sids = PRS_ALLOC_MEM(ps, LSA_TRANSLATED_SID3, out->num_entries2)) - == NULL) { - DEBUG(3, ("lsa_io_r_lookup_names3(): out of memory\n")); - return False; - } - } - - for (i = 0; i < out->num_entries2; i++) { - if(!smb_io_lsa_translated_sids3("", &out->trans_sids[i], ps, depth)) { - return False; - } - } - /* Now process the DOM_SID2 entries. */ - for (i = 0; i < out->num_entries2; i++) { - if (out->trans_sids[i].sid2) { - if( !smb_io_dom_sid2("sid2", out->trans_sids[i].sid2, ps, depth) ) { - return False; - } - } - } - } - - if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &out->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool lsa_io_q_lookup_names4(const char *desc, LSA_Q_LOOKUP_NAMES4 *q_r, - prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_q_lookup_names4"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries)) - return False; - if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2)) - return False; - - if (UNMARSHALLING(ps)) { - if (q_r->num_entries) { - if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL) - return False; - if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL) - return False; - } - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */ - return False; - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */ - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries)) - return False; - if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids)) - return False; - if(!prs_uint16("lookup_level ", ps, depth, &q_r->lookup_level)) - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count)) - return False; - if(!prs_uint32("unknown1 ", ps, depth, &q_r->unknown1)) - return False; - if(!prs_uint32("unknown2 ", ps, depth, &q_r->unknown2)) - return False; - - return True; -} - -/******************************************************************* - Identical to lsa_io_r_lookup_names3. -********************************************************************/ - -bool lsa_io_r_lookup_names4(const char *desc, LSA_R_LOOKUP_NAMES4 *out, prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_r_lookup_names4"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref)) - return False; - - if (out->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth)) - return False; - - if(!prs_uint32("num_entries", ps, depth, &out->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries)) - return False; - - if (out->ptr_entries != 0) { - if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2)) - return False; - - if (out->num_entries2 != out->num_entries) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps) && out->num_entries2) { - if ((out->trans_sids = PRS_ALLOC_MEM(ps, LSA_TRANSLATED_SID3, out->num_entries2)) - == NULL) { - DEBUG(3, ("lsa_io_r_lookup_names4(): out of memory\n")); - return False; - } - } - - for (i = 0; i < out->num_entries2; i++) { - if(!smb_io_lsa_translated_sids3("", &out->trans_sids[i], ps, depth)) { - return False; - } - } - /* Now process the DOM_SID2 entries. */ - for (i = 0; i < out->num_entries2; i++) { - if (out->trans_sids[i].sid2) { - if( !smb_io_dom_sid2("sid2", out->trans_sids[i].sid2, ps, depth) ) { - return False; - } - } - } - } - - if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &out->status)) - return False; - - return True; -} diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 5a3ed28e88..73238a5f6f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -316,82 +316,6 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -/*************************************************************************** - init_reply_lookup_names - ***************************************************************************/ - -static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, - DOM_R_REF *ref, uint32 num_entries, - DOM_RID *rid, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->dom_rid = rid; - - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - init_reply_lookup_names2 - ***************************************************************************/ - -static void init_reply_lookup_names2(LSA_R_LOOKUP_NAMES2 *r_l, - DOM_R_REF *ref, uint32 num_entries, - DOM_RID2 *rid, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->dom_rid = rid; - - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - init_reply_lookup_names3 - ***************************************************************************/ - -static void init_reply_lookup_names3(LSA_R_LOOKUP_NAMES3 *r_l, - DOM_R_REF *ref, uint32 num_entries, - LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->trans_sids = trans_sids; - - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - init_reply_lookup_names4 - ***************************************************************************/ - -static void init_reply_lookup_names4(LSA_R_LOOKUP_NAMES4 *r_l, - DOM_R_REF *ref, uint32 num_entries, - LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->trans_sids = trans_sids; - - r_l->mapped_count = mapped_count; -} - /*************************************************************************** Init_reply_lookup_sids. ***************************************************************************/ -- cgit From 5f215d2d94d76b0d0d1eb3b7e542fe8de933aacb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 15:51:21 +0100 Subject: Create missing link for libnetapi.so.0 Michael (This used to be commit 1cb2d980d3b2759d73314b112c904f5e20052135) --- source3/Makefile.in | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index e380ad2028..c948bb8131 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1514,6 +1514,7 @@ $(LIBNETAPI_SHARED_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBTDB_SHARED@ @ @$(SHLD_DSO) $(LIBNETAPI_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) + @ln -s -f `basename $@` $@.$(SONAME_VER) $(LIBNETAPI_STATIC_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ1) @echo Linking non-shared library $@ -- cgit From 1638941ba296fff1a5b22ed34dbe6eb7e0dbb4b2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 16:58:24 +0100 Subject: Fix a comment typo. Michael (This used to be commit 00e2dd36b38fcf92d76a0e79860cf9ca6a3d027e) --- source3/services/services_db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/services/services_db.c b/source3/services/services_db.c index d4e144d5ff..37440a299f 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -469,7 +469,7 @@ void svcctl_init_keys( void ) fetch_reg_keys( key, subkeys ); - /* the builting services exist */ + /* the builtin services exist */ for ( i=0; builtin_svcs[i].servicename; i++ ) add_new_svc_name( key, subkeys, builtin_svcs[i].servicename ); -- cgit From 5cd707f82c238633df9f89ea45d71e2a92b48161 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 17:23:41 +0100 Subject: Add a check for success of fetch_reg_values(). Michael (This used to be commit ba69097f37086537e6b2606fceeb874f6d3e4e1c) --- source3/services/services_db.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/services/services_db.c b/source3/services/services_db.c index 37440a299f..89095c628d 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -531,7 +531,11 @@ SEC_DESC *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN * return NULL; } - fetch_reg_values( key, values ); + if (fetch_reg_values( key, values ) == -1) { + DEBUG(0, ("Error getting registry values\n")); + TALLOC_FREE(key); + return NULL; + } TALLOC_FREE(key); -- cgit From 8ba088516aa34505849ef0a8639687bec22c5750 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 17:38:19 +0100 Subject: Fix segfault in svcctl_get_secdesc(): prevent premature TALLOC_FREE. This crash was triggered by (e.g.) net rpc service status. This patch prevents premature freeing of memory and creates a common exit point to the function. Michael (This used to be commit f1fb9fd6f14fc53629871cbe4b8558ad5acc14f0) --- source3/services/services_db.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source3') diff --git a/source3/services/services_db.c b/source3/services/services_db.c index 89095c628d..ae83e72697 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -520,29 +520,21 @@ SEC_DESC *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN * if ( !W_ERROR_IS_OK(wresult) ) { DEBUG(0,("svcctl_get_secdesc: key lookup failed! [%s] (%s)\n", path, dos_errstr(wresult))); - SAFE_FREE(path); - return NULL; + goto done; } - SAFE_FREE(path); if ( !(values = TALLOC_ZERO_P( key, REGVAL_CTR )) ) { DEBUG(0,("svcctl_get_secdesc: talloc() failed!\n")); - TALLOC_FREE( key ); - return NULL; + goto done; } if (fetch_reg_values( key, values ) == -1) { DEBUG(0, ("Error getting registry values\n")); - TALLOC_FREE(key); - return NULL; + goto done; } - TALLOC_FREE(key); - if ( !(val = regval_ctr_getvalue( values, "Security" )) ) { - DEBUG(6,("svcctl_get_secdesc: constructing default secdesc for service [%s]\n", - name)); - return construct_service_sd( ctx ); + goto fallback_to_default_sd; } /* stream the service security descriptor */ @@ -550,10 +542,18 @@ SEC_DESC *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN * status = unmarshall_sec_desc(ctx, regval_data_p(val), regval_size(val), &ret_sd); - if (!NT_STATUS_IS_OK(status)) { - return construct_service_sd( ctx ); + if (NT_STATUS_IS_OK(status)) { + goto done; } +fallback_to_default_sd: + DEBUG(6, ("svcctl_get_secdesc: constructing default secdesc for " + "service [%s]\n", name)); + ret_sd = construct_service_sd(ctx); + +done: + SAFE_FREE(path); + TALLOC_FREE(key); return ret_sd; } -- cgit From d38e756feb33718ff252d65fccdf8e4c7fe8ab4a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 15:51:56 +0100 Subject: Use BUILTIN\administrators as owner of the default registry key security descriptor. Michael (This used to be commit 52e98157650d8dbc9b3ebb55f995ca543839543b) --- source3/registry/reg_dispatcher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/registry/reg_dispatcher.c b/source3/registry/reg_dispatcher.c index e6e7613457..93b36f9289 100644 --- a/source3/registry/reg_dispatcher.c +++ b/source3/registry/reg_dispatcher.c @@ -63,7 +63,7 @@ static SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx ) if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) return NULL; - if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) + if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, &global_sid_Builtin_Administrators, NULL, NULL, acl, &sd_size)) ) return NULL; return sd; -- cgit From e16f039f26c88b8c602dc0d5e8a836688f7464d2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 14:44:51 +0100 Subject: Reformat construct_registry_sd() slightly (stick to coding rules). Michael (This used to be commit d87fb13959f84dfbbd3e1cc875f78d6e8ad44130) --- source3/registry/reg_dispatcher.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/registry/reg_dispatcher.c b/source3/registry/reg_dispatcher.c index 93b36f9289..f3fe5de98c 100644 --- a/source3/registry/reg_dispatcher.c +++ b/source3/registry/reg_dispatcher.c @@ -34,7 +34,7 @@ static const struct generic_mapping reg_generic_map = /******************************************************************** ********************************************************************/ -static SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx ) +static SEC_DESC* construct_registry_sd(TALLOC_CTX *ctx) { SEC_ACE ace[3]; SEC_ACCESS mask; @@ -45,26 +45,35 @@ static SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx ) /* basic access for Everyone */ - init_sec_access(&mask, REG_KEY_READ ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_access(&mask, REG_KEY_READ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, 0); /* Full Access 'BUILTIN\Administrators' */ - init_sec_access(&mask, REG_KEY_ALL ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_access(&mask, REG_KEY_ALL); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, + SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /* Full Access 'NT Authority\System' */ init_sec_access(&mask, REG_KEY_ALL ); - init_sec_ace(&ace[i++], &global_sid_System, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_System, SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, 0); /* create the security descriptor */ - if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) + acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace); + if (acl == NULL) { return NULL; + } - if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, &global_sid_Builtin_Administrators, NULL, NULL, acl, &sd_size)) ) + sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, + &global_sid_Builtin_Administrators, NULL, NULL, acl, + &sd_size); + if (sd == NULL) { return NULL; + } return sd; } -- cgit From 59e7ee6d7db618432ab22e023ddc1cf03bb34da8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 14:55:48 +0100 Subject: Change construct_registry_sd() to return WERROR instead of the SEC_DESC *. Michael (This used to be commit 91dbe79df2636959381825af6ab8a66abd7f97a1) --- source3/registry/reg_dispatcher.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source3') diff --git a/source3/registry/reg_dispatcher.c b/source3/registry/reg_dispatcher.c index f3fe5de98c..778a844883 100644 --- a/source3/registry/reg_dispatcher.c +++ b/source3/registry/reg_dispatcher.c @@ -34,7 +34,7 @@ static const struct generic_mapping reg_generic_map = /******************************************************************** ********************************************************************/ -static SEC_DESC* construct_registry_sd(TALLOC_CTX *ctx) +static WERROR construct_registry_sd(TALLOC_CTX *ctx, SEC_DESC **psd) { SEC_ACE ace[3]; SEC_ACCESS mask; @@ -65,17 +65,18 @@ static SEC_DESC* construct_registry_sd(TALLOC_CTX *ctx) acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace); if (acl == NULL) { - return NULL; + return WERR_NOMEM; } sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, &global_sid_Builtin_Administrators, NULL, NULL, acl, &sd_size); if (sd == NULL) { - return NULL; + return WERR_NOMEM; } - return sd; + *psd = sd; + return WERR_OK; } /*********************************************************************** @@ -185,19 +186,19 @@ WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, REGISTRY_KEY *key, struct security_descriptor **psecdesc) { struct security_descriptor *secdesc; + WERROR werr; if (key->hook && key->hook->ops && key->hook->ops->get_secdesc) { - WERROR err; - - err = key->hook->ops->get_secdesc(mem_ctx, key->name, - psecdesc); - if (W_ERROR_IS_OK(err)) { + werr = key->hook->ops->get_secdesc(mem_ctx, key->name, + psecdesc); + if (W_ERROR_IS_OK(werr)) { return WERR_OK; } } - if (!(secdesc = construct_registry_sd(mem_ctx))) { - return WERR_NOMEM; + werr = construct_registry_sd(mem_ctx, &secdesc); + if (!W_ERROR_IS_OK(werr)) { + return werr; } *psecdesc = secdesc; -- cgit From f3694d50a37c60897849a49946128228a259207e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 16:03:16 +0100 Subject: Add NT Authority\System as group sid to default registry key security descriptor. Michael (This used to be commit 9f0448ca323a6645ad662c97d92a7e30320e0c11) --- source3/registry/reg_dispatcher.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/registry/reg_dispatcher.c b/source3/registry/reg_dispatcher.c index 778a844883..cdcd045904 100644 --- a/source3/registry/reg_dispatcher.c +++ b/source3/registry/reg_dispatcher.c @@ -69,7 +69,8 @@ static WERROR construct_registry_sd(TALLOC_CTX *ctx, SEC_DESC **psd) } sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, - &global_sid_Builtin_Administrators, NULL, NULL, acl, + &global_sid_Builtin_Administrators, + &global_sid_System, NULL, acl, &sd_size); if (sd == NULL) { return WERR_NOMEM; -- cgit From 7ba906634bc89a0a9180687402ecb52ccb5f13c4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 16:33:47 +0100 Subject: Grab secdesc for key from registry for reg_savekey() instead of construction another default secdesc. Michael (This used to be commit 194e00822c349aa0c11641672b35b0e0c021da08) --- source3/registry/reg_api.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source3') diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index aba5735a0c..25cf101aaf 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -835,7 +835,7 @@ WERROR reg_restorekey(struct registry_key *key, const char *fname) ********************************************************************/ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath, - REGF_NK_REC *parent, SEC_DESC *sec_desc) + REGF_NK_REC *parent) { REGF_NK_REC *key; REGVAL_CTR *values; @@ -847,6 +847,7 @@ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath, char *subkeyname; REGISTRY_KEY registry_key; WERROR result = WERR_OK; + SEC_DESC *sec_desc = NULL; if (!regfile) { return WERR_GENERAL_FAILURE; @@ -899,6 +900,11 @@ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath, fetch_reg_keys(®istry_key, subkeys); fetch_reg_values(®istry_key, values); + result = regkey_get_secdesc(regfile->mem_ctx, ®istry_key, &sec_desc); + if (!W_ERROR_IS_OK(result)) { + goto done; + } + /* write out this key */ key = regfio_write_key(regfile, keyname, values, subkeys, sec_desc, @@ -919,7 +925,7 @@ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath, result = WERR_NOMEM; goto done; } - result = reg_write_tree(regfile, subkeypath, key, sec_desc); + result = reg_write_tree(regfile, subkeypath, key); if (!W_ERROR_IS_OK(result)) goto done; } @@ -985,7 +991,6 @@ static WERROR backup_registry_key(REGISTRY_KEY *krecord, const char *fname) { REGF_FILE *regfile; WERROR result; - SEC_DESC *sd = NULL; /* open the registry file....fail if the file already exists */ @@ -997,15 +1002,9 @@ static WERROR backup_registry_key(REGISTRY_KEY *krecord, const char *fname) return ntstatus_to_werror(map_nt_error_from_unix(errno)); } - result = make_default_reg_sd(regfile->mem_ctx, &sd); - if (!W_ERROR_IS_OK(result)) { - regfio_close(regfile); - return result; - } - /* write the registry tree to the file */ - result = reg_write_tree(regfile, krecord->name, NULL, sd); + result = reg_write_tree(regfile, krecord->name, NULL); /* cleanup */ -- cgit From bb0bf5c902c4fbf51efaeab8548fae215caf40e3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 16:34:39 +0100 Subject: Remove (now) unused function make_default_reg_sd(). Michael (This used to be commit 2c66413de284fb4cb9dc7def0ee4eb07b986c9ca) --- source3/registry/reg_api.c | 48 ---------------------------------------------- 1 file changed, 48 deletions(-) (limited to 'source3') diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index 25cf101aaf..e52aaacb4d 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -939,54 +939,6 @@ done: return result; } -static const struct generic_mapping reg_generic_map = - { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; - -static WERROR make_default_reg_sd(TALLOC_CTX *ctx, SEC_DESC **psd) -{ - DOM_SID adm_sid, owner_sid; - SEC_ACE ace[2]; /* at most 2 entries */ - SEC_ACCESS mask; - SEC_ACL *psa = NULL; - size_t sd_size; - - /* set the owner to BUILTIN\Administrator */ - - sid_copy(&owner_sid, &global_sid_Builtin); - sid_append_rid(&owner_sid, DOMAIN_USER_RID_ADMIN ); - - - /* basic access for Everyone */ - - init_sec_access(&mask, reg_generic_map.generic_execute - | reg_generic_map.generic_read); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, - mask, 0); - - /* add Full Access 'BUILTIN\Administrators' */ - - init_sec_access(&mask, reg_generic_map.generic_all); - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* create the security descriptor */ - - psa = make_sec_acl(ctx, NT4_ACL_REVISION, 2, ace); - if (psa == NULL) { - return WERR_NOMEM; - } - - *psd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, - SEC_DESC_SELF_RELATIVE, &owner_sid, NULL, - NULL, psa, &sd_size); - if (*psd == NULL) { - return WERR_NOMEM; - } - - return WERR_OK; -} - static WERROR backup_registry_key(REGISTRY_KEY *krecord, const char *fname) { REGF_FILE *regfile; -- cgit From d31806dffe111dc78968ec32d5165a21e87ad508 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 17:48:19 +0100 Subject: Fix a comment. REGISTRY_KEY has vanished from srv_winreg_nt.c (It is reg_api time) Michael (This used to be commit d94998e46ba0faac3fa625e8292d452ad52b8e55) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 5d18419c75..7ff93e0b07 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -36,7 +36,7 @@ static void free_regkey(void *ptr) } /****************************************************************** - Find a registry key handle and return a REGISTRY_KEY + Find a registry key handle and return a struct registry_key * *****************************************************************/ static struct registry_key *find_regkey_by_hnd(pipes_struct *p, -- cgit From 2a501a0760a7f1377cf1acf6594f8ba7b6fa07f0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 01:01:15 +0100 Subject: Use pidl for _lsa_LookupSids, _lsa_LookupSids2 and _lsa_LookupSids3. Guenther (This used to be commit b1609801e4443a3efbc29873477ad335d0241be4) --- source3/rpc_client/init_lsa.c | 15 +++ source3/rpc_server/srv_lsa.c | 69 +----------- source3/rpc_server/srv_lsa_nt.c | 229 +++++++++++++++++++++------------------- 3 files changed, 136 insertions(+), 177 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/init_lsa.c b/source3/rpc_client/init_lsa.c index 43d0de501f..fce382ed1b 100644 --- a/source3/rpc_client/init_lsa.c +++ b/source3/rpc_client/init_lsa.c @@ -100,3 +100,18 @@ void init_lsa_translated_sid(struct lsa_TranslatedSid *r, r->sid_index = sid_index; } +/******************************************************************* + Inits a lsa_TranslatedName2 structure. +********************************************************************/ + +void init_lsa_translated_name2(struct lsa_TranslatedName2 *r, + enum lsa_SidType sid_type, + const char *name, + uint32_t sid_index, + uint32_t unknown) +{ + r->sid_type = sid_type; + init_lsa_String(&r->name, name); + r->sid_index = sid_index; + r->unknown = unknown; +} diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index c5c7ade1a4..3f292c2158 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -88,28 +88,7 @@ static bool api_lsa_query_info(pipes_struct *p) static bool api_lsa_lookup_sids(pipes_struct *p) { - LSA_Q_LOOKUP_SIDS q_u; - LSA_R_LOOKUP_SIDS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n")); - return False; - } - - r_u.status = _lsa_lookup_sids(p, &q_u, &r_u); - - if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS); } /*************************************************************************** @@ -330,28 +309,7 @@ static bool api_lsa_delete_object(pipes_struct *p) static bool api_lsa_lookup_sids2(pipes_struct *p) { - LSA_Q_LOOKUP_SIDS2 q_u; - LSA_R_LOOKUP_SIDS2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_sids2("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_sids2: failed to unmarshall LSA_Q_LOOKUP_SIDS2.\n")); - return False; - } - - r_u.status = _lsa_lookup_sids2(p, &q_u, &r_u); - - if(!lsa_io_r_lookup_sids2("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_sids2: Failed to marshall LSA_R_LOOKUP_SIDS2.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS2); } /*************************************************************************** @@ -360,28 +318,7 @@ static bool api_lsa_lookup_sids2(pipes_struct *p) static bool api_lsa_lookup_sids3(pipes_struct *p) { - LSA_Q_LOOKUP_SIDS3 q_u; - LSA_R_LOOKUP_SIDS3 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_sids3("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_sids3: failed to unmarshall LSA_Q_LOOKUP_SIDS3.\n")); - return False; - } - - r_u.status = _lsa_lookup_sids3(p, &q_u, &r_u); - - if(!lsa_io_r_lookup_sids3("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_sids3: Failed to marshall LSA_R_LOOKUP_SIDS3.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS3); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 73238a5f6f..a216eaa730 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -764,38 +764,40 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, ***************************************************************************/ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, - uint16 level, /* input */ - int num_sids, /* input */ - const DOM_SID2 *sid, /* input */ - DOM_R_REF **pp_ref, /* output */ - LSA_TRANS_NAME_ENUM2 *names, /* input/output */ - uint32 *pp_mapped_count) + TALLOC_CTX *mem_ctx, + uint16_t level, /* input */ + int num_sids, /* input */ + struct lsa_SidPtr *sid, /* input */ + struct lsa_RefDomainList **pp_ref, /* input/output */ + struct lsa_TranslatedName2 **pp_names,/* input/output */ + uint32_t *pp_mapped_count) /* input/output */ { NTSTATUS status; int i; const DOM_SID **sids = NULL; - DOM_R_REF *ref = NULL; + struct lsa_RefDomainList *ref = NULL; uint32 mapped_count = 0; struct lsa_dom_info *dom_infos = NULL; struct lsa_name_info *name_infos = NULL; + struct lsa_TranslatedName2 *names = NULL; *pp_mapped_count = 0; + *pp_names = NULL; *pp_ref = NULL; - ZERO_STRUCTP(names); if (num_sids == 0) { return NT_STATUS_OK; } sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids); - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + ref = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList); if (sids == NULL || ref == NULL) { return NT_STATUS_NO_MEMORY; } for (i=0; imem_ctx, num_sids, sids, level, @@ -805,9 +807,8 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, return status; } - names->name = TALLOC_ARRAY(p->mem_ctx, LSA_TRANS_NAME2, num_sids); - names->uni_name = TALLOC_ARRAY(p->mem_ctx, UNISTR2, num_sids); - if ((names->name == NULL) || (names->uni_name == NULL)) { + names = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedName2, num_sids); + if (names == NULL) { return NT_STATUS_NO_MEMORY; } @@ -817,8 +818,9 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, break; } - if (init_dom_ref(ref, dom_infos[i].name, - &dom_infos[i].sid) != i) { + if (init_lsa_ref_domain_list(mem_ctx, ref, + dom_infos[i].name, + &dom_infos[i].sid) != i) { DEBUG(0, ("Domain %s mentioned twice??\n", dom_infos[i].name)); return NT_STATUS_INTERNAL_ERROR; @@ -846,13 +848,10 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, } else { mapped_count += 1; } - init_lsa_trans_name2(&names->name[i], &names->uni_name[i], - name->type, name->name, name->dom_idx); - } - names->num_entries = num_sids; - names->ptr_trans_names = 1; - names->num_entries2 = num_sids; + init_lsa_translated_name2(&names[i], name->type, + name->name, name->dom_idx, 0); + } status = NT_STATUS_NONE_MAPPED; if (mapped_count > 0) { @@ -864,31 +863,33 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, num_sids, mapped_count, nt_errstr(status))); *pp_mapped_count = mapped_count; + *pp_names = names; *pp_ref = ref; return status; } /*************************************************************************** - _lsa_lookup_sids + _lsa_LookupSids ***************************************************************************/ -NTSTATUS _lsa_lookup_sids(pipes_struct *p, - LSA_Q_LOOKUP_SIDS *q_u, - LSA_R_LOOKUP_SIDS *r_u) +NTSTATUS _lsa_LookupSids(pipes_struct *p, + struct lsa_LookupSids *r) { + NTSTATUS status; struct lsa_info *handle; - int num_sids = q_u->sids.num_entries; + int num_sids = r->in.sids->num_sids; uint32 mapped_count = 0; - DOM_R_REF *ref = NULL; - LSA_TRANS_NAME_ENUM2 names; - NTSTATUS status; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TranslatedName *names_out = NULL; + struct lsa_TranslatedName2 *names = NULL; + int i; - if ((q_u->level < 1) || (q_u->level > 6)) { + if ((r->in.level < 1) || (r->in.level > 6)) { return NT_STATUS_INVALID_PARAMETER; } - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) { return NT_STATUS_INVALID_HANDLE; } @@ -898,113 +899,137 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, } if (num_sids > MAX_LOOKUP_SIDS) { - DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, requested %d\n", + DEBUG(5,("_lsa_LookupSids: limit of %d exceeded, requested %d\n", MAX_LOOKUP_SIDS, num_sids)); return NT_STATUS_NONE_MAPPED; } - r_u->status = _lsa_lookup_sids_internal(p, - q_u->level, - num_sids, - q_u->sids.sid, - &ref, - &names, - &mapped_count); + status = _lsa_lookup_sids_internal(p, + p->mem_ctx, + r->in.level, + num_sids, + r->in.sids->sids, + &domains, + &names, + &mapped_count); - /* Convert from LSA_TRANS_NAME_ENUM2 to LSA_TRANS_NAME_ENUM */ + /* Convert from lsa_TranslatedName2 to lsa_TranslatedName */ + names_out = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedName, + num_sids); + if (!names_out) { + return NT_STATUS_NO_MEMORY; + } - status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, &names, mapped_count); - if (!NT_STATUS_IS_OK(status)) { - return status; + for (i=0; istatus; + + *r->out.domains = domains; + r->out.names->count = num_sids; + r->out.names->names = names_out; + *r->out.count = mapped_count; + + return status; } /*************************************************************************** - _lsa_lookup_sids2 + _lsa_LookupSids2 ***************************************************************************/ -NTSTATUS _lsa_lookup_sids2(pipes_struct *p, - LSA_Q_LOOKUP_SIDS2 *q_u, - LSA_R_LOOKUP_SIDS2 *r_u) +NTSTATUS _lsa_LookupSids2(pipes_struct *p, + struct lsa_LookupSids2 *r) { + NTSTATUS status; struct lsa_info *handle; - int num_sids = q_u->sids.num_entries; + int num_sids = r->in.sids->num_sids; uint32 mapped_count = 0; - DOM_R_REF *ref = NULL; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TranslatedName2 *names = NULL; + bool check_policy = true; - if ((q_u->level < 1) || (q_u->level > 6)) { - return NT_STATUS_INVALID_PARAMETER; + switch (p->hdr_req.opnum) { + case NDR_LSA_LOOKUPSIDS3: + check_policy = false; + break; + case NDR_LSA_LOOKUPSIDS2: + default: + check_policy = true; } - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - return NT_STATUS_INVALID_HANDLE; + if ((r->in.level < 1) || (r->in.level > 6)) { + return NT_STATUS_INVALID_PARAMETER; } - /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { - return NT_STATUS_ACCESS_DENIED; + if (check_policy) { + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) { + return NT_STATUS_INVALID_HANDLE; + } + + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + return NT_STATUS_ACCESS_DENIED; + } } if (num_sids > MAX_LOOKUP_SIDS) { - DEBUG(5,("_lsa_lookup_sids2: limit of %d exceeded, requested %d\n", + DEBUG(5,("_lsa_LookupSids2: limit of %d exceeded, requested %d\n", MAX_LOOKUP_SIDS, num_sids)); return NT_STATUS_NONE_MAPPED; } - r_u->status = _lsa_lookup_sids_internal(p, - q_u->level, - num_sids, - q_u->sids.sid, - &ref, - &r_u->names, - &mapped_count); + status = _lsa_lookup_sids_internal(p, + p->mem_ctx, + r->in.level, + num_sids, + r->in.sids->sids, + &domains, + &names, + &mapped_count); - init_reply_lookup_sids2(r_u, ref, mapped_count); - return r_u->status; + *r->out.domains = domains; + r->out.names->count = num_sids; + r->out.names->names = names; + *r->out.count = mapped_count; + + return status; } /*************************************************************************** - _lsa_lookup_sida3 + _lsa_LookupSids3 ***************************************************************************/ -NTSTATUS _lsa_lookup_sids3(pipes_struct *p, - LSA_Q_LOOKUP_SIDS3 *q_u, - LSA_R_LOOKUP_SIDS3 *r_u) +NTSTATUS _lsa_LookupSids3(pipes_struct *p, + struct lsa_LookupSids3 *r) { - int num_sids = q_u->sids.num_entries; - uint32 mapped_count = 0; - DOM_R_REF *ref = NULL; - - if ((q_u->level < 1) || (q_u->level > 6)) { - return NT_STATUS_INVALID_PARAMETER; - } + struct lsa_LookupSids2 q; /* No policy handle on this call. Restrict to crypto connections. */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { - DEBUG(0,("_lsa_lookup_sids3: client %s not using schannel for netlogon\n", + DEBUG(0,("_lsa_LookupSids3: client %s not using schannel for netlogon\n", get_remote_machine_name() )); return NT_STATUS_INVALID_PARAMETER; } - if (num_sids > MAX_LOOKUP_SIDS) { - DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n", - MAX_LOOKUP_SIDS, num_sids)); - return NT_STATUS_NONE_MAPPED; - } + q.in.handle = NULL; + q.in.sids = r->in.sids; + q.in.level = r->in.level; + q.in.unknown1 = r->in.unknown1; + q.in.unknown2 = r->in.unknown2; + q.in.names = r->in.names; + q.in.count = r->in.count; - r_u->status = _lsa_lookup_sids_internal(p, - q_u->level, - num_sids, - q_u->sids.sid, - &ref, - &r_u->names, - &mapped_count); + q.out.domains = r->out.domains; + q.out.names = r->out.names; + q.out.count = r->out.count; - init_reply_lookup_sids3(r_u, ref, mapped_count); - return r_u->status; + return _lsa_LookupSids2(p, &q); } +/*************************************************************************** + ***************************************************************************/ + static int lsa_lookup_level_to_flags(uint16 level) { int flags; @@ -2228,12 +2253,6 @@ NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r) { p->rng_fault_state = True; @@ -2372,12 +2391,6 @@ NTSTATUS _lsa_TestCall(pipes_struct *p, struct lsa_TestCall *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r) { p->rng_fault_state = True; @@ -2474,12 +2487,6 @@ NTSTATUS _lsa_CREDRRENAME(pipes_struct *p, struct lsa_CREDRRENAME *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r) { p->rng_fault_state = True; -- cgit From 8db780ac8fc30df1e20e70d83a49365b74a10e0a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 01:16:00 +0100 Subject: Yippie! LSARPC server-side migration to pidl finished. Guenther (This used to be commit aa7023b88d3161897b9616d950c2a99624d81931) --- source3/Makefile.in | 2 +- source3/configure.in | 4 +- source3/rpc_server/srv_lsa.c | 463 ------------------------------------------ source3/rpc_server/srv_pipe.c | 2 +- 4 files changed, 4 insertions(+), 467 deletions(-) delete mode 100644 source3/rpc_server/srv_lsa.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index c948bb8131..9da2f580f3 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -485,7 +485,7 @@ REG_API_OBJ = registry/reg_api.o \ $(REGFIO_OBJ) -RPC_LSA_OBJ = rpc_server/srv_lsa.o rpc_server/srv_lsa_nt.o librpc/gen_ndr/srv_lsa.o +RPC_LSA_OBJ = rpc_server/srv_lsa_nt.o librpc/gen_ndr/srv_lsa.o RPC_NETLOG_OBJ = rpc_server/srv_netlog_nt.o \ librpc/gen_ndr/srv_netlogon.o diff --git a/source3/configure.in b/source3/configure.in index 16c9ed916b..f1bd2d28a5 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -745,7 +745,7 @@ AC_SUBST(DYNEXP) dnl Add modules that have to be built by default here dnl These have to be built static: -default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs2 rpc_netlogon rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template" +default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs2 rpc_netlogon rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template" dnl These are preferably build shared, and static if dlopen() is not available default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_syncops vfs_xattr_tdb vfs_streams_xattr" @@ -6609,7 +6609,7 @@ SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB) SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o) -SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC) +SMB_MODULE(rpc_lsarpc, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC) SMB_MODULE(rpc_winreg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC) SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC) SMB_MODULE(rpc_dssetup, \$(RPC_DSSETUP_OBJ), "bin/librpc_dssetup.$SHLIBEXT", RPC) diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c deleted file mode 100644 index 3f292c2158..0000000000 --- a/source3/rpc_server/srv_lsa.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2002-2003. - * Copyright (C) Gerald (Jerry) Carter 2005 - * - * 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 . - */ - -/* This is the interface to the lsa server code. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -static bool proxy_lsa_call(pipes_struct *p, uint8 opnum) -{ - struct api_struct *fns; - int n_fns; - - lsarpc_get_pipe_fns(&fns, &n_fns); - - if (opnum >= n_fns) - return False; - - if (fns[opnum].opnum != opnum) { - smb_panic("LSA function table not sorted"); - } - - return fns[opnum].fn(p); -} - -/*************************************************************************** - api_lsa_open_policy2 - ***************************************************************************/ - -static bool api_lsa_open_policy2(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENPOLICY2); -} - -/*************************************************************************** -api_lsa_open_policy - ***************************************************************************/ - -static bool api_lsa_open_policy(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENPOLICY); -} - -/*************************************************************************** - api_lsa_enum_trust_dom - ***************************************************************************/ - -static bool api_lsa_enum_trust_dom(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMTRUSTDOM); -} - -/*************************************************************************** - api_lsa_query_info - ***************************************************************************/ - -static bool api_lsa_query_info(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_QUERYINFOPOLICY); -} - -/*************************************************************************** - api_lsa_lookup_sids - ***************************************************************************/ - -static bool api_lsa_lookup_sids(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS); -} - -/*************************************************************************** - api_lsa_lookup_names - ***************************************************************************/ - -static bool api_lsa_lookup_names(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES); -} - -/*************************************************************************** - api_lsa_close. - ***************************************************************************/ - -static bool api_lsa_close(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_CLOSE); -} - -/*************************************************************************** - api_lsa_open_secret. - ***************************************************************************/ - -static bool api_lsa_open_secret(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENSECRET); -} - -/*************************************************************************** - api_lsa_open_secret. - ***************************************************************************/ - -static bool api_lsa_enum_privs(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMPRIVS); -} - -/*************************************************************************** - api_lsa_open_secret. - ***************************************************************************/ - -static bool api_lsa_priv_get_dispname(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPPRIVDISPLAYNAME); -} - -/*************************************************************************** - api_lsa_open_secret. - ***************************************************************************/ - -static bool api_lsa_enum_accounts(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMACCOUNTS); -} - -/*************************************************************************** - api_lsa_UNK_GET_CONNUSER - ***************************************************************************/ - -static bool api_lsa_unk_get_connuser(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_GETUSERNAME); -} - -/*************************************************************************** - api_lsa_create_user - ***************************************************************************/ - -static bool api_lsa_create_account(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_CREATEACCOUNT); -} - -/*************************************************************************** - api_lsa_open_user - ***************************************************************************/ - -static bool api_lsa_open_account(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENACCOUNT); -} - -/*************************************************************************** - api_lsa_get_privs - ***************************************************************************/ - -static bool api_lsa_enum_privsaccount(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMPRIVSACCOUNT); -} - -/*************************************************************************** - api_lsa_getsystemaccount - ***************************************************************************/ - -static bool api_lsa_getsystemaccount(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_GETSYSTEMACCESSACCOUNT); -} - - -/*************************************************************************** - api_lsa_setsystemaccount - ***************************************************************************/ - -static bool api_lsa_setsystemaccount(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_SETSYSTEMACCESSACCOUNT); -} - -/*************************************************************************** - api_lsa_addprivs - ***************************************************************************/ - -static bool api_lsa_addprivs(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ADDPRIVILEGESTOACCOUNT); -} - -/*************************************************************************** - api_lsa_removeprivs - ***************************************************************************/ - -static bool api_lsa_removeprivs(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_REMOVEPRIVILEGESFROMACCOUNT); -} - -/*************************************************************************** - api_lsa_query_secobj - ***************************************************************************/ - -static bool api_lsa_query_secobj(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_QUERYSECURITY); -} - -/*************************************************************************** - api_lsa_add_acct_rights - ***************************************************************************/ - -static bool api_lsa_add_acct_rights(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ADDACCOUNTRIGHTS); -} - -/*************************************************************************** - api_lsa_remove_acct_rights - ***************************************************************************/ - -static bool api_lsa_remove_acct_rights(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_REMOVEACCOUNTRIGHTS); -} - -/*************************************************************************** - api_lsa_enum_acct_rights - ***************************************************************************/ - -static bool api_lsa_enum_acct_rights(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMACCOUNTRIGHTS); -} - -/*************************************************************************** - api_lsa_lookup_priv_value - ***************************************************************************/ - -static bool api_lsa_lookup_priv_value(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPPRIVVALUE); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_open_trust_dom(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENTRUSTEDDOMAIN); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_create_trust_dom(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_CREATETRUSTEDDOMAIN); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_create_secret(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_CREATESECRET); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_set_secret(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_SETSECRET); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_delete_object(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_DELETEOBJECT); -} - -/*************************************************************************** - api_lsa_lookup_sids2 - ***************************************************************************/ - -static bool api_lsa_lookup_sids2(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS2); -} - -/*************************************************************************** - api_lsa_lookup_sids3 - ***************************************************************************/ - -static bool api_lsa_lookup_sids3(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS3); -} - -/*************************************************************************** - api_lsa_lookup_names2 - ***************************************************************************/ - -static bool api_lsa_lookup_names2(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES2); -} - -/*************************************************************************** - api_lsa_lookup_names3 - ***************************************************************************/ - -static bool api_lsa_lookup_names3(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES3); -} - -/*************************************************************************** - api_lsa_lookup_names4 - ***************************************************************************/ - -static bool api_lsa_lookup_names4(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES4); -} - -#if 0 /* AD DC work in ongoing in Samba 4 */ - -/*************************************************************************** - api_lsa_query_info2 - ***************************************************************************/ - -static bool api_lsa_query_info2(pipes_struct *p) -{ - LSA_Q_QUERY_INFO2 q_u; - LSA_R_QUERY_INFO2 r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_query_info2("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_query_info2: failed to unmarshall LSA_Q_QUERY_INFO2.\n")); - return False; - } - - r_u.status = _lsa_query_info2(p, &q_u, &r_u); - - if (!lsa_io_r_query_info2("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_query_info2: failed to marshall LSA_R_QUERY_INFO2.\n")); - return False; - } - - return True; -} -#endif /* AD DC work in ongoing in Samba 4 */ - -/*************************************************************************** - \PIPE\ntlsa commands - ***************************************************************************/ - -static struct api_struct api_lsa_cmds[] = -{ - { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, - { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, - { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info }, - { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom }, - { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close }, - { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, - { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, - { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, - { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs }, - { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname}, - { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts }, - { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser }, - { "LSA_CREATEACCOUNT" , LSA_CREATEACCOUNT , api_lsa_create_account }, - { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account }, - { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount}, - { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount }, - { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount }, - { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, - { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, - { "LSA_ADDACCTRIGHTS" , LSA_ADDACCTRIGHTS , api_lsa_add_acct_rights }, - { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights }, - { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights }, - { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, - { "LSA_LOOKUPPRIVVALUE" , LSA_LOOKUPPRIVVALUE , api_lsa_lookup_priv_value }, - { "LSA_OPENTRUSTDOM" , LSA_OPENTRUSTDOM , api_lsa_open_trust_dom }, - { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, - { "LSA_CREATETRUSTDOM" , LSA_CREATETRUSTDOM , api_lsa_create_trust_dom }, - { "LSA_CREATSECRET" , LSA_CREATESECRET , api_lsa_create_secret }, - { "LSA_SETSECRET" , LSA_SETSECRET , api_lsa_set_secret }, - { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object }, - { "LSA_LOOKUPSIDS2" , LSA_LOOKUPSIDS2 , api_lsa_lookup_sids2 }, - { "LSA_LOOKUPNAMES2" , LSA_LOOKUPNAMES2 , api_lsa_lookup_names2 }, - { "LSA_LOOKUPNAMES3" , LSA_LOOKUPNAMES3 , api_lsa_lookup_names3 }, - { "LSA_LOOKUPSIDS3" , LSA_LOOKUPSIDS3 , api_lsa_lookup_sids3 }, - { "LSA_LOOKUPNAMES4" , LSA_LOOKUPNAMES4 , api_lsa_lookup_names4 } -#if 0 /* AD DC work in ongoing in Samba 4 */ - /* be careful of the adding of new RPC's. See commentrs below about - ADS DC capabilities */ - { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } -#endif /* AD DC work in ongoing in Samba 4 */ -}; - -static int count_fns(void) -{ - int funcs = sizeof(api_lsa_cmds) / sizeof(struct api_struct); - -#if 0 /* AD DC work is on going in Samba 4 */ - /* - * NOTE: Certain calls can not be enabled if we aren't an ADS DC. Make sure - * these calls are always last and that you decrement by the amount of calls - * to disable. - */ - if (!(SEC_ADS == lp_security() && ROLE_DOMAIN_PDC == lp_server_role())) { - funcs -= 1; - } -#endif /* AD DC work in ongoing in Samba 4 */ - - return funcs; -} - -void lsa_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_lsa_cmds; - *n_fns = count_fns(); -} - - -NTSTATUS rpc_lsa_init(void) -{ - int funcs = count_fns(); - - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds, - funcs); -} diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a7a7f9a389..4d066a6b7a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2376,7 +2376,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) switch ( idx ) { case PI_LSARPC: - lsa_get_pipe_fns( &cmds, &n_cmds ); + lsarpc_get_pipe_fns( &cmds, &n_cmds ); break; case PI_DSSETUP: dssetup_get_pipe_fns( &cmds, &n_cmds ); -- cgit From d48f36819fe825de58f1e4feaab14a811ad53421 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 01:19:44 +0100 Subject: Remove unused marshalling for LSA_LOOKUP_SIDS/2/3. This also removes parse_lsa.c entirely. Guenther (This used to be commit f802ba035c95e63c5a6ff9f2fb484d62341cd1a7) --- source3/Makefile.in | 2 +- source3/include/rpc_lsa.h | 164 ----------- source3/rpc_parse/parse_lsa.c | 630 ---------------------------------------- source3/rpc_server/srv_lsa_nt.c | 101 ------- 4 files changed, 1 insertion(+), 896 deletions(-) delete mode 100644 source3/rpc_parse/parse_lsa.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 9da2f580f3..cebe49b510 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -529,7 +529,7 @@ RPC_ECHO_OBJ = rpc_server/srv_echo_nt.o librpc/gen_ndr/srv_echo.o RPC_SERVER_OBJ = @RPC_STATIC@ $(RPC_PIPE_OBJ) -RPC_PARSE_OBJ = rpc_parse/parse_lsa.o $(RPC_PARSE_OBJ2) \ +RPC_PARSE_OBJ = $(RPC_PARSE_OBJ2) \ rpc_parse/parse_spoolss.o \ rpc_parse/parse_eventlog.o rpc_parse/parse_buffer.o \ rpc_parse/parse_ntsvcs.o rpc_parse/parse_svcctl.o $(REGOBJS_OBJ) diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index a92fca817d..cdd21a7515 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -136,173 +136,9 @@ POLICY_LOOKUP_NAMES ) /*******************************************************/ - -/*******************************************************/ - #define MAX_REF_DOMAINS 32 -/* DOM_TRUST_HDR */ -typedef struct dom_trust_hdr -{ - UNIHDR hdr_dom_name; /* referenced domain unicode string headers */ - uint32 ptr_dom_sid; - -} DOM_TRUST_HDR; - -/* DOM_TRUST_INFO */ -typedef struct dom_trust_info -{ - UNISTR2 uni_dom_name; /* domain name unicode string */ - DOM_SID2 ref_dom ; /* referenced domain SID */ - -} DOM_TRUST_INFO; - -/* DOM_R_REF */ -typedef struct dom_ref_info -{ - uint32 num_ref_doms_1; /* num referenced domains */ - uint32 ptr_ref_dom; /* pointer to referenced domains */ - uint32 max_entries; /* 32 - max number of entries */ - uint32 num_ref_doms_2; /* num referenced domains */ - - DOM_TRUST_HDR hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domains */ - DOM_TRUST_INFO ref_dom [MAX_REF_DOMAINS]; /* referenced domains */ - -} DOM_R_REF; - -/* the domain_idx points to a SID associated with the name */ - -/* LSA_TRANS_NAME - translated name */ -typedef struct lsa_trans_name_info -{ - uint16 sid_name_use; /* value is 5 for a well-known group; 2 for a domain group; 1 for a user... */ - UNIHDR hdr_name; - uint32 domain_idx; /* index into DOM_R_REF array of SIDs */ - -} LSA_TRANS_NAME; - -/* LSA_TRANS_NAME2 - translated name */ -typedef struct lsa_trans_name_info2 -{ - uint16 sid_name_use; /* value is 5 for a well-known group; 2 for a domain group; 1 for a user... */ - UNIHDR hdr_name; - uint32 domain_idx; /* index into DOM_R_REF array of SIDs */ - uint32 unknown; - -} LSA_TRANS_NAME2; - /* This number is based on Win2k and later maximum response allowed */ #define MAX_LOOKUP_SIDS 20480 /* 0x5000 */ -/* LSA_TRANS_NAME_ENUM - LSA Translated Name Enumeration container */ -typedef struct lsa_trans_name_enum_info -{ - uint32 num_entries; - uint32 ptr_trans_names; - uint32 num_entries2; - - LSA_TRANS_NAME *name; /* translated names */ - UNISTR2 *uni_name; - -} LSA_TRANS_NAME_ENUM; - -/* LSA_TRANS_NAME_ENUM2 - LSA Translated Name Enumeration container 2 */ -typedef struct lsa_trans_name_enum_info2 -{ - uint32 num_entries; - uint32 ptr_trans_names; - uint32 num_entries2; - - LSA_TRANS_NAME2 *name; /* translated names */ - UNISTR2 *uni_name; - -} LSA_TRANS_NAME_ENUM2; - -/* LSA_SID_ENUM - LSA SID enumeration container */ -typedef struct lsa_sid_enum_info -{ - uint32 num_entries; - uint32 ptr_sid_enum; - uint32 num_entries2; - - uint32 *ptr_sid; /* domain SID pointers to be looked up. */ - DOM_SID2 *sid; /* domain SIDs to be looked up. */ - -} LSA_SID_ENUM; - -/* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */ -typedef struct lsa_q_lookup_sids -{ - POLICY_HND pol; /* policy handle */ - LSA_SID_ENUM sids; - LSA_TRANS_NAME_ENUM names; - uint16 level; - uint32 mapped_count; - -} LSA_Q_LOOKUP_SIDS; - -/* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */ -typedef struct lsa_r_lookup_sids -{ - uint32 ptr_dom_ref; - DOM_R_REF *dom_ref; /* domain reference info */ - - LSA_TRANS_NAME_ENUM names; - uint32 mapped_count; - - NTSTATUS status; /* return code */ - -} LSA_R_LOOKUP_SIDS; - -/* LSA_Q_LOOKUP_SIDS2 - LSA Lookup SIDs 2*/ -typedef struct lsa_q_lookup_sids2 -{ - POLICY_HND pol; /* policy handle */ - LSA_SID_ENUM sids; - LSA_TRANS_NAME_ENUM2 names; - uint16 level; - uint32 mapped_count; - uint32 unknown1; - uint32 unknown2; - -} LSA_Q_LOOKUP_SIDS2; - -/* LSA_R_LOOKUP_SIDS2 - response to LSA Lookup SIDs 2*/ -typedef struct lsa_r_lookup_sids2 -{ - uint32 ptr_dom_ref; - DOM_R_REF *dom_ref; /* domain reference info */ - - LSA_TRANS_NAME_ENUM2 names; - uint32 mapped_count; - - NTSTATUS status; /* return code */ - -} LSA_R_LOOKUP_SIDS2; - -/* LSA_Q_LOOKUP_SIDS3 - LSA Lookup SIDs 3 */ -typedef struct lsa_q_lookup_sids3 -{ - LSA_SID_ENUM sids; - LSA_TRANS_NAME_ENUM2 names; - uint16 level; - uint32 mapped_count; - uint32 unknown1; - uint32 unknown2; - -} LSA_Q_LOOKUP_SIDS3; - -/* LSA_R_LOOKUP_SIDS3 - response to LSA Lookup SIDs 3 */ -typedef struct lsa_r_lookup_sids3 -{ - uint32 ptr_dom_ref; - DOM_R_REF *dom_ref; /* domain reference info */ - - LSA_TRANS_NAME_ENUM2 names; - uint32 mapped_count; - - NTSTATUS status; /* return code */ - -} LSA_R_LOOKUP_SIDS3; - #endif /* _RPC_LSA_H */ diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c deleted file mode 100644 index 81b6fc9e13..0000000000 --- a/source3/rpc_parse/parse_lsa.c +++ /dev/null @@ -1,630 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Andrew Bartlett 2002, - * Copyright (C) Jim McDonough 2002. - * Copyright (C) Gerald )Jerry) Carter 2005 - * - * 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 "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE - -static bool lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth); -static bool lsa_io_trans_names2(const char *desc, LSA_TRANS_NAME_ENUM2 *trn, prs_struct *ps, int depth); - -/******************************************************************* - Inits a LSA_TRANS_NAME structure. -********************************************************************/ - -void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name, - uint16 sid_name_use, const char *name, uint32 idx) -{ - trn->sid_name_use = sid_name_use; - init_unistr2(uni_name, name, UNI_FLAGS_NONE); - init_uni_hdr(&trn->hdr_name, uni_name); - trn->domain_idx = idx; -} - -/******************************************************************* - Reads or writes a LSA_TRANS_NAME structure. -********************************************************************/ - -static bool lsa_io_trans_name(const char *desc, LSA_TRANS_NAME *trn, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_trans_name"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth)) - return False; - if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx)) - return False; - - return True; -} - -/******************************************************************* - Inits a LSA_TRANS_NAME2 structure. -********************************************************************/ - -void init_lsa_trans_name2(LSA_TRANS_NAME2 *trn, UNISTR2 *uni_name, - uint16 sid_name_use, const char *name, uint32 idx) -{ - trn->sid_name_use = sid_name_use; - init_unistr2(uni_name, name, UNI_FLAGS_NONE); - init_uni_hdr(&trn->hdr_name, uni_name); - trn->domain_idx = idx; - trn->unknown = 0; -} - -/******************************************************************* - Reads or writes a LSA_TRANS_NAME2 structure. -********************************************************************/ - -static bool lsa_io_trans_name2(const char *desc, LSA_TRANS_NAME2 *trn, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_trans_name2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth)) - return False; - if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx)) - return False; - if(!prs_uint32("unknown ", ps, depth, &trn->unknown)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a DOM_R_REF structure. -********************************************************************/ - -static bool lsa_io_dom_r_ref(const char *desc, DOM_R_REF *dom, prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_dom_r_ref"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_ref_doms_1", ps, depth, &dom->num_ref_doms_1)) /* num referenced domains? */ - return False; - if(!prs_uint32("ptr_ref_dom ", ps, depth, &dom->ptr_ref_dom)) /* undocumented buffer pointer. */ - return False; - if(!prs_uint32("max_entries ", ps, depth, &dom->max_entries)) /* 32 - max number of entries */ - return False; - - SMB_ASSERT_ARRAY(dom->hdr_ref_dom, dom->num_ref_doms_1); - - if (dom->ptr_ref_dom != 0) { - - if(!prs_uint32("num_ref_doms_2", ps, depth, &dom->num_ref_doms_2)) /* 4 - num referenced domains? */ - return False; - - SMB_ASSERT_ARRAY(dom->ref_dom, dom->num_ref_doms_2); - - for (i = 0; i < dom->num_ref_doms_1; i++) { - fstring t; - - slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i); - if(!smb_io_unihdr(t, &dom->hdr_ref_dom[i].hdr_dom_name, ps, depth)) - return False; - - slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i); - if(!prs_uint32(t, ps, depth, &dom->hdr_ref_dom[i].ptr_dom_sid)) - return False; - } - - for (i = 0; i < dom->num_ref_doms_2; i++) { - fstring t; - - if (dom->hdr_ref_dom[i].hdr_dom_name.buffer != 0) { - slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i); - if(!smb_io_unistr2(t, &dom->ref_dom[i].uni_dom_name, True, ps, depth)) /* domain name unicode string */ - return False; - if(!prs_align(ps)) - return False; - } - - if (dom->hdr_ref_dom[i].ptr_dom_sid != 0) { - slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i); - if(!smb_io_dom_sid2(t, &dom->ref_dom[i].ref_dom, ps, depth)) /* referenced domain SIDs */ - return False; - } - } - } - - return True; -} - -/******************************************************************* - Inits a LSA_SID_ENUM structure. -********************************************************************/ - -static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen, - int num_entries, const DOM_SID *sids) -{ - int i; - - DEBUG(5, ("init_lsa_sid_enum\n")); - - sen->num_entries = num_entries; - sen->ptr_sid_enum = (num_entries != 0); - sen->num_entries2 = num_entries; - - /* Allocate memory for sids and sid pointers */ - - if (num_entries) { - if ((sen->ptr_sid = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_entries )) == NULL) { - DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n")); - return; - } - - if ((sen->sid = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID2, num_entries)) == NULL) { - DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n")); - return; - } - } - - /* Copy across SIDs and SID pointers */ - - for (i = 0; i < num_entries; i++) { - sen->ptr_sid[i] = 1; - init_dom_sid2(&sen->sid[i], &sids[i]); - } -} - -/******************************************************************* - Reads or writes a LSA_SID_ENUM structure. -********************************************************************/ - -static bool lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps, - int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_sid_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries)) - return False; - if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum)) - return False; - - /* - if the ptr is NULL, leave here. checked from a real w2k trace. - JFM, 11/23/2001 - */ - - if (sen->ptr_sid_enum==0) - return True; - - if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2)) - return False; - - /* Mallocate memory if we're unpacking from the wire */ - - if (UNMARSHALLING(ps) && sen->num_entries) { - if ((sen->ptr_sid = PRS_ALLOC_MEM( ps, uint32, sen->num_entries)) == NULL) { - DEBUG(3, ("init_lsa_sid_enum(): out of memory for " - "ptr_sid\n")); - return False; - } - - if ((sen->sid = PRS_ALLOC_MEM( ps, DOM_SID2, sen->num_entries)) == NULL) { - DEBUG(3, ("init_lsa_sid_enum(): out of memory for " - "sids\n")); - return False; - } - } - - for (i = 0; i < sen->num_entries; i++) { - fstring temp; - - slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i); - if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) { - return False; - } - } - - for (i = 0; i < sen->num_entries; i++) { - fstring temp; - - slprintf(temp, sizeof(temp) - 1, "sid[%d]", i); - if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) { - return False; - } - } - - return True; -} - -/******************************************************************* - Inits an LSA_R_ENUM_TRUST_DOM structure. -********************************************************************/ - -void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l, - POLICY_HND *hnd, int num_sids, const DOM_SID *sids, - uint16 level) -{ - DEBUG(5, ("init_q_lookup_sids\n")); - - ZERO_STRUCTP(q_l); - - memcpy(&q_l->pol, hnd, sizeof(q_l->pol)); - init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids); - - q_l->level = level; -} - -/******************************************************************* - Reads or writes a LSA_Q_LOOKUP_SIDS structure. -********************************************************************/ - -bool lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */ - return False; - if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */ - return False; - if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */ - return False; - - if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */ - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a LSA_Q_LOOKUP_SIDS2 structure. -********************************************************************/ - -bool lsa_io_q_lookup_sids2(const char *desc, LSA_Q_LOOKUP_SIDS2 *q_s, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */ - return False; - if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */ - return False; - if(!lsa_io_trans_names2("names ", &q_s->names, ps, depth)) /* translated names */ - return False; - - if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */ - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count)) - return False; - if(!prs_uint32("unknown1", ps, depth, &q_s->unknown1)) - return False; - if(!prs_uint32("unknown2", ps, depth, &q_s->unknown2)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a LSA_Q_LOOKUP_SIDS3 structure. -********************************************************************/ - -bool lsa_io_q_lookup_sids3(const char *desc, LSA_Q_LOOKUP_SIDS3 *q_s, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */ - return False; - if(!lsa_io_trans_names2("names ", &q_s->names, ps, depth)) /* translated names */ - return False; - - if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */ - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count)) - return False; - if(!prs_uint32("unknown1", ps, depth, &q_s->unknown1)) - return False; - if(!prs_uint32("unknown2", ps, depth, &q_s->unknown2)) - return False; - - return True; -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static bool lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, - prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_trans_names"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries)) - return False; - if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names)) - return False; - - if (trn->ptr_trans_names != 0) { - if(!prs_uint32("num_entries2 ", ps, depth, - &trn->num_entries2)) - return False; - - if (trn->num_entries2 != trn->num_entries) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps) && trn->num_entries2) { - if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME, trn->num_entries2)) == NULL) { - return False; - } - - if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries2)) == NULL) { - return False; - } - } - - for (i = 0; i < trn->num_entries2; i++) { - fstring t; - slprintf(t, sizeof(t) - 1, "name[%d] ", i); - - if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */ - return False; - } - - for (i = 0; i < trn->num_entries2; i++) { - fstring t; - slprintf(t, sizeof(t) - 1, "name[%d] ", i); - - if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static bool lsa_io_trans_names2(const char *desc, LSA_TRANS_NAME_ENUM2 *trn, - prs_struct *ps, int depth) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "lsa_io_trans_names2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries)) - return False; - if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names)) - return False; - - if (trn->ptr_trans_names != 0) { - if(!prs_uint32("num_entries2 ", ps, depth, - &trn->num_entries2)) - return False; - - if (trn->num_entries2 != trn->num_entries) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps) && trn->num_entries2) { - if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME2, trn->num_entries2)) == NULL) { - return False; - } - - if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries2)) == NULL) { - return False; - } - } - - for (i = 0; i < trn->num_entries2; i++) { - fstring t; - slprintf(t, sizeof(t) - 1, "name[%d] ", i); - - if(!lsa_io_trans_name2(t, &trn->name[i], ps, depth)) /* translated name */ - return False; - } - - for (i = 0; i < trn->num_entries2; i++) { - fstring t; - slprintf(t, sizeof(t) - 1, "name[%d] ", i); - - if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - } - - return True; -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref)) - return False; - - if (r_s->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */ - return False; - - if(!lsa_io_trans_names("names ", &r_s->names, ps, depth)) /* translated names */ - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_s->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool lsa_io_r_lookup_sids2(const char *desc, LSA_R_LOOKUP_SIDS2 *r_s, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref)) - return False; - - if (r_s->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */ - return False; - - if(!lsa_io_trans_names2("names ", &r_s->names, ps, depth)) /* translated names */ - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_s->status)) - return False; - - return True; -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool lsa_io_r_lookup_sids3(const char *desc, LSA_R_LOOKUP_SIDS3 *r_s, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref)) - return False; - - if (r_s->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */ - return False; - - if(!lsa_io_trans_names2("names ", &r_s->names, ps, depth)) /* translated names */ - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_s->status)) - return False; - - return True; -} diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a216eaa730..f43258d5e5 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -126,43 +126,6 @@ static void init_dom_query_5(struct lsa_DomainInfo *r, r->sid = sid; } -/*************************************************************************** - init_dom_ref - adds a domain if it's not already in, returns the index. -***************************************************************************/ - -static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) -{ - int num = 0; - - if (dom_name != NULL) { - for (num = 0; num < ref->num_ref_doms_1; num++) { - if (sid_equal(dom_sid, &ref->ref_dom[num].ref_dom.sid)) - return num; - } - } else { - num = ref->num_ref_doms_1; - } - - if (num >= MAX_REF_DOMAINS) { - /* index not found, already at maximum domain limit */ - return -1; - } - - ref->num_ref_doms_1 = num+1; - ref->ptr_ref_dom = 1; - ref->max_entries = MAX_REF_DOMAINS; - ref->num_ref_doms_2 = num+1; - - ref->hdr_ref_dom[num].ptr_dom_sid = 1; /* dom sid cannot be NULL. */ - - init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, UNI_FLAGS_NONE); - init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, &ref->ref_dom[num].uni_dom_name); - - init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid ); - - return num; -} - /*************************************************************************** lookup_lsa_rids. Must be called as root for lookup_name to work. ***************************************************************************/ @@ -316,70 +279,6 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -/*************************************************************************** - Init_reply_lookup_sids. - ***************************************************************************/ - -static void init_reply_lookup_sids2(LSA_R_LOOKUP_SIDS2 *r_l, - DOM_R_REF *ref, - uint32 mapped_count) -{ - r_l->ptr_dom_ref = ref ? 1 : 0; - r_l->dom_ref = ref; - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - Init_reply_lookup_sids. - ***************************************************************************/ - -static void init_reply_lookup_sids3(LSA_R_LOOKUP_SIDS3 *r_l, - DOM_R_REF *ref, - uint32 mapped_count) -{ - r_l->ptr_dom_ref = ref ? 1 : 0; - r_l->dom_ref = ref; - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - Init_reply_lookup_sids. - ***************************************************************************/ - -static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx, - LSA_R_LOOKUP_SIDS *r_l, - DOM_R_REF *ref, - LSA_TRANS_NAME_ENUM2 *names, - uint32 mapped_count) -{ - LSA_TRANS_NAME_ENUM *oldnames = &r_l->names; - - oldnames->num_entries = names->num_entries; - oldnames->ptr_trans_names = names->ptr_trans_names; - oldnames->num_entries2 = names->num_entries2; - oldnames->uni_name = names->uni_name; - - if (names->num_entries) { - int i; - - oldnames->name = TALLOC_ARRAY(mem_ctx, LSA_TRANS_NAME, names->num_entries); - - if (!oldnames->name) { - return NT_STATUS_NO_MEMORY; - } - for (i = 0; i < names->num_entries; i++) { - oldnames->name[i].sid_name_use = names->name[i].sid_name_use; - oldnames->name[i].hdr_name = names->name[i].hdr_name; - oldnames->name[i].domain_idx = names->name[i].domain_idx; - } - } - - r_l->ptr_dom_ref = ref ? 1 : 0; - r_l->dom_ref = ref; - r_l->mapped_count = mapped_count; - return NT_STATUS_OK; -} - static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size) { DOM_SID local_adm_sid; -- cgit From 57ab1fe21e606767ed45e7a5d4fd3ca78d378a6b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 01:20:29 +0100 Subject: w (This used to be commit c22ec556b1df777b3b99669403dd1f9094a37a7a) --- source3/include/rpc_lsa.h | 62 ----------------------------------------------- 1 file changed, 62 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index cdd21a7515..3f55e18e0f 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -23,68 +23,6 @@ #ifndef _RPC_LSA_H /* _RPC_LSA_H */ #define _RPC_LSA_H -/* Opcodes available on PIPE_LSARPC */ - -#define LSA_CLOSE 0x00 -#define LSA_DELETE 0x01 -#define LSA_ENUM_PRIVS 0x02 -#define LSA_QUERYSECOBJ 0x03 -#define LSA_SETSECOBJ 0x04 -#define LSA_CHANGEPASSWORD 0x05 -#define LSA_OPENPOLICY 0x06 -#define LSA_QUERYINFOPOLICY 0x07 -#define LSA_SETINFOPOLICY 0x08 -#define LSA_CLEARAUDITLOG 0x09 -#define LSA_CREATEACCOUNT 0x0a -#define LSA_ENUM_ACCOUNTS 0x0b -#define LSA_CREATETRUSTDOM 0x0c /* TODO: implement this one -- jerry */ -#define LSA_ENUMTRUSTDOM 0x0d -#define LSA_LOOKUPNAMES 0x0e -#define LSA_LOOKUPSIDS 0x0f -#define LSA_CREATESECRET 0x10 /* TODO: implement this one -- jerry */ -#define LSA_OPENACCOUNT 0x11 -#define LSA_ENUMPRIVSACCOUNT 0x12 -#define LSA_ADDPRIVS 0x13 -#define LSA_REMOVEPRIVS 0x14 -#define LSA_GETQUOTAS 0x15 -#define LSA_SETQUOTAS 0x16 -#define LSA_GETSYSTEMACCOUNT 0x17 -#define LSA_SETSYSTEMACCOUNT 0x18 -#define LSA_OPENTRUSTDOM 0x19 -#define LSA_QUERYTRUSTDOMINFO 0x1a -#define LSA_SETINFOTRUSTDOM 0x1b -#define LSA_OPENSECRET 0x1c /* TODO: implement this one -- jerry */ -#define LSA_SETSECRET 0x1d /* TODO: implement this one -- jerry */ -#define LSA_QUERYSECRET 0x1e -#define LSA_LOOKUPPRIVVALUE 0x1f -#define LSA_LOOKUPPRIVNAME 0x20 -#define LSA_PRIV_GET_DISPNAME 0x21 -#define LSA_DELETEOBJECT 0x22 /* TODO: implement this one -- jerry */ -#define LSA_ENUMACCTWITHRIGHT 0x23 /* TODO: implement this one -- jerry */ -#define LSA_ENUMACCTRIGHTS 0x24 -#define LSA_ADDACCTRIGHTS 0x25 -#define LSA_REMOVEACCTRIGHTS 0x26 -#define LSA_QUERYTRUSTDOMINFOBYSID 0x27 -#define LSA_SETTRUSTDOMINFO 0x28 -#define LSA_DELETETRUSTDOM 0x29 -#define LSA_STOREPRIVDATA 0x2a -#define LSA_RETRPRIVDATA 0x2b -#define LSA_OPENPOLICY2 0x2c -#define LSA_UNK_GET_CONNUSER 0x2d /* LsaGetConnectedCredentials ? */ -#define LSA_QUERYINFO2 0x2e -#define LSA_QUERYTRUSTDOMINFOBYNAME 0x30 -#define LSA_QUERYDOMINFOPOL 0x35 -#define LSA_OPENTRUSTDOMBYNAME 0x37 - -#define LSA_LOOKUPSIDS2 0x39 -#define LSA_LOOKUPNAMES2 0x3a -#define LSA_LOOKUPNAMES3 0x44 -#define LSA_LOOKUPSIDS3 0x4c -#define LSA_LOOKUPNAMES4 0x4d - -/* XXXX these are here to get a compile! */ -#define LSA_LOOKUPRIDS 0xFD - #define LSA_AUDIT_NUM_CATEGORIES_NT4 7 #define LSA_AUDIT_NUM_CATEGORIES_WIN2K 9 #define LSA_AUDIT_NUM_CATEGORIES LSA_AUDIT_NUM_CATEGORIES_NT4 -- cgit From bdd5f1cb2a3edc8c654116bc602bef743f6a0a10 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 01:48:58 +0100 Subject: Fix some uninitialized data in new netlogon client. Guenther (This used to be commit bd6e2fcf3b3ab15736584edbbfb941b381988499) --- source3/rpc_client/cli_netlogon.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3') diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index cdf51c6241..91e27c5d85 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -318,6 +318,9 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, struct netr_ChallengeResponse lm; struct netr_ChallengeResponse nt; + ZERO_STRUCT(lm); + ZERO_STRUCT(nt); + network_info = TALLOC_ZERO_P(mem_ctx, struct netr_NetworkInfo); if (!network_info) { return NT_STATUS_NO_MEMORY; @@ -417,6 +420,9 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli, ZERO_STRUCT(zeros); ZERO_STRUCT(ret_creds); + ZERO_STRUCT(lm); + ZERO_STRUCT(nt); + logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); if (!logon) { return NT_STATUS_NO_MEMORY; @@ -537,6 +543,9 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, ZERO_STRUCT(zeros); + ZERO_STRUCT(lm); + ZERO_STRUCT(nt); + logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); if (!logon) { return NT_STATUS_NO_MEMORY; -- cgit From f8b0242ca03b99186010f95378410e1acde3e8b0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:28:46 +0100 Subject: Use pidl for _svcctl_StartServiceW(). Guenther (This used to be commit d95998ffd321eccf19f7de671eed2c741038b81e) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 12 ++++-------- 2 files changed, 5 insertions(+), 25 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 84c986dbfb..5f55593f6d 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -171,23 +171,7 @@ static bool api_svcctl_enum_dependent_services(pipes_struct *p) static bool api_svcctl_start_service(pipes_struct *p) { - SVCCTL_Q_START_SERVICE q_u; - SVCCTL_R_START_SERVICE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_start_service("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_start_service(p, &q_u, &r_u); - - if(!svcctl_io_r_start_service("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_STARTSERVICEW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index bdd0f4ffe3..06637e4339 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -470,11 +470,13 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT } /******************************************************************** + _svcctl_StartServiceW ********************************************************************/ -WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCTL_R_START_SERVICE *r_u) +WERROR _svcctl_StartServiceW(pipes_struct *p, + struct svcctl_StartServiceW *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* perform access checks */ @@ -982,12 +984,6 @@ WERROR _svcctl_QueryServiceLockStatusW(pipes_struct *p, struct svcctl_QueryServi return WERR_NOT_SUPPORTED; } -WERROR _svcctl_StartServiceW(pipes_struct *p, struct svcctl_StartServiceW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_GetServiceKeyNameW(pipes_struct *p, struct svcctl_GetServiceKeyNameW *r) { p->rng_fault_state = True; -- cgit From cea7718db8defbf418f06b78a20ff57750b5346f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:29:16 +0100 Subject: Use rpccli_svcctl_StartServiceW() in net. Guenther (This used to be commit 5ca4358c1a2c13b316df7cc07d8ca5b820c79988) --- source3/utils/net_rpc_service.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c index 74848b23a4..77e2ee4ac3 100644 --- a/source3/utils/net_rpc_service.c +++ b/source3/utils/net_rpc_service.c @@ -517,8 +517,13 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, /* get the status */ - result = rpccli_svcctl_start_service(pipe_hnd, mem_ctx, &hService, NULL, 0 ); - if ( !W_ERROR_IS_OK(result) ) { + status = rpccli_svcctl_StartServiceW(pipe_hnd, mem_ctx, + &hService, + 0, + NULL, + &result); + + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Query status request failed. [%s]\n", dos_errstr(result)); goto done; } -- cgit From a750bbf1b8d0d2b48af6be40f8d505b5e0edd899 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:30:53 +0100 Subject: Remove unused marshalling for SVCCTL_START_SERVICE. Guenther (This used to be commit 57e03a7fd56062bbff19c88c3b6928e8a0481794) --- source3/include/rpc_svcctl.h | 12 ----------- source3/rpc_client/cli_svcctl.c | 29 -------------------------- source3/rpc_parse/parse_svcctl.c | 44 ---------------------------------------- 3 files changed, 85 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index c40ea8e8ce..4f2182091a 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -196,18 +196,6 @@ typedef struct _ServiceInfo { /**************************/ -typedef struct { - POLICY_HND handle; - uint32 parmcount; - UNISTR4_ARRAY *parameters; -} SVCCTL_Q_START_SERVICE; - -typedef struct { - WERROR status; -} SVCCTL_R_START_SERVICE; - -/**************************/ - typedef struct { POLICY_HND handle; uint32 control; diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index cdd1b93aaa..9889d131f3 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -233,35 +233,6 @@ WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c /******************************************************************* *******************************************************************/ -WERROR rpccli_svcctl_start_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, - const char **parm_array, uint32 parmcount ) -{ - SVCCTL_Q_START_SERVICE in; - SVCCTL_R_START_SERVICE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - - in.parmcount = 0; - in.parameters = NULL; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_START_SERVICE_W, - in, out, - qbuf, rbuf, - svcctl_io_q_start_service, - svcctl_io_r_start_service, - WERR_GENERAL_FAILURE ); - - return out.status; -} - -/******************************************************************* -*******************************************************************/ - WERROR rpccli_svcctl_control_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, uint32 control, SERVICE_STATUS *status ) diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index f3ed8d1bf5..075d619331 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -302,50 +302,6 @@ bool svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_S return True; } -/******************************************************************* -********************************************************************/ - -bool svcctl_io_q_start_service(const char *desc, SVCCTL_Q_START_SERVICE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_start_service"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) - return False; - - if(!prs_uint32("parmcount", ps, depth, &q_u->parmcount)) - return False; - - if ( !prs_pointer("rights", ps, depth, (void*)&q_u->parameters, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_start_service(const char *desc, SVCCTL_R_START_SERVICE *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_start_service"); - depth++; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - /******************************************************************* ********************************************************************/ -- cgit From e87216972a01ac233e383674555b2a1ff5dfbaab Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:35:03 +0100 Subject: Use pidl for _svcctl_ControlService(). Guenther (This used to be commit 4797ca0bd5dc922f6ba5ebb93bf65ceee09a678e) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 20 +++++++++----------- 2 files changed, 10 insertions(+), 28 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 5f55593f6d..dd3a42235d 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -179,23 +179,7 @@ static bool api_svcctl_start_service(pipes_struct *p) static bool api_svcctl_control_service(pipes_struct *p) { - SVCCTL_Q_CONTROL_SERVICE q_u; - SVCCTL_R_CONTROL_SERVICE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_control_service("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_control_service(p, &q_u, &r_u); - - if(!svcctl_io_r_control_service("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_CONTROLSERVICE); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 06637e4339..e8969c70ac 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -490,29 +490,33 @@ WERROR _svcctl_StartServiceW(pipes_struct *p, } /******************************************************************** + _svcctl_ControlService ********************************************************************/ -WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, SVCCTL_R_CONTROL_SERVICE *r_u) +WERROR _svcctl_ControlService(pipes_struct *p, + struct svcctl_ControlService *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) return WERR_BADFID; - switch ( q_u->control ) { + switch ( r->in.control ) { case SVCCTL_CONTROL_STOP: if ( !(info->access_granted & SC_RIGHT_SVC_STOP) ) return WERR_ACCESS_DENIED; - return info->ops->stop_service( info->name, &r_u->svc_status ); + return info->ops->stop_service( info->name, + r->out.service_status ); case SVCCTL_CONTROL_INTERROGATE: if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; - return info->ops->service_status( info->name, &r_u->svc_status ); + return info->ops->service_status( info->name, + r->out.service_status ); } /* default control action */ @@ -888,12 +892,6 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, } -WERROR _svcctl_ControlService(pipes_struct *p, struct svcctl_ControlService *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) { p->rng_fault_state = True; -- cgit From 87bccd70caa6521fbbf6aa603ffff3ce30d8133d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:37:12 +0100 Subject: Use rpccli_svcctl_ControlService() in net. Guenther (This used to be commit 49375f0b4d5ead7d26659cfc94997bd3e18c48a9) --- source3/utils/net_rpc_service.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c index 77e2ee4ac3..3c22bfe381 100644 --- a/source3/utils/net_rpc_service.c +++ b/source3/utils/net_rpc_service.c @@ -127,10 +127,13 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd, /* get the status */ - result = rpccli_svcctl_control_service(pipe_hnd, mem_ctx, &hService, - control, &service_status ); + status = rpccli_svcctl_ControlService(pipe_hnd, mem_ctx, + &hService, + control, + &service_status, + &result); - if ( !W_ERROR_IS_OK(result) ) { + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Control service request failed. [%s]\n", dos_errstr(result)); goto done; } -- cgit From 35e48a4b1dfa3d63476fca105766da1ec980b446 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:37:32 +0100 Subject: Remove unused marshalling for SVCCTL_CONTROL_SERVICE. Guenther (This used to be commit 84112a24f5292b8d2e4d446e39462e0402453b4a) --- source3/include/rpc_svcctl.h | 12 ---------- source3/rpc_client/cli_svcctl.c | 32 --------------------------- source3/rpc_parse/parse_svcctl.c | 47 ---------------------------------------- 3 files changed, 91 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index 4f2182091a..aaa02dd28c 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -196,18 +196,6 @@ typedef struct _ServiceInfo { /**************************/ -typedef struct { - POLICY_HND handle; - uint32 control; -} SVCCTL_Q_CONTROL_SERVICE; - -typedef struct { - SERVICE_STATUS svc_status; - WERROR status; -} SVCCTL_R_CONTROL_SERVICE; - -/**************************/ - typedef struct { POLICY_HND handle; } SVCCTL_Q_QUERY_STATUS; diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 9889d131f3..c4ff44734a 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -229,35 +229,3 @@ WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c return out.status; } - -/******************************************************************* -*******************************************************************/ - -WERROR rpccli_svcctl_control_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, uint32 control, - SERVICE_STATUS *status ) -{ - SVCCTL_Q_CONTROL_SERVICE in; - SVCCTL_R_CONTROL_SERVICE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - in.control = control; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_CONTROL_SERVICE, - in, out, - qbuf, rbuf, - svcctl_io_q_control_service, - svcctl_io_r_control_service, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( status, &out.svc_status, sizeof(SERVICE_STATUS) ); - - return out.status; -} diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index 075d619331..0f39de0746 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -358,53 +358,6 @@ bool svcctl_io_r_enum_dependent_services(const char *desc, SVCCTL_R_ENUM_DEPENDE return True; } -/******************************************************************* -********************************************************************/ - -bool svcctl_io_q_control_service(const char *desc, SVCCTL_Q_CONTROL_SERVICE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_control_service"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) - return False; - - if(!prs_uint32("control", ps, depth, &q_u->control)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_control_service(const char *desc, SVCCTL_R_CONTROL_SERVICE *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_control_service"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!svcctl_io_service_status("service_status", &r_u->svc_status, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - /******************************************************************* ********************************************************************/ -- cgit From 4421e0d1470b82cdf7988a6c6d2ac67c8ea6c753 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:41:05 +0100 Subject: Use pidl for _svcctl_QueryServiceStatus(). Guenther (This used to be commit 5453d97ef4967755ef0c903dd665325d50845028) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 14 +++++--------- 2 files changed, 6 insertions(+), 26 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index dd3a42235d..3b9960c647 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -77,23 +77,7 @@ static bool api_svcctl_get_display_name(pipes_struct *p) static bool api_svcctl_query_status(pipes_struct *p) { - SVCCTL_Q_QUERY_STATUS q_u; - SVCCTL_R_QUERY_STATUS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_query_status("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_query_status(p, &q_u, &r_u); - - if(!svcctl_io_r_query_status("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICESTATUS); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index e8969c70ac..9baf2d5110 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -361,11 +361,13 @@ WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, } /******************************************************************** + _svcctl_QueryServiceStatus ********************************************************************/ -WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) +WERROR _svcctl_QueryServiceStatus(pipes_struct *p, + struct svcctl_QueryServiceStatus *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* perform access checks */ @@ -377,7 +379,7 @@ WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_ /* try the service specific status call */ - return info->ops->service_status( info->name, &r_u->svc_status ); + return info->ops->service_status( info->name, r->out.service_status ); } /******************************************************************** @@ -916,12 +918,6 @@ WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServic return WERR_NOT_SUPPORTED; } -WERROR _svcctl_QueryServiceStatus(pipes_struct *p, struct svcctl_QueryServiceStatus *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus *r) { p->rng_fault_state = True; -- cgit From 3c3944ee3850398a8d1349143aef53cdee44cdf4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:43:04 +0100 Subject: Use rpccli_svcctl_QueryServiceStatus() in net. Guenther (This used to be commit 1cc0e9b7e5b8685dc4aff8e379837dd32e386f9f) --- source3/utils/net_rpc_service.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c index 3c22bfe381..242d653017 100644 --- a/source3/utils/net_rpc_service.c +++ b/source3/utils/net_rpc_service.c @@ -50,8 +50,12 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd, return result; } - result = rpccli_svcctl_query_status(pipe_hnd, mem_ctx, &hService, &service_status ); - if ( W_ERROR_IS_OK(result) ) { + status = rpccli_svcctl_QueryServiceStatus(pipe_hnd, mem_ctx, + &hService, + &service_status, + &result); + + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { *state = service_status.state; } @@ -269,8 +273,12 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, /* get the status */ - result = rpccli_svcctl_query_status(pipe_hnd, mem_ctx, &hService, &service_status ); - if ( !W_ERROR_IS_OK(result) ) { + status = rpccli_svcctl_QueryServiceStatus(pipe_hnd, mem_ctx, + &hService, + &service_status, + &result); + + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Query status request failed. [%s]\n", dos_errstr(result)); goto done; } -- cgit From c147f2fd6b5d8f319b2cf6903da093211f46e575 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:43:56 +0100 Subject: Remove unused marshalling for SVCCTL_QUERY_STATUS. Guenther (This used to be commit 8a621f517fe38ce91f10e12fccc2963af6afc33d) --- source3/include/rpc_svcctl.h | 11 ---------- source3/rpc_client/cli_svcctl.c | 30 ---------------------------- source3/rpc_parse/parse_svcctl.c | 43 ---------------------------------------- 3 files changed, 84 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index aaa02dd28c..2bd28db291 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -196,17 +196,6 @@ typedef struct _ServiceInfo { /**************************/ -typedef struct { - POLICY_HND handle; -} SVCCTL_Q_QUERY_STATUS; - -typedef struct { - SERVICE_STATUS svc_status; - WERROR status; -} SVCCTL_R_QUERY_STATUS; - -/**************************/ - typedef struct { POLICY_HND handle; uint32 type; diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index c4ff44734a..b21909fd03 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -129,36 +129,6 @@ WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX /******************************************************************* *******************************************************************/ -WERROR rpccli_svcctl_query_status( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, SERVICE_STATUS *status ) -{ - SVCCTL_Q_QUERY_STATUS in; - SVCCTL_R_QUERY_STATUS out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_STATUS, - in, out, - qbuf, rbuf, - svcctl_io_q_query_status, - svcctl_io_r_query_status, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( status, &out.svc_status, sizeof(SERVICE_STATUS) ); - - return out.status; -} - -/******************************************************************* -*******************************************************************/ - WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, SERVICE_CONFIG *config ) { diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index 0f39de0746..ef9f03705d 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -198,49 +198,6 @@ uint32 svcctl_sizeof_service_config( SERVICE_CONFIG *config ) /******************************************************************* ********************************************************************/ -bool svcctl_io_q_query_status(const char *desc, SVCCTL_Q_QUERY_STATUS *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_query_status"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_query_status(const char *desc, SVCCTL_R_QUERY_STATUS *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_query_status"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!svcctl_io_service_status("service_status", &r_u->svc_status, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - bool svcctl_io_q_enum_services_status(const char *desc, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, prs_struct *ps, int depth) { if (q_u == NULL) -- cgit From e0860ccc824c336103a1e57c9e43c27936265769 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:47:05 +0100 Subject: Use pidl for _svcctl_LockServiceDatabase(). Guenther (This used to be commit 939da2eb58ea8cfa637ec63b254755d77702da45) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 27 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 3b9960c647..4689e38dea 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -219,23 +219,7 @@ static bool api_svcctl_query_service_config2(pipes_struct *p) static bool api_svcctl_lock_service_db(pipes_struct *p) { - SVCCTL_Q_LOCK_SERVICE_DB q_u; - SVCCTL_R_LOCK_SERVICE_DB r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_lock_service_db("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_lock_service_db(p, &q_u, &r_u); - - if(!svcctl_io_r_lock_service_db("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_LOCKSERVICEDATABASE); } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 9baf2d5110..96eafe4215 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -764,11 +764,13 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO } /******************************************************************** + _svcctl_LockServiceDatabase ********************************************************************/ -WERROR _svcctl_lock_service_db( pipes_struct *p, SVCCTL_Q_LOCK_SERVICE_DB *q_u, SVCCTL_R_LOCK_SERVICE_DB *r_u ) +WERROR _svcctl_LockServiceDatabase(pipes_struct *p, + struct svcctl_LockServiceDatabase *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* perform access checks */ @@ -780,8 +782,7 @@ WERROR _svcctl_lock_service_db( pipes_struct *p, SVCCTL_Q_LOCK_SERVICE_DB *q_u, /* Just open a handle. Doesn't actually lock anything */ - return create_open_service_handle( p, &r_u->h_lock, SVC_HANDLE_IS_DBLOCK, NULL, 0 ); -; + return create_open_service_handle( p, r->out.lock, SVC_HANDLE_IS_DBLOCK, NULL, 0 ); } /******************************************************************** @@ -900,12 +901,6 @@ WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_LockServiceDatabase(pipes_struct *p, struct svcctl_LockServiceDatabase *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, struct svcctl_QueryServiceObjectSecurity *r) { p->rng_fault_state = True; -- cgit From 35a30ac841583326e81c27a18e93e53de9bdfc4f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:48:08 +0100 Subject: Remove unused marshalling for SVCCTL_LOCK_SERVICE_DB. Guenther (This used to be commit 23d37a9aed145d38e2bd98b170b65096ab69b0d9) --- source3/include/rpc_svcctl.h | 12 ----------- source3/rpc_parse/parse_svcctl.c | 44 ---------------------------------------- 2 files changed, 56 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index 2bd28db291..9d58a0903e 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -272,18 +272,6 @@ typedef struct { } SVCCTL_R_QUERY_SERVICE_STATUSEX; -/**************************/ - -typedef struct { - POLICY_HND handle; -} SVCCTL_Q_LOCK_SERVICE_DB; - -typedef struct { - POLICY_HND h_lock; - WERROR status; -} SVCCTL_R_LOCK_SERVICE_DB; - - /**************************/ typedef struct { diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index ef9f03705d..d5b1466535 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -593,50 +593,6 @@ bool svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVIC /******************************************************************* ********************************************************************/ -bool svcctl_io_q_lock_service_db(const char *desc, SVCCTL_Q_LOCK_SERVICE_DB *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_lock_service_db"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("scm_handle", &q_u->handle, ps, depth)) - return False; - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_lock_service_db(const char *desc, SVCCTL_R_LOCK_SERVICE_DB *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_lock_service_db"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("lock_handle", &r_u->h_lock, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - bool svcctl_io_q_unlock_service_db(const char *desc, SVCCTL_Q_UNLOCK_SERVICE_DB *q_u, prs_struct *ps, int depth) { if (q_u == NULL) -- cgit From 5894d5e99a23a1a700ef5319bcfe822b125ccbb0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:50:01 +0100 Subject: Use pidl for _svcctl_UnlockServiceDatabase(). Guenther (This used to be commit 300bf76a79bfa0a9cf55505fd1e928aba9fec171) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 14 +++++--------- 2 files changed, 6 insertions(+), 26 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 4689e38dea..565c93fa77 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -228,23 +228,7 @@ static bool api_svcctl_lock_service_db(pipes_struct *p) static bool api_svcctl_unlock_service_db(pipes_struct *p) { - SVCCTL_Q_UNLOCK_SERVICE_DB q_u; - SVCCTL_R_UNLOCK_SERVICE_DB r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_unlock_service_db("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_unlock_service_db(p, &q_u, &r_u); - - if(!svcctl_io_r_unlock_service_db("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_UNLOCKSERVICEDATABASE); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 96eafe4215..53154ef0c9 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -786,17 +786,19 @@ WERROR _svcctl_LockServiceDatabase(pipes_struct *p, } /******************************************************************** + _svcctl_UnlockServiceDatabase ********************************************************************/ -WERROR _svcctl_unlock_service_db( pipes_struct *p, SVCCTL_Q_UNLOCK_SERVICE_DB *q_u, SVCCTL_R_UNLOCK_SERVICE_DB *r_u ) +WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, + struct svcctl_UnlockServiceDatabase *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->h_lock ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.lock ); if ( !info || (info->type != SVC_HANDLE_IS_DBLOCK) ) return WERR_BADFID; - return close_policy_hnd( p, &q_u->h_lock) ? WERR_OK : WERR_BADFID; + return close_policy_hnd( p, r->out.lock) ? WERR_OK : WERR_BADFID; } /******************************************************************** @@ -919,12 +921,6 @@ WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus return WERR_NOT_SUPPORTED; } -WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, struct svcctl_UnlockServiceDatabase *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_NotifyBootConfigStatus(pipes_struct *p, struct svcctl_NotifyBootConfigStatus *r) { p->rng_fault_state = True; -- cgit From 1c9990fcfe7ac36050351f7c2b99d1e3e044a01a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:50:54 +0100 Subject: Remove unused marshalling for SVCCTL_UNLOCK_SERVICE_DB. Guenther (This used to be commit eeb598a19a3d09f2175032e013857fe743da3eec) --- source3/include/rpc_svcctl.h | 11 ----------- source3/rpc_parse/parse_svcctl.c | 41 ---------------------------------------- 2 files changed, 52 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index 9d58a0903e..99d0c7035b 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -272,17 +272,6 @@ typedef struct { } SVCCTL_R_QUERY_SERVICE_STATUSEX; -/**************************/ - -typedef struct { - POLICY_HND h_lock; -} SVCCTL_Q_UNLOCK_SERVICE_DB; - -typedef struct { - WERROR status; -} SVCCTL_R_UNLOCK_SERVICE_DB; - - /**************************/ typedef struct { diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index d5b1466535..ececf1b5ed 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -593,47 +593,6 @@ bool svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVIC /******************************************************************* ********************************************************************/ -bool svcctl_io_q_unlock_service_db(const char *desc, SVCCTL_Q_UNLOCK_SERVICE_DB *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_unlock_service_db"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("h_lock", &q_u->h_lock, ps, depth)) - return False; - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_unlock_service_db(const char *desc, SVCCTL_R_UNLOCK_SERVICE_DB *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_unlock_service_db"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - bool svcctl_io_q_query_service_sec(const char *desc, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, prs_struct *ps, int depth) { if (q_u == NULL) -- cgit From 3e3df1bfe2ebce8b5c26cb5fb7d4c2f5c422fd97 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 18:21:14 +0100 Subject: Add a function libnet_conf_get_seqnum() to the libnet_conf API. This is to provide a change sequence number to users, so that they can use it to detect change in the config and trigger a reload. Michael (This used to be commit a0b12f4d815fa92c8826954e6d73546c8a751583) --- source3/libnet/libnet_conf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source3') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index c3872b68de..688097bc5e 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -481,6 +481,19 @@ void libnet_conf_close(struct libnet_conf_ctx *ctx) TALLOC_FREE(ctx); } +/** + * Get the change sequence number of the given service/parameter. + * + * NOTE: Currently, for registry configuration, this is independent + * of the service and parameter, it returns the registry-sequence + * number. + */ +uint64_t libnet_conf_get_seqnum(struct libnet_conf_ctx *ctx, + const char *service, const char *param) +{ + return (uint64_t)regdb_get_seqnum(); +} + /** * Drop the whole configuration (restarting empty). */ -- cgit From 9e9cd40a7d755b19ad70011409d213c9e9013fe6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 01:04:31 +0100 Subject: Make regdb_init() behave like regdb_open() when registry is already opened. I.e. increment the refcounter. Michael (This used to be commit 951d3fae2cbea09cc4e1806cbf0a94ecdfcee8d5) --- source3/registry/reg_backend_db.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index e162fb587f..52e0fd4289 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -258,8 +258,11 @@ bool regdb_init( void ) const char *vstring = "INFO/version"; uint32 vers_id; - if ( tdb_reg ) + if ( tdb_reg ) { + DEBUG(10,("regdb_init: incrementing refcount (%d)\n", tdb_refcount)); + tdb_refcount++; return true; + } if ( !(tdb_reg = tdb_wrap_open(NULL, state_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR, 0600)) ) { -- cgit From 6d963a807d4798749fdfd228f30e28c67debee7f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 01:22:32 +0100 Subject: Use linbet_conf code in loadparm's registry handling. This replaces the original hand-written tdb code, now that the linking dependencies have been significantly reduced. Michael (This used to be commit d08a3a195718725228bbafa61fd4f0be8aafb43f) --- source3/Makefile.in | 58 +++++++---- source3/param/loadparm.c | 261 +++++++---------------------------------------- 2 files changed, 74 insertions(+), 245 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index cebe49b510..920d56bec0 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -358,7 +358,7 @@ READLINE_OBJ = lib/readline.o POPT_LIB_OBJ = lib/popt_common.o PARAM_WITHOUT_REG_OBJ = dynconfig.o param/loadparm.o param/params.o param/util.o lib/sharesec.o lib/ldap_debug_handler.o -PARAM_REG_ADD_OBJ = $(UTIL_REG_API_OBJ) +PARAM_REG_ADD_OBJ = $(REG_API_OBJ) $(LIBNET_CONF_OBJ) $(REGOBJS_OBJ) $(PRIVILEGES_BASIC_OBJ) PARAM_OBJ = $(PARAM_WITHOUT_REG_OBJ) $(PARAM_REG_ADD_OBJ) KRBCLIENT_OBJ = libads/kerberos.o libads/ads_status.o @@ -466,7 +466,8 @@ REGISTRY_OBJ = registry/reg_init_full.o registry/reg_cachehook.o \ $(REGISTRY_BACKENDS) \ $(UTIL_REG_API_OBJ) \ $(REG_INIT_SMBCONF_OBJ) \ - $(REGFIO_OBJ) + $(REGFIO_OBJ) \ + $(REGOBJS_OBJ) # objects to be used when not all of the registry code should be # loaded but only the portion needed by reg_api, typically for @@ -532,19 +533,23 @@ RPC_SERVER_OBJ = @RPC_STATIC@ $(RPC_PIPE_OBJ) RPC_PARSE_OBJ = $(RPC_PARSE_OBJ2) \ rpc_parse/parse_spoolss.o \ rpc_parse/parse_eventlog.o rpc_parse/parse_buffer.o \ - rpc_parse/parse_ntsvcs.o rpc_parse/parse_svcctl.o $(REGOBJS_OBJ) + rpc_parse/parse_ntsvcs.o rpc_parse/parse_svcctl.o RPC_CLIENT_OBJ = rpc_client/cli_pipe.o LOCKING_OBJ = locking/locking.o locking/brlock.o locking/posix.o +PRIVILEGES_BASIC_OBJ = lib/privileges_basic.o + +PRIVILEGES_OBJ = lib/privileges.o + PASSDB_GET_SET_OBJ = passdb/pdb_get_set.o PASSDB_OBJ = $(PASSDB_GET_SET_OBJ) passdb/passdb.o passdb/pdb_interface.o \ passdb/util_wellknown.o passdb/util_builtin.o passdb/pdb_compat.o \ passdb/util_unixsids.o passdb/lookup_sid.o \ passdb/login_cache.o @PDB_STATIC@ \ - lib/account_pol.o lib/privileges.o lib/privileges_basic.o \ + lib/account_pol.o $(PRIVILEGES_OBJ) \ lib/util_nscd.o lib/winbind_util.o DEVEL_HELP_WEIRD_OBJ = modules/weird.o @@ -556,7 +561,7 @@ GROUPDB_OBJ = groupdb/mapping.o groupdb/mapping_tdb.o groupdb/mapping_ldb.o PROFILE_OBJ = profile/profile.o PROFILES_OBJ = utils/profiles.o \ - $(REGFIO_OBJ) $(REGOBJS_OBJ) $(ERRORMAP_OBJ) \ + $(ERRORMAP_OBJ) \ $(RPC_PARSE_OBJ1) $(PARAM_OBJ) $(LIBSAMBA_OBJ) \ $(DOSERR_OBJ) $(LIB_OBJ) $(LIB_DUMMY_OBJ) \ $(POPT_LIB_OBJ) $(SECRETS_OBJ) @@ -656,7 +661,8 @@ SMBD_OBJ_BASE = $(PARAM_WITHOUT_REG_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \ $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(LIBADS_SERVER_OBJ) \ $(REGISTRY_OBJ) $(POPT_LIB_OBJ) $(BUILDOPT_OBJ) \ - $(SMBLDAP_OBJ) $(LDB_OBJ) $(LIBNET_OBJ) @LIBWBCLIENT_STATIC@ + $(SMBLDAP_OBJ) $(LDB_OBJ) $(LIBNET_OBJ) @LIBWBCLIENT_STATIC@ \ + $(PRIVILEGES_BASIC_OBJ) PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/print_aix.o \ printing/print_cups.o printing/print_generic.o \ @@ -714,7 +720,8 @@ SMBTREE_OBJ = utils/smbtree.o $(PARAM_OBJ) \ TESTPARM_OBJ = utils/testparm.o \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \ - $(SECRETS_OBJ) $(LIBSAMBA_OBJ) $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) + $(SECRETS_OBJ) $(LIBSAMBA_OBJ) $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) \ + $(ERRORMAP_OBJ) PASSWD_UTIL_OBJ = utils/passwd_util.o @@ -722,7 +729,7 @@ SMBPASSWD_OBJ = utils/smbpasswd.o $(PASSWD_UTIL_OBJ) $(PASSCHANGE_OBJ) \ $(PARAM_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ \ $(GROUPDB_OBJ) $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \ $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) $(RPC_PARSE_OBJ) \ - $(LIBMSRPC_GEN_OBJ) $(LIBMSRPC_OBJ) $(LDB_OBJ) + $(LIBMSRPC_GEN_OBJ) $(LIBMSRPC_OBJ) $(LDB_OBJ) PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ \ $(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(GROUPDB_OBJ) \ @@ -796,9 +803,11 @@ LIBNETAPI_OBJ = $(LIBNETAPI_OBJ1) $(LIBNET_OBJ) \ $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \ $(SECRETS_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \ - $(DCUTIL_OBJ) $(LIBADS_OBJ) + $(DCUTIL_OBJ) $(LIBADS_OBJ) $(REGOBJS_OBJ) $(PRIVILEGES_BASIC_OBJ) + +LIBNET_CONF_OBJ = libnet/libnet_conf.o -LIBNET_OBJ = libnet/libnet_conf.o libnet/libnet_join.o \ +LIBNET_OBJ = $(LIBNET_CONF_OBJ) libnet/libnet_join.o \ librpc/gen_ndr/ndr_libnet_join.o NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_domain.o utils/net_help.o \ @@ -821,7 +830,8 @@ NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(READLINE_OBJ) \ $(LDB_OBJ) $(LIBGPO_OBJ) @BUILD_INIPARSER@ $(DISPLAY_SEC_OBJ) \ $(REG_API_OBJ) $(DISPLAY_DSDCINFO_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ - $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ + $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ $(REGOBJS_OBJ) \ + $(PRIVILEGES_BASIC_OBJ) CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(SECRETS_OBJ) $(POPT_LIB_OBJ) @@ -841,7 +851,8 @@ CIFS_UMOUNT_OBJ = client/umount.cifs.o CIFS_SPNEGO_OBJ = client/cifs.spnego.o NMBLOOKUP_OBJ = utils/nmblookup.o $(PARAM_OBJ) $(LIBNMB_OBJ) $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) \ - $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) $(LIBSAMBA_OBJ) + $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) $(LIBSAMBA_OBJ) \ + $(ERRORMAP_OBJ) SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/utable.o \ torture/denytest.o torture/mangle_test.o @@ -868,7 +879,7 @@ PDBTEST_OBJ = torture/pdbtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ VFSTEST_OBJ = torture/cmd_vfs.o torture/vfstest.o $(SMBD_OBJ_BASE) $(READLINE_OBJ) -SMBICONV_OBJ = $(PARAM_OBJ) torture/smbiconv.o $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) $(LIBSAMBA_OBJ) $(DOSERR_OBJ) +SMBICONV_OBJ = $(PARAM_OBJ) torture/smbiconv.o $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) $(LIBSAMBA_OBJ) $(DOSERR_OBJ) $(RPC_PARSE_OBJ1) $(ERRORMAP_OBJ) LOG2PCAP_OBJ = utils/log2pcaphex.o @@ -889,19 +900,19 @@ SMBCQUOTAS_OBJ = utils/smbcquotas.o $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ EVTLOGADM_OBJ0 = utils/eventlogadm.o -EVTLOGADM_OBJ = $(EVTLOGADM_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(REGOBJS_OBJ) \ +EVTLOGADM_OBJ = $(EVTLOGADM_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(ERRORMAP_OBJ) $(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(DOSERR_OBJ) \ $(SECRETS_OBJ) \ - registry/reg_eventlog.o rpc_server/srv_eventlog_lib.o registry/reg_util.o \ - registry/reg_backend_db.o + registry/reg_eventlog.o rpc_server/srv_eventlog_lib.o SHARESEC_OBJ0 = utils/sharesec.o -SHARESEC_OBJ = $(SHARESEC_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(REGOBJS_OBJ) \ +SHARESEC_OBJ = $(SHARESEC_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(ERRORMAP_OBJ) $(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(DOSERR_OBJ) \ $(POPT_LIB_OBJ) $(SECRETS_OBJ) TALLOCTORT_OBJ = @tallocdir@/testsuite.o $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ - $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(LIBSAMBA_OBJ) $(SECRETS_OBJ) + $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(LIBSAMBA_OBJ) $(SECRETS_OBJ) \ + $(ERRORMAP_OBJ) REPLACETORT_OBJ = lib/replace/test/testsuite.o \ lib/replace/test/os2_delete.o \ @@ -911,7 +922,8 @@ REPLACETORT_OBJ = lib/replace/test/testsuite.o \ NDRDUMP_OBJ = librpc/tools/ndrdump.o \ $(PARAM_OBJ) $(LIBNDR_GEN_OBJ) \ $(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \ - $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(SECRETS_OBJ) + $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(SECRETS_OBJ) \ + $(ERRORMAP_OBJ) DEBUG2HTML_OBJ = utils/debug2html.o utils/debugparse.o @@ -924,7 +936,7 @@ PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \ $(LIBMSRPC_OBJ) \ $(LIB_WITH_PROTO_OBJ) \ $(RPC_PIPE_OBJ) $(RPC_PARSE_OBJ) $(KRBCLIENT_OBJ) \ - $(AUTH_OBJ) $(PARAM_OBJ) $(LOCKING_OBJ) $(SECRETS_OBJ) \ + $(AUTH_OBJ) $(PARAM_WITHOUT_REG_OBJ) $(LOCKING_OBJ) $(SECRETS_OBJ) \ $(PRINTING_OBJ) $(PRINTBACKEND_OBJ) $(OPLOCK_OBJ) $(NOTIFY_OBJ) \ $(PASSDB_OBJ) $(GROUPDB_OBJ) \ $(READLINE_OBJ) $(PROFILE_OBJ) $(LIBADS_OBJ) $(LIBADS_SERVER_OBJ) \ @@ -935,7 +947,8 @@ PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \ $(IDMAP_OBJ) libsmb/spnego.o $(PASSCHANGE_OBJ) $(RPC_UNIXINFO_OBJ) \ $(RPC_NTSVCS_OBJ) $(RPC_INITSHUTDOWN_OBJ) \ utils/passwd_util.o $(LIBGPO_OBJ) $(NSS_INFO_OBJ) \ - $(RPCCLIENT_NDR_OBJ) $(DISPLAY_DSDCINFO_OBJ) + $(RPCCLIENT_NDR_OBJ) $(DISPLAY_DSDCINFO_OBJ) \ + $(PRIVILEGES_BASIC_OBJ) WINBIND_WINS_NSS_OBJ = nsswitch/wins.o $(PARAM_OBJ) \ $(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) $(NSSWINS_OBJ) $(KRBCLIENT_OBJ) $(SECRETS_OBJ) @@ -988,7 +1001,8 @@ WINBINDD_OBJ = \ WBINFO_OBJ = nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(SECRETS_OBJ) $(POPT_LIB_OBJ) $(AFS_SETTOKEN_OBJ) $(RPC_PARSE_OBJ1) \ - $(DOSERR_OBJ) lib/winbind_util.o $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ + $(DOSERR_OBJ) lib/winbind_util.o $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ \ + $(ERRORMAP_OBJ) WINBIND_NSS_OBJ = $(WBCOMMON_OBJ) $(LIBREPLACE_OBJ) @WINBIND_NSS_EXTRA_OBJS@ diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 29de336df5..4d067af5a5 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -52,6 +52,7 @@ */ #include "includes.h" +#include "libnet/libnet.h" bool in_client = False; /* Not in the client by default */ bool bLoaded = False; @@ -71,7 +72,8 @@ extern userdom_struct current_user_info; #define HOMES_NAME "homes" #endif -static int regdb_last_seqnum = 0; +static uint64_t conf_last_seqnum = 0; +static struct libnet_conf_ctx *conf_ctx = NULL; #define CONFIG_BACKEND_FILE 0 #define CONFIG_BACKEND_REGISTRY 1 @@ -3377,242 +3379,47 @@ bool service_ok(int iService) return (bRetval); } -/* - * lp_regdb_open - regdb helper function - * - * this should be considered an interim solution that becomes - * superfluous once the registry code has been rewritten - * do allow use of the tdb portion of the registry alone. - * - * in the meanwhile this provides a lean access - * to the registry globals. - */ - -static struct tdb_wrap *lp_regdb_open(void) -{ - struct tdb_wrap *reg_tdb = NULL; - const char *vstring = "INFO/version"; - uint32 vers_id; - - become_root(); - reg_tdb = tdb_wrap_open(NULL, state_path("registry.tdb"), 0, - REG_TDB_FLAGS, O_RDWR, 0600); - unbecome_root(); - if (!reg_tdb) { - DEBUG(1, ("lp_regdb_open: failed to open %s: %s\n", - state_path("registry.tdb"), strerror(errno))); - goto done; - } - else { - DEBUG(10, ("lp_regdb_open: reg tdb opened.\n")); - } - - vers_id = tdb_fetch_int32(reg_tdb->tdb, vstring); - if (vers_id != REGVER_V1) { - DEBUG(10, ("lp_regdb_open: INFO: registry tdb %s has wrong " - "INFO/version (got %d, expected %d)\n", - state_path("registry.tdb"), vers_id, REGVER_V1)); - /* this is apparently not implemented in the tdb */ - } - -done: - return reg_tdb; -} - /* * process_registry_globals - * - * this is the interim version of process_registry globals - * - * until we can do it as we would like using the api and only - * using the tdb portion of the registry (see below), - * this just provides the needed functionality of regdb_fetch_values - * and regdb_unpack_values, circumventing any fancy stuff, to - * give us access to the registry globals. */ static bool process_registry_globals(bool (*pfunc)(const char *, const char *)) { - bool ret = False; - struct tdb_wrap *reg_tdb = NULL; - WERROR err; - char *keystr; - TDB_DATA data; - /* vars for the tdb unpack loop */ - int len = 0; - int i; - int buflen; - uint8 *buf; - uint32 type; - uint32 size; - uint32 num_values = 0; - uint8 *data_p; - char * valstr; - struct registry_value *value = NULL; - - ZERO_STRUCT(data); - - reg_tdb = lp_regdb_open(); - if (!reg_tdb) { - DEBUG(1, ("Error opening the registry!\n")); - goto done; - } - - /* reg_tdb is from now on used as talloc ctx. - * freeing it closes the tdb (if refcount is 0) */ - - keystr = talloc_asprintf(reg_tdb,"%s/%s/%s", REG_VALUE_PREFIX, - KEY_SMBCONF, GLOBAL_NAME); - normalize_dbkey(keystr); - - DEBUG(10, ("process_registry_globals: fetching key '%s'\n", - keystr)); - - data = tdb_fetch_bystring(reg_tdb->tdb, keystr); - if (!data.dptr) { - ret = True; - goto done; - } - - buf = data.dptr; - buflen = data.dsize; - - /* unpack number of values */ - len = tdb_unpack(buf, buflen, "d", &num_values); - DEBUG(10, ("process_registry_globals: got %d values from tdb\n", - num_values)); - - /* unpack the values */ - for (i=0; i < num_values; i++) { - fstring valname; - type = REG_NONE; - size = 0; - data_p = NULL; - len += tdb_unpack(buf+len, buflen-len, "fdB", - valname, - &type, - &size, - &data_p); - if (registry_smbconf_valname_forbidden(valname)) { - DEBUG(10, ("process_registry_globals: Ignoring " - "parameter '%s' in registry.\n", valname)); - continue; - } - DEBUG(10, ("process_registry_globals: got value '%s'\n", - valname)); - if (size && data_p) { - err = registry_pull_value(reg_tdb, - &value, - (enum winreg_Type)type, - data_p, - size, - size); - SAFE_FREE(data_p); - if (!W_ERROR_IS_OK(err)) { - goto done; - } - switch(type) { - case REG_DWORD: - valstr = talloc_asprintf(reg_tdb, "%d", - value->v.dword); - pfunc(valname, valstr); - break; - case REG_SZ: - pfunc(valname, value->v.sz.str); - break; - default: - /* ignore other types */ - break; - } + WERROR werr; + char **param_names; + char **param_values; + uint32_t num_params; + uint32_t count; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + bool ret = false; + + if (conf_ctx == NULL) { + /* first time */ + werr = libnet_conf_open(NULL, &conf_ctx); + if (!W_ERROR_IS_OK(werr)) { + goto done; } } - ret = pfunc("registry shares", "yes"); - regdb_last_seqnum = tdb_get_seqnum(reg_tdb->tdb); - -done: - TALLOC_FREE(reg_tdb); - SAFE_FREE(data.dptr); - return ret; -} - -#if 0 -/* - * this is process_registry_globals as it _should_ be (roughly) - * using the reg_api functions... - * - * We are *not* currently doing it like this due to the large - * linker dependecies of the registry code (see above). - */ -static bool process_registry_globals(bool (*pfunc)(const char *, const char *)) -{ - bool ret = False; - TALLOC_CTX *ctx = NULL; - char *regpath = NULL; - WERROR werr = WERR_OK; - struct registry_key *key = NULL; - struct registry_value *value = NULL; - char *valname = NULL; - char *valstr = NULL; - uint32 idx = 0; - NT_USER_TOKEN *token = NULL; - - ctx = talloc_init("process_registry_globals"); - if (!ctx) { - smb_panic("Failed to create talloc context!"); - } - - if (!registry_init_smbconf()) { - DEBUG(1, ("Error initializing the registry.\n")); - goto done; - } - - werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token)); + werr = libnet_conf_get_share(mem_ctx, conf_ctx, GLOBAL_NAME, + &num_params, ¶m_names, ¶m_values); if (!W_ERROR_IS_OK(werr)) { - DEBUG(1, ("Error creating admin token: %s\n",dos_errstr(werr))); goto done; } - regpath = talloc_asprintf(ctx,"%s\\%s", KEY_SMBCONF, GLOBAL_NAME); - werr = reg_open_path(ctx, regpath, REG_KEY_READ, token, &key); - if (!W_ERROR_IS_OK(werr)) { - DEBUG(1, ("Registry smbconf global section does not exist.\n")); - DEBUGADD(1, ("Error opening registry path '%s\\%s: %s\n", - KEY_SMBCONF, GLOBAL_NAME, dos_errstr(werr))); - goto done; - } - - for (idx = 0; - W_ERROR_IS_OK(werr = reg_enumvalue(ctx, key, idx, &valname, - &value)); - idx++) - { - DEBUG(5, ("got global registry parameter '%s'\n", valname)); - switch(value->type) { - case REG_DWORD: - valstr = talloc_asprintf(ctx, "%d", value->v.dword); - pfunc(valname, valstr); - TALLOC_FREE(valstr); - break; - case REG_SZ: - pfunc(valname, value->v.sz.str); - break; - default: - /* ignore other types */ - break; + for (count = 0; count < num_params; count++) { + ret = pfunc(param_names[count], param_values[count]); + if (ret != true) { + goto done; } - TALLOC_FREE(value); - TALLOC_FREE(valstr); } ret = pfunc("registry shares", "yes"); - - regdb_last_seqnum = regdb_get_seqnum(); + conf_last_seqnum = libnet_conf_get_seqnum(conf_ctx, NULL, NULL); done: - talloc_destroy(ctx); + TALLOC_FREE(mem_ctx); return ret; } -#endif /* if 0 */ static struct file_lists { struct file_lists *next; @@ -3675,17 +3482,25 @@ bool lp_config_backend_is_registry(void) bool lp_file_list_changed(void) { struct file_lists *f = file_lists; - struct tdb_wrap *reg_tdb = NULL; DEBUG(6, ("lp_file_list_changed()\n")); if (lp_config_backend() == CONFIG_BACKEND_REGISTRY) { - reg_tdb = lp_regdb_open(); - if (reg_tdb && (regdb_last_seqnum != tdb_get_seqnum(reg_tdb->tdb))) + if (conf_ctx == NULL) { + WERROR werr; + werr = libnet_conf_open(NULL, &conf_ctx); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0, ("error opening configuration: %s\n", + dos_errstr(werr))); + return false; + } + } + if (conf_last_seqnum != + libnet_conf_get_seqnum(conf_ctx, NULL, NULL)) { - DEBUGADD(6, ("regdb seqnum changed: old = %d, new = %d\n", - regdb_last_seqnum, tdb_get_seqnum(reg_tdb->tdb))); - TALLOC_FREE(reg_tdb); + DEBUGADD(6, ("regdb seqnum changed: old = %lu, " + "new = %lu\n", conf_last_seqnum, + libnet_conf_get_seqnum(conf_ctx, NULL, NULL))); return true; } else { /* -- cgit From ebdc59ca395db408c0a39cb4560a02ff1ac05623 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 11:01:00 +0100 Subject: Makefile.in: Rework registry-related object collections. Group and name objects more sanely. Michael (This used to be commit 58626eb6027f43495a030d856232a81225d0ca77) --- source3/Makefile.in | 85 +++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 45 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 920d56bec0..42cc12a8e7 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -358,7 +358,7 @@ READLINE_OBJ = lib/readline.o POPT_LIB_OBJ = lib/popt_common.o PARAM_WITHOUT_REG_OBJ = dynconfig.o param/loadparm.o param/params.o param/util.o lib/sharesec.o lib/ldap_debug_handler.o -PARAM_REG_ADD_OBJ = $(REG_API_OBJ) $(LIBNET_CONF_OBJ) $(REGOBJS_OBJ) $(PRIVILEGES_BASIC_OBJ) +PARAM_REG_ADD_OBJ = $(REG_SMBCONF_OBJ) $(LIBNET_CONF_OBJ) $(PRIVILEGES_BASIC_OBJ) PARAM_OBJ = $(PARAM_WITHOUT_REG_OBJ) $(PARAM_REG_ADD_OBJ) KRBCLIENT_OBJ = libads/kerberos.o libads/ads_status.o @@ -439,51 +439,47 @@ LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \ # UTIL_REG_OBJ = lib/util_reg.o UTIL_REG_API_OBJ = lib/util_reg_api.o + REG_INIT_SMBCONF_OBJ = registry/reg_init_smbconf.o +REG_INIT_FULL_OBJ = registry/reg_init_full.o REGFIO_OBJ = registry/regfio.o REGOBJS_OBJ = registry/reg_objects.o -REGISTRY_BACKENDS = registry/reg_backend_printing.o \ - registry/reg_backend_db.o \ - registry/reg_backend_smbconf.o \ - registry/reg_backend_shares.o \ - registry/reg_backend_netlogon_params.o \ - registry/reg_backend_prod_options.o \ - registry/reg_backend_tcpip_params.o \ - registry/reg_backend_hkpt_params.o \ - registry/reg_backend_current_version.o \ - registry/reg_backend_perflib.o - - -REGISTRY_OBJ = registry/reg_init_full.o registry/reg_cachehook.o \ - registry/reg_eventlog.o \ - registry/reg_util.o registry/reg_perfcount.o \ - registry/reg_util_legacy.o \ - registry/reg_api.o \ +REG_BACKENDS_BASE_OBJ = registry/reg_backend_db.o + +REG_BACKENDS_SMBCONF_OBJ = registry/reg_backend_smbconf.o + +REG_BACKENDS_EXTRA_OBJ = registry/reg_backend_printing.o \ + registry/reg_backend_shares.o \ + registry/reg_backend_netlogon_params.o \ + registry/reg_backend_prod_options.o \ + registry/reg_backend_tcpip_params.o \ + registry/reg_backend_hkpt_params.o \ + registry/reg_backend_current_version.o \ + registry/reg_backend_perflib.o + +REG_BASE_OBJ = registry/reg_api.o \ registry/reg_dispatcher.o \ - $(REGISTRY_BACKENDS) \ - $(UTIL_REG_API_OBJ) \ - $(REG_INIT_SMBCONF_OBJ) \ + registry/reg_cachehook.o \ $(REGFIO_OBJ) \ - $(REGOBJS_OBJ) - -# objects to be used when not all of the registry code should be -# loaded but only the portion needed by reg_api, typically for -# using smbconf (registry) - full access -REG_API_OBJ = registry/reg_api.o \ - registry/reg_dispatcher.o \ - registry/reg_backend_smbconf.o \ - registry/reg_backend_db.o \ - registry/reg_util.o \ - \ - registry/reg_cachehook.o \ - \ - lib/util_nttoken.o \ - $(UTIL_REG_API_OBJ) \ - $(REG_INIT_SMBCONF_OBJ) \ - $(REGFIO_OBJ) + $(REGOBJS_OBJ) \ + registry/reg_util.o \ + $(UTIL_REG_API_OBJ) \ + lib/util_nttoken.o \ + $(REG_BACKENDS_BASE_OBJ) + +REG_SMBCONF_OBJ = $(REG_BASE_OBJ) \ + $(REG_BACKENDS_SMBCONF_OBJ) \ + $(REG_INIT_SMBCONF_OBJ) + +REG_FULL_OBJ = $(REG_SMBCONF_OBJ) \ + $(REG_BACKENDS_EXTRA_OBJ) \ + $(REG_INIT_FULL_OBJ) \ + registry/reg_eventlog.o \ + registry/reg_perfcount.o \ + registry/reg_util_legacy.o RPC_LSA_OBJ = rpc_server/srv_lsa_nt.o librpc/gen_ndr/srv_lsa.o @@ -621,7 +617,6 @@ AUTH_WINBIND_OBJ = auth/auth_winbind.o AUTH_SCRIPT_OBJ = auth/auth_script.o AUTH_OBJ = auth/auth.o @AUTH_STATIC@ auth/auth_util.o auth/token_util.o \ - lib/util_nttoken.o \ auth/auth_compat.o auth/auth_ntlmssp.o \ $(PLAINTEXT_AUTH_OBJ) $(SLCACHE_OBJ) $(DCUTIL_OBJ) @@ -660,7 +655,7 @@ SMBD_OBJ_BASE = $(PARAM_WITHOUT_REG_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \ $(NOTIFY_OBJ) $(GROUPDB_OBJ) $(AUTH_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \ $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(LIBADS_SERVER_OBJ) \ - $(REGISTRY_OBJ) $(POPT_LIB_OBJ) $(BUILDOPT_OBJ) \ + $(REG_FULL_OBJ) $(POPT_LIB_OBJ) $(BUILDOPT_OBJ) \ $(SMBLDAP_OBJ) $(LDB_OBJ) $(LIBNET_OBJ) @LIBWBCLIENT_STATIC@ \ $(PRIVILEGES_BASIC_OBJ) @@ -798,12 +793,12 @@ LIBNETAPI_OBJ1 = lib/netapi/netapi.o \ lib/netapi/getdc.o LIBNETAPI_OBJ = $(LIBNETAPI_OBJ1) $(LIBNET_OBJ) \ - $(REG_API_OBJ) \ + $(REG_SMBCONF_OBJ) \ $(PARAM_WITHOUT_REG_OBJ) $(LIB_NONSMBD_OBJ) \ $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \ $(SECRETS_OBJ) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \ - $(DCUTIL_OBJ) $(LIBADS_OBJ) $(REGOBJS_OBJ) $(PRIVILEGES_BASIC_OBJ) + $(DCUTIL_OBJ) $(LIBADS_OBJ) $(PRIVILEGES_BASIC_OBJ) LIBNET_CONF_OBJ = libnet/libnet_conf.o @@ -829,8 +824,8 @@ NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ $(SMBLDAP_OBJ) $(DCUTIL_OBJ) $(SERVER_MUTEX_OBJ) \ $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(READLINE_OBJ) \ $(LDB_OBJ) $(LIBGPO_OBJ) @BUILD_INIPARSER@ $(DISPLAY_SEC_OBJ) \ - $(REG_API_OBJ) $(DISPLAY_DSDCINFO_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ - $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ $(REGOBJS_OBJ) \ + $(REG_SMBCONF_OBJ) $(DISPLAY_DSDCINFO_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ + $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ \ $(PRIVILEGES_BASIC_OBJ) CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ @@ -940,7 +935,7 @@ PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \ $(PRINTING_OBJ) $(PRINTBACKEND_OBJ) $(OPLOCK_OBJ) $(NOTIFY_OBJ) \ $(PASSDB_OBJ) $(GROUPDB_OBJ) \ $(READLINE_OBJ) $(PROFILE_OBJ) $(LIBADS_OBJ) $(LIBADS_SERVER_OBJ) \ - $(AUTH_SAM_OBJ) $(REGISTRY_OBJ) $(POPT_LIB_OBJ) \ + $(AUTH_SAM_OBJ) $(REG_FULL_OBJ) $(POPT_LIB_OBJ) \ $(RPC_LSA_OBJ) $(RPC_NETLOG_OBJ) $(RPC_SAMR_OBJ) $(RPC_REG_OBJ) $(RPC_DSSETUP_OBJ) \ $(RPC_SVC_OBJ) $(RPC_WKS_OBJ) $(RPC_DFS_OBJ) $(RPC_SPOOLSS_OBJ) \ $(RPC_ECHO_OBJ) $(RPC_SVCCTL_OBJ) $(RPC_EVENTLOG_OBJ) $(SMBLDAP_OBJ) \ -- cgit From cdb88dcf6b65cc2261a5dbec06fc4534c708128d Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Tue, 19 Feb 2008 11:53:36 +0100 Subject: Change ldap search filter. This function is also used to search machine accounts which may be located in a different ou. This is an extension to e71a48bb80cee85afcccacbce2884c0d600f4d72. Karolin (This used to be commit e5cc8b683cba3f2f3a84b1636b3d5bee1bfc0dda) --- source3/passdb/pdb_ldap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index da2f9f30da..ce79dce668 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -2683,7 +2683,7 @@ static NTSTATUS ldapsam_enum_group_members(struct pdb_methods *methods, goto done; } - rc = smbldap_search(conn, lp_ldap_user_suffix(), + rc = smbldap_search(conn, lp_ldap_suffix(), LDAP_SCOPE_SUBTREE, filter, sid_attrs, 0, &result); @@ -2739,7 +2739,7 @@ static NTSTATUS ldapsam_enum_group_members(struct pdb_methods *methods, LDAP_OBJ_SAMBASAMACCOUNT, gidstr); - rc = smbldap_search(conn, lp_ldap_user_suffix(), + rc = smbldap_search(conn, lp_ldap_suffix(), LDAP_SCOPE_SUBTREE, filter, sid_attrs, 0, &result); -- cgit From e12cd305dd9d383058d5bdfa805078735c8018e3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 19 Feb 2008 15:53:57 +0100 Subject: Inform level II oplock holders when we write using AIO Jeremy, please check! (This used to be commit 81d823e026fb332a88b6e1f15030fe49719f2522) --- source3/smbd/aio.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 86fdfe31b7..5515582eec 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -351,6 +351,8 @@ bool schedule_aio_write_and_X(connection_struct *conn, return False; } + release_level_2_oplocks_on_change(fsp); + if (!write_through && !lp_syncalways(SNUM(fsp->conn)) && fsp->aio_write_behind) { /* Lie to the client and immediately claim we finished the -- cgit From 4c4c1bfb798aafa5a338a821456bae75e4753da1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 19 Feb 2008 13:27:08 +0100 Subject: Update position information also for AIO Necessary to survive RAW-SEEK with AIO enabled. Jeremy, please check! (This used to be commit e2ca12c2345c0e3916dd09d097b2ba1ce2989fa8) --- source3/smbd/aio.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3') diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 5515582eec..8c6eaf1498 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -423,6 +423,9 @@ static int handle_aio_read_complete(struct aio_extra *aio_ex) SSVAL(outbuf,smb_vwv7,((nread >> 16) & 1)); SSVAL(smb_buf(outbuf),-2,nread); + aio_ex->fsp->fh->pos = aio_ex->acb.aio_offset + nread; + aio_ex->fsp->fh->position_information = aio_ex->fsp->fh->pos; + DEBUG( 3, ( "handle_aio_read_complete file %s max=%d " "nread=%d\n", aio_ex->fsp->fsp_name, @@ -524,6 +527,8 @@ static int handle_aio_write_complete(struct aio_extra *aio_ex) DEBUG(5,("handle_aio_write: sync_file for %s returned %s\n", fsp->fsp_name, nt_errstr(status) )); } + + aio_ex->fsp->fh->pos = aio_ex->acb.aio_offset + nwritten; } show_msg(outbuf); -- cgit From 6fa31c53641a7caeb82627fd35b604775abfdf14 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 15:47:30 +0100 Subject: Remove unused m4 macro files. These files were added in aa14900f8291a017aa7fab2bbb9a6c79b12889b2 (automatic dependency tracking) in SAMBA_3_2, which was removed from configure.in in the git glue commit 5c6c8e1fe93f340005110a7833946191659d88ab. But apparently, the files were not removed by accident. Michael (This used to be commit aeb3673b3686f463e6c7811d61c01d8d6aec0eb3) --- source3/m4/check_gnu_make.m4 | 78 --------------------- source3/m4/cond.m4 | 34 ---------- source3/m4/depend.m4 | 158 ------------------------------------------- source3/m4/depout.m4 | 68 ------------------- source3/m4/lead-dot.m4 | 21 ------ source3/m4/make.m4 | 51 -------------- source3/m4/substnot.m4 | 12 ---- 7 files changed, 422 deletions(-) delete mode 100644 source3/m4/check_gnu_make.m4 delete mode 100644 source3/m4/cond.m4 delete mode 100644 source3/m4/depend.m4 delete mode 100644 source3/m4/depout.m4 delete mode 100644 source3/m4/lead-dot.m4 delete mode 100644 source3/m4/make.m4 delete mode 100644 source3/m4/substnot.m4 (limited to 'source3') diff --git a/source3/m4/check_gnu_make.m4 b/source3/m4/check_gnu_make.m4 deleted file mode 100644 index 44e1d9aa20..0000000000 --- a/source3/m4/check_gnu_make.m4 +++ /dev/null @@ -1,78 +0,0 @@ -##### http://autoconf-archive.cryp.to/check_gnu_make.html -# -# SYNOPSIS -# -# CHECK_GNU_MAKE() -# -# DESCRIPTION -# -# This macro searches for a GNU version of make. If a match is found, -# the makefile variable `ifGNUmake' is set to the empty string, -# otherwise it is set to "#". This is useful for including a special -# features in a Makefile, which cannot be handled by other versions -# of make. The variable _cv_gnu_make_command is set to the command to -# invoke GNU make if it exists, the empty string otherwise. -# -# Here is an example of its use: -# -# Makefile.in might contain: -# -# # A failsafe way of putting a dependency rule into a makefile -# $(DEPEND): -# $(CC) -MM $(srcdir)/*.c > $(DEPEND) -# -# @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND))) -# @ifGNUmake@ include $(DEPEND) -# @ifGNUmake@ endif -# -# Then configure.in would normally contain: -# -# CHECK_GNU_MAKE() -# AC_OUTPUT(Makefile) -# -# Then perhaps to cause gnu make to override any other make, we could -# do something like this (note that GNU make always looks for -# GNUmakefile first): -# -# if ! test x$_cv_gnu_make_command = x ; then -# mv Makefile GNUmakefile -# echo .DEFAULT: > Makefile ; -# echo \ $_cv_gnu_make_command \$@ >> Makefile; -# fi -# -# Then, if any (well almost any) other make is called, and GNU make -# also exists, then the other make wraps the GNU make. -# -# LAST MODIFICATION -# -# 2002-01-04 -# -# COPYLEFT -# -# Copyright (c) 2002 John Darrington -# -# Copying and distribution of this file, with or without -# modification, are permitted in any medium without royalty provided -# the copyright notice and this notice are preserved. - -AC_DEFUN( - [CHECK_GNU_MAKE], [ AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command, - _cv_gnu_make_command='' ; -dnl Search all the common names for GNU make - for a in "$MAKE" make gmake gnumake ; do - if test -z "$a" ; then continue ; fi ; - if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then - _cv_gnu_make_command=$a ; - break; - fi - done ; - ) ; -dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise - if test "x$_cv_gnu_make_command" != "x" ; then - ifGNUmake='' ; - else - ifGNUmake='#' ; - AC_MSG_RESULT("Not found"); - fi - AC_SUBST(ifGNUmake) -] ) diff --git a/source3/m4/cond.m4 b/source3/m4/cond.m4 deleted file mode 100644 index d9a58d2f39..0000000000 --- a/source3/m4/cond.m4 +++ /dev/null @@ -1,34 +0,0 @@ -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 8 - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) diff --git a/source3/m4/depend.m4 b/source3/m4/depend.m4 deleted file mode 100644 index fd0937330d..0000000000 --- a/source3/m4/depend.m4 +++ /dev/null @@ -1,158 +0,0 @@ -## -*- Autoconf -*- -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 9 - -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], UPC, [depcc="$UPC" am_compiler_list=], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - none) break ;; - esac - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -]) diff --git a/source3/m4/depout.m4 b/source3/m4/depout.m4 deleted file mode 100644 index 0d9717a100..0000000000 --- a/source3/m4/depout.m4 +++ /dev/null @@ -1,68 +0,0 @@ -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -#serial 3 - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[for mf in $CONFIG_FILES; do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done -done -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) diff --git a/source3/m4/lead-dot.m4 b/source3/m4/lead-dot.m4 deleted file mode 100644 index d83bfa0b08..0000000000 --- a/source3/m4/lead-dot.m4 +++ /dev/null @@ -1,21 +0,0 @@ -## -*- Autoconf -*- -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) diff --git a/source3/m4/make.m4 b/source3/m4/make.m4 deleted file mode 100644 index 0969d9a795..0000000000 --- a/source3/m4/make.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 3 - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) diff --git a/source3/m4/substnot.m4 b/source3/m4/substnot.m4 deleted file mode 100644 index 27d3f1fbef..0000000000 --- a/source3/m4/substnot.m4 +++ /dev/null @@ -1,12 +0,0 @@ -## -*- Autoconf -*- -# Copyright (C) 2006 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) -- cgit From 1f67a36de36be9fe0218816675af4d96c194ad39 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 15:58:02 +0100 Subject: configure.in: move definition of build dir up. Michael (This used to be commit 35327e8fee778cb46e181add7d1987c843384989) --- source3/configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index f1bd2d28a5..0409e164eb 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -15,6 +15,9 @@ case "$PATH" in ;; esac +builddir=`pwd` +AC_SUBST(builddir) + SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2` echo "SAMBA VERSION: ${SMB_VERSION_STRING}" @@ -6826,9 +6829,6 @@ if test x"$krb5_developer" = x"yes" -o x"$developer" = x"yes"; then CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS)" fi -builddir=`pwd` -AC_SUBST(builddir) - # Stuff the smbd-only libraries at the end of the smbd link # path (if we have them). SMBD_LIBS="$samba_dmapi_libs" -- cgit From c666d5b3845fa7536a07b45515f2e34575951d07 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:18:32 +0100 Subject: Move AC_ENABLE_SHARED and AC_DISABLE_STATIC to a more appropriate place. I have to investigate the effect of these and evaluate the need of their presence. For now establish more reasonable grouping. Michael (This used to be commit 3ba8fa1c4b9ac46133b17112ef3494a4c23dc314) --- source3/configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 0409e164eb..a595ebb83e 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -39,9 +39,6 @@ fi AC_LIBREPLACE_LOCATION_CHECKS -AC_DISABLE_STATIC -AC_ENABLE_SHARED - ################################################# # Directory handling stuff to support both the # legacy SAMBA directories and FHS compliant @@ -1785,6 +1782,9 @@ case "$host_os" in ;; esac +AC_DISABLE_STATIC +AC_ENABLE_SHARED + # Set defaults PIE_CFLAGS="" PIE_LDFLAGS="" -- cgit From 86e758e24648f39ed547394165390df5e43e027d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:24:24 +0100 Subject: configure: move AC_SUBST's of certain directories to the corresponding checks. Michael (This used to be commit 28c862704c27aaffc858650d0a4f4cc7893bb406) --- source3/configure.in | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index a595ebb83e..2c7ebdd8e6 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -252,6 +252,21 @@ AC_ARG_WITH(mandir, ;; esac]) +AC_SUBST(configdir) +AC_SUBST(lockdir) +AC_SUBST(piddir) +AC_SUBST(logfilebase) +AC_SUBST(ctdbdir) +AC_SUBST(privatedir) +AC_SUBST(swatdir) +AC_SUBST(bindir) +AC_SUBST(sbindir) +AC_SUBST(codepagedir) +AC_SUBST(statedir) +AC_SUBST(cachedir) +AC_SUBST(rootsbindir) +AC_SUBST(pammodulesdir) + AC_ARG_WITH(cfenc, [AS_HELP_STRING([--with-cfenc=HEADERDIR], [Use internal CoreFoundation encoding API for optimization (Mac OS X/Darwin only)])], [ @@ -310,21 +325,6 @@ if test "x${srcdir-.}" != "x."; then SAMBA_CPPFLAGS=`echo ${SAMBA_CPPFLAGS} | sed -e "s;${srcdir};\$\(srcdir\);g"` fi -AC_SUBST(configdir) -AC_SUBST(lockdir) -AC_SUBST(piddir) -AC_SUBST(logfilebase) -AC_SUBST(ctdbdir) -AC_SUBST(privatedir) -AC_SUBST(swatdir) -AC_SUBST(bindir) -AC_SUBST(sbindir) -AC_SUBST(codepagedir) -AC_SUBST(statedir) -AC_SUBST(cachedir) -AC_SUBST(rootsbindir) -AC_SUBST(pammodulesdir) - dnl Unique-to-Samba variables we'll be playing with. AC_SUBST(SAMBA_CPPFLAGS) AC_SUBST(SHELL) -- cgit From 90ea8ae9b1ed3b7ed1c93076517e026e629ea1aa Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:34:43 +0100 Subject: configure: Introduce "debug" variable set to yes by --enable-debug. Michael (This used to be commit b33db84c222af21cc3dd8233d6ff96e6f32ea3cd) --- source3/configure.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 2c7ebdd8e6..e9b93eeb4b 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -410,10 +410,11 @@ AC_SUBST(NSCD_LIBS) ## check for --enable-debug first before checking CFLAGS before ## so that we don't mix -O and -g +debug=no AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [Turn on compiler debugging information (default=no)])], [if eval "test x$enable_debug = xyes"; then - CFLAGS="${CFLAGS} -g" + debug=yes fi]) # compile with optimization and without debugging by default, but @@ -424,6 +425,11 @@ AC_ARG_ENABLE(debug, if test "x$CFLAGS" = x; then CFLAGS="-O" fi +if test "x$debug" = "xyes" ; then + CFLAGS="${CFLAGS} -g" +else + CFLAGS="-O" +fi CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3" -- cgit From 5073bd13493fbfb158857ca0807424e631a29872 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:35:55 +0100 Subject: Move the --enable-debug check up above all compiler checks. Michael (This used to be commit fb74f8dd6a612db0d79b091dd9972bb3204818fb) --- source3/configure.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index e9b93eeb4b..4a9dc0c139 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -267,6 +267,15 @@ AC_SUBST(cachedir) AC_SUBST(rootsbindir) AC_SUBST(pammodulesdir) +## check for --enable-debug first before checking CFLAGS before +## so that we don't mix -O and -g +debug=no +AC_ARG_ENABLE(debug, +[AS_HELP_STRING([--enable-debug], [Turn on compiler debugging information (default=no)])], + [if eval "test x$enable_debug = xyes"; then + debug=yes + fi]) + AC_ARG_WITH(cfenc, [AS_HELP_STRING([--with-cfenc=HEADERDIR], [Use internal CoreFoundation encoding API for optimization (Mac OS X/Darwin only)])], [ @@ -408,15 +417,6 @@ AC_SUBST(EXTRA_ALL_TARGETS) AC_SUBST(CONFIG_LIBS) AC_SUBST(NSCD_LIBS) -## check for --enable-debug first before checking CFLAGS before -## so that we don't mix -O and -g -debug=no -AC_ARG_ENABLE(debug, -[AS_HELP_STRING([--enable-debug], [Turn on compiler debugging information (default=no)])], - [if eval "test x$enable_debug = xyes"; then - debug=yes - fi]) - # compile with optimization and without debugging by default, but # allow people to set their own preference. # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2" -- cgit From b40d1b131b1c0a62c8c11395f8ce17e32385fae7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:40:50 +0100 Subject: configure: move more developer/test related checks up before the compiler checks. Michael (This used to be commit 05e3095e21330c162624338160ab48d197cf0507) --- source3/configure.in | 92 ++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 4a9dc0c139..91ae8d3e9d 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -276,6 +276,52 @@ AC_ARG_ENABLE(debug, debug=yes fi]) +################################################# +# set prefix for 'make test' +selftest_prefix="./" +AC_SUBST(selftest_prefix) +AC_ARG_WITH(selftest-prefix, +[AS_HELP_STRING([--with-selftest-prefix=DIR], [The prefix where make test will be run ($selftest_prefix)])], +[ case "$withval" in + yes|no) + AC_MSG_WARN([--with-selftest-prefix called without argument - will use default]) + ;; + * ) + selftest_prefix="$withval" + ;; + esac +]) + +################################################# +# set path of samba4's smbtorture +smbtorture4_path="" +AC_SUBST(smbtorture4_path) +AC_ARG_WITH(smbtorture4_path, +[AS_HELP_STRING([--with-smbtorture4-path=PATH], [The path to a samba4 smbtorture for make test (none)])], +[ case "$withval" in + yes|no) + AC_MSG_ERROR([--with-smbtorture4-path should take a path]) + ;; + * ) + smbtorture4_path="$withval" + if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then + AC_MSG_ERROR(['$smbtorture_path' does not exist!]) + fi + ;; + esac +]) + +AC_ARG_ENABLE(developer, [AS_HELP_STRING([--enable-developer], [Turn on developer warnings and debugging (default=no)])], + [if eval "test x$enable_developer = xyes"; then + developer=yes + fi]) + +AC_ARG_ENABLE(krb5developer, [AS_HELP_STRING([--enable-krb5developer], [Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)])], + [if eval "test x$enable_krb5developer = xyes"; then + developer=yes + krb5_developer=yes + fi]) + AC_ARG_WITH(cfenc, [AS_HELP_STRING([--with-cfenc=HEADERDIR], [Use internal CoreFoundation encoding API for optimization (Mac OS X/Darwin only)])], [ @@ -453,52 +499,6 @@ AC_ARG_ENABLE(swat, AC_SUBST(SWAT_SBIN_TARGETS) AC_SUBST(SWAT_INSTALL_TARGETS) -################################################# -# set prefix for 'make test' -selftest_prefix="./" -AC_SUBST(selftest_prefix) -AC_ARG_WITH(selftest-prefix, -[AS_HELP_STRING([--with-selftest-prefix=DIR], [The prefix where make test will be run ($selftest_prefix)])], -[ case "$withval" in - yes|no) - AC_MSG_WARN([--with-selftest-prefix called without argument - will use default]) - ;; - * ) - selftest_prefix="$withval" - ;; - esac -]) - -################################################# -# set path of samba4's smbtorture -smbtorture4_path="" -AC_SUBST(smbtorture4_path) -AC_ARG_WITH(smbtorture4_path, -[AS_HELP_STRING([--with-smbtorture4-path=PATH], [The path to a samba4 smbtorture for make test (none)])], -[ case "$withval" in - yes|no) - AC_MSG_ERROR([--with-smbtorture4-path should take a path]) - ;; - * ) - smbtorture4_path="$withval" - if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then - AC_MSG_ERROR(['$smbtorture_path' does not exist!]) - fi - ;; - esac -]) - -AC_ARG_ENABLE(developer, [AS_HELP_STRING([--enable-developer], [Turn on developer warnings and debugging (default=no)])], - [if eval "test x$enable_developer = xyes"; then - developer=yes - fi]) - -AC_ARG_ENABLE(krb5developer, [AS_HELP_STRING([--enable-krb5developer], [Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)])], - [if eval "test x$enable_krb5developer = xyes"; then - developer=yes - krb5_developer=yes - fi]) - # Probe the gcc version for extra CFLAGS. We always stash these in # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple # Makefile edit, avoiding the need to re-run configure. -- cgit From 12239ef5058d69a222015e66f718a1cfba099a26 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:43:39 +0100 Subject: configure: add default for developer and krb5developer Michael (This used to be commit e9b06ac113e375de11bb847c6f625f7861502853) --- source3/configure.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 91ae8d3e9d..cbb3104480 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -311,11 +311,13 @@ AC_ARG_WITH(smbtorture4_path, esac ]) +developer=no AC_ARG_ENABLE(developer, [AS_HELP_STRING([--enable-developer], [Turn on developer warnings and debugging (default=no)])], [if eval "test x$enable_developer = xyes"; then developer=yes fi]) +krb5developer=no AC_ARG_ENABLE(krb5developer, [AS_HELP_STRING([--enable-krb5developer], [Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)])], [if eval "test x$enable_krb5developer = xyes"; then developer=yes -- cgit From 53d5624205b684d8c7a47d6b4bfb5ac6aceed998 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:44:12 +0100 Subject: configure: Also set debug=yes for --enable-developer and --enable-krb5developer. Michael (This used to be commit ad45d056df64aeed2e2c97ab69f82013791616ab) --- source3/configure.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index cbb3104480..4ed1782301 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -314,12 +314,14 @@ AC_ARG_WITH(smbtorture4_path, developer=no AC_ARG_ENABLE(developer, [AS_HELP_STRING([--enable-developer], [Turn on developer warnings and debugging (default=no)])], [if eval "test x$enable_developer = xyes"; then + debug=yes developer=yes fi]) krb5developer=no AC_ARG_ENABLE(krb5developer, [AS_HELP_STRING([--enable-krb5developer], [Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)])], [if eval "test x$enable_krb5developer = xyes"; then + debug=yes developer=yes krb5_developer=yes fi]) -- cgit From 3b3b80a3653863533c9a20833e9bf75330be5c0a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:45:38 +0100 Subject: configure: move debug check to developer check ...thereby grouping test checks and debug/developer checks together, respectively. Michael (This used to be commit bf1bb2c0906dd5e518c3f35ef97d69eba0e2efdf) --- source3/configure.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 4ed1782301..cc71ccfc18 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -267,15 +267,6 @@ AC_SUBST(cachedir) AC_SUBST(rootsbindir) AC_SUBST(pammodulesdir) -## check for --enable-debug first before checking CFLAGS before -## so that we don't mix -O and -g -debug=no -AC_ARG_ENABLE(debug, -[AS_HELP_STRING([--enable-debug], [Turn on compiler debugging information (default=no)])], - [if eval "test x$enable_debug = xyes"; then - debug=yes - fi]) - ################################################# # set prefix for 'make test' selftest_prefix="./" @@ -311,6 +302,15 @@ AC_ARG_WITH(smbtorture4_path, esac ]) +## check for --enable-debug first before checking CFLAGS before +## so that we don't mix -O and -g +debug=no +AC_ARG_ENABLE(debug, +[AS_HELP_STRING([--enable-debug], [Turn on compiler debugging information (default=no)])], + [if eval "test x$enable_debug = xyes"; then + debug=yes + fi]) + developer=no AC_ARG_ENABLE(developer, [AS_HELP_STRING([--enable-developer], [Turn on developer warnings and debugging (default=no)])], [if eval "test x$enable_developer = xyes"; then -- cgit From 07f4f95b1408933a315bf6bcbdfe085fcd64dbfd Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 16:48:49 +0100 Subject: build: change selftest_prefix from ./ to ./st . It was used as ${selftest_prefix}/st anyways... Michael (This used to be commit 1f3bfa024d61ccb87655db2c616b28adb50d6783) --- source3/Makefile.in | 6 +++--- source3/configure.in | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 42cc12a8e7..4402a6c122 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -2314,7 +2314,7 @@ test_pam_modules: pam_modules ## test: all torture timelimit @echo Running Test suite - @LIB_PATH_VAR=$(LIB_PATH_VAR) PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix}/st all "${smbtorture4_path}" + @LIB_PATH_VAR=$(LIB_PATH_VAR) PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all "${smbtorture4_path}" valgrindtest: all torture timelimit @echo Running Test suite with valgrind @@ -2322,5 +2322,5 @@ valgrindtest: all torture timelimit NMBD_VALGRIND="xterm -n nmbd -e valgrind -q --db-attach=yes --num-callers=30" \ WINBINDD_VALGRIND="xterm -n winbindd -e valgrind -q --db-attach=yes --num-callers=30" \ SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \ - VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/st/valgrind.log" \ - PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix}/st all "${smbtorture4_path}" + VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \ + PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all "${smbtorture4_path}" diff --git a/source3/configure.in b/source3/configure.in index cc71ccfc18..cf926ad8d6 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -269,7 +269,7 @@ AC_SUBST(pammodulesdir) ################################################# # set prefix for 'make test' -selftest_prefix="./" +selftest_prefix="./st" AC_SUBST(selftest_prefix) AC_ARG_WITH(selftest-prefix, [AS_HELP_STRING([--with-selftest-prefix=DIR], [The prefix where make test will be run ($selftest_prefix)])], -- cgit From 27b711414f09ccad140e6ef82d8d47c9cb4ba94a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 17:01:49 +0100 Subject: configure: Move path (and debug) checks to an m4 include file check_path.m4. This is inspired by metze's check_path.m4 of Samba4. Michael (This used to be commit d1db2b78c9dacddc0e24304624a6a0d0a817f774) --- source3/configure.in | 307 +-------------------------------------------- source3/m4/check_path.m4 | 316 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 317 insertions(+), 306 deletions(-) create mode 100644 source3/m4/check_path.m4 (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index cf926ad8d6..6ff1df2cec 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -37,312 +37,7 @@ if test -n "${SAMBA_VERSION_GIT_COMMIT_TIME}";then echo "BUILD REVISION: ${SAMBA_VERSION_GIT_COMMIT_TIME}" fi -AC_LIBREPLACE_LOCATION_CHECKS - -################################################# -# Directory handling stuff to support both the -# legacy SAMBA directories and FHS compliant -# ones... -AC_PREFIX_DEFAULT(/usr/local/samba) - -rootsbindir="\${SBINDIR}" -lockdir="\${VARDIR}/locks" -piddir="\${VARDIR}/locks" -test "${mandir}" || mandir="\${prefix}/man" -logfilebase="\${VARDIR}" -privatedir="\${prefix}/private" -test "${libdir}" || libdir="\${prefix}/lib" -pammodulesdir="\${LIBDIR}/security" -configdir="\${LIBDIR}" -swatdir="\${prefix}/swat" -codepagedir="\${LIBDIR}" -statedir="\${LOCKDIR}" -cachedir="\${LOCKDIR}" - -AC_ARG_WITH(fhs, -[AS_HELP_STRING([--with-fhs],[Use FHS-compliant paths (default=no)])], -[ case "$withval" in - yes) - lockdir="\${VARDIR}/lib/samba" - piddir="\${VARDIR}/run" - mandir="\${prefix}/share/man" - logfilebase="\${VARDIR}/log/samba" - privatedir="\${CONFIGDIR}/private" - test "${libdir}" || libdir="\${prefix}/lib/samba" - configdir="\${sysconfdir}/samba" - swatdir="\${DATADIR}/samba/swat" - codepagedir="\${LIBDIR}" - statedir="\${VARDIR}/lib/samba" - cachedir="\${VARDIR}/lib/samba" - AC_DEFINE(FHS_COMPATIBLE, 1, [Whether to use fully FHS-compatible paths]) - ;; - esac]) - -################################################# -# set private directory location -AC_ARG_WITH(privatedir, -[AS_HELP_STRING([--with-privatedir=DIR], [Where to put smbpasswd ($ac_default_prefix/private)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody calls it without argument - # - AC_MSG_WARN([--with-privatedir called without argument - will use default]) - ;; - * ) - privatedir="$withval" - ;; - esac]) - -################################################# -# set root sbin directory location -AC_ARG_WITH(rootsbindir, -[AS_HELP_STRING([--with-rootsbindir=DIR], [Which directory to use for root sbin ($ac_default_prefix/sbin)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody calls it without argument - # - AC_MSG_WARN([--with-rootsbindir called without argument - will use default]) - ;; - * ) - rootsbindir="$withval" - ;; - esac]) - -################################################# -# set lock directory location -AC_ARG_WITH(lockdir, -[AS_HELP_STRING([--with-lockdir=DIR], [Where to put lock files ($ac_default_prefix/var/locks)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody calls it without argument - # - AC_MSG_WARN([--with-lockdir called without argument - will use default]) - ;; - * ) - lockdir="$withval" - ;; - esac]) - -################################################# -# set pid directory location -AC_ARG_WITH(piddir, -[AS_HELP_STRING([--with-piddir=DIR], [Where to put pid files ($ac_default_prefix/var/locks)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody calls it without argument - # - AC_MSG_WARN([--with-piddir called without argument - will use default]) - ;; - * ) - piddir="$withval" - ;; - esac]) - -################################################# -# set SWAT directory location -AC_ARG_WITH(swatdir, -[AS_HELP_STRING([--with-swatdir=DIR], [Where to put SWAT files ($ac_default_prefix/swat)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody does it - # - AC_MSG_WARN([--with-swatdir called without argument - will use default]) - ;; - * ) - swatdir="$withval" - ;; - esac]) - -################################################# -# set configuration directory location -AC_ARG_WITH(configdir, -[AS_HELP_STRING([--with-configdir=DIR], [Where to put configuration files ($libdir)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody does it - # - AC_MSG_WARN([--with-configdir called without argument - will use default]) - ;; - * ) - configdir="$withval" - ;; - esac]) - -################################################# -# set log directory location -AC_ARG_WITH(logfilebase, -[AS_HELP_STRING([--with-logfilebase=DIR], [Where to put log files ($VARDIR)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody does it - # - AC_MSG_WARN([--with-logfilebase called without argument - will use default]) - ;; - * ) - logfilebase="$withval" - ;; - esac]) - - -################################################# -# set ctdb source directory location -AC_ARG_WITH(ctdb, -[AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])], -[ case "$withval" in - yes|no) - AC_MSG_WARN([--with-ctdb called without argument]) - ;; - * ) - ctdbdir="$withval" - ;; - esac]) - -################################################# -# set lib directory location -AC_ARG_WITH(libdir, -[AS_HELP_STRING([--with-libdir=DIR], [Where to put libdir ($libdir)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody does it - # - AC_MSG_WARN([--with-libdir without argument - will use default]) - ;; - * ) - libdir="$withval" - ;; - esac]) - -################################################# -# set PAM modules directory location -AC_ARG_WITH(pammodulesdir, -[AS_HELP_STRING([--with-pammodulesdir=DIR], [Which directory to use for PAM modules ($ac_default_prefix/$libdir/security)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody calls it without argument - # - AC_MSG_WARN([--with-pammodulesdir called without argument - will use default]) - ;; - * ) - pammodulesdir="$withval" - ;; - esac]) - -################################################# -# set man directory location -AC_ARG_WITH(mandir, -[AS_HELP_STRING([--with-mandir=DIR], [Where to put man pages ($mandir)])], -[ case "$withval" in - yes|no) - # - # Just in case anybody does it - # - AC_MSG_WARN([--with-mandir without argument - will use default]) - ;; - * ) - mandir="$withval" - ;; - esac]) - -AC_SUBST(configdir) -AC_SUBST(lockdir) -AC_SUBST(piddir) -AC_SUBST(logfilebase) -AC_SUBST(ctdbdir) -AC_SUBST(privatedir) -AC_SUBST(swatdir) -AC_SUBST(bindir) -AC_SUBST(sbindir) -AC_SUBST(codepagedir) -AC_SUBST(statedir) -AC_SUBST(cachedir) -AC_SUBST(rootsbindir) -AC_SUBST(pammodulesdir) - -################################################# -# set prefix for 'make test' -selftest_prefix="./st" -AC_SUBST(selftest_prefix) -AC_ARG_WITH(selftest-prefix, -[AS_HELP_STRING([--with-selftest-prefix=DIR], [The prefix where make test will be run ($selftest_prefix)])], -[ case "$withval" in - yes|no) - AC_MSG_WARN([--with-selftest-prefix called without argument - will use default]) - ;; - * ) - selftest_prefix="$withval" - ;; - esac -]) - -################################################# -# set path of samba4's smbtorture -smbtorture4_path="" -AC_SUBST(smbtorture4_path) -AC_ARG_WITH(smbtorture4_path, -[AS_HELP_STRING([--with-smbtorture4-path=PATH], [The path to a samba4 smbtorture for make test (none)])], -[ case "$withval" in - yes|no) - AC_MSG_ERROR([--with-smbtorture4-path should take a path]) - ;; - * ) - smbtorture4_path="$withval" - if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then - AC_MSG_ERROR(['$smbtorture_path' does not exist!]) - fi - ;; - esac -]) - -## check for --enable-debug first before checking CFLAGS before -## so that we don't mix -O and -g -debug=no -AC_ARG_ENABLE(debug, -[AS_HELP_STRING([--enable-debug], [Turn on compiler debugging information (default=no)])], - [if eval "test x$enable_debug = xyes"; then - debug=yes - fi]) - -developer=no -AC_ARG_ENABLE(developer, [AS_HELP_STRING([--enable-developer], [Turn on developer warnings and debugging (default=no)])], - [if eval "test x$enable_developer = xyes"; then - debug=yes - developer=yes - fi]) - -krb5developer=no -AC_ARG_ENABLE(krb5developer, [AS_HELP_STRING([--enable-krb5developer], [Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)])], - [if eval "test x$enable_krb5developer = xyes"; then - debug=yes - developer=yes - krb5_developer=yes - fi]) - -AC_ARG_WITH(cfenc, -[AS_HELP_STRING([--with-cfenc=HEADERDIR], [Use internal CoreFoundation encoding API for optimization (Mac OS X/Darwin only)])], -[ -# May be in source $withval/CoreFoundation/StringEncodings.subproj. -# Should have been in framework $withval/CoreFoundation.framework/Headers. -for d in \ - $withval/CoreFoundation/StringEncodings.subproj \ - $withval/StringEncodings.subproj \ - $withval/CoreFoundation.framework/Headers \ - $withval/Headers \ - $withval -do - if test -r $d/CFStringEncodingConverter.h; then - ln -sfh $d include/CoreFoundation - fi -done -]) +m4_include(m4/check_path.m4) AC_LIBREPLACE_CC_CHECKS diff --git a/source3/m4/check_path.m4 b/source3/m4/check_path.m4 new file mode 100644 index 0000000000..ccf21271c8 --- /dev/null +++ b/source3/m4/check_path.m4 @@ -0,0 +1,316 @@ +dnl +dnl Samba3 build environment path checks +dnl +dnl Copyright (C) Michael Adam 2008 +dnl +dnl Released under the GNU General Public License +dnl http://www.gnu.org/licenses/ +dnl + +AC_LIBREPLACE_LOCATION_CHECKS + +################################################# +# Directory handling stuff to support both the +# legacy SAMBA directories and FHS compliant +# ones... +AC_PREFIX_DEFAULT(/usr/local/samba) + +rootsbindir="\${SBINDIR}" +lockdir="\${VARDIR}/locks" +piddir="\${VARDIR}/locks" +test "${mandir}" || mandir="\${prefix}/man" +logfilebase="\${VARDIR}" +privatedir="\${prefix}/private" +test "${libdir}" || libdir="\${prefix}/lib" +pammodulesdir="\${LIBDIR}/security" +configdir="\${LIBDIR}" +swatdir="\${prefix}/swat" +codepagedir="\${LIBDIR}" +statedir="\${LOCKDIR}" +cachedir="\${LOCKDIR}" + +AC_ARG_WITH(fhs, +[AS_HELP_STRING([--with-fhs],[Use FHS-compliant paths (default=no)])], +[ case "$withval" in + yes) + lockdir="\${VARDIR}/lib/samba" + piddir="\${VARDIR}/run" + mandir="\${prefix}/share/man" + logfilebase="\${VARDIR}/log/samba" + privatedir="\${CONFIGDIR}/private" + test "${libdir}" || libdir="\${prefix}/lib/samba" + configdir="\${sysconfdir}/samba" + swatdir="\${DATADIR}/samba/swat" + codepagedir="\${LIBDIR}" + statedir="\${VARDIR}/lib/samba" + cachedir="\${VARDIR}/lib/samba" + AC_DEFINE(FHS_COMPATIBLE, 1, [Whether to use fully FHS-compatible paths]) + ;; + esac]) + +################################################# +# set private directory location +AC_ARG_WITH(privatedir, +[AS_HELP_STRING([--with-privatedir=DIR], [Where to put smbpasswd ($ac_default_prefix/private)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody calls it without argument + # + AC_MSG_WARN([--with-privatedir called without argument - will use default]) + ;; + * ) + privatedir="$withval" + ;; + esac]) + +################################################# +# set root sbin directory location +AC_ARG_WITH(rootsbindir, +[AS_HELP_STRING([--with-rootsbindir=DIR], [Which directory to use for root sbin ($ac_default_prefix/sbin)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody calls it without argument + # + AC_MSG_WARN([--with-rootsbindir called without argument - will use default]) + ;; + * ) + rootsbindir="$withval" + ;; + esac]) + +################################################# +# set lock directory location +AC_ARG_WITH(lockdir, +[AS_HELP_STRING([--with-lockdir=DIR], [Where to put lock files ($ac_default_prefix/var/locks)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody calls it without argument + # + AC_MSG_WARN([--with-lockdir called without argument - will use default]) + ;; + * ) + lockdir="$withval" + ;; + esac]) + +################################################# +# set pid directory location +AC_ARG_WITH(piddir, +[AS_HELP_STRING([--with-piddir=DIR], [Where to put pid files ($ac_default_prefix/var/locks)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody calls it without argument + # + AC_MSG_WARN([--with-piddir called without argument - will use default]) + ;; + * ) + piddir="$withval" + ;; + esac]) + +################################################# +# set SWAT directory location +AC_ARG_WITH(swatdir, +[AS_HELP_STRING([--with-swatdir=DIR], [Where to put SWAT files ($ac_default_prefix/swat)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody does it + # + AC_MSG_WARN([--with-swatdir called without argument - will use default]) + ;; + * ) + swatdir="$withval" + ;; + esac]) + +################################################# +# set configuration directory location +AC_ARG_WITH(configdir, +[AS_HELP_STRING([--with-configdir=DIR], [Where to put configuration files ($libdir)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody does it + # + AC_MSG_WARN([--with-configdir called without argument - will use default]) + ;; + * ) + configdir="$withval" + ;; + esac]) + +################################################# +# set log directory location +AC_ARG_WITH(logfilebase, +[AS_HELP_STRING([--with-logfilebase=DIR], [Where to put log files ($VARDIR)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody does it + # + AC_MSG_WARN([--with-logfilebase called without argument - will use default]) + ;; + * ) + logfilebase="$withval" + ;; + esac]) + + +################################################# +# set ctdb source directory location +AC_ARG_WITH(ctdb, +[AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])], +[ case "$withval" in + yes|no) + AC_MSG_WARN([--with-ctdb called without argument]) + ;; + * ) + ctdbdir="$withval" + ;; + esac]) + +################################################# +# set lib directory location +AC_ARG_WITH(libdir, +[AS_HELP_STRING([--with-libdir=DIR], [Where to put libdir ($libdir)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody does it + # + AC_MSG_WARN([--with-libdir without argument - will use default]) + ;; + * ) + libdir="$withval" + ;; + esac]) + +################################################# +# set PAM modules directory location +AC_ARG_WITH(pammodulesdir, +[AS_HELP_STRING([--with-pammodulesdir=DIR], [Which directory to use for PAM modules ($ac_default_prefix/$libdir/security)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody calls it without argument + # + AC_MSG_WARN([--with-pammodulesdir called without argument - will use default]) + ;; + * ) + pammodulesdir="$withval" + ;; + esac]) + +################################################# +# set man directory location +AC_ARG_WITH(mandir, +[AS_HELP_STRING([--with-mandir=DIR], [Where to put man pages ($mandir)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody does it + # + AC_MSG_WARN([--with-mandir without argument - will use default]) + ;; + * ) + mandir="$withval" + ;; + esac]) + +AC_SUBST(configdir) +AC_SUBST(lockdir) +AC_SUBST(piddir) +AC_SUBST(logfilebase) +AC_SUBST(ctdbdir) +AC_SUBST(privatedir) +AC_SUBST(swatdir) +AC_SUBST(bindir) +AC_SUBST(sbindir) +AC_SUBST(codepagedir) +AC_SUBST(statedir) +AC_SUBST(cachedir) +AC_SUBST(rootsbindir) +AC_SUBST(pammodulesdir) + +################################################# +# set prefix for 'make test' +selftest_prefix="./st" +AC_SUBST(selftest_prefix) +AC_ARG_WITH(selftest-prefix, +[AS_HELP_STRING([--with-selftest-prefix=DIR], [The prefix where make test will be run ($selftest_prefix)])], +[ case "$withval" in + yes|no) + AC_MSG_WARN([--with-selftest-prefix called without argument - will use default]) + ;; + * ) + selftest_prefix="$withval" + ;; + esac +]) + +################################################# +# set path of samba4's smbtorture +smbtorture4_path="" +AC_SUBST(smbtorture4_path) +AC_ARG_WITH(smbtorture4_path, +[AS_HELP_STRING([--with-smbtorture4-path=PATH], [The path to a samba4 smbtorture for make test (none)])], +[ case "$withval" in + yes|no) + AC_MSG_ERROR([--with-smbtorture4-path should take a path]) + ;; + * ) + smbtorture4_path="$withval" + if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then + AC_MSG_ERROR(['$smbtorture_path' does not exist!]) + fi + ;; + esac +]) + +## check for --enable-debug first before checking CFLAGS before +## so that we don't mix -O and -g +debug=no +AC_ARG_ENABLE(debug, +[AS_HELP_STRING([--enable-debug], [Turn on compiler debugging information (default=no)])], + [if eval "test x$enable_debug = xyes"; then + debug=yes + fi]) + +developer=no +AC_ARG_ENABLE(developer, [AS_HELP_STRING([--enable-developer], [Turn on developer warnings and debugging (default=no)])], + [if eval "test x$enable_developer = xyes"; then + debug=yes + developer=yes + fi]) + +krb5developer=no +AC_ARG_ENABLE(krb5developer, [AS_HELP_STRING([--enable-krb5developer], [Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)])], + [if eval "test x$enable_krb5developer = xyes"; then + debug=yes + developer=yes + krb5_developer=yes + fi]) + +AC_ARG_WITH(cfenc, +[AS_HELP_STRING([--with-cfenc=HEADERDIR], [Use internal CoreFoundation encoding API for optimization (Mac OS X/Darwin only)])], +[ +# May be in source $withval/CoreFoundation/StringEncodings.subproj. +# Should have been in framework $withval/CoreFoundation.framework/Headers. +for d in \ + $withval/CoreFoundation/StringEncodings.subproj \ + $withval/StringEncodings.subproj \ + $withval/CoreFoundation.framework/Headers \ + $withval/Headers \ + $withval +do + if test -r $d/CFStringEncodingConverter.h; then + ln -sfh $d include/CoreFoundation + fi +done +]) + -- cgit From 2235ffe2f754da543b796446377b1419bf046204 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 02:39:01 +0100 Subject: r26467: Use getifaddrs() for interface enumeration and provide replacements for platforms that don't have it in lib/replace. (lib/replace part of 9b4924fbd8619033c55b4c6e2589da247332e7db - Michael) (This used to be commit 789bf2d36bd728cc68b58cfb1e9570b90ca09af7) --- source3/lib/replace/getifaddrs.c | 391 +++++++++++++++++++++++++++++++++++ source3/lib/replace/getifaddrs.m4 | 94 +++++++++ source3/lib/replace/libreplace.m4 | 1 + source3/lib/replace/system/network.h | 25 +++ 4 files changed, 511 insertions(+) create mode 100644 source3/lib/replace/getifaddrs.c create mode 100644 source3/lib/replace/getifaddrs.m4 (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c new file mode 100644 index 0000000000..3969535a0b --- /dev/null +++ b/source3/lib/replace/getifaddrs.c @@ -0,0 +1,391 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Jeremy Allison 2007 + Copyright (C) Jelmer Vernooij 2007 + + 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 "replace.h" +#include "system/network.h" + +#include +#include +#include + +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifndef SIOCGIFCONF +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif +#endif + +#ifdef HAVE_IFACE_GETIFADDRS +#define _FOUND_IFACE_ANY +#else + +void freeifaddrs(struct ifaddrs *ifp) +{ + free(ifp->ifa_name); + free(ifp->ifa_addr); + free(ifp->ifa_netmask); + free(ifp->ifa_dstaddr); + if (ifp->ifa_next != NULL) + freeifaddrs(ifp->ifa_next); + free(ifp); +} + +struct sockaddr *sockaddr_dup(struct sockaddr *sa) +{ + struct sockaddr *ret = calloc(1, sa->sa_len); + if (ret == NULL) + return NULL; + memcpy(ret, sa, sa->sa_len); + return ret; +} +#endif + +#if HAVE_IFACE_IFCONF + +/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1 + V4.0, Ultrix 4.4, SCO Unix 3.2, IRIX 6.4 and FreeBSD 3.2. + + It probably also works on any BSD style system. */ + +int getifaddrs(struct ifaddrs **ifap) +{ + struct ifconf ifc; + char buff[8192]; + int fd, i, n; + struct ifreq *ifr=NULL; + int total = 0; + struct in_addr ipaddr; + struct in_addr nmask; + char *iname; + struct ifaddrs *curif, *lastif; + + *ifap = NULL; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + return -1; + } + + ifc.ifc_len = sizeof(buff); + ifc.ifc_buf = buff; + + if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) { + close(fd); + return -1; + } + + ifr = ifc.ifc_req; + + n = ifc.ifc_len / sizeof(struct ifreq); + + /* Loop through interfaces, looking for given IP address */ + for (i=n-1;i>=0 && total < max_interfaces;i--) { + if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) { + freeifaddrs(*ifap); + } + + curif = calloc(1, sizeof(struct ifaddrs)); + if (lastif == NULL) { + *ifap = curif; + } else { + lastif->ifa_next = (*ifap); + } + + curif->ifa_name = strdup(ifr[i].ifr_name); + curif->ifa_flags = ifreq.ifr_flags; + curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); + curif->ifa_dstaddr = NULL; + curif->ifa_data = NULL; + curif->ifa_next = NULL; + curif->ifa_netmask = NULL; + + if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) != 0) { + freeifaddrs(*ifap); + return -1; + } + + if (!(ifr[i].ifr_flags & IFF_UP)) { + freeifaddrs(curif); + continue; + } + + if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) { + freeifaddrs(*ifap); + return -1; + } + + curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr); + + lastif = curif; + } + + close(fd); + + return 0; +} + +#define _FOUND_IFACE_ANY +#endif /* HAVE_IFACE_IFCONF */ +#ifdef HAVE_IFACE_IFREQ + +#ifndef I_STR +#include +#endif + +/**************************************************************************** +this should cover most of the streams based systems +Thanks to Andrej.Borsenkow@mow.siemens.ru for several ideas in this code +****************************************************************************/ +int getifaddrs(struct ifaddrs **ifap) +{ + struct ifreq ifreq; + struct strioctl strioctl; + char buff[8192]; + int fd, i, n; + struct ifreq *ifr=NULL; + int total = 0; + struct in_addr ipaddr; + struct in_addr nmask; + char *iname; + struct ifaddrs *curif; + + *ifap = NULL; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + return -1; + } + + strioctl.ic_cmd = SIOCGIFCONF; + strioctl.ic_dp = buff; + strioctl.ic_len = sizeof(buff); + if (ioctl(fd, I_STR, &strioctl) < 0) { + close(fd); + return -1; + } + + /* we can ignore the possible sizeof(int) here as the resulting + number of interface structures won't change */ + n = strioctl.ic_len / sizeof(struct ifreq); + + /* we will assume that the kernel returns the length as an int + at the start of the buffer if the offered size is a + multiple of the structure size plus an int */ + if (n*sizeof(struct ifreq) + sizeof(int) == strioctl.ic_len) { + ifr = (struct ifreq *)(buff + sizeof(int)); + } else { + ifr = (struct ifreq *)buff; + } + + /* Loop through interfaces */ + + for (i = 0; iifa_next = (*ifap); + } + + curif->ifa_name = strdup(ifreq.ifr_name); + curif->ifa_flags = ifreq.ifr_flags; + curif->ifa_addr = sockaddr_dup(&ifreq.ifr_addr); + curif->ifa_dstaddr = NULL; + curif->ifa_data = NULL; + curif->ifa_next = NULL; + curif->ifa_netmask = NULL; + + strioctl.ic_cmd = SIOCGIFNETMASK; + strioctl.ic_dp = (char *)&ifreq; + strioctl.ic_len = sizeof(struct ifreq); + if (ioctl(fd, I_STR, &strioctl) != 0) { + freeifaddrs(*ifap); + return -1; + } + + curif->ifa_netmask = sockaddr_dup(&ifreq.ifr_addr); + + lastif = curif; + } + + close(fd); + + return 0; +} + +#define _FOUND_IFACE_ANY +#endif /* HAVE_IFACE_IFREQ */ +#ifdef HAVE_IFACE_AIX + +/**************************************************************************** +this one is for AIX (tested on 4.2) +****************************************************************************/ +int getifaddrs(struct ifaddrs **ifap) +{ + char buff[8192]; + int fd, i; + struct ifconf ifc; + struct ifreq *ifr=NULL; + struct in_addr ipaddr; + struct in_addr nmask; + char *iname; + int total = 0; + struct ifaddrs *curif, *lastif; + + *ifap = NULL; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + return -1; + } + + ifc.ifc_len = sizeof(buff); + ifc.ifc_buf = buff; + + if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) { + close(fd); + return -1; + } + + ifr = ifc.ifc_req; + + /* Loop through interfaces */ + i = ifc.ifc_len; + + while (i > 0) { + uint_t inc; + + inc = ifr->ifr_addr.sa_len; + + if (ioctl(fd, SIOCGIFADDR, ifr) != 0) { + freeaddrinfo(*ifap); + return -1; + } + + curif = calloc(1, sizeof(struct ifaddrs)); + if (lastif == NULL) { + *ifap = curif; + } else { + lastif->ifa_next = (*ifap); + } + + curif->ifa_name = strdup(ifr->ifr_name); + curif->ifa_flags = ifr->ifr_flags; + curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr); + curif->ifa_dstaddr = NULL; + curif->ifa_data = NULL; + curif->ifa_netmask = NULL; + curif->ifa_next = NULL; + + if (ioctl(fd, SIOCGIFFLAGS, ifr) != 0) { + freeaddrinfo(*ifap); + return -1; + } + + if (!(ifr->ifr_flags & IFF_UP)) { + freeaddrinfo(curif); + continue; + } + + if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { + freeaddrinfo(*ifap); + return -1; + } + + curif->ifa_netmask = sockaddr_dup(&ifr->ifr_addr); + + lastif = curif; + + next: + /* + * Patch from Archie Cobbs (archie@whistle.com). The + * addresses in the SIOCGIFCONF interface list have a + * minimum size. Usually this doesn't matter, but if + * your machine has tunnel interfaces, etc. that have + * a zero length "link address", this does matter. */ + + if (inc < sizeof(ifr->ifr_addr)) + inc = sizeof(ifr->ifr_addr); + inc += IFNAMSIZ; + + ifr = (struct ifreq*) (((char*) ifr) + inc); + i -= inc; + } + + close(fd); + return 0; +} + +#define _FOUND_IFACE_ANY +#endif /* HAVE_IFACE_AIX */ +#ifndef _FOUND_IFACE_ANY +int getifaddrs(struct ifaddrs **ifap) +{ + errno = ENOSYS; + return -1; +} +#endif + +#ifdef AUTOCONF_TEST +/* this is the autoconf driver to test get_interfaces() */ + + int main() +{ + struct ifaddrs *ifs; + int total = get_interfaces(ifaces, MAX_INTERFACES); + int i; + + int ret = getifaddrs(&ifs); + if (ret != 0) { + perror("getifaddrs() failed"); + return 1; + } + + while (ifs) { + printf("%-10s ", ifs->ifr_name); + printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifr_addr)->sin_addr)); + printf("NETMASK=%s\n", inet_ntoa(((struct sockaddr_in *)ifs->ifr_netmask)->sin_addr)); + } + return 0; +} +#endif diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 new file mode 100644 index 0000000000..f38827406d --- /dev/null +++ b/source3/lib/replace/getifaddrs.m4 @@ -0,0 +1,94 @@ +AC_CHECK_HEADERS([ifaddrs.h]) + +dnl test for getifaddrs and freeifaddrs +AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ +AC_TRY_COMPILE([ +#include +#include +#include +#include +#include +#include ], +[ +struct ifaddrs *ifp = NULL; +int ret = getifaddrs (&ifp); +freeifaddrs(ifp); +], +samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)]) +if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then + AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) + AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) + AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) +fi + +################## +# look for a method of finding the list of network interfaces +# +# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS" +# +old_CFLAGS=$CFLAGS +old_LIBS=$LIBS +LIBS="$NSL_LIBS $SOCKET_LIBS" +CFLAGS="$CFLAGS -Ilib/replace" +iface=no; +################## +# look for a method of finding the list of network interfaces +iface=no; +AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" +AC_TRY_RUN([ +#define NO_CONFIG_H 1 +#define HAVE_IFACE_GETIFADDRS 1 +#define AUTOCONF_TEST 1 +#include "${srcdir-.}/lib/replace/replace.c" +#include "${srcdir-.}/lib/replace/getifaddrs.c"], + samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) +CPPFLAGS="$SAVE_CPPFLAGS" +if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) +else + LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" +fi + + +if test $iface = no; then +AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[ +AC_TRY_RUN([ +#define HAVE_IFACE_AIX 1 +#define AUTOCONF_TEST 1 +#undef _XOPEN_SOURCE_EXTENDED +#include "${srcdir-.}/lib/replace/getifaddrs.c"], + samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) +if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) +fi +fi + + +if test $iface = no; then +AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ +AC_TRY_RUN([ +#define HAVE_IFACE_IFCONF 1 +#define AUTOCONF_TEST 1 +#include "${srcdir-.}/lib/replace/getifaddrs.c"], + samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)]) +if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) +fi +fi + +if test $iface = no; then +AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[ +AC_TRY_RUN([ +#define HAVE_IFACE_IFREQ 1 +#define AUTOCONF_TEST 1 +#include "${srcdir-.}/lib/replace/getifaddrs.c"], + samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)]) +if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) +fi +fi + +CFLAGS=$old_CFLAGS +LIBS=$old_LIBS diff --git a/source3/lib/replace/libreplace.m4 b/source3/lib/replace/libreplace.m4 index f866b3648f..6d1d6b8afc 100644 --- a/source3/lib/replace/libreplace.m4 +++ b/source3/lib/replace/libreplace.m4 @@ -348,6 +348,7 @@ m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) +m4_include(getifaddrs.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index aff8a841da..61be51744c 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -6,6 +6,7 @@ networking system include wrappers Copyright (C) Andrew Tridgell 2004 + Copyright (C) Jelmer Vernooij 2007 ** NOTE! The following LGPL license applies to the replace ** library. This does NOT imply that all of Samba is released @@ -97,6 +98,30 @@ int rep_inet_pton(int af, const char *src, void *dst); const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif +#ifdef HAVE_IFADDRS_H +#include +#endif + +#ifndef HAVE_STRUCT_IFADDRS +struct ifaddrs { + struct ifaddrs *ifa_next; /* Pointer to next struct */ + char *ifa_name; /* Interface name */ + u_int ifa_flags; /* Interface flags */ + struct sockaddr *ifa_addr; /* Interface address */ + struct sockaddr *ifa_netmask; /* Interface netmask */ + struct sockaddr *ifa_dstaddr; /* P2P interface destination */ + void *ifa_data; /* Address specific data */ +}; +#endif + +#ifndef HAVE_GETIFADDRS +int rep_getifaddrs(struct ifaddrs **); +#endif + +#ifndef HAVE_FREEIFADDRS +int rep_freeifaddrs(struct ifaddrs **); +#endif + /* * Some systems have getaddrinfo but not the * defines needed to use it. -- cgit From d0d4fc5f5412bcf2977afc01edee92107e995c80 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 02:49:52 +0100 Subject: r26468: Match getifaddrs more closely, add trivial test. (cherry picked from commit 92898c043b5a2649a2e423d02bcdaea78ae55737) (This used to be commit 3f9c0c210022905c7811b2e07b3b655929daf930) --- source3/lib/replace/getifaddrs.c | 33 +++++++++++---------------------- source3/lib/replace/test/testsuite.c | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 22 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index 3969535a0b..a4f16ddb76 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -112,7 +112,6 @@ int getifaddrs(struct ifaddrs **ifap) } curif->ifa_name = strdup(ifr[i].ifr_name); - curif->ifa_flags = ifreq.ifr_flags; curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -124,10 +123,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - if (!(ifr[i].ifr_flags & IFF_UP)) { - freeifaddrs(curif); - continue; - } + curif->ifa_flags = ifr[i].ifr_flags; if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) { freeifaddrs(*ifap); @@ -201,6 +197,13 @@ int getifaddrs(struct ifaddrs **ifap) for (i = 0; iifa_next = (*ifap); + } + strioctl.ic_cmd = SIOCGIFFLAGS; strioctl.ic_dp = (char *)&ifreq; strioctl.ic_len = sizeof(struct ifreq); @@ -208,11 +211,9 @@ int getifaddrs(struct ifaddrs **ifap) freeifaddrs(*ifap); return -1; } - - if (!(ifreq.ifr_flags & IFF_UP)) { - continue; - } + curif->ifa_flags = ifreq.ifr_flags; + strioctl.ic_cmd = SIOCGIFADDR; strioctl.ic_dp = (char *)&ifreq; strioctl.ic_len = sizeof(struct ifreq); @@ -221,15 +222,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - curif = calloc(1, sizeof(struct ifaddrs)); - if (lastif == NULL) { - *ifap = curif; - } else { - lastif->ifa_next = (*ifap); - } - curif->ifa_name = strdup(ifreq.ifr_name); - curif->ifa_flags = ifreq.ifr_flags; curif->ifa_addr = sockaddr_dup(&ifreq.ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -310,7 +303,6 @@ int getifaddrs(struct ifaddrs **ifap) } curif->ifa_name = strdup(ifr->ifr_name); - curif->ifa_flags = ifr->ifr_flags; curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -322,10 +314,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - if (!(ifr->ifr_flags & IFF_UP)) { - freeaddrinfo(curif); - continue; - } + curif->ifa_flags = ifr->ifr_flags; if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { freeaddrinfo(*ifap); diff --git a/source3/lib/replace/test/testsuite.c b/source3/lib/replace/test/testsuite.c index 5b95ae395c..c9f3301005 100644 --- a/source3/lib/replace/test/testsuite.c +++ b/source3/lib/replace/test/testsuite.c @@ -856,6 +856,25 @@ static int test_strptime(void) return libreplace_test_strptime(); } +static int test_getifaddrs(void) +{ + struct ifaddrs *ifa; + int ret; + + printf("test: getifaddrs\n"); + + ret = getifaddrs(&ifa); + if (ret != 0) { + printf("failure: getifaddrs\n"); + return false; + } + + freeifaddrs(ifa); + + printf("success: getifaddrs\n"); + return true; +} + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -903,6 +922,7 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_MAX(); ret &= test_socketpair(); ret &= test_strptime(); + ret &= test_getifaddrs(); return ret; } -- cgit From 7728a23d43a79eefaf2cc7e1998283e3d1e095f8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 03:22:13 +0100 Subject: r26469: Fix paths, only include IPv4 addresses for now. (cherry picked from commit fa9e3b6fa871b7541878f836ea54e882e614a3cf) (This used to be commit a2d6f6b4ae7fb6711d4228b9e255eebb6bf344bd) --- source3/lib/replace/getifaddrs.c | 21 +++++++++++++-------- source3/lib/replace/getifaddrs.m4 | 13 +++++-------- source3/lib/replace/system/network.h | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index a4f16ddb76..e04c023209 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -360,20 +360,25 @@ int getifaddrs(struct ifaddrs **ifap) int main() { - struct ifaddrs *ifs; - int total = get_interfaces(ifaces, MAX_INTERFACES); - int i; - - int ret = getifaddrs(&ifs); + struct ifaddrs *ifs = NULL; + int ret; + + ret = getifaddrs(&ifs); if (ret != 0) { perror("getifaddrs() failed"); return 1; } while (ifs) { - printf("%-10s ", ifs->ifr_name); - printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifr_addr)->sin_addr)); - printf("NETMASK=%s\n", inet_ntoa(((struct sockaddr_in *)ifs->ifr_netmask)->sin_addr)); + printf("%-10s ", ifs->ifa_name); + if (ifs->ifa_addr != NULL && + ifs->ifa_addr->sa_family == AF_INET) { + printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifa_addr)->sin_addr)); + if (ifs->ifa_netmask != NULL) + printf("NETMASK=%s", inet_ntoa(((struct sockaddr_in *)ifs->ifa_netmask)->sin_addr)); + } + printf("\n"); + ifs = ifs->ifa_next; } return 0; } diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index f38827406d..7e6016ed8f 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -26,10 +26,8 @@ fi # # This tests need LIBS="$NSL_LIBS $SOCKET_LIBS" # -old_CFLAGS=$CFLAGS old_LIBS=$LIBS LIBS="$NSL_LIBS $SOCKET_LIBS" -CFLAGS="$CFLAGS -Ilib/replace" iface=no; ################## # look for a method of finding the list of network interfaces @@ -41,8 +39,8 @@ AC_TRY_RUN([ #define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 #define AUTOCONF_TEST 1 -#include "${srcdir-.}/lib/replace/replace.c" -#include "${srcdir-.}/lib/replace/getifaddrs.c"], +#include "$libreplacedir/replace.c" +#include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) CPPFLAGS="$SAVE_CPPFLAGS" if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then @@ -58,7 +56,7 @@ AC_TRY_RUN([ #define HAVE_IFACE_AIX 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED -#include "${srcdir-.}/lib/replace/getifaddrs.c"], +#include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) @@ -71,7 +69,7 @@ AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ #define HAVE_IFACE_IFCONF 1 #define AUTOCONF_TEST 1 -#include "${srcdir-.}/lib/replace/getifaddrs.c"], +#include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) @@ -83,12 +81,11 @@ AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ #define HAVE_IFACE_IFREQ 1 #define AUTOCONF_TEST 1 -#include "${srcdir-.}/lib/replace/getifaddrs.c"], +#include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) fi fi -CFLAGS=$old_CFLAGS LIBS=$old_LIBS diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index 61be51744c..0b5fbcddd1 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -106,7 +106,7 @@ const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); struct ifaddrs { struct ifaddrs *ifa_next; /* Pointer to next struct */ char *ifa_name; /* Interface name */ - u_int ifa_flags; /* Interface flags */ + unsigned int ifa_flags; /* Interface flags */ struct sockaddr *ifa_addr; /* Interface address */ struct sockaddr *ifa_netmask; /* Interface netmask */ struct sockaddr *ifa_dstaddr; /* P2P interface destination */ -- cgit From 621983ed6d110fdc24215ba2963fcd93316accce Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 14:50:11 +0100 Subject: r26470: Update README. (cherry picked from commit 51a78cfc3e72d6b32ef6c7a6079165a36863b908) (This used to be commit 556b6b9a2fe5dd9da85b1605d91a7216a6c6d308) --- source3/lib/replace/README | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/README b/source3/lib/replace/README index c61f78a951..268a1b15cf 100644 --- a/source3/lib/replace/README +++ b/source3/lib/replace/README @@ -60,6 +60,8 @@ getaddrinfo freeaddrinfo getnameinfo gai_strerror +getifaddrs +freeifaddrs Types: bool -- cgit From 1de665002c4f3f495214659143736baeeda8ec60 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 05:53:37 +0100 Subject: r26487: Cope with systems that don't have struct sockaddr.sa_len. (cherry picked from commit 56080469ab28ae5a2f456cced34814d9c33480c6) (This used to be commit ce222d07ba73b34894454e4fcb43046f0f22c0e7) --- source3/lib/replace/getifaddrs.c | 11 +++++++++-- source3/lib/replace/getifaddrs.m4 | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index e04c023209..b681a8649c 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -53,10 +53,17 @@ void freeifaddrs(struct ifaddrs *ifp) struct sockaddr *sockaddr_dup(struct sockaddr *sa) { - struct sockaddr *ret = calloc(1, sa->sa_len); + struct sockaddr *ret; + socklen_t socklen; +#ifdef HAVE_SOCKADDR_SA_LEN + socklen = sa->sa_len; +#else + socklen = sizeof(struct sockaddr_storage); +#endif + ret = = calloc(1, socklen); if (ret == NULL) return NULL; - memcpy(ret, sa, sa->sa_len); + memcpy(ret, sa, socklen); return ret; } #endif diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 7e6016ed8f..85f08ee6c3 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -1,5 +1,11 @@ AC_CHECK_HEADERS([ifaddrs.h]) +dnl Used when getifaddrs is not available +AC_CHECK_MEMBERS([struct sockaddr.sa_len], + [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])], + [], + [#include ]) + dnl test for getifaddrs and freeifaddrs AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ -- cgit From 5fb2d5b0863e507c43462eb3913f2a16ef14c52a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 06:30:50 +0100 Subject: r26491: Fix syntax. (cherry picked from commit 2513230e286179747bb84e4e87121b80bea8f3f0) (This used to be commit d9c3b27c3fafb3adb7bc6521f5be97aec7fe8bfc) --- source3/lib/replace/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index b681a8649c..c9b5c2f6ef 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -60,7 +60,7 @@ struct sockaddr *sockaddr_dup(struct sockaddr *sa) #else socklen = sizeof(struct sockaddr_storage); #endif - ret = = calloc(1, socklen); + ret = calloc(1, socklen); if (ret == NULL) return NULL; memcpy(ret, sa, socklen); -- cgit From ea9ce8f9ac44867403673012cd0979f21cf50a27 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 06:57:30 +0100 Subject: r26492: Some hosts have a define called ifa_dstaddr. (cherry picked from commit c4cd935ee783b2f4939e2c481bbdb1bbdb9190cd) (This used to be commit 839d128a42aa624e3cd978700059f947022ee733) --- source3/lib/replace/system/network.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index 0b5fbcddd1..e03c991b3c 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -109,6 +109,7 @@ struct ifaddrs { unsigned int ifa_flags; /* Interface flags */ struct sockaddr *ifa_addr; /* Interface address */ struct sockaddr *ifa_netmask; /* Interface netmask */ +#undef ifa_dstaddr struct sockaddr *ifa_dstaddr; /* P2P interface destination */ void *ifa_data; /* Address specific data */ }; -- cgit From 1caa9cbd9dd1449c00fa431e129e1d070f4aac80 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 07:45:05 +0100 Subject: r26495: Add defines for getifaddrs/freeifaddrs. (cherry picked from commit c9e5a3078f7baa83743658d5648f0eefdeb05d2f) (This used to be commit f2f552106820d1a8f07bccc1a3ad9b45582c8b30) --- source3/lib/replace/replace.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/replace.h b/source3/lib/replace/replace.h index 1d1cbc2cd2..3f91544e97 100644 --- a/source3/lib/replace/replace.h +++ b/source3/lib/replace/replace.h @@ -340,6 +340,16 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) /* prototype is in "system/network.h" */ #endif +#ifndef HAVE_GETIFADDRS +#define getifaddrs rep_getifaddrs +/* prototype is in "system/network.h" */ +#endif + +#ifndef HAVE_FREEIFADDRS +#define freeifaddrs rep_freeifaddrs +/* prototype is in "system/network.h" */ +#endif + #ifdef HAVE_LIMITS_H #include #endif -- cgit From f822f4150b2b04619d68686ffdb72e82310a7175 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 08:20:29 +0100 Subject: r26497: Fix return type for freeifaddrs(). (cherry picked from commit 8c65053f51330bb55a81572264eefbcc56029dc1) (This used to be commit 57587e49f5942b81508b40e3c9a67e7536f2271d) --- source3/lib/replace/getifaddrs.c | 12 ++++++------ source3/lib/replace/system/network.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index c9b5c2f6ef..4037d647d7 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -40,7 +40,7 @@ #define _FOUND_IFACE_ANY #else -void freeifaddrs(struct ifaddrs *ifp) +void rep_freeifaddrs(struct ifaddrs *ifp) { free(ifp->ifa_name); free(ifp->ifa_addr); @@ -51,7 +51,7 @@ void freeifaddrs(struct ifaddrs *ifp) free(ifp); } -struct sockaddr *sockaddr_dup(struct sockaddr *sa) +static struct sockaddr *sockaddr_dup(struct sockaddr *sa) { struct sockaddr *ret; socklen_t socklen; @@ -75,7 +75,7 @@ struct sockaddr *sockaddr_dup(struct sockaddr *sa) It probably also works on any BSD style system. */ -int getifaddrs(struct ifaddrs **ifap) +int rep_getifaddrs(struct ifaddrs **ifap) { struct ifconf ifc; char buff[8192]; @@ -159,7 +159,7 @@ int getifaddrs(struct ifaddrs **ifap) this should cover most of the streams based systems Thanks to Andrej.Borsenkow@mow.siemens.ru for several ideas in this code ****************************************************************************/ -int getifaddrs(struct ifaddrs **ifap) +int rep_getifaddrs(struct ifaddrs **ifap) { struct ifreq ifreq; struct strioctl strioctl; @@ -261,7 +261,7 @@ int getifaddrs(struct ifaddrs **ifap) /**************************************************************************** this one is for AIX (tested on 4.2) ****************************************************************************/ -int getifaddrs(struct ifaddrs **ifap) +int rep_getifaddrs(struct ifaddrs **ifap) { char buff[8192]; int fd, i; @@ -355,7 +355,7 @@ int getifaddrs(struct ifaddrs **ifap) #define _FOUND_IFACE_ANY #endif /* HAVE_IFACE_AIX */ #ifndef _FOUND_IFACE_ANY -int getifaddrs(struct ifaddrs **ifap) +int rep_getifaddrs(struct ifaddrs **ifap) { errno = ENOSYS; return -1; diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index e03c991b3c..fa5ec9a680 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -120,7 +120,7 @@ int rep_getifaddrs(struct ifaddrs **); #endif #ifndef HAVE_FREEIFADDRS -int rep_freeifaddrs(struct ifaddrs **); +void rep_freeifaddrs(struct ifaddrs **); #endif /* -- cgit From f75d7a69927960ddcc81a31084b1cc11d96838ff Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 12:27:59 +0100 Subject: r26507: Fix function signature for freeifaddrs. (cherry picked from commit cc873bdd2e86e5b380c3056810ccc5ad98372f7c) (This used to be commit ccfb04d18516e0aca88ea0a96afe119175bddba7) --- source3/lib/replace/system/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index fa5ec9a680..d09e3f71f8 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -120,7 +120,7 @@ int rep_getifaddrs(struct ifaddrs **); #endif #ifndef HAVE_FREEIFADDRS -void rep_freeifaddrs(struct ifaddrs **); +void rep_freeifaddrs(struct ifaddrs *); #endif /* -- cgit From 5dd51159df0984ad876ed9a582454783130e529f Mon Sep 17 00:00:00 2001 From: James Peach Date: Thu, 20 Dec 2007 16:35:42 +0100 Subject: r26551: Make sure NULL is defined before using it to test for getifaddrs(). Patch from Timur I. Bakeyev . (cherry picked from commit 188156228b53c4bbc9c18c6ff1a0d3c6d0ba5fcb) (This used to be commit b4a2ec01fc3c8174cba2a7bda876270fcce90491) --- source3/lib/replace/getifaddrs.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 85f08ee6c3..30b9d0264f 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -11,6 +11,10 @@ AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ #include #include +#if STDC_HEADERS +#include +#include +#endif #include #include #include -- cgit From c4265bd3e8acaf8a7f5ce55b0845fd893d86037f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Dec 2007 17:07:31 +0100 Subject: r26554: Fix test for getifaddr on FreeBSD. Patch by Timur Bakeyev. (cherry picked from commit 37c7b65546190bdce40cb48435cc4fd51d89a124) (This used to be commit bc523382aef16b1260799000650bbebe132799eb) --- source3/lib/replace/getifaddrs.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 30b9d0264f..297a82d0c3 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -9,12 +9,12 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len], dnl test for getifaddrs and freeifaddrs AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ -#include #include #if STDC_HEADERS #include #include #endif +#include #include #include #include -- cgit From 3e02cdcaa8c5aae480025ca61efd2d4286cd3104 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 17:25:42 +0100 Subject: Remove relict SAMBA_CONFIGURE_CPPFLAGS from lib/replace. Michael (cherry picked from commit d10cbb533c18a6d74160477d34a81bbd4cd6c7c8) (This used to be commit 12e5b9b406d111834c013cbbfe63b759a969ec8e) --- source3/lib/replace/getifaddrs.m4 | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 297a82d0c3..4259d1a7a3 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -43,8 +43,6 @@ iface=no; # look for a method of finding the list of network interfaces iface=no; AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" AC_TRY_RUN([ #define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 @@ -52,7 +50,6 @@ AC_TRY_RUN([ #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) -CPPFLAGS="$SAVE_CPPFLAGS" if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) else -- cgit From 89ad7e4ed1fb601c085282fe1622a2d055991dbb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 22:29:34 +0100 Subject: libreplace: Remove double item in case statement. This was by accident introduced in cherry-pick commit 7a7dcd9b1265b8f031c9a5e9c4cfa89216827a28: This tiny portion had already been ported in 64ff1dad8664f14030c7d78c252d946216798a88. MIchael (This used to be commit 69b2ebc797fa986bf395f4d045ea663240e9ec2c) --- source3/lib/replace/libreplace_ld.m4 | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/libreplace_ld.m4 b/source3/lib/replace/libreplace_ld.m4 index 08defb091f..f0d10c1e3e 100644 --- a/source3/lib/replace/libreplace_ld.m4 +++ b/source3/lib/replace/libreplace_ld.m4 @@ -246,10 +246,6 @@ AC_DEFUN([AC_LD_SONAMEFLAG], # Not supported SONAMEFLAG="#" ;; - *aix*) - # Not supported - SONAMEFLAG="#" - ;; esac ]) -- cgit From 31a356420d22c5babb40946355bb33a83294fe16 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 00:17:31 +0100 Subject: configure: Use SAMBA_CONFIGURE_CPPFLAGS for AC_LIBREPLACE_BROKEN_CHECKS. To fix the build (make test) after merging libreplace changes. Michael (This used to be commit af5ec88ece3ecca2b3c5d6585deec10fe851339b) --- source3/configure.in | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 6ff1df2cec..afe68d7613 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -685,8 +685,13 @@ exit(1); esac +SAVE_CPPFLAGS="${CPPFLAGS}" +CPPFLAGS="${CPPFLAGS} ${SAMBA_CONFIGURE_CPPFLAGS}" + AC_LIBREPLACE_BROKEN_CHECKS +CPPFLAGS="${SAVE_CPPFLAGS}" + LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"` LIBREPLACE_OBJS="" -- cgit From 9e5be586afd52c208d40e25b71cee622c5eafa7a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 00:44:40 +0100 Subject: Remove the getifaddrs checks from configure.in: they are now in lib/replace. Michael (This used to be commit 53c9098253f5a7f84ea8079a755b9d4f0b28fb2c) --- source3/configure.in | 96 ---------------------------------------------------- 1 file changed, 96 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index afe68d7613..6b9131c347 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2736,102 +2736,6 @@ SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN) SMB_CHECK_SYSCONF(_SC_PAGESIZE) AC_CHECK_FUNCS(getpagesize) -dnl test for getifaddrs and freeifaddrs -AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ -AC_TRY_COMPILE([ -#include -#include -#include -#include -#include -#include ], -[ -struct ifaddrs *ifp = NULL; -int ret = getifaddrs (&ifp); -freeifaddrs(ifp); -], -samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)]) -if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then - AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) - AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) -fi - -################## -# look for a method of finding the list of network interfaces -iface=no; -AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" -AC_TRY_RUN([ -#define NO_CONFIG_H 1 -#define HAVE_IFACE_GETIFADDRS 1 -#define AUTOCONF_TEST 1 -#include "${srcdir-.}/lib/replace/replace.c" -#include "${srcdir-.}/lib/interfaces.c"], - samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) -CPPFLAGS="$SAVE_CPPFLAGS" -if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) -fi - -if test $iface = no; then -AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" -AC_TRY_RUN([ -#define NO_CONFIG_H 1 -#define HAVE_IFACE_IFCONF 1 -#define AUTOCONF_TEST 1 -#define SOCKET_WRAPPER_NOT_REPLACE -#include "${srcdir-.}/lib/replace/replace.c" -#include "${srcdir-.}/lib/interfaces.c"], - samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)]) -CPPFLAGS="$SAVE_CPPFLAGS" -if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) -fi -fi - -if test $iface = no; then -AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" -AC_TRY_RUN([ -#define NO_CONFIG_H 1 -#define HAVE_IFACE_IFREQ 1 -#define AUTOCONF_TEST 1 -#define SOCKET_WRAPPER_NOT_REPLACE -#include "${srcdir-.}/lib/replace/replace.c" -#include "${srcdir-.}/lib/replace/getaddrinfo.c" -#include "${srcdir-.}/lib/replace/snprintf.c" -#include "${srcdir-.}/lib/interfaces.c"], - samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)]) -CPPFLAGS="$SAVE_CPPFLAGS" -if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) -fi -fi - -if test $iface = no; then -AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" -AC_TRY_RUN([ -#define NO_CONFIG_H 1 -#define HAVE_IFACE_AIX 1 -#define AUTOCONF_TEST 1 -#undef _XOPEN_SOURCE_EXTENDED -#define SOCKET_WRAPPER_NOT_REPLACE -#include "${srcdir-.}/lib/replace/replace.c" -#include "${srcdir-.}/lib/replace/snprintf.c" -#include "${srcdir-.}/lib/interfaces.c"], - samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) -CPPFLAGS="$SAVE_CPPFLAGS" -if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) -fi -fi - dnl test for ipv6 AC_CACHE_CHECK([for ipv6 support],samba_cv_HAVE_IPV6,[ AC_TRY_COMPILE([ -- cgit From b277aa2893701b700eedfac8fe89d6fb6987e576 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:43:37 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in getifaddrs.m4 Michael (cherry picked from commit acab9def2a1e3460bef8baae6efc66d9dfad6eac) (This used to be commit f790cb4aedee58abe6324c47912b58a808bfca51) --- source3/lib/replace/getifaddrs.m4 | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 4259d1a7a3..4cf86d89cc 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -7,7 +7,7 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len], [#include ]) dnl test for getifaddrs and freeifaddrs -AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ +AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ #include #if STDC_HEADERS @@ -24,8 +24,8 @@ struct ifaddrs *ifp = NULL; int ret = getifaddrs (&ifp); freeifaddrs(ifp); ], -samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)]) -if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then +libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)]) +if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) @@ -42,15 +42,15 @@ iface=no; ################## # look for a method of finding the list of network interfaces iface=no; -AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ +AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ AC_TRY_RUN([ #define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) -if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then + libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) else LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" @@ -58,39 +58,39 @@ fi if test $iface = no; then -AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[ +AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ #define HAVE_IFACE_AIX 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) -if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then + libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) fi fi if test $iface = no; then -AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ +AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ #define HAVE_IFACE_IFCONF 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)]) -if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then + libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) fi fi if test $iface = no; then -AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[ +AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ #define HAVE_IFACE_IFREQ 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)]) -if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then + libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) fi fi -- cgit From 2356cc6586253a6e5dc5584e9df57cdc02873225 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:46:20 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in getpass.m4. Michael (cherry picked from commit d3b3d3ec9ff64108b4cd5b7c912ab4ea207256cb) (This used to be commit d6719f1c2f349c34d7a14e8e0e264db8dbe48598) --- source3/lib/replace/getpass.m4 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getpass.m4 b/source3/lib/replace/getpass.m4 index c4da9aae59..b93817f9d3 100644 --- a/source3/lib/replace/getpass.m4 +++ b/source3/lib/replace/getpass.m4 @@ -1,22 +1,22 @@ -AC_CHECK_FUNC(getpass, samba_cv_HAVE_GETPASS=yes) -AC_CHECK_FUNC(getpassphrase, samba_cv_HAVE_GETPASSPHRASE=yes) -if test x"$samba_cv_HAVE_GETPASS" = x"yes" -a x"$samba_cv_HAVE_GETPASSPHRASE" = x"yes"; then +AC_CHECK_FUNC(getpass, libreplace_cv_HAVE_GETPASS=yes) +AC_CHECK_FUNC(getpassphrase, libreplace_cv_HAVE_GETPASSPHRASE=yes) +if test x"$libreplace_cv_HAVE_GETPASS" = x"yes" -a x"$libreplace_cv_HAVE_GETPASSPHRASE" = x"yes"; then AC_DEFINE(REPLACE_GETPASS_BY_GETPASSPHRASE, 1, [getpass returns <9 chars where getpassphrase returns <265 chars]) AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" else -AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[ +AC_CACHE_CHECK([whether getpass should be replaced],libreplace_cv_REPLACE_GETPASS,[ SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$libreplacedir/" AC_TRY_COMPILE([ #include "confdefs.h" #define NO_CONFIG_H #include "$libreplacedir/getpass.c" -],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no) +],[],libreplace_cv_REPLACE_GETPASS=yes,libreplace_cv_REPLACE_GETPASS=no) CPPFLAGS="$SAVE_CPPFLAGS" ]) -if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then +if test x"$libreplace_cv_REPLACE_GETPASS" = x"yes"; then AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" fi -- cgit From 9ba696cb68a9c16bc2d55ac07df0b1ee626d6261 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:49:30 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in system/config.m4. Michael (cherry picked from commit 00c173bfba9c659750bf231fbd9278dd38aa8bfc) (This used to be commit 450034582ba78b296e9cacc9ea06b632196b8644) --- source3/lib/replace/system/config.m4 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/system/config.m4 b/source3/lib/replace/system/config.m4 index 1c05733126..66c2bd652a 100644 --- a/source3/lib/replace/system/config.m4 +++ b/source3/lib/replace/system/config.m4 @@ -18,7 +18,7 @@ AC_CHECK_HEADERS(sys/capability.h) case "$host_os" in *linux*) -AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ +AC_CACHE_CHECK([for broken RedHat 7.2 system header files],libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ AC_TRY_COMPILE([ #ifdef HAVE_SYS_VFS_H #include @@ -29,14 +29,14 @@ AC_TRY_COMPILE([ ],[ int i; ], - samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, - samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes + libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, + libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes )]) -if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then +if test x"$libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files]) fi -AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ +AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ AC_TRY_COMPILE([ #ifdef HAVE_SYS_CAPABILITY_H #include @@ -45,10 +45,10 @@ AC_TRY_COMPILE([ ],[ __s8 i; ], - samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, - samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes + libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, + libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes )]) -if test x"$samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then +if test x"$libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then AC_DEFINE(BROKEN_RHEL5_SYS_CAP_HEADER,1,[Broken RHEL5 sys/capability.h]) fi ;; -- cgit From 3ac36c3caf84c9169930def25bf8ca06c98df9c6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:53:07 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in libreplace.m4. Michael (cherry picked from commit 83387ecccfe95b80525bf53c5fc9e945ffee10ec) (This used to be commit 12ec7dfb109bedd7b086702394a7094a4853cf1f) --- source3/lib/replace/libreplace.m4 | 72 +++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/libreplace.m4 b/source3/lib/replace/libreplace.m4 index 6d1d6b8afc..2e0cd34f4a 100644 --- a/source3/lib/replace/libreplace.m4 +++ b/source3/lib/replace/libreplace.m4 @@ -85,10 +85,10 @@ AC_INCLUDES_DEFAULT #endif] ) -AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[ +AC_CACHE_CHECK([for working mmap],libreplace_cv_HAVE_MMAP,[ AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"], - samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)]) -if test x"$samba_cv_HAVE_MMAP" = x"yes"; then + libreplace_cv_HAVE_MMAP=yes,libreplace_cv_HAVE_MMAP=no,libreplace_cv_HAVE_MMAP=cross)]) +if test x"$libreplace_cv_HAVE_MMAP" = x"yes"; then AC_DEFINE(HAVE_MMAP,1,[Whether mmap works]) fi @@ -120,7 +120,7 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) fi -AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ +AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include #include @@ -133,8 +133,8 @@ main() { struct in_addr ip; ip.s_addr = 0x12345678; if (strcmp(inet_ntoa(ip),"18.52.86.120") && strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } exit(1);}], - samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)]) -if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then + libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) +if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi @@ -182,7 +182,7 @@ AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) -AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ +AC_CACHE_CHECK([for secure mkstemp],libreplace_cv_HAVE_SECURE_MKSTEMP,[ AC_TRY_RUN([#include #include #include @@ -197,10 +197,10 @@ main() { if ((st.st_mode & 0777) != 0600) exit(1); exit(0); }], -samba_cv_HAVE_SECURE_MKSTEMP=yes, -samba_cv_HAVE_SECURE_MKSTEMP=no, -samba_cv_HAVE_SECURE_MKSTEMP=cross)]) -if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then +libreplace_cv_HAVE_SECURE_MKSTEMP=yes, +libreplace_cv_HAVE_SECURE_MKSTEMP=no, +libreplace_cv_HAVE_SECURE_MKSTEMP=cross)]) +if test x"$libreplace_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure]) fi @@ -209,7 +209,7 @@ AC_CHECK_HEADERS(stdio.h strings.h) AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf]) AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) -AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ +AC_CACHE_CHECK([for C99 vsnprintf],libreplace_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include #include @@ -243,43 +243,43 @@ void foo(const char *format, ...) { } main() { foo("hello"); } ], -samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)]) -if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then +libreplace_cv_HAVE_C99_VSNPRINTF=yes,libreplace_cv_HAVE_C99_VSNPRINTF=no,libreplace_cv_HAVE_C99_VSNPRINTF=cross)]) +if test x"$libreplace_cv_HAVE_C99_VSNPRINTF" = x"yes"; then AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) fi dnl VA_COPY -AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ +AC_CACHE_CHECK([for va_copy],libreplace_cv_HAVE_VA_COPY,[ AC_TRY_LINK([#include va_list ap1,ap2;], [va_copy(ap1,ap2);], -samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)]) -if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then +libreplace_cv_HAVE_VA_COPY=yes,libreplace_cv_HAVE_VA_COPY=no)]) +if test x"$libreplace_cv_HAVE_VA_COPY" = x"yes"; then AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) fi -if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then -AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[ +if test x"$libreplace_cv_HAVE_VA_COPY" != x"yes"; then +AC_CACHE_CHECK([for __va_copy],libreplace_cv_HAVE___VA_COPY,[ AC_TRY_LINK([#include va_list ap1,ap2;], [__va_copy(ap1,ap2);], -samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)]) -if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then +libreplace_cv_HAVE___VA_COPY=yes,libreplace_cv_HAVE___VA_COPY=no)]) +if test x"$libreplace_cv_HAVE___VA_COPY" = x"yes"; then AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) fi fi dnl __FUNCTION__ macro -AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[ +AC_CACHE_CHECK([for __FUNCTION__ macro],libreplace_cv_HAVE_FUNCTION_MACRO,[ AC_TRY_COMPILE([#include ], [printf("%s\n", __FUNCTION__);], -samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)]) -if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then +libreplace_cv_HAVE_FUNCTION_MACRO=yes,libreplace_cv_HAVE_FUNCTION_MACRO=no)]) +if test x"$libreplace_cv_HAVE_FUNCTION_MACRO" = x"yes"; then AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) else dnl __func__ macro - AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[ + AC_CACHE_CHECK([for __func__ macro],libreplace_cv_HAVE_func_MACRO,[ AC_TRY_COMPILE([#include ], [printf("%s\n", __func__);], - samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)]) - if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then + libreplace_cv_HAVE_func_MACRO=yes,libreplace_cv_HAVE_func_MACRO=no)]) + if test x"$libreplace_cv_HAVE_func_MACRO" = x"yes"; then AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro]) fi fi @@ -302,7 +302,7 @@ eprintf("bla", "bar"); ], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available])) -AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ +AC_CACHE_CHECK([for sig_atomic_t type],libreplace_cv_sig_atomic_t, [ AC_TRY_COMPILE([ #include #if STDC_HEADERS @@ -310,30 +310,30 @@ AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ #include #endif #include ],[sig_atomic_t i = 0], - samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)]) -if test x"$samba_cv_sig_atomic_t" = x"yes"; then + libreplace_cv_sig_atomic_t=yes,libreplace_cv_sig_atomic_t=no)]) +if test x"$libreplace_cv_sig_atomic_t" = x"yes"; then AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) fi -AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[ +AC_CACHE_CHECK([for O_DIRECT flag to open(2)],libreplace_cv_HAVE_OPEN_O_DIRECT,[ AC_TRY_COMPILE([ #include #ifdef HAVE_FCNTL_H #include #endif], [int fd = open("/dev/null", O_DIRECT);], -samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)]) -if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then +libreplace_cv_HAVE_OPEN_O_DIRECT=yes,libreplace_cv_HAVE_OPEN_O_DIRECT=no)]) +if test x"$libreplace_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT]) fi dnl Check if the C compiler understands volatile (it should, being ANSI). -AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [ +AC_CACHE_CHECK([that the C compiler understands volatile],libreplace_cv_volatile, [ AC_TRY_COMPILE([#include ],[volatile int i = 0], - samba_cv_volatile=yes,samba_cv_volatile=no)]) -if test x"$samba_cv_volatile" = x"yes"; then + libreplace_cv_volatile=yes,libreplace_cv_volatile=no)]) +if test x"$libreplace_cv_volatile" = x"yes"; then AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile]) fi -- cgit From 4f5a88806733161f1b93ac3c9ca9b9248bbe0707 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 17:26:39 +0100 Subject: Remove tests for vsnprintf snprintf asprintf vasprintf and va_copy from configure. These are tested in libreplace. Michael (This used to be commit 9b9495d3672e3a8e74d153dbef62825e6b5d5170) --- source3/configure.in | 54 +--------------------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 6b9131c347..e218c0b2b0 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -907,10 +907,6 @@ fi AC_HAVE_DECL(errno, [#include ]) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) -AC_HAVE_DECL(asprintf, [#include ]) -AC_HAVE_DECL(vasprintf, [#include ]) -AC_HAVE_DECL(vsnprintf, [#include ]) -AC_HAVE_DECL(snprintf, [#include ]) # and glibc has setresuid under linux but the function does # nothing until kernel 2.1.44! very dumb. @@ -1062,7 +1058,7 @@ AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strerror chown fchown lchow AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtouq __strtoull) AC_CHECK_FUNCS(fstat strchr utime utimes chflags) AC_CHECK_FUNCS(getrlimit fsync fdatasync memset strlcpy strlcat setpgid) -AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid) +AC_CHECK_FUNCS(memmove setsid glob strpbrk pipe crypt16 getauthuid) AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent) AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath) AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64) @@ -2032,54 +2028,6 @@ if test x"$samba_cv_WITH_PROFILE" = x"yes"; then fi -AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ -AC_TRY_LINK([#include -va_list ap1,ap2;], [va_copy(ap1,ap2);], -samba_cv_HAVE_VA_COPY=yes, -samba_cv_HAVE_VA_COPY=no)]) -if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then - AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) -else - AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[ - AC_TRY_LINK([#include - va_list ap1,ap2;], [__va_copy(ap1,ap2);], - samba_cv_HAVE___VA_COPY=yes, - samba_cv_HAVE___VA_COPY=no)]) - if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then - AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) - fi -fi - -AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ -AC_TRY_RUN([ -#include -#include -void foo(const char *format, ...) { - va_list ap; - int len; - char buf[5]; - - va_start(ap, format); - len = vsnprintf(buf, 0, format, ap); - va_end(ap); - if (len != 5) exit(1); - - va_start(ap, format); - len = vsnprintf(0, 0, format, ap); - va_end(ap); - if (len != 5) exit(1); - - if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); - - exit(0); -} -main() { foo("hello"); } -], -samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)]) -if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then - AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) -fi - AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[ AC_TRY_RUN([#include #include -- cgit From 9c3f0170b396bafae33bf922d3aea00dda14bb61 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 20:05:51 +0100 Subject: Support dlopen(NULL, ...) on HPUX. (cherry picked from commit 53c70b5f77a3b9abaab783590e66278129173d5f) (This used to be commit 8883ee2418152d58e2ce609e02105e009f8ca4e8) --- source3/lib/replace/dlfcn.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/dlfcn.c b/source3/lib/replace/dlfcn.c index 42848848e8..3b109d7e40 100644 --- a/source3/lib/replace/dlfcn.c +++ b/source3/lib/replace/dlfcn.c @@ -35,6 +35,8 @@ void *rep_dlopen(const char *name, int flags) #endif { #ifdef HAVE_SHL_LOAD + if (name == NULL) + return PROG_HANDLE; return (void *)shl_load(name, flags, 0); #else return NULL; -- cgit From e0f4573de2008c6f0ba09c1f633d2213794a4208 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 17:56:21 +0100 Subject: Remove checks for ino_t, loff_t, offset_t, and comparison_fn_t from configure.in. These tests are in libreplace. Michael (This used to be commit 2e6b66eda4dc30f03f1309a1dbef3eb87a4f7d1e) --- source3/configure.in | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index e218c0b2b0..b707ac8eec 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -792,13 +792,8 @@ AC_TYPE_SIZE_T AC_TYPE_PID_T AC_STRUCT_ST_RDEV AC_DIRENT_D_OFF -AC_CHECK_TYPE(ino_t,unsigned) -AC_CHECK_TYPE(loff_t,off_t) -AC_CHECK_TYPE(offset_t,loff_t) AC_CHECK_TYPE(ssize_t, int) AC_CHECK_TYPE(wchar_t, unsigned short) -AC_CHECK_TYPE(comparison_fn_t, -[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) ############################################ # for cups support we need libcups, and a handful of header files -- cgit From 443f8ed26050b515b7786ea72e5dd747e976aa11 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 21:33:06 +0100 Subject: configure: Move assemblage of samba version strings to m4 include file. Michael (This used to be commit 8b220717e8dd62455716d4aaf6728087d04fb71b) --- source3/configure.in | 20 +------------------- source3/m4/samba_version.m4 | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 source3/m4/samba_version.m4 (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index b707ac8eec..4a798bde62 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -18,25 +18,7 @@ esac builddir=`pwd` AC_SUBST(builddir) -SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2` -echo "SAMBA VERSION: ${SMB_VERSION_STRING}" - -SAMBA_VERSION_GIT_COMMIT_FULLREV=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_FULLREV' | cut -d ' ' -f3- | cut -d '"' -f2` -if test -n "${SAMBA_VERSION_GIT_COMMIT_FULLREV}";then - echo "BUILD COMMIT REVISION: ${SAMBA_VERSION_GIT_COMMIT_FULLREV}" -fi -SAMBA_VERSION_GIT_COMMIT_DATE=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_DATE' | cut -d ' ' -f3-` -if test -n "${SAMBA_VERSION_GIT_COMMIT_DATE}";then - echo "BUILD COMMIT DATE: ${SAMBA_VERSION_GIT_COMMIT_DATE}" -fi -SAMBA_VERSION_GIT_COMMIT_TIME=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_TIME' | cut -d ' ' -f3-` -if test -n "${SAMBA_VERSION_GIT_COMMIT_TIME}";then - echo "BUILD COMMIT TIME: ${SAMBA_VERSION_GIT_COMMIT_TIME}" - - # just to keep the build-farm gui happy for now... - echo "BUILD REVISION: ${SAMBA_VERSION_GIT_COMMIT_TIME}" -fi - +m4_include(m4/samba_version.m4) m4_include(m4/check_path.m4) AC_LIBREPLACE_CC_CHECKS diff --git a/source3/m4/samba_version.m4 b/source3/m4/samba_version.m4 new file mode 100644 index 0000000000..4d749e9bb9 --- /dev/null +++ b/source3/m4/samba_version.m4 @@ -0,0 +1,29 @@ +dnl +dnl Samba3 build environment - Samba version variables +dnl +dnl Copyright (C) Michael Adam 2008 +dnl +dnl Released under the GNU General Public License +dnl http://www.gnu.org/licenses/ +dnl +dnl + +SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2` +echo "SAMBA VERSION: ${SMB_VERSION_STRING}" + +SAMBA_VERSION_GIT_COMMIT_FULLREV=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_FULLREV' | cut -d ' ' -f3- | cut -d '"' -f2` +if test -n "${SAMBA_VERSION_GIT_COMMIT_FULLREV}";then + echo "BUILD COMMIT REVISION: ${SAMBA_VERSION_GIT_COMMIT_FULLREV}" +fi +SAMBA_VERSION_GIT_COMMIT_DATE=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_DATE' | cut -d ' ' -f3-` +if test -n "${SAMBA_VERSION_GIT_COMMIT_DATE}";then + echo "BUILD COMMIT DATE: ${SAMBA_VERSION_GIT_COMMIT_DATE}" +fi +SAMBA_VERSION_GIT_COMMIT_TIME=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_TIME' | cut -d ' ' -f3-` +if test -n "${SAMBA_VERSION_GIT_COMMIT_TIME}";then + echo "BUILD COMMIT TIME: ${SAMBA_VERSION_GIT_COMMIT_TIME}" + + # just to keep the build-farm gui happy for now... + echo "BUILD REVISION: ${SAMBA_VERSION_GIT_COMMIT_TIME}" +fi + -- cgit From d2e63399d3ed09b6b1c78affd780946440414b08 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 22:47:31 +0100 Subject: configure: add --enable-shared-libs to control overall internal use of shared libs. To disable internal use of shared libraries altogether (as opposed to disabling use of single shared libs by --with-static-libs=LIBS), use this new configure parameter --disable-shared-libs. Michael (This used to be commit 63bff18f3f6396736910a8e1f5f2abf453c4f89a) --- source3/configure.in | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 4a798bde62..fe9d716804 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -4699,6 +4699,31 @@ if test $enable_static = yes; then UNINSTALLLIBCMD_A="rm -f" fi +################################################# +# --disable-shared-libs +# can be used to disable the internal use of shared libs altogether +# (this only has an effect when building shared libs is enabled) +# +USESHARED=false +AC_SUBST(USESHARED) + +AC_MSG_CHECKING(whether to use shared libraries internally) +AC_ARG_ENABLE([shared-libs], + AS_HELP_STRING([--enable-shared-libs], + [Use shared libraries internally (default=yes)]), + [enable_shared_libs=$enableval], + [enable_shared_libs=yes]) + +if test x"$enable_shared_libs" != x"no" ; then + USESHARED=$BLDSHARED +fi + +AC_MSG_RESULT([$USESHARED]) + +if test x"$enable_shared_libs" = x"yes" -a x"$BLDSHARED" != x"true" ; then + AC_MSG_WARN([--enable-shared-libs: no support for shared libraries]) +fi + ################################################# # --with-static-libs=LIBS: # link (internal) libs dynamically or statically? @@ -4762,10 +4787,12 @@ samba_cv_with_libtalloc=yes if test x"$samba_cv_with_libtalloc" = "xyes" -a $BLDSHARED = true; then LIBTALLOC_SHARED=$LIBTALLOC_SHARED_TARGET AC_MSG_RESULT(yes) - if test x"$LINK_LIBTALLOC" = "xSTATIC" ; then + if test x"$USESHARED" != x"true" -o x"$LINK_LIBTALLOC" = "xSTATIC" ; then LIBTALLOC_STATIC=$LIBTALLOC_STATIC_TARGET + AC_MSG_NOTICE([not using libtalloc shared library internally]) else LIBTALLOC_LIBS=-ltalloc + AC_MSG_NOTICE([using libtalloc shared library internally]) fi else enable_static=yes @@ -4806,8 +4833,9 @@ samba_cv_with_libtdb=yes if test x"$samba_cv_with_libtdb" = "xyes" -a $BLDSHARED = true; then LIBTDB_SHARED=$LIBTDB_SHARED_TARGET AC_MSG_RESULT(yes) - if test x"$LINK_LIBTDB" = "xSTATIC" ; then + if test x"$USESHARED" != x"true" -o x"$LINK_LIBTDB" = "xSTATIC" ; then LIBTDB_STATIC=$LIBTDB_STATIC_TARGET + AC_MSG_NOTICE([not using libtdb shared library internally]) else LIBTDB_LIBS=-ltdb fi @@ -4849,8 +4877,9 @@ samba_cv_with_libnetapi=yes if test x"$samba_cv_with_libnetapi" = x"yes" -a $BLDSHARED = true; then LIBNETAPI_SHARED=$LIBNETAPI_SHARED_TARGET AC_MSG_RESULT(yes) - if test x"$LINK_LIBNETAPI" = x"STATIC" ; then + if test x"$USESHARED" != x"true" -o x"$LINK_LIBNETAPI" = x"STATIC" ; then LIBNETAPI_STATIC=$LIBNETAPI_STATIC_TARGET + AC_MSG_NOTICE([not using libnetapi shared library internally]) else LIBNETAPI_LIBS=-lnetapi fi -- cgit From ec1576e3462725d7b0108ff02740466ad5ef6277 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 23:44:17 +0100 Subject: Fix build with static libs: place tdb static lib after tdb-util objects. Michael (This used to be commit 39eef8e86cfab60c1328d2335a737b41d8fd6db0) --- source3/Makefile.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 4402a6c122..5c0b73a694 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -241,8 +241,9 @@ MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(IDMAP_MODULES) \ LIBTDB_OBJ0 = @TDB_OBJS@ LIBTDB_OBJ = $(LIBTDB_OBJ0) $(LIBREPLACE_OBJ) -TDB_OBJ = @LIBTDB_STATIC@ lib/util_tdb.o \ - lib/dbwrap.o lib/dbwrap_tdb.o lib/dbwrap_ctdb.o lib/dbwrap_rbt.o +TDB_OBJ = lib/util_tdb.o \ + lib/dbwrap.o lib/dbwrap_tdb.o lib/dbwrap_ctdb.o lib/dbwrap_rbt.o \ + @LIBTDB_STATIC@ SMBLDAP_OBJ = @SMBLDAP@ @SMBLDAPUTIL@ -- cgit From abf84656593c567e42025eaf6b1961a2294f913b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Feb 2008 10:43:46 +1100 Subject: Fix possible close of invalid fd if call to socket() returns -1. (This used to be commit f7d2f692994918037e603ef95dd097b03d2c5456) --- source3/lib/util_sock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 71d48d6053..e040f4631a 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1933,7 +1933,8 @@ int create_pipe_sock(const char *socket_dir, out_close: SAFE_FREE(path); - close(sock); + if (sock != -1) + close(sock); out_umask: umask(old_umask); -- cgit From 441de75e58daf734c412a3e741608822289cac59 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Feb 2008 21:00:51 +1100 Subject: Fix memory leaks on error path (This used to be commit 47dd0700b4320bf5ac9a80e71ae82d82d4554e6a) --- source3/libsmb/clifile.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 9b4c380d40..10c35a30cc 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -38,8 +38,15 @@ static bool cli_link_internal(struct cli_state *cli, const char *oldname, const size_t newlen = 2*(strlen(newname)+1); param = SMB_MALLOC_ARRAY(char, 6+newlen+2); + + if (!param) { + return false; + } + data = SMB_MALLOC_ARRAY(char, oldlen+2); - if (!param || !data) { + + if (!data) { + SAFE_FREE(param); return false; } -- cgit From 34eef81d2ab05e576401da1f80a264f1fd193f36 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Feb 2008 20:37:33 +1100 Subject: Fix double free bugs after calling regfio_close() (This used to be commit 737bb950d50ac6c5d4f99279bf535ae3a9963b2f) --- source3/registry/regfio.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3') diff --git a/source3/registry/regfio.c b/source3/registry/regfio.c index 3740ff0ee4..1c3aad7a25 100644 --- a/source3/registry/regfio.c +++ b/source3/registry/regfio.c @@ -1171,7 +1171,6 @@ out: if ( !(rb->mem_ctx = talloc_init( "read_regf_block" )) ) { regfio_close( rb ); - SAFE_FREE(rb); return NULL; } @@ -1182,7 +1181,6 @@ out: if ( (rb->fd = open(filename, flags, mode)) == -1 ) { DEBUG(0,("regfio_open: failure to open %s (%s)\n", filename, strerror(errno))); regfio_close( rb ); - SAFE_FREE(rb); return NULL; } @@ -1192,7 +1190,6 @@ out: if ( !init_regf_block( rb ) ) { DEBUG(0,("regfio_open: Failed to read initial REGF block\n")); regfio_close( rb ); - SAFE_FREE(rb); return NULL; } @@ -1205,7 +1202,6 @@ out: if ( !read_regf_block( rb ) ) { DEBUG(0,("regfio_open: Failed to read initial REGF block\n")); regfio_close( rb ); - SAFE_FREE(rb); return NULL; } -- cgit From 94ed19c4a89003cb53c9dcfd068246806028e038 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 20 Feb 2008 22:10:54 -0800 Subject: From: David Disseldorp The vfs_prealloc module makes use of the now redundant fd parameter for SMB_VFS_FTRUNCATE(), instead get the fd from the files_struct. Patch for Samba 3.2 Test branch below. Cheers, David D (This used to be commit d9b72282c63b57c8e54131306b2a3028a1ea41dc) --- source3/modules/vfs_prealloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/modules/vfs_prealloc.c b/source3/modules/vfs_prealloc.c index cb3508dc30..2a06e3d81b 100644 --- a/source3/modules/vfs_prealloc.c +++ b/source3/modules/vfs_prealloc.c @@ -199,7 +199,7 @@ static int prealloc_ftruncate(vfs_handle_struct * handle, /* Maintain the allocated space even in the face of truncates. */ if ((psize = VFS_FETCH_FSP_EXTENSION(handle, fsp))) { - preallocate_space(fd, *psize); + preallocate_space(fsp->fh->fd, *psize); } return ret; @@ -218,4 +218,3 @@ NTSTATUS vfs_prealloc_init(void) return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, MODULE, prealloc_op_tuples); } - -- cgit From e823c9f2376b718a0041da7ae395722c925b03f1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 10:26:54 +0100 Subject: Fix the build on irix: Prevent empty line in TDB_OBJ This leads to a Makfile syntax error in the prerequisites for bin/smbd. Wow, irix is really picky! Michael (This used to be commit 011f24c6c95c92417d877886ad87d2a2dd82056e) --- source3/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 5c0b73a694..dce448d135 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -242,8 +242,8 @@ LIBTDB_OBJ0 = @TDB_OBJS@ LIBTDB_OBJ = $(LIBTDB_OBJ0) $(LIBREPLACE_OBJ) TDB_OBJ = lib/util_tdb.o \ - lib/dbwrap.o lib/dbwrap_tdb.o lib/dbwrap_ctdb.o lib/dbwrap_rbt.o \ - @LIBTDB_STATIC@ + lib/dbwrap.o lib/dbwrap_tdb.o lib/dbwrap_ctdb.o \ + lib/dbwrap_rbt.o @LIBTDB_STATIC@ SMBLDAP_OBJ = @SMBLDAP@ @SMBLDAPUTIL@ -- cgit From 48302a28a90190572c5e9a6a54a539d883e89f6b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 00:11:03 +0100 Subject: Remove mmap check from configure.in It is available in libreplace. Michael (This used to be commit 310c121faf5effeca9ab0df3591c486dd4982749) --- source3/configure.in | 7 ----- source3/tests/shared_mmap.c | 68 --------------------------------------------- 2 files changed, 75 deletions(-) delete mode 100644 source3/tests/shared_mmap.c (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index fe9d716804..4cc98363d5 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2756,13 +2756,6 @@ if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then [Whether to use the Darwin-specific initgroups system call]) fi -AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[ -AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"], - samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)]) -if test x"$samba_cv_HAVE_MMAP" = x"yes"; then - AC_DEFINE(HAVE_MMAP,1,[Whether mmap works]) -fi - AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[ AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"], samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)]) diff --git a/source3/tests/shared_mmap.c b/source3/tests/shared_mmap.c deleted file mode 100644 index fcef75d0d6..0000000000 --- a/source3/tests/shared_mmap.c +++ /dev/null @@ -1,68 +0,0 @@ -/* this tests whether we can use a shared writeable mmap on a file - - as needed for the mmap varient of FAST_SHARE_MODES */ - -#if defined(HAVE_UNISTD_H) -#include -#endif -#include -#include -#include -#include - -#define DATA "conftest.mmap" - -#ifndef MAP_FILE -#define MAP_FILE 0 -#endif - -main() -{ - int *buf; - int i; - int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); - int count=7; - - if (fd == -1) exit(1); - - for (i=0;i<10000;i++) { - write(fd,&i,sizeof(i)); - } - - close(fd); - - if (fork() == 0) { - fd = open(DATA,O_RDWR); - if (fd == -1) exit(1); - - buf = (int *)mmap(NULL, 10000*sizeof(int), - (PROT_READ | PROT_WRITE), - MAP_FILE | MAP_SHARED, - fd, 0); - - while (count-- && buf[9124] != 55732) sleep(1); - - if (count <= 0) exit(1); - - buf[1763] = 7268; - exit(0); - } - - fd = open(DATA,O_RDWR); - if (fd == -1) exit(1); - - buf = (int *)mmap(NULL, 10000*sizeof(int), - (PROT_READ | PROT_WRITE), - MAP_FILE | MAP_SHARED, - fd, 0); - - if (buf == (int *)-1) exit(1); - - buf[9124] = 55732; - - while (count-- && buf[1763] != 7268) sleep(1); - - unlink(DATA); - - if (count > 0) exit(0); - exit(1); -} -- cgit From 63592eebbb40abc6374e1f8f6f8a86d9beec047a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 00:34:16 +0100 Subject: Remove check for secure mkstemp from configure.in. It has moved to libreplace. Michael (This used to be commit b5e894cb3b4d447bd8e8c3f461508c4cf3f630c1) --- source3/configure.in | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 4cc98363d5..dcd083fa28 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2615,28 +2615,6 @@ if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken]) fi -AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ -AC_TRY_RUN([#include -#include -#include -#include -main() { - struct stat st; - char tpl[20]="/tmp/test.XXXXXX"; - int fd = mkstemp(tpl); - if (fd == -1) exit(1); - unlink(tpl); - if (fstat(fd, &st) != 0) exit(1); - if ((st.st_mode & 0777) != 0600) exit(1); - exit(0); -}], -samba_cv_HAVE_SECURE_MKSTEMP=yes, -samba_cv_HAVE_SECURE_MKSTEMP=no, -samba_cv_HAVE_SECURE_MKSTEMP=cross)]) -if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then - AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure]) -fi - AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[ AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"], [samba_cv_HAVE_BROKEN_READDIR=no], -- cgit From 21387a4c5e217b503a140b170d153394433dd244 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 21 Feb 2008 11:39:42 +0100 Subject: fix typo (This used to be commit 2d51bf67fc33e1f8f28151277fc254b82a04b664) --- source3/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index dcd083fa28..6627ee6dc8 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -840,7 +840,7 @@ AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [ ], samba_cv_unixsocket=yes,samba_cv_unixsocket=no)]) if test x"$samba_cv_unixsocket" = x"yes"; then - AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support]) + AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixsocket support]) fi -- cgit From d29c816b6195f9d1ef394830a6438123a0fb3afd Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 12:55:52 +0100 Subject: configure: Abstract configuration of internal libs into an m4 macro. New subsystem libraries can now be added by specifying SMB_LIBRARY(name). Michael (This used to be commit 54d73769c49eb87ecb33e3229a01214972b53858) --- source3/configure.in | 170 ++++++++++++++------------------------------------- 1 file changed, 45 insertions(+), 125 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 6627ee6dc8..14110da52b 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -83,18 +83,6 @@ AC_SUBST(UNINSTALL_LIBADDNS) AC_SUBST(LIBADDNS_SHARED) AC_SUBST(LIBADDNS) -AC_SUBST(LIBTALLOC_STATIC_TARGET) -AC_SUBST(LIBTALLOC_SHARED_TARGET) -AC_SUBST(LIBTALLOC_SHARED) -AC_SUBST(LIBTALLOC_STATIC) -AC_SUBST(LIBTALLOC_LIBS) - -AC_SUBST(LIBTDB_STATIC_TARGET) -AC_SUBST(LIBTDB_SHARED_TARGET) -AC_SUBST(LIBTDB_SHARED) -AC_SUBST(LIBTDB_STATIC) -AC_SUBST(LIBTDB_LIBS) - AC_SUBST(INSTALL_LIBWBCLIENT) AC_SUBST(UNINSTALL_LIBWBCLIENT) AC_SUBST(LIBWBCLIENT_SHARED) @@ -113,12 +101,6 @@ AC_SUBST(UNINSTALL_LIBSMBSHAREMODES) AC_SUBST(LIBSMBSHAREMODES_SHARED) AC_SUBST(LIBSMBSHAREMODES) -AC_SUBST(LIBNETAPI_SHARED_TARGET) -AC_SUBST(LIBNETAPI_STATIC_TARGET) -AC_SUBST(LIBNETAPI_SHARED) -AC_SUBST(LIBNETAPI_STATIC) -AC_SUBST(LIBNETAPI_LIBS) - AC_SUBST(PRINT_LIBS) AC_SUBST(AUTH_LIBS) AC_SUBST(ACL_LIBS) @@ -4727,140 +4709,78 @@ AC_ARG_WITH([static-libs], done], [])], []) -################################################# -# should we build libtalloc? -LIBTALLOC_SHARED_TARGET=bin/libtalloc.$SHLIBEXT -LIBTALLOC_STATIC_TARGET=bin/libtalloc.a -LIBTALLOC_SHARED= -LIBTALLOC_STATIC= -LIBTALLOC_LIBS= - -AC_MSG_CHECKING(whether to build the libtalloc shared library) -AC_ARG_WITH(libtalloc, -[AS_HELP_STRING([--with-libtalloc], - [Build the libtalloc shared library (default=yes if shared libs supported)])], -[ -case "$withval" in - *) - AC_MSG_RESULT(no) - ;; - yes) - samba_cv_with_libtalloc=yes - ;; -esac -], -[ -# if unspecified, default is to build it if possible. -samba_cv_with_libtalloc=yes -] -) -if test x"$samba_cv_with_libtalloc" = "xyes" -a $BLDSHARED = true; then - LIBTALLOC_SHARED=$LIBTALLOC_SHARED_TARGET - AC_MSG_RESULT(yes) - if test x"$USESHARED" != x"true" -o x"$LINK_LIBTALLOC" = "xSTATIC" ; then - LIBTALLOC_STATIC=$LIBTALLOC_STATIC_TARGET - AC_MSG_NOTICE([not using libtalloc shared library internally]) - else - LIBTALLOC_LIBS=-ltalloc - AC_MSG_NOTICE([using libtalloc shared library internally]) - fi -else - enable_static=yes - AC_MSG_RESULT(no shared library support -- will supply static library) -fi -if test $enable_static = yes; then - LIBTALLOC_STATIC=$LIBTALLOC_STATIC_TARGET -fi -################################################# -# should we build libtdb? -LIBTDB_SHARED_TARGET=bin/libtdb.$SHLIBEXT -LIBTDB_STATIC_TARGET=bin/libtdb.a -LIBTDB_SHARED= -LIBTDB_STATIC= -LIBTDB_LIBS= - -AC_MSG_CHECKING(whether to build the libtdb shared library) -AC_ARG_WITH(libtdb, -[AS_HELP_STRING([--with-libtdb], - [Build the libtdb shared library (default=yes if shared libs supported)])], +dnl SMB_LIBRARY(name) +dnl +dnl configure build and use of an (internal) shared library +dnl +AC_DEFUN([SMB_LIBRARY], +[ +m4_pushdef([LIBNAME], [lib$1]) +m4_pushdef([LIBUC], [m4_toupper(LIBNAME)]) +m4_pushdef([LIBLIBS], [-l$1]) + +LIBUC[_SHARED_TARGET]=bin/LIBNAME.$SHLIBEXT +LIBUC[_STATIC_TARGET]=bin/LIBNAME.a +LIBUC[_SHARED]= +LIBUC[_STATIC]= +LIBUC[_LIBS]= + +AC_SUBST(LIBUC[_SHARED_TARGET]) +AC_SUBST(LIBUC[_STATIC_TARGET]) +AC_SUBST(LIBUC[_SHARED]) +AC_SUBST(LIBUC[_STATIC]) +AC_SUBST(LIBUC[_LIBS]) + +AC_MSG_CHECKING([whether to build the LIBNAME shared library]) +AC_ARG_WITH(LIBNAME, +[AS_HELP_STRING([--with-LIBNAME], + [Build the LIBNAME shared library (default=yes if shared libs supported)])], [ case "$withval" in *) AC_MSG_RESULT(no) + build_lib=no ;; yes) - samba_cv_with_libtdb=yes + build_lib=yes ;; esac ], [ # if unspecified, default is to build it if possible. -samba_cv_with_libtdb=yes +build_lib=yes ] ) -if test x"$samba_cv_with_libtdb" = "xyes" -a $BLDSHARED = true; then - LIBTDB_SHARED=$LIBTDB_SHARED_TARGET +if eval test x"$build_lib" = "xyes" -a $BLDSHARED = true; then + LIBUC[_SHARED]=$LIBUC[_SHARED_TARGET] AC_MSG_RESULT(yes) - if test x"$USESHARED" != x"true" -o x"$LINK_LIBTDB" = "xSTATIC" ; then - LIBTDB_STATIC=$LIBTDB_STATIC_TARGET - AC_MSG_NOTICE([not using libtdb shared library internally]) + if test x"$USESHARED" != x"true" -o x"$LINK_LIBUC" = "xSTATIC" ; then + LIBUC[_STATIC]=$LIBUC[_STATIC_TARGET] else - LIBTDB_LIBS=-ltdb + LIBUC[_LIBS]=LIBLIBS fi else enable_static=yes AC_MSG_RESULT(no shared library support -- will supply static library) fi if test $enable_static = yes; then - LIBTDB_STATIC=$LIBTDB_STATIC_TARGET + LIBUC[_STATIC]=$LIBUC[_STATIC_TARGET] fi -################################################# -# should we build libnetapi? -LIBNETAPI_SHARED_TARGET=bin/libnetapi.$SHLIBEXT -LIBNETAPI_STATIC_TARGET=bin/libnetapi.a -LIBNETAPI_SHARED= -LIBNETAPI_STATIC= -LIBNETAPI_LIBS= - -AC_MSG_CHECKING(whether to build the libnetapi shared library) -AC_ARG_WITH(libnetapi, -[AS_HELP_STRING([--with-libnetapi], [Build the libnetapi shared library (default=yes if shared libs supported)])], -[ -case "$withval" in - *) - AC_MSG_RESULT(no) - ;; - yes) - samba_cv_with_libnetapi=yes - ;; -esac -], -[ -# if unspecified, default is to build it if possible. -samba_cv_with_libnetapi=yes -] -) +m4_popdef([LIBNAME]) +m4_popdef([LIBUC]) +m4_popdef([LIBLIBS]) + +]) + + +SMB_LIBRARY(talloc) +SMB_LIBRARY(tdb) +SMB_LIBRARY(netapi) -if test x"$samba_cv_with_libnetapi" = x"yes" -a $BLDSHARED = true; then - LIBNETAPI_SHARED=$LIBNETAPI_SHARED_TARGET - AC_MSG_RESULT(yes) - if test x"$USESHARED" != x"true" -o x"$LINK_LIBNETAPI" = x"STATIC" ; then - LIBNETAPI_STATIC=$LIBNETAPI_STATIC_TARGET - AC_MSG_NOTICE([not using libnetapi shared library internally]) - else - LIBNETAPI_LIBS=-lnetapi - fi -else - enable_static=yes - AC_MSG_RESULT(no shared library support -- will supply static library) -fi -if test x"$enable_static" = x"yes"; then - LIBNETAPI_STATIC=$LIBNETAPI_STATIC_TARGET -fi ################################################# # should we build libaddns? -- cgit From 0d7f555335f03219b3bfb66d8caffbedc97f585a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 14:07:45 +0100 Subject: Move the definition of SMB_LIBRARY to aclocal.m4. Michael (This used to be commit 4724b13ed8dce4721f95979803ba32f815ceaf1a) --- source3/configure.in | 67 --------------------------------------------------- source3/m4/aclocal.m4 | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 67 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 14110da52b..78f0901c53 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -4710,73 +4710,6 @@ AC_ARG_WITH([static-libs], []) - -dnl SMB_LIBRARY(name) -dnl -dnl configure build and use of an (internal) shared library -dnl -AC_DEFUN([SMB_LIBRARY], -[ -m4_pushdef([LIBNAME], [lib$1]) -m4_pushdef([LIBUC], [m4_toupper(LIBNAME)]) -m4_pushdef([LIBLIBS], [-l$1]) - -LIBUC[_SHARED_TARGET]=bin/LIBNAME.$SHLIBEXT -LIBUC[_STATIC_TARGET]=bin/LIBNAME.a -LIBUC[_SHARED]= -LIBUC[_STATIC]= -LIBUC[_LIBS]= - -AC_SUBST(LIBUC[_SHARED_TARGET]) -AC_SUBST(LIBUC[_STATIC_TARGET]) -AC_SUBST(LIBUC[_SHARED]) -AC_SUBST(LIBUC[_STATIC]) -AC_SUBST(LIBUC[_LIBS]) - -AC_MSG_CHECKING([whether to build the LIBNAME shared library]) -AC_ARG_WITH(LIBNAME, -[AS_HELP_STRING([--with-LIBNAME], - [Build the LIBNAME shared library (default=yes if shared libs supported)])], -[ -case "$withval" in - *) - AC_MSG_RESULT(no) - build_lib=no - ;; - yes) - build_lib=yes - ;; -esac -], -[ -# if unspecified, default is to build it if possible. -build_lib=yes -] -) - -if eval test x"$build_lib" = "xyes" -a $BLDSHARED = true; then - LIBUC[_SHARED]=$LIBUC[_SHARED_TARGET] - AC_MSG_RESULT(yes) - if test x"$USESHARED" != x"true" -o x"$LINK_LIBUC" = "xSTATIC" ; then - LIBUC[_STATIC]=$LIBUC[_STATIC_TARGET] - else - LIBUC[_LIBS]=LIBLIBS - fi -else - enable_static=yes - AC_MSG_RESULT(no shared library support -- will supply static library) -fi -if test $enable_static = yes; then - LIBUC[_STATIC]=$LIBUC[_STATIC_TARGET] -fi - -m4_popdef([LIBNAME]) -m4_popdef([LIBUC]) -m4_popdef([LIBLIBS]) - -]) - - SMB_LIBRARY(talloc) SMB_LIBRARY(tdb) SMB_LIBRARY(netapi) diff --git a/source3/m4/aclocal.m4 b/source3/m4/aclocal.m4 index fd9efb60e6..888c49db37 100644 --- a/source3/m4/aclocal.m4 +++ b/source3/m4/aclocal.m4 @@ -53,6 +53,73 @@ AC_DEFUN(SMB_SUBSYSTEM, ifelse([$2], , :, [rm -f $2]) ]) + +dnl SMB_LIBRARY(name) +dnl +dnl configure build and use of an (internal) shared library +dnl +AC_DEFUN([SMB_LIBRARY], +[ +m4_pushdef([LIBNAME], [lib$1]) +m4_pushdef([LIBUC], [m4_toupper(LIBNAME)]) +m4_pushdef([LIBLIBS], [-l$1]) + +LIBUC[_SHARED_TARGET]=bin/LIBNAME.$SHLIBEXT +LIBUC[_STATIC_TARGET]=bin/LIBNAME.a +LIBUC[_SHARED]= +LIBUC[_STATIC]= +LIBUC[_LIBS]= + +AC_SUBST(LIBUC[_SHARED_TARGET]) +AC_SUBST(LIBUC[_STATIC_TARGET]) +AC_SUBST(LIBUC[_SHARED]) +AC_SUBST(LIBUC[_STATIC]) +AC_SUBST(LIBUC[_LIBS]) + +AC_MSG_CHECKING([whether to build the LIBNAME shared library]) +AC_ARG_WITH(LIBNAME, +[AS_HELP_STRING([--with-LIBNAME], + [Build the LIBNAME shared library (default=yes if shared libs supported)])], +[ +case "$withval" in + *) + AC_MSG_RESULT(no) + build_lib=no + ;; + yes) + build_lib=yes + ;; +esac +], +[ +# if unspecified, default is to build it if possible. +build_lib=yes +] +) + +if eval test x"$build_lib" = "xyes" -a $BLDSHARED = true; then + LIBUC[_SHARED]=$LIBUC[_SHARED_TARGET] + AC_MSG_RESULT(yes) + if test x"$USESHARED" != x"true" -o x"$LINK_LIBUC" = "xSTATIC" ; then + LIBUC[_STATIC]=$LIBUC[_STATIC_TARGET] + else + LIBUC[_LIBS]=LIBLIBS + fi +else + enable_static=yes + AC_MSG_RESULT(no shared library support -- will supply static library) +fi +if test $enable_static = yes; then + LIBUC[_STATIC]=$LIBUC[_STATIC_TARGET] +fi + +m4_popdef([LIBNAME]) +m4_popdef([LIBUC]) +m4_popdef([LIBLIBS]) + +]) + + dnl AC_LIBTESTFUNC(lib, function, [actions if found], [actions if not found]) dnl Check for a function in a library, but don't keep adding the same library dnl to the LIBS variable. Check whether the function is available in the -- cgit From 357659b1d0c2844b328ae14478a842e111db5c7c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 17:56:33 +0100 Subject: Try and fix getifaddrs check on irix: dont't try to include config.h The missing header file is judged "catastrophic" on irix. Michael (This used to be commit 5778c90819a5a5cee38be690f442c571f3a6a051) --- source3/lib/replace/getifaddrs.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 4cf86d89cc..5d5edf1cbd 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -60,6 +60,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_AIX 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED @@ -74,6 +75,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_IFCONF 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], @@ -86,6 +88,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_IFREQ 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], -- cgit From bf6dbf8e1b371770a2c9df99b27569c36587df39 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 18:16:10 +0100 Subject: libreplace: fix compile errors in getifaddrs.c Michael (This used to be commit 22cdd4cb507022d9c670b7d5cbc8d357b0b91637) --- source3/lib/replace/getifaddrs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index 4037d647d7..f12062bd8e 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -81,7 +81,6 @@ int rep_getifaddrs(struct ifaddrs **ifap) char buff[8192]; int fd, i, n; struct ifreq *ifr=NULL; - int total = 0; struct in_addr ipaddr; struct in_addr nmask; char *iname; @@ -106,7 +105,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) n = ifc.ifc_len / sizeof(struct ifreq); /* Loop through interfaces, looking for given IP address */ - for (i=n-1;i>=0 && total < max_interfaces;i--) { + for (i=n-1; i>=0; i--) { if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) { freeifaddrs(*ifap); } @@ -166,11 +165,10 @@ int rep_getifaddrs(struct ifaddrs **ifap) char buff[8192]; int fd, i, n; struct ifreq *ifr=NULL; - int total = 0; struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif; + struct ifaddrs *curif, *lastif; *ifap = NULL; @@ -201,7 +199,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) /* Loop through interfaces */ - for (i = 0; i Date: Thu, 21 Feb 2008 19:34:48 +0100 Subject: Change option name. xattr:tdb -> xattr_tdb:file (according to the other vfs option names) Karolin (This used to be commit a2230ccc1700af02f5a5caedd2e66e6f4c14bb5c) --- source3/modules/vfs_xattr_tdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 171022b01b..0a92d5c591 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -575,7 +575,7 @@ static bool xattr_tdb_init(int snum, struct db_context **p_db) struct db_context *db; const char *dbname; - dbname = lp_parm_const_string(snum, "xattr", "tdb", + dbname = lp_parm_const_string(snum, "xattr_tdb", "file", lock_path("xattr.tdb")); if (dbname == NULL) { -- cgit From e2ec7931ff157d9468ee31009db1adb0d9acfd6d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 00:24:11 +0100 Subject: Add missing initalizations of lastif in rep_getifaddr implementations. Michael (This used to be commit 65710e752f72070cb911867ff9f31f91904ca5c0) --- source3/lib/replace/getifaddrs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index f12062bd8e..60049caa99 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -84,7 +84,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; @@ -168,7 +169,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; @@ -268,7 +270,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; -- cgit From e3d1f512cf63337ed39942f9ac8e9ee08ee0d7ef Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 00:27:00 +0100 Subject: Fix linked list of ifaddrs in implementations of rep_getifaddrs. Produce proper list instead of one-node-loop. Michael (This used to be commit ec9f4f5066ba7a8bf3af931fd4969590140c0b2b) --- source3/lib/replace/getifaddrs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index 60049caa99..37cd950e09 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -115,7 +115,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } curif->ifa_name = strdup(ifr[i].ifr_name); @@ -208,7 +208,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } strioctl.ic_cmd = SIOCGIFFLAGS; @@ -306,7 +306,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } curif->ifa_name = strdup(ifr->ifr_name); -- cgit From cc32d4c3160f4ea250b406f9adc870d0ddc4f70e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 00:34:41 +0100 Subject: libreplace: fix creation of conftest files for getifaddrs tests. Add missing includes of replace.c and defines of SOCKET_WRAPPER_NOT_REPLACE. Michael (This used to be commit 26e6ebc7090b5742deb67805d85d809cafb4543d) --- source3/lib/replace/getifaddrs.m4 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 5d5edf1cbd..dd2a95cb81 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -44,9 +44,10 @@ iface=no; iface=no; AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) @@ -60,10 +61,12 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_AIX 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then @@ -75,9 +78,11 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_IFCONF 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then @@ -88,9 +93,11 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_IFREQ 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then -- cgit From 5c6db777e4eadd031105623adeca10c1896a164d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 01:59:45 +0100 Subject: Remove the implementations of _get_interfaces and autoconf test in interfaces.c getifaddrs() is now provided by libreplace. Michael (This used to be commit 7970901223464745f99cea883b180316189e4b2c) --- source3/lib/interfaces.c | 386 ----------------------------------------------- 1 file changed, 386 deletions(-) (limited to 'source3') diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c index 3797fc679d..8925958e95 100644 --- a/source3/lib/interfaces.c +++ b/source3/lib/interfaces.c @@ -191,7 +191,6 @@ void make_net(struct sockaddr_storage *pss_out, Also gets IPv6 interfaces. ****************************************************************************/ -#if HAVE_IFACE_GETIFADDRS /**************************************************************************** Get the netmask address for a local interface. ****************************************************************************/ @@ -269,339 +268,6 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) return total; } -#define _FOUND_IFACE_ANY -#endif /* HAVE_IFACE_GETIFADDRS */ -#if HAVE_IFACE_IFCONF - -/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1 - V4.0, Ultrix 4.4, SCO Unix 3.2, IRIX 6.4 and FreeBSD 3.2. - - It probably also works on any BSD style system. */ - -/**************************************************************************** - Get the netmask address for a local interface. -****************************************************************************/ - -static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) -{ - struct ifconf ifc; - char buff[8192]; - int fd, i, n; - struct ifreq *ifr=NULL; - int total = 0; - - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { - return -1; - } - - ifc.ifc_len = sizeof(buff); - ifc.ifc_buf = buff; - - if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) { - close(fd); - return -1; - } - - ifr = ifc.ifc_req; - - n = ifc.ifc_len / sizeof(struct ifreq); - - /* Loop through interfaces, looking for given IP address */ - for (i=n-1;i>=0 && total < max_interfaces;i--) { - - memset(&ifaces[total], '\0', sizeof(ifaces[total])); - - /* Check the interface is up. */ - if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) != 0) { - continue; - } - - ifaces[total].flags = ifr[i].ifr_flags; - - if (!(ifaces[total].flags & IFF_UP)) { - continue; - } - - if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) { - continue; - } - - strlcpy(ifaces[total].name, ifr[i].ifr_name, - sizeof(ifaces[total].name)); - - memcpy(&ifaces[total].ip, &ifr[i].ifr_addr, - sizeof(struct sockaddr_in)); - - if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) { - continue; - } - - memcpy(&ifaces[total].netmask, &ifr[i].ifr_netmask, - sizeof(struct sockaddr_in)); - - if (ifaces[total].flags & IFF_BROADCAST) { - if (ioctl(fd, SIOCGIFBRDADDR, &ifr[i]) != 0) { - continue; - } - memcpy(&ifaces[total].bcast, &ifr[i].ifr_broadaddr, - sizeof(struct sockaddr_in)); - } else if (ifaces[total].flags & IFF_POINTOPOINT) { - if (ioctl(fd, SIOCGIFDSTADDR, &ifr[i]) != 0) { - continue; - } - memcpy(&ifaces[total].bcast, &ifr[i].ifr_dstaddr, - sizeof(struct sockaddr_in)); - } else { - continue; - } - - total++; - } - - close(fd); - - return total; -} - -#define _FOUND_IFACE_ANY -#endif /* HAVE_IFACE_IFCONF */ -#ifdef HAVE_IFACE_IFREQ - -#ifndef I_STR -#include -#endif - -/**************************************************************************** - This should cover most of the streams based systems. - Thanks to Andrej.Borsenkow@mow.siemens.ru for several ideas in this code. -****************************************************************************/ - -static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) -{ - struct ifreq ifreq; - struct strioctl strioctl; - char buff[8192]; - int fd, i, n; - struct ifreq *ifr=NULL; - int total = 0; - - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { - return -1; - } - - strioctl.ic_cmd = SIOCGIFCONF; - strioctl.ic_dp = buff; - strioctl.ic_len = sizeof(buff); - if (ioctl(fd, I_STR, &strioctl) < 0) { - close(fd); - return -1; - } - - /* we can ignore the possible sizeof(int) here as the resulting - number of interface structures won't change */ - n = strioctl.ic_len / sizeof(struct ifreq); - - /* we will assume that the kernel returns the length as an int - at the start of the buffer if the offered size is a - multiple of the structure size plus an int */ - if (n*sizeof(struct ifreq) + sizeof(int) == strioctl.ic_len) { - ifr = (struct ifreq *)(buff + sizeof(int)); - } else { - ifr = (struct ifreq *)buff; - } - - /* Loop through interfaces */ - - for (i = 0; i 0 && total < max_interfaces) { - uint_t inc; - - memset(&ifaces[total], '\0', sizeof(ifaces[total])); - - inc = ifr->ifr_addr.sa_len; - - if (ioctl(fd, SIOCGIFFLAGS, ifr) != 0) { - goto next; - } - - ifaces[total].flags = ifr->ifr_flags; - - if (!(ifaces[total].flags & IFF_UP)) { - goto next; - } - - if (ioctl(fd, SIOCGIFADDR, ifr) != 0) { - goto next; - } - - memcpy(&ifaces[total].ip, &ifr->ifr_addr, - sizeof(struct sockaddr_in)); - - strlcpy(ifaces[total].name, ifr->ifr_name, - sizeof(ifaces[total].name)); - - if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { - goto next; - } - - memcpy(&ifaces[total].netmask, &ifr->ifr_addr, - sizeof(struct sockaddr_in)); - - if (ifaces[total].flags & IFF_BROADCAST) { - if (ioctl(fd, SIOCGIFBRDADDR, ifr) != 0) { - goto next; - } - memcpy(&ifaces[total].bcast, &ifr->ifr_broadaddr, - sizeof(struct sockaddr_in)); - } else if (ifaces[total].flags & IFF_POINTOPOINT) { - if (ioctl(fd, SIOCGIFDSTADDR, ifr) != 0) { - goto next; - } - memcpy(&ifaces[total].bcast, &ifr->ifr_dstaddr, - sizeof(struct sockaddr_in)); - } else { - goto next; - } - - - total++; - - next: - /* - * Patch from Archie Cobbs (archie@whistle.com). The - * addresses in the SIOCGIFCONF interface list have a - * minimum size. Usually this doesn't matter, but if - * your machine has tunnel interfaces, etc. that have - * a zero length "link address", this does matter. */ - - if (inc < sizeof(ifr->ifr_addr)) - inc = sizeof(ifr->ifr_addr); - inc += IFNAMSIZ; - - ifr = (struct ifreq*) (((char*) ifr) + inc); - i -= inc; - } - - close(fd); - return total; -} - -#define _FOUND_IFACE_ANY -#endif /* HAVE_IFACE_AIX */ -#ifndef _FOUND_IFACE_ANY -static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) -{ - return -1; -} -#endif - - static int iface_comp(struct iface_struct *i1, struct iface_struct *i2) { int r; @@ -693,55 +359,3 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces) return total; } - -#ifdef AUTOCONF_TEST -/* this is the autoconf driver to test get_interfaces() */ - -static socklen_t calc_sa_size(struct sockaddr *psa) -{ - socklen_t sl = sizeof(struct sockaddr_in); -#if defined(HAVE_IPV6) - if (psa->sa_family == AF_INET6) { - sl = sizeof(struct sockaddr_in6); - } -#endif - return sl; -} - - int main() -{ - struct iface_struct ifaces[MAX_INTERFACES]; - int total = get_interfaces(ifaces, MAX_INTERFACES); - int i; - - printf("got %d interfaces:\n", total); - if (total <= 0) { - exit(1); - } - - for (i=0;i Date: Fri, 22 Feb 2008 10:43:42 +0100 Subject: Not all implementations of struct ifaddrs define ifa_broadaddr. E.g. the definition of libreplace doesn't. :-o Michael (This used to be commit 25341602ec8752e19ab993872dc2f6c4762785ff) --- source3/lib/interfaces.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'source3') diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c index 8925958e95..dd857ae672 100644 --- a/source3/lib/interfaces.c +++ b/source3/lib/interfaces.c @@ -236,19 +236,9 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) memcpy(&ifaces[total].netmask, ifptr->ifa_netmask, copy_size); if (ifaces[total].flags & (IFF_BROADCAST|IFF_LOOPBACK)) { - if (ifptr->ifa_broadaddr) { - memcpy(&ifaces[total].bcast, - ifptr->ifa_broadaddr, - copy_size); - } else { - /* For some reason ifptr->ifa_broadaddr - * is null. Make one from ifa_addr and - * ifa_netmask. - */ - make_bcast(&ifaces[total].bcast, - &ifaces[total].ip, - &ifaces[total].netmask); - } + make_bcast(&ifaces[total].bcast, + &ifaces[total].ip, + &ifaces[total].netmask); } else if ((ifaces[total].flags & IFF_POINTOPOINT) && ifptr->ifa_dstaddr ) { memcpy(&ifaces[total].bcast, -- cgit From 6a27493578a8851525c84485cc673756a4376955 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 10:42:22 +0100 Subject: libreplace: Fix comment originating from old samba source. Michael (cherry picked from commit 0440bcfe6359ca4842f473b1ca799cad9f1c6c96) (This used to be commit ddf7ac4f266e59871191c6e0a14e99b01a1dc8b1) --- source3/lib/replace/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index 37cd950e09..a6f06e545f 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -363,7 +363,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) #endif #ifdef AUTOCONF_TEST -/* this is the autoconf driver to test get_interfaces() */ +/* this is the autoconf driver to test getifaddrs() */ int main() { -- cgit From 0f0998a06b3444fab45942563079c445f50ec955 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 13:53:05 +0100 Subject: libreplace: don't use socketwrapper for getifaddrs() implementations. Michael (This used to be commit 85eec1d1d6b674294c50eb912fbe7d5a1dd42909) --- source3/lib/replace/getifaddrs.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index a6f06e545f..053657475d 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -19,6 +19,8 @@ along with this program. If not, see . */ +#define SOCKET_WRAPPER_NOT_REPLACE + #include "replace.h" #include "system/network.h" -- cgit From 14aa57a9e3368fed5b8b7d1ac0f6e94b9b1ac20e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 22 Feb 2008 16:17:10 +0100 Subject: Don't use fname after create_file has been called create_file calls unix_convert internally, so modifies fname. So we can't use "fname" after create_file has returned. Use fsp->fsp_name instead. Found during a lengthy debugging session with Karolin testing the xattr_tdb module... (This used to be commit 183fe570469963923864b732817a87f8660341ed) --- source3/smbd/nttrans.c | 10 +++++----- source3/smbd/reply.c | 22 +++++++++++----------- source3/smbd/trans2.c | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'source3') diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 9381174af0..5293ca5347 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -558,7 +558,7 @@ void reply_ntcreate_and_X(struct smb_request *req) } file_len = sbuf.st_size; - fattr = dos_mode(conn,fname,&sbuf); + fattr = dos_mode(conn,fsp->fsp_name,&sbuf); if (fattr == 0) { fattr = FILE_ATTRIBUTE_NORMAL; } @@ -626,7 +626,7 @@ void reply_ntcreate_and_X(struct smb_request *req) uint32 perms = 0; p += 25; if (fsp->is_directory - || can_write_to_file(conn, fname, &sbuf)) { + || can_write_to_file(conn, fsp->fsp_name, &sbuf)) { perms = FILE_GENERIC_ALL; } else { perms = FILE_GENERIC_READ|FILE_EXECUTE; @@ -1007,7 +1007,7 @@ static void call_nt_transact_create(connection_struct *conn, } file_len = sbuf.st_size; - fattr = dos_mode(conn,fname,&sbuf); + fattr = dos_mode(conn,fsp->fsp_name,&sbuf); if (fattr == 0) { fattr = FILE_ATTRIBUTE_NORMAL; } @@ -1075,7 +1075,7 @@ static void call_nt_transact_create(connection_struct *conn, uint32 perms = 0; p += 25; if (fsp->is_directory - || can_write_to_file(conn, fname, &sbuf)) { + || can_write_to_file(conn, fsp->fsp_name, &sbuf)) { perms = FILE_GENERIC_ALL; } else { perms = FILE_GENERIC_READ|FILE_EXECUTE; @@ -1083,7 +1083,7 @@ static void call_nt_transact_create(connection_struct *conn, SIVAL(p,0,perms); } - DEBUG(5,("call_nt_transact_create: open name = %s\n", fname)); + DEBUG(5,("call_nt_transact_create: open name = %s\n", fsp->fsp_name)); /* Send the required number of replies */ send_nt_replies(conn, req, NT_STATUS_OK, params, param_len, *ppdata, 0); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 669dad2e3a..818ff319e4 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1639,11 +1639,11 @@ void reply_open(struct smb_request *req) } size = sbuf.st_size; - fattr = dos_mode(conn,fname,&sbuf); + fattr = dos_mode(conn,fsp->fsp_name,&sbuf); mtime = sbuf.st_mtime; if (fattr & aDIR) { - DEBUG(3,("attempt to open a directory %s\n",fname)); + DEBUG(3,("attempt to open a directory %s\n",fsp->fsp_name)); close_file(fsp,ERROR_CLOSE); reply_doserror(req, ERRDOS,ERRnoaccess); END_PROFILE(SMBopen); @@ -1802,7 +1802,7 @@ void reply_open_and_X(struct smb_request *req) sbuf.st_size = get_allocation_size(conn,fsp,&sbuf); } - fattr = dos_mode(conn,fname,&sbuf); + fattr = dos_mode(conn,fsp->fsp_name,&sbuf); mtime = sbuf.st_mtime; if (fattr & aDIR) { close_file(fsp,ERROR_CLOSE); @@ -1985,7 +1985,7 @@ void reply_mknew(struct smb_request *req) } ts[0] = get_atimespec(&sbuf); /* atime. */ - file_ntimes(conn, fname, ts); + file_ntimes(conn, fsp->fsp_name, ts); reply_outbuf(req, 1, 0); SSVAL(req->outbuf,smb_vwv0,fsp->fnum); @@ -2000,9 +2000,9 @@ void reply_mknew(struct smb_request *req) CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED); } - DEBUG( 2, ( "reply_mknew: file %s\n", fname ) ); + DEBUG( 2, ( "reply_mknew: file %s\n", fsp->fsp_name ) ); DEBUG( 3, ( "reply_mknew %s fd=%d dmode=0x%x\n", - fname, fsp->fh->fd, (unsigned int)fattr ) ); + fsp->fsp_name, fsp->fh->fd, (unsigned int)fattr ) ); END_PROFILE(SMBcreate); return; @@ -2125,9 +2125,9 @@ void reply_ctemp(struct smb_request *req) SSVAL(req->outbuf,smb_vwv0,fsp->fnum); /* the returned filename is relative to the directory */ - s = strrchr_m(fname, '/'); + s = strrchr_m(fsp->fsp_name, '/'); if (!s) { - s = fname; + s = fsp->fsp_name; } else { s++; } @@ -2154,9 +2154,9 @@ void reply_ctemp(struct smb_request *req) CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED); } - DEBUG( 2, ( "reply_ctemp: created temp file %s\n", fname ) ); - DEBUG( 3, ( "reply_ctemp %s fd=%d umode=0%o\n", fname, fsp->fh->fd, - (unsigned int)sbuf.st_mode ) ); + DEBUG( 2, ( "reply_ctemp: created temp file %s\n", fsp->fsp_name ) ); + DEBUG( 3, ( "reply_ctemp %s fd=%d umode=0%o\n", fsp->fsp_name, + fsp->fh->fd, (unsigned int)sbuf.st_mode ) ); END_PROFILE(SMBctemp); return; diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 1f7af82670..dc908846b3 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1017,7 +1017,7 @@ static void call_trans2open(connection_struct *conn, } size = get_file_size(sbuf); - fattr = dos_mode(conn,fname,&sbuf); + fattr = dos_mode(conn,fsp->fsp_name,&sbuf); mtime = sbuf.st_mtime; inode = sbuf.st_ino; if (fattr & aDIR) { @@ -1054,7 +1054,7 @@ static void call_trans2open(connection_struct *conn, SIVAL(params,20,inode); SSVAL(params,24,0); /* Padding. */ if (flags & 8) { - uint32 ea_size = estimate_ea_size(conn, fsp, fname); + uint32 ea_size = estimate_ea_size(conn, fsp, fsp->fsp_name); SIVAL(params, 26, ea_size); } else { SIVAL(params, 26, 0); -- cgit From d88e40106f2864e0e105b5d4fe7c25c577df8643 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 22 Feb 2008 14:10:28 -0500 Subject: Make sure mount.cifs.c compiles on Fedora 9 with gcc 4.3 (This used to be commit ce57d388251063c22f89680e9d1c2129d9879975) --- source3/client/mount.cifs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index 3acf2154b6..44614f6e8a 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -37,6 +37,7 @@ #include #include #include +#include #define MOUNT_CIFS_VERSION_MAJOR "1" #define MOUNT_CIFS_VERSION_MINOR "11" -- cgit From 6cdd527fed86476f9fc86b11cd5d2e7f1067d2e7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 22 Feb 2008 16:12:57 -0800 Subject: Fix debug messages. Jeremy. (This used to be commit d265cedb55b07c6b8a13b9632fbdf8a05fbba886) --- source3/smbd/open.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/smbd/open.c b/source3/smbd/open.c index aa4bc48f3d..cc78503379 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2671,8 +2671,9 @@ NTSTATUS create_file_unixpath(connection_struct *conn, status = split_ntfs_stream_name(talloc_tos(), fname, &base, NULL); if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("split_ntfs_stream_name failed: %s\n", - nt_errstr(status))); + DEBUG(10, ("create_file_unixpath: " + "split_ntfs_stream_name failed: %s\n", + nt_errstr(status))); goto fail; } @@ -2840,7 +2841,7 @@ NTSTATUS create_file_unixpath(connection_struct *conn, } } - DEBUG(10, ("create_file: info=%d\n", info)); + DEBUG(10, ("create_file_unixpath: info=%d\n", info)); /* * Set fsp->base_fsp late enough that we can't "goto fail" anymore. In @@ -2867,7 +2868,7 @@ NTSTATUS create_file_unixpath(connection_struct *conn, return NT_STATUS_OK; fail: - DEBUG(10, ("create_file: %s\n", nt_errstr(status))); + DEBUG(10, ("create_file_unixpath: %s\n", nt_errstr(status))); if (fsp != NULL) { close_file(fsp, ERROR_CLOSE); -- cgit From 29d70de83c8406b9cd8b5ac9b32e49f48208ee90 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 22 Feb 2008 16:19:59 -0800 Subject: Fix "used uninitialized" errors. Jeremy. (This used to be commit 06d15d8a9f94a50337ebf6f651a004bb8b4821f3) --- source3/utils/net_rpc_samsync.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 569bbea857..6287610638 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -979,7 +979,11 @@ static NTSTATUS fetch_alias_mem(uint32_t rid, static NTSTATUS fetch_domain_info(uint32_t rid, struct netr_DELTA_DOMAIN *r) { - time_t u_max_age, u_min_age, u_logout, u_lockoutreset, u_lockouttime; + time_t u_max_age, u_min_age, u_logout; +#if 0 + /* FIXME: gd */ + time_t u_lockoutreset, u_lockouttime; +#endif NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; const char *domname; @@ -1023,7 +1027,6 @@ static NTSTATUS fetch_domain_info(uint32_t rid, /* FIXME: gd */ if (!pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, delta->account_lockout.bad_attempt_lockout)) return nt_status; -#endif if (!pdb_set_account_policy(AP_RESET_COUNT_TIME, (uint32)u_lockoutreset/60)) return nt_status; @@ -1033,6 +1036,7 @@ static NTSTATUS fetch_domain_info(uint32_t rid, if (!pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (uint32)u_lockouttime)) return nt_status; +#endif if (!pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, r->logon_to_chgpass)) -- cgit From 9712e3c11c69e2a40ea7c156dd3515dafed833ea Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:54:59 +0100 Subject: make idl: Check return value of asprintf (This used to be commit d9fb7d7bdcd0e54838ff0b1cb64a7e75d8cd726a) --- source3/librpc/gen_ndr/ndr_dfs.c | 33 +++++-------- source3/librpc/gen_ndr/ndr_echo.c | 3 +- source3/librpc/gen_ndr/ndr_epmapper.c | 15 ++---- source3/librpc/gen_ndr/ndr_eventlog.c | 3 +- source3/librpc/gen_ndr/ndr_krb5pac.c | 6 +-- source3/librpc/gen_ndr/ndr_lsa.c | 57 ++++++++--------------- source3/librpc/gen_ndr/ndr_messaging.c | 3 +- source3/librpc/gen_ndr/ndr_netlogon.c | 78 +++++++++++-------------------- source3/librpc/gen_ndr/ndr_notify.c | 6 +-- source3/librpc/gen_ndr/ndr_ntsvcs.c | 3 +- source3/librpc/gen_ndr/ndr_samr.c | 36 +++++---------- source3/librpc/gen_ndr/ndr_security.c | 6 +-- source3/librpc/gen_ndr/ndr_srvsvc.c | 84 ++++++++++++---------------------- source3/librpc/gen_ndr/ndr_unixinfo.c | 6 +-- source3/librpc/gen_ndr/ndr_winreg.c | 6 +-- source3/librpc/gen_ndr/ndr_wkssvc.c | 27 ++++------- source3/librpc/gen_ndr/ndr_xattr.c | 3 +- 17 files changed, 125 insertions(+), 250 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/ndr_dfs.c b/source3/librpc/gen_ndr/ndr_dfs.c index f5ce913bd2..2e9873e929 100644 --- a/source3/librpc/gen_ndr/ndr_dfs.c +++ b/source3/librpc/gen_ndr/ndr_dfs.c @@ -506,8 +506,7 @@ _PUBLIC_ void ndr_print_dfs_Info3(struct ndr_print *ndr, const char *name, const ndr->depth++; for (cntr_stores_1=0;cntr_stores_1num_stores;cntr_stores_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_stores_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_stores_1) != -1) { ndr_print_dfs_StorageInfo(ndr, "stores", &r->stores[cntr_stores_1]); free(idx_1); } @@ -670,8 +669,7 @@ _PUBLIC_ void ndr_print_dfs_Info4(struct ndr_print *ndr, const char *name, const ndr->depth++; for (cntr_stores_1=0;cntr_stores_1num_stores;cntr_stores_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_stores_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_stores_1) != -1) { ndr_print_dfs_StorageInfo(ndr, "stores", &r->stores[cntr_stores_1]); free(idx_1); } @@ -1079,8 +1077,7 @@ _PUBLIC_ void ndr_print_dfs_Info6(struct ndr_print *ndr, const char *name, const ndr->depth++; for (cntr_stores_1=0;cntr_stores_1num_stores;cntr_stores_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_stores_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_stores_1) != -1) { ndr_print_dfs_StorageInfo2(ndr, "stores", &r->stores[cntr_stores_1]); free(idx_1); } @@ -2271,8 +2268,7 @@ _PUBLIC_ void ndr_print_dfs_EnumArray1(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_s_1=0;cntr_s_1count;cntr_s_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_s_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_s_1) != -1) { ndr_print_dfs_Info1(ndr, "s", &r->s[cntr_s_1]); free(idx_1); } @@ -2358,8 +2354,7 @@ _PUBLIC_ void ndr_print_dfs_EnumArray2(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_s_1=0;cntr_s_1count;cntr_s_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_s_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_s_1) != -1) { ndr_print_dfs_Info2(ndr, "s", &r->s[cntr_s_1]); free(idx_1); } @@ -2445,8 +2440,7 @@ _PUBLIC_ void ndr_print_dfs_EnumArray3(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_s_1=0;cntr_s_1count;cntr_s_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_s_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_s_1) != -1) { ndr_print_dfs_Info3(ndr, "s", &r->s[cntr_s_1]); free(idx_1); } @@ -2532,8 +2526,7 @@ _PUBLIC_ void ndr_print_dfs_EnumArray4(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_s_1=0;cntr_s_1count;cntr_s_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_s_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_s_1) != -1) { ndr_print_dfs_Info4(ndr, "s", &r->s[cntr_s_1]); free(idx_1); } @@ -2619,8 +2612,7 @@ _PUBLIC_ void ndr_print_dfs_EnumArray5(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_s_1=0;cntr_s_1count;cntr_s_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_s_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_s_1) != -1) { ndr_print_dfs_Info5(ndr, "s", &r->s[cntr_s_1]); free(idx_1); } @@ -2706,8 +2698,7 @@ _PUBLIC_ void ndr_print_dfs_EnumArray6(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_s_1=0;cntr_s_1count;cntr_s_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_s_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_s_1) != -1) { ndr_print_dfs_Info6(ndr, "s", &r->s[cntr_s_1]); free(idx_1); } @@ -2793,8 +2784,7 @@ _PUBLIC_ void ndr_print_dfs_EnumArray200(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_s_1=0;cntr_s_1count;cntr_s_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_s_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_s_1) != -1) { ndr_print_dfs_Info200(ndr, "s", &r->s[cntr_s_1]); free(idx_1); } @@ -2880,8 +2870,7 @@ _PUBLIC_ void ndr_print_dfs_EnumArray300(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_s_1=0;cntr_s_1count;cntr_s_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_s_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_s_1) != -1) { ndr_print_dfs_Info300(ndr, "s", &r->s[cntr_s_1]); free(idx_1); } diff --git a/source3/librpc/gen_ndr/ndr_echo.c b/source3/librpc/gen_ndr/ndr_echo.c index 67ff0f2df4..340167cf73 100644 --- a/source3/librpc/gen_ndr/ndr_echo.c +++ b/source3/librpc/gen_ndr/ndr_echo.c @@ -627,8 +627,7 @@ _PUBLIC_ void ndr_print_echo_Surrounding(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_surrounding_0=0;cntr_surrounding_0x;cntr_surrounding_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_surrounding_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_surrounding_0) != -1) { ndr_print_uint16(ndr, "surrounding", r->surrounding[cntr_surrounding_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_epmapper.c b/source3/librpc/gen_ndr/ndr_epmapper.c index 4f9422ea57..2e709e11e0 100644 --- a/source3/librpc/gen_ndr/ndr_epmapper.c +++ b/source3/librpc/gen_ndr/ndr_epmapper.c @@ -1566,8 +1566,7 @@ _PUBLIC_ void ndr_print_epm_tower(struct ndr_print *ndr, const char *name, const ndr->depth++; for (cntr_floors_0=0;cntr_floors_0num_floors;cntr_floors_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_floors_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_floors_0) != -1) { ndr_print_epm_floor(ndr, "floors", &r->floors[cntr_floors_0]); free(idx_0); } @@ -1849,8 +1848,7 @@ _PUBLIC_ void ndr_print_epm_Insert(struct ndr_print *ndr, const char *name, int ndr->depth++; for (cntr_entries_0=0;cntr_entries_0in.num_ents;cntr_entries_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_entries_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_entries_0) != -1) { ndr_print_epm_entry_t(ndr, "entries", &r->in.entries[cntr_entries_0]); free(idx_0); } @@ -1930,8 +1928,7 @@ _PUBLIC_ void ndr_print_epm_Delete(struct ndr_print *ndr, const char *name, int ndr->depth++; for (cntr_entries_0=0;cntr_entries_0in.num_ents;cntr_entries_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_entries_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_entries_0) != -1) { ndr_print_epm_entry_t(ndr, "entries", &r->in.entries[cntr_entries_0]); free(idx_0); } @@ -2131,8 +2128,7 @@ _PUBLIC_ void ndr_print_epm_Lookup(struct ndr_print *ndr, const char *name, int ndr->depth++; for (cntr_entries_0=0;cntr_entries_0<*r->out.num_ents;cntr_entries_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_entries_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_entries_0) != -1) { ndr_print_epm_entry_t(ndr, "entries", &r->out.entries[cntr_entries_0]); free(idx_0); } @@ -2321,8 +2317,7 @@ _PUBLIC_ void ndr_print_epm_Map(struct ndr_print *ndr, const char *name, int fla ndr->depth++; for (cntr_towers_0=0;cntr_towers_0<*r->out.num_towers;cntr_towers_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_towers_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_towers_0) != -1) { ndr_print_epm_twr_p_t(ndr, "towers", &r->out.towers[cntr_towers_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_eventlog.c b/source3/librpc/gen_ndr/ndr_eventlog.c index 1b58eb66b8..c5461d99ab 100644 --- a/source3/librpc/gen_ndr/ndr_eventlog.c +++ b/source3/librpc/gen_ndr/ndr_eventlog.c @@ -176,8 +176,7 @@ _PUBLIC_ void ndr_print_eventlog_Record(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_strings_0=0;cntr_strings_0num_of_strings;cntr_strings_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_strings_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_strings_0) != -1) { ndr_print_string(ndr, "strings", r->strings[cntr_strings_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_krb5pac.c b/source3/librpc/gen_ndr/ndr_krb5pac.c index 82b7803f80..7c4dba0b0a 100644 --- a/source3/librpc/gen_ndr/ndr_krb5pac.c +++ b/source3/librpc/gen_ndr/ndr_krb5pac.c @@ -442,8 +442,7 @@ _PUBLIC_ void ndr_print_PAC_DATA(struct ndr_print *ndr, const char *name, const ndr->depth++; for (cntr_buffers_0=0;cntr_buffers_0num_buffers;cntr_buffers_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_buffers_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_buffers_0) != -1) { ndr_print_PAC_BUFFER(ndr, "buffers", &r->buffers[cntr_buffers_0]); free(idx_0); } @@ -645,8 +644,7 @@ _PUBLIC_ void ndr_print_PAC_DATA_RAW(struct ndr_print *ndr, const char *name, co ndr->depth++; for (cntr_buffers_0=0;cntr_buffers_0num_buffers;cntr_buffers_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_buffers_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_buffers_0) != -1) { ndr_print_PAC_BUFFER_RAW(ndr, "buffers", &r->buffers[cntr_buffers_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index dc4918a6d7..b54f43a353 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -221,8 +221,7 @@ _PUBLIC_ void ndr_print_lsa_Strings(struct ndr_print *ndr, const char *name, con ndr->depth++; for (cntr_names_1=0;cntr_names_1count;cntr_names_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_names_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_names_1) != -1) { ndr_print_lsa_String(ndr, "names", &r->names[cntr_names_1]); free(idx_1); } @@ -453,8 +452,7 @@ _PUBLIC_ void ndr_print_lsa_PrivArray(struct ndr_print *ndr, const char *name, c ndr->depth++; for (cntr_privs_1=0;cntr_privs_1count;cntr_privs_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_privs_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_privs_1) != -1) { ndr_print_lsa_PrivEntry(ndr, "privs", &r->privs[cntr_privs_1]); free(idx_1); } @@ -789,8 +787,7 @@ _PUBLIC_ void ndr_print_lsa_AuditEventsInfo(struct ndr_print *ndr, const char *n ndr->depth++; for (cntr_settings_1=0;cntr_settings_1count;cntr_settings_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_settings_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_settings_1) != -1) { ndr_print_lsa_PolicyAuditPolicy(ndr, "settings", r->settings[cntr_settings_1]); free(idx_1); } @@ -1622,8 +1619,7 @@ _PUBLIC_ void ndr_print_lsa_SidArray(struct ndr_print *ndr, const char *name, co ndr->depth++; for (cntr_sids_1=0;cntr_sids_1num_sids;cntr_sids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sids_1) != -1) { ndr_print_lsa_SidPtr(ndr, "sids", &r->sids[cntr_sids_1]); free(idx_1); } @@ -1709,8 +1705,7 @@ _PUBLIC_ void ndr_print_lsa_DomainList(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_domains_1=0;cntr_domains_1count;cntr_domains_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_domains_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_domains_1) != -1) { ndr_print_lsa_DomainInfo(ndr, "domains", &r->domains[cntr_domains_1]); free(idx_1); } @@ -1862,8 +1857,7 @@ _PUBLIC_ void ndr_print_lsa_TransSidArray(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_sids_1=0;cntr_sids_1count;cntr_sids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sids_1) != -1) { ndr_print_lsa_TranslatedSid(ndr, "sids", &r->sids[cntr_sids_1]); free(idx_1); } @@ -1954,8 +1948,7 @@ _PUBLIC_ void ndr_print_lsa_RefDomainList(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_domains_1=0;cntr_domains_1count;cntr_domains_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_domains_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_domains_1) != -1) { ndr_print_lsa_DomainInfo(ndr, "domains", &r->domains[cntr_domains_1]); free(idx_1); } @@ -2112,8 +2105,7 @@ _PUBLIC_ void ndr_print_lsa_TransNameArray(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_names_1=0;cntr_names_1count;cntr_names_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_names_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_names_1) != -1) { ndr_print_lsa_TranslatedName(ndr, "names", &r->names[cntr_names_1]); free(idx_1); } @@ -2213,8 +2205,7 @@ _PUBLIC_ void ndr_print_lsa_PrivilegeSet(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_set_0=0;cntr_set_0count;cntr_set_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_set_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_set_0) != -1) { ndr_print_lsa_LUIDAttribute(ndr, "set", &r->set[cntr_set_0]); free(idx_0); } @@ -3335,8 +3326,7 @@ _PUBLIC_ void ndr_print_lsa_RightSet(struct ndr_print *ndr, const char *name, co ndr->depth++; for (cntr_names_1=0;cntr_names_1count;cntr_names_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_names_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_names_1) != -1) { ndr_print_lsa_StringLarge(ndr, "names", &r->names[cntr_names_1]); free(idx_1); } @@ -3422,8 +3412,7 @@ _PUBLIC_ void ndr_print_lsa_DomainListEx(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_domains_1=0;cntr_domains_1count;cntr_domains_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_domains_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_domains_1) != -1) { ndr_print_lsa_TrustDomainInfoInfoEx(ndr, "domains", &r->domains[cntr_domains_1]); free(idx_1); } @@ -3751,8 +3740,7 @@ _PUBLIC_ void ndr_print_lsa_TransNameArray2(struct ndr_print *ndr, const char *n ndr->depth++; for (cntr_names_1=0;cntr_names_1count;cntr_names_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_names_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_names_1) != -1) { ndr_print_lsa_TranslatedName2(ndr, "names", &r->names[cntr_names_1]); free(idx_1); } @@ -3874,8 +3862,7 @@ _PUBLIC_ void ndr_print_lsa_TransSidArray2(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_sids_1=0;cntr_sids_1count;cntr_sids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sids_1) != -1) { ndr_print_lsa_TranslatedSid2(ndr, "sids", &r->sids[cntr_sids_1]); free(idx_1); } @@ -4024,8 +4011,7 @@ _PUBLIC_ void ndr_print_lsa_TransSidArray3(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_sids_1=0;cntr_sids_1count;cntr_sids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sids_1) != -1) { ndr_print_lsa_TranslatedSid3(ndr, "sids", &r->sids[cntr_sids_1]); free(idx_1); } @@ -4447,8 +4433,7 @@ _PUBLIC_ void ndr_print_lsa_ForestTrustInformation(struct ndr_print *ndr, const ndr->depth++; for (cntr_entries_1=0;cntr_entries_1count;cntr_entries_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_entries_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_entries_1) != -1) { ndr_print_ptr(ndr, "entries", r->entries[cntr_entries_1]); ndr->depth++; if (r->entries[cntr_entries_1]) { @@ -5842,8 +5827,7 @@ _PUBLIC_ void ndr_print_lsa_LookupNames(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_names_0=0;cntr_names_0in.num_names;cntr_names_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_names_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_names_0) != -1) { ndr_print_lsa_String(ndr, "names", &r->in.names[cntr_names_0]); free(idx_0); } @@ -10068,8 +10052,7 @@ _PUBLIC_ void ndr_print_lsa_LookupNames2(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_names_0=0;cntr_names_0in.num_names;cntr_names_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_names_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_names_0) != -1) { ndr_print_lsa_String(ndr, "names", &r->in.names[cntr_names_0]); free(idx_0); } @@ -10652,8 +10635,7 @@ _PUBLIC_ void ndr_print_lsa_LookupNames3(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_names_0=0;cntr_names_0in.num_names;cntr_names_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_names_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_names_0) != -1) { ndr_print_lsa_String(ndr, "names", &r->in.names[cntr_names_0]); free(idx_0); } @@ -11387,8 +11369,7 @@ _PUBLIC_ void ndr_print_lsa_LookupNames4(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_names_0=0;cntr_names_0in.num_names;cntr_names_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_names_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_names_0) != -1) { ndr_print_lsa_String(ndr, "names", &r->in.names[cntr_names_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_messaging.c b/source3/librpc/gen_ndr/ndr_messaging.c index 413421f770..db886316f1 100644 --- a/source3/librpc/gen_ndr/ndr_messaging.c +++ b/source3/librpc/gen_ndr/ndr_messaging.c @@ -103,8 +103,7 @@ _PUBLIC_ void ndr_print_messaging_array(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_messages_0=0;cntr_messages_0num_messages;cntr_messages_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_messages_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_messages_0) != -1) { ndr_print_messaging_rec(ndr, "messages", &r->messages[cntr_messages_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index fb5c4603ee..4c46fb0735 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -315,8 +315,7 @@ _PUBLIC_ void ndr_print_netr_AcctLockStr(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_bindata_1=0;cntr_bindata_1length / 2;cntr_bindata_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_bindata_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_bindata_1) != -1) { ndr_print_uint16(ndr, "bindata", r->bindata[cntr_bindata_1]); free(idx_1); } @@ -1111,8 +1110,7 @@ _PUBLIC_ void ndr_print_netr_SamBaseInfo(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_unknown_0=0;cntr_unknown_0<7;cntr_unknown_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_unknown_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_unknown_0) != -1) { ndr_print_uint32(ndr, "unknown", r->unknown[cntr_unknown_0]); free(idx_0); } @@ -1287,8 +1285,7 @@ _PUBLIC_ void ndr_print_netr_SamInfo3(struct ndr_print *ndr, const char *name, c ndr->depth++; for (cntr_sids_1=0;cntr_sids_1sidcount;cntr_sids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sids_1) != -1) { ndr_print_netr_SidAttr(ndr, "sids", &r->sids[cntr_sids_1]); free(idx_1); } @@ -1396,8 +1393,7 @@ _PUBLIC_ void ndr_print_netr_SamInfo6(struct ndr_print *ndr, const char *name, c ndr->depth++; for (cntr_sids_1=0;cntr_sids_1sidcount;cntr_sids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sids_1) != -1) { ndr_print_netr_SidAttr(ndr, "sids", &r->sids[cntr_sids_1]); free(idx_1); } @@ -1411,8 +1407,7 @@ _PUBLIC_ void ndr_print_netr_SamInfo6(struct ndr_print *ndr, const char *name, c ndr->depth++; for (cntr_unknown4_0=0;cntr_unknown4_0<20;cntr_unknown4_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_unknown4_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_unknown4_0) != -1) { ndr_print_uint32(ndr, "unknown4", r->unknown4[cntr_unknown4_0]); free(idx_0); } @@ -1558,8 +1553,7 @@ _PUBLIC_ void ndr_print_netr_PacInfo(struct ndr_print *ndr, const char *name, co ndr->depth++; for (cntr_expansionroom_0=0;cntr_expansionroom_0<10;cntr_expansionroom_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_expansionroom_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_expansionroom_0) != -1) { ndr_print_uint32(ndr, "expansionroom", r->expansionroom[cntr_expansionroom_0]); free(idx_0); } @@ -2810,8 +2804,7 @@ _PUBLIC_ void ndr_print_netr_DELTA_GROUP_MEMBER(struct ndr_print *ndr, const cha ndr->depth++; for (cntr_rids_1=0;cntr_rids_1num_rids;cntr_rids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_rids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_rids_1) != -1) { ndr_print_uint32(ndr, "rids", r->rids[cntr_rids_1]); free(idx_1); } @@ -2826,8 +2819,7 @@ _PUBLIC_ void ndr_print_netr_DELTA_GROUP_MEMBER(struct ndr_print *ndr, const cha ndr->depth++; for (cntr_attribs_1=0;cntr_attribs_1num_rids;cntr_attribs_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_attribs_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_attribs_1) != -1) { ndr_print_uint32(ndr, "attribs", r->attribs[cntr_attribs_1]); free(idx_1); } @@ -3143,8 +3135,7 @@ _PUBLIC_ void ndr_print_netr_DELTA_POLICY(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_eventauditoptions_1=0;cntr_eventauditoptions_1maxauditeventcount + 1;cntr_eventauditoptions_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_eventauditoptions_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_eventauditoptions_1) != -1) { ndr_print_uint32(ndr, "eventauditoptions", r->eventauditoptions[cntr_eventauditoptions_1]); free(idx_1); } @@ -3285,8 +3276,7 @@ _PUBLIC_ void ndr_print_netr_DELTA_TRUSTED_DOMAIN(struct ndr_print *ndr, const c ndr->depth++; for (cntr_controller_names_1=0;cntr_controller_names_1num_controllers;cntr_controller_names_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_controller_names_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_controller_names_1) != -1) { ndr_print_lsa_String(ndr, "controller_names", &r->controller_names[cntr_controller_names_1]); free(idx_1); } @@ -3484,8 +3474,7 @@ _PUBLIC_ void ndr_print_netr_DELTA_ACCOUNT(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_privilege_attrib_1=0;cntr_privilege_attrib_1privilege_entries;cntr_privilege_attrib_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_privilege_attrib_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_privilege_attrib_1) != -1) { ndr_print_uint32(ndr, "privilege_attrib", r->privilege_attrib[cntr_privilege_attrib_1]); free(idx_1); } @@ -3500,8 +3489,7 @@ _PUBLIC_ void ndr_print_netr_DELTA_ACCOUNT(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_privilege_name_1=0;cntr_privilege_name_1privilege_entries;cntr_privilege_name_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_privilege_name_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_privilege_name_1) != -1) { ndr_print_lsa_String(ndr, "privilege_name", &r->privilege_name[cntr_privilege_name_1]); free(idx_1); } @@ -5291,8 +5279,7 @@ _PUBLIC_ void ndr_print_netr_DELTA_ENUM_ARRAY(struct ndr_print *ndr, const char ndr->depth++; for (cntr_delta_enum_1=0;cntr_delta_enum_1num_deltas;cntr_delta_enum_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_delta_enum_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_delta_enum_1) != -1) { ndr_print_netr_DELTA_ENUM(ndr, "delta_enum", &r->delta_enum[cntr_delta_enum_1]); free(idx_1); } @@ -6429,8 +6416,7 @@ _PUBLIC_ void ndr_print_netr_BinaryString(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_data_1=0;cntr_data_1length / 2;cntr_data_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_data_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_data_1) != -1) { ndr_print_uint16(ndr, "data", r->data[cntr_data_1]); free(idx_1); } @@ -6703,8 +6689,7 @@ _PUBLIC_ void ndr_print_netr_DomainQuery1(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_unknown7_0=0;cntr_unknown7_0<4;cntr_unknown7_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_unknown7_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_unknown7_0) != -1) { ndr_print_uint32(ndr, "unknown7", r->unknown7[cntr_unknown7_0]); free(idx_0); } @@ -6941,8 +6926,7 @@ _PUBLIC_ void ndr_print_netr_DomainTrustInfo(struct ndr_print *ndr, const char * ndr->depth++; for (cntr_unknown1_0=0;cntr_unknown1_0<4;cntr_unknown1_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_unknown1_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_unknown1_0) != -1) { ndr_print_netr_BinaryString(ndr, "unknown1", &r->unknown1[cntr_unknown1_0]); free(idx_0); } @@ -6952,8 +6936,7 @@ _PUBLIC_ void ndr_print_netr_DomainTrustInfo(struct ndr_print *ndr, const char * ndr->depth++; for (cntr_unknown_0=0;cntr_unknown_0<4;cntr_unknown_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_unknown_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_unknown_0) != -1) { ndr_print_uint32(ndr, "unknown", r->unknown[cntr_unknown_0]); free(idx_0); } @@ -7051,8 +7034,7 @@ _PUBLIC_ void ndr_print_netr_DomainInfo1(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_trusts_1=0;cntr_trusts_1num_trusts;cntr_trusts_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_trusts_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_trusts_1) != -1) { ndr_print_netr_DomainTrustInfo(ndr, "trusts", &r->trusts[cntr_trusts_1]); free(idx_1); } @@ -7064,8 +7046,7 @@ _PUBLIC_ void ndr_print_netr_DomainInfo1(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_unknown_0=0;cntr_unknown_0<14;cntr_unknown_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_unknown_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_unknown_0) != -1) { ndr_print_uint32(ndr, "unknown", r->unknown[cntr_unknown_0]); free(idx_0); } @@ -7329,8 +7310,7 @@ _PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesWCtr(struct ndr_print *ndr, co ndr->depth++; for (cntr_sitename_1=0;cntr_sitename_1count;cntr_sitename_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sitename_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sitename_1) != -1) { ndr_print_lsa_String(ndr, "sitename", &r->sitename[cntr_sitename_1]); free(idx_1); } @@ -7692,8 +7672,7 @@ _PUBLIC_ void ndr_print_netr_DomainTrustList(struct ndr_print *ndr, const char * ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_netr_DomainTrust(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -7820,8 +7799,7 @@ _PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesExWCtr(struct ndr_print *ndr, ndr->depth++; for (cntr_sitename_1=0;cntr_sitename_1count;cntr_sitename_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sitename_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sitename_1) != -1) { ndr_print_lsa_String(ndr, "sitename", &r->sitename[cntr_sitename_1]); free(idx_1); } @@ -7836,8 +7814,7 @@ _PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesExWCtr(struct ndr_print *ndr, ndr->depth++; for (cntr_subnetname_1=0;cntr_subnetname_1count;cntr_subnetname_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_subnetname_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_subnetname_1) != -1) { ndr_print_lsa_String(ndr, "subnetname", &r->subnetname[cntr_subnetname_1]); free(idx_1); } @@ -7923,8 +7900,7 @@ _PUBLIC_ void ndr_print_DcSitesCtr(struct ndr_print *ndr, const char *name, cons ndr->depth++; for (cntr_sites_1=0;cntr_sites_1num_sites;cntr_sites_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_sites_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_sites_1) != -1) { ndr_print_lsa_String(ndr, "sites", &r->sites[cntr_sites_1]); free(idx_1); } @@ -12712,8 +12688,7 @@ _PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesW(struct ndr_print *ndr, const ndr->depth++; for (cntr_addresses_1=0;cntr_addresses_1in.count;cntr_addresses_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_addresses_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_addresses_1) != -1) { ndr_print_netr_DsRAddress(ndr, "addresses", &r->in.addresses[cntr_addresses_1]); free(idx_1); } @@ -13256,8 +13231,7 @@ _PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesExW(struct ndr_print *ndr, con ndr->depth++; for (cntr_addresses_1=0;cntr_addresses_1in.count;cntr_addresses_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_addresses_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_addresses_1) != -1) { ndr_print_netr_DsRAddress(ndr, "addresses", &r->in.addresses[cntr_addresses_1]); free(idx_1); } diff --git a/source3/librpc/gen_ndr/ndr_notify.c b/source3/librpc/gen_ndr/ndr_notify.c index 8abfdfdf92..195d421408 100644 --- a/source3/librpc/gen_ndr/ndr_notify.c +++ b/source3/librpc/gen_ndr/ndr_notify.c @@ -120,8 +120,7 @@ _PUBLIC_ void ndr_print_notify_depth(struct ndr_print *ndr, const char *name, co ndr->depth++; for (cntr_entries_0=0;cntr_entries_0num_entries;cntr_entries_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_entries_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_entries_0) != -1) { ndr_print_notify_entry(ndr, "entries", &r->entries[cntr_entries_0]); free(idx_0); } @@ -184,8 +183,7 @@ _PUBLIC_ void ndr_print_notify_array(struct ndr_print *ndr, const char *name, co ndr->depth++; for (cntr_depth_0=0;cntr_depth_0num_depths;cntr_depth_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_depth_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_depth_0) != -1) { ndr_print_notify_depth(ndr, "depth", &r->depth[cntr_depth_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.c b/source3/librpc/gen_ndr/ndr_ntsvcs.c index 058b78104a..9a0e2bcf4f 100644 --- a/source3/librpc/gen_ndr/ndr_ntsvcs.c +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c @@ -45,8 +45,7 @@ _PUBLIC_ void ndr_print_PNP_HwProfInfo(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_unknown2_0=0;cntr_unknown2_0<160;cntr_unknown2_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_unknown2_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_unknown2_0) != -1) { ndr_print_uint16(ndr, "unknown2", r->unknown2[cntr_unknown2_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_samr.c b/source3/librpc/gen_ndr/ndr_samr.c index eaa38e3a1f..3549bfd22b 100644 --- a/source3/librpc/gen_ndr/ndr_samr.c +++ b/source3/librpc/gen_ndr/ndr_samr.c @@ -299,8 +299,7 @@ _PUBLIC_ void ndr_print_samr_SamArray(struct ndr_print *ndr, const char *name, c ndr->depth++; for (cntr_entries_1=0;cntr_entries_1count;cntr_entries_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_entries_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_entries_1) != -1) { ndr_print_samr_SamEntry(ndr, "entries", &r->entries[cntr_entries_1]); free(idx_1); } @@ -1161,8 +1160,7 @@ _PUBLIC_ void ndr_print_samr_Ids(struct ndr_print *ndr, const char *name, const ndr->depth++; for (cntr_ids_1=0;cntr_ids_1count;cntr_ids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_ids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_ids_1) != -1) { ndr_print_uint32(ndr, "ids", r->ids[cntr_ids_1]); free(idx_1); } @@ -1559,8 +1557,7 @@ _PUBLIC_ void ndr_print_samr_RidTypeArray(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_rids_1=0;cntr_rids_1count;cntr_rids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_rids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_rids_1) != -1) { ndr_print_uint32(ndr, "rids", r->rids[cntr_rids_1]); free(idx_1); } @@ -1575,8 +1572,7 @@ _PUBLIC_ void ndr_print_samr_RidTypeArray(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_types_1=0;cntr_types_1count;cntr_types_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_types_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_types_1) != -1) { ndr_print_uint32(ndr, "types", r->types[cntr_types_1]); free(idx_1); } @@ -3711,8 +3707,7 @@ _PUBLIC_ void ndr_print_samr_RidWithAttributeArray(struct ndr_print *ndr, const ndr->depth++; for (cntr_rids_1=0;cntr_rids_1count;cntr_rids_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_rids_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_rids_1) != -1) { ndr_print_samr_RidWithAttribute(ndr, "rids", &r->rids[cntr_rids_1]); free(idx_1); } @@ -3849,8 +3844,7 @@ _PUBLIC_ void ndr_print_samr_DispInfoGeneral(struct ndr_print *ndr, const char * ndr->depth++; for (cntr_entries_1=0;cntr_entries_1count;cntr_entries_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_entries_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_entries_1) != -1) { ndr_print_samr_DispEntryGeneral(ndr, "entries", &r->entries[cntr_entries_1]); free(idx_1); } @@ -3982,8 +3976,7 @@ _PUBLIC_ void ndr_print_samr_DispInfoFull(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_entries_1=0;cntr_entries_1count;cntr_entries_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_entries_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_entries_1) != -1) { ndr_print_samr_DispEntryFull(ndr, "entries", &r->entries[cntr_entries_1]); free(idx_1); } @@ -4115,8 +4108,7 @@ _PUBLIC_ void ndr_print_samr_DispInfoFullGroups(struct ndr_print *ndr, const cha ndr->depth++; for (cntr_entries_1=0;cntr_entries_1count;cntr_entries_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_entries_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_entries_1) != -1) { ndr_print_samr_DispEntryFullGroup(ndr, "entries", &r->entries[cntr_entries_1]); free(idx_1); } @@ -4237,8 +4229,7 @@ _PUBLIC_ void ndr_print_samr_DispInfoAscii(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_entries_1=0;cntr_entries_1count;cntr_entries_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_entries_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_entries_1) != -1) { ndr_print_samr_DispEntryAscii(ndr, "entries", &r->entries[cntr_entries_1]); free(idx_1); } @@ -4840,8 +4831,7 @@ _PUBLIC_ void ndr_print_samr_ValidatePasswordInfo(struct ndr_print *ndr, const c ndr->depth++; for (cntr_pwd_history_1=0;cntr_pwd_history_1pwd_history_len;cntr_pwd_history_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_pwd_history_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_pwd_history_1) != -1) { ndr_print_samr_ValidationBlob(ndr, "pwd_history", &r->pwd_history[cntr_pwd_history_1]); free(idx_1); } @@ -7212,8 +7202,7 @@ _PUBLIC_ void ndr_print_samr_LookupNames(struct ndr_print *ndr, const char *name ndr->depth++; for (cntr_names_0=0;cntr_names_0in.num_names;cntr_names_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_names_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_names_0) != -1) { ndr_print_lsa_String(ndr, "names", &r->in.names[cntr_names_0]); free(idx_0); } @@ -7352,8 +7341,7 @@ _PUBLIC_ void ndr_print_samr_LookupRids(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_rids_0=0;cntr_rids_0in.num_rids;cntr_rids_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_rids_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_rids_0) != -1) { ndr_print_uint32(ndr, "rids", r->in.rids[cntr_rids_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_security.c b/source3/librpc/gen_ndr/ndr_security.c index 8ab56dd914..cbeabf48e5 100644 --- a/source3/librpc/gen_ndr/ndr_security.c +++ b/source3/librpc/gen_ndr/ndr_security.c @@ -552,8 +552,7 @@ _PUBLIC_ void ndr_print_security_acl(struct ndr_print *ndr, const char *name, co ndr->depth++; for (cntr_aces_0=0;cntr_aces_0num_aces;cntr_aces_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_aces_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_aces_0) != -1) { ndr_print_security_ace(ndr, "aces", &r->aces[cntr_aces_0]); free(idx_0); } @@ -981,8 +980,7 @@ _PUBLIC_ void ndr_print_security_token(struct ndr_print *ndr, const char *name, ndr->depth++; for (cntr_sids_0=0;cntr_sids_0num_sids;cntr_sids_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_sids_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_sids_0) != -1) { ndr_print_ptr(ndr, "sids", r->sids[cntr_sids_0]); ndr->depth++; if (r->sids[cntr_sids_0]) { diff --git a/source3/librpc/gen_ndr/ndr_srvsvc.c b/source3/librpc/gen_ndr/ndr_srvsvc.c index 86d47a856c..9b08ade4af 100644 --- a/source3/librpc/gen_ndr/ndr_srvsvc.c +++ b/source3/librpc/gen_ndr/ndr_srvsvc.c @@ -140,8 +140,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetCharDevCtr0(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetCharDevInfo0(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -326,8 +325,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetCharDevCtr1(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetCharDevInfo1(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -749,8 +747,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetCharDevQCtr0(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetCharDevQInfo0(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -938,8 +935,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetCharDevQCtr1(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetCharDevQInfo1(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -1325,8 +1321,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetConnCtr0(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetConnInfo0(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -1520,8 +1515,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetConnCtr1(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetConnInfo1(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -1769,8 +1763,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetFileCtr2(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetFileInfo2(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -1958,8 +1951,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetFileCtr3(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetFileInfo3(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -2381,8 +2373,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetSessCtr0(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetSessInfo0(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -2573,8 +2564,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetSessCtr1(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetSessInfo1(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -2798,8 +2788,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetSessCtr2(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetSessInfo2(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -2984,8 +2973,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetSessCtr10(struct ndr_print *ndr, const char *n ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetSessInfo10(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -3242,8 +3230,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetSessCtr502(struct ndr_print *ndr, const char * ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetSessInfo502(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -3694,8 +3681,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr0(struct ndr_print *ndr, const char *n ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo0(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -3877,8 +3863,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr1(struct ndr_print *ndr, const char *n ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo1(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -4135,8 +4120,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr2(struct ndr_print *ndr, const char *n ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo2(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -4321,8 +4305,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr501(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo501(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -4616,8 +4599,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr502(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo502(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -4763,8 +4745,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr1004(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo1004(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -4897,8 +4878,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr1005(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo1005(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -5008,8 +4988,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr1006(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo1006(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -5158,8 +5137,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr1007(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetShareInfo1007(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -5245,8 +5223,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareCtr1501(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_sec_desc_buf(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -11487,8 +11464,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetDiskInfo(struct ndr_print *ndr, const char *na ndr->depth++; for (cntr_disks_1=0;cntr_disks_1count;cntr_disks_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_disks_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_disks_1) != -1) { ndr_print_srvsvc_NetDiskInfo0(ndr, "disks", &r->disks[cntr_disks_1]); free(idx_1); } @@ -11781,8 +11757,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetTransportCtr0(struct ndr_print *ndr, const cha ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetTransportInfo0(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -12030,8 +12005,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetTransportCtr1(struct ndr_print *ndr, const cha ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetTransportInfo1(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -12282,8 +12256,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetTransportCtr2(struct ndr_print *ndr, const cha ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetTransportInfo2(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -12540,8 +12513,7 @@ _PUBLIC_ void ndr_print_srvsvc_NetTransportCtr3(struct ndr_print *ndr, const cha ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_srvsvc_NetTransportInfo3(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } diff --git a/source3/librpc/gen_ndr/ndr_unixinfo.c b/source3/librpc/gen_ndr/ndr_unixinfo.c index 03a8d30f03..b0b5c81395 100644 --- a/source3/librpc/gen_ndr/ndr_unixinfo.c +++ b/source3/librpc/gen_ndr/ndr_unixinfo.c @@ -425,8 +425,7 @@ _PUBLIC_ void ndr_print_unixinfo_GetPWUid(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_uids_0=0;cntr_uids_0<*r->in.count;cntr_uids_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_uids_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_uids_0) != -1) { ndr_print_hyper(ndr, "uids", r->in.uids[cntr_uids_0]); free(idx_0); } @@ -445,8 +444,7 @@ _PUBLIC_ void ndr_print_unixinfo_GetPWUid(struct ndr_print *ndr, const char *nam ndr->depth++; for (cntr_infos_0=0;cntr_infos_0<*r->out.count;cntr_infos_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_infos_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_infos_0) != -1) { ndr_print_unixinfo_GetPWUidInfo(ndr, "infos", &r->out.infos[cntr_infos_0]); free(idx_0); } diff --git a/source3/librpc/gen_ndr/ndr_winreg.c b/source3/librpc/gen_ndr/ndr_winreg.c index ed511a62db..cd16a141b0 100644 --- a/source3/librpc/gen_ndr/ndr_winreg.c +++ b/source3/librpc/gen_ndr/ndr_winreg.c @@ -3798,8 +3798,7 @@ _PUBLIC_ void ndr_print_winreg_QueryMultipleValues(struct ndr_print *ndr, const ndr->depth++; for (cntr_values_1=0;cntr_values_1in.num_values;cntr_values_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_values_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_values_1) != -1) { ndr_print_QueryMultipleValue(ndr, "values", &r->in.values[cntr_values_1]); free(idx_1); } @@ -3828,8 +3827,7 @@ _PUBLIC_ void ndr_print_winreg_QueryMultipleValues(struct ndr_print *ndr, const ndr->depth++; for (cntr_values_1=0;cntr_values_1in.num_values;cntr_values_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_values_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_values_1) != -1) { ndr_print_QueryMultipleValue(ndr, "values", &r->out.values[cntr_values_1]); free(idx_1); } diff --git a/source3/librpc/gen_ndr/ndr_wkssvc.c b/source3/librpc/gen_ndr/ndr_wkssvc.c index 096c0b2c72..80ea67526e 100644 --- a/source3/librpc/gen_ndr/ndr_wkssvc.c +++ b/source3/librpc/gen_ndr/ndr_wkssvc.c @@ -3071,8 +3071,7 @@ _PUBLIC_ void ndr_print_wkssvc_NetWkstaEnumUsersCtr0(struct ndr_print *ndr, cons ndr->depth++; for (cntr_user0_1=0;cntr_user0_1entries_read;cntr_user0_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_user0_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_user0_1) != -1) { ndr_print_wkssvc_NetrWkstaUserInfo0(ndr, "user0", &r->user0[cntr_user0_1]); free(idx_1); } @@ -3317,8 +3316,7 @@ _PUBLIC_ void ndr_print_wkssvc_NetWkstaEnumUsersCtr1(struct ndr_print *ndr, cons ndr->depth++; for (cntr_user1_1=0;cntr_user1_1entries_read;cntr_user1_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_user1_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_user1_1) != -1) { ndr_print_wkssvc_NetrWkstaUserInfo1(ndr, "user1", &r->user1[cntr_user1_1]); free(idx_1); } @@ -3909,8 +3907,7 @@ _PUBLIC_ void ndr_print_wkssvc_NetWkstaTransportCtr0(struct ndr_print *ndr, cons ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_wkssvc_NetWkstaTransportInfo0(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -4867,8 +4864,7 @@ _PUBLIC_ void ndr_print_wkssvc_NetrUseEnumCtr2(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_wkssvc_NetrUseInfo2(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -4954,8 +4950,7 @@ _PUBLIC_ void ndr_print_wkssvc_NetrUseEnumCtr1(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_wkssvc_NetrUseInfo1(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -5041,8 +5036,7 @@ _PUBLIC_ void ndr_print_wkssvc_NetrUseEnumCtr0(struct ndr_print *ndr, const char ndr->depth++; for (cntr_array_1=0;cntr_array_1count;cntr_array_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_array_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_array_1) != -1) { ndr_print_wkssvc_NetrUseInfo0(ndr, "array", &r->array[cntr_array_1]); free(idx_1); } @@ -5666,8 +5660,7 @@ _PUBLIC_ void ndr_print_wkssvc_ComputerNamesCtr(struct ndr_print *ndr, const cha ndr->depth++; for (cntr_computer_name_1=0;cntr_computer_name_1count;cntr_computer_name_1++) { char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_computer_name_1); - if (idx_1) { + if (asprintf(&idx_1, "[%d]", cntr_computer_name_1) != -1) { ndr_print_lsa_String(ndr, "computer_name", &r->computer_name[cntr_computer_name_1]); free(idx_1); } @@ -8836,8 +8829,7 @@ _PUBLIC_ void ndr_print_wkssvc_NetrGetJoinableOus(struct ndr_print *ndr, const c ndr->depth++; for (cntr_ous_2=0;cntr_ous_2<*r->out.num_ous;cntr_ous_2++) { char *idx_2=NULL; - asprintf(&idx_2, "[%d]", cntr_ous_2); - if (idx_2) { + if (asprintf(&idx_2, "[%d]", cntr_ous_2) != -1) { ndr_print_ptr(ndr, "ous", (*r->out.ous)[cntr_ous_2]); ndr->depth++; if ((*r->out.ous)[cntr_ous_2]) { @@ -9757,8 +9749,7 @@ _PUBLIC_ void ndr_print_wkssvc_NetrGetJoinableOus2(struct ndr_print *ndr, const ndr->depth++; for (cntr_ous_2=0;cntr_ous_2<*r->out.num_ous;cntr_ous_2++) { char *idx_2=NULL; - asprintf(&idx_2, "[%d]", cntr_ous_2); - if (idx_2) { + if (asprintf(&idx_2, "[%d]", cntr_ous_2) != -1) { ndr_print_ptr(ndr, "ous", (*r->out.ous)[cntr_ous_2]); ndr->depth++; if ((*r->out.ous)[cntr_ous_2]) { diff --git a/source3/librpc/gen_ndr/ndr_xattr.c b/source3/librpc/gen_ndr/ndr_xattr.c index 425ad814bf..46c4249d21 100644 --- a/source3/librpc/gen_ndr/ndr_xattr.c +++ b/source3/librpc/gen_ndr/ndr_xattr.c @@ -91,8 +91,7 @@ _PUBLIC_ void ndr_print_tdb_xattrs(struct ndr_print *ndr, const char *name, cons ndr->depth++; for (cntr_xattrs_0=0;cntr_xattrs_0num_xattrs;cntr_xattrs_0++) { char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_xattrs_0); - if (idx_0) { + if (asprintf(&idx_0, "[%d]", cntr_xattrs_0) != -1) { ndr_print_tdb_xattr(ndr, "xattrs", &r->xattrs[cntr_xattrs_0]); free(idx_0); } -- cgit From cef18563bb56b75dc45be494fab8e0ba5f1ab512 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:42:43 +0100 Subject: Check the return value of fgets (This used to be commit b8aaa9a69fd6217ce0387ef8e84f316706186d70) --- source3/lib/replace/getpass.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/getpass.c b/source3/lib/replace/getpass.c index d91d029f6a..57e28eb981 100644 --- a/source3/lib/replace/getpass.c +++ b/source3/lib/replace/getpass.c @@ -185,7 +185,10 @@ char *rep_getpass(const char *prompt) buf[0] = 0; if (!gotintr) { in_fd = fileno(in); - fgets(buf, bufsize, in); + if (fgets(buf, bufsize, in) == NULL) { + buf[0] = 0; + return buf; + } } nread = strlen(buf); if (nread) { -- cgit From 6dfb2614d81e2381c2fc5d9b4d4f152a56bfce5d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:43:58 +0100 Subject: Fix a C++ warning (This used to be commit d993b4c3cea6ead74ff1e031ee9a42f2aa39a9f1) --- source3/nsswitch/libwbclient/wbc_pam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c index 9b8a913a57..1164ab173a 100644 --- a/source3/nsswitch/libwbclient/wbc_pam.c +++ b/source3/nsswitch/libwbclient/wbc_pam.c @@ -136,7 +136,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx, 0); sn++; - p = resp->extra_data.data; + p = (char *)resp->extra_data.data; if (!p) { wbc_status = WBC_INVALID_RESPONSE; BAIL_ON_WBC_ERROR(wbc_status); -- cgit From 333c0aabc99df4ad6fed1d79d0fe66015b5d2ef6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:47:18 +0100 Subject: Check return value of dup(2) (This used to be commit d34701d49cf5b30f5b9963dab5643b4b62704413) --- source3/lib/sock_exec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/lib/sock_exec.c b/source3/lib/sock_exec.c index 203d7e93b3..278a174663 100644 --- a/source3/lib/sock_exec.c +++ b/source3/lib/sock_exec.c @@ -105,8 +105,12 @@ int sock_exec(const char *prog) close(fd[0]); close(0); close(1); - dup(fd[1]); - dup(fd[1]); + if (dup(fd[1]) == -1) { + exit(1); + } + if (dup(fd[1]) == -1) { + exit(1); + } exit(system(prog)); } close(fd[1]); -- cgit From fdf4e84e2b3fa7b29b384a7a18c422f98be35950 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:49:00 +0100 Subject: Check return value of pipe(2) (This used to be commit 49da21c03a1a5801fba4b12837cccf2887e0d8f0) --- source3/lib/select.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/select.c b/source3/lib/select.c index d5e4ba68f2..c3da6a9bba 100644 --- a/source3/lib/select.c +++ b/source3/lib/select.c @@ -58,7 +58,8 @@ int sys_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, s fd_set *readfds2, readfds_buf; if (initialised != sys_getpid()) { - pipe(select_pipe); + if (pipe(select_pipe) == -1) + smb_panic("Could not create select pipe"); /* * These next two lines seem to fix a bug with the Linux -- cgit From 6548493de7680dedd429bf851fc57b577e06c673 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:50:12 +0100 Subject: Fix a C++ warning (This used to be commit ac027a9b2e84d319f961ac0e84654a0e48920138) --- source3/libsmb/samlogon_cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index e2a4b3898f..3cc0dcf0fb 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -228,7 +228,8 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const DOM_SID * goto done; } - info3 = talloc_memdup(mem_ctx, &r.info3, sizeof(r.info3)); + info3 = (struct netr_SamInfo3 *)talloc_memdup(mem_ctx, &r.info3, + sizeof(r.info3)); done: SAFE_FREE(data.dptr); -- cgit From 44b2ba6880100417705dea05c9bf0272f1ddc3d3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:52:12 +0100 Subject: Fix a C++ warning (This used to be commit c4cab9e1c1f4975d970665f85838b2dea023d5fc) --- source3/utils/smbcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 76036bfdde..db2eefe1e2 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -1035,7 +1035,7 @@ static bool do_winbind_dump_domain_list(struct messaging_context *msg_ctx, print_pid_string_cb); buf_len = sizeof(myid)+domain_len; - buf = SMB_MALLOC(buf_len); + buf = SMB_MALLOC_ARRAY(uint8_t, buf_len); if (!buf) { return false; } -- cgit From a5e43bc81711e25cb07224df5e64f0120d4ef500 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 21:40:39 +0100 Subject: Fix typo (This used to be commit 621db68f32f7007de8b2c4d7cf604a5778725615) --- source3/libsmb/cliconnect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index e97be98fc1..d88a5d6242 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -581,8 +581,8 @@ static bool cli_session_setup_blob(struct cli_state *cli, DATA_BLOB blob, DATA_B if (cli_is_error(cli) && !NT_STATUS_EQUAL( cli_get_nt_error(cli), NT_STATUS_MORE_PROCESSING_REQUIRED)) { - DEBUG(0, ("cli_session_setup_blob: recieve failed (%s)\n", - nt_errstr(cli_get_nt_error(cli)) )); + DEBUG(0, ("cli_session_setup_blob: receive failed " + "(%s)\n", nt_errstr(cli_get_nt_error(cli)))); cli->vuid = 0; return False; } -- cgit From db9db9cef9b1ec04952ff7f0079cdff1e6ea8016 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 24 Feb 2008 00:01:07 +0100 Subject: AIO on streams does not work (yet...) (This used to be commit 1ba223f202a070a695581e0d7161473a3ebf4332) --- source3/smbd/aio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3') diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 8c6eaf1498..59dd9a9568 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -202,6 +202,12 @@ bool schedule_aio_read_and_X(connection_struct *conn, size_t bufsize; size_t min_aio_read_size = lp_aio_read_size(SNUM(conn)); + if (fsp->base_fsp != NULL) { + /* No AIO on streams yet */ + DEBUG(10, ("AIO on streams not yet supported\n")); + return false; + } + if ((!min_aio_read_size || (smb_maxcnt < min_aio_read_size)) && !SMB_VFS_AIO_FORCE(fsp)) { /* Too small a read for aio request. */ @@ -285,6 +291,12 @@ bool schedule_aio_write_and_X(connection_struct *conn, bool write_through = BITSETW(req->inbuf+smb_vwv7,0); size_t min_aio_write_size = lp_aio_write_size(SNUM(conn)); + if (fsp->base_fsp != NULL) { + /* No AIO on streams yet */ + DEBUG(10, ("AIO on streams not yet supported\n")); + return false; + } + if ((!min_aio_write_size || (numtowrite < min_aio_write_size)) && !SMB_VFS_AIO_FORCE(fsp)) { /* Too small a write for aio request. */ -- cgit From 658b72916f176190b78586073e922ffabf6704b5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 24 Feb 2008 01:00:39 +0100 Subject: Fix aix-build of libtalloc.so by exporting all necessary symbols. Use -bexpfull instead of -bexpall for LDSHFLAGS to also export symbols starting with "_". This exports all necessary symbols from libtalloc.so. Michael (This used to be commit 213ba3a719e77979c04b872f1d82f68e87287cb0) --- source3/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 78f0901c53..3ab2166095 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1573,7 +1573,7 @@ DSO_EXPORTS="" ;; *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix]) BLDSHARED="true" - LDSHFLAGS="-Wl,-G,-bexpall,-bbigtoc" + LDSHFLAGS="-Wl,-G,-bexpfull,-bbigtoc" DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc" PICFLAG="-O2" # as AIX code is always position independent... -- cgit From 21b6a036780ae0c020e199043c25c63fbbf8fa95 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 24 Feb 2008 11:39:57 +0100 Subject: Export aio_request_done() This is for external modules implementing the Posix AIO API that not necessarily depend on the signal mechanism to indicate completion. (This used to be commit 9a069d306bb6f8a2cd51b8ba87b433884942d13f) --- source3/smbd/aio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 59dd9a9568..78189d32f7 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -150,12 +150,18 @@ static uint16 aio_pending_array[AIO_PENDING_SIZE]; Signal handler when an aio request completes. *****************************************************************************/ -static void signal_handler(int sig, siginfo_t *info, void *unused) +void aio_request_done(uint16_t mid) { if (signals_received < AIO_PENDING_SIZE) { - aio_pending_array[signals_received] = info->si_value.sival_int; + aio_pending_array[signals_received] = mid; signals_received++; - } /* Else signal is lost. */ + } + /* Else signal is lost. */ +} + +static void signal_handler(int sig, siginfo_t *info, void *unused) +{ + aio_request_done(info->si_value.sival_int); sys_select_signal(RT_SIGNAL_AIO); } -- cgit From fcee8fee63fc907f106477a55d651b5a1be692bf Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 24 Feb 2008 11:32:22 +0100 Subject: Allow "max mux" async i/o requests In the negprot reply, we allowed the client to issued "max mux" concurrent requests. The OS might allow less, for example AFAIK AIX has a configurable limit of concurrent AIO requests. We will fall back to sync operation for the requests that are too many when aio_read/aio_write return an error. Jeremy, please check! (This used to be commit 8f86f7f25c4eb71bbdfcc6bf2d12eaaae9a8d9ec) --- source3/smbd/aio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 78189d32f7..2889e3c13f 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -141,10 +141,10 @@ static struct aio_extra *find_aio_ex(uint16 mid) We can have these many aio buffers in flight. *****************************************************************************/ -#define AIO_PENDING_SIZE 10 +static int aio_pending_size; static sig_atomic_t signals_received; static int outstanding_aio_calls; -static uint16 aio_pending_array[AIO_PENDING_SIZE]; +static uint16 *aio_pending_array; /**************************************************************************** Signal handler when an aio request completes. @@ -152,7 +152,7 @@ static uint16 aio_pending_array[AIO_PENDING_SIZE]; void aio_request_done(uint16_t mid) { - if (signals_received < AIO_PENDING_SIZE) { + if (signals_received < aio_pending_size) { aio_pending_array[signals_received] = mid; signals_received++; } @@ -182,6 +182,10 @@ void initialize_async_io_handler(void) { struct sigaction act; + aio_pending_size = lp_maxmux(); + aio_pending_array = SMB_MALLOC_ARRAY(uint16, aio_pending_size); + SMB_ASSERT(aio_pending_array != NULL); + ZERO_STRUCT(act); act.sa_sigaction = signal_handler; act.sa_flags = SA_SIGINFO; @@ -231,7 +235,7 @@ bool schedule_aio_read_and_X(connection_struct *conn, return False; } - if (outstanding_aio_calls >= AIO_PENDING_SIZE) { + if (outstanding_aio_calls >= aio_pending_size) { DEBUG(10,("schedule_aio_read_and_X: Already have %d aio " "activities outstanding.\n", outstanding_aio_calls )); @@ -320,7 +324,7 @@ bool schedule_aio_write_and_X(connection_struct *conn, return False; } - if (outstanding_aio_calls >= AIO_PENDING_SIZE) { + if (outstanding_aio_calls >= aio_pending_size) { DEBUG(3,("schedule_aio_write_and_X: Already have %d aio " "activities outstanding.\n", outstanding_aio_calls )); -- cgit From 90ad42fad3b59384953faff30925affb32677e03 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 Feb 2008 09:51:33 +0100 Subject: Fix confusing error message -- bug 5252 Thanks to Walter Franzini (This used to be commit 19de47fef1b35c47885acc40760a232e4643079c) --- source3/client/mount.cifs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index 44614f6e8a..c68c9ee7f7 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -205,8 +205,10 @@ static int open_cred_file(char * file_name) /* go past equals sign */ temp_val++; for(length = 0;length<4087;length++) { - if(temp_val[length] == '\n') + if ((temp_val[length] == '\n') + || (temp_val[length] == '\0')) { break; + } } if(length > 4086) { printf("mount.cifs failed due to malformed username in credentials file"); @@ -229,7 +231,7 @@ static int open_cred_file(char * file_name) /* go past equals sign */ temp_val++; for(length = 0;length<65;length++) { - if(temp_val[length] == '\n') + if(temp_val[length] == '\n' || temp_val[length] == '\0') break; } if(length > 64) { @@ -258,7 +260,7 @@ static int open_cred_file(char * file_name) if(verboseflag) printf("\nDomain %s\n",temp_val); for(length = 0;length<65;length++) { - if(temp_val[length] == '\n') + if(temp_val[length] == '\n' || temp_val[length] == '\0') break; } if(length > 64) { -- cgit From c7522804a57e839334e8165c8a2f14d1948ff450 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 Feb 2008 09:55:53 +0100 Subject: Do the formatting change in all 3 places :-) (This used to be commit d32066eaef1d09ec41fd5365e18eacd93e485d53) --- source3/client/mount.cifs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index c68c9ee7f7..e73d90859c 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -231,8 +231,10 @@ static int open_cred_file(char * file_name) /* go past equals sign */ temp_val++; for(length = 0;length<65;length++) { - if(temp_val[length] == '\n' || temp_val[length] == '\0') + if ((temp_val[length] == '\n') + || (temp_val[length] == '\0')) { break; + } } if(length > 64) { printf("mount.cifs failed: password in credentials file too long\n"); @@ -260,8 +262,10 @@ static int open_cred_file(char * file_name) if(verboseflag) printf("\nDomain %s\n",temp_val); for(length = 0;length<65;length++) { - if(temp_val[length] == '\n' || temp_val[length] == '\0') - break; + if ((temp_val[length] == '\n') + || (temp_val[length] == '\0')) { + break; + } } if(length > 64) { printf("mount.cifs failed: domain in credentials file too long\n"); -- cgit From 1f635e3888d51641a414f84f7402f249de287a74 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 25 Feb 2008 11:34:44 +0100 Subject: make test: pass --option=torture:sharedelay=100000 to samba4 smbtorture BASE-DEFER_OPEN is now more strict with incorrect timing metze (This used to be commit 9b761062df80c45bf2b76af071131d0c78e94a09) --- source3/script/tests/test_posix_s3.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/script/tests/test_posix_s3.sh b/source3/script/tests/test_posix_s3.sh index 91863b7a6b..7b4c0224ba 100755 --- a/source3/script/tests/test_posix_s3.sh +++ b/source3/script/tests/test_posix_s3.sh @@ -54,6 +54,8 @@ skipped="$skipped RAW-SFILEINFO" echo "WARNING: Skipping tests $skipped" +ADDARGS="$ADDARGS --option=torture:sharedelay=100000" + failed=0 for t in $tests; do if [ ! -z "$start" -a "$start" != $t ]; then -- cgit From 43491db17c8f0b62f5bfdcb68a92feef651ed5d4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 Feb 2008 12:52:55 +0100 Subject: Fix inotify detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug 5271 -- thanks to Tiziano Müller (This used to be commit 4a1a138b0fe0f2200e5a37a0609481e4340a896c) --- source3/configure.in | 2 +- source3/smbd/notify_inotify.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 3ab2166095..1c326a8ea2 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2362,7 +2362,7 @@ fi AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[ AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h) -AC_CHECK_FUNC(inotify_init) +AC_CHECK_FUNCS(inotify_init) AC_HAVE_DECL(__NR_inotify_init, [#include ]) ], samba_cv_HAVE_INOTIFY=yes, diff --git a/source3/smbd/notify_inotify.c b/source3/smbd/notify_inotify.c index 73cee440d4..fa0f0ed51d 100644 --- a/source3/smbd/notify_inotify.c +++ b/source3/smbd/notify_inotify.c @@ -29,10 +29,12 @@ #include #endif +#ifndef HAVE_INOTIFY_INIT + #include #include -#ifndef HAVE_INOTIFY_INIT + /* glibc doesn't define these functions yet (as of March 2006) */ @@ -50,6 +52,10 @@ static int inotify_rm_watch(int fd, int wd) { return syscall(__NR_inotify_rm_watch, fd, wd); } +#else + +#include + #endif -- cgit From cd95385207ff2a9c27031dcff19b7b74df3a626f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 Feb 2008 13:00:24 +0100 Subject: Correctly check return of rename(2) Bug 5279 -- Thanks to Max Matveev (This used to be commit 71641f04d4e9a41775e898f2e4ac3c8792783cd3) --- source3/modules/vfs_default.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index cf135dfd03..31ebb6352a 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -468,7 +468,7 @@ static int vfswrap_rename(vfs_handle_struct *handle, const char *oldname, const START_PROFILE(syscall_rename); result = rename(oldname, newname); - if (errno == EXDEV) { + if ((result == -1) && (errno == EXDEV)) { /* Rename across filesystems needed. */ result = copy_reg(oldname, newname); } -- cgit From 317639287886181edf08ccecad1b324e4cc55d0b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 Feb 2008 15:24:49 +0100 Subject: Fix some warnings warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result (This used to be commit ad37b7b0aee265a3e4d8b7552610f4b9a105434d) --- source3/intl/lang_tdb.c | 11 +++++++++-- source3/lib/debug.c | 10 ++++++---- source3/lib/gencache.c | 12 ++++++------ source3/lib/util_sock.c | 3 +-- source3/lib/util_str.c | 30 ++++++++++++++---------------- source3/lib/util_tdb.c | 16 +++++++++------- source3/libads/kerberos.c | 22 +++++++++++++++------- source3/librpc/ndr/ndr.c | 22 ++++++++++++++++++---- source3/librpc/ndr/ndr_basic.c | 3 +-- source3/librpc/ndr/ndr_string.c | 3 +-- source3/libsmb/clifsinfo.c | 3 +-- source3/param/loadparm.c | 3 +-- source3/passdb/machine_sid.c | 5 ++++- 13 files changed, 86 insertions(+), 57 deletions(-) (limited to 'source3') diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c index bb780c5fed..6ad9ef8496 100644 --- a/source3/intl/lang_tdb.c +++ b/source3/intl/lang_tdb.c @@ -127,7 +127,11 @@ bool lang_tdb_init(const char *lang) if (!lang) return True; - asprintf(&msg_path, "%s.msg", data_path((const char *)lang)); + if (asprintf(&msg_path, "%s.msg", + data_path((const char *)lang)) == -1) { + DEBUG(0, ("asprintf failed\n")); + goto done; + } if (stat(msg_path, &st) != 0) { /* the msg file isn't available */ DEBUG(10, ("lang_tdb_init: %s: %s\n", msg_path, @@ -135,7 +139,10 @@ bool lang_tdb_init(const char *lang) goto done; } - asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang); + if (asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang) == -1) { + DEBUG(0, ("asprintf failed\n")); + goto done; + } DEBUG(10, ("lang_tdb_init: loading %s\n", path)); diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 9ff267b607..c4a0d1b47b 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -827,6 +827,7 @@ void check_log_size( void ) }; int priority; char *msgbuf = NULL; + int ret; if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0) priority = LOG_DEBUG; @@ -834,10 +835,10 @@ void check_log_size( void ) priority = priority_map[syslog_level]; va_start(ap, format_str); - vasprintf(&msgbuf, format_str, ap); + ret = vasprintf(&msgbuf, format_str, ap); va_end(ap); - if (msgbuf) { + if (ret == -1) { syslog(priority, "%s", msgbuf); } SAFE_FREE(msgbuf); @@ -1059,12 +1060,13 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line) va_list ap; char *msgbuf = NULL; bool ret = true; + int res; va_start(ap, format_str); - vasprintf(&msgbuf, format_str, ap); + res = vasprintf(&msgbuf, format_str, ap); va_end(ap); - if (msgbuf) { + if (res != -1) { format_debug_text(msgbuf); } else { ret = false; diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 663385cfe3..6131269adb 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -120,9 +120,9 @@ bool gencache_set(const char *keystr, const char *value, time_t timeout) if (!gencache_init()) return False; - asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value); - if (!valstr) + if (asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value) == -1) { return False; + } databuf = string_term_tdb_data(valstr); DEBUG(10, ("Adding cache entry with key = %s; value = %s and timeout =" @@ -340,8 +340,7 @@ bool gencache_set_data_blob(const char *keystr, DATA_BLOB *blob, time_t timeout) return False; } - asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE); - if (!valstr) { + if (asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE) == -1) { return False; } @@ -452,8 +451,9 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time break; } - asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE, (unsigned int)databuf.dsize - TIMEOUT_LEN); - if (!fmt) { + if (asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE, + (unsigned int)databuf.dsize - TIMEOUT_LEN) + == -1) { SAFE_FREE(valstr); SAFE_FREE(entry); SAFE_FREE(keystr); diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index e040f4631a..a7c35c4887 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1904,8 +1904,7 @@ int create_pipe_sock(const char *socket_dir, goto out_close; } - asprintf(&path, "%s/%s", socket_dir, socket_name); - if (!path) { + if (asprintf(&path, "%s/%s", socket_dir, socket_name) == -1) { goto out_close; } diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index f631dfffee..cb8a100fa7 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -2086,6 +2086,7 @@ static char *ipstr_list_add(char **ipstr_list, const struct ip_service *service) { char *new_ipstr = NULL; char addr_buf[INET6_ADDRSTRLEN]; + int ret; /* arguments checking */ if (!ipstr_list || !service) { @@ -2100,33 +2101,30 @@ static char *ipstr_list_add(char **ipstr_list, const struct ip_service *service) if (*ipstr_list) { if (service->ss.ss_family == AF_INET) { /* IPv4 */ - asprintf(&new_ipstr, "%s%s%s:%d", - *ipstr_list, - IPSTR_LIST_SEP, - addr_buf, - service->port); + ret = asprintf(&new_ipstr, "%s%s%s:%d", *ipstr_list, + IPSTR_LIST_SEP, addr_buf, + service->port); } else { /* IPv6 */ - asprintf(&new_ipstr, "%s%s[%s]:%d", - *ipstr_list, - IPSTR_LIST_SEP, - addr_buf, - service->port); + ret = asprintf(&new_ipstr, "%s%s[%s]:%d", *ipstr_list, + IPSTR_LIST_SEP, addr_buf, + service->port); } SAFE_FREE(*ipstr_list); } else { if (service->ss.ss_family == AF_INET) { /* IPv4 */ - asprintf(&new_ipstr, "%s:%d", - addr_buf, - service->port); + ret = asprintf(&new_ipstr, "%s:%d", addr_buf, + service->port); } else { /* IPv6 */ - asprintf(&new_ipstr, "[%s]:%d", - addr_buf, - service->port); + ret = asprintf(&new_ipstr, "[%s]:%d", addr_buf, + service->port); } } + if (ret == -1) { + return NULL; + } *ipstr_list = new_ipstr; return *ipstr_list; } diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c index dd5ebcd7ab..724832ea5b 100644 --- a/source3/lib/util_tdb.c +++ b/source3/lib/util_tdb.c @@ -669,12 +669,13 @@ static void tdb_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, const char *fo { va_list ap; char *ptr = NULL; + int ret; va_start(ap, format); - vasprintf(&ptr, format, ap); + ret = vasprintf(&ptr, format, ap); va_end(ap); - if (!ptr || !*ptr) + if ((ret == -1) || !*ptr) return; DEBUG((int)level, ("tdb(%s): %s", tdb_name(tdb) ? tdb_name(tdb) : "unnamed", ptr)); @@ -867,11 +868,8 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, va_list ap; char *ptr = NULL; int debuglevel = 0; + int ret; - va_start(ap, format); - vasprintf(&ptr, format, ap); - va_end(ap); - switch (level) { case TDB_DEBUG_FATAL: debug_level = 0; @@ -889,7 +887,11 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, debuglevel = 0; } - if (ptr != NULL) { + va_start(ap, format); + ret = vasprintf(&ptr, format, ap); + va_end(ap); + + if (ret != -1) { const char *name = tdb_name(tdb); DEBUG(debuglevel, ("tdb(%s): %s", name ? name : "unnamed", ptr)); free(ptr); diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c index d47e8a3ff1..b37b9a500f 100644 --- a/source3/libads/kerberos.c +++ b/source3/libads/kerberos.c @@ -407,8 +407,8 @@ static char *kerberos_secrets_fetch_salting_principal(const char *service, int e char *key = NULL; char *ret = NULL; - asprintf(&key, "%s/%s/enctype=%d", SECRETS_SALTING_PRINCIPAL, service, enctype); - if (!key) { + if (asprintf(&key, "%s/%s/enctype=%d", + SECRETS_SALTING_PRINCIPAL, service, enctype) == -1) { return NULL; } ret = (char *)secrets_fetch(key, NULL); @@ -438,7 +438,10 @@ static char* des_salt_key( void ) { char *key; - asprintf(&key, "%s/DES/%s", SECRETS_SALTING_PRINCIPAL, lp_realm()); + if (asprintf(&key, "%s/DES/%s", SECRETS_SALTING_PRINCIPAL, + lp_realm()) == -1) { + return NULL; + } return key; } @@ -609,9 +612,13 @@ bool kerberos_secrets_store_salting_principal(const char *service, return False; } if (strchr_m(service, '@')) { - asprintf(&princ_s, "%s", service); + if (asprintf(&princ_s, "%s", service) == -1) { + goto out; + } } else { - asprintf(&princ_s, "%s@%s", service, lp_realm()); + if (asprintf(&princ_s, "%s@%s", service, lp_realm()) == -1) { + goto out; + } } if (smb_krb5_parse_name(context, princ_s, &princ) != 0) { @@ -622,8 +629,9 @@ bool kerberos_secrets_store_salting_principal(const char *service, goto out; } - asprintf(&key, "%s/%s/enctype=%d", SECRETS_SALTING_PRINCIPAL, unparsed_name, enctype); - if (!key) { + if (asprintf(&key, "%s/%s/enctype=%d", + SECRETS_SALTING_PRINCIPAL, unparsed_name, enctype) + == -1) { goto out; } diff --git a/source3/librpc/ndr/ndr.c b/source3/librpc/ndr/ndr.c index 62a88a8856..53eff00d59 100644 --- a/source3/librpc/ndr/ndr.c +++ b/source3/librpc/ndr/ndr.c @@ -176,12 +176,16 @@ _PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, { va_list ap; char *s = NULL; - int i; + int i, ret; va_start(ap, format); - vasprintf(&s, format, ap); + ret = vasprintf(&s, format, ap); va_end(ap); + if (ret == -1) { + return; + } + for (i=0;idepth;i++) { DEBUGADD(0,(" ")); } @@ -450,11 +454,16 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr, { char *s=NULL; va_list ap; + int ret; va_start(ap, format); - vasprintf(&s, format, ap); + ret = vasprintf(&s, format, ap); va_end(ap); + if (ret == -1) { + return NDR_ERR_ALLOC; + } + DEBUG(3,("ndr_pull_error(%u): %s\n", ndr_err, s)); free(s); @@ -471,11 +480,16 @@ _PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr, { char *s=NULL; va_list ap; + int ret; va_start(ap, format); - vasprintf(&s, format, ap); + ret = vasprintf(&s, format, ap); va_end(ap); + if (ret == -1) { + return NDR_ERR_ALLOC; + } + DEBUG(3,("ndr_push_error(%u): %s\n", ndr_err, s)); free(s); diff --git a/source3/librpc/ndr/ndr_basic.c b/source3/librpc/ndr/ndr_basic.c index 54397c9469..f342c6e36f 100644 --- a/source3/librpc/ndr/ndr_basic.c +++ b/source3/librpc/ndr/ndr_basic.c @@ -773,8 +773,7 @@ _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, ndr->depth++; for (i=0;idepth++; for (i=0;iparam_opt; } - asprintf(¶m_key, "%s:%s", type, option); - if (!param_key) { + if (asprintf(¶m_key, "%s:%s", type, option) == -1) { DEBUG(0,("asprintf failed!\n")); return NULL; } diff --git a/source3/passdb/machine_sid.c b/source3/passdb/machine_sid.c index d1599047a7..8fafcbbbd4 100644 --- a/source3/passdb/machine_sid.c +++ b/source3/passdb/machine_sid.c @@ -128,7 +128,10 @@ static DOM_SID *pdb_generate_sam_sid(void) } /* check for an old MACHINE.SID file for backwards compatibility */ - asprintf(&fname, "%s/MACHINE.SID", lp_private_dir()); + if (asprintf(&fname, "%s/MACHINE.SID", lp_private_dir()) == -1) { + SAFE_FREE(sam_sid); + return NULL; + } if (read_sid_from_file(fname, sam_sid)) { /* remember it for future reference and unlink the old MACHINE.SID */ -- cgit From b46bf471712ae152722ded16676ead1cbf7b2577 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 25 Feb 2008 17:05:21 +0100 Subject: Fix the build on OpenBSD: ENOTSUP is not always defined. Michael (This used to be commit 2e4028162f3a93c677a57b96de8f0cb2f892e73b) --- source3/modules/vfs_xattr_tdb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3') diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 0a92d5c591..7b5e510747 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -588,7 +588,11 @@ static bool xattr_tdb_init(int snum, struct db_context **p_db) unbecome_root(); if (db == NULL) { +#if defined(ENOTSUP) errno = ENOTSUP; +#else + errno = ENOSYS; +#endif return false; } -- cgit From 32dd3411195e3a0d5b2b05bc353e8045e07b6e5a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 25 Feb 2008 17:24:52 +0100 Subject: Fix build on some systems : don't pass libraries to mkproto.awk Currently, some static libraries have gone into object lists that are also passed to make proto. (This should probably be changed...) Then some awk versions fail when passed an non- existing lib/libtdb.a e.g.. This patch changes mkproto.sh to exclude \.a files from the list of files to process. Michael (This used to be commit 826b9ab07b58ca39350cca921002a4213ce7c7c9) --- source3/script/mkproto.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/script/mkproto.sh b/source3/script/mkproto.sh index e46e73e3e9..8561f42dff 100755 --- a/source3/script/mkproto.sh +++ b/source3/script/mkproto.sh @@ -25,7 +25,7 @@ header="$1" shift headertmp="$header.$$.tmp~" -proto_src="`echo $@ | tr ' ' '\n' | sed -e 's/\.o/\.c/g' | sort | uniq | egrep -v 'tdb/|wrapped|modules/getdate'`" +proto_src="`echo $@ | tr ' ' '\n' | sed -e 's/\.o/\.c/g' | sort | uniq | egrep -v 'tdb/|wrapped|modules/getdate' | egrep -v '\.a$'`" echo creating $header -- cgit From 79fa62a1bf486e7cc8a5ad01d6ed2440ea2cab26 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Tue, 26 Feb 2008 10:26:10 +0100 Subject: Fix some typos. Karolin (This used to be commit 71f05a1f9656c4a50dd4b8b08575be6536e92288) --- source3/utils/net_rpc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 5bc37f391f..0e31d013a1 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -3600,14 +3600,14 @@ static bool check_share_sanity(struct cli_state *cli, fstring netname, uint32 ty } /** - * Migrate shares from a remote RPC server to the local RPC srever + * Migrate shares from a remote RPC server to the local RPC server * * All parameters are provided by the run_rpc_command function, except for - * argc, argv which are passes through. + * argc, argv which are passed through. * * @param domain_sid The domain sid acquired from the remote server * @param cli A cli_state connected to the server. - * @param mem_ctx Talloc context, destoyed on completion of the function. + * @param mem_ctx Talloc context, destroyed on completion of the function. * @param argc Standard main() style argc * @param argv Standard main() style argv. Initial components are already * stripped -- cgit From 9f5c463415b8b7ea495589ce3fa9deb7c01efb2e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 26 Feb 2008 11:18:51 +0100 Subject: Fix build on VOS: socklen_t is needed for rep_inet_ntop: move it up. Michael (This used to be commit 7b98620ef16c6969fd21dd9c157aedd4adb117a3) --- source3/lib/replace/system/network.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index d09e3f71f8..a84b22e5d0 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -83,6 +83,11 @@ #include #endif +#ifndef HAVE_SOCKLEN_T +#define HAVE_SOCKLEN_T +typedef int socklen_t; +#endif + #ifdef REPLACE_INET_NTOA /* define is in "replace.h" */ char *rep_inet_ntoa(struct in_addr ip); @@ -245,11 +250,6 @@ void rep_freeifaddrs(struct ifaddrs *); #define HOST_NAME_MAX 256 #endif -#ifndef HAVE_SOCKLEN_T -#define HAVE_SOCKLEN_T -typedef int socklen_t; -#endif - #ifndef HAVE_SA_FAMILY_T #define HAVE_SA_FAMILY_T typedef unsigned short int sa_family_t; -- cgit From df3939da940c5f5cca9d0b782c84a0427c5b6b3a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 25 Feb 2008 17:42:12 +0100 Subject: configure: put swat-part of config into m4-include file of its own. Michael (This used to be commit 622667c0790c0092bfceced8dc6fb05e781ac5e7) --- source3/configure.in | 17 +---------------- source3/m4/swat.m4 | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 source3/m4/swat.m4 (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 1c326a8ea2..4fadfd7ae0 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -145,22 +145,7 @@ CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3" m4_include(lib/socket_wrapper/config.m4) m4_include(lib/nss_wrapper/config.m4) -SWAT_SBIN_TARGETS='bin/swat$(EXEEXT)' -SWAT_INSTALL_TARGETS=installswat - -AC_ARG_ENABLE(swat, -[AS_HELP_STRING([--enable-swat], [Build the SWAT tool (default=yes)])], -[ - case "$enable_swat" in - no) - SWAT_SBIN_TARGETS='' - SWAT_INSTALL_TARGETS='' - ;; - esac -]) - -AC_SUBST(SWAT_SBIN_TARGETS) -AC_SUBST(SWAT_INSTALL_TARGETS) +m4_include(m4/swat.m4) # Probe the gcc version for extra CFLAGS. We always stash these in # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple diff --git a/source3/m4/swat.m4 b/source3/m4/swat.m4 new file mode 100644 index 0000000000..2fdd82eda2 --- /dev/null +++ b/source3/m4/swat.m4 @@ -0,0 +1,27 @@ +dnl +dnl Samba3 build environment SWAT configuration +dnl +dnl Copyright (C) Michael Adam 2008 +dnl +dnl Released under the GNU General Public License +dnl http://www.gnu.org/licenses/ +dnl + + +SWAT_SBIN_TARGETS='bin/swat$(EXEEXT)' +SWAT_INSTALL_TARGETS=installswat + +AC_ARG_ENABLE(swat, +[AS_HELP_STRING([--enable-swat], [Build the SWAT tool (default=yes)])], +[ + case "$enable_swat" in + no) + SWAT_SBIN_TARGETS='' + SWAT_INSTALL_TARGETS='' + ;; + esac +]) + +AC_SUBST(SWAT_SBIN_TARGETS) +AC_SUBST(SWAT_INSTALL_TARGETS) + -- cgit From 7bdd648477c49dc7e23f832b2438bef673398fbf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 26 Feb 2008 13:24:54 +0100 Subject: libreplace: Add tests for connect and gethostbyname. Provide dummy replacements when a function isnt found. The functions are also searched for in certain libraries, and variables SOCKET_LIBS and NSL_LIBS are set accordingly. One purpose of this is to fix the getifaddrs tests on systems where e.g. the socket calls require special libs for linking. Michael (This used to be commit c19f7a0e1004213f95e0bf8db5cd1f6697c7a47b) --- source3/lib/replace/libreplace.m4 | 1 + source3/lib/replace/replace.h | 10 +++++++++ source3/lib/replace/socket.c | 35 +++++++++++++++++++++++++++++++ source3/lib/replace/socket.m4 | 40 ++++++++++++++++++++++++++++++++++++ source3/lib/replace/system/network.h | 10 +++++++++ 5 files changed, 96 insertions(+) create mode 100644 source3/lib/replace/socket.c create mode 100644 source3/lib/replace/socket.m4 (limited to 'source3') diff --git a/source3/lib/replace/libreplace.m4 b/source3/lib/replace/libreplace.m4 index 2e0cd34f4a..e0cc57f4c8 100644 --- a/source3/lib/replace/libreplace.m4 +++ b/source3/lib/replace/libreplace.m4 @@ -344,6 +344,7 @@ m4_include(getpass.m4) m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) +m4_include(socket.m4) m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(getaddrinfo.m4) diff --git a/source3/lib/replace/replace.h b/source3/lib/replace/replace.h index 3f91544e97..0d16f4ffd0 100644 --- a/source3/lib/replace/replace.h +++ b/source3/lib/replace/replace.h @@ -340,6 +340,16 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) /* prototype is in "system/network.h" */ #endif +#ifndef HAVE_CONNECT +#define connect rep_connect +/* prototype is in "system/network.h" */ +#endif + +#ifndef HAVE_GETHOSTBYNAME +#define gethostbyname rep_gethostbyname +/* prototype is in "system/network.h" */ +#endif + #ifndef HAVE_GETIFADDRS #define getifaddrs rep_getifaddrs /* prototype is in "system/network.h" */ diff --git a/source3/lib/replace/socket.c b/source3/lib/replace/socket.c new file mode 100644 index 0000000000..35e975fce7 --- /dev/null +++ b/source3/lib/replace/socket.c @@ -0,0 +1,35 @@ +/* + * Unix SMB/CIFS implementation. + * + * Dummy replacements for socket functions. + * + * Copyright (C) Michael Adam 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 "replace.h" +#include "system/network.h" + +int rep_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) +{ + errno = ENOSYS; + return -1; +} + +struct hostent *rep_gethostbyname(const char *name) +{ + errno = ENOSYS; + return NULL; +} diff --git a/source3/lib/replace/socket.m4 b/source3/lib/replace/socket.m4 new file mode 100644 index 0000000000..c0c8f93e81 --- /dev/null +++ b/source3/lib/replace/socket.m4 @@ -0,0 +1,40 @@ +dnl The following test is roughl taken from the cvs sources. +dnl +dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. +dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has +dnl libsocket.so which has a bad implementation of gethostbyname (it +dnl only looks in /etc/hosts), so we only look for -lsocket if we need +dnl it. +AC_CHECK_FUNCS(connect) +if test x"$ac_cv_func_connect" = x"no"; then + AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect) + dnl We can't just call AC_CHECK_FUNCS(connect) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || + test x"$ac_cv_lib_ext_nsl_connect" = x"yes" || + test x"$ac_cv_lib_ext_socket_connect" = x"yes" || + test x"$ac_cv_lib_ext_inet_connect" = x"yes" + then + AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()]) + fi +fi + +AC_CHECK_FUNCS(gethostbyname) +if test x"$ac_cv_func_gethostbyname" = x"no"; then + AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname) + dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || + test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" || + test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes" + then + AC_DEFINE(HAVE_GETHOSTBYNAME,1, + [Whether the system has gethostbyname()]) + fi +fi + diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index a84b22e5d0..410c6d7cca 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -103,6 +103,16 @@ int rep_inet_pton(int af, const char *src, void *dst); const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif +#ifndef HAVE_CONNECT +/* define is in "replace.h" */ +int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +#endif + +#ifndef HAVE_GETHOSTBYNAME +/* define is in "replace.h" */ +struct hostent *rep_gethostbyname(const char *name); +#endif + #ifdef HAVE_IFADDRS_H #include #endif -- cgit From 379fa9baaec5094b6509821d0c97f1f92cc3afb8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 26 Feb 2008 16:01:34 +0100 Subject: make idl: Only compile idl files newer than the output to be generated. Fix "if" condition in build_idl.sh to not always evaluate as false. Michael (This used to be commit 79c199d16e565eabd9fd971247f8df62689bb92a) --- source3/script/build_idl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/script/build_idl.sh b/source3/script/build_idl.sh index 7aaddc70c7..39a63573b9 100755 --- a/source3/script/build_idl.sh +++ b/source3/script/build_idl.sh @@ -23,7 +23,7 @@ for f in ${IDL_FILES}; do basename=`basename $f .idl` ndr="librpc/gen_ndr/ndr_$basename.c" - if [ -f $ndr ] && false; then + if [ -f $ndr ] ; then if [ "x`find librpc/idl/$f -newer $ndr -print`" = "xlibrpc/idl/$f" ]; then list="$list librpc/idl/$f" fi -- cgit From 75f56b1ad21515a15ba406f9135cf208f13765a1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 26 Feb 2008 16:02:47 +0100 Subject: Add libnet_join.idl to the IDL files to be processed by "make idl". Michael (This used to be commit 9b47a7329091b2bfe7cd9b2112ac8fa652ed9f60) --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index dce448d135..1b91b7e326 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1137,7 +1137,7 @@ modules: SHOWFLAGS $(MODULES) IDL_FILES = unixinfo.idl lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \ epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \ - dssetup.idl krb5pac.idl ntsvcs.idl + dssetup.idl krb5pac.idl ntsvcs.idl libnet_join.idl idl: @IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \ -- cgit From be626225ef8b70694012d539489075d240b4f2a8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 26 Feb 2008 16:04:34 +0100 Subject: Rerun make idl. To remove irritating semicolon. Michael (This used to be commit 3e1f88c90e4c5721381778062edfe6e681c8eec3) --- source3/librpc/gen_ndr/libnet_join.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/libnet_join.h b/source3/librpc/gen_ndr/libnet_join.h index 40759cb489..27e66ec0a5 100644 --- a/source3/librpc/gen_ndr/libnet_join.h +++ b/source3/librpc/gen_ndr/libnet_join.h @@ -7,8 +7,6 @@ #ifndef _HEADER_libnetjoin #define _HEADER_libnetjoin -; - struct libnet_JoinCtx { struct { -- cgit From d85c517b45b8feb8469f7073d770e7fedc818259 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 22 Feb 2008 17:35:53 +0100 Subject: Add variable to define if a share should be hidden. If you create a share on a Windows machine called foo$ then this share is of the type STYPE_DISKTREE. So it is possible to administrate this kind of share. Tested on Windows NT and 2003. In samba we assume that if a share with a $ at the end must be of the type STYPE_DISKTREE_HIDDEN. This is wrong, so we need a variable in the config to define if the share should be hidden or not. (This used to be commit a3da677bf0faed56e6731ee96708a7847a61d118) --- source3/param/loadparm.c | 5 +++++ source3/rpc_server/srv_srvsvc_nt.c | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 86446d5b75..79c522f77c 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -420,6 +420,7 @@ typedef struct { bool bRead_only; bool bNo_set_dir; bool bGuest_only; + bool bHidden; bool bGuest_ok; bool bPrint_ok; bool bMap_system; @@ -562,6 +563,7 @@ static service sDefault = { True, /* bRead_only */ True, /* bNo_set_dir */ False, /* bGuest_only */ + False, /* bHidden */ False, /* bGuest_ok */ False, /* bPrint_ok */ False, /* bMap_system */ @@ -971,6 +973,7 @@ static struct parm_struct parm_table[] = { {"inherit owner", P_BOOL, P_LOCAL, &sDefault.bInheritOwner, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_HIDE}, + {"hidden", P_BOOL, P_LOCAL, &sDefault.bHidden, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT}, {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT}, {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_HIDE}, @@ -2137,6 +2140,7 @@ FN_LOCAL_BOOL(lp_readonly, bRead_only) FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir) FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok) FN_LOCAL_BOOL(lp_guest_only, bGuest_only) +FN_LOCAL_BOOL(lp_hidden, bHidden) FN_LOCAL_BOOL(lp_print_ok, bPrint_ok) FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden) FN_LOCAL_BOOL(lp_map_archive, bMap_archive) @@ -2774,6 +2778,7 @@ static bool lp_add_ipc(const char *ipc_name, bool guest_ok) ServicePtrs[i]->bAvailable = True; ServicePtrs[i]->bRead_only = True; ServicePtrs[i]->bGuest_only = False; + ServicePtrs[i]->bHidden = True; ServicePtrs[i]->bGuest_ok = guest_ok; ServicePtrs[i]->bPrint_ok = False; ServicePtrs[i]->bBrowseable = sDefault.bBrowseable; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1b877ee5b4..f0680a89e5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -225,9 +225,6 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, ********************************************************************/ static uint32 get_share_type(int snum) { - char *net_name = lp_servicename(snum); - int len_net_name = strlen(net_name); - /* work out the share type */ uint32 type = STYPE_DISKTREE; @@ -235,7 +232,7 @@ static uint32 get_share_type(int snum) type = STYPE_PRINTQ; if (strequal(lp_fstype(snum), "IPC")) type = STYPE_IPC; - if (net_name[len_net_name-1] == '$') + if (lp_hidden(snum)) type |= STYPE_HIDDEN; return type; -- cgit From c58e7427bf7200ad413c259f429f020b98d723ec Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 26 Feb 2008 21:42:26 -0500 Subject: add a function to truncate a file to a specified size (This used to be commit 7e5752812d6d9e3bcf9a545cbdcf3afe2175dbc4) --- source3/libsmb/clifile.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source3') diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 10c35a30cc..12c427a6fa 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -888,6 +888,55 @@ bool cli_close(struct cli_state *cli, int fnum) } +/**************************************************************************** + Truncate a file to a specified size +****************************************************************************/ + +bool cli_ftruncate(struct cli_state *cli, int fnum, uint64_t size) +{ + unsigned int param_len = 6; + unsigned int data_len = 8; + uint16 setup = TRANSACT2_SETFILEINFO; + char param[6]; + unsigned char data[8]; + char *rparam=NULL, *rdata=NULL; + int saved_timeout = cli->timeout; + + SSVAL(param,0,fnum); + SSVAL(param,2,SMB_SET_FILE_END_OF_FILE_INFO); + SSVAL(param,4,0); + + SBVAL(data, 0, size); + + if (!cli_send_trans(cli, SMBtrans2, + NULL, /* name */ + -1, 0, /* fid, flags */ + &setup, 1, 0, /* setup, length, max */ + param, param_len, 2, /* param, length, max */ + (char *)&data, data_len,/* data, length, ... */ + cli->max_xmit)) { /* ... max */ + cli->timeout = saved_timeout; + return False; + } + + if (!cli_receive_trans(cli, SMBtrans2, + &rparam, ¶m_len, + &rdata, &data_len)) { + cli->timeout = saved_timeout; + SAFE_FREE(rdata); + SAFE_FREE(rparam); + return False; + } + + cli->timeout = saved_timeout; + + SAFE_FREE(rdata); + SAFE_FREE(rparam); + + return True; +} + + /**************************************************************************** send a lock with a specified locktype this is used for testing LOCKING_ANDX_CANCEL_LOCK -- cgit From 346c94972a0c603ecf8dd5690822c107dbeacc67 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 26 Feb 2008 21:43:13 -0500 Subject: add 64-bit macros from samba4 (This used to be commit a19e5fd5846685d5264e92bedf5cb57d99271f28) --- source3/include/byteorder.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3') diff --git a/source3/include/byteorder.h b/source3/include/byteorder.h index 32138a89ce..9ced9cea3a 100644 --- a/source3/include/byteorder.h +++ b/source3/include/byteorder.h @@ -167,4 +167,10 @@ it also defines lots of intermediate macros, just ignore those :-) #define ALIGN4(p,base) ((p) + ((4 - (PTR_DIFF((p), (base)) & 3)) & 3)) #define ALIGN2(p,base) ((p) + ((2 - (PTR_DIFF((p), (base)) & 1)) & 1)) +/* 64 bit macros */ +#define BVAL(p, ofs) (IVAL(p,ofs) | (((uint64_t)IVAL(p,(ofs)+4)) << 32)) +#define BVALS(p, ofs) ((int64_t)BVAL(p,ofs)) +#define SBVAL(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,((uint64_t)(v))>>32)) +#define SBVALS(p, ofs, v) (SBVAL(p,ofs,(uint64_t)v)) + #endif /* _BYTEORDER_H */ -- cgit From fa341d526293f4d986f2f3d838a728ce4223ee88 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 26 Feb 2008 21:44:51 -0500 Subject: add smbc_ftruncate() to emulate POSIX ftruncate() (This used to be commit 6f5051b9c1405ab1dc3e697419ceedb3acac46d8) --- source3/include/libsmbclient.h | 31 +++++++++++++++++ source3/libsmb/libsmb_compat.c | 6 ++++ source3/libsmb/libsmbclient.c | 75 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) (limited to 'source3') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 07242f7956..64afc09499 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -427,6 +427,8 @@ struct _SMBCCTX { off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); int (*stat) (SMBCCTX *c, const char *fname, struct stat *st); int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st); + /* ftruncate added near _internal for ABI compatibility */ + int (*close_fn) (SMBCCTX *c, SMBCFILE *file); /** callable functions for dirs @@ -520,6 +522,12 @@ struct _SMBCCTX { int flags; /** user options selections that apply to this session + * + * NEW OPTIONS ARE NOT ADDED HERE! + * + * We must maintain ABI backward compatibility. We now use + * smbc_option_set() and smbc_option_get() for all newly added + * options. */ struct _smbc_options { @@ -580,6 +588,9 @@ struct _SMBCCTX { int one_share_per_server; } options; + /* Add additional functions here for ABI backward compatibility */ + int (*ftruncate)(SMBCCTX *c, SMBCFILE *f, off_t size); + /** INTERNAL DATA * do _NOT_ touch this from your program ! */ @@ -1193,6 +1204,26 @@ int smbc_stat(const char *url, struct stat *st); int smbc_fstat(int fd, struct stat *st); +/**@ingroup attribute + * Truncate a file given a file descriptor + * + * @param fd Open file handle from smbc_open() or smbc_creat() + * + * @param size size to truncate the file to + * + * @return EBADF filedes is bad. + * - EACCES Permission denied. + * - EBADF fd is not a valid file descriptor + * - EINVAL Problems occurred in the underlying routines + * or smbc_init not called. + * - ENOMEM Out of memory + * + * @see , Unix ftruncate() + * + */ +int smbc_ftruncate(int fd, off_t size); + + /**@ingroup attribue * Change the ownership of a file or directory. * diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 573d087d6e..6042464fd2 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -289,6 +289,12 @@ int smbc_fstat(int fd, struct stat *st) return (statcont->fstat)(statcont, file, st); } +int smbc_ftruncate(int fd, off_t size) +{ + SMBCFILE * file = find_fd(fd); + return (statcont->ftruncate)(statcont, file, size); +} + int smbc_chmod(const char *url, mode_t mode) { return (statcont->chmod)(statcont, url, mode); diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index e84de59637..fe008ed6b6 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -2482,6 +2482,80 @@ smbc_fstat_ctx(SMBCCTX *context, } +/* + * Routine to truncate a file given by its file descriptor, to a specified size + */ + +static int +smbc_ftruncate_ctx(SMBCCTX *context, + SMBCFILE *file, + off_t length) +{ + SMB_OFF_T size = length; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->internal || + !context->internal->_initialized) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { + errno = EBADF; + TALLOC_FREE(frame); + return -1; + } + + if (!file->file) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ + if (smbc_parse_path(frame, + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>fstat: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", file->srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ + + if (!cli_ftruncate(targetcli, file->cli_fd, size)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + TALLOC_FREE(frame); + return 0; + +} + /* * Routine to open a directory * We accept the URL syntax explained in smbc_parse_path(), above. @@ -6703,6 +6777,7 @@ smbc_new_context(void) context->telldir = smbc_telldir_ctx; context->lseekdir = smbc_lseekdir_ctx; context->fstatdir = smbc_fstatdir_ctx; + context->ftruncate = smbc_ftruncate_ctx; context->chmod = smbc_chmod_ctx; context->utimes = smbc_utimes_ctx; context->setxattr = smbc_setxattr_ctx; -- cgit From 6fb37ae6725acda88876d92061a4db39f53cbf0a Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Tue, 26 Feb 2008 20:14:04 -0800 Subject: Closed memory leak on error path. (This used to be commit 376de8a0e4194e186b460911e3319b0f4448203e) --- source3/rpc_client/cli_pipe.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 40d0ac5da9..c89c5531d7 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -1807,6 +1807,7 @@ static NTSTATUS rpc_finish_auth3_bind(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(0,("rpc_finish_auth3_bind: NTLMSSP update using server blob failed.\n")); + data_blob_free(&server_response); return nt_status; } -- cgit From 71ab53a13be17c50ed7e640290407f0dca11db3c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 27 Feb 2008 10:06:53 +0100 Subject: Fix caller of node_status_query() to use sockaddr_storage(). Caller is hidden inside an #ifdef . Michael (This used to be commit 4a0d1ad601facf158db0c1d1c320e9e1369093d0) --- source3/nsswitch/wins.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/nsswitch/wins.c b/source3/nsswitch/wins.c index c822fc78b9..35649dfda2 100644 --- a/source3/nsswitch/wins.c +++ b/source3/nsswitch/wins.c @@ -147,7 +147,7 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count) static NODE_STATUS_STRUCT *lookup_byaddr_backend(char *addr, int *count) { int fd; - struct in_addr ip; + struct sockaddr_storage ss; struct nmb_name nname; NODE_STATUS_STRUCT *status; @@ -160,8 +160,10 @@ static NODE_STATUS_STRUCT *lookup_byaddr_backend(char *addr, int *count) return NULL; make_nmb_name(&nname, "*", 0); - (void)interpret_addr2(&ip,addr); - status = node_status_query(fd,&nname,ip, count, NULL); + if (!interpret_string_addr(&ss, addr, AI_NUMERICHOST)) { + return NULL; + } + status = node_status_query(fd, &nname, &ss, count, NULL); close(fd); return status; -- cgit From a565f50735e1c90b55c8069067821754938035f9 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 27 Feb 2008 01:29:12 +0100 Subject: libreplace: fix standalone build on some systems. getifaddr tests include system/network.h, which does not find getaddrinfo.h without "-I.". Michael (This used to be commit 66d4c38967e0d420929d4e1fdab0590161d526bc) --- source3/lib/replace/configure.ac | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/configure.ac b/source3/lib/replace/configure.ac index beeb77e152..72d788ddcc 100644 --- a/source3/lib/replace/configure.ac +++ b/source3/lib/replace/configure.ac @@ -3,6 +3,8 @@ AC_INIT(replace.c) AC_CONFIG_SRCDIR([replace.c]) AC_CONFIG_HEADER(config.h) +CFLAGS="$CFLAGS -I." + AC_LIBREPLACE_ALL_CHECKS if test "$ac_cv_prog_gcc" = yes; then -- cgit From e80790f649b181e2eb6a8bfa0ef0340d05ead050 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 27 Feb 2008 01:41:30 +0100 Subject: libreplace: fix standalone build - add necessary libs. The libs needed for getifaddrs replacements have to be added to LIBS and used for the testsuite target. Michael (This used to be commit f162de7b8012d29408060610a969ca76c61a4c80) --- source3/lib/replace/Makefile.in | 4 +++- source3/lib/replace/getifaddrs.m4 | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/Makefile.in b/source3/lib/replace/Makefile.in index 30f39ac6cb..af9522f3a6 100644 --- a/source3/lib/replace/Makefile.in +++ b/source3/lib/replace/Makefile.in @@ -10,6 +10,7 @@ VPATH = @libreplacedir@ srcdir = @srcdir@ builddir = @builddir@ INSTALL = @INSTALL@ +LIBS = @LIBS@ .PHONY: test all showflags install installcheck clean distclean realdistclean @@ -25,6 +26,7 @@ showflags: @echo ' CC = $(CC)' @echo ' CFLAGS = $(CFLAGS)' @echo ' LDFLAGS= $(LDFLAGS)' + @echo ' LIBS = $(LIBS)' install: all mkdir -p $(libdir) @@ -41,7 +43,7 @@ installcheck: install test TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o testsuite: libreplace.a $(TEST_OBJS) - $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) + $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS) .c.o: @echo Compiling $*.c diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index dd2a95cb81..767797e8d2 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -71,6 +71,7 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) + old_LIBS="$old_LIBS $LIBS" fi fi @@ -87,6 +88,7 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) + old_LIBS="$old_LIBS $LIBS" fi fi @@ -102,6 +104,7 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) + old_LIBS="$old_LIBS $LIBS" fi fi -- cgit From e281c0b1f5dd01f0d532dd8d5b22e966dc43b4e6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 27 Feb 2008 10:33:32 +0100 Subject: libreplace: standalone build: use -I$srcdir instead of -I. Michael (This used to be commit 5c08730f1938b8c56b70554378051d88d174c061) --- source3/lib/replace/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/configure.ac b/source3/lib/replace/configure.ac index 72d788ddcc..f5e054f476 100644 --- a/source3/lib/replace/configure.ac +++ b/source3/lib/replace/configure.ac @@ -3,7 +3,7 @@ AC_INIT(replace.c) AC_CONFIG_SRCDIR([replace.c]) AC_CONFIG_HEADER(config.h) -CFLAGS="$CFLAGS -I." +CFLAGS="$CFLAGS -I$srcdir" AC_LIBREPLACE_ALL_CHECKS -- cgit From 022b7d87a285a988759512afbc2fd061b61f9856 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 03:30:37 +0100 Subject: Copy recent spoolss IDL from samba4 into our tree. Guenther (This used to be commit 18233fb9d6dfbeee68c26c6a7449c292cc669550) --- source3/librpc/idl/spoolss.idl | 473 +++++++++++++++++++++++++++-------------- 1 file changed, 314 insertions(+), 159 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/spoolss.idl b/source3/librpc/idl/spoolss.idl index b64dfa481b..2144393ebd 100644 --- a/source3/librpc/idl/spoolss.idl +++ b/source3/librpc/idl/spoolss.idl @@ -3,16 +3,17 @@ /* spoolss interface definitions */ +import "security.idl", "winreg.idl"; [ uuid("12345678-1234-abcd-ef00-0123456789ab"), version(1.0), endpoint("ncacn_np:[\\pipe\\spoolss]"), pointer_default(unique), helpstring("Spooler SubSystem"), - depends(security), helper("librpc/ndr/ndr_spoolss_buf.h") ] interface spoolss { + typedef [v1_enum] enum winreg_Type winreg_Type; typedef struct { uint16 year; uint16 month; @@ -57,7 +58,7 @@ } spoolss_PrinterInfo0; typedef [public,gensize] struct { - string32 devicename; + [charset(UTF16)] uint16 devicename[32]; uint16 specversion; uint16 driverversion; uint16 size; @@ -76,7 +77,7 @@ uint16 yresolution; uint16 ttoption; uint16 collate; - string32 formname; + [charset(UTF16)] uint16 formname[32]; uint16 logpixels; uint32 bitsperpel; uint32 pelswidth; @@ -103,7 +104,6 @@ PRINTER_ENUM_REMOTE = 0x00000010, PRINTER_ENUM_SHARED = 0x00000020, PRINTER_ENUM_NETWORK = 0x00000040, - PRINTER_ENUM_UNKNOWN_8 = 0x00000008, PRINTER_ENUM_EXPAND = 0x00004000, PRINTER_ENUM_CONTAINER = 0x00008000, PRINTER_ENUM_ICON1 = 0x00010000, @@ -253,13 +253,13 @@ /* we are using this as internal parsing code */ [public,noopnum,noprint] WERROR _spoolss_EnumPrinters( [in] spoolss_EnumPrinterFlags flags, - [in] [string,charset(UTF16)] uint16 *server, + [in,unique] [string,charset(UTF16)] uint16 *server, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out] DATA_BLOB *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique] DATA_BLOB *info, + [out] uint32 needed, + [out] uint32 count ); [public,noopnum,noprint] void __spoolss_EnumPrinters( [in] uint32 level, @@ -268,16 +268,16 @@ ); [nopull,nopush] WERROR spoolss_EnumPrinters( [in] spoolss_EnumPrinterFlags flags, - [in] [string,charset(UTF16)] uint16 *server, + [in,unique] [string,charset(UTF16)] uint16 *server, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, /* what we have here is a subcontext containing an array of no discriminant unions * and the array has no size in front */ - [out,switch_is(level),size_is(count)] spoolss_PrinterInfo *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique,switch_is(level),size_is(count)] spoolss_PrinterInfo *info, + [out] uint32 needed, + [out] uint32 count ); /******************/ @@ -287,9 +287,9 @@ [subcontext(4),subcontext_size(_ndr_size)] spoolss_DeviceMode *devmode; } spoolss_DevmodeContainer; - WERROR spoolss_OpenPrinter( - [in] [string,charset(UTF16)] uint16 *printername, - [in] [string,charset(UTF16)] uint16 *datatype, + [public] WERROR spoolss_OpenPrinter( + [in,unique] [string,charset(UTF16)] uint16 *printername, + [in,unique] [string,charset(UTF16)] uint16 *datatype, [in] spoolss_DevmodeContainer devmode_ctr, [in] uint32 access_mask, [out,ref] policy_handle *handle @@ -338,7 +338,7 @@ WERROR spoolss_SetJob( [in,ref] policy_handle *handle, [in] uint32 job_id, - [in] spoolss_JobInfoContainer *ctr, + [in,unique] spoolss_JobInfoContainer *ctr, [in] spoolss_JobControl command ); @@ -348,10 +348,10 @@ [in,ref] policy_handle *handle, [in] uint32 job_id, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_JobInfo *info, - [out] uint32 *needed + [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_JobInfo *info, + [out] uint32 needed ); /******************/ @@ -361,11 +361,11 @@ [in] uint32 firstjob, [in] uint32 numjobs, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out] DATA_BLOB *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique] DATA_BLOB *info, + [out] uint32 needed, + [out] uint32 count ); [public,noopnum,noprint] void __spoolss_EnumJobs( [in] uint32 level, @@ -377,11 +377,11 @@ [in] uint32 firstjob, [in] uint32 numjobs, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,switch_is(level),size_is(count)] spoolss_JobInfo *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique,switch_is(level),size_is(count)] spoolss_JobInfo *info, + [out] uint32 needed, + [out] uint32 count ); /******************/ @@ -431,13 +431,13 @@ /******************/ /* Function: 0x08 */ - WERROR spoolss_GetPrinter( + [public] WERROR spoolss_GetPrinter( [in,ref] policy_handle *handle, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_PrinterInfo *info, - [out] uint32 *needed + [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_PrinterInfo *info, + [out] uint32 needed ); /******************/ @@ -537,14 +537,14 @@ /******************/ /* Function: 0x0a */ [public,noopnum,noprint] WERROR _spoolss_EnumPrinterDrivers( - [in] [string,charset(UTF16)] uint16 *server, - [in] [string,charset(UTF16)] uint16 *environment, + [in,unique] [string,charset(UTF16)] uint16 *server, + [in,unique] [string,charset(UTF16)] uint16 *environment, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out] DATA_BLOB *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique] DATA_BLOB *info, + [out] uint32 needed, + [out] uint32 count ); [public,noopnum,noprint] void __spoolss_EnumPrinterDrivers( [in] uint32 level, @@ -552,14 +552,14 @@ [out,switch_is(level)] spoolss_DriverInfo info[count] ); [nopull,nopush] WERROR spoolss_EnumPrinterDrivers( - [in] [string,charset(UTF16)] uint16 *server, - [in] [string,charset(UTF16)] uint16 *environment, + [in,unique] [string,charset(UTF16)] uint16 *server, + [in,unique] [string,charset(UTF16)] uint16 *environment, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,switch_is(level),size_is(count)] spoolss_DriverInfo *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique,switch_is(level),size_is(count)] spoolss_DriverInfo *info, + [out] uint32 needed, + [out] uint32 count ); /******************/ @@ -581,21 +581,21 @@ [default] spoolss_DriverDirectoryInfo1 info1; } spoolss_DriverDirectoryInfo; - WERROR spoolss_GetPrinterDriverDirectory( - [in] [string,charset(UTF16)] uint16 *server, - [in] [string,charset(UTF16)] uint16 *environment, + [public] WERROR spoolss_GetPrinterDriverDirectory( + [in,unique] [string,charset(UTF16)] uint16 *server, + [in,unique] [string,charset(UTF16)] uint16 *environment, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_DriverDirectoryInfo *info, - [out] uint32 *needed + [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_DriverDirectoryInfo *info, + [out] uint32 needed ); /******************/ /* Function: 0x0d */ WERROR spoolss_DeletePrinterDriver( [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 *server, + [in,unique] [string,charset(UTF16)] uint16 *server, [in] [string,charset(UTF16)] uint16 architecture[], [in] [string,charset(UTF16)] uint16 driver[] ); @@ -617,14 +617,14 @@ } spoolss_PrintProcessorInfo; [public,noopnum,noprint] WERROR _spoolss_EnumPrintProcessors( - [in] [string,charset(UTF16)] uint16 *servername, - [in] [string,charset(UTF16)] uint16 *environment, + [in,unique] [string,charset(UTF16)] uint16 *servername, + [in,unique] [string,charset(UTF16)] uint16 *environment, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out] DATA_BLOB *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique] DATA_BLOB *info, + [out] uint32 needed, + [out] uint32 count ); [public,noopnum,noprint] void __spoolss_EnumPrintProcessors( [in] uint32 level, @@ -632,14 +632,14 @@ [out,switch_is(level)] spoolss_PrintProcessorInfo info[count] ); [nopull,nopush] WERROR spoolss_EnumPrintProcessors( - [in] [string,charset(UTF16)] uint16 *servername, - [in] [string,charset(UTF16)] uint16 *environment, + [in,unique] [string,charset(UTF16)] uint16 *servername, + [in,unique] [string,charset(UTF16)] uint16 *environment, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,switch_is(level),size_is(count)] spoolss_PrintProcessorInfo *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique,switch_is(level),size_is(count)] spoolss_PrintProcessorInfo *info, + [out] uint32 needed, + [out] uint32 count ); /******************/ @@ -666,7 +666,7 @@ [in,ref] policy_handle *handle, [in] uint32 level, [in,switch_is(level)] spoolss_DocumentInfo info, - [out] uint32 *job_id + [out] uint32 job_id ); /******************/ @@ -681,7 +681,7 @@ [in,ref] policy_handle *handle, [in] DATA_BLOB data, [in,value(r->in.data.length)] uint32 _data_size, - [out] uint32 *num_written + [out] uint32 num_written ); /******************/ @@ -701,8 +701,8 @@ WERROR spoolss_ReadPrinter( [in,ref] policy_handle *handle, [in] uint32 data_size, - [out] DATA_BLOB *data, - [out,value(r->out.data.length)] uint32 *_data_size + [out] DATA_BLOB data, + [out,value(r->out.data.length)] uint32 _data_size ); /******************/ @@ -766,21 +766,21 @@ [in,ref] policy_handle *handle, [in] [string,charset(UTF16)] uint16 value_name[], [in] uint32 offered, - [out] spoolss_PrinterDataType *type, - [out] DATA_BLOB *data, - [out] uint32 *needed + [out] spoolss_PrinterDataType type, + [out] DATA_BLOB data, + [out] uint32 needed ); [noopnum,noprint,public] void __spoolss_GetPrinterData( [in] spoolss_PrinterDataType type, - [out,switch_is(type)] spoolss_PrinterData *data + [out,switch_is(type)] spoolss_PrinterData data ); - [nopull,nopush] WERROR spoolss_GetPrinterData( + [nopull,nopush,public] WERROR spoolss_GetPrinterData( [in,ref] policy_handle *handle, [in] [string,charset(UTF16)] uint16 value_name[], [in] uint32 offered, - [out] spoolss_PrinterDataType *type, - [out,subcontext(4),subcontext_size(offered),switch_is(type)] spoolss_PrinterData *data, - [out] uint32 *needed + [out] spoolss_PrinterDataType type, + [out,subcontext(4),subcontext_size(offered),switch_is(type)] spoolss_PrinterData data, + [out] uint32 needed ); /******************/ @@ -790,11 +790,11 @@ [in] [string,charset(UTF16)] uint16 value_name[], [in] spoolss_PrinterDataType type, [in] DATA_BLOB data, - [in] uint32 *_offered + [in] uint32 _offered ); [noopnum,nopull,noprint,public] void __spoolss_SetPrinterData( [in] spoolss_PrinterDataType type, - [out,switch_is(type)] spoolss_PrinterData *data + [out,switch_is(type)] spoolss_PrinterData data ); [nopush] WERROR spoolss_SetPrinterData( [in,ref] policy_handle *handle, @@ -811,7 +811,7 @@ /******************/ /* Function: 0x1d */ - WERROR spoolss_ClosePrinter( + [public] WERROR spoolss_ClosePrinter( [in,out,ref] policy_handle *handle ); @@ -877,10 +877,10 @@ [in,ref] policy_handle *handle, [in] [string,charset(UTF16)] uint16 form_name[], [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_FormInfo *info, - [out] uint32 *needed + [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_FormInfo *info, + [out] uint32 needed ); /******************/ @@ -897,11 +897,11 @@ [public,noopnum,noprint] WERROR _spoolss_EnumForms( [in,ref] policy_handle *handle, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out] DATA_BLOB *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique] DATA_BLOB *info, + [out] uint32 needed, + [out] uint32 count ); [public,noopnum,noprint] void __spoolss_EnumForms( [in] uint32 level, @@ -911,11 +911,11 @@ [nopull,nopush] WERROR spoolss_EnumForms( [in,ref] policy_handle *handle, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,switch_is(level),size_is(count)] spoolss_FormInfo *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique,switch_is(level),size_is(count)] spoolss_FormInfo *info, + [out] uint32 needed, + [out] uint32 count ); typedef struct { @@ -947,13 +947,13 @@ /******************/ /* Function: 0x23 */ [public,noopnum,noprint] WERROR _spoolss_EnumPorts( - [in] [string,charset(UTF16)] uint16 *servername, + [in,unique] [string,charset(UTF16)] uint16 *servername, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out] DATA_BLOB *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique] DATA_BLOB *info, + [out] uint32 needed, + [out] uint32 count ); [public,noopnum,noprint] void __spoolss_EnumPorts( [in] uint32 level, @@ -961,13 +961,13 @@ [out,switch_is(level)] spoolss_PortInfo info[count] ); [nopull,nopush] WERROR spoolss_EnumPorts( - [in] [string,charset(UTF16)] uint16 *servername, + [in,unique] [string,charset(UTF16)] uint16 *servername, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,switch_is(level),size_is(count)] spoolss_PortInfo *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique,switch_is(level),size_is(count)] spoolss_PortInfo *info, + [out] uint32 needed, + [out] uint32 count ); /******************/ @@ -989,13 +989,13 @@ } spoolss_MonitorInfo; [public,noopnum,noprint] WERROR _spoolss_EnumMonitors( - [in] [string,charset(UTF16)] uint16 *servername, + [in,unique] [string,charset(UTF16)] uint16 *servername, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out] DATA_BLOB *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique] DATA_BLOB *info, + [out] uint32 needed, + [out] uint32 count ); [public,noopnum,noprint] void __spoolss_EnumMonitors( [in] uint32 level, @@ -1003,19 +1003,19 @@ [out,switch_is(level)] spoolss_MonitorInfo info[count] ); [nopull,nopush] WERROR spoolss_EnumMonitors( - [in] [string,charset(UTF16)] uint16 *servername, + [in,unique] [string,charset(UTF16)] uint16 *servername, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, - [out,switch_is(level),size_is(count)] spoolss_MonitorInfo *info, - [out] uint32 *needed, - [out] uint32 *count + [out,unique,switch_is(level),size_is(count)] spoolss_MonitorInfo *info, + [out] uint32 needed, + [out] uint32 count ); /******************/ /* Function: 0x25 */ WERROR spoolss_AddPort( - [in] [string,charset(UTF16)] uint16 *server_name, + [in,unique] [string,charset(UTF16)] uint16 *server_name, [in] uint32 unknown, [in] [string,charset(UTF16)] uint16 monitor_name[] ); @@ -1101,16 +1101,16 @@ /* Function: 0x35 */ WERROR spoolss_GetPrinterDriver2( [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 *architecture, + [in,unique] [string,charset(UTF16)] uint16 *architecture, [in] uint32 level, - [in] DATA_BLOB *buffer, + [in,unique] DATA_BLOB *buffer, [in] uint32 offered, [in] uint32 client_major_version, [in] uint32 client_minor_version, - [out] DATA_BLOB *info, - [out] uint32 *needed, - [out] uint32 *server_major_version, - [out] uint32 *server_minor_version + [out,unique] DATA_BLOB *info, + [out] uint32 needed, + [out] uint32 server_major_version, + [out] uint32 server_minor_version ); /******************/ @@ -1125,7 +1125,8 @@ /******************/ /* Function: 0x38 */ - WERROR spoolss_FindClosePrinterNotify( + [public] WERROR spoolss_FindClosePrinterNotify( + [in,ref] policy_handle *handle ); /******************/ @@ -1135,7 +1136,13 @@ /******************/ /* Function: 0x3a */ - WERROR spoolss_ReplyOpenPrinter( + [public] WERROR spoolss_ReplyOpenPrinter( + [in,string,charset(UTF16)] uint16 server_name[], + [in] uint32 printer_local, + [in] winreg_Type type, + [in] uint32 unknown1, + [in] uint32 unknown2, + [out,ref] policy_handle *handle ); /******************/ @@ -1145,7 +1152,8 @@ /******************/ /* Function: 0x3c */ - WERROR spoolss_ReplyClosePrinter( + [public] WERROR spoolss_ReplyClosePrinter( + [in,out,ref] policy_handle *handle ); /******************/ @@ -1168,31 +1176,65 @@ WERROR spoolss_ResetPrinterEx( ); + typedef [enum16bit] enum { + SPOOLSS_FIELD_SERVER_NAME = 0, + SPOOLSS_FIELD_PRINTER_NAME = 1, + SPOOLSS_FIELD_SHARE_NAME = 2, + SPOOLSS_FIELD_PORT_NAME = 3, + SPOOLSS_FIELD_DRIVER_NAME = 4, + SPOOLSS_FIELD_COMMENT = 5, + SPOOLSS_FIELD_LOCATION = 6, + SPOOLSS_FIELD_DEVMODE = 7, + SPOOLSS_FIELD_SEPFILE = 8, + SPOOLSS_FIELD_PRINT_PROCESSOR = 9, + SPOOLSS_FIELD_PARAMETERS = 10, + SPOOLSS_FIELD_DATATYPE = 11, + SPOOLSS_FIELD_SECURITY_DESCRIPTOR=12, + SPOOLSS_FIELD_ATTRIBUTES = 13, + SPOOLSS_FIELD_PRIORITY = 14, + SPOOLSS_FIELD_DEFAULT_PRIORITY = 15, + SPOOLSS_FIELD_START_TIME = 16, + SPOOLSS_FIELD_UNTIL_TIME = 17, + SPOOLSS_FIELD_STATUS = 18, + SPOOLSS_FIELD_STATUS_STRING = 19, + SPOOLSS_FIELD_CJOBS = 20, + SPOOLSS_FIELD_AVERAGE_PPM = 21, + SPOOLSS_FIELD_TOTAL_PAGES = 22, + SPOOLSS_FIELD_PAGES_PRINTED = 23, + SPOOLSS_FIELD_TOTAL_BYTES = 24, + SPOOLSS_FIELD_BYTES_PRINTED = 25 + } spoolss_Field; + + typedef [enum16bit] enum { + SPOOLSS_NOTIFY_PRINTER = 0, + SPOOLSS_NOTIFY_JOB = 1 + } spoolss_NotifyType; + /******************/ /* Function: 0x41 */ - typedef [flag(NDR_PAHEX)] struct { + typedef struct { + spoolss_NotifyType type; uint16 u1; - uint16 u2; + uint32 u2; uint32 u3; - uint32 u4; uint32 count; - [size_is(count)] uint16 *array; - } spoolss_RemoteFindFirstPrinterChangeNotifyEx_t2; + [size_is(count)] spoolss_Field *fields; + } spoolss_NotifyOptionsArray; typedef struct { - uint32 u1; - uint32 u2; + uint32 version; + uint32 flags; uint32 count; - [size_is(count)] spoolss_RemoteFindFirstPrinterChangeNotifyEx_t2 *t2; - } spoolss_RemoteFindFirstPrinterChangeNotifyEx_t1; + [size_is(count)] spoolss_NotifyOptionsArray *options; + } spoolss_NotifyOptionsContainer; - WERROR spoolss_RemoteFindFirstPrinterChangeNotifyEx( + [public] WERROR spoolss_RemoteFindFirstPrinterChangeNotifyEx( [in,ref] policy_handle *handle, - [in] uint32 u1, - [in] uint32 u2, - [in] [string,charset(UTF16)] uint16 *str, - [in] uint32 u3, - [in] spoolss_RemoteFindFirstPrinterChangeNotifyEx_t1 *t1 + [in] uint32 flags, + [in] uint32 options, + [in,unique] [string,charset(UTF16)] uint16 *str, + [in] uint32 printer_local, + [in,unique] spoolss_NotifyOptionsContainer *t1 ); /******************/ @@ -1200,9 +1242,55 @@ WERROR spoolss_RouterRefreshPrinterChangeNotification( ); + typedef struct { + uint32 size; + [size_is(size/2),unique,charset(UTF16)] uint16 *string; + } spoolss_NotifyUTF16String; + + typedef struct { + uint32 size; + [size_is(size),charset(DOS)] uint8 *string; + } spoolss_NotifyDOSString; + + typedef struct { + uint16 data[8]; + } spoolss_NotifyBlobData; + + typedef struct { + uint32 len; + [unique] spoolss_NotifyBlobData *data; + } spoolss_NotifyBlob; + + typedef [switch_type(uint32)] union { + [case(1)] dlong integer; + [case(2)] spoolss_NotifyUTF16String utf16_string; + [case(3)] spoolss_NotifyDOSString ascii_string; + [case(4)] spoolss_NotifyBlob blob; + [case(5)] spoolss_NotifyDOSString ascii_string; + } spoolss_NotifyData; + + typedef struct { + spoolss_NotifyType type; + spoolss_Field field; + uint32 variable_type; + uint32 job_id; + [switch_is(variable_type)] spoolss_NotifyData data; + } spoolss_Notify; + + typedef struct { + uint32 version; + uint32 flags; + uint32 count; + [size_is(count)] spoolss_Notify notifies[]; + } spoolss_NotifyInfo; + /******************/ /* Function: 0x43 */ - WERROR spoolss_RemoteFindNextPrinterChangeNotifyEx( + [public] WERROR spoolss_RemoteFindNextPrinterChangeNotifyEx( + [in,ref] policy_handle *handle, + [in] uint32 change_low, + [in,unique] spoolss_NotifyOptionsContainer *container, + [out, unique] spoolss_NotifyInfo *info ); /******************/ @@ -1224,11 +1312,72 @@ [case(1)] spoolss_UserLevel1 *level1; } spoolss_UserLevel; + typedef bitmap { + SERVER_ACCESS_ADMINISTER = 0x00000001, + SERVER_ACCESS_ENUMERATE = 0x00000002, + PRINTER_ACCESS_ADMINISTER = 0x00000004, + PRINTER_ACCESS_USE = 0x00000008, + JOB_ACCESS_ADMINISTER = 0x00000010 + } spoolss_AccessRights; + + /* Access rights for print servers */ + const int SERVER_ALL_ACCESS = SEC_STD_REQUIRED | + SERVER_ACCESS_ADMINISTER | + SERVER_ACCESS_ENUMERATE; + + const int SERVER_READ = SEC_STD_READ_CONTROL | + SERVER_ACCESS_ENUMERATE; + + const int SERVER_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | + SERVER_ACCESS_ADMINISTER | + SERVER_ACCESS_ENUMERATE; + + const int SERVER_EXECUTE = SEC_STD_READ_CONTROL | + SERVER_ACCESS_ENUMERATE; + + /* Access rights for printers */ + const int PRINTER_ALL_ACCESS = SEC_STD_REQUIRED | + PRINTER_ACCESS_ADMINISTER | + PRINTER_ACCESS_USE; + + const int PRINTER_READ = SEC_STD_READ_CONTROL | + PRINTER_ACCESS_USE; + + const int PRINTER_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | + PRINTER_ACCESS_USE; + + const int PRINTER_EXECUTE = SEC_STD_READ_CONTROL | + PRINTER_ACCESS_USE; + + /* Access rights for jobs */ + const int JOB_ALL_ACCESS = SEC_STD_REQUIRED | + JOB_ACCESS_ADMINISTER; + + const int JOB_READ = SEC_STD_READ_CONTROL | + JOB_ACCESS_ADMINISTER; + + const int JOB_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | + JOB_ACCESS_ADMINISTER; + + const int JOB_EXECUTE = SEC_STD_READ_CONTROL | + JOB_ACCESS_ADMINISTER; + + /* ACE masks for various print permissions */ + const int PRINTER_ACE_FULL_CONTROL = SEC_GENERIC_ALL | + PRINTER_ALL_ACCESS; + + const int PRINTER_ACE_MANAGE_DOCUMENTS = SEC_GENERIC_ALL | + READ_CONTROL_ACCESS; + + const int PRINTER_ACE_PRINT = GENERIC_EXECUTE_ACCESS | + READ_CONTROL_ACCESS | + PRINTER_ACCESS_USE; + /******************/ /* Function: 0x45 */ - WERROR spoolss_OpenPrinterEx( - [in] [string,charset(UTF16)] uint16 *printername, - [in] [string,charset(UTF16)] uint16 *datatype, + [public] WERROR spoolss_OpenPrinterEx( + [in,unique] [string,charset(UTF16)] uint16 *printername, + [in,unique] [string,charset(UTF16)] uint16 *datatype, [in] spoolss_DevmodeContainer devmode_ctr, [in] uint32 access_mask, [in] uint32 level, @@ -1239,11 +1388,11 @@ /******************/ /* Function: 0x46 */ WERROR spoolss_AddPrinterEx( - [in] [string,charset(UTF16)] uint16 *server, + [in,unique] [string,charset(UTF16)] uint16 *server, [in] uint32 level, - [in,switch_is(level)] spoolss_PrinterInfo *info, + [in,unique,switch_is(level)] spoolss_PrinterInfo *info, [in] spoolss_DevmodeContainer devmode_ctr, - [in] security_descriptor *secdesc, + [in,unique] security_descriptor *secdesc, [in] uint32 ulevel, [in,switch_is(ulevel)] spoolss_UserLevel userlevel ); @@ -1258,12 +1407,13 @@ WERROR spoolss_EnumPrinterData( [in,ref] policy_handle *handle, [in] uint32 enum_index, + [out,ref,size_is(value_offered/2),charset(UTF16)] uint16 *value_name, [in] uint32 value_offered, - [out] lstring *value_name, - [out] uint32 *value_needed, - [out] uint32 *printerdata_type, - [out] DATA_BLOB *buffer, - [in,out,ref] uint32 *data_size + [out,ref] uint32 *value_needed, + [out,ref] uint32 *printerdata_type, + [out,ref] DATA_BLOB *buffer, + [in] uint32 data_offered, + [out,ref] uint32 *data_needed ); /******************/ @@ -1306,25 +1456,30 @@ [in] [string,charset(UTF16)] uint16 key_name[], [in] [string,charset(UTF16)] uint16 value_name[], [in] uint32 offered, - [out] uint32 *type, - [out] DATA_BLOB *buffer, - [out] uint32 *needed + [out] uint32 type, + [out] DATA_BLOB buffer, + [out] uint32 needed ); /******************/ /* Function: 0x4f */ - WERROR spoolss_EnumPrinterDataEx( + [public] WERROR spoolss_EnumPrinterDataEx( [in,ref] policy_handle *handle, [in] [string,charset(UTF16)] uint16 key_name[], [in] uint32 offered, - [out] DATA_BLOB *buffer, - [out] uint32 *needed, - [out] uint32 *count + [out] DATA_BLOB buffer, + [out] uint32 needed, + [out] uint32 count ); /******************/ /* Function: 0x50 */ - WERROR spoolss_EnumPrinterKey( + [public] WERROR spoolss_EnumPrinterKey( + [in, ref] policy_handle *handle, + [in] [string,charset(UTF16)] uint16 key_name[], + [out] uint32 key_buffer_size, + [out] uint16 key_buffer[key_buffer_size], + [in,out] uint32 needed ); /******************/ @@ -1374,14 +1529,14 @@ [in,value(r->in.in_data.length)] uint32 _in_data_length, [in] uint32 offered, [in] uint32 unknown1, - [out] DATA_BLOB *out_data, - [out] uint32 *needed, - [out] uint32 *unknown2 + [out] DATA_BLOB out_data, + [out] uint32 needed, + [out] uint32 unknown2 ); /******************/ /* Function: 0x59 */ - WERROR spoolss_AddPrinterDriverEx( + [public] WERROR spoolss_AddPrinterDriverEx( ); /******************/ -- cgit From c5e4455e074bb4be65dbaf8fdb3f1c8bfe93f900 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 15:46:35 +0100 Subject: Add lsa_PolicyAccessMask to lsa.idl. Guenther (This used to be commit 5fad28beec7eacd32f434a3bbfcaeb41640dfd22) --- source3/librpc/idl/lsa.idl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 38f3489a9f..6b38c5f74d 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -117,6 +117,21 @@ import "security.idl"; lsa_QosInfo *sec_qos; } lsa_ObjectAttribute; + typedef [public,bitmap32bit] bitmap { + LSA_POLICY_VIEW_LOCAL_INFORMATION = 0x00000001, + LSA_POLICY_VIEW_AUDIT_INFORMATION = 0x00000002, + LSA_POLICY_GET_PRIVATE_INFORMATION = 0x00000004, + LSA_POLICY_TRUST_ADMIN = 0x00000008, + LSA_POLICY_CREATE_ACCOUNT = 0x00000010, + LSA_POLICY_CREATE_SECRET = 0x00000020, + LSA_POLICY_CREATE_PRIVILEGE = 0x00000040, + LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS = 0x00000080, + LSA_POLICY_SET_AUDIT_REQUIREMENTS = 0x00000100, + LSA_POLICY_AUDIT_LOG_ADMIN = 0x00000200, + LSA_POLICY_SERVER_ADMIN = 0x00000400, + LSA_POLICY_LOOKUP_NAMES = 0x00000800 + } lsa_PolicyAccessMask; + /* notice the screwup with the system_name - thats why MS created OpenPolicy2 */ [public] NTSTATUS lsa_OpenPolicy ( -- cgit From 8f7fe454c4669d791e4a3854fe5c0399431473a3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 15:47:26 +0100 Subject: Use lsa_PolicyAccessMask in lsa_OpenPolicy/2. Guenther (This used to be commit 2b28ca34a1aad151ad712e5ecbb2a77c66d2b671) --- source3/librpc/idl/lsa.idl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 6b38c5f74d..228634ea1f 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -137,7 +137,7 @@ import "security.idl"; [public] NTSTATUS lsa_OpenPolicy ( [in,unique] uint16 *system_name, [in] lsa_ObjectAttribute *attr, - [in] uint32 access_mask, + [in] lsa_PolicyAccessMask access_mask, [out] policy_handle *handle ); @@ -752,7 +752,7 @@ import "security.idl"; [public] NTSTATUS lsa_OpenPolicy2 ( [in,unique] [string,charset(UTF16)] uint16 *system_name, [in] lsa_ObjectAttribute *attr, - [in] uint32 access_mask, + [in] lsa_PolicyAccessMask access_mask, [out] policy_handle *handle ); -- cgit From 3c54bb142e95bbc3e49d59ca28e960b1ee6a20f9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 15:56:18 +0100 Subject: Re-run make idl. Guenther (This used to be commit 01cdb071af7bc677450e511ebc7ef2036e9510e4) --- source3/librpc/gen_ndr/lsa.h | 14 +++++++++++++ source3/librpc/gen_ndr/ndr_lsa.c | 45 ++++++++++++++++++++++++++++++++++------ source3/librpc/gen_ndr/ndr_lsa.h | 3 +++ 3 files changed, 56 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index cc7bca3150..0840149563 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -63,6 +63,20 @@ struct lsa_ObjectAttribute { struct lsa_QosInfo *sec_qos;/* [unique] */ }; +/* bitmap lsa_PolicyAccessMask */ +#define LSA_POLICY_VIEW_LOCAL_INFORMATION ( 0x00000001 ) +#define LSA_POLICY_VIEW_AUDIT_INFORMATION ( 0x00000002 ) +#define LSA_POLICY_GET_PRIVATE_INFORMATION ( 0x00000004 ) +#define LSA_POLICY_TRUST_ADMIN ( 0x00000008 ) +#define LSA_POLICY_CREATE_ACCOUNT ( 0x00000010 ) +#define LSA_POLICY_CREATE_SECRET ( 0x00000020 ) +#define LSA_POLICY_CREATE_PRIVILEGE ( 0x00000040 ) +#define LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS ( 0x00000080 ) +#define LSA_POLICY_SET_AUDIT_REQUIREMENTS ( 0x00000100 ) +#define LSA_POLICY_AUDIT_LOG_ADMIN ( 0x00000200 ) +#define LSA_POLICY_SERVER_ADMIN ( 0x00000400 ) +#define LSA_POLICY_LOOKUP_NAMES ( 0x00000800 ) + struct lsa_AuditLogInfo { uint32_t percent_full; uint32_t log_size; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index b54f43a353..2a683fee77 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -640,6 +640,39 @@ _PUBLIC_ void ndr_print_lsa_ObjectAttribute(struct ndr_print *ndr, const char *n ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_lsa_PolicyAccessMask(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_lsa_PolicyAccessMask(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_PolicyAccessMask(struct ndr_print *ndr, const char *name, uint32_t r) +{ + ndr_print_uint32(ndr, name, r); + ndr->depth++; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_VIEW_LOCAL_INFORMATION", LSA_POLICY_VIEW_LOCAL_INFORMATION, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_VIEW_AUDIT_INFORMATION", LSA_POLICY_VIEW_AUDIT_INFORMATION, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_GET_PRIVATE_INFORMATION", LSA_POLICY_GET_PRIVATE_INFORMATION, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_TRUST_ADMIN", LSA_POLICY_TRUST_ADMIN, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_CREATE_ACCOUNT", LSA_POLICY_CREATE_ACCOUNT, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_CREATE_SECRET", LSA_POLICY_CREATE_SECRET, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_CREATE_PRIVILEGE", LSA_POLICY_CREATE_PRIVILEGE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS", LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_SET_AUDIT_REQUIREMENTS", LSA_POLICY_SET_AUDIT_REQUIREMENTS, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_AUDIT_LOG_ADMIN", LSA_POLICY_AUDIT_LOG_ADMIN, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_SERVER_ADMIN", LSA_POLICY_SERVER_ADMIN, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_POLICY_LOOKUP_NAMES", LSA_POLICY_LOOKUP_NAMES, r); + ndr->depth--; +} + static enum ndr_err_code ndr_push_lsa_AuditLogInfo(struct ndr_push *ndr, int ndr_flags, const struct lsa_AuditLogInfo *r) { if (ndr_flags & NDR_SCALARS) { @@ -4924,7 +4957,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenPolicy(struct ndr_push *ndr, int fla return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_lsa_ObjectAttribute(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.attr)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); + NDR_CHECK(ndr_push_lsa_PolicyAccessMask(ndr, NDR_SCALARS, r->in.access_mask)); } if (flags & NDR_OUT) { if (r->out.handle == NULL) { @@ -4964,7 +4997,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenPolicy(struct ndr_pull *ndr, int fla NDR_PULL_SET_MEM_CTX(ndr, r->in.attr, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_ObjectAttribute(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.attr)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_attr_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); + NDR_CHECK(ndr_pull_lsa_PolicyAccessMask(ndr, NDR_SCALARS, &r->in.access_mask)); NDR_PULL_ALLOC(ndr, r->out.handle); ZERO_STRUCTP(r->out.handle); } @@ -5001,7 +5034,7 @@ _PUBLIC_ void ndr_print_lsa_OpenPolicy(struct ndr_print *ndr, const char *name, ndr->depth++; ndr_print_lsa_ObjectAttribute(ndr, "attr", r->in.attr); ndr->depth--; - ndr_print_uint32(ndr, "access_mask", r->in.access_mask); + ndr_print_lsa_PolicyAccessMask(ndr, "access_mask", r->in.access_mask); ndr->depth--; } if (flags & NDR_OUT) { @@ -8459,7 +8492,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenPolicy2(struct ndr_push *ndr, int fl return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_lsa_ObjectAttribute(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.attr)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); + NDR_CHECK(ndr_push_lsa_PolicyAccessMask(ndr, NDR_SCALARS, r->in.access_mask)); } if (flags & NDR_OUT) { if (r->out.handle == NULL) { @@ -8505,7 +8538,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenPolicy2(struct ndr_pull *ndr, int fl NDR_PULL_SET_MEM_CTX(ndr, r->in.attr, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_ObjectAttribute(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.attr)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_attr_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); + NDR_CHECK(ndr_pull_lsa_PolicyAccessMask(ndr, NDR_SCALARS, &r->in.access_mask)); NDR_PULL_ALLOC(ndr, r->out.handle); ZERO_STRUCTP(r->out.handle); } @@ -8542,7 +8575,7 @@ _PUBLIC_ void ndr_print_lsa_OpenPolicy2(struct ndr_print *ndr, const char *name, ndr->depth++; ndr_print_lsa_ObjectAttribute(ndr, "attr", r->in.attr); ndr->depth--; - ndr_print_uint32(ndr, "access_mask", r->in.access_mask); + ndr_print_lsa_PolicyAccessMask(ndr, "access_mask", r->in.access_mask); ndr->depth--; } if (flags & NDR_OUT) { diff --git a/source3/librpc/gen_ndr/ndr_lsa.h b/source3/librpc/gen_ndr/ndr_lsa.h index 76add459c2..2df42dbaea 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.h +++ b/source3/librpc/gen_ndr/ndr_lsa.h @@ -193,6 +193,9 @@ void ndr_print_lsa_PrivEntry(struct ndr_print *ndr, const char *name, const stru void ndr_print_lsa_PrivArray(struct ndr_print *ndr, const char *name, const struct lsa_PrivArray *r); void ndr_print_lsa_QosInfo(struct ndr_print *ndr, const char *name, const struct lsa_QosInfo *r); void ndr_print_lsa_ObjectAttribute(struct ndr_print *ndr, const char *name, const struct lsa_ObjectAttribute *r); +enum ndr_err_code ndr_push_lsa_PolicyAccessMask(struct ndr_push *ndr, int ndr_flags, uint32_t r); +enum ndr_err_code ndr_pull_lsa_PolicyAccessMask(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); +void ndr_print_lsa_PolicyAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_lsa_AuditLogInfo(struct ndr_print *ndr, const char *name, const struct lsa_AuditLogInfo *r); void ndr_print_lsa_PolicyAuditPolicy(struct ndr_print *ndr, const char *name, enum lsa_PolicyAuditPolicy r); void ndr_print_lsa_AuditEventsInfo(struct ndr_print *ndr, const char *name, const struct lsa_AuditEventsInfo *r); -- cgit From 2d01ec2c390f8dd753600f22cefb17e7b8916ffd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 15:49:31 +0100 Subject: Use new LSA_POLICY defines in lsa rpc server code and other places. Guenther (This used to be commit 58cca9faf9db506bd2f6eab4a99ef85153797ab2) --- source3/include/rpc_lsa.h | 69 +++++++++++++++++------------------------ source3/libsmb/trusts_util.c | 2 +- source3/rpc_server/srv_lsa_nt.c | 48 ++++++++++++++-------------- source3/rpcclient/cmd_lsarpc.c | 2 +- 4 files changed, 54 insertions(+), 67 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 3f55e18e0f..a5316c49e5 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -27,51 +27,38 @@ #define LSA_AUDIT_NUM_CATEGORIES_WIN2K 9 #define LSA_AUDIT_NUM_CATEGORIES LSA_AUDIT_NUM_CATEGORIES_NT4 -#define POLICY_VIEW_LOCAL_INFORMATION 0x00000001 -#define POLICY_VIEW_AUDIT_INFORMATION 0x00000002 -#define POLICY_GET_PRIVATE_INFORMATION 0x00000004 -#define POLICY_TRUST_ADMIN 0x00000008 -#define POLICY_CREATE_ACCOUNT 0x00000010 -#define POLICY_CREATE_SECRET 0x00000020 -#define POLICY_CREATE_PRIVILEGE 0x00000040 -#define POLICY_SET_DEFAULT_QUOTA_LIMITS 0x00000080 -#define POLICY_SET_AUDIT_REQUIREMENTS 0x00000100 -#define POLICY_AUDIT_LOG_ADMIN 0x00000200 -#define POLICY_SERVER_ADMIN 0x00000400 -#define POLICY_LOOKUP_NAMES 0x00000800 +#define LSA_POLICY_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED_ACCESS |\ + LSA_POLICY_VIEW_LOCAL_INFORMATION |\ + LSA_POLICY_VIEW_AUDIT_INFORMATION |\ + LSA_POLICY_GET_PRIVATE_INFORMATION |\ + LSA_POLICY_TRUST_ADMIN |\ + LSA_POLICY_CREATE_ACCOUNT |\ + LSA_POLICY_CREATE_SECRET |\ + LSA_POLICY_CREATE_PRIVILEGE |\ + LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS |\ + LSA_POLICY_SET_AUDIT_REQUIREMENTS |\ + LSA_POLICY_AUDIT_LOG_ADMIN |\ + LSA_POLICY_SERVER_ADMIN |\ + LSA_POLICY_LOOKUP_NAMES ) -#define POLICY_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED_ACCESS |\ - POLICY_VIEW_LOCAL_INFORMATION |\ - POLICY_VIEW_AUDIT_INFORMATION |\ - POLICY_GET_PRIVATE_INFORMATION |\ - POLICY_TRUST_ADMIN |\ - POLICY_CREATE_ACCOUNT |\ - POLICY_CREATE_SECRET |\ - POLICY_CREATE_PRIVILEGE |\ - POLICY_SET_DEFAULT_QUOTA_LIMITS |\ - POLICY_SET_AUDIT_REQUIREMENTS |\ - POLICY_AUDIT_LOG_ADMIN |\ - POLICY_SERVER_ADMIN |\ - POLICY_LOOKUP_NAMES ) +#define LSA_POLICY_READ ( STANDARD_RIGHTS_READ_ACCESS |\ + LSA_POLICY_VIEW_AUDIT_INFORMATION |\ + LSA_POLICY_GET_PRIVATE_INFORMATION) -#define POLICY_READ ( STANDARD_RIGHTS_READ_ACCESS |\ - POLICY_VIEW_AUDIT_INFORMATION |\ - POLICY_GET_PRIVATE_INFORMATION) +#define LSA_POLICY_WRITE ( STD_RIGHT_READ_CONTROL_ACCESS |\ + LSA_POLICY_TRUST_ADMIN |\ + LSA_POLICY_CREATE_ACCOUNT |\ + LSA_POLICY_CREATE_SECRET |\ + LSA_POLICY_CREATE_PRIVILEGE |\ + LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS |\ + LSA_POLICY_SET_AUDIT_REQUIREMENTS |\ + LSA_POLICY_AUDIT_LOG_ADMIN |\ + LSA_POLICY_SERVER_ADMIN) -#define POLICY_WRITE ( STD_RIGHT_READ_CONTROL_ACCESS |\ - POLICY_TRUST_ADMIN |\ - POLICY_CREATE_ACCOUNT |\ - POLICY_CREATE_SECRET |\ - POLICY_CREATE_PRIVILEGE |\ - POLICY_SET_DEFAULT_QUOTA_LIMITS |\ - POLICY_SET_AUDIT_REQUIREMENTS |\ - POLICY_AUDIT_LOG_ADMIN |\ - POLICY_SERVER_ADMIN) - -#define POLICY_EXECUTE ( STANDARD_RIGHTS_EXECUTE_ACCESS |\ - POLICY_VIEW_LOCAL_INFORMATION |\ - POLICY_LOOKUP_NAMES ) +#define LSA_POLICY_EXECUTE ( STANDARD_RIGHTS_EXECUTE_ACCESS |\ + LSA_POLICY_VIEW_LOCAL_INFORMATION |\ + LSA_POLICY_LOOKUP_NAMES ) /*******************************************************/ #define MAX_REF_DOMAINS 32 diff --git a/source3/libsmb/trusts_util.c b/source3/libsmb/trusts_util.c index 1e92bf21de..c079fb149a 100644 --- a/source3/libsmb/trusts_util.c +++ b/source3/libsmb/trusts_util.c @@ -209,7 +209,7 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain, /* get a handle */ result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, True, - POLICY_VIEW_LOCAL_INFORMATION, &pol); + LSA_POLICY_VIEW_LOCAL_INFORMATION, &pol); if ( !NT_STATUS_IS_OK(result) ) goto done; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f43258d5e5..ec9da32874 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -40,10 +40,10 @@ struct lsa_info { }; const struct generic_mapping lsa_generic_mapping = { - POLICY_READ, - POLICY_WRITE, - POLICY_EXECUTE, - POLICY_ALL_ACCESS + LSA_POLICY_READ, + LSA_POLICY_WRITE, + LSA_POLICY_EXECUTE, + LSA_POLICY_ALL_ACCESS }; /*************************************************************************** @@ -289,17 +289,17 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s SEC_ACL *psa = NULL; - init_sec_access(&mask, POLICY_EXECUTE); + init_sec_access(&mask, LSA_POLICY_EXECUTE); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); sid_copy(&adm_sid, get_global_sam_sid()); sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS); - init_sec_access(&mask, POLICY_ALL_ACCESS); + init_sec_access(&mask, LSA_POLICY_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); sid_copy(&local_adm_sid, &global_sid_Builtin); sid_append_rid(&local_adm_sid, BUILTIN_ALIAS_RID_ADMINS); - init_sec_access(&mask, POLICY_ALL_ACCESS); + init_sec_access(&mask, LSA_POLICY_ALL_ACCESS); init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL) @@ -390,7 +390,7 @@ NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, /* This is needed for lsa_open_account and rpcclient .... :-) */ if (p->pipe_user.ut.uid == sec_initial_uid()) - acc_granted = POLICY_ALL_ACCESS; + acc_granted = LSA_POLICY_ALL_ACCESS; /* associate the domain SID with the (unique) handle. */ if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) @@ -483,7 +483,7 @@ NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ - if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(info->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; nt_status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains); @@ -558,7 +558,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, uint32 policy_def = LSA_AUDIT_POLICY_ALL; /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) { + if (!(handle->access & LSA_POLICY_VIEW_AUDIT_INFORMATION)) { DEBUG(10,("_lsa_QueryInfoPolicy: insufficient access rights\n")); return NT_STATUS_ACCESS_DENIED; } @@ -586,7 +586,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, } case 0x03: /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* Request PolicyPrimaryDomainInformation. */ @@ -615,7 +615,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, break; case 0x05: /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* Request PolicyAccountDomainInformation. */ @@ -626,7 +626,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, break; case 0x06: /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; switch (lp_server_role()) { @@ -793,7 +793,7 @@ NTSTATUS _lsa_LookupSids(pipes_struct *p, } /* check if the user has enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { + if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { return NT_STATUS_ACCESS_DENIED; } @@ -867,7 +867,7 @@ NTSTATUS _lsa_LookupSids2(pipes_struct *p, } /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { + if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { return NT_STATUS_ACCESS_DENIED; } } @@ -999,7 +999,7 @@ NTSTATUS _lsa_LookupNames(pipes_struct *p, } /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { + if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { status = NT_STATUS_ACCESS_DENIED; goto done; } @@ -1138,7 +1138,7 @@ NTSTATUS _lsa_LookupNames3(pipes_struct *p, } /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { + if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { status = NT_STATUS_ACCESS_DENIED; goto done; } @@ -1292,7 +1292,7 @@ NTSTATUS _lsa_EnumPrivs(pipes_struct *p, /* check if the user have enough rights I don't know if it's the right one. not documented. */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; if (num_privs) { @@ -1350,7 +1350,7 @@ NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, /* * I don't know if it's the right one. not documented. */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; DEBUG(10,("_lsa_LookupPrivDisplayName: name = %s\n", r->in.name->string)); @@ -1392,7 +1392,7 @@ NTSTATUS _lsa_EnumAccounts(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; sid_list = NULL; @@ -1505,7 +1505,7 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, * I don't know if it's the right one. not documented. * but guessed with rpcclient. */ - if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) + if (!(handle->access & LSA_POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* check to see if the pipe_user is a Domain Admin since @@ -1554,7 +1554,7 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p, * I don't know if it's the right one. not documented. * but guessed with rpcclient. */ - if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) + if (!(handle->access & LSA_POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* TODO: Fis the parsing routine before reenabling this check! */ @@ -1798,7 +1798,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; @@ -1855,7 +1855,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, switch (q_u->info_class) { case 0x0c: /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* Request PolicyPrimaryDomainInformation. */ diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 3fe8bc8e52..512d80ae15 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -394,7 +394,7 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli, } result = rpccli_lsa_open_policy(cli, mem_ctx, True, - POLICY_VIEW_LOCAL_INFORMATION, + LSA_POLICY_VIEW_LOCAL_INFORMATION, &pol); if (!NT_STATUS_IS_OK(result)) -- cgit From eaeb55ee9fa0989b4830f98e65c98dfa9ee731c2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 16:13:39 +0100 Subject: Move MAX_REF_DOMAINS to lsa.idl. Guenther (This used to be commit 8f54ba22d21eb014624670d8fdba7a63d1af684d) --- source3/include/rpc_lsa.h | 3 --- source3/librpc/idl/lsa.idl | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index a5316c49e5..43359e34d0 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -60,9 +60,6 @@ LSA_POLICY_VIEW_LOCAL_INFORMATION |\ LSA_POLICY_LOOKUP_NAMES ) -/*******************************************************/ -#define MAX_REF_DOMAINS 32 - /* This number is based on Win2k and later maximum response allowed */ #define MAX_LOOKUP_SIDS 20480 /* 0x5000 */ diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 228634ea1f..12be4d835b 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -375,6 +375,8 @@ import "security.idl"; } lsa_TransSidArray; const int LSA_REF_DOMAIN_LIST_MULTIPLIER = 32; + const int MAX_REF_DOMAINS = LSA_REF_DOMAIN_LIST_MULTIPLIER; + typedef struct { [range(0,1000)] uint32 count; [size_is(count)] lsa_DomainInfo *domains; -- cgit From f0b2ae2a183eb2576c829325dab9ed0cbc0437bd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 17:05:31 +0100 Subject: Re-run make idl. Guenther (This used to be commit 64e7f3f1422eb56c153ea0ad764b38e46410d594) --- source3/librpc/gen_ndr/lsa.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 0840149563..373c4fcd87 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -8,6 +8,7 @@ #define LSA_ENUM_TRUST_DOMAIN_MULTIPLIER ( 60 ) #define LSA_REF_DOMAIN_LIST_MULTIPLIER ( 32 ) +#define MAX_REF_DOMAINS ( LSA_REF_DOMAIN_LIST_MULTIPLIER ) #define LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER ( 82 ) struct lsa_String { uint16_t length;/* [value(2*strlen_m(string))] */ -- cgit From 1affdac7ca14542d79c03670c75e6240c309a11d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 16:03:17 +0100 Subject: Move MAX_LOOKUP_SIDS to lsa.idl. Guenther (This used to be commit 61da5b8c003f9c8785a901fadb06f0dbb8139c5f) --- source3/include/rpc_lsa.h | 3 --- source3/librpc/idl/lsa.idl | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 43359e34d0..2f23722d6a 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -60,7 +60,4 @@ LSA_POLICY_VIEW_LOCAL_INFORMATION |\ LSA_POLICY_LOOKUP_NAMES ) -/* This number is based on Win2k and later maximum response allowed */ -#define MAX_LOOKUP_SIDS 20480 /* 0x5000 */ - #endif /* _RPC_LSA_H */ diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 12be4d835b..68dc0497da 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -425,6 +425,9 @@ import "security.idl"; [size_is(count)] lsa_TranslatedName *names; } lsa_TransNameArray; + /* This number is based on Win2k and later maximum response allowed */ + const int MAX_LOOKUP_SIDS = 0x5000; /* 20480 */ + [public] NTSTATUS lsa_LookupSids ( [in] policy_handle *handle, [in,ref] lsa_SidArray *sids, -- cgit From f084c60dc6136d3e442df9cec900f9d8af780fb4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 17:06:03 +0100 Subject: Re-run make idl. Guenther (This used to be commit 360220a6a358bb36dd705213f3c9fd2bb463e49a) --- source3/librpc/gen_ndr/lsa.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 373c4fcd87..0f0ed143eb 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -9,6 +9,7 @@ #define LSA_ENUM_TRUST_DOMAIN_MULTIPLIER ( 60 ) #define LSA_REF_DOMAIN_LIST_MULTIPLIER ( 32 ) #define MAX_REF_DOMAINS ( LSA_REF_DOMAIN_LIST_MULTIPLIER ) +#define MAX_LOOKUP_SIDS ( 0x5000 ) #define LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER ( 82 ) struct lsa_String { uint16_t length;/* [value(2*strlen_m(string))] */ -- cgit From ec790d039779c2a920911bbcdc6969f792e86ab1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 16:14:27 +0100 Subject: Move LSA_AUDIT_NUM_CATEGORIES defines to lsa rpc_server. Guenther (This used to be commit 9e7d32e28ce40ff158f3705354e8673f99b462bc) --- source3/include/rpc_lsa.h | 4 ---- source3/rpc_server/srv_lsa_nt.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 2f23722d6a..b4021afd0a 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -23,10 +23,6 @@ #ifndef _RPC_LSA_H /* _RPC_LSA_H */ #define _RPC_LSA_H -#define LSA_AUDIT_NUM_CATEGORIES_NT4 7 -#define LSA_AUDIT_NUM_CATEGORIES_WIN2K 9 -#define LSA_AUDIT_NUM_CATEGORIES LSA_AUDIT_NUM_CATEGORIES_NT4 - #define LSA_POLICY_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED_ACCESS |\ LSA_POLICY_VIEW_LOCAL_INFORMATION |\ LSA_POLICY_VIEW_AUDIT_INFORMATION |\ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ec9da32874..788fdb3661 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -529,6 +529,10 @@ NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, return nt_status; } +#define LSA_AUDIT_NUM_CATEGORIES_NT4 7 +#define LSA_AUDIT_NUM_CATEGORIES_WIN2K 9 +#define LSA_AUDIT_NUM_CATEGORIES LSA_AUDIT_NUM_CATEGORIES_NT4 + /*************************************************************************** _lsa_QueryInfoPolicy ***************************************************************************/ -- cgit From c672a343138b4c642fe8902337d7a9225531c276 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 16:49:44 +0100 Subject: Move PASS_*_CHANGE_AT_NEXT_LOGON defines to samr.idl. Guenther (This used to be commit 618eae4c0cd6a68349a76cdf36f281733fb472ae) --- source3/include/rpc_samr.h | 3 --- source3/librpc/idl/samr.idl | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h index cf6027999b..12fbfb601d 100644 --- a/source3/include/rpc_samr.h +++ b/source3/include/rpc_samr.h @@ -74,9 +74,6 @@ SamrTestPrivateFunctionsUser ********************************************************************/ -#define PASS_MUST_CHANGE_AT_NEXT_LOGON 0x01 -#define PASS_DONT_CHANGE_AT_NEXT_LOGON 0x00 - #define MAX_SAM_ENTRIES_W2K 0x400 #define MAX_SAM_ENTRIES_W95 50 /* The following should be the greater of the preceeding two. */ diff --git a/source3/librpc/idl/samr.idl b/source3/librpc/idl/samr.idl index ebd1975458..ddef8b4d30 100644 --- a/source3/librpc/idl/samr.idl +++ b/source3/librpc/idl/samr.idl @@ -779,6 +779,10 @@ import "misc.idl", "lsa.idl", "security.idl"; SAMR_FIELD_OWF_PWD = 0x20000000 } samr_FieldsPresent; + /* used for 'password_expired' in samr_UserInfo21 */ + const int PASS_MUST_CHANGE_AT_NEXT_LOGON = 0x01; + const int PASS_DONT_CHANGE_AT_NEXT_LOGON = 0x00; + typedef struct { NTTIME last_logon; NTTIME last_logoff; -- cgit From 446a037156cdb94c1b7a541ce67cc90b460808ac Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 17:14:22 +0100 Subject: Re-run make idl. Guenther (This used to be commit 44e63dbac990333878cda4f1a16634496ba47d0e) --- source3/librpc/gen_ndr/samr.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/samr.h b/source3/librpc/gen_ndr/samr.h index dff4bf80f0..fb40e0ee87 100644 --- a/source3/librpc/gen_ndr/samr.h +++ b/source3/librpc/gen_ndr/samr.h @@ -9,6 +9,8 @@ #define _HEADER_samr #define SAMR_ENUM_USERS_MULTIPLIER ( 54 ) +#define PASS_MUST_CHANGE_AT_NEXT_LOGON ( 0x01 ) +#define PASS_DONT_CHANGE_AT_NEXT_LOGON ( 0x00 ) /* bitmap samr_AcctFlags */ #define ACB_DISABLED ( 0x00000001 ) #define ACB_HOMDIRREQ ( 0x00000002 ) -- cgit From d61831dcd414e0279dfd576a8c85a83a37bf2699 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 16:52:39 +0100 Subject: Move MAX_SAM_ENTRIES defines to samr rpc_server and to samr.idl. Guenther (This used to be commit 6c6455157317049d65a9012f4e339b7e86fb0af6) --- source3/include/rpc_samr.h | 5 ----- source3/librpc/idl/samr.idl | 4 ++++ source3/rpc_server/srv_samr_nt.c | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h index 12fbfb601d..9491212e3d 100644 --- a/source3/include/rpc_samr.h +++ b/source3/include/rpc_samr.h @@ -74,11 +74,6 @@ SamrTestPrivateFunctionsUser ********************************************************************/ -#define MAX_SAM_ENTRIES_W2K 0x400 -#define MAX_SAM_ENTRIES_W95 50 -/* The following should be the greater of the preceeding two. */ -#define MAX_SAM_ENTRIES MAX_SAM_ENTRIES_W2K - /* these are from the old rpc_samr.h - they are needed while the merge is still going on */ #define MAX_SAM_SIDS 15 diff --git a/source3/librpc/idl/samr.idl b/source3/librpc/idl/samr.idl index ddef8b4d30..ac0934d85c 100644 --- a/source3/librpc/idl/samr.idl +++ b/source3/librpc/idl/samr.idl @@ -316,6 +316,10 @@ import "misc.idl", "lsa.idl", "security.idl"; /************************/ /* Function 0x0b */ + + const int MAX_SAM_ENTRIES_W2K = 0x400; /* 1024 */ + const int MAX_SAM_ENTRIES_W95 = 50; + NTSTATUS samr_EnumDomainGroups( [in] policy_handle *domain_handle, [in,out,ref] uint32 *resume_handle, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index df7bb9b206..8289440d6e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -876,6 +876,8 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, return NT_STATUS_OK; } +#define MAX_SAM_ENTRIES MAX_SAM_ENTRIES_W2K + /******************************************************************* _samr_EnumDomainUsers ********************************************************************/ -- cgit From a136e403add8bfd299ba9963964ed7337eba0a5f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 17:15:09 +0100 Subject: Re-run make idl. Guenther (This used to be commit 2ebfd28cf73a63ccf595775853e9b1660a43fd20) --- source3/librpc/gen_ndr/samr.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/samr.h b/source3/librpc/gen_ndr/samr.h index fb40e0ee87..700c46222d 100644 --- a/source3/librpc/gen_ndr/samr.h +++ b/source3/librpc/gen_ndr/samr.h @@ -8,6 +8,8 @@ #ifndef _HEADER_samr #define _HEADER_samr +#define MAX_SAM_ENTRIES_W2K ( 0x400 ) +#define MAX_SAM_ENTRIES_W95 ( 50 ) #define SAMR_ENUM_USERS_MULTIPLIER ( 54 ) #define PASS_MUST_CHANGE_AT_NEXT_LOGON ( 0x01 ) #define PASS_DONT_CHANGE_AT_NEXT_LOGON ( 0x00 ) -- cgit From 42f5c6d20cfc728344fc5f9ecf9407bb10d77896 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 16:54:01 +0100 Subject: Remove unneeded rpc_samr.h. Guenther (This used to be commit e6701352dc2cd4ff9cc7d04db6f1975594477cdb) --- source3/include/includes.h | 1 - source3/include/rpc_samr.h | 81 ---------------------------------------------- 2 files changed, 82 deletions(-) delete mode 100644 source3/include/rpc_samr.h (limited to 'source3') diff --git a/source3/include/includes.h b/source3/include/includes.h index 02edbb0401..a2c3a0c466 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -698,7 +698,6 @@ typedef char fstring[FSTRING_LEN]; #include "rpc_netlogon.h" #include "reg_objects.h" #include "reg_db.h" -#include "rpc_samr.h" #include "rpc_srvsvc.h" #include "rpc_spoolss.h" #include "rpc_eventlog.h" diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h deleted file mode 100644 index 9491212e3d..0000000000 --- a/source3/include/rpc_samr.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-2000 - Copyright (C) Luke Kenneth Casson Leighton 1996-2000 - Copyright (C) Paul Ashton 1997-2000 - Copyright (C) Jean François Micouleau 1998-2001 - Copyright (C) Jim McDonough 2002 - - - 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 . -*/ - -#ifndef _RPC_SAMR_H /* _RPC_SAMR_H */ -#define _RPC_SAMR_H - -/******************************************************************* - the following information comes from a QuickView on samsrv.dll, - and gives an idea of exactly what is needed: - -x SamrAddMemberToAlias -x SamrAddMemberToGroup -SamrAddMultipleMembersToAlias -x SamrChangePasswordUser -x SamrCloseHandle -x SamrConnect -x SamrCreateAliasInDomain -x SamrCreateGroupInDomain -x SamrCreateUserInDomain -? SamrDeleteAlias -SamrDeleteGroup -x SamrDeleteUser -x SamrEnumerateAliasesInDomain -SamrEnumerateDomainsInSamServer -x SamrEnumerateGroupsInDomain -x SamrEnumerateUsersInDomain -SamrGetUserDomainPasswordInformation -SamrLookupDomainInSamServer -? SamrLookupIdsInDomain -x SamrLookupNamesInDomain -x SamrOpenAlias -x SamrOpenDomain -x SamrOpenGroup -x SamrOpenUser -x SamrQueryDisplayInformation -x SamrQueryInformationAlias -SamrQueryInformationDomain -? SamrQueryInformationUser -x SamrQuerySecurityObject -SamrRemoveMemberFromAlias -SamrRemoveMemberFromForiegnDomain -SamrRemoveMemberFromGroup -SamrRemoveMultipleMembersFromAlias -x SamrSetInformationAlias -SamrSetInformationDomain -x SamrSetInformationGroup -x SamrSetInformationUser -SamrSetMemberAttributesOfGroup -SamrSetSecurityObject -SamrShutdownSamServer -SamrTestPrivateFunctionsDomain -SamrTestPrivateFunctionsUser - -********************************************************************/ - -/* these are from the old rpc_samr.h - they are needed while the merge - is still going on */ -#define MAX_SAM_SIDS 15 - -#endif /* _RPC_SAMR_H */ -- cgit From cb34a31cc6819987c30a0808b2c35871404678d5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 18:48:02 +0100 Subject: Remove unused BRS marshalling headers. Guenther (This used to be commit 9e17e94c8ee6e555ca3322745faaeb946650bb15) --- source3/include/rpc_brs.h | 79 ----------------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 source3/include/rpc_brs.h (limited to 'source3') diff --git a/source3/include/rpc_brs.h b/source3/include/rpc_brs.h deleted file mode 100644 index 62ee86050f..0000000000 --- a/source3/include/rpc_brs.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1999 - Copyright (C) Luke Kenneth Casson Leighton 1996-1999 - - 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 . -*/ - -#ifndef _RPC_BRS_H /* _RPC_BRS_H */ -#define _RPC_BRS_H - - -/* brssvc pipe */ -#define BRS_QUERY_INFO 0x02 - - -/* BRS_Q_QUERY_INFO - probably a capabilities request */ -typedef struct q_brs_query_info_info -{ - uint32 ptr_srv_name; /* pointer (to server name?) */ - UNISTR2 uni_srv_name; /* unicode server name starting with '\\' */ - - uint16 switch_value1; /* info level 100 (0x64) */ - /* align */ - uint16 switch_value2; /* info level 100 (0x64) */ - - uint32 ptr; - uint32 pad1; - uint32 pad2; - -} BRS_Q_QUERY_INFO; - - -/* BRS_INFO_100 - level 100 info */ -typedef struct brs_info_100_info -{ - uint32 pad1; - uint32 ptr2; - uint32 pad2; - uint32 pad3; - -} BRS_INFO_100; - - -/* BRS_R_QUERY_INFO - probably a capabilities request */ -typedef struct r_brs_query_info_info -{ - uint16 switch_value1; /* 100 (0x64) - switch value */ - /* align */ - uint16 switch_value2; /* info level 100 (0x64) */ - - /* for now, only level 100 is supported. this should be an enum container */ - uint32 ptr_1; /* pointer 1 */ - - union - { - BRS_INFO_100 *brs100; /* browser info level 100 */ - void *id; - - } info; - - NTSTATUS status; /* return status */ - -} BRS_R_QUERY_INFO; - -#endif /* _RPC_BRS_H */ - -- cgit From 583aa074a9525e08d2d14696ca27f0a636bbf6a5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 18:49:17 +0100 Subject: Cosmetics: make check_bind_req() debug statements a little nicer. Guenther (This used to be commit 997a0a4a12d97595ff4df963601cf2c24d612972) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4d066a6b7a..19c8db0533 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -993,7 +993,7 @@ bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ for ( i=0; pipe_names[i].client_pipe; i++ ) { - DEBUG(10,("checking %s\n", pipe_names[i].client_pipe)); + DEBUGADD(10,("checking %s\n", pipe_names[i].client_pipe)); if ( strequal(pipe_names[i].client_pipe, pname) && (abstract->version == pipe_names[i].abstr_syntax.version) && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct GUID)) == 0) -- cgit From 7269a504fdd06fbbe24c2df8e084b41382d71269 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 19:38:48 +0100 Subject: Add my copyright. Guenther (This used to be commit d078a8757182d84dfd3307a2e1b751cf173aaa97) --- source3/libads/authdata.c | 2 +- source3/libsmb/samlogon_cache.c | 1 + source3/rpc_client/cli_lsarpc.c | 1 + source3/rpc_client/cli_netlogon.c | 1 + source3/rpc_client/cli_samr.c | 1 + source3/rpc_server/srv_lsa_nt.c | 1 + source3/rpc_server/srv_netlog_nt.c | 1 + source3/rpc_server/srv_samr_nt.c | 1 + source3/rpc_server/srv_samr_util.c | 1 + source3/rpcclient/cmd_lsarpc.c | 1 + source3/rpcclient/cmd_netlogon.c | 1 + source3/rpcclient/cmd_samr.c | 1 + source3/utils/net_domain.c | 1 + source3/utils/net_rpc.c | 2 +- source3/utils/net_rpc_audit.c | 2 +- source3/utils/net_rpc_join.c | 1 + source3/utils/net_rpc_rights.c | 1 + source3/utils/net_rpc_samsync.c | 1 + source3/winbindd/winbindd_rpc.c | 1 + 19 files changed, 19 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c index 79972875ac..0bde3e6984 100644 --- a/source3/libads/authdata.c +++ b/source3/libads/authdata.c @@ -6,7 +6,7 @@ Copyright (C) Andrew Tridgell 2001 Copyright (C) Luke Howard 2002-2003 Copyright (C) Stefan Metzmacher 2004-2005 - Copyright (C) Guenther Deschner 2005,2007 + Copyright (C) Guenther Deschner 2005,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 diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index 3cc0dcf0fb..0d855f4c6c 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -5,6 +5,7 @@ Copyright (C) Andrew Bartlett 2002. Copyright (C) Gerald Carter 2003. Copyright (C) Tim Potter 2003. + 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 diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index 1fb0205f29..2759881dd3 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -6,6 +6,7 @@ Copyright (C) Rafal Szczesniak 2002 Copyright (C) Jeremy Allison 2005. Copyright (C) Michael Adam 2007. + 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 diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index 91e27c5d85..2af514320e 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -4,6 +4,7 @@ Copyright (C) Andrew Tridgell 1992-2000 Copyright (C) Jeremy Allison 1998. Largely re-written by Jeremy Allison (C) 2005. + 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 diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c index c805f00efb..62a5c72d81 100644 --- a/source3/rpc_client/cli_samr.c +++ b/source3/rpc_client/cli_samr.c @@ -5,6 +5,7 @@ Copyright (C) Andrew Tridgell 1992-1997,2000, Copyright (C) Rafal Szczesniak 2002. Copyright (C) Jeremy Allison 2005. + 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 diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 788fdb3661..1333d656d4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -10,6 +10,7 @@ * Copyright (C) Simo Sorce 2003. * Copyright (C) Gerald (Jerry) Carter 2005. * Copyright (C) Volker Lendecke 2005. + * 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 diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c64e5b8d10..5b26f55845 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -6,6 +6,7 @@ * Copyright (C) Paul Ashton 1997. * Copyright (C) Jeremy Allison 1998-2001. * Copyright (C) Andrew Bartlett 2001. + * 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 diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8289440d6e..f8b953904f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -11,6 +11,7 @@ * Copyright (C) Gerald (Jerry) Carter 2003-2004, * Copyright (C) Simo Sorce 2003. * Copyright (C) Volker Lendecke 2005. + * 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 diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 364adbc0de..688d72064f 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -6,6 +6,7 @@ Copyright (C) Gerald (Jerry) Carter 2000-2001 Copyright (C) Andrew Bartlett 2001-2002 Copyright (C) Stefan (metze) Metzmacher 2002 + 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 diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 512d80ae15..90f8646810 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -4,6 +4,7 @@ Copyright (C) Tim Potter 2000 Copyright (C) Rafal Szczesniak 2002 + 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 diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 49098b12e4..95d79b5825 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -3,6 +3,7 @@ RPC pipe client Copyright (C) Tim Potter 2000 + 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 diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 8b4ee47a67..2d20afeb13 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -6,6 +6,7 @@ Copyright (C) Luke Kenneth Casson Leighton 1996-2000, Copyright (C) Elrond 2000, Copyright (C) Tim Potter 2000 + 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 diff --git a/source3/utils/net_domain.c b/source3/utils/net_domain.c index 90d28b5e6e..1a84c6cbc6 100644 --- a/source3/utils/net_domain.c +++ b/source3/utils/net_domain.c @@ -5,6 +5,7 @@ Copyright (C) 2001 Remus Koos (remuskoos@yahoo.com) Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) Copyright (C) 2006 Gerald (Jerry) Carter (jerry@samba.org) + Copyright (C) 2008 Guenther Deschner (gd@samba.org) 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 diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 0e31d013a1..f7fadb9520 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -3,7 +3,7 @@ Distributed SMB/CIFS Server Management Utility Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org) Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) - Copyright (C) 2004 Guenther Deschner (gd@samba.org) + Copyright (C) 2004,2008 Guenther Deschner (gd@samba.org) Copyright (C) 2005 Jeremy Allison (jra@samba.org) Copyright (C) 2006 Jelmer Vernooij (jelmer@samba.org) diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 7c2a5b33ca..a846395bb8 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -1,7 +1,7 @@ /* Samba Unix/Linux SMB client library Distributed SMB/CIFS Server Management Utility - Copyright (C) 2006 Guenther Deschner + Copyright (C) 2006,2008 Guenther Deschner 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 diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index f08dc66d3c..8259ec46e6 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -3,6 +3,7 @@ Distributed SMB/CIFS Server Management Utility Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org) Copyright (C) Tim Potter 2001 + Copyright (C) 2008 Guenther Deschner 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 diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index 16d75e57d9..7857dbcbaf 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -2,6 +2,7 @@ Samba Unix/Linux SMB client library Distributed SMB/CIFS Server Management Utility Copyright (C) Gerald (Jerry) Carter 2004 + 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 diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 6287610638..775270a69b 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -7,6 +7,7 @@ Copyright (C) Jim McDonough 2005 Modified by Volker Lendecke 2002 Copyright (C) Jeremy Allison 2005. + 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 diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index f818772ce7..2a7704c8a5 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -6,6 +6,7 @@ Copyright (C) Tim Potter 2000-2001,2003 Copyright (C) Andrew Tridgell 2001 Copyright (C) Volker Lendecke 2005 + Copyright (C) Guenther Deschner 2008 (pidl conversion) 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 -- cgit From 8c2b6a126c0f6e111d66e17fb46077a76bc81a15 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 27 Feb 2008 20:03:42 +0100 Subject: remove unused unixinfo.idl and generated files The idl in this version uses pidl specific non NDR types... metze (This used to be commit 5dd83aaff325a1d15a0c786cbab42b8fcd6dd5ee) --- source3/Makefile.in | 8 +- source3/librpc/gen_ndr/cli_unixinfo.c | 216 -------------- source3/librpc/gen_ndr/cli_unixinfo.h | 25 -- source3/librpc/gen_ndr/ndr_unixinfo.c | 536 ---------------------------------- source3/librpc/gen_ndr/ndr_unixinfo.h | 31 -- source3/librpc/gen_ndr/srv_unixinfo.c | 430 --------------------------- source3/librpc/gen_ndr/srv_unixinfo.h | 11 - source3/librpc/gen_ndr/unixinfo.h | 82 ------ source3/librpc/idl/unixinfo.idl | 56 ---- 9 files changed, 2 insertions(+), 1393 deletions(-) delete mode 100644 source3/librpc/gen_ndr/cli_unixinfo.c delete mode 100644 source3/librpc/gen_ndr/cli_unixinfo.h delete mode 100644 source3/librpc/gen_ndr/ndr_unixinfo.c delete mode 100644 source3/librpc/gen_ndr/ndr_unixinfo.h delete mode 100644 source3/librpc/gen_ndr/srv_unixinfo.c delete mode 100644 source3/librpc/gen_ndr/srv_unixinfo.h delete mode 100644 source3/librpc/gen_ndr/unixinfo.h delete mode 100644 source3/librpc/idl/unixinfo.idl (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 1b91b7e326..599e7a9e1f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -940,7 +940,7 @@ PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \ $(RPC_LSA_OBJ) $(RPC_NETLOG_OBJ) $(RPC_SAMR_OBJ) $(RPC_REG_OBJ) $(RPC_DSSETUP_OBJ) \ $(RPC_SVC_OBJ) $(RPC_WKS_OBJ) $(RPC_DFS_OBJ) $(RPC_SPOOLSS_OBJ) \ $(RPC_ECHO_OBJ) $(RPC_SVCCTL_OBJ) $(RPC_EVENTLOG_OBJ) $(SMBLDAP_OBJ) \ - $(IDMAP_OBJ) libsmb/spnego.o $(PASSCHANGE_OBJ) $(RPC_UNIXINFO_OBJ) \ + $(IDMAP_OBJ) libsmb/spnego.o $(PASSCHANGE_OBJ) \ $(RPC_NTSVCS_OBJ) $(RPC_INITSHUTDOWN_OBJ) \ utils/passwd_util.o $(LIBGPO_OBJ) $(NSS_INFO_OBJ) \ $(RPCCLIENT_NDR_OBJ) $(DISPLAY_DSDCINFO_OBJ) \ @@ -1134,7 +1134,7 @@ modules: SHOWFLAGS $(MODULES) ##################################################################### ## Perl IDL Compiler -IDL_FILES = unixinfo.idl lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ +IDL_FILES = lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \ epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \ dssetup.idl krb5pac.idl ntsvcs.idl libnet_join.idl @@ -1583,10 +1583,6 @@ bin/librpc_samr.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_SAMR_OBJ) @echo "Linking $@" @$(SHLD_MODULE) $(RPC_SAMR_OBJ) -bin/librpc_unixinfo.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_UNIXINFO_OBJ) - @echo "Linking $@" - @$(SHLD_MODULE) $(RPC_UNIXINFO_OBJ) - bin/librpc_srvsvc.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_SVC_OBJ) @echo "Linking $@" @$(SHLD_MODULE) $(RPC_SVC_OBJ) diff --git a/source3/librpc/gen_ndr/cli_unixinfo.c b/source3/librpc/gen_ndr/cli_unixinfo.c deleted file mode 100644 index c8a6c926ef..0000000000 --- a/source3/librpc/gen_ndr/cli_unixinfo.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * client auto-generated by pidl. DO NOT MODIFY! - */ - -#include "includes.h" -#include "librpc/gen_ndr/cli_unixinfo.h" - -NTSTATUS rpccli_unixinfo_SidToUid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - struct dom_sid sid, - uint64_t *uid) -{ - struct unixinfo_SidToUid r; - NTSTATUS status; - - /* In parameters */ - r.in.sid = sid; - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_SidToUid, &r); - } - - status = cli_do_rpc_ndr(cli, - mem_ctx, - PI_UNIXINFO, - &ndr_table_unixinfo, - NDR_UNIXINFO_SIDTOUID, - &r); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_SidToUid, &r); - } - - if (NT_STATUS_IS_ERR(status)) { - return status; - } - - /* Return variables */ - *uid = *r.out.uid; - - /* Return result */ - return r.out.result; -} - -NTSTATUS rpccli_unixinfo_UidToSid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - uint64_t uid, - struct dom_sid *sid) -{ - struct unixinfo_UidToSid r; - NTSTATUS status; - - /* In parameters */ - r.in.uid = uid; - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_UidToSid, &r); - } - - status = cli_do_rpc_ndr(cli, - mem_ctx, - PI_UNIXINFO, - &ndr_table_unixinfo, - NDR_UNIXINFO_UIDTOSID, - &r); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_UidToSid, &r); - } - - if (NT_STATUS_IS_ERR(status)) { - return status; - } - - /* Return variables */ - *sid = *r.out.sid; - - /* Return result */ - return r.out.result; -} - -NTSTATUS rpccli_unixinfo_SidToGid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - struct dom_sid sid, - uint64_t *gid) -{ - struct unixinfo_SidToGid r; - NTSTATUS status; - - /* In parameters */ - r.in.sid = sid; - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_SidToGid, &r); - } - - status = cli_do_rpc_ndr(cli, - mem_ctx, - PI_UNIXINFO, - &ndr_table_unixinfo, - NDR_UNIXINFO_SIDTOGID, - &r); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_SidToGid, &r); - } - - if (NT_STATUS_IS_ERR(status)) { - return status; - } - - /* Return variables */ - *gid = *r.out.gid; - - /* Return result */ - return r.out.result; -} - -NTSTATUS rpccli_unixinfo_GidToSid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - uint64_t gid, - struct dom_sid *sid) -{ - struct unixinfo_GidToSid r; - NTSTATUS status; - - /* In parameters */ - r.in.gid = gid; - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_GidToSid, &r); - } - - status = cli_do_rpc_ndr(cli, - mem_ctx, - PI_UNIXINFO, - &ndr_table_unixinfo, - NDR_UNIXINFO_GIDTOSID, - &r); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_GidToSid, &r); - } - - if (NT_STATUS_IS_ERR(status)) { - return status; - } - - /* Return variables */ - *sid = *r.out.sid; - - /* Return result */ - return r.out.result; -} - -NTSTATUS rpccli_unixinfo_GetPWUid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - uint32_t *count, - uint64_t *uids, - struct unixinfo_GetPWUidInfo *infos) -{ - struct unixinfo_GetPWUid r; - NTSTATUS status; - - /* In parameters */ - r.in.count = count; - r.in.uids = uids; - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_GetPWUid, &r); - } - - status = cli_do_rpc_ndr(cli, - mem_ctx, - PI_UNIXINFO, - &ndr_table_unixinfo, - NDR_UNIXINFO_GETPWUID, - &r); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_GetPWUid, &r); - } - - if (NT_STATUS_IS_ERR(status)) { - return status; - } - - /* Return variables */ - *count = *r.out.count; - memcpy(infos, r.out.infos, *r.in.count); - - /* Return result */ - return r.out.result; -} - diff --git a/source3/librpc/gen_ndr/cli_unixinfo.h b/source3/librpc/gen_ndr/cli_unixinfo.h deleted file mode 100644 index fa084cc75d..0000000000 --- a/source3/librpc/gen_ndr/cli_unixinfo.h +++ /dev/null @@ -1,25 +0,0 @@ -#include "librpc/gen_ndr/ndr_unixinfo.h" -#ifndef __CLI_UNIXINFO__ -#define __CLI_UNIXINFO__ -NTSTATUS rpccli_unixinfo_SidToUid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - struct dom_sid sid, - uint64_t *uid); -NTSTATUS rpccli_unixinfo_UidToSid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - uint64_t uid, - struct dom_sid *sid); -NTSTATUS rpccli_unixinfo_SidToGid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - struct dom_sid sid, - uint64_t *gid); -NTSTATUS rpccli_unixinfo_GidToSid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - uint64_t gid, - struct dom_sid *sid); -NTSTATUS rpccli_unixinfo_GetPWUid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - uint32_t *count, - uint64_t *uids, - struct unixinfo_GetPWUidInfo *infos); -#endif /* __CLI_UNIXINFO__ */ diff --git a/source3/librpc/gen_ndr/ndr_unixinfo.c b/source3/librpc/gen_ndr/ndr_unixinfo.c deleted file mode 100644 index b0b5c81395..0000000000 --- a/source3/librpc/gen_ndr/ndr_unixinfo.c +++ /dev/null @@ -1,536 +0,0 @@ -/* parser auto-generated by pidl */ - -#include "includes.h" -#include "librpc/gen_ndr/ndr_unixinfo.h" - -#include "librpc/gen_ndr/ndr_security.h" -static enum ndr_err_code ndr_push_unixinfo_GetPWUidInfo(struct ndr_push *ndr, int ndr_flags, const struct unixinfo_GetPWUidInfo *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->status)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->homedir)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->shell)); - ndr->flags = _flags_save_string; - } - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_unixinfo_GetPWUidInfo(struct ndr_pull *ndr, int ndr_flags, struct unixinfo_GetPWUidInfo *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->status)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->homedir)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->shell)); - ndr->flags = _flags_save_string; - } - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_unixinfo_GetPWUidInfo(struct ndr_print *ndr, const char *name, const struct unixinfo_GetPWUidInfo *r) -{ - ndr_print_struct(ndr, name, "unixinfo_GetPWUidInfo"); - ndr->depth++; - ndr_print_NTSTATUS(ndr, "status", r->status); - ndr_print_string(ndr, "homedir", r->homedir); - ndr_print_string(ndr, "shell", r->shell); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_unixinfo_SidToUid(struct ndr_push *ndr, int flags, const struct unixinfo_SidToUid *r) -{ - if (flags & NDR_IN) { - NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.sid)); - } - if (flags & NDR_OUT) { - if (r->out.uid == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); - } - NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, *r->out.uid)); - NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_unixinfo_SidToUid(struct ndr_pull *ndr, int flags, struct unixinfo_SidToUid *r) -{ - TALLOC_CTX *_mem_save_uid_0; - if (flags & NDR_IN) { - ZERO_STRUCT(r->out); - - NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.sid)); - NDR_PULL_ALLOC(ndr, r->out.uid); - ZERO_STRUCTP(r->out.uid); - } - if (flags & NDR_OUT) { - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.uid); - } - _mem_save_uid_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.uid, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, r->out.uid)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_uid_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_unixinfo_SidToUid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_SidToUid *r) -{ - ndr_print_struct(ndr, name, "unixinfo_SidToUid"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "unixinfo_SidToUid"); - ndr->depth++; - ndr_print_dom_sid(ndr, "sid", &r->in.sid); - ndr->depth--; - } - if (flags & NDR_OUT) { - ndr_print_struct(ndr, "out", "unixinfo_SidToUid"); - ndr->depth++; - ndr_print_ptr(ndr, "uid", r->out.uid); - ndr->depth++; - ndr_print_hyper(ndr, "uid", *r->out.uid); - ndr->depth--; - ndr_print_NTSTATUS(ndr, "result", r->out.result); - ndr->depth--; - } - ndr->depth--; -} - -static enum ndr_err_code ndr_push_unixinfo_UidToSid(struct ndr_push *ndr, int flags, const struct unixinfo_UidToSid *r) -{ - if (flags & NDR_IN) { - NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->in.uid)); - } - if (flags & NDR_OUT) { - if (r->out.sid == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); - } - NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sid)); - NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_unixinfo_UidToSid(struct ndr_pull *ndr, int flags, struct unixinfo_UidToSid *r) -{ - TALLOC_CTX *_mem_save_sid_0; - if (flags & NDR_IN) { - ZERO_STRUCT(r->out); - - NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->in.uid)); - NDR_PULL_ALLOC(ndr, r->out.sid); - ZERO_STRUCTP(r->out.sid); - } - if (flags & NDR_OUT) { - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.sid); - } - _mem_save_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.sid, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sid)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_unixinfo_UidToSid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_UidToSid *r) -{ - ndr_print_struct(ndr, name, "unixinfo_UidToSid"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "unixinfo_UidToSid"); - ndr->depth++; - ndr_print_hyper(ndr, "uid", r->in.uid); - ndr->depth--; - } - if (flags & NDR_OUT) { - ndr_print_struct(ndr, "out", "unixinfo_UidToSid"); - ndr->depth++; - ndr_print_ptr(ndr, "sid", r->out.sid); - ndr->depth++; - ndr_print_dom_sid(ndr, "sid", r->out.sid); - ndr->depth--; - ndr_print_NTSTATUS(ndr, "result", r->out.result); - ndr->depth--; - } - ndr->depth--; -} - -static enum ndr_err_code ndr_push_unixinfo_SidToGid(struct ndr_push *ndr, int flags, const struct unixinfo_SidToGid *r) -{ - if (flags & NDR_IN) { - NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.sid)); - } - if (flags & NDR_OUT) { - if (r->out.gid == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); - } - NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, *r->out.gid)); - NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_unixinfo_SidToGid(struct ndr_pull *ndr, int flags, struct unixinfo_SidToGid *r) -{ - TALLOC_CTX *_mem_save_gid_0; - if (flags & NDR_IN) { - ZERO_STRUCT(r->out); - - NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.sid)); - NDR_PULL_ALLOC(ndr, r->out.gid); - ZERO_STRUCTP(r->out.gid); - } - if (flags & NDR_OUT) { - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.gid); - } - _mem_save_gid_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.gid, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, r->out.gid)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_gid_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_unixinfo_SidToGid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_SidToGid *r) -{ - ndr_print_struct(ndr, name, "unixinfo_SidToGid"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "unixinfo_SidToGid"); - ndr->depth++; - ndr_print_dom_sid(ndr, "sid", &r->in.sid); - ndr->depth--; - } - if (flags & NDR_OUT) { - ndr_print_struct(ndr, "out", "unixinfo_SidToGid"); - ndr->depth++; - ndr_print_ptr(ndr, "gid", r->out.gid); - ndr->depth++; - ndr_print_hyper(ndr, "gid", *r->out.gid); - ndr->depth--; - ndr_print_NTSTATUS(ndr, "result", r->out.result); - ndr->depth--; - } - ndr->depth--; -} - -static enum ndr_err_code ndr_push_unixinfo_GidToSid(struct ndr_push *ndr, int flags, const struct unixinfo_GidToSid *r) -{ - if (flags & NDR_IN) { - NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->in.gid)); - } - if (flags & NDR_OUT) { - if (r->out.sid == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); - } - NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sid)); - NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_unixinfo_GidToSid(struct ndr_pull *ndr, int flags, struct unixinfo_GidToSid *r) -{ - TALLOC_CTX *_mem_save_sid_0; - if (flags & NDR_IN) { - ZERO_STRUCT(r->out); - - NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->in.gid)); - NDR_PULL_ALLOC(ndr, r->out.sid); - ZERO_STRUCTP(r->out.sid); - } - if (flags & NDR_OUT) { - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.sid); - } - _mem_save_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.sid, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sid)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_unixinfo_GidToSid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_GidToSid *r) -{ - ndr_print_struct(ndr, name, "unixinfo_GidToSid"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "unixinfo_GidToSid"); - ndr->depth++; - ndr_print_hyper(ndr, "gid", r->in.gid); - ndr->depth--; - } - if (flags & NDR_OUT) { - ndr_print_struct(ndr, "out", "unixinfo_GidToSid"); - ndr->depth++; - ndr_print_ptr(ndr, "sid", r->out.sid); - ndr->depth++; - ndr_print_dom_sid(ndr, "sid", r->out.sid); - ndr->depth--; - ndr_print_NTSTATUS(ndr, "result", r->out.result); - ndr->depth--; - } - ndr->depth--; -} - -static enum ndr_err_code ndr_push_unixinfo_GetPWUid(struct ndr_push *ndr, int flags, const struct unixinfo_GetPWUid *r) -{ - uint32_t cntr_uids_0; - uint32_t cntr_infos_0; - if (flags & NDR_IN) { - if (r->in.count == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.count)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.count)); - for (cntr_uids_0 = 0; cntr_uids_0 < *r->in.count; cntr_uids_0++) { - NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->in.uids[cntr_uids_0])); - } - } - if (flags & NDR_OUT) { - if (r->out.count == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.count)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.count)); - for (cntr_infos_0 = 0; cntr_infos_0 < *r->out.count; cntr_infos_0++) { - NDR_CHECK(ndr_push_unixinfo_GetPWUidInfo(ndr, NDR_SCALARS, &r->out.infos[cntr_infos_0])); - } - NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_unixinfo_GetPWUid(struct ndr_pull *ndr, int flags, struct unixinfo_GetPWUid *r) -{ - uint32_t cntr_uids_0; - uint32_t cntr_infos_0; - TALLOC_CTX *_mem_save_count_0; - TALLOC_CTX *_mem_save_uids_0; - TALLOC_CTX *_mem_save_infos_0; - if (flags & NDR_IN) { - ZERO_STRUCT(r->out); - - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->in.count); - } - _mem_save_count_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->in.count, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.count)); - if (*r->in.count < 0 || *r->in.count > 1023) { - return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_array_size(ndr, &r->in.uids)); - NDR_PULL_ALLOC_N(ndr, r->in.uids, ndr_get_array_size(ndr, &r->in.uids)); - _mem_save_uids_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->in.uids, 0); - for (cntr_uids_0 = 0; cntr_uids_0 < *r->in.count; cntr_uids_0++) { - NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->in.uids[cntr_uids_0])); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_uids_0, 0); - NDR_PULL_ALLOC(ndr, r->out.count); - *r->out.count = *r->in.count; - if (r->in.uids) { - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.uids, *r->in.count)); - } - } - if (flags & NDR_OUT) { - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.count); - } - _mem_save_count_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.count, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.count)); - if (*r->out.count < 0 || *r->out.count > 1023) { - return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_array_size(ndr, &r->out.infos)); - NDR_PULL_ALLOC_N(ndr, r->out.infos, ndr_get_array_size(ndr, &r->out.infos)); - _mem_save_infos_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.infos, 0); - for (cntr_infos_0 = 0; cntr_infos_0 < *r->out.count; cntr_infos_0++) { - NDR_CHECK(ndr_pull_unixinfo_GetPWUidInfo(ndr, NDR_SCALARS, &r->out.infos[cntr_infos_0])); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_infos_0, 0); - NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); - if (r->out.infos) { - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.infos, *r->out.count)); - } - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_unixinfo_GetPWUid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_GetPWUid *r) -{ - uint32_t cntr_uids_0; - uint32_t cntr_infos_0; - ndr_print_struct(ndr, name, "unixinfo_GetPWUid"); - ndr->depth++; - if (flags & NDR_SET_VALUES) { - ndr->flags |= LIBNDR_PRINT_SET_VALUES; - } - if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "unixinfo_GetPWUid"); - ndr->depth++; - ndr_print_ptr(ndr, "count", r->in.count); - ndr->depth++; - ndr_print_uint32(ndr, "count", *r->in.count); - ndr->depth--; - ndr->print(ndr, "%s: ARRAY(%d)", "uids", *r->in.count); - ndr->depth++; - for (cntr_uids_0=0;cntr_uids_0<*r->in.count;cntr_uids_0++) { - char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_uids_0) != -1) { - ndr_print_hyper(ndr, "uids", r->in.uids[cntr_uids_0]); - free(idx_0); - } - } - ndr->depth--; - ndr->depth--; - } - if (flags & NDR_OUT) { - ndr_print_struct(ndr, "out", "unixinfo_GetPWUid"); - ndr->depth++; - ndr_print_ptr(ndr, "count", r->out.count); - ndr->depth++; - ndr_print_uint32(ndr, "count", *r->out.count); - ndr->depth--; - ndr->print(ndr, "%s: ARRAY(%d)", "infos", *r->out.count); - ndr->depth++; - for (cntr_infos_0=0;cntr_infos_0<*r->out.count;cntr_infos_0++) { - char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_infos_0) != -1) { - ndr_print_unixinfo_GetPWUidInfo(ndr, "infos", &r->out.infos[cntr_infos_0]); - free(idx_0); - } - } - ndr->depth--; - ndr_print_NTSTATUS(ndr, "result", r->out.result); - ndr->depth--; - } - ndr->depth--; -} - -static const struct ndr_interface_call unixinfo_calls[] = { - { - "unixinfo_SidToUid", - sizeof(struct unixinfo_SidToUid), - (ndr_push_flags_fn_t) ndr_push_unixinfo_SidToUid, - (ndr_pull_flags_fn_t) ndr_pull_unixinfo_SidToUid, - (ndr_print_function_t) ndr_print_unixinfo_SidToUid, - false, - }, - { - "unixinfo_UidToSid", - sizeof(struct unixinfo_UidToSid), - (ndr_push_flags_fn_t) ndr_push_unixinfo_UidToSid, - (ndr_pull_flags_fn_t) ndr_pull_unixinfo_UidToSid, - (ndr_print_function_t) ndr_print_unixinfo_UidToSid, - false, - }, - { - "unixinfo_SidToGid", - sizeof(struct unixinfo_SidToGid), - (ndr_push_flags_fn_t) ndr_push_unixinfo_SidToGid, - (ndr_pull_flags_fn_t) ndr_pull_unixinfo_SidToGid, - (ndr_print_function_t) ndr_print_unixinfo_SidToGid, - false, - }, - { - "unixinfo_GidToSid", - sizeof(struct unixinfo_GidToSid), - (ndr_push_flags_fn_t) ndr_push_unixinfo_GidToSid, - (ndr_pull_flags_fn_t) ndr_pull_unixinfo_GidToSid, - (ndr_print_function_t) ndr_print_unixinfo_GidToSid, - false, - }, - { - "unixinfo_GetPWUid", - sizeof(struct unixinfo_GetPWUid), - (ndr_push_flags_fn_t) ndr_push_unixinfo_GetPWUid, - (ndr_pull_flags_fn_t) ndr_pull_unixinfo_GetPWUid, - (ndr_print_function_t) ndr_print_unixinfo_GetPWUid, - false, - }, - { NULL, 0, NULL, NULL, NULL, false } -}; - -static const char * const unixinfo_endpoint_strings[] = { - "ncacn_np:[\\pipe\\unixinfo]", - "ncacn_ip_tcp:", - "ncalrpc:", -}; - -static const struct ndr_interface_string_array unixinfo_endpoints = { - .count = 3, - .names = unixinfo_endpoint_strings -}; - -static const char * const unixinfo_authservice_strings[] = { - "host", -}; - -static const struct ndr_interface_string_array unixinfo_authservices = { - .count = 3, - .names = unixinfo_authservice_strings -}; - - -const struct ndr_interface_table ndr_table_unixinfo = { - .name = "unixinfo", - .syntax_id = { - {0x9c54e310,0xa955,0x4885,{0xbd,0x31},{0x78,0x78,0x71,0x47,0xdf,0xa6}}, - NDR_UNIXINFO_VERSION - }, - .helpstring = NDR_UNIXINFO_HELPSTRING, - .num_calls = 5, - .calls = unixinfo_calls, - .endpoints = &unixinfo_endpoints, - .authservices = &unixinfo_authservices -}; - diff --git a/source3/librpc/gen_ndr/ndr_unixinfo.h b/source3/librpc/gen_ndr/ndr_unixinfo.h deleted file mode 100644 index 17f8b811db..0000000000 --- a/source3/librpc/gen_ndr/ndr_unixinfo.h +++ /dev/null @@ -1,31 +0,0 @@ -/* header auto-generated by pidl */ - -#include "librpc/ndr/libndr.h" -#include "librpc/gen_ndr/unixinfo.h" - -#ifndef _HEADER_NDR_unixinfo -#define _HEADER_NDR_unixinfo - -#define NDR_UNIXINFO_UUID "9c54e310-a955-4885-bd31-78787147dfa6" -#define NDR_UNIXINFO_VERSION 0.0 -#define NDR_UNIXINFO_NAME "unixinfo" -#define NDR_UNIXINFO_HELPSTRING "Unixinfo specific stuff" -extern const struct ndr_interface_table ndr_table_unixinfo; -#define NDR_UNIXINFO_SIDTOUID (0x00) - -#define NDR_UNIXINFO_UIDTOSID (0x01) - -#define NDR_UNIXINFO_SIDTOGID (0x02) - -#define NDR_UNIXINFO_GIDTOSID (0x03) - -#define NDR_UNIXINFO_GETPWUID (0x04) - -#define NDR_UNIXINFO_CALL_COUNT (5) -void ndr_print_unixinfo_GetPWUidInfo(struct ndr_print *ndr, const char *name, const struct unixinfo_GetPWUidInfo *r); -void ndr_print_unixinfo_SidToUid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_SidToUid *r); -void ndr_print_unixinfo_UidToSid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_UidToSid *r); -void ndr_print_unixinfo_SidToGid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_SidToGid *r); -void ndr_print_unixinfo_GidToSid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_GidToSid *r); -void ndr_print_unixinfo_GetPWUid(struct ndr_print *ndr, const char *name, int flags, const struct unixinfo_GetPWUid *r); -#endif /* _HEADER_NDR_unixinfo */ diff --git a/source3/librpc/gen_ndr/srv_unixinfo.c b/source3/librpc/gen_ndr/srv_unixinfo.c deleted file mode 100644 index 6142bb113f..0000000000 --- a/source3/librpc/gen_ndr/srv_unixinfo.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * server auto-generated by pidl. DO NOT MODIFY! - */ - -#include "includes.h" -#include "librpc/gen_ndr/srv_unixinfo.h" - -static bool api_unixinfo_SidToUid(pipes_struct *p) -{ - const struct ndr_interface_call *call; - struct ndr_pull *pull; - struct ndr_push *push; - enum ndr_err_code ndr_err; - DATA_BLOB blob; - struct unixinfo_SidToUid *r; - - call = &ndr_table_unixinfo.calls[NDR_UNIXINFO_SIDTOUID]; - - r = talloc(talloc_tos(), struct unixinfo_SidToUid); - if (r == NULL) { - return false; - } - - if (!prs_data_blob(&p->in_data.data, &blob, r)) { - talloc_free(r); - return false; - } - - pull = ndr_pull_init_blob(&blob, r); - if (pull == NULL) { - talloc_free(r); - return false; - } - - pull->flags |= LIBNDR_FLAG_REF_ALLOC; - ndr_err = call->ndr_pull(pull, NDR_IN, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_SidToUid, r); - } - - ZERO_STRUCT(r->out); - r->out.uid = talloc_zero(r, uint64_t); - if (r->out.uid == NULL) { - talloc_free(r); - return false; - } - - r->out.result = _unixinfo_SidToUid(p, r); - - if (p->rng_fault_state) { - talloc_free(r); - /* Return true here, srv_pipe_hnd.c will take care */ - return true; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_SidToUid, r); - } - - push = ndr_push_init_ctx(r); - if (push == NULL) { - talloc_free(r); - return false; - } - - ndr_err = call->ndr_push(push, NDR_OUT, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - blob = ndr_push_blob(push); - if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { - talloc_free(r); - return false; - } - - talloc_free(r); - - return true; -} - -static bool api_unixinfo_UidToSid(pipes_struct *p) -{ - const struct ndr_interface_call *call; - struct ndr_pull *pull; - struct ndr_push *push; - enum ndr_err_code ndr_err; - DATA_BLOB blob; - struct unixinfo_UidToSid *r; - - call = &ndr_table_unixinfo.calls[NDR_UNIXINFO_UIDTOSID]; - - r = talloc(talloc_tos(), struct unixinfo_UidToSid); - if (r == NULL) { - return false; - } - - if (!prs_data_blob(&p->in_data.data, &blob, r)) { - talloc_free(r); - return false; - } - - pull = ndr_pull_init_blob(&blob, r); - if (pull == NULL) { - talloc_free(r); - return false; - } - - pull->flags |= LIBNDR_FLAG_REF_ALLOC; - ndr_err = call->ndr_pull(pull, NDR_IN, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_UidToSid, r); - } - - ZERO_STRUCT(r->out); - r->out.sid = talloc_zero(r, struct dom_sid); - if (r->out.sid == NULL) { - talloc_free(r); - return false; - } - - r->out.result = _unixinfo_UidToSid(p, r); - - if (p->rng_fault_state) { - talloc_free(r); - /* Return true here, srv_pipe_hnd.c will take care */ - return true; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_UidToSid, r); - } - - push = ndr_push_init_ctx(r); - if (push == NULL) { - talloc_free(r); - return false; - } - - ndr_err = call->ndr_push(push, NDR_OUT, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - blob = ndr_push_blob(push); - if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { - talloc_free(r); - return false; - } - - talloc_free(r); - - return true; -} - -static bool api_unixinfo_SidToGid(pipes_struct *p) -{ - const struct ndr_interface_call *call; - struct ndr_pull *pull; - struct ndr_push *push; - enum ndr_err_code ndr_err; - DATA_BLOB blob; - struct unixinfo_SidToGid *r; - - call = &ndr_table_unixinfo.calls[NDR_UNIXINFO_SIDTOGID]; - - r = talloc(talloc_tos(), struct unixinfo_SidToGid); - if (r == NULL) { - return false; - } - - if (!prs_data_blob(&p->in_data.data, &blob, r)) { - talloc_free(r); - return false; - } - - pull = ndr_pull_init_blob(&blob, r); - if (pull == NULL) { - talloc_free(r); - return false; - } - - pull->flags |= LIBNDR_FLAG_REF_ALLOC; - ndr_err = call->ndr_pull(pull, NDR_IN, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_SidToGid, r); - } - - ZERO_STRUCT(r->out); - r->out.gid = talloc_zero(r, uint64_t); - if (r->out.gid == NULL) { - talloc_free(r); - return false; - } - - r->out.result = _unixinfo_SidToGid(p, r); - - if (p->rng_fault_state) { - talloc_free(r); - /* Return true here, srv_pipe_hnd.c will take care */ - return true; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_SidToGid, r); - } - - push = ndr_push_init_ctx(r); - if (push == NULL) { - talloc_free(r); - return false; - } - - ndr_err = call->ndr_push(push, NDR_OUT, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - blob = ndr_push_blob(push); - if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { - talloc_free(r); - return false; - } - - talloc_free(r); - - return true; -} - -static bool api_unixinfo_GidToSid(pipes_struct *p) -{ - const struct ndr_interface_call *call; - struct ndr_pull *pull; - struct ndr_push *push; - enum ndr_err_code ndr_err; - DATA_BLOB blob; - struct unixinfo_GidToSid *r; - - call = &ndr_table_unixinfo.calls[NDR_UNIXINFO_GIDTOSID]; - - r = talloc(talloc_tos(), struct unixinfo_GidToSid); - if (r == NULL) { - return false; - } - - if (!prs_data_blob(&p->in_data.data, &blob, r)) { - talloc_free(r); - return false; - } - - pull = ndr_pull_init_blob(&blob, r); - if (pull == NULL) { - talloc_free(r); - return false; - } - - pull->flags |= LIBNDR_FLAG_REF_ALLOC; - ndr_err = call->ndr_pull(pull, NDR_IN, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_GidToSid, r); - } - - ZERO_STRUCT(r->out); - r->out.sid = talloc_zero(r, struct dom_sid); - if (r->out.sid == NULL) { - talloc_free(r); - return false; - } - - r->out.result = _unixinfo_GidToSid(p, r); - - if (p->rng_fault_state) { - talloc_free(r); - /* Return true here, srv_pipe_hnd.c will take care */ - return true; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_GidToSid, r); - } - - push = ndr_push_init_ctx(r); - if (push == NULL) { - talloc_free(r); - return false; - } - - ndr_err = call->ndr_push(push, NDR_OUT, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - blob = ndr_push_blob(push); - if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { - talloc_free(r); - return false; - } - - talloc_free(r); - - return true; -} - -static bool api_unixinfo_GetPWUid(pipes_struct *p) -{ - const struct ndr_interface_call *call; - struct ndr_pull *pull; - struct ndr_push *push; - enum ndr_err_code ndr_err; - DATA_BLOB blob; - struct unixinfo_GetPWUid *r; - - call = &ndr_table_unixinfo.calls[NDR_UNIXINFO_GETPWUID]; - - r = talloc(talloc_tos(), struct unixinfo_GetPWUid); - if (r == NULL) { - return false; - } - - if (!prs_data_blob(&p->in_data.data, &blob, r)) { - talloc_free(r); - return false; - } - - pull = ndr_pull_init_blob(&blob, r); - if (pull == NULL) { - talloc_free(r); - return false; - } - - pull->flags |= LIBNDR_FLAG_REF_ALLOC; - ndr_err = call->ndr_pull(pull, NDR_IN, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(unixinfo_GetPWUid, r); - } - - ZERO_STRUCT(r->out); - r->out.count = r->in.count; - r->out.infos = talloc_zero_array(r, struct unixinfo_GetPWUidInfo, *r->out.count); - if (r->out.infos == NULL) { - talloc_free(r); - return false; - } - - r->out.result = _unixinfo_GetPWUid(p, r); - - if (p->rng_fault_state) { - talloc_free(r); - /* Return true here, srv_pipe_hnd.c will take care */ - return true; - } - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(unixinfo_GetPWUid, r); - } - - push = ndr_push_init_ctx(r); - if (push == NULL) { - talloc_free(r); - return false; - } - - ndr_err = call->ndr_push(push, NDR_OUT, r); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(r); - return false; - } - - blob = ndr_push_blob(push); - if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { - talloc_free(r); - return false; - } - - talloc_free(r); - - return true; -} - - -/* Tables */ -static struct api_struct api_unixinfo_cmds[] = -{ - {"UNIXINFO_SIDTOUID", NDR_UNIXINFO_SIDTOUID, api_unixinfo_SidToUid}, - {"UNIXINFO_UIDTOSID", NDR_UNIXINFO_UIDTOSID, api_unixinfo_UidToSid}, - {"UNIXINFO_SIDTOGID", NDR_UNIXINFO_SIDTOGID, api_unixinfo_SidToGid}, - {"UNIXINFO_GIDTOSID", NDR_UNIXINFO_GIDTOSID, api_unixinfo_GidToSid}, - {"UNIXINFO_GETPWUID", NDR_UNIXINFO_GETPWUID, api_unixinfo_GetPWUid}, -}; - -void unixinfo_get_pipe_fns(struct api_struct **fns, int *n_fns) -{ - *fns = api_unixinfo_cmds; - *n_fns = sizeof(api_unixinfo_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_unixinfo_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "unixinfo", "unixinfo", api_unixinfo_cmds, sizeof(api_unixinfo_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/librpc/gen_ndr/srv_unixinfo.h b/source3/librpc/gen_ndr/srv_unixinfo.h deleted file mode 100644 index 6e5c033b61..0000000000 --- a/source3/librpc/gen_ndr/srv_unixinfo.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "librpc/gen_ndr/ndr_unixinfo.h" -#ifndef __SRV_UNIXINFO__ -#define __SRV_UNIXINFO__ -NTSTATUS _unixinfo_SidToUid(pipes_struct *p, struct unixinfo_SidToUid *r); -NTSTATUS _unixinfo_UidToSid(pipes_struct *p, struct unixinfo_UidToSid *r); -NTSTATUS _unixinfo_SidToGid(pipes_struct *p, struct unixinfo_SidToGid *r); -NTSTATUS _unixinfo_GidToSid(pipes_struct *p, struct unixinfo_GidToSid *r); -NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, struct unixinfo_GetPWUid *r); -void unixinfo_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_unixinfo_init(void); -#endif /* __SRV_UNIXINFO__ */ diff --git a/source3/librpc/gen_ndr/unixinfo.h b/source3/librpc/gen_ndr/unixinfo.h deleted file mode 100644 index bfe0934ccd..0000000000 --- a/source3/librpc/gen_ndr/unixinfo.h +++ /dev/null @@ -1,82 +0,0 @@ -/* header auto-generated by pidl */ - -#include - -#include "librpc/gen_ndr/security.h" -#ifndef _HEADER_unixinfo -#define _HEADER_unixinfo - -struct unixinfo_GetPWUidInfo { - NTSTATUS status; - const char * homedir;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM)] */ - const char * shell;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM)] */ -}; - - -struct unixinfo_SidToUid { - struct { - struct dom_sid sid; - } in; - - struct { - uint64_t *uid;/* [ref] */ - NTSTATUS result; - } out; - -}; - - -struct unixinfo_UidToSid { - struct { - uint64_t uid; - } in; - - struct { - struct dom_sid *sid;/* [ref] */ - NTSTATUS result; - } out; - -}; - - -struct unixinfo_SidToGid { - struct { - struct dom_sid sid; - } in; - - struct { - uint64_t *gid;/* [ref] */ - NTSTATUS result; - } out; - -}; - - -struct unixinfo_GidToSid { - struct { - uint64_t gid; - } in; - - struct { - struct dom_sid *sid;/* [ref] */ - NTSTATUS result; - } out; - -}; - - -struct unixinfo_GetPWUid { - struct { - uint64_t *uids;/* [size_is(*count)] */ - uint32_t *count;/* [ref,range(0,1023)] */ - } in; - - struct { - struct unixinfo_GetPWUidInfo *infos;/* [size_is(*count)] */ - uint32_t *count;/* [ref,range(0,1023)] */ - NTSTATUS result; - } out; - -}; - -#endif /* _HEADER_unixinfo */ diff --git a/source3/librpc/idl/unixinfo.idl b/source3/librpc/idl/unixinfo.idl deleted file mode 100644 index 48bc565fff..0000000000 --- a/source3/librpc/idl/unixinfo.idl +++ /dev/null @@ -1,56 +0,0 @@ -#include "idl_types.h" -/* - Unixinfo interface definition -*/ - -import "security.idl"; - -[ uuid("9c54e310-a955-4885-bd31-78787147dfa6"), - version(0.0), - endpoint("ncacn_np:[\\pipe\\unixinfo]", "ncacn_ip_tcp:", "ncalrpc:"), - pointer_default(unique), - helpstring("Unixinfo specific stuff") -] interface unixinfo -{ - /******************/ - /* Function: 0x00 */ - NTSTATUS unixinfo_SidToUid ( - [in] dom_sid sid, - [out] hyper *uid - ); - - /******************/ - /* Function: 0x01 */ - NTSTATUS unixinfo_UidToSid ( - [in] hyper uid, - [out] dom_sid *sid - ); - - /******************/ - /* Function: 0x02 */ - NTSTATUS unixinfo_SidToGid ( - [in] dom_sid sid, - [out] hyper *gid - ); - - /******************/ - /* Function: 0x03 */ - NTSTATUS unixinfo_GidToSid ( - [in] hyper gid, - [out] dom_sid *sid - ); - - typedef struct { - NTSTATUS status; - utf8string homedir; - utf8string shell; - } unixinfo_GetPWUidInfo; - - /******************/ - /* Function: 0x04 */ - NTSTATUS unixinfo_GetPWUid ( - [in,out,ref,range(0,1023)] uint32 *count, - [in,size_is(*count)] hyper uids[], - [out,size_is(*count)] unixinfo_GetPWUidInfo infos[*] - ); -} -- cgit From bdd08fc8d6873908f2666c9ff278e735015cf19f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:03:20 +0100 Subject: Fill in IDL for svcctl_QueryServiceObjectSecurity. Guenther (This used to be commit b1edbc7649561fa2e518281a8035765916a684f2) --- source3/librpc/idl/svcctl.idl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3') diff --git a/source3/librpc/idl/svcctl.idl b/source3/librpc/idl/svcctl.idl index 97c9f0e24b..8e7e2b8831 100644 --- a/source3/librpc/idl/svcctl.idl +++ b/source3/librpc/idl/svcctl.idl @@ -115,6 +115,11 @@ /*****************/ /* Function 0x04 */ WERROR svcctl_QueryServiceObjectSecurity( + [in] policy_handle *handle, + [in] uint32 security_flags, + [out,ref,size_is(buffer_size)] uint8 *buffer, + [in,range(0,0x40000)] uint32 buffer_size, + [out,ref,range(0,0x40000)] uint32 *needed ); /*****************/ -- cgit From 179405e8e7cdbfb2e305b7c1c79c8cddcc842287 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:03:00 +0100 Subject: Re-run make idl. Guenther (This used to be commit 6a84317aec9ae3fcd813390b0eec655387e036ec) --- source3/librpc/gen_ndr/cli_svcctl.c | 10 ++++++ source3/librpc/gen_ndr/cli_svcctl.h | 5 +++ source3/librpc/gen_ndr/ndr_svcctl.c | 67 +++++++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/srv_svcctl.c | 13 +++++++ source3/librpc/gen_ndr/svcctl.h | 8 +++++ 5 files changed, 103 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_svcctl.c b/source3/librpc/gen_ndr/cli_svcctl.c index 2a5d6badc6..42711e3174 100644 --- a/source3/librpc/gen_ndr/cli_svcctl.c +++ b/source3/librpc/gen_ndr/cli_svcctl.c @@ -191,12 +191,20 @@ NTSTATUS rpccli_svcctl_LockServiceDatabase(struct rpc_pipe_client *cli, NTSTATUS rpccli_svcctl_QueryServiceObjectSecurity(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + uint32_t security_flags, + uint8_t *buffer, + uint32_t buffer_size, + uint32_t *needed, WERROR *werror) { struct svcctl_QueryServiceObjectSecurity r; NTSTATUS status; /* In parameters */ + r.in.handle = handle; + r.in.security_flags = security_flags; + r.in.buffer_size = buffer_size; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(svcctl_QueryServiceObjectSecurity, &r); @@ -222,6 +230,8 @@ NTSTATUS rpccli_svcctl_QueryServiceObjectSecurity(struct rpc_pipe_client *cli, } /* Return variables */ + memcpy(buffer, r.out.buffer, r.in.buffer_size); + *needed = *r.out.needed; /* Return result */ if (werror) { diff --git a/source3/librpc/gen_ndr/cli_svcctl.h b/source3/librpc/gen_ndr/cli_svcctl.h index e9eeb2d9e2..d9ab510d5a 100644 --- a/source3/librpc/gen_ndr/cli_svcctl.h +++ b/source3/librpc/gen_ndr/cli_svcctl.h @@ -22,6 +22,11 @@ NTSTATUS rpccli_svcctl_LockServiceDatabase(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_svcctl_QueryServiceObjectSecurity(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + uint32_t security_flags, + uint8_t *buffer, + uint32_t buffer_size, + uint32_t *needed, WERROR *werror); NTSTATUS rpccli_svcctl_SetServiceObjectSecurity(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_svcctl.c b/source3/librpc/gen_ndr/ndr_svcctl.c index b2dfd0eef4..74466f76c0 100644 --- a/source3/librpc/gen_ndr/ndr_svcctl.c +++ b/source3/librpc/gen_ndr/ndr_svcctl.c @@ -588,8 +588,23 @@ _PUBLIC_ void ndr_print_svcctl_LockServiceDatabase(struct ndr_print *ndr, const static enum ndr_err_code ndr_push_svcctl_QueryServiceObjectSecurity(struct ndr_push *ndr, int flags, const struct svcctl_QueryServiceObjectSecurity *r) { if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.security_flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buffer_size)); } if (flags & NDR_OUT) { + if (r->out.buffer == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buffer_size)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.buffer, r->in.buffer_size)); + if (r->out.needed == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.needed)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -597,10 +612,48 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceObjectSecurity(struct ndr_p static enum ndr_err_code ndr_pull_svcctl_QueryServiceObjectSecurity(struct ndr_pull *ndr, int flags, struct svcctl_QueryServiceObjectSecurity *r) { + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_needed_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.security_flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buffer_size)); + if (r->in.buffer_size < 0 || r->in.buffer_size > 0x40000) { + return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); + } + NDR_PULL_ALLOC_N(ndr, r->out.buffer, r->in.buffer_size); + memset(r->out.buffer, 0, (r->in.buffer_size) * sizeof(*r->out.buffer)); + NDR_PULL_ALLOC(ndr, r->out.needed); + ZERO_STRUCTP(r->out.needed); } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_array_size(ndr, &r->out.buffer)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC_N(ndr, r->out.buffer, ndr_get_array_size(ndr, &r->out.buffer)); + } + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->out.buffer, ndr_get_array_size(ndr, &r->out.buffer))); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.needed); + } + _mem_save_needed_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.needed, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.needed)); + if (*r->out.needed < 0 || *r->out.needed > 0x40000) { + return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_needed_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + if (r->out.buffer) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.buffer, r->in.buffer_size)); + } } return NDR_ERR_SUCCESS; } @@ -615,11 +668,25 @@ _PUBLIC_ void ndr_print_svcctl_QueryServiceObjectSecurity(struct ndr_print *ndr, if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "svcctl_QueryServiceObjectSecurity"); ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "security_flags", r->in.security_flags); + ndr_print_uint32(ndr, "buffer_size", r->in.buffer_size); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "svcctl_QueryServiceObjectSecurity"); ndr->depth++; + ndr_print_ptr(ndr, "buffer", r->out.buffer); + ndr->depth++; + ndr_print_array_uint8(ndr, "buffer", r->out.buffer, r->in.buffer_size); + ndr->depth--; + ndr_print_ptr(ndr, "needed", r->out.needed); + ndr->depth++; + ndr_print_uint32(ndr, "needed", *r->out.needed); + ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/srv_svcctl.c b/source3/librpc/gen_ndr/srv_svcctl.c index a7163917bd..10db320452 100644 --- a/source3/librpc/gen_ndr/srv_svcctl.c +++ b/source3/librpc/gen_ndr/srv_svcctl.c @@ -352,6 +352,19 @@ static bool api_svcctl_QueryServiceObjectSecurity(pipes_struct *p) NDR_PRINT_IN_DEBUG(svcctl_QueryServiceObjectSecurity, r); } + ZERO_STRUCT(r->out); + r->out.buffer = talloc_zero_array(r, uint8_t, r->in.buffer_size); + if (r->out.buffer == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + r->out.result = _svcctl_QueryServiceObjectSecurity(p, r); if (p->rng_fault_state) { diff --git a/source3/librpc/gen_ndr/svcctl.h b/source3/librpc/gen_ndr/svcctl.h index 7314be0a33..1e005d872a 100644 --- a/source3/librpc/gen_ndr/svcctl.h +++ b/source3/librpc/gen_ndr/svcctl.h @@ -134,6 +134,14 @@ struct svcctl_LockServiceDatabase { struct svcctl_QueryServiceObjectSecurity { struct { + struct policy_handle *handle;/* [ref] */ + uint32_t security_flags; + uint32_t buffer_size;/* [range(0,0x40000)] */ + } in; + + struct { + uint8_t *buffer;/* [ref,size_is(buffer_size)] */ + uint32_t *needed;/* [ref,range(0,0x40000)] */ WERROR result; } out; -- cgit From fac7193cd21c678e1fd5fef1582b712405032931 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:05:23 +0100 Subject: Use pidl for _svcctl_QueryServiceObjectSecurity(). Guenther (This used to be commit 7c1d30f3dca068d7a3b6ec138d1d01141f0386c2) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 32 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 565c93fa77..2c594ace8c 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -236,23 +236,7 @@ static bool api_svcctl_unlock_service_db(pipes_struct *p) static bool api_svcctl_query_security_sec(pipes_struct *p) { - SVCCTL_Q_QUERY_SERVICE_SEC q_u; - SVCCTL_R_QUERY_SERVICE_SEC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_query_service_sec("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_query_service_sec(p, &q_u, &r_u); - - if(!svcctl_io_r_query_service_sec("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICEOBJECTSECURITY); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 53154ef0c9..2672647c1d 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -802,12 +802,17 @@ WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, } /******************************************************************** + _svcctl_QueryServiceObjectSecurity ********************************************************************/ -WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, SVCCTL_R_QUERY_SERVICE_SEC *r_u ) +WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, + struct svcctl_QueryServiceObjectSecurity *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); SEC_DESC *sec_desc; + NTSTATUS status; + uint8_t *buffer = NULL; + size_t len = 0; /* only support the SCM and individual services */ @@ -822,7 +827,7 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q /* TODO: handle something besides DACL_SECURITY_INFORMATION */ - if ( (q_u->security_flags & DACL_SECURITY_INFORMATION) != DACL_SECURITY_INFORMATION ) + if ( (r->in.security_flags & DACL_SECURITY_INFORMATION) != DACL_SECURITY_INFORMATION ) return WERR_INVALID_PARAM; /* lookup the security descriptor and marshall it up for a reply */ @@ -830,17 +835,20 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, info->name, get_root_nt_token() )) ) return WERR_NOMEM; - r_u->needed = ndr_size_security_descriptor( sec_desc, 0 ); + *r->out.needed = ndr_size_security_descriptor( sec_desc, 0 ); - if ( r_u->needed > q_u->buffer_size ) { - ZERO_STRUCTP( &r_u->buffer ); + if ( *r->out.needed > r->in.buffer_size ) { + ZERO_STRUCTP( &r->out.buffer ); return WERR_INSUFFICIENT_BUFFER; } - rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); + status = marshall_sec_desc(p->mem_ctx, sec_desc, &buffer, &len); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } - if ( !sec_io_desc("", &sec_desc, &r_u->buffer.prs, 0 ) ) - return WERR_NOMEM; + *r->out.needed = len; + r->out.buffer = buffer; return WERR_OK; } @@ -903,12 +911,6 @@ WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, struct svcctl_QueryServiceObjectSecurity *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServiceObjectSecurity *r) { p->rng_fault_state = True; -- cgit From 8a1249817e8642de20095527db0c37ee3c4bd077 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:16:46 +0100 Subject: Remove unused marshalling for SVCCTL_QUERY_SERVICE_SEC. Guenther (This used to be commit a69c6422bb7b1ab64236cbab193d54fd90c106f0) --- source3/include/rpc_svcctl.h | 14 ----------- source3/rpc_parse/parse_svcctl.c | 51 ---------------------------------------- 2 files changed, 65 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index 99d0c7035b..1c3d492359 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -272,20 +272,6 @@ typedef struct { } SVCCTL_R_QUERY_SERVICE_STATUSEX; -/**************************/ - -typedef struct { - POLICY_HND handle; - uint32 security_flags; - uint32 buffer_size; -} SVCCTL_Q_QUERY_SERVICE_SEC; - -typedef struct { - RPC_BUFFER buffer; - uint32 needed; - WERROR status; -} SVCCTL_R_QUERY_SERVICE_SEC; - /**************************/ typedef struct { diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index ececf1b5ed..cd08dbef1f 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -593,57 +593,6 @@ bool svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVIC /******************************************************************* ********************************************************************/ -bool svcctl_io_q_query_service_sec(const char *desc, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_query_service_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("handle", &q_u->handle, ps, depth)) - return False; - if(!prs_uint32("security_flags", ps, depth, &q_u->security_flags)) - return False; - if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) - return False; - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_query_service_sec(const char *desc, SVCCTL_R_QUERY_SERVICE_SEC *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_query_service_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!prs_rpcbuffer("buffer", ps, depth, &r_u->buffer)) - return False; - - if(!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - bool svcctl_io_q_set_service_sec(const char *desc, SVCCTL_Q_SET_SERVICE_SEC *q_u, prs_struct *ps, int depth) { if (q_u == NULL) -- cgit From 6135d08bcfd7150453f479c2dd8a91a7fd2a824c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:17:30 +0100 Subject: Fill in IDL for svcctl_SetServiceObjectSecurity. Guenther (This used to be commit 67293496c5ae287e8bf2823fe21ed17c22bb4fac) --- source3/librpc/idl/svcctl.idl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3') diff --git a/source3/librpc/idl/svcctl.idl b/source3/librpc/idl/svcctl.idl index 8e7e2b8831..e36a0918bf 100644 --- a/source3/librpc/idl/svcctl.idl +++ b/source3/librpc/idl/svcctl.idl @@ -125,6 +125,10 @@ /*****************/ /* Function 0x05 */ WERROR svcctl_SetServiceObjectSecurity( + [in] policy_handle *handle, + [in] uint32 security_flags, + [in,ref,size_is(buffer_size)] uint8 *buffer, + [in] uint32 buffer_size ); /*****************/ -- cgit From 8b23d4a6c3e615015ef230070a3f4f9ee5095d2a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:18:37 +0100 Subject: Re-run make idl. Guenther (This used to be commit 86061904136706443e5abfda254a2c3a14ffd304) --- source3/librpc/gen_ndr/cli_svcctl.c | 8 ++++++++ source3/librpc/gen_ndr/cli_svcctl.h | 4 ++++ source3/librpc/gen_ndr/ndr_svcctl.c | 39 +++++++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/svcctl.h | 7 +++++++ 4 files changed, 58 insertions(+) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_svcctl.c b/source3/librpc/gen_ndr/cli_svcctl.c index 42711e3174..b8f18afe1c 100644 --- a/source3/librpc/gen_ndr/cli_svcctl.c +++ b/source3/librpc/gen_ndr/cli_svcctl.c @@ -243,12 +243,20 @@ NTSTATUS rpccli_svcctl_QueryServiceObjectSecurity(struct rpc_pipe_client *cli, NTSTATUS rpccli_svcctl_SetServiceObjectSecurity(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + uint32_t security_flags, + uint8_t *buffer, + uint32_t buffer_size, WERROR *werror) { struct svcctl_SetServiceObjectSecurity r; NTSTATUS status; /* In parameters */ + r.in.handle = handle; + r.in.security_flags = security_flags; + r.in.buffer = buffer; + r.in.buffer_size = buffer_size; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(svcctl_SetServiceObjectSecurity, &r); diff --git a/source3/librpc/gen_ndr/cli_svcctl.h b/source3/librpc/gen_ndr/cli_svcctl.h index d9ab510d5a..7c62519187 100644 --- a/source3/librpc/gen_ndr/cli_svcctl.h +++ b/source3/librpc/gen_ndr/cli_svcctl.h @@ -30,6 +30,10 @@ NTSTATUS rpccli_svcctl_QueryServiceObjectSecurity(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_svcctl_SetServiceObjectSecurity(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + uint32_t security_flags, + uint8_t *buffer, + uint32_t buffer_size, WERROR *werror); NTSTATUS rpccli_svcctl_QueryServiceStatus(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_svcctl.c b/source3/librpc/gen_ndr/ndr_svcctl.c index 74466f76c0..16e0416288 100644 --- a/source3/librpc/gen_ndr/ndr_svcctl.c +++ b/source3/librpc/gen_ndr/ndr_svcctl.c @@ -696,6 +696,17 @@ _PUBLIC_ void ndr_print_svcctl_QueryServiceObjectSecurity(struct ndr_print *ndr, static enum ndr_err_code ndr_push_svcctl_SetServiceObjectSecurity(struct ndr_push *ndr, int flags, const struct svcctl_SetServiceObjectSecurity *r) { if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.security_flags)); + if (r->in.buffer == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buffer_size)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.buffer, r->in.buffer_size)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buffer_size)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); @@ -705,7 +716,25 @@ static enum ndr_err_code ndr_push_svcctl_SetServiceObjectSecurity(struct ndr_pus static enum ndr_err_code ndr_pull_svcctl_SetServiceObjectSecurity(struct ndr_pull *ndr, int flags, struct svcctl_SetServiceObjectSecurity *r) { + TALLOC_CTX *_mem_save_handle_0; if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.security_flags)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.buffer)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC_N(ndr, r->in.buffer, ndr_get_array_size(ndr, &r->in.buffer)); + } + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->in.buffer, ndr_get_array_size(ndr, &r->in.buffer))); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buffer_size)); + if (r->in.buffer) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.buffer, r->in.buffer_size)); + } } if (flags & NDR_OUT) { NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); @@ -723,6 +752,16 @@ _PUBLIC_ void ndr_print_svcctl_SetServiceObjectSecurity(struct ndr_print *ndr, c if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "svcctl_SetServiceObjectSecurity"); ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "security_flags", r->in.security_flags); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + ndr_print_array_uint8(ndr, "buffer", r->in.buffer, r->in.buffer_size); + ndr->depth--; + ndr_print_uint32(ndr, "buffer_size", r->in.buffer_size); ndr->depth--; } if (flags & NDR_OUT) { diff --git a/source3/librpc/gen_ndr/svcctl.h b/source3/librpc/gen_ndr/svcctl.h index 1e005d872a..c13e96b2a0 100644 --- a/source3/librpc/gen_ndr/svcctl.h +++ b/source3/librpc/gen_ndr/svcctl.h @@ -149,6 +149,13 @@ struct svcctl_QueryServiceObjectSecurity { struct svcctl_SetServiceObjectSecurity { + struct { + struct policy_handle *handle;/* [ref] */ + uint32_t security_flags; + uint8_t *buffer;/* [ref,size_is(buffer_size)] */ + uint32_t buffer_size; + } in; + struct { WERROR result; } out; -- cgit From c86cbd736957b6d5f3c3f648ce07c593fd60af99 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:33:06 +0100 Subject: Use pidl for _svcctl_SetServiceObjectSecurity(). Guenther (This used to be commit 19048ab4ad1b262536efae5b8b8b4411ec088921) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 28 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 2c594ace8c..5e125145d6 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -244,23 +244,7 @@ static bool api_svcctl_query_security_sec(pipes_struct *p) static bool api_svcctl_set_security_sec(pipes_struct *p) { - SVCCTL_Q_SET_SERVICE_SEC q_u; - SVCCTL_R_SET_SERVICE_SEC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_set_service_sec("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_set_service_sec(p, &q_u, &r_u); - - if(!svcctl_io_r_set_service_sec("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_SETSERVICEOBJECTSECURITY); } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 2672647c1d..73d09b1bbb 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -854,13 +854,16 @@ WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, } /******************************************************************** + _svcctl_SetServiceObjectSecurity ********************************************************************/ -WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, SVCCTL_R_SET_SERVICE_SEC *r_u ) +WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, + struct svcctl_SetServiceObjectSecurity *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); SEC_DESC *sec_desc = NULL; uint32 required_access; + NTSTATUS status; if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) return WERR_BADFID; @@ -872,7 +875,7 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, /* check the access on the open handle */ - switch ( q_u->security_flags ) { + switch ( r->in.security_flags ) { case DACL_SECURITY_INFORMATION: required_access = STD_RIGHT_WRITE_DAC_ACCESS; break; @@ -893,8 +896,12 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, /* read the security descfriptor */ - if ( !sec_io_desc("", &sec_desc, &q_u->buffer.prs, 0 ) ) - return WERR_NOMEM; + status = unmarshall_sec_desc(p->mem_ctx, + r->in.buffer, r->in.buffer_size, + &sec_desc); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } /* store the new SD */ @@ -911,12 +918,6 @@ WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServiceObjectSecurity *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus *r) { p->rng_fault_state = True; -- cgit From edacb74344961d366828087e6f95c19a698e6e0e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:34:45 +0100 Subject: Remove unused marshalling for SVCCTL_SET_SERVICE_SEC. Guenther (This used to be commit 9ac2606d5214f1bf4a8ec2ac46bcaeba62e56992) --- source3/include/rpc_svcctl.h | 15 ----------- source3/rpc_parse/parse_svcctl.c | 56 ---------------------------------------- 2 files changed, 71 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index 1c3d492359..5a87e350ba 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -271,20 +271,5 @@ typedef struct { WERROR status; } SVCCTL_R_QUERY_SERVICE_STATUSEX; - -/**************************/ - -typedef struct { - POLICY_HND handle; - uint32 security_flags; - RPC_BUFFER buffer; - uint32 buffer_size; -} SVCCTL_Q_SET_SERVICE_SEC; - -typedef struct { - WERROR status; -} SVCCTL_R_SET_SERVICE_SEC; - - #endif /* _RPC_SVCCTL_H */ diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index cd08dbef1f..62c1e21927 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -589,59 +589,3 @@ bool svcctl_io_r_query_service_status_ex(const char *desc, SVCCTL_R_QUERY_SERVIC return True; } - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_q_set_service_sec(const char *desc, SVCCTL_Q_SET_SERVICE_SEC *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_set_service_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("handle", &q_u->handle, ps, depth)) - return False; - if(!prs_uint32("security_flags", ps, depth, &q_u->security_flags)) - return False; - - if (!prs_rpcbuffer("buffer", ps, depth, &q_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) - return False; - - return True; - -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_set_service_sec(const char *desc, SVCCTL_R_SET_SERVICE_SEC *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_set_service_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - - - -- cgit From d43aa3ee3a062dfcbab2f3429af1ce491c6c985d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Feb 2008 08:29:07 +0100 Subject: call libnet_conf_get_seqnum() just once and fix compiler warnings metze (This used to be commit fb352fdbcc3fe378d2aadc4914b981eaa06b35ae) --- source3/param/loadparm.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 79c522f77c..e23c30789a 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -3490,6 +3490,7 @@ bool lp_file_list_changed(void) DEBUG(6, ("lp_file_list_changed()\n")); if (lp_config_backend() == CONFIG_BACKEND_REGISTRY) { + uint64_t conf_cur_seqnum; if (conf_ctx == NULL) { WERROR werr; werr = libnet_conf_open(NULL, &conf_ctx); @@ -3499,12 +3500,12 @@ bool lp_file_list_changed(void) return false; } } - if (conf_last_seqnum != - libnet_conf_get_seqnum(conf_ctx, NULL, NULL)) - { - DEBUGADD(6, ("regdb seqnum changed: old = %lu, " - "new = %lu\n", conf_last_seqnum, - libnet_conf_get_seqnum(conf_ctx, NULL, NULL))); + conf_cur_seqnum = libnet_conf_get_seqnum(conf_ctx, NULL, NULL); + if (conf_last_seqnum != conf_cur_seqnum) { + DEBUGADD(6, ("regdb seqnum changed: old = %llu, " + "new = %llu\n", + (unsigned long long)conf_last_seqnum, + (unsigned long long)conf_cur_seqnum)); return true; } else { /* -- cgit From b2ed9341ee309acf2cb6f81bff4bc9243bf21d55 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 10:14:26 +0100 Subject: Fix segfault in _srv_net_file_enum. Guenther (This used to be commit 6523a051ded9f7b433fcce2d4c4a5f186b5a28f6) --- source3/rpc_server/srv_srvsvc_nt.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f0680a89e5..37bd204f75 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1216,17 +1216,20 @@ done: WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) { + const char *username = NULL; + switch ( q_u->level ) { - case 3: { - char *username; - if (!(username = rpcstr_pull_unistr2_talloc( - p->mem_ctx, q_u->username))) { - return WERR_NOMEM; + case 3: + if (q_u->username) { + username = rpcstr_pull_unistr2_talloc( + p->mem_ctx, q_u->username); + if (!username) { + return WERR_NOMEM; + } } return net_file_enum_3(username, r_u, get_enum_hnd(&q_u->enum_hnd)); - } default: return WERR_UNKNOWN_LEVEL; } -- cgit From 1d940490e815bbdb7e4af23ace05ec9ac8fddae8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 28 Feb 2008 02:22:13 -0800 Subject: Fix from Guenter Kukkukk to fix listing against OS/2 servers. OS/2 returns eclass == ERRDOS && ecode == ERRnofiles for a zero entry directory listing. Jeremy. (This used to be commit b34da627053581a9584367e177566d4a2cef7e82) --- source3/libsmb/clierror.c | 12 ++++++++++++ source3/libsmb/clilist.c | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 587abade59..36746419f7 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -483,3 +483,15 @@ void cli_set_nt_error(struct cli_state *cli, NTSTATUS status) SSVAL(cli->inbuf,smb_flg2, SVAL(cli->inbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(status)); } + +/* Reset an error. */ + +void cli_reset_error(struct cli_state *cli) +{ + if (SVAL(cli->inbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES) { + SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(NT_STATUS_OK)); + } else { + SCVAL(cli->inbuf,smb_rcls,0); + SSVAL(cli->inbuf,smb_err,0); + } +} diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index e1b16154f2..50918458b0 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -328,7 +328,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, &rparam, ¶m_len, &rdata, &data_len) && cli_is_dos_error(cli)) { - /* we need to work around a Win95 bug - sometimes + /* We need to work around a Win95 bug - sometimes it gives ERRSRV/ERRerror temprarily */ uint8 eclass; uint32 ecode; @@ -337,6 +337,20 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, SAFE_FREE(rparam); cli_dos_error(cli, &eclass, &ecode); + + /* + * OS/2 might return "no more files", + * which just tells us, that searchcount is zero + * in this search. + * Guenter Kukkukk + */ + + if (eclass == ERRDOS && ecode == ERRnofiles) { + ff_searchcount = 0; + cli_reset_error(cli); + break; + } + if (eclass != ERRSRV || ecode != ERRerror) break; smb_msleep(100); -- cgit From c3ef76593b106e2c35c9c422cd9a216f0039ebf2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 10:52:37 +0100 Subject: Some cosmetics for net_derive_salting_principal(). Guenther (This used to be commit 6f8e83b43085c038bb8fb2500319fed1daf6e4e4) --- source3/utils/net_ads.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index fb644ba55e..199804f3aa 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1277,9 +1277,7 @@ static bool net_derive_salting_principal( TALLOC_CTX *ctx, ADS_STRUCT *ads ) /* if it's a Windows functional domain, we have to look for the UPN */ if ( domain_func == DS_DOMAIN_FUNCTION_2000 ) { - char *upn; - - upn = ads_get_upn(ads, ctx, machine_name); + char *upn = ads_get_upn(ads, ctx, machine_name); if ( upn ) { fstrcpy( salt, upn ); } -- cgit From 3257f6068522ea80d2e62911cccab0fb0b009574 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 10:56:27 +0100 Subject: Add noopnum to libnet join/unjoin calls. Guenther (This used to be commit 0d8081499fd211e1225d651ff208a857167ce1db) --- source3/librpc/idl/libnet_join.idl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/libnet_join.idl b/source3/librpc/idl/libnet_join.idl index 2741b7bd7b..c295fbe2a7 100644 --- a/source3/librpc/idl/libnet_join.idl +++ b/source3/librpc/idl/libnet_join.idl @@ -13,7 +13,7 @@ interface libnetjoin { typedef bitmap wkssvc_joinflags wkssvc_joinflags; - [nopush,nopull] WERROR libnet_JoinCtx( + [nopush,nopull,noopnum] WERROR libnet_JoinCtx( [in] string dc_name, [in] string machine_name, [in,ref] string *domain_name, @@ -39,7 +39,7 @@ interface libnetjoin [out] boolean8 domain_is_ad ); - [nopush,nopull] WERROR libnet_UnjoinCtx( + [nopush,nopull,noopnum] WERROR libnet_UnjoinCtx( [in] string dc_name, [in] string machine_name, [in] string domain_name, -- cgit From 97c2dfc52f0f02c2bc605304885128622cf7f750 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:00:50 +0100 Subject: Use W_ERROR_NOT_OK_GOTO_DONE macro in libnetjoin. Guenther (This used to be commit fec230b28f456469bce051a2b26249d2026a48ea) --- source3/libnet/libnet_join.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 0543ca8474..510b9e2e2f 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -50,6 +50,12 @@ #define LIBNET_UNJOIN_OUT_DUMP_CTX(ctx, r) \ LIBNET_UNJOIN_DUMP_CTX(ctx, r, NDR_OUT) +#define W_ERROR_NOT_OK_GOTO_DONE(x) do { \ + if (!W_ERROR_IS_OK(x)) {\ + goto done;\ + }\ +} while (0) + /**************************************************************** ****************************************************************/ @@ -942,9 +948,7 @@ static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r) if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE)) { werr = libnet_conf_set_global_parameter(ctx, "security", "user"); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } + W_ERROR_NOT_OK_GOTO_DONE(werr); werr = libnet_conf_set_global_parameter(ctx, "workgroup", r->in.domain_name); @@ -952,27 +956,22 @@ static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r) } werr = libnet_conf_set_global_parameter(ctx, "security", "domain"); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } + W_ERROR_NOT_OK_GOTO_DONE(werr); werr = libnet_conf_set_global_parameter(ctx, "workgroup", r->out.netbios_domain_name); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } + W_ERROR_NOT_OK_GOTO_DONE(werr); if (r->out.domain_is_ad) { werr = libnet_conf_set_global_parameter(ctx, "security", "ads"); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } + W_ERROR_NOT_OK_GOTO_DONE(werr); werr = libnet_conf_set_global_parameter(ctx, "realm", r->out.dns_domain_name); + W_ERROR_NOT_OK_GOTO_DONE(werr); } -done: + done: libnet_conf_close(ctx); return werr; } @@ -993,14 +992,11 @@ static WERROR do_unjoin_modify_vals_config(struct libnet_UnjoinCtx *r) if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) { werr = libnet_conf_set_global_parameter(ctx, "security", "user"); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } + W_ERROR_NOT_OK_GOTO_DONE(werr); + libnet_conf_delete_global_parameter(ctx, "realm"); } - libnet_conf_delete_global_parameter(ctx, "realm"); - -done: + done: libnet_conf_close(ctx); return werr; } -- cgit From 39ba91fd8391df61881dc07a04dde7a630f95d39 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:02:01 +0100 Subject: Merge all connect ads calls into libnet_join_post_processing_ads(). Guenther (This used to be commit be96baeffc60d05d8e297034e5253c8b75512ab2) --- source3/libnet/libnet_join.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 510b9e2e2f..2d00fb094f 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -296,13 +296,6 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, const char *spn_array[3] = {NULL, NULL, NULL}; char *spn = NULL; - if (!r->in.ads) { - status = libnet_join_connect_ads(mem_ctx, r); - if (!ADS_ERR_OK(status)) { - return status; - } - } - status = libnet_join_find_machine_acct(mem_ctx, r); if (!ADS_ERR_OK(status)) { return status; @@ -358,13 +351,6 @@ static ADS_STATUS libnet_join_set_machine_upn(TALLOC_CTX *mem_ctx, return ADS_SUCCESS; } - if (!r->in.ads) { - status = libnet_join_connect_ads(mem_ctx, r); - if (!ADS_ERR_OK(status)) { - return status; - } - } - status = libnet_join_find_machine_acct(mem_ctx, r); if (!ADS_ERR_OK(status)) { return status; @@ -408,13 +394,6 @@ static ADS_STATUS libnet_join_set_os_attributes(TALLOC_CTX *mem_ctx, return ADS_SUCCESS; } - if (!r->in.ads) { - status = libnet_join_connect_ads(mem_ctx, r); - if (!ADS_ERR_OK(status)) { - return status; - } - } - status = libnet_join_find_machine_acct(mem_ctx, r); if (!ADS_ERR_OK(status)) { return status; @@ -525,6 +504,13 @@ static ADS_STATUS libnet_join_post_processing_ads(TALLOC_CTX *mem_ctx, { ADS_STATUS status; + if (!r->in.ads) { + status = libnet_join_connect_ads(mem_ctx, r); + if (!ADS_ERR_OK(status)) { + return status; + } + } + status = libnet_join_set_machine_spn(mem_ctx, r); if (!ADS_ERR_OK(status)) { libnet_join_set_error_string(mem_ctx, r, -- cgit From c1636ccd70a075fcc2ba6988a4ad66ce9b606e08 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:11:05 +0100 Subject: Add disabled_machine_account and deleted_machine_accoutn flags to libnetunjoin. Guenther (This used to be commit 365943063497c6330ba77914bb01a2be324866f7) --- source3/librpc/idl/libnet_join.idl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/libnet_join.idl b/source3/librpc/idl/libnet_join.idl index c295fbe2a7..65d17c9203 100644 --- a/source3/librpc/idl/libnet_join.idl +++ b/source3/librpc/idl/libnet_join.idl @@ -55,6 +55,8 @@ interface libnetjoin [out] string netbios_domain_name, [out] string dns_domain_name, [out] boolean8 modified_config, - [out] string error_string + [out] string error_string, + [out] boolean8 disabled_machine_account, + [out] boolean8 deleted_machine_account ); } -- cgit From bdebe9dc2a9dfeb922fe8827f97cc68d468e390d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:12:33 +0100 Subject: Re-run make idl. Guenther (This used to be commit 5895a03fd600745ec897d987910abca83d79de3e) --- source3/librpc/gen_ndr/libnet_join.h | 2 ++ source3/librpc/gen_ndr/ndr_libnet_join.c | 2 ++ source3/librpc/gen_ndr/ndr_libnet_join.h | 6 +----- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/libnet_join.h b/source3/librpc/gen_ndr/libnet_join.h index 27e66ec0a5..8dbadcf0a2 100644 --- a/source3/librpc/gen_ndr/libnet_join.h +++ b/source3/librpc/gen_ndr/libnet_join.h @@ -63,6 +63,8 @@ struct libnet_UnjoinCtx { const char * dns_domain_name; uint8_t modified_config; const char * error_string; + uint8_t disabled_machine_account; + uint8_t deleted_machine_account; WERROR result; } out; diff --git a/source3/librpc/gen_ndr/ndr_libnet_join.c b/source3/librpc/gen_ndr/ndr_libnet_join.c index 5345bc0ad4..6e65d03977 100644 --- a/source3/librpc/gen_ndr/ndr_libnet_join.c +++ b/source3/librpc/gen_ndr/ndr_libnet_join.c @@ -95,6 +95,8 @@ _PUBLIC_ void ndr_print_libnet_UnjoinCtx(struct ndr_print *ndr, const char *name ndr_print_string(ndr, "dns_domain_name", r->out.dns_domain_name); ndr_print_uint8(ndr, "modified_config", r->out.modified_config); ndr_print_string(ndr, "error_string", r->out.error_string); + ndr_print_uint8(ndr, "disabled_machine_account", r->out.disabled_machine_account); + ndr_print_uint8(ndr, "deleted_machine_account", r->out.deleted_machine_account); ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/ndr_libnet_join.h b/source3/librpc/gen_ndr/ndr_libnet_join.h index 4a5fdf0d50..14c8a863aa 100644 --- a/source3/librpc/gen_ndr/ndr_libnet_join.h +++ b/source3/librpc/gen_ndr/ndr_libnet_join.h @@ -6,11 +6,7 @@ #ifndef _HEADER_NDR_libnetjoin #define _HEADER_NDR_libnetjoin -#define NDR_LIBNET_JOINCTX (0x00) - -#define NDR_LIBNET_UNJOINCTX (0x01) - -#define NDR_LIBNETJOIN_CALL_COUNT (2) +#define NDR_LIBNETJOIN_CALL_COUNT (0) enum ndr_err_code ndr_push_libnet_JoinCtx(struct ndr_push *ndr, int flags, const struct libnet_JoinCtx *r); enum ndr_err_code ndr_pull_libnet_JoinCtx(struct ndr_pull *ndr, int flags, struct libnet_JoinCtx *r); void ndr_print_libnet_JoinCtx(struct ndr_print *ndr, const char *name, int flags, const struct libnet_JoinCtx *r); -- cgit From 1d807c3c29eaffb512279d3180f088cfcfe980f8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:17:29 +0100 Subject: Add preliminary libnet_join_post_verify call to libnetjoin. Guenther (This used to be commit f0e319a18d86303aeb73c08841024c27c1b135cd) --- source3/libnet/libnet_join.c | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 2d00fb094f..30b38372f1 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -788,6 +788,132 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, /**************************************************************** ****************************************************************/ +NTSTATUS libnet_join_ok(const char *netbios_domain_name, + const char *machine_name, + const char *dc_name) +{ + uint32_t neg_flags = NETLOGON_NEG_AUTH2_FLAGS | + NETLOGON_NEG_SCHANNEL; + /* FIXME: NETLOGON_NEG_SELECT_AUTH2_FLAGS */ + struct cli_state *cli = NULL; + struct rpc_pipe_client *pipe_hnd = NULL; + struct rpc_pipe_client *netlogon_pipe = NULL; + NTSTATUS status; + char *machine_password = NULL; + char *machine_account = NULL; + + if (!dc_name) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (!secrets_init()) { + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + } + + machine_password = secrets_fetch_machine_password(netbios_domain_name, + NULL, NULL); + if (!machine_password) { + return NT_STATUS_NO_TRUST_LSA_SECRET; + } + + asprintf(&machine_account, "%s$", machine_name); + if (!machine_account) { + SAFE_FREE(machine_password); + return NT_STATUS_NO_MEMORY; + } + + status = cli_full_connection(&cli, NULL, + dc_name, + NULL, 0, + "IPC$", "IPC", + machine_account, + NULL, + machine_password, + 0, + Undefined, NULL); + free(machine_account); + free(machine_password); + + if (!NT_STATUS_IS_OK(status)) { + status = cli_full_connection(&cli, NULL, + dc_name, + NULL, 0, + "IPC$", "IPC", + "", + NULL, + "", + 0, + Undefined, NULL); + } + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + netlogon_pipe = get_schannel_session_key(cli, + netbios_domain_name, + &neg_flags, &status); + if (!netlogon_pipe) { + if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_NETWORK_RESPONSE)) { + cli_shutdown(cli); + return NT_STATUS_OK; + } + + DEBUG(0,("libnet_join_ok: failed to get schannel session " + "key from server %s for domain %s. Error was %s\n", + cli->desthost, netbios_domain_name, nt_errstr(status))); + cli_shutdown(cli); + return status; + } + + if (!lp_client_schannel()) { + cli_shutdown(cli); + return NT_STATUS_OK; + } + + pipe_hnd = cli_rpc_pipe_open_schannel_with_key(cli, PI_NETLOGON, + PIPE_AUTH_LEVEL_PRIVACY, + netbios_domain_name, + netlogon_pipe->dc, + &status); + + cli_shutdown(cli); + + if (!pipe_hnd) { + DEBUG(0,("libnet_join_ok: failed to open schannel session " + "on netlogon pipe to server %s for domain %s. " + "Error was %s\n", + cli->desthost, netbios_domain_name, nt_errstr(status))); + return status; + } + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static WERROR libnet_join_post_verify(TALLOC_CTX *mem_ctx, + struct libnet_JoinCtx *r) +{ + NTSTATUS status; + + status = libnet_join_ok(r->out.netbios_domain_name, + r->in.machine_name, + r->in.dc_name); + if (!NT_STATUS_IS_OK(status)) { + libnet_join_set_error_string(mem_ctx, r, + "failed to verify domain membership after joining: %s", + get_friendly_nt_error_msg(status)); + return WERR_SETUP_NOT_JOINED; + } + + return WERR_OK; +} + +/**************************************************************** +****************************************************************/ + static bool libnet_join_unjoindomain_remove_secrets(TALLOC_CTX *mem_ctx, struct libnet_UnjoinCtx *r) { @@ -1265,6 +1391,11 @@ WERROR libnet_Join(TALLOC_CTX *mem_ctx, if (!W_ERROR_IS_OK(werr)) { goto done; } + + werr = libnet_join_post_verify(mem_ctx, r); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } } werr = libnet_join_post_processing(mem_ctx, r); -- cgit From 09886976f6895dc9e906e62c54408076cd509304 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:19:57 +0100 Subject: Fill in machine account manipulation flags while unjoining in libnetunjoin. Guenther (This used to be commit 23ae67158e6506199318025e3dd5fd5c0b099548) --- source3/libnet/libnet_join.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 30b38372f1..40372611c2 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1464,6 +1464,8 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, return ntstatus_to_werror(status); } + r->out.disabled_machine_account = true; + #ifdef WITH_ADS if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE) { ADS_STATUS ads_status; @@ -1473,6 +1475,12 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, libnet_unjoin_set_error_string(mem_ctx, r, "failed to remove machine account from AD: %s", ads_errstr(ads_status)); + } else { + r->out.deleted_machine_account = true; + /* dirty hack */ + r->out.dns_domain_name = talloc_strdup(mem_ctx, + r->in.ads->server.realm); + W_ERROR_HAVE_NO_MEMORY(r->out.dns_domain_name); } } #endif /* WITH_ADS */ -- cgit From 4ba6c04d0a1f229cd75de9e3ea6be07653b34b51 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:23:36 +0100 Subject: Delete affinity cache entries while unjoining with libnetunjoin. Guenther (This used to be commit 0315b8e53dca9a836d6bc2282fb1192f40545601) --- source3/libnet/libnet_join.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 40372611c2..c690cfc0dc 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1142,7 +1142,7 @@ static WERROR do_JoinConfig(struct libnet_JoinCtx *r) /**************************************************************** ****************************************************************/ -static WERROR do_UnjoinConfig(struct libnet_UnjoinCtx *r) +static WERROR libnet_unjoin_config(struct libnet_UnjoinCtx *r) { WERROR werr; @@ -1509,6 +1509,17 @@ static WERROR libnet_unjoin_pre_processing(TALLOC_CTX *mem_ctx, return WERR_OK; } +/**************************************************************** +****************************************************************/ + +static WERROR libnet_unjoin_post_processing(TALLOC_CTX *mem_ctx, + struct libnet_UnjoinCtx *r) +{ + saf_delete(r->out.netbios_domain_name); + saf_delete(r->out.dns_domain_name); + + return libnet_unjoin_config(r); +} /**************************************************************** ****************************************************************/ @@ -1530,11 +1541,12 @@ WERROR libnet_Unjoin(TALLOC_CTX *mem_ctx, if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) { werr = libnet_DomainUnjoin(mem_ctx, r); if (!W_ERROR_IS_OK(werr)) { + libnet_unjoin_config(r); goto done; } } - werr = do_UnjoinConfig(r); + werr = libnet_unjoin_post_processing(mem_ctx, r); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From 46bdaa5d375f8c8f80045212eb7bdb7bbd3f266d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:26:47 +0100 Subject: Check for mandatory domain name in libnetjoin/unjoin. Guenther (This used to be commit 95bdf2f23c195cad1b317995e362f153695e793a) --- source3/libnet/libnet_join.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index c690cfc0dc..31eec80561 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1171,8 +1171,9 @@ static WERROR libnet_unjoin_config(struct libnet_UnjoinCtx *r) static WERROR libnet_join_pre_processing(TALLOC_CTX *mem_ctx, struct libnet_JoinCtx *r) { - if (!r->in.domain_name) { + libnet_join_set_error_string(mem_ctx, r, + "No domain name defined"); return WERR_INVALID_PARAM; } @@ -1496,6 +1497,12 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, static WERROR libnet_unjoin_pre_processing(TALLOC_CTX *mem_ctx, struct libnet_UnjoinCtx *r) { + if (!r->in.domain_name) { + libnet_unjoin_set_error_string(mem_ctx, r, + "No domain name defined"); + return WERR_INVALID_PARAM; + } + if (r->in.modify_config && !lp_config_backend_is_registry()) { return WERR_NOT_SUPPORTED; } -- cgit From 7347e1ff4797fea2ab3c463f18dfcd81cdac5a75 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:29:56 +0100 Subject: Store domain_is_ad info as early as possible in libnetjoin. Guenther (This used to be commit c4ba68aa94888eace393b91a669e22b27ffaba3e) --- source3/libnet/libnet_join.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 31eec80561..d2242ffb2c 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -152,9 +152,24 @@ static ADS_STATUS libnet_join_connect_ads(TALLOC_CTX *mem_ctx, libnet_join_set_error_string(mem_ctx, r, "failed to connect to AD: %s", ads_errstr(status)); + return status; } - return status; + if (!r->out.netbios_domain_name) { + r->out.netbios_domain_name = talloc_strdup(mem_ctx, + r->in.ads->server.workgroup); + ADS_ERROR_HAVE_NO_MEMORY(r->out.netbios_domain_name); + } + + if (!r->out.dns_domain_name) { + r->out.dns_domain_name = talloc_strdup(mem_ctx, + r->in.ads->config.realm); + ADS_ERROR_HAVE_NO_MEMORY(r->out.dns_domain_name); + } + + r->out.domain_is_ad = true; + + return ADS_SUCCESS; } /**************************************************************** -- cgit From 42e301570b1d14e311b1db5f5afc59a4c6f89d17 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 11:55:36 +0100 Subject: Use libnet_Unjoin() for "net ads leave". Guenther (This used to be commit 11a19e88e208e09d7590370f2e68aa1df5c89e31) --- source3/utils/net_ads.c | 84 ++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 47 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 199804f3aa..8cf76ecbb6 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -23,6 +23,8 @@ #include "includes.h" #include "utils/net.h" +#include "libnet/libnet.h" + #ifdef HAVE_ADS int net_ads_usage(int argc, const char **argv) @@ -810,76 +812,64 @@ static int net_ads_status(int argc, const char **argv) static int net_ads_leave(int argc, const char **argv) { - ADS_STRUCT *ads = NULL; - ADS_STATUS adsret; - NTSTATUS status; - int ret = -1; - struct cli_state *cli = NULL; TALLOC_CTX *ctx; - DOM_SID *dom_sid = NULL; - const char *short_domain_name = NULL; - - if (!secrets_init()) { - DEBUG(1,("Failed to initialise secrets database\n")); - return -1; - } + struct libnet_UnjoinCtx *r = NULL; + WERROR werr; if (!(ctx = talloc_init("net_ads_leave"))) { d_fprintf(stderr, "Could not initialise talloc context.\n"); return -1; } - /* The finds a DC and takes care of getting the - user creds if necessary */ + use_in_memory_ccache(); - if (!ADS_ERR_OK(ads_startup(True, &ads))) { + werr = libnet_init_UnjoinCtx(ctx, &r); + if (!W_ERROR_IS_OK(werr)) { + d_fprintf(stderr, "Could not initialise unjoin context.\n"); return -1; } - /* make RPC calls here */ + r->in.debug = opt_verbose; + r->in.dc_name = opt_host; + r->in.domain_name = lp_realm(); + r->in.admin_account = opt_user_name; + r->in.admin_password = net_prompt_pass(opt_user_name); + r->in.unjoin_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE | + WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE; - if ( !NT_STATUS_IS_OK(connect_to_ipc_krb5(&cli, &ads->ldap.ss, - ads->config.ldap_server_name)) ) - { + werr = libnet_Unjoin(ctx, r); + if (!W_ERROR_IS_OK(werr)) { + d_printf("%s: %s\n", get_friendly_werror_msg(werr), + r->out.error_string ? r->out.error_string : ""); goto done; } - if ( !NT_STATUS_IS_OK(netdom_get_domain_sid( ctx, cli, &short_domain_name, &dom_sid )) ) { + if (W_ERROR_IS_OK(werr)) { + d_printf("Deleted account for '%s' in realm '%s'\n", + r->in.machine_name, r->out.dns_domain_name); goto done; } - saf_delete( short_domain_name ); - - status = netdom_leave_domain(ctx, cli, dom_sid); - - /* Try and delete it via LDAP - the old way we used to. */ - - adsret = ads_leave_realm(ads, global_myname()); - if (ADS_ERR_OK(adsret)) { - d_printf("Deleted account for '%s' in realm '%s'\n", - global_myname(), ads->config.realm); - ret = 0; - } else { - /* We couldn't delete it - see if the disable succeeded. */ - if (NT_STATUS_IS_OK(status)) { - d_printf("Disabled account for '%s' in realm '%s'\n", - global_myname(), ads->config.realm); - ret = 0; - } else { - d_fprintf(stderr, "Failed to disable machine account for '%s' in realm '%s'\n", - global_myname(), ads->config.realm); - } + /* We couldn't delete it - see if the disable succeeded. */ + if (r->out.disabled_machine_account) { + d_printf("Disabled account for '%s' in realm '%s'\n", + r->in.machine_name, r->out.dns_domain_name); + werr = WERR_OK; + goto done; } -done: + d_fprintf(stderr, "Failed to disable machine account for '%s' in realm '%s'\n", + r->in.machine_name, r->out.dns_domain_name); - if ( cli ) - cli_shutdown(cli); + done: + TALLOC_FREE(r); + TALLOC_FREE(ctx); - ads_destroy(&ads); - TALLOC_FREE( ctx ); + if (W_ERROR_IS_OK(werr)) { + return 0; + } - return ret; + return -1; } static NTSTATUS net_ads_join_ok(void) -- cgit From 3e581eeee9a03afad5faf0fd730624cee7485c7b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 28 Feb 2008 11:31:20 +0100 Subject: Remove a useless variable. Michael (This used to be commit 661b9f3d779b419e72968dd3b42348f9da68d803) --- source3/torture/cmd_vfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 82a28bd868..9359b58599 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -842,7 +842,6 @@ static NTSTATUS cmd_ftruncate(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int ar static NTSTATUS cmd_lock(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - bool ret; int fd; int op; long offset; @@ -914,7 +913,7 @@ static NTSTATUS cmd_lock(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c printf("lock: debug lock(fd=%d, op=%d, offset=%ld, count=%ld, type=%d))\n", fd, op, offset, count, type); - if ((ret = SMB_VFS_LOCK(vfs->files[fd], op, offset, count, type)) == False) { + if (SMB_VFS_LOCK(vfs->files[fd], op, offset, count, type) == False) { printf("lock: error=%d (%s)\n", errno, strerror(errno)); return NT_STATUS_UNSUCCESSFUL; } -- 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 +-- source3/libnet/libnet_join.c | 8 +- source3/libsmb/dsgetdcname.c | 144 +++++++++++++++++------------------- source3/utils/net_lookup.c | 7 +- source3/winbindd/winbindd_locator.c | 10 +-- 5 files changed, 87 insertions(+), 94 deletions(-) (limited to 'source3') 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; } diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index d2242ffb2c..623ca39f71 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1315,7 +1315,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx, #endif /* WITH_ADS */ if (!r->in.dc_name) { - struct DS_DOMAIN_CONTROLLER_INFO *info; + struct netr_DsRGetDCNameInfo *info; status = dsgetdcname(mem_ctx, r->in.domain_name, NULL, @@ -1333,7 +1333,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx, } r->in.dc_name = talloc_strdup(mem_ctx, - info->domain_controller_name); + info->dc_unc); W_ERROR_HAVE_NO_MEMORY(r->in.dc_name); } @@ -1447,7 +1447,7 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, } if (!r->in.dc_name) { - struct DS_DOMAIN_CONTROLLER_INFO *info; + struct netr_DsRGetDCNameInfo *info; status = dsgetdcname(mem_ctx, r->in.domain_name, NULL, @@ -1465,7 +1465,7 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, } r->in.dc_name = talloc_strdup(mem_ctx, - info->domain_controller_name); + info->dc_unc); W_ERROR_HAVE_NO_MEMORY(r->in.dc_name); } diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index e0be76cc85..bc9f4b92c8 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -110,7 +110,7 @@ void debug_dsdcinfo_flags(int lvl, uint32_t flags) /********************************************************************* ********************************************************************/ -static int pack_dsdcinfo(struct DS_DOMAIN_CONTROLLER_INFO *info, +static int pack_dsdcinfo(struct netr_DsRGetDCNameInfo *info, unsigned char **buf) { unsigned char *buffer = NULL; @@ -122,9 +122,8 @@ static int pack_dsdcinfo(struct DS_DOMAIN_CONTROLLER_INFO *info, ZERO_STRUCT(guid_flat); - if (info->domain_guid) { - const struct GUID *guid = info->domain_guid; - smb_uuid_pack(*guid, &guid_flat); + if (!GUID_all_zero(&info->domain_guid)) { + smb_uuid_pack(info->domain_guid, &guid_flat); } again: @@ -132,17 +131,17 @@ static int pack_dsdcinfo(struct DS_DOMAIN_CONTROLLER_INFO *info, if (buflen > 0) { DEBUG(10,("pack_dsdcinfo: Packing domain %s (%s)\n", - info->domain_name, info->domain_controller_name)); + info->domain_name, info->dc_unc)); } len += tdb_pack(buffer+len, buflen-len, "ffdBffdff", - info->domain_controller_name, - info->domain_controller_address, - info->domain_controller_address_type, + info->dc_unc, + info->dc_address, + info->dc_address_type, UUID_FLAT_SIZE, guid_flat.info, info->domain_name, - info->dns_forest_name, - info->flags, + info->forest_name, + info->dc_flags, info->dc_site_name, info->client_site_name); @@ -169,33 +168,33 @@ static int pack_dsdcinfo(struct DS_DOMAIN_CONTROLLER_INFO *info, static NTSTATUS unpack_dsdcinfo(TALLOC_CTX *mem_ctx, unsigned char *buf, int buflen, - struct DS_DOMAIN_CONTROLLER_INFO **info_ret) + struct netr_DsRGetDCNameInfo **info_ret) { int len = 0; - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; uint32_t guid_len = 0; unsigned char *guid_buf = NULL; UUID_FLAT guid_flat; /* forgive me 6 times */ - fstring domain_controller_name; - fstring domain_controller_address; + fstring dc_unc; + fstring dc_address; fstring domain_name; - fstring dns_forest_name; + fstring forest_name; fstring dc_site_name; fstring client_site_name; - info = TALLOC_ZERO_P(mem_ctx, struct DS_DOMAIN_CONTROLLER_INFO); + info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo); NT_STATUS_HAVE_NO_MEMORY(info); len += tdb_unpack(buf+len, buflen-len, "ffdBffdff", - &domain_controller_name, - &domain_controller_address, - &info->domain_controller_address_type, + &dc_unc, + &dc_address, + &info->dc_address_type, &guid_len, &guid_buf, &domain_name, - &dns_forest_name, - &info->flags, + &forest_name, + &info->dc_flags, &dc_site_name, &client_site_name); if (len == -1) { @@ -203,23 +202,23 @@ static NTSTATUS unpack_dsdcinfo(TALLOC_CTX *mem_ctx, goto failed; } - info->domain_controller_name = - talloc_strdup(mem_ctx, domain_controller_name); - info->domain_controller_address = - talloc_strdup(mem_ctx, domain_controller_address); + info->dc_unc = + talloc_strdup(mem_ctx, dc_unc); + info->dc_address = + talloc_strdup(mem_ctx, dc_address); info->domain_name = talloc_strdup(mem_ctx, domain_name); - info->dns_forest_name = - talloc_strdup(mem_ctx, dns_forest_name); + info->forest_name = + talloc_strdup(mem_ctx, forest_name); info->dc_site_name = talloc_strdup(mem_ctx, dc_site_name); info->client_site_name = talloc_strdup(mem_ctx, client_site_name); - if (!info->domain_controller_name || - !info->domain_controller_address || + if (!info->dc_unc || + !info->dc_address || !info->domain_name || - !info->dns_forest_name || + !info->forest_name || !info->dc_site_name || !info->client_site_name) { goto failed; @@ -235,16 +234,12 @@ static NTSTATUS unpack_dsdcinfo(TALLOC_CTX *mem_ctx, memcpy(&guid_flat.info, guid_buf, guid_len); smb_uuid_unpack(guid_flat, &guid); - info->domain_guid = (struct GUID *)talloc_memdup( - mem_ctx, &guid, sizeof(guid)); - if (!info->domain_guid) { - goto failed; - } + info->domain_guid = guid; SAFE_FREE(guid_buf); } DEBUG(10,("unpack_dcscinfo: Unpacked domain %s (%s)\n", - info->domain_name, info->domain_controller_name)); + info->domain_name, info->dc_unc)); *info_ret = info; @@ -297,7 +292,7 @@ static NTSTATUS dsgetdcname_cache_delete(TALLOC_CTX *mem_ctx, static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx, const char *domain_name, - struct DS_DOMAIN_CONTROLLER_INFO *info) + struct netr_DsRGetDCNameInfo *info) { time_t expire_time; char *key; @@ -346,7 +341,7 @@ static NTSTATUS dsgetdcname_cache_refresh(TALLOC_CTX *mem_ctx, struct GUID *domain_guid, uint32_t flags, const char *site_name, - struct DS_DOMAIN_CONTROLLER_INFO *info) + struct netr_DsRGetDCNameInfo *info) { struct cldap_netlogon_reply r; @@ -355,7 +350,7 @@ static NTSTATUS dsgetdcname_cache_refresh(TALLOC_CTX *mem_ctx, ZERO_STRUCT(r); - if (ads_cldap_netlogon(info->domain_controller_name, + if (ads_cldap_netlogon(info->dc_unc, info->domain_name, &r)) { dsgetdcname_cache_delete(mem_ctx, domain_name); @@ -409,7 +404,7 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, struct GUID *domain_guid, uint32_t flags, const char *site_name, - struct DS_DOMAIN_CONTROLLER_INFO **info, + struct netr_DsRGetDCNameInfo **info, bool *expired) { char *key; @@ -438,13 +433,13 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, data_blob_free(&blob); /* check flags */ - if (!check_cldap_reply_required_flags((*info)->flags, flags)) { + if (!check_cldap_reply_required_flags((*info)->dc_flags, flags)) { DEBUG(10,("invalid flags\n")); return NT_STATUS_INVALID_PARAMETER; } if ((flags & DS_IP_REQUIRED) && - ((*info)->domain_controller_address_type != ADS_INET_ADDRESS)) { + ((*info)->dc_address_type != DS_ADDRESS_TYPE_INET)) { return NT_STATUS_INVALID_PARAMETER_MIX; } @@ -459,7 +454,7 @@ static NTSTATUS dsgetdcname_cached(TALLOC_CTX *mem_ctx, struct GUID *domain_guid, uint32_t flags, const char *site_name, - struct DS_DOMAIN_CONTROLLER_INFO **info) + struct netr_DsRGetDCNameInfo **info) { NTSTATUS status; bool expired = false; @@ -663,40 +658,36 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx, ****************************************************************/ static NTSTATUS make_domain_controller_info(TALLOC_CTX *mem_ctx, - const char *domain_controller_name, - const char *domain_controller_address, - uint32_t domain_controller_address_type, + const char *dc_unc, + const char *dc_address, + uint32_t dc_address_type, const struct GUID *domain_guid, const char *domain_name, - const char *dns_forest_name, + const char *forest_name, uint32_t flags, const char *dc_site_name, const char *client_site_name, - struct DS_DOMAIN_CONTROLLER_INFO **info_out) + struct netr_DsRGetDCNameInfo **info_out) { - struct DS_DOMAIN_CONTROLLER_INFO *info; + struct netr_DsRGetDCNameInfo *info; - info = TALLOC_ZERO_P(mem_ctx, struct DS_DOMAIN_CONTROLLER_INFO); + info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo); NT_STATUS_HAVE_NO_MEMORY(info); - if (domain_controller_name) { - info->domain_controller_name = talloc_strdup(mem_ctx, - domain_controller_name); - NT_STATUS_HAVE_NO_MEMORY(info->domain_controller_name); + if (dc_unc) { + info->dc_unc = talloc_strdup(mem_ctx, dc_unc); + NT_STATUS_HAVE_NO_MEMORY(info->dc_unc); } - if (domain_controller_address) { - info->domain_controller_address = talloc_strdup(mem_ctx, - domain_controller_address); - NT_STATUS_HAVE_NO_MEMORY(info->domain_controller_address); + if (dc_address) { + info->dc_address = talloc_strdup(mem_ctx, dc_address); + NT_STATUS_HAVE_NO_MEMORY(info->dc_address); } - info->domain_controller_address_type = domain_controller_address_type; + info->dc_address_type = dc_address_type; if (domain_guid) { - info->domain_guid = (struct GUID *)talloc_memdup( - mem_ctx, domain_guid, sizeof(*domain_guid)); - NT_STATUS_HAVE_NO_MEMORY(info->domain_guid); + info->domain_guid = *domain_guid; } if (domain_name) { @@ -704,13 +695,12 @@ static NTSTATUS make_domain_controller_info(TALLOC_CTX *mem_ctx, NT_STATUS_HAVE_NO_MEMORY(info->domain_name); } - if (dns_forest_name) { - info->dns_forest_name = talloc_strdup(mem_ctx, - dns_forest_name); - NT_STATUS_HAVE_NO_MEMORY(info->dns_forest_name); + if (forest_name) { + info->forest_name = talloc_strdup(mem_ctx, forest_name); + NT_STATUS_HAVE_NO_MEMORY(info->forest_name); } - info->flags = flags; + info->dc_flags = flags; if (dc_site_name) { info->dc_site_name = talloc_strdup(mem_ctx, dc_site_name); @@ -736,7 +726,7 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx, uint32_t flags, struct ip_service_name **dclist, int num_dcs, - struct DS_DOMAIN_CONTROLLER_INFO **info) + struct netr_DsRGetDCNameInfo **info) { int i = 0; bool valid_dc = false; @@ -779,12 +769,12 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx, } dc_hostname = r.hostname; dc_domain_name = r.domain; - dc_flags |= ADS_DNS_DOMAIN | ADS_DNS_CONTROLLER; + dc_flags |= DS_DNS_DOMAIN | DS_DNS_CONTROLLER; } else { /* FIXME */ dc_hostname = r.hostname; dc_domain_name = r.domain; - dc_flags |= ADS_DNS_DOMAIN | ADS_DNS_CONTROLLER; + dc_flags |= DS_DNS_DOMAIN | DS_DNS_CONTROLLER; } if (flags & DS_IP_REQUIRED) { @@ -792,17 +782,17 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx, print_sockaddr(addr, sizeof(addr), &dclist[i]->ss); dc_address = talloc_asprintf(mem_ctx, "\\\\%s", addr); - dc_address_type = ADS_INET_ADDRESS; + dc_address_type = DS_ADDRESS_TYPE_INET; } else { dc_address = talloc_asprintf(mem_ctx, "\\\\%s", r.netbios_hostname); - dc_address_type = ADS_NETBIOS_ADDRESS; + dc_address_type = DS_ADDRESS_TYPE_NETBIOS; } NT_STATUS_HAVE_NO_MEMORY(dc_address); smb_uuid_unpack(r.guid, &dc_guid); if (r.forest) { - dc_flags |= ADS_DNS_FOREST; + dc_flags |= DS_DNS_FOREST; } return make_domain_controller_info(mem_ctx, @@ -827,7 +817,7 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, uint32_t flags, struct ip_service_name **dclist, int num_dcs, - struct DS_DOMAIN_CONTROLLER_INFO **info) + struct netr_DsRGetDCNameInfo **info) { /* FIXME: code here */ @@ -842,7 +832,7 @@ static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx, struct GUID *domain_guid, uint32_t flags, const char *site_name, - struct DS_DOMAIN_CONTROLLER_INFO **info) + struct netr_DsRGetDCNameInfo **info) { NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; struct ip_service_name *dclist; @@ -901,10 +891,10 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx, struct GUID *domain_guid, const char *site_name, uint32_t flags, - struct DS_DOMAIN_CONTROLLER_INFO **info) + struct netr_DsRGetDCNameInfo **info) { NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; - struct DS_DOMAIN_CONTROLLER_INFO *myinfo = NULL; + struct netr_DsRGetDCNameInfo *myinfo = NULL; DEBUG(10,("dsgetdcname: domain_name: %s, " "domain_guid: %s, site_name: %s, flags: 0x%08x\n", diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c index 8c01b5b4ba..e5d83bc891 100644 --- a/source3/utils/net_lookup.c +++ b/source3/utils/net_lookup.c @@ -366,8 +366,9 @@ static int net_lookup_dsgetdcname(int argc, const char **argv) const char *domain_name = NULL; char *site_name = NULL; uint32_t flags = 0; - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; TALLOC_CTX *mem_ctx; + char *s = NULL; if (argc < 1 || argc > 3) { d_printf("usage: net lookup dsgetdcname " @@ -410,7 +411,9 @@ static int net_lookup_dsgetdcname(int argc, const char **argv) return -1; } - display_ds_domain_controller_info(mem_ctx, info); + s = NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info); + printf("%s\n", s); + TALLOC_FREE(s); SAFE_FREE(site_name); TALLOC_FREE(mem_ctx); diff --git a/source3/winbindd/winbindd_locator.c b/source3/winbindd/winbindd_locator.c index 6b1cff99e0..10a6c5afeb 100644 --- a/source3/winbindd/winbindd_locator.c +++ b/source3/winbindd/winbindd_locator.c @@ -58,7 +58,7 @@ static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain, struct winbindd_cli_state *state) { NTSTATUS result; - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; const char *dc = NULL; state->request.domain_name @@ -74,15 +74,15 @@ static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain, return WINBINDD_ERROR; } - if (info->domain_controller_address) { - dc = info->domain_controller_address; + if (info->dc_address) { + dc = info->dc_address; if ((dc[0] == '\\') && (dc[1] == '\\')) { dc += 2; } } - if ((!dc || !is_ipaddress_v4(dc)) && info->domain_controller_name) { - dc = info->domain_controller_name; + if ((!dc || !is_ipaddress_v4(dc)) && info->dc_unc) { + dc = info->dc_unc; } if (!dc || !*dc) { -- cgit From 261671dc95d52aabe48cbcc97f608132fa7fe5e1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 12:43:43 +0100 Subject: Remove unused display_ds_domain_controller_info() function. Guenther (This used to be commit 24a5098b1c3452b2d7088cab6ecdd1d75810e403) --- source3/Makefile.in | 5 ++- source3/lib/display_dsdcinfo.c | 72 ------------------------------------------ 2 files changed, 2 insertions(+), 75 deletions(-) delete mode 100644 source3/lib/display_dsdcinfo.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 599e7a9e1f..245889b63c 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -735,7 +735,6 @@ PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) @LIB SMBGET_OBJ = utils/smbget.o $(POPT_LIB_OBJ) $(LIBSMBCLIENT_OBJ0) DISPLAY_SEC_OBJ= lib/display_sec.o -DISPLAY_DSDCINFO_OBJ= lib/display_dsdcinfo.o RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_lsarpc.o \ rpcclient/cmd_samr.o rpcclient/cmd_spoolss.o \ @@ -825,7 +824,7 @@ NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ $(SMBLDAP_OBJ) $(DCUTIL_OBJ) $(SERVER_MUTEX_OBJ) \ $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(READLINE_OBJ) \ $(LDB_OBJ) $(LIBGPO_OBJ) @BUILD_INIPARSER@ $(DISPLAY_SEC_OBJ) \ - $(REG_SMBCONF_OBJ) $(DISPLAY_DSDCINFO_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ + $(REG_SMBCONF_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ \ $(PRIVILEGES_BASIC_OBJ) @@ -943,7 +942,7 @@ PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \ $(IDMAP_OBJ) libsmb/spnego.o $(PASSCHANGE_OBJ) \ $(RPC_NTSVCS_OBJ) $(RPC_INITSHUTDOWN_OBJ) \ utils/passwd_util.o $(LIBGPO_OBJ) $(NSS_INFO_OBJ) \ - $(RPCCLIENT_NDR_OBJ) $(DISPLAY_DSDCINFO_OBJ) \ + $(RPCCLIENT_NDR_OBJ) \ $(PRIVILEGES_BASIC_OBJ) WINBIND_WINS_NSS_OBJ = nsswitch/wins.o $(PARAM_OBJ) \ diff --git a/source3/lib/display_dsdcinfo.c b/source3/lib/display_dsdcinfo.c deleted file mode 100644 index dcb05297a1..0000000000 --- a/source3/lib/display_dsdcinfo.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Guenther Deschner 2007 - - 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 "includes.h" - -/**************************************************************** -****************************************************************/ - -void display_ds_domain_controller_info(TALLOC_CTX *mem_ctx, - const struct DS_DOMAIN_CONTROLLER_INFO *info) -{ - d_printf("domain_controller_name: %s\n", - info->domain_controller_name); - d_printf("domain_controller_address: %s\n", - info->domain_controller_address); - d_printf("domain_controller_address_type: %d\n", - info->domain_controller_address_type); - d_printf("domain_guid: %s\n", - GUID_string(mem_ctx, info->domain_guid)); - d_printf("domain_name: %s\n", - info->domain_name); - d_printf("dns_forest_name: %s\n", - info->dns_forest_name); - - d_printf("flags: 0x%08x\n" - "\tIs a PDC: %s\n" - "\tIs a GC of the forest: %s\n" - "\tIs an LDAP server: %s\n" - "\tSupports DS: %s\n" - "\tIs running a KDC: %s\n" - "\tIs running time services: %s\n" - "\tIs the closest DC: %s\n" - "\tIs writable: %s\n" - "\tHas a hardware clock: %s\n" - "\tIs a non-domain NC serviced by LDAP server: %s\n" - "\tDomainControllerName is a DNS name: %s\n" - "\tDomainName is a DNS name: %s\n" - "\tDnsForestName is a DNS name: %s\n", - info->flags, - (info->flags & ADS_PDC) ? "yes" : "no", - (info->flags & ADS_GC) ? "yes" : "no", - (info->flags & ADS_LDAP) ? "yes" : "no", - (info->flags & ADS_DS) ? "yes" : "no", - (info->flags & ADS_KDC) ? "yes" : "no", - (info->flags & ADS_TIMESERV) ? "yes" : "no", - (info->flags & ADS_CLOSEST) ? "yes" : "no", - (info->flags & ADS_WRITABLE) ? "yes" : "no", - (info->flags & ADS_GOOD_TIMESERV) ? "yes" : "no", - (info->flags & ADS_NDNC) ? "yes" : "no", - (info->flags & ADS_DNS_CONTROLLER) ? "yes":"no", - (info->flags & ADS_DNS_DOMAIN) ? "yes":"no", - (info->flags & ADS_DNS_FOREST) ? "yes":"no"); - - d_printf("dc_site_name: %s\n", info->dc_site_name); - d_printf("client_site_name: %s\n", info->client_site_name); -} -- cgit From b9ca5bf0a12f40030bbbe6a5c881cc4a035ed68d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 12:51:45 +0100 Subject: Fix one dsgetdcname call in wkssvc rpc server. Guenther (This used to be commit a69b918784b037aa17d2dd88a33bd99930631c9b) --- source3/rpc_server/srv_wkssvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index e0103e6b58..43bd20d2d7 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -293,7 +293,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r WERROR werr; NTSTATUS status; struct nt_user_token *token = p->pipe_user.nt_user_token; - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; if (!r->in.domain_name) { return WERR_INVALID_PARAM; @@ -335,7 +335,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r return werr; } - j->in.dc_name = info->domain_controller_name; + j->in.dc_name = info->dc_unc; j->in.domain_name = r->in.domain_name; j->in.account_ou = r->in.account_ou; j->in.join_flags = r->in.join_flags; -- cgit From bbe6d400e7bbc0089c8158a49a5d8d0b5717125f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 13:04:30 +0100 Subject: Re-arrange dns update block during "net ads join" a little. Guenther (This used to be commit 5d30e9f9fef98de7764ae53d3cbe659b78ae9fce) --- source3/utils/net_ads.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 8cf76ecbb6..daddbfae73 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1645,34 +1645,36 @@ int net_ads_join(int argc, const char **argv) DEBUG(1,("Error creating host keytab!\n")); } -#if defined(WITH_DNS_UPDATES) - /* We enter this block with user creds */ + d_printf("Joined '%s' to realm '%s'\n", global_myname(), ads->server.realm); + ads_kdestroy( NULL ); ads_destroy(&ads); - ads = NULL; - if ( (ads = ads_init( lp_realm(), NULL, NULL )) != NULL ) { - /* kinit with the machine password */ +#if defined(WITH_DNS_UPDATES) + { + /* We enter this block with user creds */ + ADS_STRUCT *ads_dns = NULL; + + if ( (ads_dns = ads_init( lp_realm(), NULL, NULL )) != NULL ) { + /* kinit with the machine password */ + + use_in_memory_ccache(); + asprintf( &ads_dns->auth.user_name, "%s$", global_myname() ); + ads_dns->auth.password = secrets_fetch_machine_password( + lp_workgroup(), NULL, NULL ); + ads_dns->auth.realm = SMB_STRDUP( lp_realm() ); + ads_kinit_password( ads_dns ); + } - use_in_memory_ccache(); - asprintf( &ads->auth.user_name, "%s$", global_myname() ); - ads->auth.password = secrets_fetch_machine_password( - lp_workgroup(), NULL, NULL ); - ads->auth.realm = SMB_STRDUP( lp_realm() ); - ads_kinit_password( ads ); - } + if ( !ads_dns || !NT_STATUS_IS_OK(net_update_dns( ctx, ads_dns )) ) { + d_fprintf( stderr, "DNS update failed!\n" ); + } - if ( !ads || !NT_STATUS_IS_OK(net_update_dns( ctx, ads )) ) { - d_fprintf( stderr, "DNS update failed!\n" ); + /* exit from this block using machine creds */ + ads_destroy(&ads_dns); } - - /* exit from this block using machine creds */ #endif - - d_printf("Joined '%s' to realm '%s'\n", global_myname(), ads->server.realm); - TALLOC_FREE( ctx ); - ads_destroy(&ads); return 0; -- cgit From 4b5169f590425334d9ae3f2b7be2201e2e0b747e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 12 Feb 2008 11:54:37 +0100 Subject: Add explicit buf arg to cli_encrypt_message and cli_calculate_sign_mac (This used to be commit db6ae9ed2326e6cd68475375d049084cf1d5a98c) --- source3/libsmb/cliconnect.c | 2 +- source3/libsmb/clientgen.c | 5 +++-- source3/libsmb/smb_seal.c | 6 +++--- source3/libsmb/smb_signing.c | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index d88a5d6242..9c27d30166 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -757,7 +757,7 @@ static NTSTATUS cli_session_setup_ntlmssp(struct cli_state *cli, const char *use /* 'resign' the last message, so we get the right sequence numbers for checking the first reply from the server */ - cli_calculate_sign_mac(cli); + cli_calculate_sign_mac(cli, cli->outbuf); if (!cli_check_sign_mac(cli)) { nt_status = NT_STATUS_ACCESS_DENIED; diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 3b7669f33e..2fd304f135 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -343,10 +343,11 @@ bool cli_send_smb(struct cli_state *cli) if (cli->fd == -1) return false; - cli_calculate_sign_mac(cli); + cli_calculate_sign_mac(cli, cli->outbuf); if (enc_on) { - NTSTATUS status = cli_encrypt_message(cli, &buf_out); + NTSTATUS status = cli_encrypt_message(cli, cli->outbuf, + &buf_out); if (!NT_STATUS_IS_OK(status)) { close(cli->fd); cli->fd = -1; diff --git a/source3/libsmb/smb_seal.c b/source3/libsmb/smb_seal.c index b5befbf7cd..a81ae9afd5 100644 --- a/source3/libsmb/smb_seal.c +++ b/source3/libsmb/smb_seal.c @@ -483,15 +483,15 @@ NTSTATUS cli_decrypt_message(struct cli_state *cli) Encrypt an outgoing buffer. Return the encrypted pointer in buf_out. ******************************************************************************/ -NTSTATUS cli_encrypt_message(struct cli_state *cli, char **buf_out) +NTSTATUS cli_encrypt_message(struct cli_state *cli, char *buf, char **buf_out) { /* Ignore non-session messages. */ - if(CVAL(cli->outbuf,0)) { + if (CVAL(buf,0)) { return NT_STATUS_OK; } /* If we supported multiple encrytion contexts * here we'd look up based on tid. */ - return common_encrypt_buffer(cli->trans_enc_state, cli->outbuf, buf_out); + return common_encrypt_buffer(cli->trans_enc_state, buf, buf_out); } diff --git a/source3/libsmb/smb_signing.c b/source3/libsmb/smb_signing.c index f03c21bd0e..eeaf28c3d1 100644 --- a/source3/libsmb/smb_signing.c +++ b/source3/libsmb/smb_signing.c @@ -573,9 +573,9 @@ void cli_free_signing_context(struct cli_state *cli) * Sign a packet with the current mechanism */ -void cli_calculate_sign_mac(struct cli_state *cli) +void cli_calculate_sign_mac(struct cli_state *cli, char *buf) { - cli->sign_info.sign_outgoing_message(cli->outbuf, &cli->sign_info); + cli->sign_info.sign_outgoing_message(buf, &cli->sign_info); } /** -- cgit From b9f7dd2909487f8e306774ee0475f8b20331a866 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 12 Feb 2008 23:16:37 +0100 Subject: Add explicit buf arg to cli_check_sign_mac (This used to be commit ffc1c8cc03e6bad40ed2be91392074b4f038a1bf) --- source3/libsmb/cliconnect.c | 2 +- source3/libsmb/clientgen.c | 2 +- source3/libsmb/smb_signing.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 9c27d30166..912b841d5e 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -759,7 +759,7 @@ static NTSTATUS cli_session_setup_ntlmssp(struct cli_state *cli, const char *use for checking the first reply from the server */ cli_calculate_sign_mac(cli, cli->outbuf); - if (!cli_check_sign_mac(cli)) { + if (!cli_check_sign_mac(cli, cli->inbuf)) { nt_status = NT_STATUS_ACCESS_DENIED; } } diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 2fd304f135..ccd1cc67d5 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -164,7 +164,7 @@ bool cli_receive_smb(struct cli_state *cli) return false; } - if (!cli_check_sign_mac(cli)) { + if (!cli_check_sign_mac(cli, cli->inbuf)) { /* * If we get a signature failure in sessionsetup, then * the server sometimes just reflects the sent signature diff --git a/source3/libsmb/smb_signing.c b/source3/libsmb/smb_signing.c index eeaf28c3d1..bd6d97123d 100644 --- a/source3/libsmb/smb_signing.c +++ b/source3/libsmb/smb_signing.c @@ -584,9 +584,9 @@ void cli_calculate_sign_mac(struct cli_state *cli, char *buf) * which had a bad checksum, True otherwise. */ -bool cli_check_sign_mac(struct cli_state *cli) +bool cli_check_sign_mac(struct cli_state *cli, char *buf) { - if (!cli->sign_info.check_incoming_message(cli->inbuf, &cli->sign_info, True)) { + if (!cli->sign_info.check_incoming_message(buf, &cli->sign_info, True)) { free_signing_context(&cli->sign_info); return False; } -- cgit From 11b81cb8e419315abc8bf2d7b1a93424aa9788e9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 13:58:34 +0100 Subject: Add WERR_TIME_SKEW to werror mapping tables. Guenther (This used to be commit 74767be627d48eb1a8deea3784847159b536a0fb) --- source3/libsmb/doserr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/libsmb/doserr.c b/source3/libsmb/doserr.c index a3043a2152..203f682599 100644 --- a/source3/libsmb/doserr.c +++ b/source3/libsmb/doserr.c @@ -84,6 +84,7 @@ werror_code_struct dos_errs[] = { "WERR_LOGON_FAILURE", WERR_LOGON_FAILURE }, { "WERR_NO_SUCH_DOMAIN", WERR_NO_SUCH_DOMAIN }, { "WERR_INVALID_SECURITY_DESCRIPTOR", WERR_INVALID_SECURITY_DESCRIPTOR }, + { "WERR_TIME_SKEW", WERR_TIME_SKEW }, { "WERR_INVALID_OWNER", WERR_INVALID_OWNER }, { "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE }, { "WERR_IO_PENDING", WERR_IO_PENDING }, @@ -121,6 +122,7 @@ werror_str_struct dos_err_strs[] = { { WERR_USER_EXISTS, "User account already exists" }, { WERR_PASSWORD_MUST_CHANGE, "The password must be changed" }, { WERR_ACCOUNT_LOCKED_OUT, "Account locked out" }, + { WERR_TIME_SKEW, "Time difference between client and server" }, }; /***************************************************************************** -- cgit From 4d55efe4ab2fed0205d5ce7ffa111b89e0d04c73 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 14:08:32 +0100 Subject: Nicen error output in net_ads_leave. Guenther (This used to be commit b0d1db95e5d7590f9c67be7bf5cb78adfee16635) --- source3/utils/net_ads.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index daddbfae73..c69b816586 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -839,8 +839,9 @@ static int net_ads_leave(int argc, const char **argv) werr = libnet_Unjoin(ctx, r); if (!W_ERROR_IS_OK(werr)) { - d_printf("%s: %s\n", get_friendly_werror_msg(werr), - r->out.error_string ? r->out.error_string : ""); + d_printf("Failed to leave domain: %s\n", + r->out.error_string ? r->out.error_string : + get_friendly_werror_msg(werr)); goto done; } -- cgit From 57a9fba097a5f5af7833eaf4355667dbfacaec43 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 28 Feb 2008 14:03:38 +0100 Subject: Make cli_struct a talloc parent (This used to be commit e69244a5c8c7c6b7c1897adc4b4b1cfdfc7a7999) --- source3/libsmb/clientgen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index ccd1cc67d5..592f050e90 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -537,7 +537,7 @@ struct cli_state *cli_initialise(void) return NULL; } - cli = SMB_MALLOC_P(struct cli_state); + cli = talloc(NULL, struct cli_state); if (!cli) { return NULL; } @@ -695,7 +695,7 @@ void cli_shutdown(struct cli_state *cli) cli->fd = -1; cli->smb_rw_error = SMB_READ_OK; - SAFE_FREE(cli); + TALLOC_FREE(cli); } /**************************************************************************** -- cgit From be4a76a861f3a152f1d1aebf937b06e1628f2d55 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 28 Feb 2008 14:04:54 +0100 Subject: Add cli_setup_packet_buf This is == cli_setup_packet but takes an explicit buffer argument (This used to be commit f64b46dc278899c3449cfd3dbb614aadcf5614d3) --- source3/libsmb/clientgen.c | 54 +++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 592f050e90..64191239d3 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -450,31 +450,41 @@ bool cli_send_smb_direct_writeX(struct cli_state *cli, Setup basics in a outgoing packet. ****************************************************************************/ -void cli_setup_packet(struct cli_state *cli) +void cli_setup_packet_buf(struct cli_state *cli, char *buf) { + uint16 flags2; cli->rap_error = 0; - SSVAL(cli->outbuf,smb_pid,cli->pid); - SSVAL(cli->outbuf,smb_uid,cli->vuid); - SSVAL(cli->outbuf,smb_mid,cli->mid); - if (cli->protocol > PROTOCOL_CORE) { - uint16 flags2; - if (cli->case_sensitive) { - SCVAL(cli->outbuf,smb_flg,0x0); - } else { - /* Default setting, case insensitive. */ - SCVAL(cli->outbuf,smb_flg,0x8); - } - flags2 = FLAGS2_LONG_PATH_COMPONENTS; - if (cli->capabilities & CAP_UNICODE) - flags2 |= FLAGS2_UNICODE_STRINGS; - if ((cli->capabilities & CAP_DFS) && cli->dfsroot) - flags2 |= FLAGS2_DFS_PATHNAMES; - if (cli->capabilities & CAP_STATUS32) - flags2 |= FLAGS2_32_BIT_ERROR_CODES; - if (cli->use_spnego) - flags2 |= FLAGS2_EXTENDED_SECURITY; - SSVAL(cli->outbuf,smb_flg2, flags2); + SIVAL(buf,smb_rcls,0); + SSVAL(buf,smb_pid,cli->pid); + memset(buf+smb_pidhigh, 0, 12); + SSVAL(buf,smb_uid,cli->vuid); + SSVAL(buf,smb_mid,cli->mid); + + if (cli->protocol <= PROTOCOL_CORE) { + return; + } + + if (cli->case_sensitive) { + SCVAL(buf,smb_flg,0x0); + } else { + /* Default setting, case insensitive. */ + SCVAL(buf,smb_flg,0x8); } + flags2 = FLAGS2_LONG_PATH_COMPONENTS; + if (cli->capabilities & CAP_UNICODE) + flags2 |= FLAGS2_UNICODE_STRINGS; + if ((cli->capabilities & CAP_DFS) && cli->dfsroot) + flags2 |= FLAGS2_DFS_PATHNAMES; + if (cli->capabilities & CAP_STATUS32) + flags2 |= FLAGS2_32_BIT_ERROR_CODES; + if (cli->use_spnego) + flags2 |= FLAGS2_EXTENDED_SECURITY; + SSVAL(buf,smb_flg2, flags2); +} + +void cli_setup_packet(struct cli_state *cli) +{ + cli_setup_packet_buf(cli, cli->outbuf); } /**************************************************************************** -- cgit From e5775b4faed78e18353de8fb528615e29b44422d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 14:18:03 +0100 Subject: Use libnet_Join() for "net ads join". Guenther (This used to be commit 9a7a2777e4ea1a2b5d7c800af8522b38cf22c511) --- source3/utils/net_ads.c | 183 +++++++++--------------------------------------- 1 file changed, 33 insertions(+), 150 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index c69b816586..b87920a20f 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1432,19 +1432,15 @@ static int net_ads_join_usage(int argc, const char **argv) int net_ads_join(int argc, const char **argv) { - ADS_STRUCT *ads = NULL; - ADS_STATUS status; NTSTATUS nt_status; - const char *short_domain_name = NULL; - char *tmp_password, *password; TALLOC_CTX *ctx = NULL; - DOM_SID *domain_sid = NULL; + struct libnet_JoinCtx *r; + const char *domain = lp_realm(); + WERROR werr; bool createupn = False; const char *machineupn = NULL; const char *create_in_ou = NULL; int i; - fstring dc_name; - struct sockaddr_storage dcss; const char *os_name = NULL; const char *os_version = NULL; @@ -1454,22 +1450,11 @@ int net_ads_join(int argc, const char **argv) goto fail; } - /* find a DC to initialize the server affinity cache */ - - get_dc_name( lp_workgroup(), lp_realm(), dc_name, &dcss ); - - status = ads_startup(True, &ads); - if (!ADS_ERR_OK(status)) { - DEBUG(1, ("error on ads_startup: %s\n", ads_errstr(status))); - nt_status = ads_ntstatus(status); - goto fail; - } + use_in_memory_ccache(); - if (strcmp(ads->config.realm, lp_realm()) != 0) { - d_fprintf(stderr, "realm of remote server (%s) and realm in %s " - "(%s) DO NOT match. Aborting join\n", - ads->config.realm, get_dyn_CONFIGFILE(), lp_realm()); - nt_status = NT_STATUS_INVALID_PARAMETER; + werr = libnet_init_JoinCtx(ctx, &r); + if (!W_ERROR_IS_OK(werr)) { + nt_status = werror_to_ntstatus(werr); goto fail; } @@ -1508,148 +1493,45 @@ int net_ads_join(int argc, const char **argv) } } else { - d_fprintf(stderr, "Bad option: %s\n", argv[i]); - nt_status = NT_STATUS_INVALID_PARAMETER; - goto fail; - } - } - - /* If we were given an OU, try to create the machine in - the OU account first and then do the normal RPC join */ - - if ( create_in_ou ) { - status = net_precreate_machine_acct( ads, create_in_ou ); - if ( !ADS_ERR_OK(status) ) { - d_fprintf( stderr, "Failed to pre-create the machine object " - "in OU %s.\n", create_in_ou); - DEBUG(1, ("error calling net_precreate_machine_acct: %s\n", - ads_errstr(status))); - nt_status = ads_ntstatus(status); - goto fail; + domain = argv[i]; } } /* Do the domain join here */ - tmp_password = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); - password = talloc_strdup(ctx, tmp_password); + r->in.domain_name = domain; + r->in.create_upn = createupn; + r->in.upn = machineupn; + r->in.account_ou = create_in_ou; + r->in.os_name = os_name; + r->in.os_version = os_version; + r->in.dc_name = opt_host; + r->in.admin_account = opt_user_name; + r->in.admin_password = net_prompt_pass(opt_user_name); + r->in.debug = opt_verbose; + r->in.join_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE | + WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE | + WKSSVC_JOIN_FLAGS_DOMAIN_JOIN_IF_JOINED; - nt_status = net_join_domain(ctx, ads->config.ldap_server_name, - &ads->ldap.ss, &short_domain_name, &domain_sid, password); - if ( !NT_STATUS_IS_OK(nt_status) ) { - DEBUG(1, ("call of net_join_domain failed: %s\n", - get_friendly_nt_error_msg(nt_status))); + werr = libnet_Join(ctx, r); + if (!W_ERROR_IS_OK(werr)) { goto fail; } /* Check the short name of the domain */ - if ( !strequal(lp_workgroup(), short_domain_name) ) { + if (!strequal(lp_workgroup(), r->out.netbios_domain_name)) { d_printf("The workgroup in %s does not match the short\n", get_dyn_CONFIGFILE()); d_printf("domain name obtained from the server.\n"); - d_printf("Using the name [%s] from the server.\n", short_domain_name); + d_printf("Using the name [%s] from the server.\n", r->out.netbios_domain_name); d_printf("You should set \"workgroup = %s\" in %s.\n", - short_domain_name, get_dyn_CONFIGFILE()); - } - - d_printf("Using short domain name -- %s\n", short_domain_name); - - /* HACK ALERT! Store the sid and password under both the lp_workgroup() - value from smb.conf and the string returned from the server. The former is - neede to bootstrap winbindd's first connection to the DC to get the real - short domain name --jerry */ - - if ( (netdom_store_machine_account( lp_workgroup(), domain_sid, password ) == -1) - || (netdom_store_machine_account( short_domain_name, domain_sid, password ) == -1) ) - { - /* issue an internal error here for now. - * everything else would mean changing tdb routines. */ - nt_status = NT_STATUS_INTERNAL_ERROR; - goto fail; - } - - /* Verify that everything is ok */ - - nt_status = net_rpc_join_ok(short_domain_name, - ads->config.ldap_server_name, &ads->ldap.ss); - if (!NT_STATUS_IS_OK(nt_status)) { - d_fprintf(stderr, - "Failed to verify membership in domain: %s!\n", - nt_errstr(nt_status)); - goto fail; + r->out.netbios_domain_name, get_dyn_CONFIGFILE()); } - /* create the dNSHostName & servicePrincipalName values */ + d_printf("Using short domain name -- %s\n", r->out.netbios_domain_name); - status = net_set_machine_spn( ctx, ads ); - if ( !ADS_ERR_OK(status) ) { - - d_fprintf(stderr, "Failed to set servicePrincipalNames. Please ensure that\n"); - d_fprintf(stderr, "the DNS domain of this server matches the AD domain,\n"); - d_fprintf(stderr, "Or rejoin with using Domain Admin credentials.\n"); - - /* Disable the machine account in AD. Better to fail than to leave - a confused admin. */ - - if ( net_ads_leave( 0, NULL ) != 0 ) { - d_fprintf( stderr, "Failed to disable machine account in AD. Please do so manually.\n"); - } - - /* clear out the machine password */ - - netdom_store_machine_account( lp_workgroup(), domain_sid, "" ); - netdom_store_machine_account( short_domain_name, domain_sid, "" ); - - nt_status = ads_ntstatus(status); - goto fail; - } - - if ( !net_derive_salting_principal( ctx, ads ) ) { - DEBUG(1,("Failed to determine salting principal\n")); - goto fail; - } - - if ( createupn ) { - char *upn; - - /* default to using the short UPN name */ - if (!machineupn ) { - upn = talloc_asprintf(ctx, - "host/%s@%s", global_myname(), - ads->config.realm ); - if (!upn) { - nt_status = NT_STATUS_NO_MEMORY; - goto fail; - } - machineupn = upn; - } - - status = net_set_machine_upn( ctx, ads, machineupn ); - if ( !ADS_ERR_OK(status) ) { - d_fprintf(stderr, "Failed to set userPrincipalName. Are you a Domain Admin?\n"); - } - } - - /* Try to set the operatingSystem attributes if asked */ - - if ( os_name && os_version ) { - status = net_set_os_attributes( ctx, ads, os_name, os_version ); - if ( !ADS_ERR_OK(status) ) { - d_fprintf(stderr, "Failed to set operatingSystem attributes. " - "Are you a Domain Admin?\n"); - } - } - - /* Now build the keytab, using the same ADS connection */ - - if (lp_use_kerberos_keytab() && ads_keytab_create_default(ads)) { - DEBUG(1,("Error creating host keytab!\n")); - } - - d_printf("Joined '%s' to realm '%s'\n", global_myname(), ads->server.realm); - - ads_kdestroy( NULL ); - ads_destroy(&ads); + d_printf("Joined '%s' to realm '%s'\n", r->in.machine_name, + r->out.dns_domain_name); #if defined(WITH_DNS_UPDATES) { @@ -1675,16 +1557,17 @@ int net_ads_join(int argc, const char **argv) ads_destroy(&ads_dns); } #endif + TALLOC_FREE(r); TALLOC_FREE( ctx ); return 0; fail: /* issue an overall failure message at the end. */ - d_printf("Failed to join domain: %s\n", get_friendly_nt_error_msg(nt_status)); - + d_printf("Failed to join domain: %s\n", + r->out.error_string ? r->out.error_string : + get_friendly_werror_msg(werr)); TALLOC_FREE( ctx ); - ads_destroy(&ads); return -1; -- cgit From 642f46dcf9717c274bb93abc20cf19a8a757ecae Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 14:29:44 +0100 Subject: Some fixes for net ads join (uninitialized vars). Guenther (This used to be commit 735235e32bf41a7564ce2d585c1dae187b00bf6b) --- source3/utils/net_ads.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index b87920a20f..345665d62e 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1434,9 +1434,9 @@ int net_ads_join(int argc, const char **argv) { NTSTATUS nt_status; TALLOC_CTX *ctx = NULL; - struct libnet_JoinCtx *r; + struct libnet_JoinCtx *r = NULL; const char *domain = lp_realm(); - WERROR werr; + WERROR werr = WERR_SETUP_NOT_JOINED; bool createupn = False; const char *machineupn = NULL; const char *create_in_ou = NULL; @@ -1447,6 +1447,7 @@ int net_ads_join(int argc, const char **argv) nt_status = check_ads_config(); if (!NT_STATUS_IS_OK(nt_status)) { d_fprintf(stderr, "Invalid configuration. Exiting....\n"); + werr = ntstatus_to_werror(nt_status); goto fail; } @@ -1454,13 +1455,12 @@ int net_ads_join(int argc, const char **argv) werr = libnet_init_JoinCtx(ctx, &r); if (!W_ERROR_IS_OK(werr)) { - nt_status = werror_to_ntstatus(werr); goto fail; } if (!(ctx = talloc_init("net_ads_join"))) { d_fprintf(stderr, "Could not initialise talloc context.\n"); - nt_status = NT_STATUS_NO_MEMORY; + werr = WERR_NOMEM; goto fail; } @@ -1474,21 +1474,21 @@ int net_ads_join(int argc, const char **argv) else if ( !StrnCaseCmp(argv[i], "createcomputer", strlen("createcomputer")) ) { if ( (create_in_ou = get_string_param(argv[i])) == NULL ) { d_fprintf(stderr, "Please supply a valid OU path.\n"); - nt_status = NT_STATUS_INVALID_PARAMETER; + werr = WERR_INVALID_PARAM; goto fail; } } else if ( !StrnCaseCmp(argv[i], "osName", strlen("osName")) ) { if ( (os_name = get_string_param(argv[i])) == NULL ) { d_fprintf(stderr, "Please supply a operating system name.\n"); - nt_status = NT_STATUS_INVALID_PARAMETER; + werr = WERR_INVALID_PARAM; goto fail; } } else if ( !StrnCaseCmp(argv[i], "osVer", strlen("osVer")) ) { if ( (os_version = get_string_param(argv[i])) == NULL ) { d_fprintf(stderr, "Please supply a valid operating system version.\n"); - nt_status = NT_STATUS_INVALID_PARAMETER; + werr = WERR_INVALID_PARAM; goto fail; } } @@ -1565,12 +1565,11 @@ int net_ads_join(int argc, const char **argv) fail: /* issue an overall failure message at the end. */ d_printf("Failed to join domain: %s\n", - r->out.error_string ? r->out.error_string : + r && r->out.error_string ? r->out.error_string : get_friendly_werror_msg(werr)); TALLOC_FREE( ctx ); return -1; - } /******************************************************************* -- cgit From a763f4b79f56b09d633114aed776f168356741ae Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 28 Feb 2008 05:54:50 -0800 Subject: Don't define SMB_TRANS_ENC_GSS if we don't have KRB5. Jeremy. (This used to be commit 6f2b33f6072629be393f88d4450fa6631ef672f6) --- source3/include/client.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/include/client.h b/source3/include/client.h index f8adf567de..d29a2e7341 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -82,7 +82,12 @@ struct rpc_pipe_client { }; /* Transport encryption state. */ -enum smb_trans_enc_type { SMB_TRANS_ENC_NTLM, SMB_TRANS_ENC_GSS }; +enum smb_trans_enc_type { + SMB_TRANS_ENC_NTLM +#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5) + , SMB_TRANS_ENC_GSS +#endif +}; #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5) struct smb_tran_enc_state_gss { -- cgit From 6e2e0e2ce7ebef473cf8f8787363500eb090d692 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 28 Feb 2008 06:01:09 -0800 Subject: Fix the build - don't use SMB_TRANS_ENC_GSS without KRB5. Jeremy. (This used to be commit d16c295642c3df49be02440427ded0cd9b4179f5) --- source3/libsmb/clifsinfo.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c index f4945f812a..0005c3908a 100644 --- a/source3/libsmb/clifsinfo.c +++ b/source3/libsmb/clifsinfo.c @@ -368,20 +368,16 @@ static struct smb_trans_enc_state *make_cli_enc_state(enum smb_trans_enc_type sm ZERO_STRUCTP(es); es->smb_enc_type = smb_enc_type; - if (smb_enc_type == SMB_TRANS_ENC_GSS) { #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5) + if (smb_enc_type == SMB_TRANS_ENC_GSS) { es->s.gss_state = SMB_MALLOC_P(struct smb_tran_enc_state_gss); if (!es->s.gss_state) { SAFE_FREE(es); return NULL; } ZERO_STRUCTP(es->s.gss_state); -#else - DEBUG(0,("make_cli_enc_state: no krb5 compiled.\n")); - SAFE_FREE(es); - return NULL; -#endif } +#endif return es; } -- cgit From 93e06129abf02fa445830955f33d981a407dc17d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 28 Feb 2008 13:55:53 +0100 Subject: Add basic infrastructure for general async requests (This used to be commit ae254cb61f4b9331755848c47ebc34e90dd80390) --- source3/Makefile.in | 2 +- source3/include/async_req.h | 89 +++++++++++++++++++++++++++++++++++++++++++++ source3/include/includes.h | 1 + source3/lib/async_req.c | 68 ++++++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 source3/include/async_req.h create mode 100644 source3/lib/async_req.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 245889b63c..15b2910245 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -323,7 +323,7 @@ LIB_WITHOUT_PROTO_OBJ = $(LIBSAMBAUTIL_OBJ) \ lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \ lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o lib/talloc_stack.o \ lib/interfaces.o lib/rbtree.o lib/memcache.o \ - lib/util_transfer_file.o + lib/util_transfer_file.o lib/async_req.o LIB_WITH_PROTO_OBJ = $(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \ lib/interface.o lib/md4.o \ diff --git a/source3/include/async_req.h b/source3/include/async_req.h new file mode 100644 index 0000000000..6df53602b2 --- /dev/null +++ b/source3/include/async_req.h @@ -0,0 +1,89 @@ +/* + Unix SMB/CIFS implementation. + Infrastructure for async requests + Copyright (C) Volker Lendecke 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 . +*/ + +#ifndef __ASYNC_REQ_H__ +#define __ASYNC_REQ_H__ + +#include "includes.h" + +/* + * An async request moves between the following 4 states. + */ +enum async_req_state { + ASYNC_REQ_INIT, /* we are creating the request */ + ASYNC_REQ_IN_PROGRESS, /* we are waiting the request to complete */ + ASYNC_REQ_DONE, /* the request is finished */ + ASYNC_REQ_ERROR }; /* an error has occured */ + +struct async_req { + /* the external state - will be queried by the caller */ + enum async_req_state state; + + /* a private pointer for use by the async function implementation */ + void *private_data; + + /* print yourself, for debugging purposes */ + char *(*print)(TALLOC_CTX *mem_ctx, struct async_req *); + + /* status code when finished */ + NTSTATUS status; + + /* the event context we are using */ + struct event_context *event_ctx; + + /* information on what to do on completion */ + struct { + void (*fn)(struct async_req *); + void *priv; + } async; +}; + +/* + * Print an async_req structure for debugging purposes + */ +char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req); + +/* + * Create an async request + */ +struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev); + +/* + * An async request has successfully finished, invoke the callback + */ +void async_req_done(struct async_req *req); + +/* + * An async request has seen an error, invoke the callback + */ +void async_req_error(struct async_req *req, NTSTATUS status); + +/* + * Convenience helper to easily check alloc failure within a callback. + * + * Call pattern would be + * p = talloc(mem_ctx, bla); + * if (async_req_nomem(p, req)) { + * return; + * } + * + */ +bool async_req_nomem(const void *p, struct async_req *req); + +#endif diff --git a/source3/include/includes.h b/source3/include/includes.h index a2c3a0c466..8b94d7aed2 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -723,6 +723,7 @@ typedef char fstring[FSTRING_LEN]; #include "ctdbd_conn.h" #include "talloc_stack.h" #include "memcache.h" +#include "async_req.h" /* used in net.c */ struct functable { diff --git a/source3/lib/async_req.c b/source3/lib/async_req.c new file mode 100644 index 0000000000..01154ca436 --- /dev/null +++ b/source3/lib/async_req.c @@ -0,0 +1,68 @@ +/* + Unix SMB/CIFS implementation. + Infrastructure for async requests + Copyright (C) Volker Lendecke 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 "includes.h" + +char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req) +{ + return talloc_asprintf(mem_ctx, "async_req: state=%d, status=%s, " + "priv=%s", req->state, nt_errstr(req->status), + talloc_get_name(req->private_data)); +} + +struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev) +{ + struct async_req *result; + + result = TALLOC_ZERO_P(mem_ctx, struct async_req); + if (result == NULL) { + return NULL; + } + result->state = ASYNC_REQ_IN_PROGRESS; + result->event_ctx = ev; + result->print = async_req_print; + return result; +} + +void async_req_done(struct async_req *req) +{ + req->status = NT_STATUS_OK; + req->state = ASYNC_REQ_DONE; + if (req->async.fn != NULL) { + req->async.fn(req); + } +} + +void async_req_error(struct async_req *req, NTSTATUS status) +{ + req->status = status; + req->state = ASYNC_REQ_ERROR; + if (req->async.fn != NULL) { + req->async.fn(req); + } +} + +bool async_req_nomem(const void *p, struct async_req *req) +{ + if (p != NULL) { + return false; + } + async_req_error(req, NT_STATUS_NO_MEMORY); + return true; +} -- cgit From 1d41b5bd2a58dcc6966a3a49ccb063ff05e46125 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 28 Feb 2008 14:41:25 +0100 Subject: Add infrastructure to support async SMB requests (This used to be commit f5356825698a02df2d400b51dd95d1f857c83e81) --- source3/Makefile.in | 2 +- source3/include/async_smb.h | 62 ++++++ source3/include/client.h | 30 +++ source3/include/includes.h | 1 + source3/libsmb/async_smb.c | 483 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 577 insertions(+), 1 deletion(-) create mode 100644 source3/include/async_smb.h create mode 100644 source3/libsmb/async_smb.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 15b2910245..e0068ba5cb 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -408,7 +408,7 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \ libsmb/clistr.o libsmb/cliquota.o libsmb/clifsinfo.o libsmb/clidfs.o \ libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \ libsmb/clioplock.o $(ERRORMAP_OBJ) libsmb/clirap2.o \ - libsmb/smb_seal.o $(DOSERR_OBJ) \ + libsmb/smb_seal.o $(DOSERR_OBJ) libsmb/async_smb.o \ $(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(LIBNMB_OBJ) RPC_CLIENT_OBJ1 = rpc_client/cli_netlogon.o rpc_client/cli_srvsvc.o diff --git a/source3/include/async_smb.h b/source3/include/async_smb.h new file mode 100644 index 0000000000..19408be74b --- /dev/null +++ b/source3/include/async_smb.h @@ -0,0 +1,62 @@ +/* + Unix SMB/CIFS implementation. + Infrastructure for async SMB client requests + Copyright (C) Volker Lendecke 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 "includes.h" + +/* + * Create a fresh async smb request + */ + +struct async_req *cli_request_new(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + uint8_t num_words, size_t num_bytes, + struct cli_request **preq); + +/* + * Convenience function to get the SMB part out of an async_req + */ + +struct cli_request *cli_request_get(struct async_req *req); + +/* + * Fetch an error out of a NBT packet + */ + +NTSTATUS cli_pull_error(char *buf); + +/* + * Compatibility helper for the sync APIs: Fake NTSTATUS in cli->inbuf + */ + +void cli_set_error(struct cli_state *cli, NTSTATUS status); + +/* + * Create a temporary event context for use in the sync helper functions + */ + +struct cli_tmp_event *cli_tmp_event_ctx(TALLOC_CTX *mem_ctx, + struct cli_state *cli); + +/* + * Attach an event context permanently to a cli_struct + */ + +NTSTATUS cli_add_event_ctx(struct cli_state *cli, + struct event_context *event_ctx); diff --git a/source3/include/client.h b/source3/include/client.h index d29a2e7341..52dc513d65 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -192,6 +192,36 @@ struct cli_state { bool force_dos_errors; bool case_sensitive; /* False by default. */ + + struct event_context *event_ctx; + struct fd_event *fd_event; + char *evt_inbuf; + + struct cli_request *outstanding_requests; +}; + +struct cli_request { + struct cli_request *prev, *next; + struct async_req *async; + + struct cli_state *cli; + + struct smb_trans_enc_state *enc_state; + + uint16_t mid; + + char *outbuf; + size_t sent; + char *inbuf; + + union { + struct { + off_t ofs; + size_t size; + ssize_t received; + uint8_t *rcvbuf; + } read; + } data; }; typedef struct file_info { diff --git a/source3/include/includes.h b/source3/include/includes.h index 8b94d7aed2..269baa5a9c 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -724,6 +724,7 @@ typedef char fstring[FSTRING_LEN]; #include "talloc_stack.h" #include "memcache.h" #include "async_req.h" +#include "async_smb.h" /* used in net.c */ struct functable { diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c new file mode 100644 index 0000000000..21bcd5b9b1 --- /dev/null +++ b/source3/libsmb/async_smb.c @@ -0,0 +1,483 @@ +/* + Unix SMB/CIFS implementation. + Infrastructure for async SMB client requests + Copyright (C) Volker Lendecke 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 "includes.h" + +/* + * Fetch an error out of a NBT packet + */ + +NTSTATUS cli_pull_error(char *buf) +{ + uint32_t flags2 = SVAL(buf, smb_flg2); + + if (flags2 & FLAGS2_32_BIT_ERROR_CODES) { + return NT_STATUS(IVAL(buf, smb_rcls)); + } + + return NT_STATUS_DOS(CVAL(buf, smb_rcls), SVAL(buf,smb_err)); +} + +/* + * Compatibility helper for the sync APIs: Fake NTSTATUS in cli->inbuf + */ + +void cli_set_error(struct cli_state *cli, NTSTATUS status) +{ + uint32_t flags2 = SVAL(cli->inbuf, smb_flg2); + + if (NT_STATUS_IS_DOS(status)) { + SSVAL(cli->inbuf, smb_flg2, + flags2 & ~FLAGS2_32_BIT_ERROR_CODES); + SCVAL(cli->inbuf, smb_rcls, NT_STATUS_DOS_CLASS(status)); + SSVAL(cli->inbuf, smb_err, NT_STATUS_DOS_CODE(status)); + return; + } + + SSVAL(cli->inbuf, smb_flg2, flags2 | FLAGS2_32_BIT_ERROR_CODES); + SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(status)); + return; +} + +/* + * Allocate a new mid + */ + +static uint16_t cli_new_mid(struct cli_state *cli) +{ + uint16_t result; + struct cli_request *req; + + while (true) { + result = cli->mid++; + if (result == 0) { + continue; + } + + for (req = cli->outstanding_requests; req; req = req->next) { + if (result == req->mid) { + break; + } + } + + if (req == NULL) { + return result; + } + } +} + +static char *cli_request_print(TALLOC_CTX *mem_ctx, struct async_req *req) +{ + char *result = async_req_print(mem_ctx, req); + struct cli_request *cli_req = cli_request_get(req); + + if (result == NULL) { + return NULL; + } + + return talloc_asprintf_append_buffer( + result, "mid=%d\n", cli_req->mid); +} + +static int cli_request_destructor(struct cli_request *req) +{ + if (req->enc_state != NULL) { + common_free_enc_buffer(req->enc_state, req->outbuf); + } + DLIST_REMOVE(req->cli->outstanding_requests, req); + return 0; +} + +/* + * Create a fresh async smb request + */ + +struct async_req *cli_request_new(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + uint8_t num_words, size_t num_bytes, + struct cli_request **preq) +{ + struct async_req *result; + struct cli_request *cli_req; + size_t bufsize = smb_size + num_words * 2 + num_bytes; + + result = async_req_new(mem_ctx, ev); + if (result == NULL) { + return NULL; + } + + cli_req = (struct cli_request *)talloc_size( + result, sizeof(*cli_req) + bufsize); + if (cli_req == NULL) { + TALLOC_FREE(result); + return NULL; + } + talloc_set_name_const(cli_req, "struct cli_request"); + result->private_data = cli_req; + result->print = cli_request_print; + + cli_req->async = result; + cli_req->cli = cli; + cli_req->outbuf = ((char *)cli_req + sizeof(*cli_req)); + cli_req->sent = 0; + cli_req->mid = cli_new_mid(cli); + cli_req->inbuf = NULL; + cli_req->enc_state = NULL; + + SCVAL(cli_req->outbuf, smb_wct, num_words); + SSVAL(cli_req->outbuf, smb_vwv + num_words * 2, num_bytes); + + DLIST_ADD_END(cli->outstanding_requests, cli_req, + struct cli_request *); + talloc_set_destructor(cli_req, cli_request_destructor); + + DEBUG(10, ("cli_request_new: mid=%d\n", cli_req->mid)); + + *preq = cli_req; + return result; +} + +/* + * Convenience function to get the SMB part out of an async_req + */ + +struct cli_request *cli_request_get(struct async_req *req) +{ + if (req == NULL) { + return NULL; + } + return talloc_get_type_abort(req->private_data, struct cli_request); +} + +/* + * A PDU has arrived on cli->evt_inbuf + */ + +static void handle_incoming_pdu(struct cli_state *cli) +{ + struct cli_request *req; + uint16_t mid; + size_t raw_pdu_len, buf_len, pdu_len; + size_t rest_len; + NTSTATUS status; + + /* + * The encrypted PDU len might differ from the unencrypted one + */ + raw_pdu_len = smb_len(cli->evt_inbuf) + 4; + + /* + * TODO: Handle oplock break requests + */ + + if (cli_encryption_on(cli) && CVAL(cli->evt_inbuf, 0) == 0) { + uint16_t enc_ctx_num; + + status = get_enc_ctx_num((uint8_t *)cli->evt_inbuf, + &enc_ctx_num); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("get_enc_ctx_num returned %s\n", + nt_errstr(status))); + goto invalidate_requests; + } + + if (enc_ctx_num != cli->trans_enc_state->enc_ctx_num) { + DEBUG(10, ("wrong enc_ctx %d, expected %d\n", + enc_ctx_num, + cli->trans_enc_state->enc_ctx_num)); + status = NT_STATUS_INVALID_HANDLE; + goto invalidate_requests; + } + + status = common_decrypt_buffer(cli->trans_enc_state, + cli->evt_inbuf); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("common_decrypt_buffer returned %s\n", + nt_errstr(status))); + goto invalidate_requests; + } + } + + if (!cli_check_sign_mac(cli, cli->evt_inbuf)) { + DEBUG(10, ("cli_check_sign_mac failed\n")); + status = NT_STATUS_ACCESS_DENIED; + goto invalidate_requests; + } + + mid = SVAL(cli->evt_inbuf, smb_mid); + + DEBUG(10, ("handle_incoming_pdu: got mid %d\n", mid)); + + for (req = cli->outstanding_requests; req; req = req->next) { + if (req->mid == mid) { + break; + } + } + + buf_len = talloc_get_size(cli->evt_inbuf); + pdu_len = smb_len(cli->evt_inbuf) + 4; + rest_len = buf_len - raw_pdu_len; + + if (req == NULL) { + DEBUG(3, ("Request for mid %d not found, dumping PDU\n", mid)); + + memmove(cli->evt_inbuf, cli->evt_inbuf + raw_pdu_len, + buf_len - raw_pdu_len); + + cli->evt_inbuf = TALLOC_REALLOC_ARRAY(NULL, cli->evt_inbuf, + char, rest_len); + return; + } + + if (buf_len == pdu_len) { + /* + * Optimal case: Exactly one PDU was in the socket buffer + */ + req->inbuf = talloc_move(req, &cli->evt_inbuf); + goto done; + } + + DEBUG(11, ("buf_len = %d, pdu_len = %d, splitting buffer\n", + (int)buf_len, (int)pdu_len)); + + if (pdu_len < rest_len) { + /* + * The PDU is shorter, talloc_memdup that one. + */ + req->inbuf = (char *)talloc_memdup( + req, cli->evt_inbuf, pdu_len); + + memmove(cli->evt_inbuf, + cli->evt_inbuf + raw_pdu_len, + buf_len - raw_pdu_len); + + cli->evt_inbuf = TALLOC_REALLOC_ARRAY( + NULL, cli->evt_inbuf, char, rest_len); + } + else { + /* + * The PDU is larger than the rest, + * talloc_memdup the rest + */ + req->inbuf = talloc_move(req, &cli->evt_inbuf); + + cli->evt_inbuf = (char *)talloc_memdup( + cli, req->inbuf + raw_pdu_len, + rest_len); + } + + if ((req->inbuf == NULL) || (cli->evt_inbuf == NULL)) { + status = NT_STATUS_NO_MEMORY; + goto invalidate_requests; + } + + done: + async_req_done(req->async); + return; + + invalidate_requests: + + DEBUG(10, ("handle_incoming_pdu: Aborting with %s\n", + nt_errstr(status))); + + for (req = cli->outstanding_requests; req; req = req->next) { + async_req_error(req->async, status); + } + return; +} + +/* + * fd event callback. This is the basic connection to the socket + */ + +static void cli_state_handler(struct event_context *event_ctx, + struct fd_event *event, uint16 flags, void *p) +{ + struct cli_state *cli = (struct cli_state *)p; + struct cli_request *req; + + DEBUG(11, ("cli_state_handler called with flags %d\n", flags)); + + if (flags & EVENT_FD_READ) { + int res, available; + size_t old_size, new_size; + char *tmp; + + res = ioctl(cli->fd, FIONREAD, &available); + if (res == -1) { + DEBUG(10, ("ioctl(FIONREAD) failed: %s\n", + strerror(errno))); + goto sock_error; + } + + if (available == 0) { + /* EOF */ + goto sock_error; + } + + old_size = talloc_get_size(cli->evt_inbuf); + new_size = old_size + available; + + if (new_size < old_size) { + /* wrap */ + goto sock_error; + } + + tmp = TALLOC_REALLOC_ARRAY(cli, cli->evt_inbuf, char, + new_size); + if (tmp == NULL) { + /* nomem */ + goto sock_error; + } + cli->evt_inbuf = tmp; + + res = recv(cli->fd, cli->evt_inbuf + old_size, available, 0); + if (res == -1) { + DEBUG(10, ("recv failed: %s\n", strerror(errno))); + goto sock_error; + } + + DEBUG(11, ("cli_state_handler: received %d bytes, " + "smb_len(evt_inbuf) = %d\n", (int)res, + smb_len(cli->evt_inbuf))); + + /* recv *might* have returned less than announced */ + new_size = old_size + res; + + /* shrink, so I don't expect errors here */ + cli->evt_inbuf = TALLOC_REALLOC_ARRAY(cli, cli->evt_inbuf, + char, new_size); + + while ((cli->evt_inbuf != NULL) + && ((smb_len(cli->evt_inbuf) + 4) <= new_size)) { + /* + * we've got a complete NBT level PDU in evt_inbuf + */ + handle_incoming_pdu(cli); + new_size = talloc_get_size(cli->evt_inbuf); + } + } + + if (flags & EVENT_FD_WRITE) { + size_t to_send; + ssize_t sent; + + for (req = cli->outstanding_requests; req; req = req->next) { + to_send = smb_len(req->outbuf)+4; + if (to_send > req->sent) { + break; + } + } + + if (req == NULL) { + event_fd_set_not_writeable(event); + return; + } + + sent = send(cli->fd, req->outbuf + req->sent, + to_send - req->sent, 0); + + if (sent < 0) { + goto sock_error; + } + + req->sent += sent; + + if (req->sent == to_send) { + return; + } + } + return; + + sock_error: + for (req = cli->outstanding_requests; req; req = req->next) { + req->async->state = ASYNC_REQ_ERROR; + req->async->status = map_nt_error_from_unix(errno); + } + TALLOC_FREE(cli->fd_event); + close(cli->fd); + cli->fd = -1; +} + +/* + * Holder for a talloc_destructor, we need to zero out the pointers in cli + * when deleting + */ +struct cli_tmp_event { + struct cli_state *cli; +}; + +static int cli_tmp_event_destructor(struct cli_tmp_event *e) +{ + TALLOC_FREE(e->cli->fd_event); + TALLOC_FREE(e->cli->event_ctx); + return 0; +} + +/* + * Create a temporary event context for use in the sync helper functions + */ + +struct cli_tmp_event *cli_tmp_event_ctx(TALLOC_CTX *mem_ctx, + struct cli_state *cli) +{ + struct cli_tmp_event *state; + + if (cli->event_ctx != NULL) { + return NULL; + } + + state = talloc(mem_ctx, struct cli_tmp_event); + if (state == NULL) { + return NULL; + } + state->cli = cli; + talloc_set_destructor(state, cli_tmp_event_destructor); + + cli->event_ctx = event_context_init(state); + if (cli->event_ctx == NULL) { + TALLOC_FREE(state); + return NULL; + } + + cli->fd_event = event_add_fd(cli->event_ctx, state, cli->fd, + EVENT_FD_READ, cli_state_handler, cli); + if (cli->fd_event == NULL) { + TALLOC_FREE(state); + return NULL; + } + return state; +} + +/* + * Attach an event context permanently to a cli_struct + */ + +NTSTATUS cli_add_event_ctx(struct cli_state *cli, + struct event_context *event_ctx) +{ + cli->event_ctx = event_ctx; + cli->fd_event = event_add_fd(event_ctx, cli, cli->fd, EVENT_FD_READ, + cli_state_handler, cli); + if (cli->fd_event == NULL) { + return NT_STATUS_NO_MEMORY; + } + return NT_STATUS_OK; +} -- cgit From 525aac775ecef275dbd0732830a9bac0fd023135 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 28 Feb 2008 15:21:33 +0100 Subject: Add async cli_pull support This is the big (and potentially controversial) one. It took a phone call to explain to metze what is going on inside cli_pull_read_done, but I would really like everybody to understand this function. It is a very good and reasonably complex example of async programming. If we want more asynchronism in s3, this is what we will have to deal with :-) Make use of it in the smbclient "get" command. Volker (This used to be commit 844a163458c7585e4306a21ffdae5d08e03d6e4d) --- source3/client/client.c | 42 ++--- source3/libsmb/clireadwrite.c | 425 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 440 insertions(+), 27 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index f7ed33ad8a..1410fc2f33 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -964,12 +964,20 @@ static int cmd_echo(void) Get a file from rname to lname ****************************************************************************/ +static NTSTATUS writefile_sink(char *buf, size_t n, void *priv) +{ + int *pfd = (int *)priv; + if (writefile(*pfd, buf, n) == -1) { + return map_nt_error_from_unix(errno); + } + return NT_STATUS_OK; +} + static int do_get(const char *rname, const char *lname_in, bool reget) { TALLOC_CTX *ctx = talloc_tos(); int handle = 0, fnum; bool newhandle = false; - char *data = NULL; struct timeval tp_start; int read_size = io_bufsize; uint16 attr; @@ -980,6 +988,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget) struct cli_state *targetcli = NULL; char *targetname = NULL; char *lname = NULL; + NTSTATUS status; lname = talloc_strdup(ctx, lname_in); if (!lname) { @@ -1038,36 +1047,15 @@ static int do_get(const char *rname, const char *lname_in, bool reget) DEBUG(1,("getting file %s of size %.0f as %s ", rname, (double)size, lname)); - if(!(data = (char *)SMB_MALLOC(read_size))) { - d_printf("malloc fail for size %d\n", read_size); + status = cli_pull(targetcli, fnum, start, size, 1024*1024, + writefile_sink, (void *)&handle, &nread); + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "parallel_read returned %s\n", + nt_errstr(status)); cli_close(targetcli, fnum); return 1; } - while (1) { - int n = cli_read(targetcli, fnum, data, nread + start, read_size); - - if (n <= 0) - break; - - if (writefile(handle,data, n) != n) { - d_printf("Error writing local file\n"); - rc = 1; - break; - } - - nread += n; - } - - if (nread + start < size) { - DEBUG (0, ("Short read when getting file %s. Only got %ld bytes.\n", - rname, (long)nread)); - - rc = 1; - } - - SAFE_FREE(data); - if (!cli_close(targetcli, fnum)) { d_printf("Error %s closing remote file\n",cli_errstr(cli)); rc = 1; diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index af13ed8f73..5aee8f18bd 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -19,6 +19,431 @@ #include "includes.h" +/**************************************************************************** + Calculate the recommended read buffer size +****************************************************************************/ +static size_t cli_read_max_bufsize(struct cli_state *cli) +{ + if (!client_is_signing_on(cli) && !cli_encryption_on(cli) == false + && (cli->posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) { + return CLI_SAMBA_MAX_POSIX_LARGE_READX_SIZE; + } + if (cli->capabilities & CAP_LARGE_READX) { + return cli->is_samba + ? CLI_SAMBA_MAX_LARGE_READX_SIZE + : CLI_WINDOWS_MAX_LARGE_READX_SIZE; + } + return (cli->max_xmit - (smb_size+32)) & ~1023; +} + +/* + * Send a read&x request + */ + +struct async_req *cli_read_andx_send(TALLOC_CTX *mem_ctx, + struct cli_state *cli, int fnum, + off_t offset, size_t size) +{ + struct async_req *result; + struct cli_request *req; + bool bigoffset = False; + char *enc_buf; + + if (size > cli_read_max_bufsize(cli)) { + DEBUG(0, ("cli_read_andx_send got size=%d, can only handle " + "size=%d\n", (int)size, + (int)cli_read_max_bufsize(cli))); + return NULL; + } + + result = cli_request_new(mem_ctx, cli->event_ctx, cli, 12, 0, &req); + if (result == NULL) { + DEBUG(0, ("cli_request_new failed\n")); + return NULL; + } + + req = cli_request_get(result); + + req->data.read.ofs = offset; + req->data.read.size = size; + req->data.read.received = 0; + req->data.read.rcvbuf = NULL; + + if ((SMB_BIG_UINT)offset >> 32) + bigoffset = True; + + cli_set_message(req->outbuf, bigoffset ? 12 : 10, 0, False); + + SCVAL(req->outbuf,smb_com,SMBreadX); + SSVAL(req->outbuf,smb_tid,cli->cnum); + cli_setup_packet_buf(cli, req->outbuf); + + SCVAL(req->outbuf,smb_vwv0,0xFF); + SCVAL(req->outbuf,smb_vwv0+1,0); + SSVAL(req->outbuf,smb_vwv1,0); + SSVAL(req->outbuf,smb_vwv2,fnum); + SIVAL(req->outbuf,smb_vwv3,offset); + SSVAL(req->outbuf,smb_vwv5,size); + SSVAL(req->outbuf,smb_vwv6,size); + SSVAL(req->outbuf,smb_vwv7,(size >> 16)); + SSVAL(req->outbuf,smb_vwv8,0); + SSVAL(req->outbuf,smb_vwv9,0); + SSVAL(req->outbuf,smb_mid,req->mid); + + if (bigoffset) { + SIVAL(req->outbuf, smb_vwv10, + (((SMB_BIG_UINT)offset)>>32) & 0xffffffff); + } + + cli_calculate_sign_mac(cli, req->outbuf); + + event_fd_set_writeable(cli->fd_event); + + if (cli_encryption_on(cli)) { + NTSTATUS status; + status = cli_encrypt_message(cli, req->outbuf, &enc_buf); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Error in encrypting client message. " + "Error %s\n", nt_errstr(status))); + TALLOC_FREE(req); + return NULL; + } + req->outbuf = enc_buf; + req->enc_state = cli->trans_enc_state; + } + + return result; +} + +/* + * Pull the data out of a finished async read_and_x request. rcvbuf is + * talloced from the request, so better make sure that you copy it away before + * you talloc_free(req). "rcvbuf" is NOT a talloc_ctx of its own, so do not + * talloc_move it! + */ + +NTSTATUS cli_read_andx_recv(struct async_req *req, ssize_t *received, + uint8_t **rcvbuf) +{ + struct cli_request *cli_req = cli_request_get(req); + NTSTATUS status; + size_t size; + + SMB_ASSERT(req->state >= ASYNC_REQ_DONE); + if (req->state == ASYNC_REQ_ERROR) { + return req->status; + } + + status = cli_pull_error(cli_req->inbuf); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + /* size is the number of bytes the server returned. + * Might be zero. */ + size = SVAL(cli_req->inbuf, smb_vwv5); + size |= (((unsigned int)(SVAL(cli_req->inbuf, smb_vwv7))) << 16); + + if (size > cli_req->data.read.size) { + DEBUG(5,("server returned more than we wanted!\n")); + return NT_STATUS_UNEXPECTED_IO_ERROR; + } + + if (size < 0) { + DEBUG(5,("read return < 0!\n")); + return NT_STATUS_UNEXPECTED_IO_ERROR; + } + + *rcvbuf = (uint8_t *) + (smb_base(cli_req->inbuf) + SVAL(cli_req->inbuf, smb_vwv6)); + *received = size; + return NT_STATUS_OK; +} + +/* + * Parallel read support. + * + * cli_pull sends as many read&x requests as the server would allow via + * max_mux at a time. When replies flow back in, the data is written into + * the callback function "sink" in the right order. + */ + +struct cli_pull_state { + struct async_req *req; + + struct cli_state *cli; + uint16_t fnum; + off_t start_offset; + size_t size; + + NTSTATUS (*sink)(char *buf, size_t n, void *priv); + void *priv; + + size_t chunk_size; + + /* + * Outstanding requests + */ + int num_reqs; + struct async_req **reqs; + + /* + * For how many bytes did we send requests already? + */ + off_t requested; + + /* + * Next request index to push into "sink". This walks around the "req" + * array, taking care that the requests are pushed to "sink" in the + * right order. If necessary (i.e. replies don't come in in the right + * order), replies are held back in "reqs". + */ + int top_req; + + /* + * How many bytes did we push into "sink"? + */ + + off_t pushed; +}; + +static char *cli_pull_print(TALLOC_CTX *mem_ctx, struct async_req *req) +{ + struct cli_pull_state *state = talloc_get_type_abort( + req->private_data, struct cli_pull_state); + char *result; + + result = async_req_print(mem_ctx, req); + if (result == NULL) { + return NULL; + } + + return talloc_asprintf_append_buffer( + result, "num_reqs=%d, top_req=%d", + state->num_reqs, state->top_req); +} + +static void cli_pull_read_done(struct async_req *read_req); + +/* + * Prepare an async pull request + */ + +struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx, struct cli_state *cli, + uint16_t fnum, off_t start_offset, + size_t size, size_t window_size, + NTSTATUS (*sink)(char *buf, size_t n, + void *priv), + void *priv) +{ + struct async_req *result; + struct cli_pull_state *state; + int i; + + result = async_req_new(mem_ctx, cli->event_ctx); + if (result == NULL) { + goto failed; + } + state = talloc(result, struct cli_pull_state); + if (state == NULL) { + goto failed; + } + result->private_data = state; + result->print = cli_pull_print; + state->req = result; + + state->cli = cli; + state->fnum = fnum; + state->start_offset = start_offset; + state->size = size; + state->sink = sink; + state->priv = priv; + + state->pushed = 0; + state->top_req = 0; + state->chunk_size = cli_read_max_bufsize(cli); + + state->num_reqs = MAX(window_size/state->chunk_size, 1); + state->num_reqs = MIN(state->num_reqs, cli->max_mux); + + state->reqs = TALLOC_ZERO_ARRAY(state, struct async_req *, + state->num_reqs); + if (state->reqs == NULL) { + goto failed; + } + + state->requested = 0; + + for (i=0; inum_reqs; i++) { + size_t size_left, request_thistime; + + if (state->requested >= size) { + state->num_reqs = i; + break; + } + + size_left = size - state->requested; + request_thistime = MIN(size_left, state->chunk_size); + + state->reqs[i] = cli_read_andx_send( + state->reqs, cli, fnum, + state->start_offset + state->requested, + request_thistime); + + if (state->reqs[i] == NULL) { + goto failed; + } + + state->reqs[i]->async.fn = cli_pull_read_done; + state->reqs[i]->async.priv = result; + + state->requested += request_thistime; + } + return result; + +failed: + TALLOC_FREE(result); + return NULL; +} + +/* + * Handle incoming read replies, push the data into sink and send out new + * requests if necessary. + */ + +static void cli_pull_read_done(struct async_req *read_req) +{ + struct async_req *pull_req = talloc_get_type_abort( + read_req->async.priv, struct async_req); + struct cli_pull_state *state = talloc_get_type_abort( + pull_req->private_data, struct cli_pull_state); + struct cli_request *read_state = cli_request_get(read_req); + NTSTATUS status; + + status = cli_read_andx_recv(read_req, &read_state->data.read.received, + &read_state->data.read.rcvbuf); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(state->req, status); + return; + } + + /* + * This loop is the one to take care of out-of-order replies. All + * pending requests are in state->reqs, state->reqs[top_req] is the + * one that is to be pushed next. If however a request later than + * top_req is replied to, then we can't push yet. If top_req is + * replied to at a later point then, we need to push all the finished + * requests. + */ + + while (state->reqs[state->top_req] != NULL) { + struct cli_request *top_read; + + DEBUG(11, ("cli_pull_read_done: top_req = %d\n", + state->top_req)); + + if (state->reqs[state->top_req]->state < ASYNC_REQ_DONE) { + DEBUG(11, ("cli_pull_read_done: top request not yet " + "done\n")); + return; + } + + top_read = cli_request_get(state->reqs[state->top_req]); + + DEBUG(10, ("cli_pull_read_done: Pushing %d bytes, %d already " + "pushed\n", (int)top_read->data.read.received, + (int)state->pushed)); + + status = state->sink((char *)top_read->data.read.rcvbuf, + top_read->data.read.received, + state->priv); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(state->req, status); + return; + } + state->pushed += top_read->data.read.received; + + TALLOC_FREE(state->reqs[state->top_req]); + + if (state->requested < state->size) { + struct async_req *new_req; + size_t size_left, request_thistime; + + size_left = state->size - state->requested; + request_thistime = MIN(size_left, state->chunk_size); + + DEBUG(10, ("cli_pull_read_done: Requesting %d bytes " + "at %d, position %d\n", + (int)request_thistime, + (int)(state->start_offset + + state->requested), + state->top_req)); + + new_req = cli_read_andx_send( + state->reqs, state->cli, state->fnum, + state->start_offset + state->requested, + request_thistime); + + if (async_req_nomem(new_req, state->req)) { + return; + } + + new_req->async.fn = cli_pull_read_done; + new_req->async.priv = pull_req; + + state->reqs[state->top_req] = new_req; + state->requested += request_thistime; + } + + state->top_req = (state->top_req+1) % state->num_reqs; + } + + async_req_done(pull_req); +} + +NTSTATUS cli_pull_recv(struct async_req *req, ssize_t *received) +{ + struct cli_pull_state *state = talloc_get_type_abort( + req->private_data, struct cli_pull_state); + + SMB_ASSERT(req->state >= ASYNC_REQ_DONE); + if (req->state == ASYNC_REQ_ERROR) { + return req->status; + } + *received = state->pushed; + return NT_STATUS_OK; +} + +NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum, + off_t start_offset, size_t size, size_t window_size, + NTSTATUS (*sink)(char *buf, size_t n, void *priv), + void *priv, ssize_t *received) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct async_req *req; + NTSTATUS result = NT_STATUS_NO_MEMORY; + + if (cli_tmp_event_ctx(frame, cli) == NULL) { + goto nomem; + } + + req = cli_pull_send(frame, cli, fnum, start_offset, size, window_size, + sink, priv); + if (req == NULL) { + goto nomem; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(cli->event_ctx); + } + + result = cli_pull_recv(req, received); + nomem: + TALLOC_FREE(frame); + return result; +} + /**************************************************************************** Issue a single SMBread and don't wait for a reply. ****************************************************************************/ -- cgit From 95222d115a1ab676ecebdaa30d627608afb9758f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 28 Feb 2008 15:26:01 +0100 Subject: Convert cli_read to use cli_pull (This used to be commit 719527f55e88f0c5fdceda5c807475aba299c79f) --- source3/libsmb/clireadwrite.c | 178 ++++-------------------------------------- 1 file changed, 15 insertions(+), 163 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index 5aee8f18bd..c618509f01 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -444,175 +444,27 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum, return result; } -/**************************************************************************** -Issue a single SMBread and don't wait for a reply. -****************************************************************************/ - -static bool cli_issue_read(struct cli_state *cli, int fnum, off_t offset, - size_t size, int i) +static NTSTATUS cli_read_sink(char *buf, size_t n, void *priv) { - bool bigoffset = False; - - memset(cli->outbuf,'\0',smb_size); - memset(cli->inbuf,'\0',smb_size); - - if ((SMB_BIG_UINT)offset >> 32) - bigoffset = True; - - cli_set_message(cli->outbuf,bigoffset ? 12 : 10,0,True); - - SCVAL(cli->outbuf,smb_com,SMBreadX); - SSVAL(cli->outbuf,smb_tid,cli->cnum); - cli_setup_packet(cli); - - SCVAL(cli->outbuf,smb_vwv0,0xFF); - SSVAL(cli->outbuf,smb_vwv2,fnum); - SIVAL(cli->outbuf,smb_vwv3,offset); - SSVAL(cli->outbuf,smb_vwv5,size); - SSVAL(cli->outbuf,smb_vwv6,size); - SSVAL(cli->outbuf,smb_vwv7,(size >> 16)); - SSVAL(cli->outbuf,smb_mid,cli->mid + i); - - if (bigoffset) { - SIVAL(cli->outbuf,smb_vwv10,(((SMB_BIG_UINT)offset)>>32) & 0xffffffff); - } - - return cli_send_smb(cli); + char **pbuf = (char **)priv; + memcpy(*pbuf, buf, n); + *pbuf += n; + return NT_STATUS_OK; } -/**************************************************************************** - Read size bytes at offset offset using SMBreadX. -****************************************************************************/ - -ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size) +ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, + off_t offset, size_t size) { - char *p; - size_t size2; - size_t readsize; - ssize_t total = 0; - /* We can only do direct reads if not signing or encrypting. */ - bool direct_reads = !client_is_signing_on(cli) && !cli_encryption_on(cli); - - if (size == 0) - return 0; - - /* - * Set readsize to the maximum size we can handle in one readX, - * rounded down to a multiple of 1024. - */ - - if (client_is_signing_on(cli) == false && - cli_encryption_on(cli) == false && - (cli->posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) { - readsize = CLI_SAMBA_MAX_POSIX_LARGE_READX_SIZE; - } else if (cli->capabilities & CAP_LARGE_READX) { - if (cli->is_samba) { - readsize = CLI_SAMBA_MAX_LARGE_READX_SIZE; - } else { - readsize = CLI_WINDOWS_MAX_LARGE_READX_SIZE; - } - } else { - readsize = (cli->max_xmit - (smb_size+32)) & ~1023; - } - - while (total < size) { - readsize = MIN(readsize, size-total); - - /* Issue a read and receive a reply */ - - if (!cli_issue_read(cli, fnum, offset, readsize, 0)) - return -1; - - if (direct_reads) { - if (!cli_receive_smb_readX_header(cli)) - return -1; - } else { - if (!cli_receive_smb(cli)) - return -1; - } - - /* Check for error. Make sure to check for DOS and NT - errors. */ - - if (cli_is_error(cli)) { - bool recoverable_error = False; - NTSTATUS status = NT_STATUS_OK; - uint8 eclass = 0; - uint32 ecode = 0; - - if (cli_is_nt_error(cli)) - status = cli_nt_error(cli); - else - cli_dos_error(cli, &eclass, &ecode); - - /* - * ERRDOS ERRmoredata or STATUS_MORE_ENRTIES is a - * recoverable error, plus we have valid data in the - * packet so don't error out here. - */ - - if ((eclass == ERRDOS && ecode == ERRmoredata) || - NT_STATUS_V(status) == NT_STATUS_V(STATUS_MORE_ENTRIES)) - recoverable_error = True; - - if (!recoverable_error) - return -1; - } - - /* size2 is the number of bytes the server returned. - * Might be zero. */ - size2 = SVAL(cli->inbuf, smb_vwv5); - size2 |= (((unsigned int)(SVAL(cli->inbuf, smb_vwv7))) << 16); - - if (size2 > readsize) { - DEBUG(5,("server returned more than we wanted!\n")); - return -1; - } else if (size2 < 0) { - DEBUG(5,("read return < 0!\n")); - return -1; - } - - if (size2) { - /* smb_vwv6 is the offset in the packet of the returned - * data bytes. Only valid if size2 != 0. */ - - if (!direct_reads) { - /* Copy data into buffer */ - p = smb_base(cli->inbuf) + SVAL(cli->inbuf,smb_vwv6); - memcpy(buf + total, p, size2); - } else { - /* Ensure the remaining data matches the return size. */ - ssize_t toread = smb_len_large(cli->inbuf) - SVAL(cli->inbuf,smb_vwv6); - - /* Ensure the size is correct. */ - if (toread != size2) { - DEBUG(5,("direct read logic fail toread (%d) != size2 (%u)\n", - (int)toread, (unsigned int)size2 )); - return -1; - } - - /* Read data directly into buffer */ - toread = cli_receive_smb_data(cli,buf+total,size2); - if (toread != size2) { - DEBUG(5,("direct read read failure toread (%d) != size2 (%u)\n", - (int)toread, (unsigned int)size2 )); - return -1; - } - } - } - - total += size2; - offset += size2; - - /* - * If the server returned less than we asked for we're at EOF. - */ + NTSTATUS status; + ssize_t ret; - if (size2 < readsize) - break; + status = cli_pull(cli, fnum, offset, size, size, + cli_read_sink, &buf, &ret); + if (!NT_STATUS_IS_OK(status)) { + cli_set_error(cli, status); + return -1; } - - return total; + return ret; } #if 0 /* relies on client_receive_smb(), now a static in libsmb/clientgen.c */ -- cgit From e1b32594c70ee57f16c84adb7910aa5c84a560f8 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Thu, 28 Feb 2008 15:49:57 +0100 Subject: Remove smbmount. Karolin (This used to be commit 5fbd98f7065268ae134108310119078ad8f62322) --- source3/Makefile.in | 25 +- source3/client/smbmnt.c | 332 ------------ source3/client/smbmount.c | 1047 ------------------------------------- source3/client/smbumount.c | 196 ------- source3/configure.in | 26 - source3/include/smb_macros.h | 5 +- source3/script/installbin.sh.in | 9 - source3/script/installman.sh | 1 - source3/script/uninstallbin.sh.in | 6 - 9 files changed, 4 insertions(+), 1643 deletions(-) delete mode 100644 source3/client/smbmnt.c delete mode 100644 source3/client/smbmount.c delete mode 100644 source3/client/smbumount.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index e0068ba5cb..d20cea2d16 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -208,7 +208,7 @@ TORTURE_PROGS = bin/smbtorture@EXEEXT@ bin/msgtest@EXEEXT@ \ bin/pdbtest@EXEEXT@ bin/talloctort@EXEEXT@ bin/replacetort@EXEEXT@ \ bin/tdbtorture@EXEEXT@ -BIN_PROGS = @EXTRA_BIN_PROGS@ @SMBMOUNT_PROGS@ \ +BIN_PROGS = @EXTRA_BIN_PROGS@ \ $(BIN_PROGS1) $(BIN_PROGS2) $(BIN_PROGS3) $(BIN_PROGS4) EVERYTHING_PROGS = bin/debug2html@EXEEXT@ bin/smbfilter@EXEEXT@ \ @@ -831,14 +831,6 @@ NET_OBJ = $(NET_OBJ1) $(PARAM_WITHOUT_REG_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(SECRETS_OBJ) $(POPT_LIB_OBJ) -MOUNT_OBJ = client/smbmount.o \ - $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ) - -MNT_OBJ = client/smbmnt.o $(VERSION_OBJ) $(LIBREPLACE_OBJ) $(SOCKET_WRAPPER_OBJ) - -UMOUNT_OBJ = client/smbumount.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ - $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ) - CIFS_MOUNT_OBJ = client/mount.cifs.o CIFS_UMOUNT_OBJ = client/umount.cifs.o @@ -1294,18 +1286,6 @@ bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbmount@EXEEXT@: $(BINARY_PREREQS) $(MOUNT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ - @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ - -bin/smbmnt@EXEEXT@: $(BINARY_PREREQS) $(MNT_OBJ) @BUILD_POPT@ - @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MNT_OBJ) $(DYNEXP) $(LDFLAGS) @POPTLIBS@ - -bin/smbumount@EXEEXT@: $(BINARY_PREREQS) $(UMOUNT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ - @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ - bin/mount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_MOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CIFS_MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) @POPTLIBS@ @@ -2051,8 +2031,7 @@ revert: @$(SHELL) $(srcdir)/script/revert.sh $(BINDIR) $(BIN_PROGS) $(SCRIPTS) installman: installdirs - @SMBMOUNT_PROGS="@SMBMOUNT_PROGS@" $(SHELL) \ - $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(srcdir) C "@ROFF@" + @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(srcdir) C "@ROFF@" .PHONY: showlayout diff --git a/source3/client/smbmnt.c b/source3/client/smbmnt.c deleted file mode 100644 index 3d7de1b3c0..0000000000 --- a/source3/client/smbmnt.c +++ /dev/null @@ -1,332 +0,0 @@ -/* - * smbmnt.c - * - * Copyright (C) 1995-1998 by Paal-Kr. Engstad and Volker Lendecke - * extensively modified by Tridge - * - * 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 . - * - */ - -#define SMBMOUNT_MALLOC 1 - -#include "includes.h" - -#include -#include - -#include -#include -#include -#include -#include - -#ifndef MS_MGC_VAL -/* This may look strange but MS_MGC_VAL is what we are looking for and - is what we need from under libc systems and is - provided in standard includes on glibc systems. So... We - switch on what we need... */ -#include -#endif - -static uid_t mount_uid; -static gid_t mount_gid; -static int mount_ro; -static unsigned mount_fmask; -static unsigned mount_dmask; -static int user_mount; -static char *options; - -static void -help(void) -{ - printf("\n"); - printf("Usage: smbmnt mount-point [options]\n"); - printf("Version %s\n\n",SAMBA_VERSION_STRING); - printf("-s share share name on server\n" - "-r mount read-only\n" - "-u uid mount as uid\n" - "-g gid mount as gid\n" - "-f mask permission mask for files\n" - "-d mask permission mask for directories\n" - "-o options name=value, list of options\n" - "-h print this help text\n"); -} - -static int -parse_args(int argc, char *argv[], struct smb_mount_data *data, char **share) -{ - int opt; - - while ((opt = getopt (argc, argv, "s:u:g:rf:d:o:")) != EOF) - { - switch (opt) - { - case 's': - *share = optarg; - break; - case 'u': - if (!user_mount) { - mount_uid = strtol(optarg, NULL, 0); - } - break; - case 'g': - if (!user_mount) { - mount_gid = strtol(optarg, NULL, 0); - } - break; - case 'r': - mount_ro = 1; - break; - case 'f': - mount_fmask = strtol(optarg, NULL, 8); - break; - case 'd': - mount_dmask = strtol(optarg, NULL, 8); - break; - case 'o': - options = optarg; - break; - default: - return -1; - } - } - return 0; - -} - -static char * -fullpath(const char *p) -{ - char path[PATH_MAX+1]; - - if (strlen(p) > PATH_MAX) { - return NULL; - } - - if (realpath(p, path) == NULL) { - fprintf(stderr,"Failed to find real path for mount point %s: %s\n", - p, strerror(errno)); - exit(1); - } - return strdup(path); -} - -/* Check whether user is allowed to mount on the specified mount point. If it's - OK then we change into that directory - this prevents race conditions */ -static int mount_ok(char *mount_point) -{ - struct stat st; - - if (chdir(mount_point) != 0) { - return -1; - } - - if (stat(".", &st) != 0) { - return -1; - } - - if (!S_ISDIR(st.st_mode)) { - errno = ENOTDIR; - return -1; - } - - if ((getuid() != 0) && - ((getuid() != st.st_uid) || - ((st.st_mode & S_IRWXU) != S_IRWXU))) { - errno = EPERM; - return -1; - } - - return 0; -} - -/* Tries to mount using the appropriate format. For 2.2 the struct, - for 2.4 the ascii version. */ -static int -do_mount(char *share_name, unsigned int flags, struct smb_mount_data *data) -{ - char *opts; - struct utsname uts; - char *release, *major, *minor; - char *data1, *data2; - int ret; - char *saveptr = NULL; - - if (asprintf(&opts, - "version=7,uid=%d,gid=%d,file_mode=0%o,dir_mode=0%o,%s", - mount_uid, mount_gid, data->file_mode, - data->dir_mode,options) < 0) { - return -1; - } - - uname(&uts); - release = uts.release; - major = strtok_r(release, ".", &saveptr); - minor = strtok_r(NULL, ".", &saveptr); - if (major && minor && atoi(major) == 2 && atoi(minor) < 4) { - /* < 2.4, assume struct */ - data1 = (char *) data; - data2 = opts; - } else { - /* >= 2.4, assume ascii but fall back on struct */ - data1 = opts; - data2 = (char *) data; - } - - if (mount(share_name, ".", "smbfs", flags, data1) == 0) { - SAFE_FREE(opts); - return 0; - } - ret = mount(share_name, ".", "smbfs", flags, data2); - SAFE_FREE(opts); - return ret; -} - - int main(int argc, char *argv[]) -{ - char *mount_point, *share_name = NULL; - FILE *mtab; - int fd; - unsigned int flags; - struct smb_mount_data data; - struct mntent ment; - - memset(&data, 0, sizeof(struct smb_mount_data)); - - if (argc < 2) { - help(); - exit(1); - } - - if (argv[1][0] == '-') { - help(); - exit(1); - } - - if (getuid() != 0) { - user_mount = 1; - } - - if (geteuid() != 0) { - fprintf(stderr, "smbmnt must be installed suid root for direct user mounts (%d,%d)\n", getuid(), geteuid()); - exit(1); - } - - mount_uid = getuid(); - mount_gid = getgid(); - mount_fmask = umask(0); - umask(mount_fmask); - mount_fmask = ~mount_fmask; - - mount_point = fullpath(argv[1]); - - argv += 1; - argc -= 1; - - if (mount_ok(mount_point) != 0) { - fprintf(stderr, "cannot mount on %s: %s\n", - mount_point, strerror(errno)); - exit(1); - } - - data.version = SMB_MOUNT_VERSION; - - /* getuid() gives us the real uid, who may umount the fs */ - data.mounted_uid = getuid(); - - if (parse_args(argc, argv, &data, &share_name) != 0) { - help(); - return -1; - } - - data.uid = mount_uid; /* truncates to 16-bits here!!! */ - data.gid = mount_gid; - data.file_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & mount_fmask; - data.dir_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & mount_dmask; - - if (mount_dmask == 0) { - data.dir_mode = data.file_mode; - if ((data.dir_mode & S_IRUSR) != 0) - data.dir_mode |= S_IXUSR; - if ((data.dir_mode & S_IRGRP) != 0) - data.dir_mode |= S_IXGRP; - if ((data.dir_mode & S_IROTH) != 0) - data.dir_mode |= S_IXOTH; - } - - flags = MS_MGC_VAL | MS_NOSUID | MS_NODEV; - - if (mount_ro) flags |= MS_RDONLY; - - if (do_mount(share_name, flags, &data) < 0) { - switch (errno) { - case ENODEV: - fprintf(stderr, "ERROR: smbfs filesystem not supported by the kernel\n"); - break; - default: - perror("mount error"); - } - fprintf(stderr, "Please refer to the smbmnt(8) manual page\n"); - return -1; - } - - ment.mnt_fsname = share_name ? share_name : (char *)"none"; - ment.mnt_dir = mount_point; - ment.mnt_type = (char *)"smbfs"; - ment.mnt_opts = (char *)""; - ment.mnt_freq = 0; - ment.mnt_passno= 0; - - mount_point = ment.mnt_dir; - - if (mount_point == NULL) - { - fprintf(stderr, "Mount point too long\n"); - return -1; - } - - if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1) - { - fprintf(stderr, "Can't get "MOUNTED"~ lock file"); - return 1; - } - close(fd); - - if ((mtab = setmntent(MOUNTED, "a+")) == NULL) - { - fprintf(stderr, "Can't open " MOUNTED); - return 1; - } - - if (addmntent(mtab, &ment) == 1) - { - fprintf(stderr, "Can't write mount entry"); - return 1; - } - if (fchmod(fileno(mtab), 0644) == -1) - { - fprintf(stderr, "Can't set perms on "MOUNTED); - return 1; - } - endmntent(mtab); - - if (unlink(MOUNTED"~") == -1) - { - fprintf(stderr, "Can't remove "MOUNTED"~"); - return 1; - } - - return 0; -} diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c deleted file mode 100644 index ee4b180a89..0000000000 --- a/source3/client/smbmount.c +++ /dev/null @@ -1,1047 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMBFS mount program - Copyright (C) Andrew Tridgell 1999 - - 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 "includes.h" - -#include -#include -#include - -extern bool in_client; -extern char *optarg; -extern int optind; - -static char *credentials; -static fstring my_netbios_name; -static char *password; -static char *username; -static fstring workgroup; -static char *mpoint; -static char *service; -static char *options; - -static struct sockaddr_storage dest_ip; -static bool have_ip; -static int smb_port = 0; -static bool got_user; -static bool got_pass; -static uid_t mount_uid; -static gid_t mount_gid; -static int mount_ro; -static unsigned mount_fmask; -static unsigned mount_dmask; -static bool use_kerberos; -/* TODO: Add code to detect smbfs version in kernel */ -static bool status32_smbfs = False; -static bool smbfs_has_unicode = False; -static bool smbfs_has_lfs = False; - -static void usage(void); - -static void exit_parent(int sig) -{ - /* parent simply exits when child says go... */ - exit(0); -} - -static void daemonize(void) -{ - int j, status; - pid_t child_pid; - - signal( SIGTERM, exit_parent ); - - if ((child_pid = sys_fork()) < 0) { - DEBUG(0,("could not fork\n")); - } - - if (child_pid > 0) { - while( 1 ) { - j = waitpid( child_pid, &status, 0 ); - if( j < 0 ) { - if( EINTR == errno ) { - continue; - } - status = errno; - } - break; - } - - /* If we get here - the child exited with some error status */ - if (WIFSIGNALED(status)) - exit(128 + WTERMSIG(status)); - else - exit(WEXITSTATUS(status)); - } - - signal( SIGTERM, SIG_DFL ); - chdir("/"); -} - -static void close_our_files(int client_fd) -{ - int i; - struct rlimit limits; - - getrlimit(RLIMIT_NOFILE,&limits); - for (i = 0; i< limits.rlim_max; i++) { - if (i == client_fd) - continue; - close(i); - } -} - -static void usr1_handler(int x) -{ - return; -} - - -/***************************************************** -return a connection to a server -*******************************************************/ -static struct cli_state *do_connection(char *the_service) -{ - struct cli_state *c; - struct nmb_name called, calling; - char *server_n; - struct sockaddr_storage ip; - char *server; - char *share; - const char *c_username; - const char *c_password; - TALLOC_CTX *ctx = talloc_tos(); - - if (the_service[0] != '\\' || the_service[1] != '\\') { - usage(); - exit(1); - } - - server = talloc_strdup(ctx, the_service+2); - if (!server) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - share = strchr_m(server,'\\'); - if (!share) { - usage(); - exit(1); - } - *share = 0; - share++; - - server_n = server; - - make_nmb_name(&calling, my_netbios_name, 0x0); - make_nmb_name(&called , server, 0x20); - - again: - zero_addr(&ip); - if (have_ip) ip = dest_ip; - - /* have to open a new connection */ - if (!(c=cli_initialise()) || (cli_set_port(c, smb_port) != smb_port) || - !NT_STATUS_IS_OK(cli_connect(c, server_n, &ip))) { - DEBUG(0,("%d: Connection to %s failed\n", sys_getpid(), server_n)); - if (c) { - cli_shutdown(c); - } - return NULL; - } - - /* SPNEGO doesn't work till we get NTSTATUS error support */ - /* But it is REQUIRED for kerberos authentication */ - if(!use_kerberos) c->use_spnego = False; - - /* The kernel doesn't yet know how to sign it's packets */ - c->sign_info.allow_smb_signing = False; - - /* Use kerberos authentication if specified */ - c->use_kerberos = use_kerberos; - - if (!cli_session_request(c, &calling, &called)) { - char *p; - DEBUG(0,("%d: session request to %s failed (%s)\n", - sys_getpid(), called.name, cli_errstr(c))); - cli_shutdown(c); - if ((p=strchr_m(called.name, '.'))) { - *p = 0; - goto again; - } - if (strcmp(called.name, "*SMBSERVER")) { - make_nmb_name(&called , "*SMBSERVER", 0x20); - goto again; - } - return NULL; - } - - DEBUG(4,("%d: session request ok\n", sys_getpid())); - - if (!cli_negprot(c)) { - DEBUG(0,("%d: protocol negotiation failed\n", sys_getpid())); - cli_shutdown(c); - return NULL; - } - - if (!got_pass) { - char *pass = getpass("Password: "); - if (pass) { - password = talloc_strdup(talloc_tos(), pass); - if (!password) { - return NULL; - } - } - } - - /* This should be right for current smbfs. Future versions will support - large files as well as unicode and oplocks. */ - c->capabilities &= ~(CAP_NT_SMBS | CAP_NT_FIND | CAP_LEVEL_II_OPLOCKS); - if (!smbfs_has_lfs) - c->capabilities &= ~CAP_LARGE_FILES; - if (!smbfs_has_unicode) - c->capabilities &= ~CAP_UNICODE; - if (!status32_smbfs) { - c->capabilities &= ~CAP_STATUS32; - c->force_dos_errors = True; - } - - c_password = password ? password : ""; - c_username = username ? username : ""; - - if (!NT_STATUS_IS_OK(cli_session_setup(c, - c_username, - c_password, strlen(c_password), - c_password, strlen(c_password), - workgroup))) { - /* if a password was not supplied then try again with a - null username */ - if (c_password[0] || !c_username[0] || - !NT_STATUS_IS_OK(cli_session_setup(c, "", "", 0, "", 0, workgroup))) { - DEBUG(0,("%d: session setup failed: %s\n", - sys_getpid(), cli_errstr(c))); - cli_shutdown(c); - return NULL; - } - DEBUG(0,("Anonymous login successful\n")); - } - - DEBUG(4,("%d: session setup ok\n", sys_getpid())); - - if (!cli_send_tconX(c, share, "?????", - c_password, strlen(c_password)+1)) { - DEBUG(0,("%d: tree connect failed: %s\n", - sys_getpid(), cli_errstr(c))); - cli_shutdown(c); - return NULL; - } - - DEBUG(4,("%d: tconx ok\n", sys_getpid())); - - got_pass = True; - - return c; -} - -/**************************************************************************** -unmount smbfs (this is a bailout routine to clean up if a reconnect fails) - Code blatently stolen from smbumount.c - -mhw- -****************************************************************************/ -static void smb_umount(char *mount_point) -{ - int fd; - struct mntent *mnt; - FILE* mtab; - FILE* new_mtab; - - /* Programmers Note: - This routine only gets called to the scene of a disaster - to shoot the survivors... A connection that was working - has now apparently failed. We have an active mount point - (presumably) that we need to dump. If we get errors along - the way - make some noise, but we are already turning out - the lights to exit anyways... - */ - if (umount(mount_point) != 0) { - DEBUG(0,("%d: Could not umount %s: %s\n", - sys_getpid(), mount_point, strerror(errno))); - return; - } - - if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1) { - DEBUG(0,("%d: Can't get "MOUNTED"~ lock file", sys_getpid())); - return; - } - - close(fd); - - if ((mtab = setmntent(MOUNTED, "r")) == NULL) { - DEBUG(0,("%d: Can't open " MOUNTED ": %s\n", - sys_getpid(), strerror(errno))); - return; - } - -#define MOUNTED_TMP MOUNTED".tmp" - - if ((new_mtab = setmntent(MOUNTED_TMP, "w")) == NULL) { - DEBUG(0,("%d: Can't open " MOUNTED_TMP ": %s\n", - sys_getpid(), strerror(errno))); - endmntent(mtab); - return; - } - - while ((mnt = getmntent(mtab)) != NULL) { - if (strcmp(mnt->mnt_dir, mount_point) != 0) { - addmntent(new_mtab, mnt); - } - } - - endmntent(mtab); - - if (fchmod (fileno (new_mtab), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) { - DEBUG(0,("%d: Error changing mode of %s: %s\n", - sys_getpid(), MOUNTED_TMP, strerror(errno))); - return; - } - - endmntent(new_mtab); - - if (rename(MOUNTED_TMP, MOUNTED) < 0) { - DEBUG(0,("%d: Cannot rename %s to %s: %s\n", - sys_getpid(), MOUNTED, MOUNTED_TMP, strerror(errno))); - return; - } - - if (unlink(MOUNTED"~") == -1) { - DEBUG(0,("%d: Can't remove "MOUNTED"~", sys_getpid())); - return; - } -} - - -/* - * Call the smbfs ioctl to install a connection socket, - * then wait for a signal to reconnect. Note that we do - * not exit after open_sockets() or send_login() errors, - * as the smbfs mount would then have no way to recover. - */ -static void send_fs_socket(char *the_service, char *mount_point, struct cli_state *c) -{ - int fd, closed = 0, res = 1; - pid_t parentpid = getppid(); - struct smb_conn_opt conn_options; - - memset(&conn_options, 0, sizeof(conn_options)); - - while (1) { - if ((fd = open(mount_point, O_RDONLY)) < 0) { - DEBUG(0,("mount.smbfs[%d]: can't open %s\n", - sys_getpid(), mount_point)); - break; - } - - conn_options.fd = c->fd; - conn_options.protocol = c->protocol; - conn_options.case_handling = SMB_CASE_DEFAULT; - conn_options.max_xmit = c->max_xmit; - conn_options.server_uid = c->vuid; - conn_options.tid = c->cnum; - conn_options.secmode = c->sec_mode; - conn_options.rawmode = 0; - conn_options.sesskey = c->sesskey; - conn_options.maxraw = 0; - conn_options.capabilities = c->capabilities; - conn_options.serverzone = c->serverzone/60; - - res = ioctl(fd, SMB_IOC_NEWCONN, &conn_options); - if (res != 0) { - DEBUG(0,("mount.smbfs[%d]: ioctl failed, res=%d\n", - sys_getpid(), res)); - close(fd); - break; - } - - if (parentpid) { - /* Ok... We are going to kill the parent. Now - is the time to break the process group... */ - setsid(); - /* Send a signal to the parent to terminate */ - kill(parentpid, SIGTERM); - parentpid = 0; - } - - close(fd); - - /* This looks wierd but we are only closing the userspace - side, the connection has already been passed to smbfs and - it has increased the usage count on the socket. - - If we don't do this we will "leak" sockets and memory on - each reconnection we have to make. */ - c->smb_rw_error = SMB_DO_NOT_DO_TDIS; - cli_shutdown(c); - c = NULL; - - if (!closed) { - /* close the name cache so that close_our_files() doesn't steal its FD */ - namecache_shutdown(); - - /* redirect stdout & stderr since we can't know that - the library functions we use are using DEBUG. */ - if ( (fd = open("/dev/null", O_WRONLY)) < 0) - DEBUG(2,("mount.smbfs: can't open /dev/null\n")); - close_our_files(fd); - if (fd >= 0) { - dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); - close(fd); - } - - /* here we are no longer interactive */ - set_remote_machine_name("smbmount", False); /* sneaky ... */ - setup_logging("mount.smbfs", False); - reopen_logs(); - DEBUG(0, ("mount.smbfs: entering daemon mode for service %s, pid=%d\n", the_service, sys_getpid())); - - closed = 1; - } - - /* Wait for a signal from smbfs ... but don't continue - until we actually get a new connection. */ - while (!c) { - CatchSignal(SIGUSR1, &usr1_handler); - pause(); - DEBUG(2,("mount.smbfs[%d]: got signal, getting new socket\n", sys_getpid())); - c = do_connection(the_service); - } - } - - smb_umount(mount_point); - DEBUG(2,("mount.smbfs[%d]: exit\n", sys_getpid())); - exit(1); -} - - -/** - * Mount a smbfs - **/ - -#define NUM_ARGS 20 - -static void init_mount(void) -{ - char mount_point[PATH_MAX+1]; - TALLOC_CTX *ctx = talloc_tos(); - char *svc2; - struct cli_state *c; - const char *args[NUM_ARGS]; - int i, status; - - if (realpath(mpoint, mount_point) == NULL) { - fprintf(stderr, "Could not resolve mount point %s\n", mpoint); - return; - } - - - c = do_connection(service); - if (!c) { - fprintf(stderr,"SMB connection failed\n"); - exit(1); - } - - /* - Set up to return as a daemon child and wait in the parent - until the child say it's ready... - */ - daemonize(); - - svc2 = talloc_strdup(ctx, service); - if (!svc2) { - fprintf(stderr, "Out of memory.\n"); - exit(ENOMEM); - } - string_replace(svc2, '\\','/'); - string_replace(svc2, ' ','_'); - - memset(args, 0, sizeof(args[0])*NUM_ARGS); - - i=0; - args[i++] = "smbmnt"; - - args[i++] = mount_point; - args[i++] = "-s"; - args[i++] = svc2; - - if (mount_ro && i < NUM_ARGS-2) { - args[i++] = "-r"; - } - if (mount_uid && i < NUM_ARGS-3) { - args[i++] = "-u"; - args[i] = talloc_asprintf(ctx, "%d", mount_uid); - if (!args[i]) { - fprintf(stderr, "Out of memory.\n"); - exit(ENOMEM); - } - i++; - } - if (mount_gid && i < NUM_ARGS-3) { - args[i++] = "-g"; - args[i] = talloc_asprintf(ctx, "%d", mount_gid); - if (!args[i]) { - fprintf(stderr, "Out of memory.\n"); - exit(ENOMEM); - } - i++; - } - if (mount_fmask && i < NUM_ARGS-3) { - args[i++] = "-f"; - args[i] = talloc_asprintf(ctx, "0%o", mount_fmask); - if (!args[i]) { - fprintf(stderr, "Out of memory.\n"); - exit(ENOMEM); - } - i++; - } - if (mount_dmask && i < NUM_ARGS-3) { - args[i++] = "-d"; - args[i] = talloc_asprintf(ctx, "0%o", mount_dmask); - if (!args[i]) { - fprintf(stderr, "Out of memory.\n"); - exit(ENOMEM); - } - i++; - } - if (options && i < NUM_ARGS-3) { - args[i++] = "-o"; - args[i++] = options; - } - - if (sys_fork() == 0) { - char *smbmnt_path; - - asprintf(&smbmnt_path, "%s/smbmnt", get_dyn_BINDIR()); - - if (file_exist(smbmnt_path, NULL)) { - execv(smbmnt_path, (char * const *)args); - fprintf(stderr, - "smbfs/init_mount: execv of %s failed. Error was %s.", - smbmnt_path, strerror(errno)); - } else { - execvp("smbmnt", (char * const *)args); - fprintf(stderr, - "smbfs/init_mount: execv of %s failed. Error was %s.", - "smbmnt", strerror(errno)); - } - free(smbmnt_path); - exit(1); - } - - if (waitpid(-1, &status, 0) == -1) { - fprintf(stderr,"waitpid failed: Error was %s", strerror(errno) ); - /* FIXME: do some proper error handling */ - exit(1); - } - - if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { - fprintf(stderr,"smbmnt failed: %d\n", WEXITSTATUS(status)); - /* FIXME: do some proper error handling */ - exit(1); - } else if (WIFSIGNALED(status)) { - fprintf(stderr, "smbmnt killed by signal %d\n", WTERMSIG(status)); - exit(1); - } - - /* Ok... This is the rubicon for that mount point... At any point - after this, if the connections fail and can not be reconstructed - for any reason, we will have to unmount the mount point. There - is no exit from the next call... - */ - send_fs_socket(service, mount_point, c); -} - - -/**************************************************************************** -get a password from a a file or file descriptor -exit on failure (from smbclient, move to libsmb or shared .c file?) -****************************************************************************/ - -static void get_password_file(void) -{ - int fd = -1; - char *p; - bool close_it = False; - char *spec = NULL; - TALLOC_CTX *ctx = talloc_tos(); - char pass[128]; - - if ((p = getenv("PASSWD_FD")) != NULL) { - spec = talloc_asprintf(ctx, - "descriptor %s", - p); - if (!spec) { - fprintf(stderr, "Out of memory.\n"); - exit(ENOMEM); - } - fd = atoi(p); - close_it = False; - } else if ((p = getenv("PASSWD_FILE")) != NULL) { - fd = sys_open(p, O_RDONLY, 0); - spec = talloc_strdup(ctx, p); - if (!spec) { - fprintf(stderr, "Out of memory.\n"); - exit(ENOMEM); - } - if (fd < 0) { - fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", - spec, strerror(errno)); - exit(1); - } - close_it = True; - } - - for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */ - p && p - pass < sizeof(pass);) { - switch (read(fd, p, 1)) { - case 1: - if (*p != '\n' && *p != '\0') { - *++p = '\0'; /* advance p, and null-terminate pass */ - break; - } - case 0: - if (p - pass) { - *p = '\0'; /* null-terminate it, just in case... */ - p = NULL; /* then force the loop condition to become false */ - break; - } else { - fprintf(stderr, "Error reading password from file %s: %s\n", - spec, "empty password\n"); - exit(1); - } - - default: - fprintf(stderr, "Error reading password from file %s: %s\n", - spec, strerror(errno)); - exit(1); - } - } - password = talloc_strdup(ctx, pass); - if (close_it) - close(fd); -} - -/**************************************************************************** -get username and password from a credentials file -exit on failure (from smbclient, move to libsmb or shared .c file?) -****************************************************************************/ - -static void read_credentials_file(const char *filename) -{ - FILE *auth; - fstring buf; - uint16 len = 0; - char *ptr, *val, *param; - - if ((auth=sys_fopen(filename, "r")) == NULL) - { - /* fail if we can't open the credentials file */ - DEBUG(0,("ERROR: Unable to open credentials file!\n")); - exit (-1); - } - - while (!feof(auth)) - { - /* get a line from the file */ - if (!fgets (buf, sizeof(buf), auth)) - continue; - len = strlen(buf); - - if ((len) && (buf[len-1]=='\n')) - { - buf[len-1] = '\0'; - len--; - } - if (len == 0) - continue; - - /* break up the line into parameter & value. - will need to eat a little whitespace possibly */ - param = buf; - if (!(ptr = strchr (buf, '='))) - continue; - val = ptr+1; - *ptr = '\0'; - - /* eat leading white space */ - while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) - val++; - - if (strwicmp("password", param) == 0) - { - password = talloc_strdup(talloc_tos(),val); - got_pass = True; - } - else if (strwicmp("username", param) == 0) { - username = talloc_strdup(talloc_tos(), val); - } - - memset(buf, 0, sizeof(buf)); - } - fclose(auth); -} - - -/**************************************************************************** -usage on the program -****************************************************************************/ -static void usage(void) -{ - printf("Usage: mount.smbfs service mountpoint [-o options,...]\n"); - - printf("Version %s\n\n",SAMBA_VERSION_STRING); - - printf("Please be aware that smbfs is deprecated in favor of " - "cifs\n\n"); - - printf( -"Options:\n\ - username= SMB username\n\ - password= SMB password\n\ - credentials= file with username/password\n\ - krb use kerberos (active directory)\n\ - netbiosname= source NetBIOS name\n\ - uid= mount uid or username\n\ - gid= mount gid or groupname\n\ - port= remote SMB port number\n\ - fmask= file umask\n\ - dmask= directory umask\n\ - debug= debug level\n\ - ip= destination host or IP address\n\ - workgroup= workgroup on destination\n\ - sockopt= TCP socket options\n\ - scope= NetBIOS scope\n\ - iocharset= Linux charset (iso8859-1, utf8)\n\ - codepage= server codepage (cp850)\n\ - unicode use unicode when communicating with server\n\ - lfs large file system support\n\ - ttl= dircache time to live\n\ - guest don't prompt for a password\n\ - ro mount read-only\n\ - rw mount read-write\n\ -\n\ -This command is designed to be run from within /bin/mount by giving\n\ -the option '-t smbfs'. For example:\n\ - mount -t smbfs -o username=tridge,password=foobar //fjall/test /data/test\n\ -"); -} - - -/**************************************************************************** - Argument parsing for mount.smbfs interface - mount will call us like this: - mount.smbfs device mountpoint -o - - is never empty, containing at least rw or ro - ****************************************************************************/ -static void parse_mount_smb(int argc, char **argv) -{ - int opt; - char *opts; - char *opteq; - int val; - char *saveptr = NULL; - TALLOC_CTX *ctx = talloc_tos(); - - /* FIXME: This function can silently fail if the arguments are - * not in the expected order. - - > The arguments syntax of smbmount 2.2.3a (smbfs of Debian stable) - > requires that one gives "-o" before further options like username=... - > . Without -o, the username=.. setting is *silently* ignored. I've - > spent about an hour trying to find out why I couldn't log in now.. - - */ - - - if (argc < 2 || argv[1][0] == '-') { - usage(); - exit(1); - } - - service = talloc_strdup(ctx, argv[1]); - if (!service) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - mpoint = talloc_strdup(ctx, argv[2]); - if (!mpoint) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - - /* Convert any '/' characters in the service name to - '\' characters */ - string_replace(service, '/','\\'); - argc -= 2; - argv += 2; - - opt = getopt(argc, argv, "o:"); - if(opt != 'o') { - return; - } - - options = talloc_strdup(ctx, ""); - if (!options) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - - /* - * option parsing from nfsmount.c (util-linux-2.9u) - */ - for (opts = strtok_r(optarg, ",", &saveptr); opts; - opts = strtok_r(NULL, ",", &saveptr)) { - DEBUG(3, ("opts: %s\n", opts)); - if ((opteq = strchr_m(opts, '='))) { - val = atoi(opteq + 1); - *opteq = '\0'; - - if (!strcmp(opts, "username") || - !strcmp(opts, "logon")) { - char *lp; - got_user = True; - username = talloc_strdup(ctx, opteq+1); - if (!username) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - if ((lp=strchr_m(username,'%'))) { - *lp = 0; - password = talloc_strdup(ctx, lp+1); - if (!password) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - got_pass = True; - memset(strchr_m(opteq+1,'%')+1,'X',strlen(password)); - } - if ((lp=strchr_m(username,'/'))) { - *lp = 0; - fstrcpy(workgroup,lp+1); - } - } else if(!strcmp(opts, "passwd") || - !strcmp(opts, "password")) { - password = talloc_strdup(ctx,opteq+1); - if (!password) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - got_pass = True; - memset(opteq+1,'X',strlen(password)); - } else if(!strcmp(opts, "credentials")) { - credentials = talloc_strdup(ctx,opteq+1); - if (!credentials) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - } else if(!strcmp(opts, "netbiosname")) { - fstrcpy(my_netbios_name,opteq+1); - } else if(!strcmp(opts, "uid")) { - mount_uid = nametouid(opteq+1); - } else if(!strcmp(opts, "gid")) { - mount_gid = nametogid(opteq+1); - } else if(!strcmp(opts, "port")) { - smb_port = val; - } else if(!strcmp(opts, "fmask")) { - mount_fmask = strtol(opteq+1, NULL, 8); - } else if(!strcmp(opts, "dmask")) { - mount_dmask = strtol(opteq+1, NULL, 8); - } else if(!strcmp(opts, "debug")) { - DEBUGLEVEL = val; - } else if(!strcmp(opts, "ip")) { - if (!interpret_string_addr(&dest_ip, opteq+1, - 0)) { - fprintf(stderr,"Can't resolve address %s\n", opteq+1); - exit(1); - } - have_ip = True; - } else if(!strcmp(opts, "workgroup")) { - fstrcpy(workgroup,opteq+1); - } else if(!strcmp(opts, "sockopt")) { - lp_do_parameter(-1, "socket options", opteq+1); - } else if(!strcmp(opts, "scope")) { - set_global_scope(opteq+1); - } else { - options = talloc_asprintf_append(options, - "%s=%s,", - opts, opteq+1); - if (!options) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - } - } else { - val = 1; - if(!strcmp(opts, "nocaps")) { - fprintf(stderr, "Unhandled option: %s\n", opteq+1); - exit(1); - } else if(!strcmp(opts, "guest")) { - password = talloc_strdup(talloc_tos(), ""); - if (!password) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - got_pass = True; - } else if(!strcmp(opts, "krb")) { -#ifdef HAVE_KRB5 - - use_kerberos = True; - if(!status32_smbfs) - fprintf(stderr, "Warning: kerberos support will only work for samba servers\n"); -#else - fprintf(stderr,"No kerberos support compiled in\n"); - exit(1); -#endif - } else if(!strcmp(opts, "rw")) { - mount_ro = 0; - } else if(!strcmp(opts, "ro")) { - mount_ro = 1; - } else if(!strcmp(opts, "unicode")) { - smbfs_has_unicode = True; - } else if(!strcmp(opts, "lfs")) { - smbfs_has_lfs = True; - } else { - options = talloc_asprintf_append(options, - "%s,", - opts); - if (!options) { - fprintf(stderr,"Out of memory\n"); - exit(ENOMEM); - } - } - } - } - - if (!service || !*service) { - usage(); - exit(1); - } - - if (options && *options && options[strlen(options)-1] == ',') { - options[strlen(options)-1] = '\0'; /* remove trailing , */ - DEBUG(3,("passthrough options '%s'\n", options)); - } -} - -/**************************************************************************** - main program -****************************************************************************/ - int main(int argc,char *argv[]) -{ - TALLOC_CTX *frame = talloc_stackframe(); - char *p; - - DEBUGLEVEL = 1; - - load_case_tables(); - - /* here we are interactive, even if run from autofs */ - setup_logging("mount.smbfs",True); - -#if 0 /* JRA - Urban says not needed ? */ - /* CLI_FORCE_ASCII=false makes smbmount negotiate unicode. The default - is to not announce any unicode capabilities as current smbfs does - not support it. */ - p = getenv("CLI_FORCE_ASCII"); - if (p && !strcmp(p, "false")) - unsetenv("CLI_FORCE_ASCII"); - else - setenv("CLI_FORCE_ASCII", "true", 1); -#endif - - in_client = True; /* Make sure that we tell lp_load we are */ - - if (getenv("USER")) { - username = talloc_strdup(frame, getenv("USER")); - if (!username) { - exit(ENOMEM); - } - - if ((p=strchr_m(username,'%'))) { - *p = 0; - password = talloc_strdup(frame, p+1); - if (!password) { - exit(ENOMEM); - } - got_pass = True; - memset(strchr_m(getenv("USER"),'%')+1,'X',strlen(password)); - } - strupper_m(username); - } - - if (getenv("PASSWD")) { - password = talloc_strdup(frame, getenv("PASSWD")); - if (!password) { - exit(ENOMEM); - } - got_pass = True; - } - - if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) { - get_password_file(); - got_pass = True; - } - - if ((!username || *username == 0) && getenv("LOGNAME")) { - username = talloc_strdup(frame, getenv("LOGNAME")); - if (!username) { - exit(ENOMEM); - } - } - - if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True)) { - fprintf(stderr, "Can't load %s - run testparm to debug it\n", - get_dyn_CONFIGFILE()); - } - - parse_mount_smb(argc, argv); - - if (use_kerberos && !got_user) { - got_pass = True; - } - - if (credentials && *credentials != 0) { - read_credentials_file(credentials); - } - - DEBUG(3,("mount.smbfs started (version %s)\n", SAMBA_VERSION_STRING)); - - if (*workgroup == 0) { - fstrcpy(workgroup,lp_workgroup()); - } - - load_interfaces(); - if (!*my_netbios_name) { - fstrcpy(my_netbios_name, myhostname()); - } - strupper_m(my_netbios_name); - - init_mount(); - TALLOC_FREE(frame); - return 0; -} diff --git a/source3/client/smbumount.c b/source3/client/smbumount.c deleted file mode 100644 index e74c31299c..0000000000 --- a/source3/client/smbumount.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * smbumount.c - * - * Copyright (C) 1995-1998 by Volker Lendecke - * - */ - -#define SMBMOUNT_MALLOC 1 - -#include "includes.h" - -#include - -#include -#include -#include -#include -#include - -/* This is a (hopefully) temporary hack due to the fact that - sizeof( uid_t ) != sizeof( __kernel_uid_t ) under glibc. - This may change in the future and smb.h may get fixed in the - future. In the mean time, it's ugly hack time - get over it. -*/ -#undef SMB_IOC_GETMOUNTUID -#define SMB_IOC_GETMOUNTUID _IOR('u', 1, __kernel_uid_t) - -#ifndef O_NOFOLLOW -#define O_NOFOLLOW 0400000 -#endif - -static void -usage(void) -{ - printf("usage: smbumount mountpoint\n\n"); - printf("Please be aware that smbfs is deprecated in favor of " - "cifs\n"); -} - -static int -umount_ok(const char *mount_point) -{ - /* we set O_NOFOLLOW to prevent users playing games with symlinks to - umount filesystems they don't own */ - int fid = open(mount_point, O_RDONLY|O_NOFOLLOW, 0); - __kernel_uid32_t mount_uid; - - if (fid == -1) { - fprintf(stderr, "Could not open %s: %s\n", - mount_point, strerror(errno)); - return -1; - } - - if (ioctl(fid, SMB_IOC_GETMOUNTUID32, &mount_uid) != 0) { - __kernel_uid_t mount_uid16; - if (ioctl(fid, SMB_IOC_GETMOUNTUID, &mount_uid16) != 0) { - fprintf(stderr, "%s probably not smb-filesystem\n", - mount_point); - return -1; - } - mount_uid = mount_uid16; - } - - if ((getuid() != 0) - && (mount_uid != getuid())) { - fprintf(stderr, "You are not allowed to umount %s\n", - mount_point); - return -1; - } - - close(fid); - return 0; -} - -/* Make a canonical pathname from PATH. Returns a freshly malloced string. - It is up the *caller* to ensure that the PATH is sensible. i.e. - canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.'' - is not a legal pathname for ``/dev/fd0'' Anything we cannot parse - we return unmodified. */ -static char * -canonicalize (char *path) -{ - char *canonical = (char*)malloc (PATH_MAX + 1); - - if (!canonical) { - fprintf(stderr, "Error! Not enough memory!\n"); - return NULL; - } - - if (strlen(path) > PATH_MAX) { - fprintf(stderr, "Mount point string too long\n"); - return NULL; - } - - if (path == NULL) - return NULL; - - if (realpath (path, canonical)) - return canonical; - - strncpy (canonical, path, PATH_MAX); - canonical[PATH_MAX] = '\0'; - return canonical; -} - - -int -main(int argc, char *argv[]) -{ - int fd; - char* mount_point; - struct mntent *mnt; - FILE* mtab; - FILE* new_mtab; - TALLOC_CTX *frame = talloc_stackframe(); - - if (argc != 2) { - usage(); - exit(1); - } - - if (geteuid() != 0) { - fprintf(stderr, "smbumount must be installed suid root\n"); - exit(1); - } - - mount_point = canonicalize(argv[1]); - - if (mount_point == NULL) - { - exit(1); - } - - if (umount_ok(mount_point) != 0) { - exit(1); - } - - if (umount(mount_point) != 0) { - fprintf(stderr, "Could not umount %s: %s\n", - mount_point, strerror(errno)); - exit(1); - } - - if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1) - { - fprintf(stderr, "Can't get "MOUNTED"~ lock file"); - return 1; - } - close(fd); - - if ((mtab = setmntent(MOUNTED, "r")) == NULL) { - fprintf(stderr, "Can't open " MOUNTED ": %s\n", - strerror(errno)); - return 1; - } - -#define MOUNTED_TMP MOUNTED".tmp" - - if ((new_mtab = setmntent(MOUNTED_TMP, "w")) == NULL) { - fprintf(stderr, "Can't open " MOUNTED_TMP ": %s\n", - strerror(errno)); - endmntent(mtab); - return 1; - } - - while ((mnt = getmntent(mtab)) != NULL) { - if (strcmp(mnt->mnt_dir, mount_point) != 0) { - addmntent(new_mtab, mnt); - } - } - - endmntent(mtab); - - if (fchmod (fileno (new_mtab), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) { - fprintf(stderr, "Error changing mode of %s: %s\n", - MOUNTED_TMP, strerror(errno)); - exit(1); - } - - endmntent(new_mtab); - - if (rename(MOUNTED_TMP, MOUNTED) < 0) { - fprintf(stderr, "Cannot rename %s to %s: %s\n", - MOUNTED, MOUNTED_TMP, strerror(errno)); - exit(1); - } - - if (unlink(MOUNTED"~") == -1) - { - fprintf(stderr, "Can't remove "MOUNTED"~"); - return 1; - } - - TALLOC_FREE(frame); - return 0; -} diff --git a/source3/configure.in b/source3/configure.in index 4fadfd7ae0..5de8a289db 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -114,7 +114,6 @@ AC_SUBST(INSTALL_PAM_MODULES) AC_SUBST(UNINSTALL_PAM_MODULES) AC_SUBST(NSS_MODULES) AC_SUBST(EXTRA_BIN_PROGS) -AC_SUBST(SMBMOUNT_PROGS) AC_SUBST(CIFSMOUNT_PROGS) AC_SUBST(INSTALL_CIFSMOUNT) AC_SUBST(UNINSTALL_CIFSMOUNT) @@ -3990,31 +3989,6 @@ AC_ARG_WITH(automount, AC_MSG_RESULT(no) ) -################################################# -# check for smbmount support -AC_MSG_CHECKING(whether to use smbmount) -AC_ARG_WITH(smbmount, -[AS_HELP_STRING([--with-smbmount], [Include smbmount (Linux only) support (default=no)])], -[ case "$withval" in - yes) - case "$host_os" in - *linux*) - AC_MSG_RESULT(yes) - AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount]) - SMBMOUNT_PROGS="bin/smbmount bin/smbmnt bin/smbumount" - ;; - *) - AC_MSG_ERROR(not on a linux system!) - ;; - esac - ;; - *) - AC_MSG_RESULT(no) - ;; - esac ], - AC_MSG_RESULT(no) -) - ################################################# # check for mount- and umount.cifs support CIFSMOUNT_PROGS="" diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 463a2bdb0b..c98c4244de 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -305,10 +305,9 @@ NULL returns on zero request. JRA. #define talloc_destroy(ctx) talloc_free(ctx) #define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0) -/* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling - the smbmount utils */ +/* only define PARANOID_MALLOC_CHECKER with --enable-developer */ -#if defined(DEVELOPER) && !defined(SMBMOUNT_MALLOC) +#if defined(DEVELOPER) # define PARANOID_MALLOC_CHECKER 1 #endif diff --git a/source3/script/installbin.sh.in b/source3/script/installbin.sh.in index 59a6c31ca8..c607d9e445 100755 --- a/source3/script/installbin.sh.in +++ b/source3/script/installbin.sh.in @@ -19,15 +19,6 @@ for p in $*; do fi cp $p $DESTDIR/$BINDIR/ chmod $INSTALLPERMS $DESTDIR/$BINDIR/$p2 - - # this is a special case, mount needs this in a specific location - if [ $p2 = smbmount ]; then - if [ ! -d $DESTDIR/@rootsbindir@ ]; then - mkdir $DESTDIR/@rootsbindir@ - fi - echo "Creating sym link $DESTDIR/@rootsbindir@/mount.smbfs to $BINDIR/$p2 " - ln -sf $BINDIR/$p2 $DESTDIR/@rootsbindir@/mount.smbfs - fi done diff --git a/source3/script/installman.sh b/source3/script/installman.sh index 7edc707ab0..869ce6ee38 100755 --- a/source3/script/installman.sh +++ b/source3/script/installman.sh @@ -49,7 +49,6 @@ for lang in $langs; do # Check if this man page if required by the configured feature set case "${MP_BASENAME}" in smbsh.1) test -z "${SMBWRAPPER}" && continue ;; - smbmnt.8|smbmount.8|smbumount.8) test -z "${SMBMOUNT_PROGS}" && continue ;; *) ;; esac diff --git a/source3/script/uninstallbin.sh.in b/source3/script/uninstallbin.sh.in index e1bbf6ecb1..8064db8d95 100755 --- a/source3/script/uninstallbin.sh.in +++ b/source3/script/uninstallbin.sh.in @@ -26,12 +26,6 @@ for p in $*; do echo "Cannot remove $DESTDIR/$BINDIR/$p2 ... does $USER have privileges? " fi fi - - # this is a special case, mount needs this in a specific location - if test "$p2" = smbmount -a -f "$DESTDIR/sbin/mount.smbfs"; then - echo "Removing $DESTDIR/sbin/mount.smbfs " - rm -f "$DESTDIR/@rootsbindir@/sbin/mount.smbfs" - fi done -- cgit From 4a8e6c9a91b772a924b8f0519d373457bb2a95ae Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 16:56:35 +0100 Subject: Use libnetapi_get_error_string() in "net dom" commands. Guenther (This used to be commit 58048f0c575d6ac5b770873e308d4a1a9ce68123) --- source3/utils/net_dom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c index 30993ae2fa..e88bbdb276 100644 --- a/source3/utils/net_dom.c +++ b/source3/utils/net_dom.c @@ -101,7 +101,7 @@ static int net_dom_unjoin(int argc, const char **argv) status = NetUnjoinDomain(server_name, account, password, unjoin_flags); if (status != 0) { printf("Failed to unjoin domain: %s\n", - libnetapi_errstr(status)); + libnetapi_get_error_string(ctx, status)); goto done; } @@ -215,7 +215,7 @@ static int net_dom_join(int argc, const char **argv) Account, password, join_flags); if (status != 0) { printf("Failed to join domain: %s\n", - libnetapi_errstr(status)); + libnetapi_get_error_string(ctx, status)); goto done; } -- cgit From 15f6e27bd5a9065c8b781fa21f5989ce2c355776 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 17:02:14 +0100 Subject: Add some more error handling in libnetjoin. Guenther (This used to be commit 892b2bc0cf1692c5707d322d0eb711b8245a3a96) --- source3/libnet/libnet_join.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 623ca39f71..97fad95a68 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1193,6 +1193,9 @@ static WERROR libnet_join_pre_processing(TALLOC_CTX *mem_ctx, } if (r->in.modify_config && !lp_config_backend_is_registry()) { + libnet_join_set_error_string(mem_ctx, r, + "Configuration manipulation requested but not " + "supported by backend"); return WERR_NOT_SUPPORTED; } @@ -1519,9 +1522,16 @@ static WERROR libnet_unjoin_pre_processing(TALLOC_CTX *mem_ctx, } if (r->in.modify_config && !lp_config_backend_is_registry()) { + libnet_unjoin_set_error_string(mem_ctx, r, + "Configuration manipulation requested but not " + "supported by backend"); return WERR_NOT_SUPPORTED; } + if (IS_DC) { + return WERR_SETUP_DOMAIN_CONTROLLER; + } + if (!secrets_init()) { libnet_unjoin_set_error_string(mem_ctx, r, "Unable to open secrets database"); -- 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') 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 8f58ae97f0c46dc66f680d7b6ed93ee2aa6bc629 Mon Sep 17 00:00:00 2001 From: "Gerald W. Carter" Date: Thu, 28 Feb 2008 11:58:05 -0600 Subject: Fix macro name (no 's' in ifr_addr). Interface detection on Solaris still failing due to items pointed out here: http://lists.samba.org/archive/samba-technical/2007-November/056701.html (This used to be commit 37c87acc9d48c1fb5d4806374ca8e992300db1ff) --- source3/lib/replace/system/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h index 410c6d7cca..796df2d1da 100644 --- a/source3/lib/replace/system/network.h +++ b/source3/lib/replace/system/network.h @@ -305,7 +305,7 @@ struct addrinfo { /* Needed for some systems that don't define it (Solaris). */ #ifndef ifr_netmask -#define ifr_netmask ifr_addrs +#define ifr_netmask ifr_addr #endif #ifdef SOCKET_WRAPPER -- cgit From 2306574570332855670f1c53f3c9376b5114b91a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 19:44:34 +0100 Subject: libnetjoin: Merge in comments, debugs and missing code from original join code. Guenther (This used to be commit 09e6010159cb9c2a5d86861889b8c2a07bd39a8d) --- source3/libnet/libnet_join.c | 120 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 117 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 97fad95a68..38d98221b4 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -196,6 +196,7 @@ static ADS_STATUS libnet_unjoin_connect_ads(TALLOC_CTX *mem_ctx, } /**************************************************************** + join a domain using ADS (LDAP mods) ****************************************************************/ static ADS_STATUS libnet_join_precreate_machine_acct(TALLOC_CTX *mem_ctx, @@ -204,6 +205,7 @@ static ADS_STATUS libnet_join_precreate_machine_acct(TALLOC_CTX *mem_ctx, ADS_STATUS status; LDAPMessage *res = NULL; const char *attrs[] = { "dn", NULL }; + bool moved = false; status = ads_search_dn(r->in.ads, &res, r->in.account_ou, attrs); if (!ADS_ERR_OK(status)) { @@ -215,16 +217,41 @@ static ADS_STATUS libnet_join_precreate_machine_acct(TALLOC_CTX *mem_ctx, return ADS_ERROR_LDAP(LDAP_NO_SUCH_OBJECT); } + ads_msgfree(r->in.ads, res); + + /* Attempt to create the machine account and bail if this fails. + Assume that the admin wants exactly what they requested */ + status = ads_create_machine_acct(r->in.ads, r->in.machine_name, r->in.account_ou); - ads_msgfree(r->in.ads, res); - if ((status.error_type == ENUM_ADS_ERROR_LDAP) && - (status.err.rc == LDAP_ALREADY_EXISTS)) { + if (ADS_ERR_OK(status)) { + DEBUG(1,("machine account creation created\n")); + return status; + } else if ((status.error_type == ENUM_ADS_ERROR_LDAP) && + (status.err.rc == LDAP_ALREADY_EXISTS)) { status = ADS_SUCCESS; } + if (!ADS_ERR_OK(status)) { + DEBUG(1,("machine account creation failed\n")); + return status; + } + + status = ads_move_machine_acct(r->in.ads, + r->in.machine_name, + r->in.account_ou, + &moved); + if (!ADS_ERR_OK(status)) { + DEBUG(1,("failure to locate/move pre-existing " + "machine account\n")); + return status; + } + + DEBUG(1,("The machine account %s the specified OU.\n", + moved ? "was moved into" : "already exists in")); + return status; } @@ -300,6 +327,7 @@ static ADS_STATUS libnet_join_find_machine_acct(TALLOC_CTX *mem_ctx, } /**************************************************************** + Set a machines dNSHostName and servicePrincipalName attributes ****************************************************************/ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, @@ -311,11 +339,15 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, const char *spn_array[3] = {NULL, NULL, NULL}; char *spn = NULL; + /* Find our DN */ + status = libnet_join_find_machine_acct(mem_ctx, r); if (!ADS_ERR_OK(status)) { return status; } + /* Windows only creates HOST/shortname & HOST/fqdn. */ + spn = talloc_asprintf(mem_ctx, "HOST/%s", r->in.machine_name); if (!spn) { return ADS_ERROR_LDAP(LDAP_NO_MEMORY); @@ -339,6 +371,8 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, return ADS_ERROR_LDAP(LDAP_NO_MEMORY); } + /* fields of primary importance */ + status = ads_mod_str(mem_ctx, &mods, "dNSHostName", my_fqdn); if (!ADS_ERR_OK(status)) { return ADS_ERROR_LDAP(LDAP_NO_MEMORY); @@ -366,6 +400,8 @@ static ADS_STATUS libnet_join_set_machine_upn(TALLOC_CTX *mem_ctx, return ADS_SUCCESS; } + /* Find our DN */ + status = libnet_join_find_machine_acct(mem_ctx, r); if (!ADS_ERR_OK(status)) { return status; @@ -381,11 +417,15 @@ static ADS_STATUS libnet_join_set_machine_upn(TALLOC_CTX *mem_ctx, } } + /* now do the mods */ + mods = ads_init_mods(mem_ctx); if (!mods) { return ADS_ERROR_LDAP(LDAP_NO_MEMORY); } + /* fields of primary importance */ + status = ads_mod_str(mem_ctx, &mods, "userPrincipalName", r->in.upn); if (!ADS_ERR_OK(status)) { return ADS_ERROR_LDAP(LDAP_NO_MEMORY); @@ -409,11 +449,15 @@ static ADS_STATUS libnet_join_set_os_attributes(TALLOC_CTX *mem_ctx, return ADS_SUCCESS; } + /* Find our DN */ + status = libnet_join_find_machine_acct(mem_ctx, r); if (!ADS_ERR_OK(status)) { return status; } + /* now do the mods */ + mods = ads_init_mods(mem_ctx); if (!mods) { return ADS_ERROR(LDAP_NO_MEMORY); @@ -424,6 +468,8 @@ static ADS_STATUS libnet_join_set_os_attributes(TALLOC_CTX *mem_ctx, return ADS_ERROR(LDAP_NO_MEMORY); } + /* fields of primary importance */ + status = ads_mod_str(mem_ctx, &mods, "operatingSystem", r->in.os_name); if (!ADS_ERR_OK(status)) { @@ -481,6 +527,8 @@ static bool libnet_join_derive_salting_principal(TALLOC_CTX *mem_ctx, return false; } + /* go ahead and setup the default salt */ + std_salt = kerberos_standard_des_salt(); if (!std_salt) { libnet_join_set_error_string(mem_ctx, r, @@ -495,6 +543,8 @@ static bool libnet_join_derive_salting_principal(TALLOC_CTX *mem_ctx, SAFE_FREE(std_salt); + /* if it's a Windows functional domain, we have to look for the UPN */ + if (domain_func == DS_DOMAIN_FUNCTION_2000) { char *upn; @@ -565,6 +615,7 @@ static ADS_STATUS libnet_join_post_processing_ads(TALLOC_CTX *mem_ctx, #endif /* WITH_ADS */ /**************************************************************** + Store the machine password and domain SID ****************************************************************/ static bool libnet_join_joindomain_store_secrets(TALLOC_CTX *mem_ctx, @@ -573,6 +624,7 @@ static bool libnet_join_joindomain_store_secrets(TALLOC_CTX *mem_ctx, if (!secrets_store_domain_sid(r->out.netbios_domain_name, r->out.domain_sid)) { + DEBUG(1,("Failed to save domain sid\n")); return false; } @@ -580,6 +632,7 @@ static bool libnet_join_joindomain_store_secrets(TALLOC_CTX *mem_ctx, r->out.netbios_domain_name, SEC_CHAN_WKSTA)) { + DEBUG(1,("Failed to save machine password\n")); return false; } @@ -587,6 +640,7 @@ static bool libnet_join_joindomain_store_secrets(TALLOC_CTX *mem_ctx, } /**************************************************************** + Do the domain join ****************************************************************/ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, @@ -631,6 +685,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &status); if (!pipe_hnd) { + DEBUG(0,("Error connecting to LSA pipe. Error was %s\n", + nt_errstr(status))); goto done; } @@ -667,8 +723,12 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol); cli_rpc_pipe_close(pipe_hnd); + /* Open the domain */ + pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &status); if (!pipe_hnd) { + DEBUG(0,("Error connecting to SAM pipe. Error was %s\n", + nt_errstr(status))); goto done; } @@ -689,6 +749,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, goto done; } + /* Create domain user */ + acct_name = talloc_asprintf(mem_ctx, "%s$", r->in.machine_name); strlower_m(acct_name); @@ -703,6 +765,10 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, SAMR_USER_ACCESS_SET_ATTRIBUTES; uint32_t access_granted = 0; + /* Don't try to set any acb_info flags other than ACB_WSTRUST */ + + DEBUG(10,("Creating account with flags: %d\n", acct_flags)); + status = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx, &domain_pol, &lsa_acct_name, @@ -711,6 +777,25 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, &user_pol, &access_granted, &user_rid); + if (!NT_STATUS_IS_OK(status) && + !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { + + DEBUG(10,("Creation of workstation account failed: %s\n", + nt_errstr(status))); + + /* If NT_STATUS_ACCESS_DENIED then we have a valid + username/password combo but the user does not have + administrator access. */ + + if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + libnet_join_set_error_string(mem_ctx, r, + "User specified does not have " + "administrator privileges"); + } + + return status; + } + if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_DOMAIN_JOIN_IF_JOINED)) { @@ -718,6 +803,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, } } + /* We *must* do this.... don't ask... */ + if (NT_STATUS_IS_OK(status)) { rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); } @@ -734,12 +821,16 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, } if (name_types.ids[0] != SID_NAME_USER) { + DEBUG(0,("%s is not a user account (type=%d)\n", + acct_name, name_types.ids[0])); status = NT_STATUS_INVALID_WORKSTATION; goto done; } user_rid = user_rids.ids[0]; + /* Open handle on user */ + status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx, &domain_pol, SEC_RIGHTS_MAXIMUM_ALLOWED, @@ -749,6 +840,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, goto done; } + /* Create a random machine account password and generate the hash */ + E_md4hash(r->in.machine_password, md4_trust_password); encode_pw_buffer(pwbuf, r->in.machine_password, STR_UNICODE); @@ -764,6 +857,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, SamOEMhashBlob(pwbuf, sizeof(pwbuf), &digested_session_key); memcpy(&pwbuf[516], md5buffer, sizeof(md5buffer)); + /* Fill in the additional account flags now */ + acb_info |= ACB_PWNOEXP; if (r->out.domain_is_ad) { #if !defined(ENCTYPE_ARCFOUR_HMAC) @@ -772,6 +867,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, ;; } + /* Set password and account flags on machine account */ + ZERO_STRUCT(user_info.info25); user_info.info25.info.fields_present = ACCT_NT_PWD_SET | @@ -785,6 +882,9 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, 25, &user_info); if (!NT_STATUS_IS_OK(status)) { + libnet_join_set_error_string(mem_ctx, r, + "Failed to set password for machine account (%s)\n", + nt_errstr(status)); goto done; } @@ -973,8 +1073,12 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx, goto done; } + /* Open the domain */ + pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &status); if (!pipe_hnd) { + DEBUG(0,("Error connecting to SAM pipe. Error was %s\n", + nt_errstr(status))); goto done; } @@ -995,6 +1099,8 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx, goto done; } + /* Create domain user */ + acct_name = talloc_asprintf(mem_ctx, "%s$", r->in.machine_name); strlower_m(acct_name); @@ -1012,12 +1118,16 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx, } if (name_types.ids[0] != SID_NAME_USER) { + DEBUG(0, ("%s is not a user account (type=%d)\n", acct_name, + name_types.ids[0])); status = NT_STATUS_INVALID_WORKSTATION; goto done; } user_rid = user_rids.ids[0]; + /* Open handle on user */ + status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx, &domain_pol, SEC_RIGHTS_MAXIMUM_ALLOWED, @@ -1027,6 +1137,8 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx, goto done; } + /* Get user info */ + status = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx, &user_pol, 16, @@ -1036,6 +1148,8 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx, goto done; } + /* now disable and setuser info */ + info->info16.acct_flags |= ACB_DISABLED; status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, -- cgit From 27310f0768f734f68f4c48d6b2c2cc441a0a434c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 19:54:35 +0100 Subject: Remove original copy of now redundant join code. Jerry, I checked this very carefully that nothing got lost. The only thing I need to re-add still is the normalized DN handling for account precreation in "net ads join". Guenther (This used to be commit a5c6347644f2aa138a8e67ffe6c167847df941d0) --- source3/Makefile.in | 2 +- source3/utils/net_ads.c | 330 -------------------------------------- source3/utils/net_domain.c | 387 --------------------------------------------- 3 files changed, 1 insertion(+), 718 deletions(-) delete mode 100644 source3/utils/net_domain.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index d20cea2d16..63328ec86e 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -805,7 +805,7 @@ LIBNET_CONF_OBJ = libnet/libnet_conf.o LIBNET_OBJ = $(LIBNET_CONF_OBJ) libnet/libnet_join.o \ librpc/gen_ndr/ndr_libnet_join.o -NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_domain.o utils/net_help.o \ +NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \ utils/net_rap.o utils/net_rpc.o utils/net_rpc_samsync.o \ utils/net_rpc_join.o utils/net_time.o utils/net_lookup.o \ utils/net_cache.o utils/net_groupmap.o utils/net_idmap.o \ diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 345665d62e..9358a4f184 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -947,336 +947,6 @@ static NTSTATUS check_ads_config( void ) return NT_STATUS_OK; } -/******************************************************************* - Do the domain join - ********************************************************************/ - -static NTSTATUS net_join_domain(TALLOC_CTX *ctx, const char *servername, - struct sockaddr_storage *pss, - const char **domain, - DOM_SID **dom_sid, - const char *password) -{ - NTSTATUS ret = NT_STATUS_UNSUCCESSFUL; - struct cli_state *cli = NULL; - - ret = connect_to_ipc_krb5(&cli, pss, servername); - if ( !NT_STATUS_IS_OK(ret) ) { - goto done; - } - - ret = netdom_get_domain_sid( ctx, cli, domain, dom_sid ); - if ( !NT_STATUS_IS_OK(ret) ) { - goto done; - } - - /* cli->server_domain is not filled in when using krb5 - session setups */ - - saf_store( *domain, cli->desthost ); - - ret = netdom_join_domain( ctx, cli, *dom_sid, password, ND_TYPE_AD ); - -done: - if ( cli ) - cli_shutdown(cli); - - return ret; -} - -/******************************************************************* - Set a machines dNSHostName and servicePrincipalName attributes - ********************************************************************/ - -static ADS_STATUS net_set_machine_spn(TALLOC_CTX *ctx, ADS_STRUCT *ads_s ) -{ - ADS_STATUS status = ADS_ERROR(LDAP_SERVER_DOWN); - char *new_dn; - ADS_MODLIST mods; - const char *servicePrincipalName[3] = {NULL, NULL, NULL}; - char *psp; - fstring my_fqdn; - LDAPMessage *res = NULL; - char *dn_string = NULL; - const char *machine_name = global_myname(); - int count; - - if ( !machine_name ) { - return ADS_ERROR(LDAP_NO_MEMORY); - } - - /* Find our DN */ - - status = ads_find_machine_acct(ads_s, &res, machine_name); - if (!ADS_ERR_OK(status)) - return status; - - if ( (count = ads_count_replies(ads_s, res)) != 1 ) { - DEBUG(1,("net_set_machine_spn: %d entries returned!\n", count)); - return ADS_ERROR(LDAP_NO_MEMORY); - } - - if ( (dn_string = ads_get_dn(ads_s, res)) == NULL ) { - DEBUG(1, ("ads_add_machine_acct: ads_get_dn returned NULL (malloc failure?)\n")); - goto done; - } - - new_dn = talloc_strdup(ctx, dn_string); - ads_memfree(ads_s, dn_string); - if (!new_dn) { - return ADS_ERROR(LDAP_NO_MEMORY); - } - - /* Windows only creates HOST/shortname & HOST/fqdn. */ - - if ( !(psp = talloc_asprintf(ctx, "HOST/%s", machine_name)) ) - goto done; - strupper_m(psp); - servicePrincipalName[0] = psp; - - name_to_fqdn(my_fqdn, machine_name); - strlower_m(my_fqdn); - if ( !(psp = talloc_asprintf(ctx, "HOST/%s", my_fqdn)) ) - goto done; - servicePrincipalName[1] = psp; - - if (!(mods = ads_init_mods(ctx))) { - goto done; - } - - /* fields of primary importance */ - - ads_mod_str(ctx, &mods, "dNSHostName", my_fqdn); - ads_mod_strlist(ctx, &mods, "servicePrincipalName", servicePrincipalName); - - status = ads_gen_mod(ads_s, new_dn, mods); - -done: - ads_msgfree(ads_s, res); - - return status; -} - -/******************************************************************* - Set a machines dNSHostName and servicePrincipalName attributes - ********************************************************************/ - -static ADS_STATUS net_set_machine_upn(TALLOC_CTX *ctx, ADS_STRUCT *ads_s, const char *upn ) -{ - ADS_STATUS status = ADS_ERROR(LDAP_SERVER_DOWN); - char *new_dn; - ADS_MODLIST mods; - LDAPMessage *res = NULL; - char *dn_string = NULL; - const char *machine_name = global_myname(); - int count; - - if ( !machine_name ) { - return ADS_ERROR(LDAP_NO_MEMORY); - } - - /* Find our DN */ - - status = ads_find_machine_acct(ads_s, &res, machine_name); - if (!ADS_ERR_OK(status)) - return status; - - if ( (count = ads_count_replies(ads_s, res)) != 1 ) { - DEBUG(1,("net_set_machine_spn: %d entries returned!\n", count)); - return ADS_ERROR(LDAP_NO_MEMORY); - } - - if ( (dn_string = ads_get_dn(ads_s, res)) == NULL ) { - DEBUG(1, ("ads_add_machine_acct: ads_get_dn returned NULL (malloc failure?)\n")); - goto done; - } - - new_dn = talloc_strdup(ctx, dn_string); - ads_memfree(ads_s, dn_string); - if (!new_dn) { - return ADS_ERROR(LDAP_NO_MEMORY); - } - - /* now do the mods */ - - if (!(mods = ads_init_mods(ctx))) { - goto done; - } - - /* fields of primary importance */ - - ads_mod_str(ctx, &mods, "userPrincipalName", upn); - - status = ads_gen_mod(ads_s, new_dn, mods); - -done: - ads_msgfree(ads_s, res); - - return status; -} - -/******************************************************************* - Set a machines dNSHostName and servicePrincipalName attributes - ********************************************************************/ - -static ADS_STATUS net_set_os_attributes(TALLOC_CTX *ctx, ADS_STRUCT *ads_s, - const char *os_name, const char *os_version ) -{ - ADS_STATUS status = ADS_ERROR(LDAP_SERVER_DOWN); - char *new_dn; - ADS_MODLIST mods; - LDAPMessage *res = NULL; - char *dn_string = NULL; - const char *machine_name = global_myname(); - int count; - char *os_sp = NULL; - - if ( !os_name || !os_version ) { - return ADS_ERROR(LDAP_NO_MEMORY); - } - - /* Find our DN */ - - status = ads_find_machine_acct(ads_s, &res, machine_name); - if (!ADS_ERR_OK(status)) - return status; - - if ( (count = ads_count_replies(ads_s, res)) != 1 ) { - DEBUG(1,("net_set_machine_spn: %d entries returned!\n", count)); - return ADS_ERROR(LDAP_NO_MEMORY); - } - - if ( (dn_string = ads_get_dn(ads_s, res)) == NULL ) { - DEBUG(1, ("ads_add_machine_acct: ads_get_dn returned NULL (malloc failure?)\n")); - goto done; - } - - new_dn = talloc_strdup(ctx, dn_string); - ads_memfree(ads_s, dn_string); - if (!new_dn) { - return ADS_ERROR(LDAP_NO_MEMORY); - } - - /* now do the mods */ - - if (!(mods = ads_init_mods(ctx))) { - goto done; - } - - os_sp = talloc_asprintf( ctx, "Samba %s", SAMBA_VERSION_STRING ); - - /* fields of primary importance */ - - ads_mod_str(ctx, &mods, "operatingSystem", os_name); - ads_mod_str(ctx, &mods, "operatingSystemVersion", os_version); - if ( os_sp ) - ads_mod_str(ctx, &mods, "operatingSystemServicePack", os_sp); - - status = ads_gen_mod(ads_s, new_dn, mods); - -done: - ads_msgfree(ads_s, res); - TALLOC_FREE( os_sp ); - - return status; -} - -/******************************************************************* - join a domain using ADS (LDAP mods) - ********************************************************************/ - -static ADS_STATUS net_precreate_machine_acct( ADS_STRUCT *ads, const char *ou ) -{ - ADS_STATUS rc = ADS_ERROR(LDAP_SERVER_DOWN); - char *ou_str = NULL; - char *dn = NULL; - LDAPMessage *res = NULL; - bool moved; - - ou_str = ads_ou_string(ads, ou); - if (asprintf(&dn, "%s,%s", ou_str, ads->config.bind_path) == -1) { - rc = ADS_ERROR(LDAP_NO_MEMORY); - goto done; - } - - rc = ads_search_dn(ads, &res, dn, NULL); - if (!ADS_ERR_OK(rc)) { - d_fprintf(stderr, "The specified OU does not exist.\n"); - goto done; - } - - /* Attempt to create the machine account and bail if this fails. - Assume that the admin wants exactly what they requested */ - - rc = ads_create_machine_acct( ads, global_myname(), dn ); - if (ADS_ERR_OK(rc)) { - DEBUG(1, ("machine account created\n")); - goto done; - } - if ( !(rc.error_type == ENUM_ADS_ERROR_LDAP && rc.err.rc == LDAP_ALREADY_EXISTS) ) { - DEBUG(1, ("machine account creation failed\n")); - goto done; - } - - rc = ads_move_machine_acct(ads, global_myname(), dn, &moved); - if (!ADS_ERR_OK(rc)) { - DEBUG(1, ("failure to locate/move pre-existing machine account\n")); - goto done; - } - - if (moved) { - d_printf("The machine account was moved into the specified OU.\n"); - } else { - d_printf("The machine account already exists in the specified OU.\n"); - } - -done: - ads_msgfree(ads, res); - SAFE_FREE( ou_str ); - SAFE_FREE( dn ); - - return rc; -} - -/************************************************************************ - ************************************************************************/ - -static bool net_derive_salting_principal( TALLOC_CTX *ctx, ADS_STRUCT *ads ) -{ - uint32 domain_func; - ADS_STATUS status; - fstring salt; - char *std_salt; - const char *machine_name = global_myname(); - - status = ads_domain_func_level( ads, &domain_func ); - if ( !ADS_ERR_OK(status) ) { - DEBUG(2,("Failed to determine domain functional level!\n")); - return False; - } - - /* go ahead and setup the default salt */ - - if ( (std_salt = kerberos_standard_des_salt()) == NULL ) { - d_fprintf(stderr, "net_derive_salting_principal: failed to obtain stanard DES salt\n"); - return False; - } - - fstrcpy( salt, std_salt ); - SAFE_FREE( std_salt ); - - /* if it's a Windows functional domain, we have to look for the UPN */ - - if ( domain_func == DS_DOMAIN_FUNCTION_2000 ) { - char *upn = ads_get_upn(ads, ctx, machine_name); - if ( upn ) { - fstrcpy( salt, upn ); - } - } - - return kerberos_secrets_store_des_salt( salt ); -} - /******************************************************************* Send a DNS update request *******************************************************************/ diff --git a/source3/utils/net_domain.c b/source3/utils/net_domain.c deleted file mode 100644 index 1a84c6cbc6..0000000000 --- a/source3/utils/net_domain.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - Samba Unix/Linux SMB client library - net ads commands - Copyright (C) 2001 Andrew Tridgell (tridge@samba.org) - Copyright (C) 2001 Remus Koos (remuskoos@yahoo.com) - Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com) - Copyright (C) 2006 Gerald (Jerry) Carter (jerry@samba.org) - Copyright (C) 2008 Guenther Deschner (gd@samba.org) - - 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 "includes.h" -#include "utils/net.h" - -/* Macro for checking RPC error codes to make things more readable */ - -#define CHECK_RPC_ERR(rpc, msg) \ - if (!NT_STATUS_IS_OK(result = rpc)) { \ - DEBUG(0, (msg ": %s\n", nt_errstr(result))); \ - goto done; \ - } - -#define CHECK_RPC_ERR_DEBUG(rpc, debug_args) \ - if (!NT_STATUS_IS_OK(result = rpc)) { \ - DEBUG(0, debug_args); \ - goto done; \ - } - -/******************************************************************* - Leave an AD domain. Windows XP disables the machine account. - We'll try the same. The old code would do an LDAP delete. - That only worked using the machine creds because added the machine - with full control to the computer object's ACL. -*******************************************************************/ - -NTSTATUS netdom_leave_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli, - DOM_SID *dom_sid ) -{ - struct rpc_pipe_client *pipe_hnd = NULL; - POLICY_HND sam_pol, domain_pol, user_pol; - NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - char *acct_name; - uint32 user_rid; - struct lsa_String lsa_acct_name; - struct samr_Ids user_rids; - struct samr_Ids name_types; - union samr_UserInfo *info = NULL; - - /* Open the domain */ - - if ( (pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &status)) == NULL ) { - DEBUG(0, ("Error connecting to SAM pipe. Error was %s\n", - nt_errstr(status) )); - return status; - } - - status = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, - SEC_RIGHTS_MAXIMUM_ALLOWED, - &sam_pol); - if ( !NT_STATUS_IS_OK(status) ) - return status; - - - status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, - &sam_pol, - SEC_RIGHTS_MAXIMUM_ALLOWED, - dom_sid, - &domain_pol); - if ( !NT_STATUS_IS_OK(status) ) - return status; - - /* Create domain user */ - - acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname()); - strlower_m(acct_name); - - init_lsa_String(&lsa_acct_name, acct_name); - - status = rpccli_samr_LookupNames(pipe_hnd, mem_ctx, - &domain_pol, - 1, - &lsa_acct_name, - &user_rids, - &name_types); - if ( !NT_STATUS_IS_OK(status) ) - return status; - - if ( name_types.ids[0] != SID_NAME_USER) { - DEBUG(0, ("%s is not a user account (type=%d)\n", acct_name, name_types.ids[0])); - return NT_STATUS_INVALID_WORKSTATION; - } - - user_rid = user_rids.ids[0]; - - /* Open handle on user */ - - status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx, - &domain_pol, - SEC_RIGHTS_MAXIMUM_ALLOWED, - user_rid, - &user_pol); - if ( !NT_STATUS_IS_OK(status) ) { - goto done; - } - - /* Get user info */ - - status = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx, - &user_pol, - 16, - &info); - if ( !NT_STATUS_IS_OK(status) ) { - rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); - goto done; - } - - /* now disable and setuser info */ - - info->info16.acct_flags |= ACB_DISABLED; - - status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, - &user_pol, - 16, - info); - - rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); - -done: - rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol); - rpccli_samr_Close(pipe_hnd, mem_ctx, &sam_pol); - - cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */ - - return status; -} - -/******************************************************************* - Store the machine password and domain SID - ********************************************************************/ - -int netdom_store_machine_account( const char *domain, DOM_SID *sid, const char *pw ) -{ - if (!secrets_store_domain_sid(domain, sid)) { - DEBUG(1,("Failed to save domain sid\n")); - return -1; - } - - if (!secrets_store_machine_password(pw, domain, SEC_CHAN_WKSTA)) { - DEBUG(1,("Failed to save machine password\n")); - return -1; - } - - return 0; -} - -/******************************************************************* - ********************************************************************/ - -NTSTATUS netdom_get_domain_sid( TALLOC_CTX *mem_ctx, struct cli_state *cli, - const char **domain, DOM_SID **sid ) -{ - struct rpc_pipe_client *pipe_hnd = NULL; - POLICY_HND lsa_pol; - NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - union lsa_PolicyInformation *info = NULL; - - if ( (pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &status)) == NULL ) { - DEBUG(0, ("Error connecting to LSA pipe. Error was %s\n", - nt_errstr(status) )); - return status; - } - - status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, - SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol); - if ( !NT_STATUS_IS_OK(status) ) - return status; - - status = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, - &lsa_pol, - LSA_POLICY_INFO_ACCOUNT_DOMAIN, - &info); - if ( !NT_STATUS_IS_OK(status) ) - return status; - - *domain = info->account_domain.name.string; - *sid = info->account_domain.sid; - - rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol); - cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */ - - /* Bail out if domain didn't get set. */ - if (!domain) { - DEBUG(0, ("Could not get domain name.\n")); - return NT_STATUS_UNSUCCESSFUL; - } - - return NT_STATUS_OK; -} - -/******************************************************************* - Do the domain join - ********************************************************************/ - -NTSTATUS netdom_join_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli, - DOM_SID *dom_sid, const char *clear_pw, - enum netdom_domain_t dom_type ) -{ - struct rpc_pipe_client *pipe_hnd = NULL; - POLICY_HND sam_pol, domain_pol, user_pol; - NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - char *acct_name; - struct lsa_String lsa_acct_name; - uint32 user_rid; - uint32 acb_info = ACB_WSTRUST; - uint32 acct_flags; - uchar pwbuf[532]; - struct MD5Context md5ctx; - uchar md5buffer[16]; - DATA_BLOB digested_session_key; - uchar md4_trust_password[16]; - uint32_t access_granted = 0; - struct samr_Ids user_rids; - struct samr_Ids name_types; - union samr_UserInfo info; - - /* Open the domain */ - - if ( (pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &status)) == NULL ) { - DEBUG(0, ("Error connecting to SAM pipe. Error was %s\n", - nt_errstr(status) )); - return status; - } - - status = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, - SEC_RIGHTS_MAXIMUM_ALLOWED, - &sam_pol); - if ( !NT_STATUS_IS_OK(status) ) - return status; - - - status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, - &sam_pol, - SEC_RIGHTS_MAXIMUM_ALLOWED, - dom_sid, - &domain_pol); - if ( !NT_STATUS_IS_OK(status) ) - return status; - - /* Create domain user */ - - acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname()); - strlower_m(acct_name); - - init_lsa_String(&lsa_acct_name, acct_name); - - /* Don't try to set any acb_info flags other than ACB_WSTRUST */ - acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE | - SEC_STD_WRITE_DAC | SEC_STD_DELETE | - SAMR_USER_ACCESS_SET_PASSWORD | - SAMR_USER_ACCESS_GET_ATTRIBUTES | - SAMR_USER_ACCESS_SET_ATTRIBUTES; - - DEBUG(10, ("Creating account with flags: %d\n",acct_flags)); - - status = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx, - &domain_pol, - &lsa_acct_name, - acb_info, - acct_flags, - &user_pol, - &access_granted, - &user_rid); - - if ( !NT_STATUS_IS_OK(status) - && !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) - { - d_fprintf(stderr, "Creation of workstation account failed\n"); - - /* If NT_STATUS_ACCESS_DENIED then we have a valid - username/password combo but the user does not have - administrator access. */ - - if (NT_STATUS_V(status) == NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) - d_fprintf(stderr, "User specified does not have administrator privileges\n"); - - return status; - } - - /* We *must* do this.... don't ask... */ - - if (NT_STATUS_IS_OK(status)) { - rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); - } - - status = rpccli_samr_LookupNames(pipe_hnd, mem_ctx, - &domain_pol, - 1, - &lsa_acct_name, - &user_rids, - &name_types); - if ( !NT_STATUS_IS_OK(status) ) - return status; - - if ( name_types.ids[0] != SID_NAME_USER) { - DEBUG(0, ("%s is not a user account (type=%d)\n", acct_name, name_types.ids[0])); - return NT_STATUS_INVALID_WORKSTATION; - } - - user_rid = user_rids.ids[0]; - - /* Open handle on user */ - - status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx, - &domain_pol, - SEC_RIGHTS_MAXIMUM_ALLOWED, - user_rid, - &user_pol); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - /* Create a random machine account password and generate the hash */ - - E_md4hash(clear_pw, md4_trust_password); - encode_pw_buffer(pwbuf, clear_pw, STR_UNICODE); - - generate_random_buffer((uint8*)md5buffer, sizeof(md5buffer)); - digested_session_key = data_blob_talloc(mem_ctx, 0, 16); - - MD5Init(&md5ctx); - MD5Update(&md5ctx, md5buffer, sizeof(md5buffer)); - MD5Update(&md5ctx, cli->user_session_key.data, cli->user_session_key.length); - MD5Final(digested_session_key.data, &md5ctx); - - SamOEMhashBlob(pwbuf, sizeof(pwbuf), &digested_session_key); - memcpy(&pwbuf[516], md5buffer, sizeof(md5buffer)); - - /* Fill in the additional account flags now */ - - acb_info |= ACB_PWNOEXP; - if ( dom_type == ND_TYPE_AD ) { -#if !defined(ENCTYPE_ARCFOUR_HMAC) - acb_info |= ACB_USE_DES_KEY_ONLY; -#endif - ;; - } - - /* Set password and account flags on machine account */ - ZERO_STRUCT(info.info25); - info.info25.info.fields_present = ACCT_NT_PWD_SET | - ACCT_LM_PWD_SET | - SAMR_FIELD_ACCT_FLAGS; - info.info25.info.acct_flags = acb_info; - memcpy(&info.info25.password.data, pwbuf, sizeof(pwbuf)); - - - status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, - &user_pol, - 25, - &info); - - if ( !NT_STATUS_IS_OK(status) ) { - d_fprintf( stderr, "Failed to set password for machine account (%s)\n", - nt_errstr(status)); - return status; - } - - rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); - cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */ - - return status; -} - -- cgit From 781e1ab4a1d9c5fe581034d42c9c597cd5d7be4d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 20:01:32 +0100 Subject: Re-enable _wkssvc_NetrJoinDomain2 remote join implementation now that we are ready for it. "netdom join SAMBAHOST" from a windows workstation nicely demonstrates it. Guenther (This used to be commit 3bcaa3582a101abc17f7c21128e01024af877577) --- source3/rpc_server/srv_wkssvc_nt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 43bd20d2d7..e559248ef8 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -281,11 +281,12 @@ WERROR _wkssvc_NetrGetJoinableOus(pipes_struct *p, struct wkssvc_NetrGetJoinable } /******************************************************************** + _wkssvc_NetrJoinDomain2 ********************************************************************/ -WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r) +WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, + struct wkssvc_NetrJoinDomain2 *r) { -#if 0 struct libnet_JoinCtx *j = NULL; char *cleartext_pwd = NULL; char *admin_domain = NULL; @@ -302,6 +303,8 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r if (!user_has_privileges(token, &se_machine_account) && !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) && !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) { + DEBUG(5,("_wkssvc_NetrJoinDomain2: account doesn't have " + "sufficient privileges\n")); return WERR_ACCESS_DENIED; } @@ -341,16 +344,20 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r j->in.join_flags = r->in.join_flags; j->in.admin_account = admin_account; j->in.admin_password = cleartext_pwd; - j->in.modify_config = true; + j->in.debug = true; become_root(); werr = libnet_Join(p->mem_ctx, j); unbecome_root(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(5,("_wkssvc_NetrJoinDomain2: libnet_Join gave %s\n", + j->out.error_string ? j->out.error_string : + dos_errstr(werr))); + } + + TALLOC_FREE(j); return werr; -#endif - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; } /******************************************************************** -- cgit From 37bca2ea57e2f2f13a9ab59d6fcd8f27052f65ef Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 21:55:01 +0100 Subject: While we are at it: add _wkssvc_NetrUnjoinDomain2 implementation. This can be tested with e.g. "netdom remove SAMBAHOST" from windows. Guenther (This used to be commit 53121e62ea32ff3a984533dca044b67cf5b2c55b) --- source3/rpc_server/srv_wkssvc_nt.c | 68 +++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index e559248ef8..6d03009d00 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -361,13 +361,73 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, } /******************************************************************** + _wkssvc_NetrUnjoinDomain2 ********************************************************************/ -WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, struct wkssvc_NetrUnjoinDomain2 *r) +WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, + struct wkssvc_NetrUnjoinDomain2 *r) { - /* FIXME: Add implementation code here */ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + struct libnet_UnjoinCtx *u = NULL; + char *cleartext_pwd = NULL; + char *admin_domain = NULL; + char *admin_account = NULL; + WERROR werr; + NTSTATUS status; + struct nt_user_token *token = p->pipe_user.nt_user_token; + struct netr_DsRGetDCNameInfo *info = NULL; + + if (!user_has_privileges(token, &se_machine_account) && + !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) && + !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) { + DEBUG(5,("_wkssvc_NetrUnjoinDomain2: account doesn't have " + "sufficient privileges\n")); + return WERR_ACCESS_DENIED; + } + + werr = decode_wkssvc_join_password_buffer(p->mem_ctx, + r->in.encrypted_password, + &p->session_key, + &cleartext_pwd); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + split_domain_user(p->mem_ctx, + r->in.account, + &admin_domain, + &admin_account); + + status = dsgetdcname(p->mem_ctx, + lp_realm(), + NULL, + NULL, + DS_DIRECTORY_SERVICE_REQUIRED | + DS_WRITABLE_REQUIRED | + DS_RETURN_DNS_NAME, + &info); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + werr = libnet_init_UnjoinCtx(p->mem_ctx, &u); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + u->in.dc_name = info->dc_unc; + u->in.domain_name = lp_realm(); + u->in.unjoin_flags = r->in.unjoin_flags | + WKSSVC_JOIN_FLAGS_JOIN_TYPE; + u->in.admin_account = admin_account; + u->in.admin_password = cleartext_pwd; + u->in.debug = true; + + become_root(); + werr = libnet_Unjoin(p->mem_ctx, u); + unbecome_root(); + + TALLOC_FREE(u); + return werr; } /******************************************************************** -- cgit From 76de025c724d68bef1b81c8ec6081db5e0f19c4a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Feb 2008 13:29:47 +0100 Subject: winbind: use a struct element for WBFLAG_PAM_UNIX_NAME To not conflict with WBFLAG_PAM_INFO3_TEXT. This should fix pam_winbind. metze (This used to be commit 1b8ed6c0ffb2548442bb7e9d848117ce9b1c65c0) --- source3/nsswitch/pam_winbind.c | 5 +++-- source3/nsswitch/winbind_struct_protocol.h | 1 + source3/utils/ntlm_auth.c | 2 +- source3/winbindd/winbindd_pam.c | 18 ++++-------------- 4 files changed, 9 insertions(+), 17 deletions(-) (limited to 'source3') diff --git a/source3/nsswitch/pam_winbind.c b/source3/nsswitch/pam_winbind.c index 89db0773ae..81f5227410 100644 --- a/source3/nsswitch/pam_winbind.c +++ b/source3/nsswitch/pam_winbind.c @@ -1341,9 +1341,10 @@ static int winbind_auth_request(pam_handle_t * pamh, /* If winbindd returned a username, return the pointer to it * here. */ - if (user_ret && response.extra_data.data) { + if (user_ret && response.data.auth.unix_username[0]) { /* We have to trust it's a null terminated string. */ - *user_ret = (char *)response.extra_data.data; + *user_ret = strndup(response.data.auth.unix_username, + sizeof(response.data.auth.unix_username) - 1); } } diff --git a/source3/nsswitch/winbind_struct_protocol.h b/source3/nsswitch/winbind_struct_protocol.h index 12ca1e55c8..e81813c77b 100644 --- a/source3/nsswitch/winbind_struct_protocol.h +++ b/source3/nsswitch/winbind_struct_protocol.h @@ -431,6 +431,7 @@ struct winbindd_response { fstring logon_srv; fstring logon_dom; } info3; + fstring unix_username; } auth; struct { fstring name; diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index 9e9da2a66f..df2bf9753b 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -418,7 +418,7 @@ NTSTATUS contact_winbind_auth_crap(const char *username, } if (flags & WBFLAG_PAM_UNIX_NAME) { - *unix_name = SMB_STRDUP((char *)response.extra_data.data); + *unix_name = SMB_STRDUP(response.data.auth.unix_username); if (!*unix_name) { winbindd_free_response(&response); return NT_STATUS_NO_MEMORY; diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c index 79b4c764c3..ef5a312eea 100644 --- a/source3/winbindd/winbindd_pam.c +++ b/source3/winbindd/winbindd_pam.c @@ -157,7 +157,6 @@ static NTSTATUS append_unix_username(TALLOC_CTX *mem_ctx, /* We've been asked to return the unix username, per 'winbind use default domain' settings and the like */ - fstring username_out; const char *nt_username, *nt_domain; nt_domain = talloc_strdup(mem_ctx, info3->base.domain.string); @@ -174,18 +173,11 @@ static NTSTATUS append_unix_username(TALLOC_CTX *mem_ctx, nt_username = name_user; } - fill_domain_username(username_out, nt_domain, nt_username, - True); + fill_domain_username(state->response.data.auth.unix_username, + nt_domain, nt_username, True); - DEBUG(5,("Setting unix username to [%s]\n", username_out)); - - SAFE_FREE(state->response.extra_data.data); - state->response.extra_data.data = SMB_STRDUP(username_out); - if (!state->response.extra_data.data) { - return NT_STATUS_NO_MEMORY; - } - state->response.length += - strlen((const char *)state->response.extra_data.data)+1; + DEBUG(5,("Setting unix username to [%s]\n", + state->response.data.auth.unix_username)); return NT_STATUS_OK; } @@ -736,14 +728,12 @@ failed: static bool check_request_flags(uint32_t flags) { uint32_t flags_edata = WBFLAG_PAM_AFS_TOKEN | - WBFLAG_PAM_UNIX_NAME | WBFLAG_PAM_INFO3_TEXT | WBFLAG_PAM_INFO3_NDR; if ( ( (flags & flags_edata) == WBFLAG_PAM_AFS_TOKEN) || ( (flags & flags_edata) == WBFLAG_PAM_INFO3_NDR) || ( (flags & flags_edata) == WBFLAG_PAM_INFO3_TEXT)|| - ( (flags & flags_edata) == WBFLAG_PAM_UNIX_NAME) || !(flags & flags_edata) ) { return True; } -- cgit From bddceee09a12e6308b5e27bf666d8948b2a894d1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 23:15:11 +0100 Subject: Fix memleak in netsamlogon_cache_get(). Guenther (This used to be commit b736c77dc6c36dcdb601903fadf0ef7f163052a3) --- source3/libsmb/samlogon_cache.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index 0d855f4c6c..73b570c383 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -226,6 +226,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const DOM_SID * if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0,("netsamlogon_cache_get: failed to pull entry from cache\n")); tdb_delete(netsamlogon_tdb, data); + TALLOC_FREE(info3); goto done; } -- cgit From a29b042204db84f5200f168896edfe14768080eb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 12:48:08 +0100 Subject: Remove DomainControllerAddressType which we now have in IDL. Guenther (This used to be commit 0a012c12d643e627ea1bad2a2ad6214f78918fa7) --- source3/include/ads.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3') diff --git a/source3/include/ads.h b/source3/include/ads.h index d1047bbdc2..d5ce88babe 100644 --- a/source3/include/ads.h +++ b/source3/include/ads.h @@ -319,11 +319,6 @@ typedef void **ADS_MODLIST; #define ADS_DNS_DOMAIN 0x40000000 /* DomainName is a DNS name */ #define ADS_DNS_FOREST 0x80000000 /* DnsForestName is a DNS name */ -/* DomainControllerAddressType */ -#define ADS_INET_ADDRESS 0x00000001 -#define ADS_NETBIOS_ADDRESS 0x00000002 - - /* ads auth control flags */ #define ADS_AUTH_DISABLE_KERBEROS 0x01 #define ADS_AUTH_NO_BIND 0x02 -- cgit From f610e1fa526e53425a71169b0a6c28905faed615 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Feb 2008 16:08:50 +0100 Subject: lsa.idl: don't use ascstr_noterm anymore metze (This used to be commit 1937d19623029cc4ac0f2c4b336b6460399fa509) --- source3/librpc/idl/lsa.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 68dc0497da..d25d93adc5 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -33,9 +33,9 @@ import "security.idl"; } lsa_Strings; typedef [public] struct { - [value(strlen_m(string))] uint16 length; - [value(strlen_m(string))] uint16 size; - ascstr_noterm *string; + [value(strlen(string))] uint16 length; + [value(strlen(string))] uint16 size; + [charset(DOS),size_is(size),length_is(length)] uint8 *string; } lsa_AsciiString; /******************/ -- cgit From 48bffb0f34d7ea3dd875094b33410fe048b61d4e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Feb 2008 14:56:07 +0100 Subject: lsa.idl: add lsa_AsciiStringLarge metze (This used to be commit bf5da9ea08f28f37aecc0674bd9322f0f0cbd82e) --- source3/librpc/idl/lsa.idl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index d25d93adc5..0079840366 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -38,6 +38,12 @@ import "security.idl"; [charset(DOS),size_is(size),length_is(length)] uint8 *string; } lsa_AsciiString; + typedef [public] struct { + [value(strlen(string))] uint16 length; + [value(strlen(string)+1)] uint16 size; + [charset(DOS),size_is(size),length_is(length)] uint8 *string; + } lsa_AsciiStringLarge; + /******************/ /* Function: 0x00 */ NTSTATUS lsa_Close ( -- cgit From 364ce40643c44085c016c2d9ad8e1bb02edf6a8a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Feb 2008 14:44:50 +0100 Subject: lsa.idl: use strlen_m_term() in lsa_StringLarge to support NULL strings metze (This used to be commit d98ac73122d44f3a92531b4ebbe09401652b89c7) --- source3/librpc/idl/lsa.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 0079840366..a705306fdc 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -23,7 +23,7 @@ import "security.idl"; typedef [public] struct { [value(2*strlen_m(string))] uint16 length; - [value(2*(strlen_m(string)+1))] uint16 size; + [value(2*strlen_m_term(string))] uint16 size; [charset(UTF16),size_is(size/2),length_is(length/2)] uint16 *string; } lsa_StringLarge; -- cgit From 5e7cc85a12ff08ab53d3c0a2fd22a45e332c4ab3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Feb 2008 14:47:22 +0100 Subject: lsa.idl: strlen_m*() also for the lsa_AsciiString* versions We already did this before b994f899b42d294c0418bdc82660a2f7510667d6. This is needed to handle NULL strings, where strlen() would crash... Maybe we should add a strlen_a() and strlen_a_term() later... metze (This used to be commit c445a17a91827c6c95b3a1cda9b78f5cdd41aa55) --- source3/librpc/idl/lsa.idl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index a705306fdc..ee8a2fe6b2 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -33,14 +33,14 @@ import "security.idl"; } lsa_Strings; typedef [public] struct { - [value(strlen(string))] uint16 length; - [value(strlen(string))] uint16 size; + [value(strlen_m(string))] uint16 length; + [value(strlen_m(string))] uint16 size; [charset(DOS),size_is(size),length_is(length)] uint8 *string; } lsa_AsciiString; typedef [public] struct { - [value(strlen(string))] uint16 length; - [value(strlen(string)+1)] uint16 size; + [value(strlen_m(string))] uint16 length; + [value(strlen_m_term(string))] uint16 size; [charset(DOS),size_is(size),length_is(length)] uint8 *string; } lsa_AsciiStringLarge; -- cgit From c7d0b8f3bac049b07bfe39a84a1edbf60113831d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Feb 2008 14:56:35 +0100 Subject: samr.idl: windows uses lsa_AsciiStringLarge in QueryDisplayInfo Tested with nt4 and w2k3. metze (This used to be commit 490d0c52bb117561227cbc59a15b15b688814fe2) --- source3/librpc/idl/samr.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/samr.idl b/source3/librpc/idl/samr.idl index ac0934d85c..c2449d3088 100644 --- a/source3/librpc/idl/samr.idl +++ b/source3/librpc/idl/samr.idl @@ -976,7 +976,7 @@ import "misc.idl", "lsa.idl", "security.idl"; typedef struct { uint32 idx; - lsa_AsciiString account_name; + lsa_AsciiStringLarge account_name; } samr_DispEntryAscii; typedef struct { -- cgit From de39bd20c1f2a674f7acd4ed4fa2527fdbff8aeb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 23:37:18 +0100 Subject: Re-run make idl. Guenther (This used to be commit 7d88cb2e8db8789b923d8f9979b5c9f65664d3eb) --- source3/librpc/gen_ndr/lsa.h | 10 ++- source3/librpc/gen_ndr/ndr_lsa.c | 135 ++++++++++++++++++++++++++++---------- source3/librpc/gen_ndr/ndr_lsa.h | 3 + source3/librpc/gen_ndr/ndr_samr.c | 10 +-- source3/librpc/gen_ndr/samr.h | 2 +- 5 files changed, 117 insertions(+), 43 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 0f0ed143eb..4fea08e99d 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -19,7 +19,7 @@ struct lsa_String { struct lsa_StringLarge { uint16_t length;/* [value(2*strlen_m(string))] */ - uint16_t size;/* [value(2*(strlen_m(string)+1))] */ + uint16_t size;/* [value(2*strlen_m_term(string))] */ const char *string;/* [unique,charset(UTF16),length_is(length/2),size_is(size/2)] */ }/* [public] */; @@ -31,7 +31,13 @@ struct lsa_Strings { struct lsa_AsciiString { uint16_t length;/* [value(strlen_m(string))] */ uint16_t size;/* [value(strlen_m(string))] */ - const char * string;/* [unique,flag(LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4)] */ + const char *string;/* [unique,charset(DOS),length_is(length),size_is(size)] */ +}/* [public] */; + +struct lsa_AsciiStringLarge { + uint16_t length;/* [value(strlen_m(string))] */ + uint16_t size;/* [value(strlen_m_term(string))] */ + const char *string;/* [unique,charset(DOS),length_is(length),size_is(size)] */ }/* [public] */; struct lsa_LUID { diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index 2a683fee77..03e1c21e55 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -80,12 +80,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_StringLarge(struct ndr_push *ndr, int nd if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 2 * strlen_m(r->string))); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 2 * (strlen_m(r->string) + 1))); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 2 * strlen_m_term(r->string))); NDR_CHECK(ndr_push_unique_ptr(ndr, r->string)); } if (ndr_flags & NDR_BUFFERS) { if (r->string) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2 * (strlen_m(r->string) + 1) / 2)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2 * strlen_m_term(r->string) / 2)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2 * strlen_m(r->string) / 2)); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->string, 2 * strlen_m(r->string) / 2, sizeof(uint16_t), CH_UTF16)); @@ -136,7 +136,7 @@ _PUBLIC_ void ndr_print_lsa_StringLarge(struct ndr_print *ndr, const char *name, ndr_print_struct(ndr, name, "lsa_StringLarge"); ndr->depth++; ndr_print_uint16(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * strlen_m(r->string):r->length); - ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * (strlen_m(r->string) + 1):r->size); + ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * strlen_m_term(r->string):r->size); ndr_print_ptr(ndr, "string", r->string); ndr->depth++; if (r->string) { @@ -238,21 +238,14 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_AsciiString(struct ndr_push *ndr, int nd NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m(r->string))); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m(r->string))); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->string)); - ndr->flags = _flags_save_string; - } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->string)); } if (ndr_flags & NDR_BUFFERS) { - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->string) { - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->string)); - } - ndr->flags = _flags_save_string; + if (r->string) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m(r->string))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m(r->string))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->string, strlen_m(r->string), sizeof(uint8_t), CH_DOS)); } } return NDR_ERR_SUCCESS; @@ -266,29 +259,30 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_AsciiString(struct ndr_pull *ndr, int nd NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_string)); - if (_ptr_string) { - NDR_PULL_ALLOC(ndr, r->string); - } else { - r->string = NULL; - } - ndr->flags = _flags_save_string; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_string)); + if (_ptr_string) { + NDR_PULL_ALLOC(ndr, r->string); + } else { + r->string = NULL; } } if (ndr_flags & NDR_BUFFERS) { - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_LEN4); - if (r->string) { - _mem_save_string_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->string, 0); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->string)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_string_0, 0); + if (r->string) { + _mem_save_string_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->string, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->string)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->string)); + if (ndr_get_array_length(ndr, &r->string) > ndr_get_array_size(ndr, &r->string)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->string), ndr_get_array_length(ndr, &r->string)); } - ndr->flags = _flags_save_string; + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->string, ndr_get_array_length(ndr, &r->string), sizeof(uint8_t), CH_DOS)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_string_0, 0); + } + if (r->string) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->string, r->size)); + } + if (r->string) { + NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->string, r->length)); } } return NDR_ERR_SUCCESS; @@ -309,6 +303,77 @@ _PUBLIC_ void ndr_print_lsa_AsciiString(struct ndr_print *ndr, const char *name, ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_lsa_AsciiStringLarge(struct ndr_push *ndr, int ndr_flags, const struct lsa_AsciiStringLarge *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m(r->string))); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m_term(r->string))); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->string)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m_term(r->string))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m(r->string))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->string, strlen_m(r->string), sizeof(uint8_t), CH_DOS)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_lsa_AsciiStringLarge(struct ndr_pull *ndr, int ndr_flags, struct lsa_AsciiStringLarge *r) +{ + uint32_t _ptr_string; + TALLOC_CTX *_mem_save_string_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_string)); + if (_ptr_string) { + NDR_PULL_ALLOC(ndr, r->string); + } else { + r->string = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + _mem_save_string_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->string, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->string)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->string)); + if (ndr_get_array_length(ndr, &r->string) > ndr_get_array_size(ndr, &r->string)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->string), ndr_get_array_length(ndr, &r->string)); + } + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->string, ndr_get_array_length(ndr, &r->string), sizeof(uint8_t), CH_DOS)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_string_0, 0); + } + if (r->string) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->string, r->size)); + } + if (r->string) { + NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->string, r->length)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_AsciiStringLarge(struct ndr_print *ndr, const char *name, const struct lsa_AsciiStringLarge *r) +{ + ndr_print_struct(ndr, name, "lsa_AsciiStringLarge"); + ndr->depth++; + ndr_print_uint16(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m(r->string):r->length); + ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m_term(r->string):r->size); + ndr_print_ptr(ndr, "string", r->string); + ndr->depth++; + if (r->string) { + ndr_print_string(ndr, "string", r->string); + } + ndr->depth--; + ndr->depth--; +} + static enum ndr_err_code ndr_push_lsa_LUID(struct ndr_push *ndr, int ndr_flags, const struct lsa_LUID *r) { if (ndr_flags & NDR_SCALARS) { diff --git a/source3/librpc/gen_ndr/ndr_lsa.h b/source3/librpc/gen_ndr/ndr_lsa.h index 2df42dbaea..a96f2d41b9 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.h +++ b/source3/librpc/gen_ndr/ndr_lsa.h @@ -188,6 +188,9 @@ void ndr_print_lsa_Strings(struct ndr_print *ndr, const char *name, const struct enum ndr_err_code ndr_push_lsa_AsciiString(struct ndr_push *ndr, int ndr_flags, const struct lsa_AsciiString *r); enum ndr_err_code ndr_pull_lsa_AsciiString(struct ndr_pull *ndr, int ndr_flags, struct lsa_AsciiString *r); void ndr_print_lsa_AsciiString(struct ndr_print *ndr, const char *name, const struct lsa_AsciiString *r); +enum ndr_err_code ndr_push_lsa_AsciiStringLarge(struct ndr_push *ndr, int ndr_flags, const struct lsa_AsciiStringLarge *r); +enum ndr_err_code ndr_pull_lsa_AsciiStringLarge(struct ndr_pull *ndr, int ndr_flags, struct lsa_AsciiStringLarge *r); +void ndr_print_lsa_AsciiStringLarge(struct ndr_print *ndr, const char *name, const struct lsa_AsciiStringLarge *r); void ndr_print_lsa_LUID(struct ndr_print *ndr, const char *name, const struct lsa_LUID *r); void ndr_print_lsa_PrivEntry(struct ndr_print *ndr, const char *name, const struct lsa_PrivEntry *r); void ndr_print_lsa_PrivArray(struct ndr_print *ndr, const char *name, const struct lsa_PrivArray *r); diff --git a/source3/librpc/gen_ndr/ndr_samr.c b/source3/librpc/gen_ndr/ndr_samr.c index 3549bfd22b..3af589f393 100644 --- a/source3/librpc/gen_ndr/ndr_samr.c +++ b/source3/librpc/gen_ndr/ndr_samr.c @@ -4124,10 +4124,10 @@ static enum ndr_err_code ndr_push_samr_DispEntryAscii(struct ndr_push *ndr, int if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->idx)); - NDR_CHECK(ndr_push_lsa_AsciiString(ndr, NDR_SCALARS, &r->account_name)); + NDR_CHECK(ndr_push_lsa_AsciiStringLarge(ndr, NDR_SCALARS, &r->account_name)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_lsa_AsciiString(ndr, NDR_BUFFERS, &r->account_name)); + NDR_CHECK(ndr_push_lsa_AsciiStringLarge(ndr, NDR_BUFFERS, &r->account_name)); } return NDR_ERR_SUCCESS; } @@ -4137,10 +4137,10 @@ static enum ndr_err_code ndr_pull_samr_DispEntryAscii(struct ndr_pull *ndr, int if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->idx)); - NDR_CHECK(ndr_pull_lsa_AsciiString(ndr, NDR_SCALARS, &r->account_name)); + NDR_CHECK(ndr_pull_lsa_AsciiStringLarge(ndr, NDR_SCALARS, &r->account_name)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_lsa_AsciiString(ndr, NDR_BUFFERS, &r->account_name)); + NDR_CHECK(ndr_pull_lsa_AsciiStringLarge(ndr, NDR_BUFFERS, &r->account_name)); } return NDR_ERR_SUCCESS; } @@ -4150,7 +4150,7 @@ _PUBLIC_ void ndr_print_samr_DispEntryAscii(struct ndr_print *ndr, const char *n ndr_print_struct(ndr, name, "samr_DispEntryAscii"); ndr->depth++; ndr_print_uint32(ndr, "idx", r->idx); - ndr_print_lsa_AsciiString(ndr, "account_name", &r->account_name); + ndr_print_lsa_AsciiStringLarge(ndr, "account_name", &r->account_name); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/samr.h b/source3/librpc/gen_ndr/samr.h index 700c46222d..c0e2d9d9a9 100644 --- a/source3/librpc/gen_ndr/samr.h +++ b/source3/librpc/gen_ndr/samr.h @@ -594,7 +594,7 @@ struct samr_DispInfoFullGroups { struct samr_DispEntryAscii { uint32_t idx; - struct lsa_AsciiString account_name; + struct lsa_AsciiStringLarge account_name; }; struct samr_DispInfoAscii { -- cgit From 700438dbbd45c8e097a74b98a56a0c97e241fa34 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 23:37:47 +0100 Subject: Fix samr querydispinfo w.r.t. lsa_AsciiStringLarge. Thanks metze for the fix. Guenther (This used to be commit dcffb885bc5d16e795b71d95e0790d3d7d70cf3c) --- source3/rpc_client/init_lsa.c | 9 +++++++++ source3/rpc_server/srv_samr_nt.c | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/init_lsa.c b/source3/rpc_client/init_lsa.c index fce382ed1b..2637158fd0 100644 --- a/source3/rpc_client/init_lsa.c +++ b/source3/rpc_client/init_lsa.c @@ -46,6 +46,15 @@ void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s) name->string = s; } +/******************************************************************* + inits a structure. +********************************************************************/ + +void init_lsa_AsciiStringLarge(struct lsa_AsciiStringLarge *name, const char *s) +{ + name->string = s; +} + /******************************************************************* Inits an lsa_QosInfo structure. ********************************************************************/ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f8b953904f..f38a8fcfc0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1318,8 +1318,8 @@ static NTSTATUS init_samr_dispinfo_4(TALLOC_CTX *ctx, for (i = 0; i < num_entries ; i++) { - init_lsa_AsciiString(&r->entries[i].account_name, - entries[i].account_name); + init_lsa_AsciiStringLarge(&r->entries[i].account_name, + entries[i].account_name); r->entries[i].idx = start_idx+i+1; } @@ -1354,8 +1354,8 @@ static NTSTATUS init_samr_dispinfo_5(TALLOC_CTX *ctx, for (i = 0; i < num_entries ; i++) { - init_lsa_AsciiString(&r->entries[i].account_name, - entries[i].account_name); + init_lsa_AsciiStringLarge(&r->entries[i].account_name, + entries[i].account_name); r->entries[i].idx = start_idx+i+1; } -- cgit From 29222fa551591a6a845cf6619a664a8e3877fa3c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 01:25:45 +0100 Subject: libnetjoin: Trying to avoid confusion between acct_flags, acb_info and access_desired. Guenther (This used to be commit 63894e5c93ef0663fc58bcc191777cd1aca7e21c) --- source3/libnet/libnet_join.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 38d98221b4..b8572f68b5 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -652,8 +652,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, NTSTATUS status = NT_STATUS_UNSUCCESSFUL; char *acct_name; struct lsa_String lsa_acct_name; - uint32 user_rid; - uint32 acb_info = ACB_WSTRUST; + uint32_t user_rid; + uint32_t acct_flags = ACB_WSTRUST; uchar pwbuf[532]; struct MD5Context md5ctx; uchar md5buffer[16]; @@ -690,7 +690,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, goto done; } - status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol); if (!NT_STATUS_IS_OK(status)) { goto done; @@ -757,7 +757,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, init_lsa_String(&lsa_acct_name, acct_name); if (r->in.join_flags & WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE) { - uint32_t acct_flags = + uint32_t access_desired = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE | SEC_STD_WRITE_DAC | SEC_STD_DELETE | SAMR_USER_ACCESS_SET_PASSWORD | @@ -765,15 +765,16 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, SAMR_USER_ACCESS_SET_ATTRIBUTES; uint32_t access_granted = 0; - /* Don't try to set any acb_info flags other than ACB_WSTRUST */ + /* Don't try to set any acct_flags flags other than ACB_WSTRUST */ - DEBUG(10,("Creating account with flags: %d\n", acct_flags)); + DEBUG(10,("Creating account with desired access mask: %d\n", + access_desired)); status = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx, &domain_pol, &lsa_acct_name, ACB_WSTRUST, - acct_flags, + access_desired, &user_pol, &access_granted, &user_rid); @@ -845,7 +846,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, E_md4hash(r->in.machine_password, md4_trust_password); encode_pw_buffer(pwbuf, r->in.machine_password, STR_UNICODE); - generate_random_buffer((uint8*)md5buffer, sizeof(md5buffer)); + generate_random_buffer((uint8_t*)md5buffer, sizeof(md5buffer)); digested_session_key = data_blob_talloc(mem_ctx, 0, 16); MD5Init(&md5ctx); @@ -859,10 +860,10 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, /* Fill in the additional account flags now */ - acb_info |= ACB_PWNOEXP; + acct_flags |= ACB_PWNOEXP; if (r->out.domain_is_ad) { #if !defined(ENCTYPE_ARCFOUR_HMAC) - acb_info |= ACB_USE_DES_KEY_ONLY; + acct_flags |= ACB_USE_DES_KEY_ONLY; #endif ;; } @@ -874,7 +875,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, user_info.info25.info.fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | SAMR_FIELD_ACCT_FLAGS; - user_info.info25.info.acct_flags = acb_info; + + user_info.info25.info.acct_flags = acct_flags; memcpy(&user_info.info25.password.data, pwbuf, sizeof(pwbuf)); status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx, @@ -1054,7 +1056,7 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx, POLICY_HND sam_pol, domain_pol, user_pol; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; char *acct_name; - uint32 user_rid; + uint32_t user_rid; struct lsa_String lsa_acct_name; struct samr_Ids user_rids; struct samr_Ids name_types; -- cgit From 53d55794dfbce06fcb40e5bdd81ca8a6dc1c4655 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 01:27:52 +0100 Subject: libnetjoin: add fallback to level 24 samr setinfo so that libnet can join NT4. Guenther (This used to be commit bc2d3d51449831146a9faf6e809e7a91d174659c) --- source3/libnet/libnet_join.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index b8572f68b5..1a8486f5b5 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -883,6 +883,25 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, &user_pol, 25, &user_info); + + if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) { + + uchar pwbuf2[516]; + + encode_pw_buffer(pwbuf2, r->in.machine_password, STR_UNICODE); + + /* retry with level 24 */ + init_samr_user_info24(&user_info.info24, pwbuf2, 24); + + SamOEMhashBlob(user_info.info24.password.data, 516, + &cli->user_session_key); + + status = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx, + &user_pol, + 24, + &user_info); + } + if (!NT_STATUS_IS_OK(status)) { libnet_join_set_error_string(mem_ctx, r, "Failed to set password for machine account (%s)\n", -- 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') 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 From d24f3b8a9367cb3903e1d76fa66a14389554da33 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 28 Feb 2008 21:43:06 +0100 Subject: libreplace: add extended getifaddrs test that prints out the interfaces. Michael cherry-picked from libreplace-part of 9d2bab09aac22c00fe23f1e1265a2dbd0901e9ce and adapted replacetort creation (This used to be commit 52d79ad4872a20cf55f31aba97629c2561bfc16c) --- source3/lib/replace/Makefile.in | 2 +- source3/lib/replace/test/getifaddrs.c | 96 +++++++++++++++++++++++++++++++++++ source3/lib/replace/test/testsuite.c | 9 ++-- 3 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 source3/lib/replace/test/getifaddrs.c (limited to 'source3') diff --git a/source3/lib/replace/Makefile.in b/source3/lib/replace/Makefile.in index af9522f3a6..c989835a8d 100644 --- a/source3/lib/replace/Makefile.in +++ b/source3/lib/replace/Makefile.in @@ -40,7 +40,7 @@ test: all installcheck: install test -TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o +TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o testsuite: libreplace.a $(TEST_OBJS) $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS) diff --git a/source3/lib/replace/test/getifaddrs.c b/source3/lib/replace/test/getifaddrs.c new file mode 100644 index 0000000000..66eed70268 --- /dev/null +++ b/source3/lib/replace/test/getifaddrs.c @@ -0,0 +1,96 @@ +/* + * Unix SMB/CIFS implementation. + * + * libreplace getifaddrs test + * + * Copyright (C) Michael Adam 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 . + */ + +#ifndef AUTOCONF_TEST +#include "replace.h" +#include "system/network.h" +#endif + +#ifdef HAVE_INET_NTOP +#define rep_inet_ntop inet_ntop +#endif + +static const char *format_sockaddr(struct sockaddr *addr, + char *addrstring, + socklen_t addrlen) +{ + const char *result = NULL; + + if (addr->sa_family == AF_INET) { + result = rep_inet_ntop(AF_INET, + &((struct sockaddr_in *)addr)->sin_addr, + addrstring, + addrlen); + } else if (addr->sa_family == AF_INET6) { + result = rep_inet_ntop(AF_INET6, + &((struct sockaddr_in6 *)addr)->sin6_addr, + addrstring, + addrlen); + } + return result; +} + +int getifaddrs_test(void) +{ + struct ifaddrs *ifs = NULL; + int ret; + + ret = getifaddrs(&ifs); + if (ret != 0) { + fprintf(stderr, "getifaddrs() failed: %s", strerror(errno)); + return 1; + } + + while (ifs) { + printf("%-10s ", ifs->ifa_name); + if (ifs->ifa_addr != NULL) { + char addrstring[INET6_ADDRSTRLEN]; + const char *result; + + result = format_sockaddr(ifs->ifa_addr, + addrstring, + sizeof(addrstring)); + if (result != NULL) { + printf("IP=%s ", addrstring); + } + + if (ifs->ifa_netmask != NULL) { + result = format_sockaddr(ifs->ifa_netmask, + addrstring, + sizeof(addrstring)); + if (result != NULL) { + printf("NETMASK=%s", addrstring); + } + } else { + printf("AF=%d ", ifs->ifa_addr->sa_family); + } + } else { + printf(""); + } + + printf("\n"); + ifs = ifs->ifa_next; + } + + freeifaddrs(ifs); + + return 0; +} diff --git a/source3/lib/replace/test/testsuite.c b/source3/lib/replace/test/testsuite.c index c9f3301005..b538360365 100644 --- a/source3/lib/replace/test/testsuite.c +++ b/source3/lib/replace/test/testsuite.c @@ -856,21 +856,18 @@ static int test_strptime(void) return libreplace_test_strptime(); } +extern int getifaddrs_test(void); + static int test_getifaddrs(void) { - struct ifaddrs *ifa; - int ret; printf("test: getifaddrs\n"); - ret = getifaddrs(&ifa); - if (ret != 0) { + if (getifaddrs_test() != 0) { printf("failure: getifaddrs\n"); return false; } - freeifaddrs(ifa); - printf("success: getifaddrs\n"); return true; } -- cgit From ca237a3ad31a8bba18297042df670e3a710ca10e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 28 Feb 2008 21:44:31 +0100 Subject: libreplace: use the new getifaddrs test also for autoconf. Michael (cherry picked from commit a2a506ff0eae2a64ebe2ddbb81a6c2a5fa7fe3da) (This used to be commit c5932414fdf0b568cbfe6cdefaec41c8afc8ca6b) --- source3/lib/replace/getifaddrs.c | 29 ----------------------------- source3/lib/replace/getifaddrs.m4 | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 33 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index 053657475d..551ff863df 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -363,32 +363,3 @@ int rep_getifaddrs(struct ifaddrs **ifap) return -1; } #endif - -#ifdef AUTOCONF_TEST -/* this is the autoconf driver to test getifaddrs() */ - - int main() -{ - struct ifaddrs *ifs = NULL; - int ret; - - ret = getifaddrs(&ifs); - if (ret != 0) { - perror("getifaddrs() failed"); - return 1; - } - - while (ifs) { - printf("%-10s ", ifs->ifa_name); - if (ifs->ifa_addr != NULL && - ifs->ifa_addr->sa_family == AF_INET) { - printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifa_addr)->sin_addr)); - if (ifs->ifa_netmask != NULL) - printf("NETMASK=%s", inet_ntoa(((struct sockaddr_in *)ifs->ifa_netmask)->sin_addr)); - } - printf("\n"); - ifs = ifs->ifa_next; - } - return 0; -} -#endif diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 767797e8d2..1fa168b59e 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -49,7 +49,10 @@ AC_TRY_RUN([ #define AUTOCONF_TEST 1 #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" -#include "$libreplacedir/getifaddrs.c"], +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) @@ -67,7 +70,10 @@ AC_TRY_RUN([ #undef _XOPEN_SOURCE_EXTENDED #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" -#include "$libreplacedir/getifaddrs.c"], +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) @@ -84,7 +90,10 @@ AC_TRY_RUN([ #define AUTOCONF_TEST 1 #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" -#include "$libreplacedir/getifaddrs.c"], +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) @@ -100,7 +109,10 @@ AC_TRY_RUN([ #define AUTOCONF_TEST 1 #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" -#include "$libreplacedir/getifaddrs.c"], +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) -- cgit From 39cae1d5b7dc987fd1457b5e4e4e9c15baf17086 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 00:06:55 +0100 Subject: libreplace: try and fix rep_getifaddrs() for Tru64. Don't fail when there is no address assigned to the interface. Put NULL into the ifaddrs structure instead. Michael (cherry picked from commit ee170c85e0e76411bd752de5fe51db6940dab929) (This used to be commit 650cc1da4b4404880389c583dbb07ce86df48576) --- source3/lib/replace/getifaddrs.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index 551ff863df..f66bf800eb 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -109,38 +109,33 @@ int rep_getifaddrs(struct ifaddrs **ifap) /* Loop through interfaces, looking for given IP address */ for (i=n-1; i>=0; i--) { - if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) { + if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) == -1) { freeifaddrs(*ifap); + return -1; } curif = calloc(1, sizeof(struct ifaddrs)); - if (lastif == NULL) { - *ifap = curif; - } else { - lastif->ifa_next = curif; - } - curif->ifa_name = strdup(ifr[i].ifr_name); - curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); + curif->ifa_flags = ifr[i].ifr_flags; curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; curif->ifa_next = NULL; - curif->ifa_netmask = NULL; - - if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) != 0) { - freeifaddrs(*ifap); - return -1; - } - curif->ifa_flags = ifr[i].ifr_flags; - - if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) { - freeifaddrs(*ifap); - return -1; - } + curif->ifa_addr = NULL + if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != -1) { + curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); + } - curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr); + curif->ifa_netmask = NULL; + if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != -1) { + curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr); + } + if (lastif == NULL) { + *ifap = curif; + } else { + lastif->ifa_next = curif; + } lastif = curif; } -- cgit From 539c4df84b21b6c45a91bd0b83c6e387b0829858 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 01:25:54 +0100 Subject: libreplace: add missing semicolon to getifaddrs. Michael (cherry picked from commit 29818a07de826fd687003ff25865d77939ecaa9a) (This used to be commit 1d906d346ed90b87895772a64c7613324ef8b682) --- source3/lib/replace/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index f66bf800eb..adc2517e5c 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -121,7 +121,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) curif->ifa_data = NULL; curif->ifa_next = NULL; - curif->ifa_addr = NULL + curif->ifa_addr = NULL; if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != -1) { curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); } -- cgit From 3be85e76a82c4d67a66e2c6e86a7a9d5c394815f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 01:49:30 +0100 Subject: libreplace: add missing newline in output of getifaddrs test. Michael (cherry picked from commit f8243cfc47c7414bab7f249d0e5d1c85e8ca7d64) (This used to be commit 3c1843f931b896dd3bb142346ecb44c0fb9202d6) --- source3/lib/replace/test/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/test/getifaddrs.c b/source3/lib/replace/test/getifaddrs.c index 66eed70268..4455462193 100644 --- a/source3/lib/replace/test/getifaddrs.c +++ b/source3/lib/replace/test/getifaddrs.c @@ -55,7 +55,7 @@ int getifaddrs_test(void) ret = getifaddrs(&ifs); if (ret != 0) { - fprintf(stderr, "getifaddrs() failed: %s", strerror(errno)); + fprintf(stderr, "getifaddrs() failed: %s\n", strerror(errno)); return 1; } -- cgit From b6578dc7fedcb98186940dc82d8faccac552a361 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:22:02 +0100 Subject: libreplace: fix silly crashbug in getifaddrs_test(). Michael (cherry picked from commit 523626908d25f974fd1ae6d7306b1d4bc8414162) (This used to be commit 0906120a6e4fe0eb66f3c3fd99c625b30672cb2b) --- source3/lib/replace/test/getifaddrs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/replace/test/getifaddrs.c b/source3/lib/replace/test/getifaddrs.c index 4455462193..c78c9b545e 100644 --- a/source3/lib/replace/test/getifaddrs.c +++ b/source3/lib/replace/test/getifaddrs.c @@ -51,9 +51,11 @@ static const char *format_sockaddr(struct sockaddr *addr, int getifaddrs_test(void) { struct ifaddrs *ifs = NULL; + struct ifaddrs *ifs_head = NULL; int ret; ret = getifaddrs(&ifs); + ifs_head = ifs; if (ret != 0) { fprintf(stderr, "getifaddrs() failed: %s\n", strerror(errno)); return 1; @@ -90,7 +92,7 @@ int getifaddrs_test(void) ifs = ifs->ifa_next; } - freeifaddrs(ifs); + freeifaddrs(ifs_head); return 0; } -- cgit From 5827e84d88c0216c9e9e2373378b6992ce8357c5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:23:29 +0100 Subject: libreplace: fix rep_freeifaddrs to not segfault on NULL input. Michael (cherry picked from commit 0cbb87453beb52c6b0bc3a48791f49678f4030c5) (This used to be commit 34d906ef44d1a5c3452097a9cac438d721fe35c1) --- source3/lib/replace/getifaddrs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index adc2517e5c..f6f0ec080c 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -44,13 +44,14 @@ void rep_freeifaddrs(struct ifaddrs *ifp) { - free(ifp->ifa_name); - free(ifp->ifa_addr); - free(ifp->ifa_netmask); - free(ifp->ifa_dstaddr); - if (ifp->ifa_next != NULL) + if (ifp != NULL) { + free(ifp->ifa_name); + free(ifp->ifa_addr); + free(ifp->ifa_netmask); + free(ifp->ifa_dstaddr); freeifaddrs(ifp->ifa_next); - free(ifp); + free(ifp); + } } static struct sockaddr *sockaddr_dup(struct sockaddr *sa) -- cgit From a73f4bc27f79f7920a881fcb0050621119591e64 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:43:24 +0100 Subject: libreplace: ifdef out ip6 code if unsupported. Michael (cherry picked from commit 54cc0df4dbf6d63a9b94e1ac6af4ec7f7803bc30) (This used to be commit 1ff0b616a9cb029040031f797b52112d4973e1eb) --- source3/lib/replace/test/getifaddrs.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/test/getifaddrs.c b/source3/lib/replace/test/getifaddrs.c index c78c9b545e..8b00ac2f40 100644 --- a/source3/lib/replace/test/getifaddrs.c +++ b/source3/lib/replace/test/getifaddrs.c @@ -39,11 +39,13 @@ static const char *format_sockaddr(struct sockaddr *addr, &((struct sockaddr_in *)addr)->sin_addr, addrstring, addrlen); +#ifdef HAVE_STRUCT_SOCKADDR_IN6 } else if (addr->sa_family == AF_INET6) { result = rep_inet_ntop(AF_INET6, &((struct sockaddr_in6 *)addr)->sin6_addr, addrstring, addrlen); +#endif } return result; } -- cgit From 71f74cfc67e8954698467aa630156b0435894abc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:46:14 +0100 Subject: libreplace: add snprintf.c to test code for getifaddrs - needed on some systems. Michael (cherry picked from commit 0aff54a12e20d5e91fcdec7aaec103fb9a371a23) (This used to be commit 77b7d7c0417e498340d1c9364fbbb8671c175477) --- source3/lib/replace/getifaddrs.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3') diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4 index 1fa168b59e..6cca155de3 100644 --- a/source3/lib/replace/getifaddrs.m4 +++ b/source3/lib/replace/getifaddrs.m4 @@ -50,6 +50,7 @@ AC_TRY_RUN([ #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" #include "$libreplacedir/getifaddrs.c" #define getifaddrs_test main #include "$libreplacedir/test/getifaddrs.c"], @@ -71,6 +72,7 @@ AC_TRY_RUN([ #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" #include "$libreplacedir/getifaddrs.c" #define getifaddrs_test main #include "$libreplacedir/test/getifaddrs.c"], @@ -91,6 +93,7 @@ AC_TRY_RUN([ #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" #include "$libreplacedir/getifaddrs.c" #define getifaddrs_test main #include "$libreplacedir/test/getifaddrs.c"], @@ -110,6 +113,7 @@ AC_TRY_RUN([ #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" #include "$libreplacedir/getifaddrs.c" #define getifaddrs_test main #include "$libreplacedir/test/getifaddrs.c"], -- cgit From bab27a2ff2600ebfba244cc18a07658ded1ef312 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 09:40:09 +0100 Subject: Fix creation of replacetort. Forgot to git add Makefile.in before doing git commit --amend in previous commit... Michael (This used to be commit 7cf645cdae8ce17705036951538991b0a9dbefaf) --- source3/Makefile.in | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 63328ec86e..7ab0c4fb37 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -902,6 +902,7 @@ TALLOCTORT_OBJ = @tallocdir@/testsuite.o $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(ERRORMAP_OBJ) REPLACETORT_OBJ = lib/replace/test/testsuite.o \ + lib/replace/test/getifaddrs.o \ lib/replace/test/os2_delete.o \ lib/replace/test/strptime.o \ $(LIBREPLACE_OBJ) -- cgit From 18206a4cb52fba13253339c1b166d3df27345380 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 21 Feb 2008 16:14:08 +0100 Subject: Add vfs_aio_fork This is used for two purposes: First, I'm using it to test the async I/O code. In the forked process it is pretty easy to delay a reply for a random amount of time. See the BUILD_FARM_HACKS snippet. Second, there are systems around that claim to have Posix AIO but which is broken. This might be some help for those systems. Also add tests how to pass file descriptors (This used to be commit b0e52cecf2009d4c7f29412dadf17910e54e4327) --- source3/Makefile.in | 5 + source3/configure.in | 51 +++ source3/modules/vfs_aio_fork.c | 728 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 784 insertions(+) create mode 100644 source3/modules/vfs_aio_fork.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 7ab0c4fb37..2f963e295d 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -601,6 +601,7 @@ VFS_NOTIFY_FAM_OBJ = modules/vfs_notify_fam.o VFS_READAHEAD_OBJ = modules/vfs_readahead.o VFS_TSMSM_OBJ = modules/vfs_tsmsm.o VFS_FILEID_OBJ = modules/vfs_fileid.o +VFS_AIO_FORK_OBJ = modules/vfs_aio_fork.o VFS_SYNCOPS_OBJ = modules/vfs_syncops.o PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o @@ -1854,6 +1855,10 @@ bin/fileid.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_FILEID_OBJ) @echo "Building plugin $@" @$(SHLD_MODULE) $(VFS_FILEID_OBJ) +bin/aio_fork.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_AIO_FORK_OBJ) + @echo "Building plugin $@" + @$(SHLD_MODULE) $(VFS_AIO_FORK_OBJ) + ######################################################### ## IdMap NSS plugins diff --git a/source3/configure.in b/source3/configure.in index 5de8a289db..495da90c33 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -809,6 +809,56 @@ if test x"$samba_cv_unixsocket" = x"yes"; then AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixsocket support]) fi +############################################# +# check for fd passing struct via msg_control +AC_CACHE_CHECK([for fd passing via msg_control],samba_cv_msghdr_msg_control, [ + AC_TRY_COMPILE([ +#include +#include +#include +#include +#include ], +[ + struct msghdr msg; + union { + struct cmsghdr cm; + char control[CMSG_SPACE(sizeof(int))]; + } control_un; + msg.msg_control = control_un.control; + msg.msg_controllen = sizeof(control_un.control); +], + samba_cv_msghdr_msg_control=yes,samba_cv_msghdr_msg_control=no)]) +if test x"$samba_cv_msghdr_msg_control" = x"yes"; then + AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL,1, + [If we can use msg_control for passing file descriptors]) +fi + +############################################# +# check for fd passing struct via msg_acctrights +AC_CACHE_CHECK([for fd passing via msg_acctrights], + samba_cv_msghdr_msg_acctrights, [ + AC_TRY_COMPILE([ +#include +#include +#include +#include +#include ], +[ + struct msghdr msg; + int fd; + msg.msg_acctrights = (caddr_t) &fd; + msg.msg_acctrightslen = sizeof(fd); +], + samba_cv_msghdr_msg_acctrights=yes,samba_cv_msghdr_msg_acctrights=no)]) +if test x"$samba_cv_msghdr_msg_acctrights" = x"yes"; then + AC_DEFINE(HAVE_MSGHDR_MSG_ACCTRIGHTS,1, + [If we can use msg_acctrights for passing file descriptors]) +fi + +if test x"$samba_cv_msghdr_msg_control" = x"yes" -o \ + x"$samba_cv_msghdr_msg_acctright" = x"yes"; then + default_shared_modules="$default_shared_modules vfs_aio_fork" +fi AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ AC_TRY_COMPILE([ @@ -6038,6 +6088,7 @@ SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS) SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS) SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS) SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS) +SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS) SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS) SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS) SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS) diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c new file mode 100644 index 0000000000..21f63d0b87 --- /dev/null +++ b/source3/modules/vfs_aio_fork.c @@ -0,0 +1,728 @@ +/* + * Simulate the Posix AIO using mmap/fork + * + * Copyright (C) Volker Lendecke 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 2 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +struct mmap_area { + size_t size; + volatile void *ptr; +}; + +static int mmap_area_destructor(struct mmap_area *area) +{ + munmap((void *)area->ptr, area->size); + return 0; +} + +static struct mmap_area *mmap_area_init(TALLOC_CTX *mem_ctx, size_t size) +{ + struct mmap_area *result; + int fd; + + result = talloc(mem_ctx, struct mmap_area); + if (result == NULL) { + DEBUG(0, ("talloc failed\n")); + goto fail; + } + + fd = open("/dev/zero", O_RDWR); + if (fd == -1) { + DEBUG(3, ("open(\"/dev/zero\") failed: %s\n", + strerror(errno))); + goto fail; + } + + result->ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, + MAP_SHARED|MAP_FILE, fd, 0); + if (result->ptr == MAP_FAILED) { + DEBUG(1, ("mmap failed: %s\n", strerror(errno))); + goto fail; + } + + result->size = size; + talloc_set_destructor(result, mmap_area_destructor); + + return result; + +fail: + TALLOC_FREE(result); + return NULL; +} + +struct rw_cmd { + size_t n; + SMB_OFF_T offset; + bool read_cmd; +}; + +struct rw_ret { + ssize_t size; + int ret_errno; +}; + +struct aio_child_list; + +struct aio_child { + struct aio_child *prev, *next; + struct aio_child_list *list; + SMB_STRUCT_AIOCB *aiocb; + pid_t pid; + int sockfd; + struct fd_event *sock_event; + struct rw_ret retval; + struct mmap_area *map; /* ==NULL means write request */ + bool dont_delete; /* Marked as in use since last cleanup */ + bool cancelled; + bool read_cmd; +}; + +struct aio_child_list { + struct aio_child *children; + struct timed_event *cleanup_event; +}; + +static void free_aio_children(void **p) +{ + TALLOC_FREE(*p); +} + +static ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd) +{ + struct msghdr msg; + struct iovec iov[1]; + ssize_t n; +#ifndef HAVE_MSGHDR_MSG_CONTROL + int newfd; +#endif + +#ifdef HAVE_MSGHDR_MSG_CONTROL + union { + struct cmsghdr cm; + char control[CMSG_SPACE(sizeof(int))]; + } control_un; + struct cmsghdr *cmptr; + + msg.msg_control = control_un.control; + msg.msg_controllen = sizeof(control_un.control); +#else +#if HAVE_MSGHDR_MSG_ACCTRIGHTS + msg.msg_accrights = (caddr_t) &newfd; + msg.msg_accrightslen = sizeof(int); +#else +#error Can not pass file descriptors +#endif +#endif + + msg.msg_name = NULL; + msg.msg_namelen = 0; + + iov[0].iov_base = ptr; + iov[0].iov_len = nbytes; + msg.msg_iov = iov; + msg.msg_iovlen = 1; + + if ( (n = recvmsg(fd, &msg, 0)) <= 0) { + return(n); + } + +#ifdef HAVE_MSGHDR_MSG_CONTROL + if ((cmptr = CMSG_FIRSTHDR(&msg)) != NULL + && cmptr->cmsg_len == CMSG_LEN(sizeof(int))) { + if (cmptr->cmsg_level != SOL_SOCKET) { + DEBUG(10, ("control level != SOL_SOCKET")); + errno = EINVAL; + return -1; + } + if (cmptr->cmsg_type != SCM_RIGHTS) { + DEBUG(10, ("control type != SCM_RIGHTS")); + errno = EINVAL; + return -1; + } + *recvfd = *((int *) CMSG_DATA(cmptr)); + } else { + *recvfd = -1; /* descriptor was not passed */ + } +#else + if (msg.msg_accrightslen == sizeof(int)) { + *recvfd = newfd; + } + else { + *recvfd = -1; /* descriptor was not passed */ + } +#endif + + return(n); +} + +static ssize_t write_fd(int fd, void *ptr, size_t nbytes, int sendfd) +{ + struct msghdr msg; + struct iovec iov[1]; + +#ifdef HAVE_MSGHDR_MSG_CONTROL + union { + struct cmsghdr cm; + char control[CMSG_SPACE(sizeof(int))]; + } control_un; + struct cmsghdr *cmptr; + + ZERO_STRUCT(msg); + ZERO_STRUCT(control_un); + + msg.msg_control = control_un.control; + msg.msg_controllen = sizeof(control_un.control); + + cmptr = CMSG_FIRSTHDR(&msg); + cmptr->cmsg_len = CMSG_LEN(sizeof(int)); + cmptr->cmsg_level = SOL_SOCKET; + cmptr->cmsg_type = SCM_RIGHTS; + *((int *) CMSG_DATA(cmptr)) = sendfd; +#else + ZERO_STRUCT(msg); + msg.msg_accrights = (caddr_t) &sendfd; + msg.msg_accrightslen = sizeof(int); +#endif + + msg.msg_name = NULL; + msg.msg_namelen = 0; + + ZERO_STRUCT(iov); + iov[0].iov_base = ptr; + iov[0].iov_len = nbytes; + msg.msg_iov = iov; + msg.msg_iovlen = 1; + + return (sendmsg(fd, &msg, 0)); +} + +static void aio_child_cleanup(struct event_context *event_ctx, + struct timed_event *te, + const struct timeval *now, + void *private_data) +{ + struct aio_child_list *list = talloc_get_type_abort( + private_data, struct aio_child_list); + struct aio_child *child, *next; + + TALLOC_FREE(list->cleanup_event); + + for (child = list->children; child != NULL; child = next) { + next = child->next; + + if (child->aiocb != NULL) { + DEBUG(10, ("child %d currently active\n", + (int)child->pid)); + continue; + } + + if (child->dont_delete) { + DEBUG(10, ("Child %d was active since last cleanup\n", + (int)child->pid)); + child->dont_delete = false; + continue; + } + + DEBUG(10, ("Child %d idle for more than 30 seconds, " + "deleting\n", (int)child->pid)); + + TALLOC_FREE(child); + } + + if (list->children != NULL) { + /* + * Re-schedule the next cleanup round + */ + list->cleanup_event = event_add_timed(smbd_event_context(), list, + timeval_add(now, 30, 0), + "aio_child_cleanup", + aio_child_cleanup, list); + + } +} + +static struct aio_child_list *init_aio_children(struct vfs_handle_struct *handle) +{ + struct aio_child_list *data = NULL; + + if (SMB_VFS_HANDLE_TEST_DATA(handle)) { + SMB_VFS_HANDLE_GET_DATA(handle, data, struct aio_child_list, + return NULL); + } + + if (data == NULL) { + data = TALLOC_ZERO_P(NULL, struct aio_child_list); + if (data == NULL) { + return NULL; + } + } + + /* + * Regardless of whether the child_list had been around or not, make + * sure that we have a cleanup timed event. This timed event will + * delete itself when it finds that no children are around anymore. + */ + + if (data->cleanup_event == NULL) { + data->cleanup_event = event_add_timed(smbd_event_context(), data, + timeval_current_ofs(30, 0), + "aio_child_cleanup", + aio_child_cleanup, data); + if (data->cleanup_event == NULL) { + TALLOC_FREE(data); + return NULL; + } + } + + if (!SMB_VFS_HANDLE_TEST_DATA(handle)) { + SMB_VFS_HANDLE_SET_DATA(handle, data, free_aio_children, + struct aio_child_list, return False); + } + + return data; +} + +static void aio_child_loop(int sockfd, struct mmap_area *map) +{ + while (true) { + int fd = -1; + ssize_t ret; + struct rw_cmd cmd_struct; + struct rw_ret ret_struct; + + ret = read_fd(sockfd, &cmd_struct, sizeof(cmd_struct), &fd); + if (ret != sizeof(cmd_struct)) { + DEBUG(10, ("read_fd returned %d: %s\n", (int)ret, + strerror(errno))); + exit(1); + } + + DEBUG(10, ("aio_child_loop: %s %d bytes at %d from fd %d\n", + cmd_struct.read_cmd ? "read" : "write", + (int)cmd_struct.n, (int)cmd_struct.offset, fd)); + +#ifdef ENABLE_BUILD_FARM_HACKS + { + /* + * In the build farm, we want erratic behaviour for + * async I/O times + */ + uint8_t randval; + unsigned msecs; + /* + * use generate_random_buffer, we just forked from a + * common parent state + */ + generate_random_buffer(&randval, sizeof(randval)); + msecs = randval + 20; + DEBUG(10, ("delaying for %u msecs\n", msecs)); + smb_msleep(msecs); + } +#endif + + + ZERO_STRUCT(ret_struct); + + if (cmd_struct.read_cmd) { + ret_struct.size = sys_pread( + fd, (void *)map->ptr, cmd_struct.n, + cmd_struct.offset); + } + else { + ret_struct.size = sys_pwrite( + fd, (void *)map->ptr, cmd_struct.n, + cmd_struct.offset); + } + + DEBUG(10, ("aio_child_loop: syscall returned %d\n", + (int)ret_struct.size)); + + if (ret_struct.size == -1) { + ret_struct.ret_errno = errno; + } + + ret = write_data(sockfd, (char *)&ret_struct, + sizeof(ret_struct)); + if (ret != sizeof(ret_struct)) { + DEBUG(10, ("could not write ret_struct: %s\n", + strerror(errno))); + exit(2); + } + + close(fd); + } +} + +static void handle_aio_completion(struct event_context *event_ctx, + struct fd_event *event, uint16 flags, + void *p) +{ + struct aio_child *child = (struct aio_child *)p; + uint16 mid; + + DEBUG(10, ("handle_aio_completion called with flags=%d\n", flags)); + + if ((flags & EVENT_FD_READ) == 0) { + return; + } + + if (!NT_STATUS_IS_OK(read_data(child->sockfd, + (char *)&child->retval, + sizeof(child->retval)))) { + DEBUG(0, ("aio child %d died\n", (int)child->pid)); + child->retval.size = -1; + child->retval.ret_errno = EIO; + } + + if (child->cancelled) { + child->aiocb = NULL; + child->cancelled = false; + return; + } + + if (child->read_cmd && (child->retval.size > 0)) { + SMB_ASSERT(child->retval.size <= child->aiocb->aio_nbytes); + memcpy((void *)child->aiocb->aio_buf, (void *)child->map->ptr, + child->retval.size); + } + + mid = child->aiocb->aio_sigevent.sigev_value.sival_int; + + DEBUG(10, ("mid %d finished\n", (int)mid)); + + aio_request_done(mid); + process_aio_queue(); +} + +static int aio_child_destructor(struct aio_child *child) +{ + SMB_ASSERT((child->aiocb == NULL) || child->cancelled); + close(child->sockfd); + DLIST_REMOVE(child->list->children, child); + return 0; +} + +static NTSTATUS create_aio_child(struct aio_child_list *children, + size_t map_size, + struct aio_child **presult) +{ + struct aio_child *result; + int fdpair[2]; + NTSTATUS status; + + fdpair[0] = fdpair[1] = -1; + + result = TALLOC_ZERO_P(children, struct aio_child); + NT_STATUS_HAVE_NO_MEMORY(result); + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fdpair) == -1) { + status = map_nt_error_from_unix(errno); + DEBUG(10, ("socketpair() failed: %s\n", strerror(errno))); + TALLOC_FREE(result); + goto fail; + } + + DEBUG(10, ("fdpair = %d/%d\n", fdpair[0], fdpair[1])); + + result->map = mmap_area_init(result, map_size); + if (result->map == NULL) { + status = map_nt_error_from_unix(errno); + DEBUG(0, ("Could not create mmap area\n")); + goto fail; + } + + result->pid = sys_fork(); + if (result->pid == -1) { + status = map_nt_error_from_unix(errno); + DEBUG(0, ("fork failed: %s\n", strerror(errno))); + goto fail; + } + + if (result->pid == 0) { + close(fdpair[0]); + result->sockfd = fdpair[1]; + aio_child_loop(result->sockfd, result->map); + } + + DEBUG(10, ("Child %d created\n", result->pid)); + + result->sockfd = fdpair[0]; + close(fdpair[1]); + + result->sock_event = event_add_fd(smbd_event_context(), result, + result->sockfd, EVENT_FD_READ, + handle_aio_completion, + result); + if (result->sock_event == NULL) { + status = NT_STATUS_NO_MEMORY; + DEBUG(0, ("event_add_fd failed\n")); + goto fail; + } + + result->list = children; + DLIST_ADD(children->children, result); + + talloc_set_destructor(result, aio_child_destructor); + + *presult = result; + + return NT_STATUS_OK; + + fail: + if (fdpair[0] != -1) close(fdpair[0]); + if (fdpair[1] != -1) close(fdpair[1]); + TALLOC_FREE(result); + + return status; +} + +static NTSTATUS get_idle_child(struct vfs_handle_struct *handle, + struct aio_child **pchild) +{ + struct aio_child_list *children; + struct aio_child *child; + NTSTATUS status; + + children = init_aio_children(handle); + if (children == NULL) { + return NT_STATUS_NO_MEMORY; + } + + for (child = children->children; child != NULL; child = child->next) { + if (child->aiocb == NULL) { + /* idle */ + break; + } + } + + if (child == NULL) { + DEBUG(10, ("no idle child found, creating new one\n")); + + status = create_aio_child(children, 128*1024, &child); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("create_aio_child failed: %s\n", + nt_errstr(status))); + return status; + } + } + + child->dont_delete = true; + + *pchild = child; + return NT_STATUS_OK; +} + +static int aio_fork_read(struct vfs_handle_struct *handle, + struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) +{ + struct aio_child *child; + struct rw_cmd cmd; + ssize_t ret; + NTSTATUS status; + + if (aiocb->aio_nbytes > 128*1024) { + /* TODO: support variable buffers */ + errno = EINVAL; + return -1; + } + + status = get_idle_child(handle, &child); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("Could not get an idle child\n")); + return -1; + } + + child->read_cmd = true; + child->aiocb = aiocb; + child->retval.ret_errno = EINPROGRESS; + + ZERO_STRUCT(cmd); + cmd.n = aiocb->aio_nbytes; + cmd.offset = aiocb->aio_offset; + cmd.read_cmd = child->read_cmd; + + DEBUG(10, ("sending fd %d to child %d\n", fsp->fh->fd, + (int)child->pid)); + + ret = write_fd(child->sockfd, &cmd, sizeof(cmd), fsp->fh->fd); + if (ret == -1) { + DEBUG(10, ("write_fd failed: %s\n", strerror(errno))); + return -1; + } + + return 0; +} + +static int aio_fork_write(struct vfs_handle_struct *handle, + struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) +{ + struct aio_child *child; + struct rw_cmd cmd; + ssize_t ret; + NTSTATUS status; + + if (aiocb->aio_nbytes > 128*1024) { + /* TODO: support variable buffers */ + errno = EINVAL; + return -1; + } + + status = get_idle_child(handle, &child); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("Could not get an idle child\n")); + return -1; + } + + child->read_cmd = false; + child->aiocb = aiocb; + child->retval.ret_errno = EINPROGRESS; + + memcpy((void *)child->map->ptr, (void *)aiocb->aio_buf, + aiocb->aio_nbytes); + + ZERO_STRUCT(cmd); + cmd.n = aiocb->aio_nbytes; + cmd.offset = aiocb->aio_offset; + cmd.read_cmd = child->read_cmd; + + DEBUG(10, ("sending fd %d to child %d\n", fsp->fh->fd, + (int)child->pid)); + + ret = write_fd(child->sockfd, &cmd, sizeof(cmd), fsp->fh->fd); + if (ret == -1) { + DEBUG(10, ("write_fd failed: %s\n", strerror(errno))); + return -1; + } + + return 0; +} + +static struct aio_child *aio_fork_find_child(struct vfs_handle_struct *handle, + SMB_STRUCT_AIOCB *aiocb) +{ + struct aio_child_list *children; + struct aio_child *child; + + children = init_aio_children(handle); + if (children == NULL) { + return NULL; + } + + for (child = children->children; child != NULL; child = child->next) { + if (child->aiocb == aiocb) { + return child; + } + } + + return NULL; +} + +static ssize_t aio_fork_return_fn(struct vfs_handle_struct *handle, + struct files_struct *fsp, + SMB_STRUCT_AIOCB *aiocb) +{ + struct aio_child *child = aio_fork_find_child(handle, aiocb); + + if (child == NULL) { + errno = EINVAL; + DEBUG(0, ("returning EINVAL\n")); + return -1; + } + + child->aiocb = NULL; + + if (child->retval.size == -1) { + errno = child->retval.ret_errno; + } + + return child->retval.size; +} + +static int aio_fork_cancel(struct vfs_handle_struct *handle, + struct files_struct *fsp, + SMB_STRUCT_AIOCB *aiocb) +{ + struct aio_child_list *children; + struct aio_child *child; + + children = init_aio_children(handle); + if (children == NULL) { + errno = EINVAL; + return -1; + } + + for (child = children->children; child != NULL; child = child->next) { + if (child->aiocb == NULL) { + continue; + } + if (child->aiocb->aio_fildes != fsp->fh->fd) { + continue; + } + if ((aiocb != NULL) && (child->aiocb != aiocb)) { + continue; + } + + /* + * We let the child do its job, but we discard the result when + * it's finished. + */ + + child->cancelled = true; + } + + return AIO_CANCELED; +} + +static int aio_fork_error_fn(struct vfs_handle_struct *handle, + struct files_struct *fsp, + SMB_STRUCT_AIOCB *aiocb) +{ + struct aio_child *child = aio_fork_find_child(handle, aiocb); + + if (child == NULL) { + errno = EINVAL; + return -1; + } + + return child->retval.ret_errno; +} + +/* VFS operations structure */ + +static vfs_op_tuple aio_fork_ops[] = { + {SMB_VFS_OP(aio_fork_read), SMB_VFS_OP_AIO_READ, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(aio_fork_write), SMB_VFS_OP_AIO_WRITE, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(aio_fork_return_fn), SMB_VFS_OP_AIO_RETURN, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(aio_fork_cancel), SMB_VFS_OP_AIO_CANCEL, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(aio_fork_error_fn), SMB_VFS_OP_AIO_ERROR, + SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, + SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_aio_fork_init(void); +NTSTATUS vfs_aio_fork_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, + "aio_fork", aio_fork_ops); +} -- cgit From 8657066f3ad942f5596ef14e0f071b8dbfcd5554 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 29 Feb 2008 09:25:18 +0100 Subject: configure: Remove lib/repdir.c and related stuff It was only used in configure, but lib/replace already has a much better version of it. metze (This used to be commit c9b60b75b4763c37cfa63741b4f055e4ea488e92) --- source3/configure.in | 18 ---- source3/lib/repdir.c | 217 --------------------------------------------- source3/tests/os2_delete.c | 214 -------------------------------------------- 3 files changed, 449 deletions(-) delete mode 100644 source3/lib/repdir.c delete mode 100644 source3/tests/os2_delete.c (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 495da90c33..9970647bf8 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2631,24 +2631,6 @@ if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken]) fi -AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[ - AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"], - [samba_cv_HAVE_BROKEN_READDIR=no], - [samba_cv_HAVE_BROKEN_READDIR=yes], - [samba_cv_HAVE_BROKEN_READDIR="assuming not"])]) - -if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then -AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[ - AC_TRY_RUN([ -#include "${srcdir-.}/lib/repdir.c" -#include "${srcdir-.}/tests/os2_delete.c"], - samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)]) -fi - -if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then - AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) -fi - SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX) SMB_CHECK_SYSCONF(_SC_NPROC_ONLN) SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN) diff --git a/source3/lib/repdir.c b/source3/lib/repdir.c deleted file mode 100644 index 08f7d16a81..0000000000 --- a/source3/lib/repdir.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Andrew Tridgell 2005 - Updated for Samba3 64-bit cleanliness (C) Jeremy Allison 2006 - - 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 . -*/ -/* - a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems - - This is needed because the existing directory handling in FreeBSD - and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink() - on files in a directory where telldir() has been used. On a block - boundary it will occasionally miss a file when seekdir() is used to - return to a position previously recorded with telldir(). - - This also fixes a severe performance and memory usage problem with - telldir() on BSD systems. Each call to telldir() in BSD adds an - entry to a linked list, and those entries are cleaned up on - closedir(). This means with a large directory closedir() can take an - arbitrary amount of time, causing network timeouts as millions of - telldir() entries are freed - - Note! This replacement code is not portable. It relies on getdents() - always leaving the file descriptor at a seek offset that is a - multiple of DIR_BUF_SIZE. If the code detects that this doesn't - happen then it will abort(). It also does not handle directories - with offsets larger than can be stored in a long, - - This code is available under other free software licenses as - well. Contact the author. -*/ - -#include - - void replace_readdir_dummy(void); - void replace_readdir_dummy(void) {} - -#if defined(REPLACE_READDIR) - -#if defined(PARANOID_MALLOC_CHECKER) -#ifdef malloc -#undef malloc -#endif -#endif - -#define DIR_BUF_BITS 9 -#define DIR_BUF_SIZE (1<fd = open64(dname, O_RDONLY); -#else - d->fd = open(dname, O_RDONLY); -#endif - - if (d->fd == -1) { - free(d); - return NULL; - } - d->ofs = 0; - d->seekpos = 0; - d->nbytes = 0; - return (SMB_STRUCT_DIR *)d; -} - -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_READDIR64) - SMB_STRUCT_DIRENT *readdir64(SMB_STRUCT_DIR *dir) -#else - SMB_STRUCT_DIRENT *readdir(SMB_STRUCT_DIR *dir) -#endif -{ - struct dir_buf *d = (struct dir_buf *)dir; - SMB_STRUCT_DIRENT *de; - - if (d->ofs >= d->nbytes) { -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_LSEEK64) - d->seekpos = lseek64(d->fd, 0, SEEK_CUR); -#else - d->seekpos = lseek(d->fd, 0, SEEK_CUR); -#endif - -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_GETDENTS64) - d->nbytes = getdents64(d->fd, d->buf, DIR_BUF_SIZE); -#else - d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); -#endif - d->ofs = 0; - } - if (d->ofs >= d->nbytes) { - return NULL; - } - de = (SMB_STRUCT_DIRENT *)&d->buf[d->ofs]; - d->ofs += de->d_reclen; - return de; -} - -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_TELLDIR64) - long telldir64(SMB_STRUCT_DIR *dir) -#else - long telldir(SMB_STRUCT_DIR *dir) -#endif -{ - struct dir_buf *d = (struct dir_buf *)dir; - if (d->ofs >= d->nbytes) { -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_LSEEK64) - d->seekpos = lseek64(d->fd, 0, SEEK_CUR); -#else - d->seekpos = lseek(d->fd, 0, SEEK_CUR); -#endif - d->ofs = 0; - d->nbytes = 0; - } - /* this relies on seekpos always being a multiple of - DIR_BUF_SIZE. Is that always true on BSD systems? */ - if (d->seekpos & (DIR_BUF_SIZE-1)) { - abort(); - } - return d->seekpos + d->ofs; -} - -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_SEEKDIR64) - void seekdir64(SMB_STRUCT_DIR *dir, long ofs) -#else - void seekdir(SMB_STRUCT_DIR *dir, long ofs) -#endif -{ - struct dir_buf *d = (struct dir_buf *)dir; -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_LSEEK64) - d->seekpos = lseek64(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); -#else - d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); -#endif - -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_GETDENTS64) - d->nbytes = getdents64(d->fd, d->buf, DIR_BUF_SIZE); -#else - d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); -#endif - - d->ofs = 0; - while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_READDIR64) - if (readdir64(dir) == NULL) break; -#else - if (readdir(dir) == NULL) break; -#endif - } -} - -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_REWINDDIR64) - void rewinddir64(SMB_STRUCT_DIR *dir) -#else - void rewinddir(SMB_STRUCT_DIR *dir) -#endif -{ -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_SEEKDIR64) - seekdir64(dir, 0); -#else - seekdir(dir, 0); -#endif -} - -#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_CLOSEDIR64) - int closedir64(SMB_STRUCT_DIR *dir) -#else - int closedir(SMB_STRUCT_DIR *dir) -#endif -{ - struct dir_buf *d = (struct dir_buf *)dir; - int r = close(d->fd); - if (r != 0) { - return r; - } - free(d); - return 0; -} - -#ifndef dirfd -/* darn, this is a macro on some systems. */ - int dirfd(SMB_STRUCT_DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - return d->fd; -} -#endif -#endif /* REPLACE_READDIR */ diff --git a/source3/tests/os2_delete.c b/source3/tests/os2_delete.c deleted file mode 100644 index b3aaf67f41..0000000000 --- a/source3/tests/os2_delete.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - test readdir/unlink pattern that OS/2 uses - tridge@samba.org July 2005 -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_FILES 700 -#define READDIR_SIZE 100 -#define DELETE_SIZE 4 - -#define TESTDIR "test.dir" - -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -static void cleanup(void) -{ - /* I'm a lazy bastard */ - system("rm -rf " TESTDIR); - mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); -} - -static void create_files() -{ - int i; - for (i=0;id_name); - } - - if (i == 0) { - return 0; - } - - /* delete the first few */ - for (j=0; jd_name, ".") == 0 || FAILED("match ."); - de = readdir(d); - strcmp(de->d_name, "..") == 0 || FAILED("match .."); - - while (1) { - int n = os2_delete(d); - if (n == 0) break; - total_deleted += n; - } - closedir(d); - - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); - - rmdir(TESTDIR) == 0 || FAILED("rmdir"); - - return 0; -} -/* - test readdir/unlink pattern that OS/2 uses - tridge@samba.org July 2005 -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_FILES 700 -#define READDIR_SIZE 100 -#define DELETE_SIZE 4 - -#define TESTDIR "test.dir" - -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -static void cleanup(void) -{ - /* I'm a lazy bastard */ - system("rm -rf " TESTDIR); - mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); -} - -static void create_files() -{ - int i; - for (i=0;id_name); - } - - if (i == 0) { - return 0; - } - - /* delete the first few */ - for (j=0; jd_name, ".") == 0 || FAILED("match ."); - de = readdir(d); - strcmp(de->d_name, "..") == 0 || FAILED("match .."); - - while (1) { - int n = os2_delete(d); - if (n == 0) break; - total_deleted += n; - } - closedir(d); - - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); - - rmdir(TESTDIR) == 0 || FAILED("rmdir"); - - return 0; -} -- cgit From 85b7f90c47828618ea0ce825d8af20d8acd793b7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 29 Feb 2008 09:58:37 +0100 Subject: configure: only build vfs_syncops if dirfd() is available This hopefully fixes the build on HP-UX. metze (This used to be commit 5fb7533e37b6c682e019b1c3515dc6befc8bda09) --- source3/configure.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 9970647bf8..5254c8bba7 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -401,7 +401,7 @@ dnl These have to be built static: default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs2 rpc_netlogon rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template" dnl These are preferably build shared, and static if dlopen() is not available -default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_syncops vfs_xattr_tdb vfs_streams_xattr" +default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb vfs_streams_xattr" if test "x$developer" = xyes; then default_static_modules="$default_static_modules rpc_rpcecho" @@ -860,6 +860,11 @@ if test x"$samba_cv_msghdr_msg_control" = x"yes" -o \ default_shared_modules="$default_shared_modules vfs_aio_fork" fi +AC_CHECK_FUNCS(dirfd) +if test x"$ac_cv_func_dirfd" = x"yes"; then + default_shared_modules="$default_shared_modules vfs_syncops" +fi + AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ AC_TRY_COMPILE([ #include -- cgit From 695b6662abe64a40061bfa05ede12173fc4b1945 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 29 Feb 2008 10:17:35 +0100 Subject: Attempt to fix the build (This used to be commit 364d87a5e41045808ebd28f46c5c0c93bd13a7da) --- source3/configure.in | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 5254c8bba7..f481a30b3b 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -855,11 +855,6 @@ if test x"$samba_cv_msghdr_msg_acctrights" = x"yes"; then [If we can use msg_acctrights for passing file descriptors]) fi -if test x"$samba_cv_msghdr_msg_control" = x"yes" -o \ - x"$samba_cv_msghdr_msg_acctright" = x"yes"; then - default_shared_modules="$default_shared_modules vfs_aio_fork" -fi - AC_CHECK_FUNCS(dirfd) if test x"$ac_cv_func_dirfd" = x"yes"; then default_shared_modules="$default_shared_modules vfs_syncops" -- cgit From 4688f2600b3c6bc501fe7e5ed65032ff6212f498 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 12:38:29 +0100 Subject: Fix linking of smbget when there is no shared library support. smbget needs libwbclient. Michael (This used to be commit 78bc496ecf72b5c2474911302e81a90c488e3070) --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 2f963e295d..35a448016e 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -733,7 +733,7 @@ PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) @LIB $(SECRETS_OBJ) $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) libsmb/asn1.o \ $(RPC_PARSE_OBJ1) $(DOSERR_OBJ) $(LDB_OBJ) $(ERRORMAP_OBJ) -SMBGET_OBJ = utils/smbget.o $(POPT_LIB_OBJ) $(LIBSMBCLIENT_OBJ0) +SMBGET_OBJ = utils/smbget.o $(POPT_LIB_OBJ) $(LIBSMBCLIENT_OBJ0) @LIBWBCLIENT_STATIC@ DISPLAY_SEC_OBJ= lib/display_sec.o -- cgit From 1751b533f00ca75082b452ca9922c2c8f277be4b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 28 Feb 2008 14:06:11 +0100 Subject: Rename the 'hidden' variable to 'administrative share'. (This used to be commit eff3d3bad5a8860b99375cc0be9dc24f3679e416) --- source3/param/loadparm.c | 10 +++++----- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index e23c30789a..5651a435de 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -420,7 +420,7 @@ typedef struct { bool bRead_only; bool bNo_set_dir; bool bGuest_only; - bool bHidden; + bool bAdministrative_share; bool bGuest_ok; bool bPrint_ok; bool bMap_system; @@ -563,7 +563,7 @@ static service sDefault = { True, /* bRead_only */ True, /* bNo_set_dir */ False, /* bGuest_only */ - False, /* bHidden */ + False, /* bAdministrative_share */ False, /* bGuest_ok */ False, /* bPrint_ok */ False, /* bMap_system */ @@ -973,7 +973,7 @@ static struct parm_struct parm_table[] = { {"inherit owner", P_BOOL, P_LOCAL, &sDefault.bInheritOwner, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE}, {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, FLAG_HIDE}, - {"hidden", P_BOOL, P_LOCAL, &sDefault.bHidden, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT}, + {"administrative share", P_BOOL, P_LOCAL, &sDefault.bAdministrative_share, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT}, {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT}, {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_HIDE}, @@ -2140,7 +2140,7 @@ FN_LOCAL_BOOL(lp_readonly, bRead_only) FN_LOCAL_BOOL(lp_no_set_dir, bNo_set_dir) FN_LOCAL_BOOL(lp_guest_ok, bGuest_ok) FN_LOCAL_BOOL(lp_guest_only, bGuest_only) -FN_LOCAL_BOOL(lp_hidden, bHidden) +FN_LOCAL_BOOL(lp_administrative_share, bAdministrative_share) FN_LOCAL_BOOL(lp_print_ok, bPrint_ok) FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden) FN_LOCAL_BOOL(lp_map_archive, bMap_archive) @@ -2778,7 +2778,7 @@ static bool lp_add_ipc(const char *ipc_name, bool guest_ok) ServicePtrs[i]->bAvailable = True; ServicePtrs[i]->bRead_only = True; ServicePtrs[i]->bGuest_only = False; - ServicePtrs[i]->bHidden = True; + ServicePtrs[i]->bAdministrative_share = True; ServicePtrs[i]->bGuest_ok = guest_ok; ServicePtrs[i]->bPrint_ok = False; ServicePtrs[i]->bBrowseable = sDefault.bBrowseable; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 37bd204f75..8a25b6cfd5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -232,7 +232,7 @@ static uint32 get_share_type(int snum) type = STYPE_PRINTQ; if (strequal(lp_fstype(snum), "IPC")) type = STYPE_IPC; - if (lp_hidden(snum)) + if (lp_administrative_share(snum)) type |= STYPE_HIDDEN; return type; -- cgit From d40b891eb0fa29d34fa3ecfbc00110154a12ffc6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 13:15:56 +0100 Subject: Revert "Add libnet_join.idl to the IDL files to be processed by "make idl"." This reverts commit 9b47a7329091b2bfe7cd9b2112ac8fa652ed9f60. libnet_join.idl should not be processed along with the other idl files since it should not produce server and client code, just the header. Michael (This used to be commit 2967b29f23e04f24a62ea576b0b6c948055689d0) --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 35a448016e..c6815e91e6 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1130,7 +1130,7 @@ modules: SHOWFLAGS $(MODULES) IDL_FILES = lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \ epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \ - dssetup.idl krb5pac.idl ntsvcs.idl libnet_join.idl + dssetup.idl krb5pac.idl ntsvcs.idl idl: @IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \ -- cgit From af3e746d9e79f96d004b0f50760b4918ce57eb3a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 13:17:18 +0100 Subject: Revert "make idl: Only compile idl files newer than the output to be generated." This reverts commit 79c199d16e565eabd9fd971247f8df62689bb92a. Revert this until pidl is capable of doing decent dependency tracking itself (importing types from imported idls). Michael (This used to be commit 1fb69ad1f5c79dd77f73a5fee266e1e363e6974d) --- source3/script/build_idl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/script/build_idl.sh b/source3/script/build_idl.sh index 39a63573b9..7aaddc70c7 100755 --- a/source3/script/build_idl.sh +++ b/source3/script/build_idl.sh @@ -23,7 +23,7 @@ for f in ${IDL_FILES}; do basename=`basename $f .idl` ndr="librpc/gen_ndr/ndr_$basename.c" - if [ -f $ndr ] ; then + if [ -f $ndr ] && false; then if [ "x`find librpc/idl/$f -newer $ndr -print`" = "xlibrpc/idl/$f" ]; then list="$list librpc/idl/$f" fi -- cgit From e9c2515df0ac92e275da3dcd62de6cc50009bf6e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 13:35:16 +0100 Subject: Eliminate tons of build warnings on non-IPV6 system. Michael (This used to be commit ee4810099c2d26a0ebab3c41a95bc6b57921683d) --- source3/include/includes.h | 5 +++++ source3/lib/util_sock.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/include/includes.h b/source3/include/includes.h index 269baa5a9c..36c71d7533 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -1289,4 +1289,9 @@ void exit_server_fault(void) NORETURN_ATTRIBUTE ; #include "libnscd.h" #endif +#if defined(HAVE_IPV6) +void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss, + struct in6_addr ip); +#endif + #endif /* _INCLUDES_H */ diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index a7c35c4887..2a65943872 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -370,7 +370,7 @@ void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss, Convert an IPv6 struct in_addr to a struct sockaddr_storage. ********************************************************************/ -void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss, + void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss, struct in6_addr ip) { struct sockaddr_in6 *sa = (struct sockaddr_in6 *)ss; -- cgit From 6346ab79a61be7325fdf3f16ac7f002f8128050c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Feb 2008 05:51:09 -0800 Subject: Fix part of bug #3617 from valgrind trace. "Invalid read of size 1" errors. Jeremy. (This used to be commit d954a4954ba8ed6cb2c6074176a6008cfa398dd7) --- source3/nmbd/nmbd_namelistdb.c | 1 - source3/nmbd/nmbd_nameregister.c | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c index f9cbcf4f59..6570fd4ec7 100644 --- a/source3/nmbd/nmbd_namelistdb.c +++ b/source3/nmbd/nmbd_namelistdb.c @@ -297,7 +297,6 @@ void standard_success_register(struct subnet_record *subrec, ******************************************************************/ void standard_fail_register( struct subnet_record *subrec, - struct response_record *rrec, struct nmb_name *nmbname ) { struct name_record *namerec; diff --git a/source3/nmbd/nmbd_nameregister.c b/source3/nmbd/nmbd_nameregister.c index edcf258519..98f129aa89 100644 --- a/source3/nmbd/nmbd_nameregister.c +++ b/source3/nmbd/nmbd_nameregister.c @@ -152,10 +152,11 @@ static void register_name_response(struct subnet_record *subrec, if( rrec->success_fn) (*(register_name_success_function)rrec->success_fn)(subrec, rrec->userdata, answer_name, nb_flags, ttl, register_ip); } else { + struct nmb_name qname = *question_name; if( rrec->fail_fn) (*(register_name_fail_function)rrec->fail_fn)(subrec, rrec, question_name); /* Remove the name. */ - standard_fail_register( subrec, rrec, question_name); + standard_fail_register( subrec, &qname); } /* Ensure we don't retry. */ @@ -280,10 +281,11 @@ static void register_name_timeout_response(struct subnet_record *subrec, if( rrec->success_fn) (*(register_name_success_function)rrec->success_fn)(subrec, rrec->userdata, question_name, nb_flags, ttl, registered_ip); } else { + struct nmb_name qname = *question_name; if( rrec->fail_fn) (*(register_name_fail_function)rrec->fail_fn)(subrec, rrec, question_name); /* Remove the name. */ - standard_fail_register( subrec, rrec, question_name); + standard_fail_register( subrec, &qname); } /* Ensure we don't retry. */ -- cgit From f12770079bcf21a3fc3e493504443ea203c95004 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 14:51:37 +0100 Subject: Pure cosmetics, trying to get my group policy diff smaller. Gunther (This used to be commit d7346e9360ffa97e44fa781293d32c707436193b) --- source3/libgpo/gpo_fetch.c | 35 ++++++++++++----------------------- source3/libgpo/gpo_filesync.c | 4 ++-- source3/libgpo/gpo_ini.c | 4 ++-- source3/libgpo/gpo_ldap.c | 12 ++++++------ source3/libgpo/gpo_sec.c | 8 ++++---- 5 files changed, 26 insertions(+), 37 deletions(-) (limited to 'source3') diff --git a/source3/libgpo/gpo_fetch.c b/source3/libgpo/gpo_fetch.c index 916db2b3d3..2ec066425b 100644 --- a/source3/libgpo/gpo_fetch.c +++ b/source3/libgpo/gpo_fetch.c @@ -44,15 +44,18 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx, if (!next_token_talloc(mem_ctx, &file_sys_path, server, "\\")) { return NT_STATUS_INVALID_PARAMETER; } + NT_STATUS_HAVE_NO_MEMORY(*server); if (!next_token_talloc(mem_ctx, &file_sys_path, service, "\\")) { return NT_STATUS_INVALID_PARAMETER; } + NT_STATUS_HAVE_NO_MEMORY(*service); if ((*nt_path = talloc_asprintf(mem_ctx, "\\%s", file_sys_path)) == NULL) { return NT_STATUS_NO_MEMORY; } + NT_STATUS_HAVE_NO_MEMORY(*nt_path); if ((path = talloc_asprintf(mem_ctx, "%s/%s", @@ -65,9 +68,8 @@ NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - if ((*unix_path = talloc_strdup(mem_ctx, path)) == NULL) { - return NT_STATUS_NO_MEMORY; - } + *unix_path = talloc_strdup(mem_ctx, path); + NT_STATUS_HAVE_NO_MEMORY(*unix_path); TALLOC_FREE(path); return NT_STATUS_OK; @@ -124,36 +126,23 @@ NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx, result = gpo_explode_filesyspath(mem_ctx, gpo->file_sys_path, &server, &service, &nt_path, &unix_path); - if (!NT_STATUS_IS_OK(result)) { - goto out; - } + NT_STATUS_NOT_OK_RETURN(result); result = gpo_prepare_local_store(mem_ctx, unix_path); - if (!NT_STATUS_IS_OK(result)) { - goto out; - } + NT_STATUS_NOT_OK_RETURN(result); unix_ini_path = talloc_asprintf(mem_ctx, "%s/%s", unix_path, GPT_INI); nt_ini_path = talloc_asprintf(mem_ctx, "%s\\%s", nt_path, GPT_INI); - if (!unix_path || !nt_ini_path) { - result = NT_STATUS_NO_MEMORY; - goto out; - } + NT_STATUS_HAVE_NO_MEMORY(unix_ini_path); + NT_STATUS_HAVE_NO_MEMORY(nt_ini_path); result = gpo_copy_file(mem_ctx, cli, nt_ini_path, unix_ini_path); - if (!NT_STATUS_IS_OK(result)) { - goto out; - } + NT_STATUS_NOT_OK_RETURN(result); result = gpo_sync_directories(mem_ctx, cli, nt_path, unix_path); - if (!NT_STATUS_IS_OK(result)) { - goto out; - } + NT_STATUS_NOT_OK_RETURN(result); - result = NT_STATUS_OK; - - out: - return result; + return NT_STATUS_OK; } /**************************************************************** diff --git a/source3/libgpo/gpo_filesync.c b/source3/libgpo/gpo_filesync.c index 03d5286fae..6d64d7b968 100644 --- a/source3/libgpo/gpo_filesync.c +++ b/source3/libgpo/gpo_filesync.c @@ -117,10 +117,10 @@ static bool gpo_sync_files(struct sync_context *ctx) ctx) == -1) { DEBUG(1,("listing [%s] failed with error: %s\n", ctx->mask, cli_errstr(ctx->cli))); - return False; + return false; } - return True; + return true; } /**************************************************************** diff --git a/source3/libgpo/gpo_ini.c b/source3/libgpo/gpo_ini.c index 306d6f9bec..d8f14b609f 100644 --- a/source3/libgpo/gpo_ini.c +++ b/source3/libgpo/gpo_ini.c @@ -174,7 +174,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx, failed: - DEBUG(1,("gp_inifile_init_context failed: %s\n", + DEBUG(1,("gp_inifile_init_context failed: %s\n", nt_errstr(status))); TALLOC_FREE(ctx); @@ -237,7 +237,7 @@ NTSTATUS parse_gpt_ini(TALLOC_CTX *mem_ctx, result = NT_STATUS_OK; out: - if (dict) { + if (dict) { iniparser_freedict(dict); } diff --git a/source3/libgpo/gpo_ldap.c b/source3/libgpo/gpo_ldap.c index a34e6861a5..477832abc5 100644 --- a/source3/libgpo/gpo_ldap.c +++ b/source3/libgpo/gpo_ldap.c @@ -27,7 +27,7 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, const char *extension_raw, struct GP_EXT **gp_ext) { - bool ret = False; + bool ret = false; struct GP_EXT *ext = NULL; char **ext_list = NULL; char **ext_strings = NULL; @@ -134,7 +134,7 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx, *gp_ext = ext; - ret = True; + ret = true; parse_error: TALLOC_FREE(ext_list); @@ -659,7 +659,7 @@ ADS_STATUS ads_get_sid_token(ADS_STRUCT *ads, } } - new_token = create_local_nt_token(mem_ctx, &object_sid, False, + new_token = create_local_nt_token(mem_ctx, &object_sid, false, num_token_sids, token_sids); ADS_ERROR_HAVE_NO_MEMORY(new_token); @@ -713,7 +713,7 @@ ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads, ADS_STATUS status; struct GP_LINK gp_link; const char *parent_dn, *site_dn, *tmp_dn; - bool add_only_forced_gpos = False; + bool add_only_forced_gpos = false; ZERO_STRUCTP(gpo_list); @@ -793,7 +793,7 @@ ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads, /* block inheritance from now on */ if (gp_link.gp_opts & GPOPTIONS_BLOCK_INHERITANCE) { - add_only_forced_gpos = True; + add_only_forced_gpos = true; } status = add_gplink_to_gpo_list(ads, @@ -839,7 +839,7 @@ ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads, /* block inheritance from now on */ if (gp_link.gp_opts & GPOPTIONS_BLOCK_INHERITANCE) { - add_only_forced_gpos = True; + add_only_forced_gpos = true; } status = add_gplink_to_gpo_list(ads, diff --git a/source3/libgpo/gpo_sec.c b/source3/libgpo/gpo_sec.c index 7f8324b994..42ab72a99b 100644 --- a/source3/libgpo/gpo_sec.c +++ b/source3/libgpo/gpo_sec.c @@ -28,13 +28,13 @@ static bool gpo_sd_check_agp_object_guid(const struct security_ace_object *objec NTSTATUS status; if (!object) { - return False; + return false; } status = GUID_from_string(ADS_EXTENDED_RIGHT_APPLY_GROUP_POLICY, &ext_right_apg_guid); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } switch (object->flags) { @@ -52,7 +52,7 @@ static bool gpo_sd_check_agp_object_guid(const struct security_ace_object *objec break; } - return False; + return false; } /**************************************************************** @@ -61,7 +61,7 @@ static bool gpo_sd_check_agp_object_guid(const struct security_ace_object *objec static bool gpo_sd_check_agp_object(const SEC_ACE *ace) { if (!sec_ace_object(ace->type)) { - return False; + return false; } return gpo_sd_check_agp_object_guid(&ace->object.object); -- cgit From b50eb31bb4369e2ae22c43ad9f0fa2d9e2385d25 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 29 Feb 2008 15:13:02 +0100 Subject: Fix warnings (This used to be commit 9a966e5593ae4474014aec5d8c68c489ac8ce0c9) --- source3/client/client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 1410fc2f33..c97f6223a7 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -979,11 +979,10 @@ static int do_get(const char *rname, const char *lname_in, bool reget) int handle = 0, fnum; bool newhandle = false; struct timeval tp_start; - int read_size = io_bufsize; uint16 attr; SMB_OFF_T size; off_t start = 0; - off_t nread = 0; + ssize_t nread = 0; int rc = 0; struct cli_state *targetcli = NULL; char *targetname = NULL; -- cgit From c613bd5d4e34caff88deed13cf82608f894e083c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 15:46:14 +0100 Subject: Add infrastructure for reading/storing Group Policy state and control data in the registry. Guenther (This used to be commit f673bbd300d972dd7ae2d092b3b1e642ed29cfd2) --- source3/Makefile.in | 3 +- source3/include/gpo.h | 60 ++- source3/include/reg_objects.h | 7 + source3/libgpo/gpo_reg.c | 1058 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1126 insertions(+), 2 deletions(-) create mode 100644 source3/libgpo/gpo_reg.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index c6815e91e6..baa917724d 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -377,7 +377,8 @@ LIBWBCLIENT_OBJ0 = nsswitch/libwbclient/wbclient.o \ LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) $(WBCOMMON_OBJ) @LIBTALLOC_STATIC@ $(LIBREPLACE_OBJ) LIBGPO_OBJ0 = libgpo/gpo_ldap.o libgpo/gpo_ini.o libgpo/gpo_util.o \ - libgpo/gpo_fetch.o libgpo/gpo_filesync.o libgpo/gpo_sec.o + libgpo/gpo_fetch.o libgpo/gpo_filesync.o libgpo/gpo_sec.o \ + libgpo/gpo_reg.o LIBGPO_OBJ = $(LIBGPO_OBJ0) LIBADS_OBJ = libads/ldap.o libads/ldap_printer.o \ diff --git a/source3/include/gpo.h b/source3/include/gpo.h index 9b1a672640..d8d9e8e597 100644 --- a/source3/include/gpo.h +++ b/source3/include/gpo.h @@ -22,7 +22,8 @@ enum GPO_LINK_TYPE { GP_LINK_MACHINE = 1, GP_LINK_SITE = 2, GP_LINK_DOMAIN = 3, - GP_LINK_OU = 4 + GP_LINK_OU = 4, + GP_LINK_LOCAL = 5 /* for convenience */ }; /* GPO_OPTIONS */ @@ -33,6 +34,17 @@ enum GPO_LINK_TYPE { #define GPO_LIST_FLAG_MACHINE 0x00000001 #define GPO_LIST_FLAG_SITEONLY 0x00000002 +/* following flags from http://support.microsoft.com/kb/312164/EN-US/ */ +#define GPO_INFO_FLAG_MACHINE 0x00000001 +#define GPO_INFO_FLAG_BACKGROUND 0x00000010 +#define GPO_INFO_FLAG_SLOWLINK 0x00000020 +#define GPO_INFO_FLAG_VERBOSE 0x00000040 +#define GPO_INFO_FLAG_NOCHANGES 0x00000080 +#define GPO_INFO_FLAG_LINKTRANSITION 0x00000100 +#define GPO_INFO_FLAG_LOGRSOP_TRANSITION 0x00000200 +#define GPO_INFO_FLAG_FORCED_REFRESH 0x00000400 +#define GPO_INFO_FLAG_SAFEMODE_BOOT 0x00000800 + #define GPO_VERSION_USER(x) (x >> 16) #define GPO_VERSION_MACHINE(x) (x & 0xffff) @@ -88,10 +100,56 @@ struct GP_EXT { char **extensions_guid; char **snapins; char **snapins_guid; + struct GP_EXT *next, *prev; }; #define GPO_CACHE_DIR "gpo_cache" #define GPT_INI "GPT.INI" +#define GPO_REFRESH_INTERVAL 60*90 + +#define GPO_REG_STATE_MACHINE "State\\Machine" + +enum gp_reg_action { + GP_REG_ACTION_NONE = 0, + GP_REG_ACTION_ADD_VALUE = 1, + GP_REG_ACTION_ADD_KEY = 2, + GP_REG_ACTION_DEL_VALUES = 3, + GP_REG_ACTION_DEL_VALUE = 4, + GP_REG_ACTION_DEL_ALL_VALUES = 5, + GP_REG_ACTION_DEL_KEYS = 6, + GP_REG_ACTION_SEC_KEY_SET = 7, + GP_REG_ACTION_SEC_KEY_RESET = 8 +}; + +struct gp_registry_entry { + enum gp_reg_action action; + const char *key; + const char *value; + struct registry_value *data; +}; + +struct gp_registry_value { + const char *value; + struct registry_value *data; +}; + +struct gp_registry_entry2 { + enum gp_reg_action action; + const char *key; + size_t num_values; + struct gp_registry_value **values; +}; + +struct gp_registry_entries { + size_t num_entries; + struct gp_registry_entry **entries; +}; + +struct gp_registry_context { + const struct nt_user_token *token; + const char *path; + struct registry_key *curr_key; +}; #define GP_EXT_GUID_SECURITY "827D319E-6EAC-11D2-A4EA-00C04F79F83A" #define GP_EXT_GUID_REGISTRY "35378EAC-683F-11D2-A89A-00C04FBBCFA2" diff --git a/source3/include/reg_objects.h b/source3/include/reg_objects.h index 3df701f61c..1d0d0d4996 100644 --- a/source3/include/reg_objects.h +++ b/source3/include/reg_objects.h @@ -105,9 +105,16 @@ typedef struct { #define KEY_CURRENT_VERSION "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" #define KEY_PERFLIB "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib" #define KEY_PERFLIB_009 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009" +#define KEY_GROUP_POLICY "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Group Policy" +#define KEY_WINLOGON "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon" #define KEY_SMBCONF "HKLM\\SOFTWARE\\Samba\\smbconf" +#define KEY_SAMBA_GROUP_POLICY "HKLM\\SOFTWARE\\Samba\\Group Policy" #define KEY_TREE_ROOT "" +#define KEY_GP_MACHINE_POLICY "HKLM\\Software\\Policies" +#define KEY_GP_MACHINE_WIN_POLICY "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies" +#define KEY_GP_USER_POLICY "HKCU\\Software\\Policies" +#define KEY_GP_USER_WIN_POLICY "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies" /* * Registry key types * Most keys are going to be GENERIC -- may need a better name? diff --git a/source3/libgpo/gpo_reg.c b/source3/libgpo/gpo_reg.c new file mode 100644 index 0000000000..2a27a7ed93 --- /dev/null +++ b/source3/libgpo/gpo_reg.c @@ -0,0 +1,1058 @@ +/* + * Unix SMB/CIFS implementation. + * Group Policy Object Support + * 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 + * 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 "includes.h" + + +extern REGISTRY_OPS regdb_ops; + +static int gp_reg_fetch_keys(const char *key, REGSUBKEY_CTR *subkey_ctr) +{ + return regdb_ops.fetch_subkeys(key, subkey_ctr); +} + +static bool gp_reg_store_keys(const char *key, REGSUBKEY_CTR *subkeys) +{ + return regdb_ops.store_subkeys(key, subkeys); +} + +static int gp_reg_fetch_values(const char *key, REGVAL_CTR *val) +{ + return regdb_ops.fetch_values(key, val); +} + +static bool gp_reg_store_values(const char *key, REGVAL_CTR *val) +{ + return regdb_ops.store_values(key, val); +} + +static WERROR gp_reg_get_secdesc(TALLOC_CTX *mem_ctx, const char *key, + struct security_descriptor **psecdesc) +{ + return regdb_ops.get_secdesc(mem_ctx, key, psecdesc); +} + +static WERROR gp_reg_set_secdesc(const char *key, + struct security_descriptor *secdesc) +{ + return regdb_ops.set_secdesc(key, secdesc); +} + +/**************************************************************** +****************************************************************/ + +static REGISTRY_OPS gp_reg_ops = { + .fetch_subkeys = gp_reg_fetch_keys, + .fetch_values = gp_reg_fetch_values, + .store_subkeys = gp_reg_store_keys, + .store_values = gp_reg_store_values, +/* .reg_access_check = gp_reg_reg_access_check, */ + .get_secdesc = gp_reg_get_secdesc, + .set_secdesc = gp_reg_set_secdesc +}; + +/**************************************************************** +****************************************************************/ + +struct nt_user_token *registry_create_system_token(TALLOC_CTX *mem_ctx) +{ + struct nt_user_token *token = NULL; + + token = TALLOC_ZERO_P(mem_ctx, struct nt_user_token); + if (!token) { + DEBUG(1,("talloc failed\n")); + return NULL; + } + + token->privileges = se_priv_all; + + if (!NT_STATUS_IS_OK(add_sid_to_array(token, &global_sid_System, + &token->user_sids, &token->num_sids))) { + DEBUG(1,("Error adding nt-authority system sid to token\n")); + return NULL; + } + + return token; +} + +/**************************************************************** +****************************************************************/ + +WERROR gp_init_reg_ctx(TALLOC_CTX *mem_ctx, + const char *initial_path, + uint32_t desired_access, + const struct nt_user_token *token, + struct gp_registry_context **reg_ctx) +{ + struct gp_registry_context *tmp_ctx; + static REGISTRY_HOOK gp_reg_hook; + WERROR werr; + + if (!reg_ctx) { + return WERR_INVALID_PARAM; + } + + if (!regdb_init()) { + return WERR_CAN_NOT_COMPLETE; + } + + gp_reg_hook.keyname = initial_path; /* KEY_SAMBA_GROUP_POLICY */ + gp_reg_hook.ops = &gp_reg_ops; + + /* not sure about the cache hook */ + reghook_cache_init(); + + if (!reghook_cache_add(&gp_reg_hook)) { + return WERR_CAN_NOT_COMPLETE; + } + + tmp_ctx = TALLOC_ZERO_P(mem_ctx, struct gp_registry_context); + W_ERROR_HAVE_NO_MEMORY(tmp_ctx); + + if (token) { + tmp_ctx->token = token; + } else { + tmp_ctx->token = registry_create_system_token(mem_ctx); + } + if (!tmp_ctx->token) { + TALLOC_FREE(tmp_ctx); + return WERR_NOMEM; + } + + if (initial_path) { + tmp_ctx->path = talloc_strdup(mem_ctx, initial_path); + if (!tmp_ctx->path) { + TALLOC_FREE(tmp_ctx); + return WERR_NOMEM; + } + + werr = reg_open_path(mem_ctx, tmp_ctx->path, desired_access, + tmp_ctx->token, &tmp_ctx->curr_key); + if (!W_ERROR_IS_OK(werr)) { + TALLOC_FREE(tmp_ctx); + return werr; + } + } + + *reg_ctx = tmp_ctx; + + return WERR_OK; +} + +/**************************************************************** +****************************************************************/ + +void gp_free_reg_ctx(struct gp_registry_context *reg_ctx) +{ + TALLOC_FREE(reg_ctx); +} + +/**************************************************************** +****************************************************************/ + +WERROR gp_store_reg_subkey(TALLOC_CTX *mem_ctx, + const char *subkeyname, + struct registry_key *curr_key, + struct registry_key **new_key) +{ + enum winreg_CreateAction action = REG_ACTION_NONE; + WERROR werr; + + werr = reg_createkey(mem_ctx, curr_key, subkeyname, + REG_KEY_WRITE, new_key, &action); + if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) { + return WERR_OK; + } + + return werr; +} + +/**************************************************************** +****************************************************************/ + +WERROR gp_read_reg_subkey(TALLOC_CTX *mem_ctx, + struct gp_registry_context *reg_ctx, + const char *subkeyname, + struct registry_key **key) +{ + const char *tmp = NULL; + + if (!reg_ctx || !subkeyname || !key) { + return WERR_INVALID_PARAM; + } + + tmp = talloc_asprintf(mem_ctx, "%s\\%s", reg_ctx->path, subkeyname); + W_ERROR_HAVE_NO_MEMORY(tmp); + + return reg_open_path(mem_ctx, tmp, REG_KEY_READ, + reg_ctx->token, key); +} + +/**************************************************************** +****************************************************************/ + +WERROR gp_store_reg_val_sz(TALLOC_CTX *mem_ctx, + struct registry_key *key, + const char *val_name, + const char *val) +{ + struct registry_value reg_val; + ZERO_STRUCT(reg_val); + + /* FIXME: hack */ + val = val ? val : " "; + + reg_val.type = REG_SZ; + reg_val.v.sz.len = strlen(val); + reg_val.v.sz.str = talloc_strdup(mem_ctx, val); + W_ERROR_HAVE_NO_MEMORY(reg_val.v.sz.str); + + return reg_setvalue(key, val_name, ®_val); +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_store_reg_val_dword(TALLOC_CTX *mem_ctx, + struct registry_key *key, + const char *val_name, + uint32_t val) +{ + struct registry_value reg_val; + ZERO_STRUCT(reg_val); + + reg_val.type = REG_DWORD; + reg_val.v.dword = val; + + return reg_setvalue(key, val_name, ®_val); +} + +/**************************************************************** +****************************************************************/ + +WERROR gp_read_reg_val_sz(TALLOC_CTX *mem_ctx, + struct registry_key *key, + const char *val_name, + const char **val) +{ + WERROR werr; + struct registry_value *reg_val = NULL; + + werr = reg_queryvalue(mem_ctx, key, val_name, ®_val); + W_ERROR_NOT_OK_RETURN(werr); + + if (reg_val->type != REG_SZ) { + return WERR_INVALID_DATATYPE; + } + + *val = talloc_strdup(mem_ctx, reg_val->v.sz.str); + W_ERROR_HAVE_NO_MEMORY(*val); + + return WERR_OK; +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_read_reg_val_dword(TALLOC_CTX *mem_ctx, + struct registry_key *key, + const char *val_name, + uint32_t *val) +{ + WERROR werr; + struct registry_value *reg_val = NULL; + + werr = reg_queryvalue(mem_ctx, key, val_name, ®_val); + W_ERROR_NOT_OK_RETURN(werr); + + if (reg_val->type != REG_DWORD) { + return WERR_INVALID_DATATYPE; + } + + *val = reg_val->v.dword; + + return WERR_OK; +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_store_reg_gpovals(TALLOC_CTX *mem_ctx, + struct registry_key *key, + struct GROUP_POLICY_OBJECT *gpo) +{ + WERROR werr; + + if (!key || !gpo) { + return WERR_INVALID_PARAM; + } + + werr = gp_store_reg_val_dword(mem_ctx, key, "Version", + gpo->version); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_store_reg_val_dword(mem_ctx, key, "WQLFilterPass", + true); /* fake */ + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_store_reg_val_dword(mem_ctx, key, "AccessDenied", + false); /* fake */ + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_store_reg_val_dword(mem_ctx, key, "GPO-Disabled", + (gpo->options & GPO_FLAG_DISABLE)); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_store_reg_val_dword(mem_ctx, key, "Options", + gpo->options); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_store_reg_val_sz(mem_ctx, key, "GPOID", + gpo->name); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_store_reg_val_sz(mem_ctx, key, "SOM", + gpo->link); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_store_reg_val_sz(mem_ctx, key, "DisplayName", + gpo->display_name); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_store_reg_val_sz(mem_ctx, key, "WQL-Id", + NULL); + W_ERROR_NOT_OK_RETURN(werr); + + return werr; +} + +/**************************************************************** +****************************************************************/ + +static const char *gp_reg_groupmembership_path(TALLOC_CTX *mem_ctx, + const DOM_SID *sid, + uint32_t flags) +{ + if (flags & GPO_LIST_FLAG_MACHINE) { + return "GroupMembership"; + } + + return talloc_asprintf(mem_ctx, "%s\\%s", sid_string_tos(sid), + "GroupMembership"); +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_reg_del_groupmembership(TALLOC_CTX *mem_ctx, + struct registry_key *key, + const struct nt_user_token *token, + uint32_t flags) +{ + const char *path = NULL; + + path = gp_reg_groupmembership_path(mem_ctx, &token->user_sids[0], + flags); + W_ERROR_HAVE_NO_MEMORY(path); + + return reg_deletekey_recursive(mem_ctx, key, path); + +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_reg_store_groupmembership(TALLOC_CTX *mem_ctx, + struct gp_registry_context *reg_ctx, + const struct nt_user_token *token, + uint32_t flags) +{ + struct registry_key *key = NULL; + WERROR werr; + int i = 0; + const char *valname = NULL; + const char *path = NULL; + const char *val = NULL; + int count = 0; + + path = gp_reg_groupmembership_path(mem_ctx, &token->user_sids[0], + flags); + W_ERROR_HAVE_NO_MEMORY(path); + + gp_reg_del_groupmembership(mem_ctx, reg_ctx->curr_key, token, flags); + + werr = gp_store_reg_subkey(mem_ctx, path, + reg_ctx->curr_key, &key); + W_ERROR_NOT_OK_RETURN(werr); + + for (i=0; inum_sids; i++) { + + valname = talloc_asprintf(mem_ctx, "Group%d", count++); + W_ERROR_HAVE_NO_MEMORY(valname); + + val = sid_string_talloc(mem_ctx, &token->user_sids[i]); + W_ERROR_HAVE_NO_MEMORY(val); + werr = gp_store_reg_val_sz(mem_ctx, key, valname, val); + W_ERROR_NOT_OK_RETURN(werr); + } + + werr = gp_store_reg_val_dword(mem_ctx, key, "Count", count); + W_ERROR_NOT_OK_RETURN(werr); + + return WERR_OK; +} + +/**************************************************************** +****************************************************************/ +#if 0 +/* not used yet */ +static WERROR gp_reg_read_groupmembership(TALLOC_CTX *mem_ctx, + struct gp_registry_context *reg_ctx, + const DOM_SID *object_sid, + struct nt_user_token **token, + uint32_t flags) +{ + struct registry_key *key = NULL; + WERROR werr; + int i = 0; + const char *valname = NULL; + const char *val = NULL; + const char *path = NULL; + uint32_t count = 0; + int num_token_sids = 0; + struct nt_user_token *tmp_token = NULL; + + tmp_token = TALLOC_ZERO_P(mem_ctx, struct nt_user_token); + W_ERROR_HAVE_NO_MEMORY(tmp_token); + + path = gp_reg_groupmembership_path(mem_ctx, object_sid, flags); + W_ERROR_HAVE_NO_MEMORY(path); + + werr = gp_read_reg_subkey(mem_ctx, reg_ctx, path, &key); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_read_reg_val_dword(mem_ctx, key, "Count", &count); + W_ERROR_NOT_OK_RETURN(werr); + + for (i=0; iuser_sids[num_token_sids++], + val)) { + return WERR_INSUFFICIENT_BUFFER; + } + } + + tmp_token->num_sids = num_token_sids; + + *token = tmp_token; + + return WERR_OK; +} +#endif +/**************************************************************** +****************************************************************/ + +static const char *gp_req_state_path(TALLOC_CTX *mem_ctx, + const DOM_SID *sid, + uint32_t flags) +{ + if (flags & GPO_LIST_FLAG_MACHINE) { + return GPO_REG_STATE_MACHINE; + } + + return talloc_asprintf(mem_ctx, "%s\\%s", "State", sid_string_tos(sid)); +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_del_reg_state(TALLOC_CTX *mem_ctx, + struct registry_key *key, + const char *path) +{ + return reg_deletesubkeys_recursive(mem_ctx, key, path); +} + +/**************************************************************** +****************************************************************/ + +WERROR gp_reg_state_store(TALLOC_CTX *mem_ctx, + uint32_t flags, + const char *dn, + const struct nt_user_token *token, + struct GROUP_POLICY_OBJECT *gpo_list) +{ + struct gp_registry_context *reg_ctx = NULL; + WERROR werr = WERR_GENERAL_FAILURE; + const char *subkeyname = NULL; + struct GROUP_POLICY_OBJECT *gpo; + int count = 0; + struct registry_key *key; + + werr = gp_init_reg_ctx(mem_ctx, KEY_GROUP_POLICY, REG_KEY_WRITE, + token, ®_ctx); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_secure_key(mem_ctx, flags, KEY_GROUP_POLICY, + &token->user_sids[0]); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("failed to secure key: %s\n", dos_errstr(werr))); + goto done; + } + + werr = gp_reg_store_groupmembership(mem_ctx, reg_ctx, token, flags); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("failed to store group membership: %s\n", dos_errstr(werr))); + goto done; + } + + subkeyname = gp_req_state_path(mem_ctx, &token->user_sids[0], flags); + if (!subkeyname) { + werr = WERR_NOMEM; + goto done; + } + + werr = gp_del_reg_state(mem_ctx, reg_ctx->curr_key, subkeyname); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("failed to delete old state: %s\n", dos_errstr(werr))); + /* goto done; */ + } + + werr = gp_store_reg_subkey(mem_ctx, subkeyname, + reg_ctx->curr_key, ®_ctx->curr_key); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = gp_store_reg_val_sz(mem_ctx, reg_ctx->curr_key, + "Distinguished-Name", dn); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + /* store link list */ + + werr = gp_store_reg_subkey(mem_ctx, "GPLink-List", + reg_ctx->curr_key, &key); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + /* store gpo list */ + + werr = gp_store_reg_subkey(mem_ctx, "GPO-List", + reg_ctx->curr_key, ®_ctx->curr_key); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + for (gpo = gpo_list; gpo; gpo = gpo->next) { + + subkeyname = talloc_asprintf(mem_ctx, "%d", count++); + if (!subkeyname) { + werr = WERR_NOMEM; + goto done; + } + + werr = gp_store_reg_subkey(mem_ctx, subkeyname, + reg_ctx->curr_key, &key); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = gp_store_reg_gpovals(mem_ctx, key, gpo); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("gp_reg_state_store: " + "gpo_store_reg_gpovals failed for %s: %s\n", + gpo->display_name, dos_errstr(werr))); + goto done; + } + } + done: + gp_free_reg_ctx(reg_ctx); + return werr; +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_read_reg_gpovals(TALLOC_CTX *mem_ctx, + struct registry_key *key, + struct GROUP_POLICY_OBJECT *gpo) +{ + WERROR werr; + + if (!key || !gpo) { + return WERR_INVALID_PARAM; + } + + werr = gp_read_reg_val_dword(mem_ctx, key, "Version", + &gpo->version); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_read_reg_val_dword(mem_ctx, key, "Options", + &gpo->options); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_read_reg_val_sz(mem_ctx, key, "GPOID", + &gpo->name); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_read_reg_val_sz(mem_ctx, key, "SOM", + &gpo->link); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_read_reg_val_sz(mem_ctx, key, "DisplayName", + &gpo->display_name); + W_ERROR_NOT_OK_RETURN(werr); + + return werr; +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_read_reg_gpo(TALLOC_CTX *mem_ctx, + struct registry_key *key, + struct GROUP_POLICY_OBJECT **gpo_ret) +{ + struct GROUP_POLICY_OBJECT *gpo = NULL; + WERROR werr; + + if (!gpo_ret || !key) { + return WERR_INVALID_PARAM; + } + + gpo = TALLOC_ZERO_P(mem_ctx, struct GROUP_POLICY_OBJECT); + W_ERROR_HAVE_NO_MEMORY(gpo); + + werr = gp_read_reg_gpovals(mem_ctx, key, gpo); + W_ERROR_NOT_OK_RETURN(werr); + + *gpo_ret = gpo; + + return werr; +} + +/**************************************************************** +****************************************************************/ + +WERROR gp_reg_state_read(TALLOC_CTX *mem_ctx, + uint32_t flags, + const DOM_SID *sid, + struct GROUP_POLICY_OBJECT **gpo_list) +{ + struct gp_registry_context *reg_ctx = NULL; + WERROR werr = WERR_GENERAL_FAILURE; + const char *subkeyname = NULL; + struct GROUP_POLICY_OBJECT *gpo = NULL; + int count = 0; + struct registry_key *key = NULL; + const char *path = NULL; + const char *gp_state_path = NULL; + + if (!gpo_list) { + return WERR_INVALID_PARAM; + } + + ZERO_STRUCTP(gpo_list); + + gp_state_path = gp_req_state_path(mem_ctx, sid, flags); + if (!gp_state_path) { + werr = WERR_NOMEM; + goto done; + } + + path = talloc_asprintf(mem_ctx, "%s\\%s\\%s", + KEY_GROUP_POLICY, + gp_state_path, + "GPO-List"); + if (!path) { + werr = WERR_NOMEM; + goto done; + } + + werr = gp_init_reg_ctx(mem_ctx, path, REG_KEY_READ, NULL, ®_ctx); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + while (1) { + + subkeyname = talloc_asprintf(mem_ctx, "%d", count++); + if (!subkeyname) { + werr = WERR_NOMEM; + goto done; + } + + werr = gp_read_reg_subkey(mem_ctx, reg_ctx, subkeyname, &key); + if (W_ERROR_EQUAL(werr, WERR_BADFILE)) { + werr = WERR_OK; + break; + } + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("gp_reg_state_read: " + "gp_read_reg_subkey gave: %s\n", + dos_errstr(werr))); + goto done; + } + + werr = gp_read_reg_gpo(mem_ctx, key, &gpo); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + DLIST_ADD(*gpo_list, gpo); + } + + done: + gp_free_reg_ctx(reg_ctx); + return werr; +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_reg_generate_sd(TALLOC_CTX *mem_ctx, + const DOM_SID *sid, + struct security_descriptor **sd, + size_t *sd_size) +{ + SEC_ACE ace[6]; + SEC_ACCESS mask; + + SEC_ACL *acl = NULL; + + uint8_t inherit_flags; + + init_sec_access(&mask, REG_KEY_ALL); + init_sec_ace(&ace[0], + &global_sid_System, + SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, 0); + + init_sec_access(&mask, REG_KEY_ALL); + init_sec_ace(&ace[1], + &global_sid_Builtin_Administrators, + SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, 0); + + init_sec_access(&mask, REG_KEY_READ); + init_sec_ace(&ace[2], + sid ? sid : &global_sid_Authenticated_Users, + SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, 0); + + inherit_flags = SEC_ACE_FLAG_OBJECT_INHERIT | + SEC_ACE_FLAG_CONTAINER_INHERIT | + SEC_ACE_FLAG_INHERIT_ONLY; + + init_sec_access(&mask, REG_KEY_ALL); + init_sec_ace(&ace[3], + &global_sid_System, + SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, inherit_flags); + + init_sec_access(&mask, REG_KEY_ALL); + init_sec_ace(&ace[4], + &global_sid_Builtin_Administrators, + SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, inherit_flags); + + init_sec_access(&mask, REG_KEY_READ); + init_sec_ace(&ace[5], + sid ? sid : &global_sid_Authenticated_Users, + SEC_ACE_TYPE_ACCESS_ALLOWED, + mask, inherit_flags); + + acl = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 6, ace); + W_ERROR_HAVE_NO_MEMORY(acl); + + *sd = make_sec_desc(mem_ctx, SEC_DESC_REVISION, + SEC_DESC_SELF_RELATIVE | + SEC_DESC_DACL_AUTO_INHERITED | /* really ? */ + SEC_DESC_DACL_AUTO_INHERIT_REQ, /* really ? */ + NULL, NULL, NULL, + acl, sd_size); + W_ERROR_HAVE_NO_MEMORY(*sd); + + return WERR_OK; +} + +/**************************************************************** +****************************************************************/ + +WERROR gp_secure_key(TALLOC_CTX *mem_ctx, + uint32_t flags, + const char *key, + const DOM_SID *sid) +{ + struct security_descriptor *sd = NULL; + size_t sd_size = 0; + const DOM_SID *sd_sid = NULL; + WERROR werr; + + if (!(flags & GPO_LIST_FLAG_MACHINE)) { + sd_sid = sid; + } + + werr = gp_reg_generate_sd(mem_ctx, sd_sid, &sd, &sd_size); + W_ERROR_NOT_OK_RETURN(werr); + + return gp_reg_set_secdesc(key, sd); +} + +/**************************************************************** +****************************************************************/ + +void dump_reg_val(int lvl, const char *direction, + const char *key, const char *subkey, + struct registry_value *val) +{ + int i = 0; + const char *type_str = NULL; + + if (!val) { + DEBUG(lvl,("no val!\n")); + return; + } + + type_str = reg_type_lookup(val->type); + + DEBUG(lvl,("\tdump_reg_val: %s '%s' '%s' %s: ", + direction, key, subkey, type_str)); + + switch (val->type) { + case REG_DWORD: + DEBUG(lvl,("%d\n", (int)val->v.dword)); + break; + case REG_QWORD: + DEBUG(lvl,("%d\n", (int)val->v.qword)); + break; + case REG_SZ: + DEBUG(lvl,("%s (length: %d)\n", + val->v.sz.str, + (int)val->v.sz.len)); + break; + case REG_MULTI_SZ: + DEBUG(lvl,("(num_strings: %d)\n", + val->v.multi_sz.num_strings)); + for (i=0; i < val->v.multi_sz.num_strings; i++) { + DEBUGADD(lvl,("\t%s\n", + val->v.multi_sz.strings[i])); + } + break; + case REG_NONE: + DEBUG(lvl,("\n")); + break; + case REG_BINARY: + dump_data(lvl, val->v.binary.data, + val->v.binary.length); + break; + default: + DEBUG(lvl,("unsupported type: %d\n", val->type)); + break; + } +} + +/**************************************************************** +****************************************************************/ + +void dump_reg_entry(uint32_t flags, + const char *dir, + struct gp_registry_entry *entry) +{ + if (!(flags & GPO_INFO_FLAG_VERBOSE)) + return; + + dump_reg_val(1, dir, + entry->key, + entry->value, + entry->data); +} + +/**************************************************************** +****************************************************************/ + +void dump_reg_entries(uint32_t flags, + const char *dir, + struct gp_registry_entry *entries, + size_t num_entries) +{ + size_t i; + + if (!(flags & GPO_INFO_FLAG_VERBOSE)) + return; + + for (i=0; i < num_entries; i++) { + dump_reg_entry(flags, dir, &entries[i]); + } +} + +/**************************************************************** +****************************************************************/ + +bool add_gp_registry_entry_to_array(TALLOC_CTX *mem_ctx, + struct gp_registry_entry *entry, + struct gp_registry_entry **entries, + size_t *num) +{ + *entries = TALLOC_REALLOC_ARRAY(mem_ctx, *entries, + struct gp_registry_entry, + (*num)+1); + + if (*entries == NULL) { + *num = 0; + return false; + } + + (*entries)[*num].action = entry->action; + (*entries)[*num].key = entry->key; + (*entries)[*num].value = entry->value; + (*entries)[*num].data = entry->data; + + *num += 1; + return true; +} + +/**************************************************************** +****************************************************************/ + +static const char *gp_reg_action_str(enum gp_reg_action action) +{ + switch (action) { + case GP_REG_ACTION_NONE: + return "GP_REG_ACTION_NONE"; + case GP_REG_ACTION_ADD_VALUE: + return "GP_REG_ACTION_ADD_VALUE"; + case GP_REG_ACTION_ADD_KEY: + return "GP_REG_ACTION_ADD_KEY"; + case GP_REG_ACTION_DEL_VALUES: + return "GP_REG_ACTION_DEL_VALUES"; + case GP_REG_ACTION_DEL_VALUE: + return "GP_REG_ACTION_DEL_VALUE"; + case GP_REG_ACTION_DEL_ALL_VALUES: + return "GP_REG_ACTION_DEL_ALL_VALUES"; + case GP_REG_ACTION_DEL_KEYS: + return "GP_REG_ACTION_DEL_KEYS"; + case GP_REG_ACTION_SEC_KEY_SET: + return "GP_REG_ACTION_SEC_KEY_SET"; + case GP_REG_ACTION_SEC_KEY_RESET: + return "GP_REG_ACTION_SEC_KEY_RESET"; + default: + return "unknown"; + } +}; + +/**************************************************************** +****************************************************************/ + +WERROR reg_apply_registry_entry(TALLOC_CTX *mem_ctx, + struct registry_key *root_key, + struct gp_registry_context *reg_ctx, + struct gp_registry_entry *entry, + const struct nt_user_token *token, + uint32_t flags) +{ + WERROR werr; + struct registry_key *key = NULL; + + if (flags & GPO_INFO_FLAG_VERBOSE) { + printf("about to store key: [%s]\n", entry->key); + printf(" value: [%s]\n", entry->value); + printf(" data: [%s]\n", reg_type_lookup(entry->data->type)); + printf(" action: [%s]\n", gp_reg_action_str(entry->action)); + } + + werr = gp_store_reg_subkey(mem_ctx, entry->key, + root_key, &key); + /* reg_ctx->curr_key, &key); */ + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("gp_store_reg_subkey failed: %s\n", dos_errstr(werr))); + return werr; + } + + switch (entry->action) { + case GP_REG_ACTION_NONE: + case GP_REG_ACTION_ADD_KEY: + return WERR_OK; + + case GP_REG_ACTION_SEC_KEY_SET: + werr = gp_secure_key(mem_ctx, flags, + entry->key, + &token->user_sids[0]); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("reg_apply_registry_entry: " + "gp_secure_key failed: %s\n", + dos_errstr(werr))); + return werr; + } + break; + case GP_REG_ACTION_ADD_VALUE: + werr = reg_setvalue(key, entry->value, entry->data); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("reg_apply_registry_entry: " + "reg_setvalue failed: %s\n", + dos_errstr(werr))); + dump_reg_entry(flags, "STORE", entry); + return werr; + } + break; + case GP_REG_ACTION_DEL_VALUE: + werr = reg_deletevalue(key, entry->value); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("reg_apply_registry_entry: " + "reg_deletevalue failed: %s\n", + dos_errstr(werr))); + dump_reg_entry(flags, "STORE", entry); + return werr; + } + break; + case GP_REG_ACTION_DEL_ALL_VALUES: + werr = reg_deleteallvalues(key); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,("reg_apply_registry_entry: " + "reg_deleteallvalues failed: %s\n", + dos_errstr(werr))); + dump_reg_entry(flags, "STORE", entry); + return werr; + } + break; + case GP_REG_ACTION_DEL_VALUES: + case GP_REG_ACTION_DEL_KEYS: + case GP_REG_ACTION_SEC_KEY_RESET: + DEBUG(0,("reg_apply_registry_entry: " + "not yet supported: %s (%d)\n", + gp_reg_action_str(entry->action), + entry->action)); + return WERR_NOT_SUPPORTED; + default: + DEBUG(0,("invalid action: %d\n", entry->action)); + return WERR_INVALID_PARAM; + } + + return werr; +} + -- cgit From 6a7b6a1961b2bb74e25b4134422089f16a32cc9e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Feb 2008 06:55:33 -0800 Subject: Patch to fix the "Invalid read of size 4" errors. Bug #3617. Jeremy. (This used to be commit fa12667ec284fdda45b79cbf6bf548ab0faae34f) --- source3/nmbd/nmbd_responserecordsdb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source3') diff --git a/source3/nmbd/nmbd_responserecordsdb.c b/source3/nmbd/nmbd_responserecordsdb.c index 6498ce04cf..b042fb41ed 100644 --- a/source3/nmbd/nmbd_responserecordsdb.c +++ b/source3/nmbd/nmbd_responserecordsdb.c @@ -46,6 +46,24 @@ static void add_response_record(struct subnet_record *subrec, void remove_response_record(struct subnet_record *subrec, struct response_record *rrec) { + /* It is possible this can be called twice, + with a rrec pointer that has been freed. So + before we inderect into rrec, search for it + on the responselist first. Bug #3617. JRA. */ + + struct response_record *p = NULL; + + for (p = subrec->responselist; p; p = p->next) { + if (p == rrec) { + break; + } + } + + if (p == NULL) { + /* We didn't find rrec on the list. */ + return; + } + DLIST_REMOVE(subrec->responselist, rrec); if(rrec->userdata) { -- cgit From 41efa5ca45f87435ad2a344010ead8e5e2fecbb0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 16:03:23 +0100 Subject: Add Group Policy extension infrastructure. Guenther (This used to be commit 6d543b1a1a5a7af98affc9aea2edf650cb476379) --- source3/Makefile.in | 5 +- source3/configure.in | 2 + source3/include/gpo.h | 4 +- source3/libgpo/gpext/gpext.c | 746 +++++++++++++++++++++++++++++++++++++++++++ source3/libgpo/gpext/gpext.h | 79 +++++ source3/libgpo/gpo_util.c | 33 ++ 6 files changed, 867 insertions(+), 2 deletions(-) create mode 100644 source3/libgpo/gpext/gpext.c create mode 100644 source3/libgpo/gpext/gpext.h (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index baa917724d..cfb607a977 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -376,9 +376,12 @@ LIBWBCLIENT_OBJ0 = nsswitch/libwbclient/wbclient.o \ nsswitch/libwbclient/wbc_pam.o LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) $(WBCOMMON_OBJ) @LIBTALLOC_STATIC@ $(LIBREPLACE_OBJ) +GPEXT_OBJ = libgpo/gpext/gpext.o @GPEXT_STATIC@ + LIBGPO_OBJ0 = libgpo/gpo_ldap.o libgpo/gpo_ini.o libgpo/gpo_util.o \ libgpo/gpo_fetch.o libgpo/gpo_filesync.o libgpo/gpo_sec.o \ - libgpo/gpo_reg.o + libgpo/gpo_reg.o \ + $(GPEXT_OBJ) LIBGPO_OBJ = $(LIBGPO_OBJ0) LIBADS_OBJ = libads/ldap.o libads/ldap_printer.o \ diff --git a/source3/configure.in b/source3/configure.in index f481a30b3b..c4f6d92bfa 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -6078,6 +6078,8 @@ SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", V SMB_SUBSYSTEM(VFS,smbd/vfs.o) +SMB_SUBSYSTEM(GPEXT, libgpo/gpext/gpext.o) + AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) ################################################# diff --git a/source3/include/gpo.h b/source3/include/gpo.h index d8d9e8e597..bf5ff6a598 100644 --- a/source3/include/gpo.h +++ b/source3/include/gpo.h @@ -1,7 +1,7 @@ /* * Unix SMB/CIFS implementation. * Group Policy Object Support - * Copyright (C) Guenther Deschner 2005-2007 + * Copyright (C) Guenther Deschner 2005-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 @@ -154,3 +154,5 @@ struct gp_registry_context { #define GP_EXT_GUID_SECURITY "827D319E-6EAC-11D2-A4EA-00C04F79F83A" #define GP_EXT_GUID_REGISTRY "35378EAC-683F-11D2-A89A-00C04FBBCFA2" #define GP_EXT_GUID_SCRIPTS "42B5FAAE-6536-11D2-AE5A-0000F87571E3" + +#include "libgpo/gpext/gpext.h" diff --git a/source3/libgpo/gpext/gpext.c b/source3/libgpo/gpext/gpext.c new file mode 100644 index 0000000000..184a2fa185 --- /dev/null +++ b/source3/libgpo/gpext/gpext.c @@ -0,0 +1,746 @@ +/* + * Unix SMB/CIFS implementation. + * Group Policy Support + * 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 + * 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 "includes.h" + +static struct gp_extension *extensions = NULL; + +/**************************************************************** +****************************************************************/ + +struct gp_extension *get_gp_extension_list(void) +{ + return extensions; +} + +/**************************************************************** +****************************************************************/ + +/* see http://support.microsoft.com/kb/216358/en-us/ for more info */ + +struct gp_extension_reg_table gpext_reg_vals[] = { + { "DllName", REG_EXPAND_SZ }, + { "ProcessGroupPolicy", REG_SZ }, + { "NoMachinePolicy", REG_DWORD }, + { "NoUserPolicy", REG_DWORD }, + { "NoSlowLink", REG_DWORD }, + { "NoBackgroundPolicy", REG_DWORD }, + { "NoGPOListChanges", REG_DWORD }, + { "PerUserLocalSettings", REG_DWORD }, + { "RequiresSuccessfulRegistry", REG_DWORD }, + { "EnableAsynchronousProcessing", REG_DWORD }, + { "ExtensionDebugLevel", REG_DWORD }, + /* new */ + { "GenerateGroupPolicy", REG_SZ }, /* not supported on w2k */ + { "NotifyLinkTransition", REG_DWORD }, + { "ProcessGroupPolicyEx", REG_SZ }, /* not supported on w2k */ + { "ExtensionEventSource", REG_MULTI_SZ }, /* not supported on w2k */ + { "GenerateGroupPolicy", REG_SZ }, + { "MaxNoGPOListChangesInterval", REG_DWORD }, + { NULL, REG_NONE } +}; + +/**************************************************************** +****************************************************************/ + +static struct gp_extension *get_extension_by_name(struct gp_extension *be, + const char *name) +{ + struct gp_extension *b; + + for (b = be; b; b = b->next) { + if (strequal(b->name, name)) { + return b; + } + } + + return NULL; +} + +/**************************************************************** +****************************************************************/ + +static struct gp_extension_methods *get_methods_by_name(struct gp_extension *be, + const char *name) +{ + struct gp_extension *b; + + for (b = be; b; b = b->next) { + if (strequal(b->name, name)) { + return b->methods; + } + } + + return NULL; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS unregister_gp_extension(const char *name) +{ + struct gp_extension *ext; + + ext = get_extension_by_name(extensions, name); + if (!ext) { + return NT_STATUS_OK; + } + + DLIST_REMOVE(extensions, ext); + TALLOC_FREE(ext); + + DEBUG(2,("Successfully removed GP extension '%s'\n", name)); + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS register_gp_extension(TALLOC_CTX *gpext_ctx, + int version, + const char *name, + const char *guid, + struct gp_extension_methods *methods) +{ + struct gp_extension_methods *test; + struct gp_extension *entry; + NTSTATUS status; + + if (!gpext_ctx) { + return NT_STATUS_INTERNAL_DB_ERROR; + } + + if ((version != SMB_GPEXT_INTERFACE_VERSION)) { + DEBUG(0,("Failed to register gp extension.\n" + "The module was compiled against " + "SMB_GPEXT_INTERFACE_VERSION %d,\n" + "current SMB_GPEXT_INTERFACE_VERSION is %d.\n" + "Please recompile against the current " + "version of samba!\n", + version, SMB_GPEXT_INTERFACE_VERSION)); + return NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + if (!guid || !name || !name[0] || !methods) { + DEBUG(0,("Called with NULL pointer or empty name!\n")); + return NT_STATUS_INVALID_PARAMETER; + } + + test = get_methods_by_name(extensions, name); + if (test) { + DEBUG(0,("GP extension module %s already registered!\n", + name)); + return NT_STATUS_OBJECT_NAME_COLLISION; + } + + entry = TALLOC_ZERO_P(gpext_ctx, struct gp_extension); + NT_STATUS_HAVE_NO_MEMORY(entry); + + entry->name = talloc_strdup(gpext_ctx, name); + NT_STATUS_HAVE_NO_MEMORY(entry->name); + + entry->guid = TALLOC_ZERO_P(gpext_ctx, struct GUID); + NT_STATUS_HAVE_NO_MEMORY(entry->guid); + status = GUID_from_string(guid, entry->guid); + NT_STATUS_NOT_OK_RETURN(status); + + entry->methods = methods; + DLIST_ADD(extensions, entry); + + DEBUG(2,("Successfully added GP extension '%s' %s\n", + name, GUID_string2(gpext_ctx, entry->guid))); + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS gp_extension_init_module(TALLOC_CTX *mem_ctx, + const char *name, + struct gp_extension **gpext) +{ + NTSTATUS status; + struct gp_extension *ext = NULL; + + ext = TALLOC_ZERO_P(mem_ctx, struct gp_extension); + NT_STATUS_HAVE_NO_MEMORY(gpext); + + ext->methods = get_methods_by_name(extensions, name); + if (!ext->methods) { + + status = smb_probe_module(SAMBA_SUBSYSTEM_GPEXT, + name); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + ext->methods = get_methods_by_name(extensions, name); + if (!ext->methods) { + return NT_STATUS_DLL_INIT_FAILED; + } + } + + *gpext = ext; + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static bool add_gp_extension_reg_entry_to_array(TALLOC_CTX *mem_ctx, + struct gp_extension_reg_entry *entry, + struct gp_extension_reg_entry **entries, + size_t *num) +{ + *entries = TALLOC_REALLOC_ARRAY(mem_ctx, *entries, + struct gp_extension_reg_entry, + (*num)+1); + if (*entries == NULL) { + *num = 0; + return false; + } + + (*entries)[*num].value = entry->value; + (*entries)[*num].data = entry->data; + + *num += 1; + return true; +} + +/**************************************************************** +****************************************************************/ + +static bool add_gp_extension_reg_info_entry_to_array(TALLOC_CTX *mem_ctx, + struct gp_extension_reg_info_entry *entry, + struct gp_extension_reg_info_entry **entries, + size_t *num) +{ + *entries = TALLOC_REALLOC_ARRAY(mem_ctx, *entries, + struct gp_extension_reg_info_entry, + (*num)+1); + if (*entries == NULL) { + *num = 0; + return false; + } + + (*entries)[*num].guid = entry->guid; + (*entries)[*num].num_entries = entry->num_entries; + (*entries)[*num].entries = entry->entries; + + *num += 1; + return true; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS gp_ext_info_add_reg(TALLOC_CTX *mem_ctx, + struct gp_extension_reg_info_entry *entry, + const char *value, + enum winreg_Type type, + const char *data_s) +{ + struct gp_extension_reg_entry *reg_entry = NULL; + struct registry_value *data = NULL; + + reg_entry = TALLOC_ZERO_P(mem_ctx, struct gp_extension_reg_entry); + NT_STATUS_HAVE_NO_MEMORY(reg_entry); + + data = TALLOC_ZERO_P(mem_ctx, struct registry_value); + NT_STATUS_HAVE_NO_MEMORY(data); + + data->type = type; + + switch (type) { + case REG_SZ: + case REG_EXPAND_SZ: + data->v.sz.str = talloc_strdup(mem_ctx, data_s); + NT_STATUS_HAVE_NO_MEMORY(data->v.sz.str); + data->v.sz.len = strlen(data_s); + break; + case REG_DWORD: + data->v.dword = atoi(data_s); + break; + default: + return NT_STATUS_NOT_SUPPORTED; + } + + reg_entry->value = value; + reg_entry->data = data; + + if (!add_gp_extension_reg_entry_to_array(mem_ctx, reg_entry, + &entry->entries, + &entry->num_entries)) { + return NT_STATUS_NO_MEMORY; + } + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS gp_ext_info_add_reg_table(TALLOC_CTX *mem_ctx, + const char *module, + struct gp_extension_reg_info_entry *entry, + struct gp_extension_reg_table *table) +{ + NTSTATUS status; + const char *module_name = NULL; + int i; + + module_name = talloc_asprintf(mem_ctx, "%s.%s", module, shlib_ext()); + NT_STATUS_HAVE_NO_MEMORY(module_name); + + status = gp_ext_info_add_reg(mem_ctx, entry, + "DllName", REG_EXPAND_SZ, module_name); + NT_STATUS_NOT_OK_RETURN(status); + + for (i=0; table[i].val; i++) { + status = gp_ext_info_add_reg(mem_ctx, entry, + table[i].val, + table[i].type, + table[i].data); + NT_STATUS_NOT_OK_RETURN(status); + } + + return status; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS gp_ext_info_add_entry(TALLOC_CTX *mem_ctx, + const char *module, + const char *ext_guid, + struct gp_extension_reg_table *table, + struct gp_extension_reg_info *info) +{ + NTSTATUS status; + struct gp_extension_reg_info_entry *entry = NULL; + + entry = TALLOC_ZERO_P(mem_ctx, struct gp_extension_reg_info_entry); + NT_STATUS_HAVE_NO_MEMORY(entry); + + status = GUID_from_string(ext_guid, &entry->guid); + NT_STATUS_NOT_OK_RETURN(status); + + status = gp_ext_info_add_reg_table(mem_ctx, module, entry, table); + NT_STATUS_NOT_OK_RETURN(status); + + if (!add_gp_extension_reg_info_entry_to_array(mem_ctx, entry, + &info->entries, + &info->num_entries)) { + return NT_STATUS_NO_MEMORY; + } + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static bool gp_extension_reg_info_verify_entry(struct gp_extension_reg_entry *entry) +{ + int i; + + for (i=0; gpext_reg_vals[i].val; i++) { + + if ((strequal(entry->value, gpext_reg_vals[i].val)) && + (entry->data->type == gpext_reg_vals[i].type)) { + return true; + } + } + + return false; +} + +/**************************************************************** +****************************************************************/ + +static bool gp_extension_reg_info_verify(struct gp_extension_reg_info_entry *entry) +{ + int i; + + for (i=0; i < entry->num_entries; i++) { + if (!gp_extension_reg_info_verify_entry(&entry->entries[i])) { + return false; + } + } + + return true; +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_extension_store_reg_vals(TALLOC_CTX *mem_ctx, + struct registry_key *key, + struct gp_extension_reg_info_entry *entry) +{ + WERROR werr = WERR_OK; + size_t i; + + for (i=0; i < entry->num_entries; i++) { + + werr = reg_setvalue(key, + entry->entries[i].value, + entry->entries[i].data); + W_ERROR_NOT_OK_RETURN(werr); + } + + return werr; +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_extension_store_reg_entry(TALLOC_CTX *mem_ctx, + struct gp_registry_context *reg_ctx, + struct gp_extension_reg_info_entry *entry) +{ + WERROR werr; + struct registry_key *key = NULL; + const char *subkeyname = NULL; + + if (!gp_extension_reg_info_verify(entry)) { + return WERR_INVALID_PARAM; + } + + subkeyname = GUID_string2(mem_ctx, &entry->guid); + W_ERROR_HAVE_NO_MEMORY(subkeyname); + + strupper_m(CONST_DISCARD(char *,subkeyname)); + + werr = gp_store_reg_subkey(mem_ctx, + subkeyname, + reg_ctx->curr_key, + &key); + W_ERROR_NOT_OK_RETURN(werr); + + werr = gp_extension_store_reg_vals(mem_ctx, + key, + entry); + W_ERROR_NOT_OK_RETURN(werr); + + return werr; +} + +/**************************************************************** +****************************************************************/ + +static WERROR gp_extension_store_reg(TALLOC_CTX *mem_ctx, + struct gp_registry_context *reg_ctx, + struct gp_extension_reg_info *info) +{ + WERROR werr = WERR_OK; + int i; + + if (!info) { + return WERR_OK; + } + + for (i=0; i < info->num_entries; i++) { + werr = gp_extension_store_reg_entry(mem_ctx, + reg_ctx, + &info->entries[i]); + W_ERROR_NOT_OK_RETURN(werr); + } + + return werr; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS gp_glob_ext_list(TALLOC_CTX *mem_ctx, + const char ***ext_list, + size_t *ext_list_len) +{ + SMB_STRUCT_DIR *dir = NULL; + SMB_STRUCT_DIRENT *dirent = NULL; + + dir = sys_opendir(lib_path(SAMBA_SUBSYSTEM_GPEXT)); + if (!dir) { + return map_nt_error_from_unix(errno); + } + + while ((dirent = sys_readdir(dir))) { + + fstring name; /* forgive me... */ + char *p; + + if ((strequal(dirent->d_name, ".")) || + (strequal(dirent->d_name, ".."))) { + continue; + } + + p = strrchr(dirent->d_name, '.'); + if (!p) { + sys_closedir(dir); + return NT_STATUS_NO_MEMORY; + } + + if (!strcsequal(p+1, shlib_ext())) { + DEBUG(10,("gp_glob_ext_list: not a *.so file: %s\n", + dirent->d_name)); + continue; + } + + fstrcpy(name, dirent->d_name); + name[PTR_DIFF(p, dirent->d_name)] = 0; + + if (!add_string_to_array(mem_ctx, name, ext_list, + (int *)ext_list_len)) { + sys_closedir(dir); + return NT_STATUS_NO_MEMORY; + } + } + + sys_closedir(dir); + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS shutdown_gp_extensions(void) +{ + struct gp_extension *ext = NULL; + + for (ext = extensions; ext; ext = ext->next) { + if (ext->methods && ext->methods->shutdown) { + ext->methods->shutdown(); + } + } + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS init_gp_extensions(TALLOC_CTX *mem_ctx) +{ + NTSTATUS status; + WERROR werr; + int i = 0; + const char **ext_array = NULL; + size_t ext_array_len = 0; + struct gp_extension *gpext = NULL; + struct gp_registry_context *reg_ctx = NULL; + + if (get_gp_extension_list()) { + return NT_STATUS_OK; + } + + status = gp_glob_ext_list(mem_ctx, &ext_array, &ext_array_len); + NT_STATUS_NOT_OK_RETURN(status); + + for (i=0; imethods->get_reg_config) { + + status = gpext->methods->initialize(mem_ctx); + if (!NT_STATUS_IS_OK(status)) { + gpext->methods->shutdown(); + goto out; + } + + status = gpext->methods->get_reg_config(mem_ctx, + &info); + if (!NT_STATUS_IS_OK(status)) { + gpext->methods->shutdown(); + goto out; + } + + if (!reg_ctx) { + struct nt_user_token *token; + + token = registry_create_system_token(mem_ctx); + NT_STATUS_HAVE_NO_MEMORY(token); + + werr = gp_init_reg_ctx(mem_ctx, + KEY_WINLOGON_GPEXT_PATH, + REG_KEY_WRITE, + token, + ®_ctx); + if (!W_ERROR_IS_OK(werr)) { + status = werror_to_ntstatus(werr); + gpext->methods->shutdown(); + goto out; + } + } + + werr = gp_extension_store_reg(mem_ctx, reg_ctx, info); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(1,("gp_extension_store_reg failed: %s\n", + dos_errstr(werr))); + TALLOC_FREE(info); + gpext->methods->shutdown(); + status = werror_to_ntstatus(werr); + goto out; + } + TALLOC_FREE(info); + } + + } + + out: + TALLOC_FREE(reg_ctx); + + return status; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS free_gp_extensions(void) +{ + struct gp_extension *ext, *ext_next = NULL; + + for (ext = extensions; ext; ext = ext_next) { + ext_next = ext->next; + DLIST_REMOVE(extensions, ext); + TALLOC_FREE(ext); + } + + extensions = NULL; + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +void debug_gpext_header(int lvl, + const char *name, + uint32_t flags, + struct GROUP_POLICY_OBJECT *gpo, + const char *extension_guid, + const char *snapin_guid) +{ + char *flags_str = NULL; + + DEBUG(lvl,("%s\n", name)); + DEBUGADD(lvl,("\tgpo: %s (%s)\n", gpo->name, + gpo->display_name)); + DEBUGADD(lvl,("\tcse extension: %s (%s)\n", extension_guid, + cse_gpo_guid_string_to_name(extension_guid))); + DEBUGADD(lvl,("\tgplink: %s\n", gpo->link)); + DEBUGADD(lvl,("\tsnapin: %s (%s)\n", snapin_guid, + cse_snapin_gpo_guid_string_to_name(snapin_guid))); + + flags_str = gpo_flag_str(flags); + DEBUGADD(lvl,("\tflags: 0x%08x %s\n", flags, flags_str)); + SAFE_FREE(flags_str); +} + +NTSTATUS process_gpo_list_with_extension(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + const struct nt_user_token *token, + struct GROUP_POLICY_OBJECT *gpo_list, + const char *extension_guid, + const char *snapin_guid) +{ + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS gpext_process_extension(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + const struct nt_user_token *token, + struct registry_key *root_key, + struct GROUP_POLICY_OBJECT *gpo, + const char *extension_guid, + const char *snapin_guid) +{ + NTSTATUS status; + struct gp_extension *ext = NULL; + struct GUID guid; + bool cse_found = false; + + status = init_gp_extensions(mem_ctx); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1,("init_gp_extensions failed: %s\n", + nt_errstr(status))); + return status; + } + + status = GUID_from_string(extension_guid, &guid); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + for (ext = extensions; ext; ext = ext->next) { + + if (GUID_equal(ext->guid, &guid)) { + cse_found = true; + break; + } + } + + if (!cse_found) { + goto no_ext; + } + + status = ext->methods->initialize(mem_ctx); + NT_STATUS_NOT_OK_RETURN(status); + + status = ext->methods->process_group_policy(ads, + mem_ctx, + flags, + root_key, + token, + gpo, + extension_guid, + snapin_guid); + if (!NT_STATUS_IS_OK(status)) { + ext->methods->shutdown(); + } + + return status; + + no_ext: + if (flags & GPO_INFO_FLAG_VERBOSE) { + DEBUG(0,("process_extension: no extension available for:\n")); + DEBUGADD(0,("%s (%s) (snapin: %s)\n", + extension_guid, + cse_gpo_guid_string_to_name(extension_guid), + snapin_guid)); + } + + return NT_STATUS_OK; +} diff --git a/source3/libgpo/gpext/gpext.h b/source3/libgpo/gpext/gpext.h new file mode 100644 index 0000000000..0f0445701d --- /dev/null +++ b/source3/libgpo/gpext/gpext.h @@ -0,0 +1,79 @@ +/* + * Unix SMB/CIFS implementation. + * Group Policy Support + * 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 + * 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 . + */ + +#define KEY_WINLOGON_GPEXT_PATH "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\GPExtensions" + +#define SAMBA_SUBSYSTEM_GPEXT "gpext" + +#define SMB_GPEXT_INTERFACE_VERSION 1 + +struct gp_extension { + struct GUID *guid; + const char *name; + struct gp_extension_methods *methods; + struct gp_extension *prev, *next; +}; + +struct gp_extension_reg_table { + const char *val; + enum winreg_Type type; + const char *data; +}; + +struct gp_extension_reg_entry { + const char *value; + struct registry_value *data; +}; + +struct gp_extension_reg_info_entry { + struct GUID guid; + size_t num_entries; + struct gp_extension_reg_entry *entries; +}; + +struct gp_extension_reg_info { + size_t num_entries; + struct gp_extension_reg_info_entry *entries; +}; + +struct gp_extension_methods { + + NTSTATUS (*initialize)(TALLOC_CTX *mem_ctx); + + NTSTATUS (*process_group_policy)(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + struct registry_key *root_key, + const struct nt_user_token *token, + struct GROUP_POLICY_OBJECT *gpo, + const char *extension_guid, + const char *snapin_guid); + + NTSTATUS (*process_group_policy2)(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + const struct nt_user_token *token, + struct GROUP_POLICY_OBJECT *gpo_list, + const char *extension_guid); + + NTSTATUS (*get_reg_config)(TALLOC_CTX *mem_ctx, + struct gp_extension_reg_info **info); + + NTSTATUS (*shutdown)(void); +}; diff --git a/source3/libgpo/gpo_util.c b/source3/libgpo/gpo_util.c index cd532da48b..bc6c35726c 100644 --- a/source3/libgpo/gpo_util.c +++ b/source3/libgpo/gpo_util.c @@ -668,6 +668,39 @@ NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads, /**************************************************************** ****************************************************************/ +char *gpo_flag_str(uint32_t flags) +{ + fstring str = ""; + + if (flags == 0) { + return NULL; + } + + if (flags & GPO_INFO_FLAG_SLOWLINK) + fstrcat(str, "GPO_INFO_FLAG_SLOWLINK "); + if (flags & GPO_INFO_FLAG_VERBOSE) + fstrcat(str, "GPO_INFO_FLAG_VERBOSE "); + if (flags & GPO_INFO_FLAG_SAFEMODE_BOOT) + fstrcat(str, "GPO_INFO_FLAG_SAFEMODE_BOOT "); + if (flags & GPO_INFO_FLAG_NOCHANGES) + fstrcat(str, "GPO_INFO_FLAG_NOCHANGES "); + if (flags & GPO_INFO_FLAG_MACHINE) + fstrcat(str, "GPO_INFO_FLAG_MACHINE "); + if (flags & GPO_INFO_FLAG_LOGRSOP_TRANSITION) + fstrcat(str, "GPO_INFO_FLAG_LOGRSOP_TRANSITION "); + if (flags & GPO_INFO_FLAG_LINKTRANSITION) + fstrcat(str, "GPO_INFO_FLAG_LINKTRANSITION "); + if (flags & GPO_INFO_FLAG_FORCED_REFRESH) + fstrcat(str, "GPO_INFO_FLAG_FORCED_REFRESH "); + if (flags & GPO_INFO_FLAG_BACKGROUND) + fstrcat(str, "GPO_INFO_FLAG_BACKGROUND "); + + return SMB_STRDUP(str); +} + +/**************************************************************** +****************************************************************/ + NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx, uint32_t flags, const char *filename, -- cgit From 485b070eb86492dc07c29ae63634fb99389baea6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 17:06:22 +0100 Subject: Add "registry" Group Policy extension. Guenther (This used to be commit 4e93301ca4931908a7d1994be45c57002f8c6fea) --- source3/Makefile.in | 13 +- source3/configure.in | 2 + source3/libgpo/gpext/registry.c | 634 ++++++++++++++++++++++++++++++++++++++++ source3/libgpo/gpo_util.c | 12 + 4 files changed, 660 insertions(+), 1 deletion(-) create mode 100644 source3/libgpo/gpext/registry.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index cfb607a977..d01abc9afc 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -102,6 +102,7 @@ NSSINFOLIBDIR = $(LIBDIR)/nss_info CHARSETLIBDIR = $(LIBDIR)/charset AUTHLIBDIR = $(LIBDIR)/auth CONFIGLIBDIR = $(LIBDIR)/config +GPEXTLIBDIR = $(LIBDIR)/gpext CONFIGDIR = @configdir@ VARDIR = @localstatedir@ MANDIR = @mandir@ @@ -231,8 +232,10 @@ IDMAP_MODULES = @IDMAP_MODULES@ CHARSET_MODULES = @CHARSET_MODULES@ AUTH_MODULES = @AUTH_MODULES@ NSS_INFO_MODULES = @NSS_INFO_MODULES@ +GPEXT_MODULES = @GPEXT_MODULES@ MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(IDMAP_MODULES) \ - $(CHARSET_MODULES) $(AUTH_MODULES) $(NSS_INFO_MODULES) + $(CHARSET_MODULES) $(AUTH_MODULES) $(NSS_INFO_MODULES) \ + $(GPEXT_MODULES) ###################################################################### # object file lists @@ -1087,6 +1090,8 @@ nss_modules : $(NSS_MODULES) pam_modules : $(PAM_MODULES) +gpext_modules : SHOWFLAGS $(GPEXT_MODULES) + pam_smbpass : SHOWFLAGS bin/pam_smbpass.@SHLIBEXT@ pam_winbind : SHOWFLAGS bin/pam_winbind.@SHLIBEXT@ @@ -1863,6 +1868,10 @@ bin/aio_fork.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_AIO_FORK_OBJ) @echo "Building plugin $@" @$(SHLD_MODULE) $(VFS_AIO_FORK_OBJ) +bin/registry.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/registry.o + @echo "Building plugin $@" + @$(SHLD_MODULE) libgpo/gpext/registry.o + ######################################################### ## IdMap NSS plugins @@ -1962,6 +1971,7 @@ installmodules: modules installdirs @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix) $(NSSINFOLIBDIR) $(NSS_INFO_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix) $(CHARSETLIBDIR) $(CHARSET_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix) $(AUTHLIBDIR) $(AUTH_MODULES) + @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix) $(GPEXTLIBDIR) $(GPEXT_MODULES) @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(PDBLIBDIR) ldapsam.@SHLIBEXT@ NDS_ldapsam.@SHLIBEXT@ @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(PDBLIBDIR) ldapsam.@SHLIBEXT@ NDS_ldapsam_compat.@SHLIBEXT@ @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(PDBLIBDIR) ldapsam.@SHLIBEXT@ ldapsam_compat.@SHLIBEXT@ @@ -2084,6 +2094,7 @@ uninstallmodules: @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix) $(IDMAPLIBDIR) $(IDMAP_MODULES) @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix) $(CHARSETLIBDIR) $(CHARSET_MODULES) @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix) $(AUTHLIBDIR) $(AUTH_MODULES) + @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix) $(GPEXTLIBDIR) $(GPEXT_MODULES) uninstallscripts: @$(SHELL) $(srcdir)/script/uninstallscripts.sh $(INSTALLPERMS_BIN) $(DESTDIR)$(BINDIR) $(SCRIPTS) diff --git a/source3/configure.in b/source3/configure.in index c4f6d92bfa..056c0f8049 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -109,6 +109,7 @@ AC_SUBST(IDMAP_LIBS) AC_SUBST(KRB5_LIBS) AC_SUBST(UUID_LIBS) AC_SUBST(LDAP_LIBS) +AC_SUBST(GPEXT_LIBS) AC_SUBST(PAM_MODULES) AC_SUBST(INSTALL_PAM_MODULES) AC_SUBST(UNINSTALL_PAM_MODULES) @@ -6078,6 +6079,7 @@ SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", V SMB_SUBSYSTEM(VFS,smbd/vfs.o) +SMB_MODULE(gpext_registry, libgpo/gpext/registry.o, "bin/registry.$SHLIBEXT", GPEXT) SMB_SUBSYSTEM(GPEXT, libgpo/gpext/gpext.o) AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) diff --git a/source3/libgpo/gpext/registry.c b/source3/libgpo/gpext/registry.c new file mode 100644 index 0000000000..6cad8c796c --- /dev/null +++ b/source3/libgpo/gpext/registry.c @@ -0,0 +1,634 @@ +/* + * Unix SMB/CIFS implementation. + * Group Policy Support + * 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 + * 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 "includes.h" + +#define GP_EXT_NAME "registry" + +/* more info can be found at: + * http://msdn2.microsoft.com/en-us/library/aa374407.aspx */ + +#define GP_REGPOL_FILE "Registry.pol" + +#define GP_REGPOL_FILE_SIGNATURE 0x67655250 /* 'PReg' */ +#define GP_REGPOL_FILE_VERSION 1 + +static TALLOC_CTX *ctx = NULL; + +struct gp_registry_file_header { + uint32_t signature; + uint32_t version; +}; + +struct gp_registry_file_entry { + UNISTR key; + UNISTR value; + enum winreg_Type type; + size_t size; + uint8_t *data; +}; + +struct gp_registry_file { + struct gp_registry_file_header header; + size_t num_entries; + struct gp_registry_entry *entries; +}; + +/**************************************************************** +****************************************************************/ + +static bool reg_parse_header(const char *desc, + struct gp_registry_file_header *header, + prs_struct *ps, + int depth) +{ + if (!header) + return false; + + prs_debug(ps, depth, desc, "reg_parse_header"); + depth++; + + if (!prs_uint32("signature", ps, depth, &header->signature)) + return false; + + if (!prs_uint32("version", ps, depth, &header->version)) + return false; + + return true; +} + +/**************************************************************** +****************************************************************/ + +static bool reg_parse_and_verify_ucs2_char(const char *desc, + char character, + prs_struct *ps, + int depth) +{ + uint16_t tmp; + + if (!prs_uint16(desc, ps, depth, &tmp)) + return false; + + if (tmp != UCS2_CHAR(character)) + return false; + + return true; +} + +/**************************************************************** +****************************************************************/ + +static bool reg_parse_init(prs_struct *ps, int depth) +{ + return reg_parse_and_verify_ucs2_char("initiator '['", '[', + ps, depth); +} + +/**************************************************************** +****************************************************************/ + +static bool reg_parse_sep(prs_struct *ps, int depth) +{ + return reg_parse_and_verify_ucs2_char("separator ';'", ';', + ps, depth); +} + +/**************************************************************** +****************************************************************/ + +static bool reg_parse_term(prs_struct *ps, int depth) +{ + return reg_parse_and_verify_ucs2_char("terminator ']'", ']', + ps, depth); +} + + +/**************************************************************** +* [key;value;type;size;data] +****************************************************************/ + +static bool reg_parse_entry(TALLOC_CTX *mem_ctx, + const char *desc, + struct gp_registry_file_entry *entry, + prs_struct *ps, + int depth) +{ + uint32_t size = 0; + + if (!entry) + return false; + + prs_debug(ps, depth, desc, "reg_parse_entry"); + depth++; + + ZERO_STRUCTP(entry); + + if (!reg_parse_init(ps, depth)) + return false; + + if (!prs_unistr("key", ps, depth, &entry->key)) + return false; + + if (!reg_parse_sep(ps, depth)) + return false; + + if (!prs_unistr("value", ps, depth, &entry->value)) + return false; + + if (!reg_parse_sep(ps, depth)) + return false; + + if (!prs_uint32("type", ps, depth, &entry->type)) + return false; + + if (!reg_parse_sep(ps, depth)) + return false; + + if (!prs_uint32("size", ps, depth, &size)) + return false; + + entry->size = size; + + if (!reg_parse_sep(ps, depth)) + return false; + + if (entry->size) { + entry->data = TALLOC_ZERO_ARRAY(mem_ctx, uint8, entry->size); + if (!entry->data) + return false; + } + + if (!prs_uint8s(false, "data", ps, depth, entry->data, entry->size)) + return false; + + if (!reg_parse_term(ps, depth)) + return false; + + return true; +} + +/**************************************************************** +****************************************************************/ + +static bool reg_parse_value(TALLOC_CTX *mem_ctx, + char **value, + enum gp_reg_action *action) +{ + if (!*value) { + *action = GP_REG_ACTION_ADD_KEY; + return true; + } + + if (strncmp(*value, "**", 2) != 0) { + *action = GP_REG_ACTION_ADD_VALUE; + return true; + } + + if (strnequal(*value, "**DelVals.", 10)) { + *action = GP_REG_ACTION_DEL_ALL_VALUES; + return true; + } + + if (strnequal(*value, "**Del.", 6)) { + *value = talloc_strdup(mem_ctx, *value + 6); + *action = GP_REG_ACTION_DEL_VALUE; + return true; + } + + if (strnequal(*value, "**SecureKey", 11)) { + if (strnequal(*value, "**SecureKey=1", 13)) { + *action = GP_REG_ACTION_SEC_KEY_SET; + return true; + } + + /*************** not tested from here on ***************/ + if (strnequal(*value, "**SecureKey=0", 13)) { + smb_panic("not supported: **SecureKey=0"); + *action = GP_REG_ACTION_SEC_KEY_RESET; + return true; + } + DEBUG(0,("unknown: SecureKey: %s\n", *value)); + smb_panic("not supported SecureKey method"); + return false; + } + + if (strnequal(*value, "**DeleteValues", strlen("**DeleteValues"))) { + smb_panic("not supported: **DeleteValues"); + *action = GP_REG_ACTION_DEL_VALUES; + return false; + } + + if (strnequal(*value, "**DeleteKeys", strlen("**DeleteKeys"))) { + smb_panic("not supported: **DeleteKeys"); + *action = GP_REG_ACTION_DEL_KEYS; + return false; + } + + DEBUG(0,("unknown value: %s\n", *value)); + smb_panic(*value); + return false; +} + +/**************************************************************** +****************************************************************/ + +static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx, + struct gp_registry_file_entry *file_entry, + struct gp_registry_entry **reg_entry) +{ + struct registry_value *data = NULL; + struct gp_registry_entry *entry = NULL; + char *key = NULL; + char *value = NULL; + enum gp_reg_action action = GP_REG_ACTION_NONE; + + ZERO_STRUCTP(*reg_entry); + + data = TALLOC_ZERO_P(mem_ctx, struct registry_value); + if (!data) + return false; + + if (strlen_w((const smb_ucs2_t *)file_entry->key.buffer) <= 0) + return false; + + if (!pull_ucs2_talloc(mem_ctx, &key, file_entry->key.buffer)) + return false; + + if (strlen_w((const smb_ucs2_t *)file_entry->value.buffer) > 0) { + if (!pull_ucs2_talloc(mem_ctx, &value, + file_entry->value.buffer)) + return false; + } + + if (!reg_parse_value(mem_ctx, &value, &action)) + return false; + + data->type = file_entry->type; + + switch (data->type) { + case REG_DWORD: + data->v.dword = atoi((char *)file_entry->data); + break; + case REG_BINARY: + data->v.binary = data_blob_talloc(mem_ctx, + file_entry->data, + file_entry->size); + break; + case REG_NONE: + break; + case REG_SZ: + data->v.sz.len = pull_ucs2_talloc(mem_ctx, + &data->v.sz.str, + (const smb_ucs2_t *)file_entry->data); + break; + case REG_DWORD_BIG_ENDIAN: + case REG_EXPAND_SZ: + case REG_LINK: + case REG_MULTI_SZ: + case REG_QWORD: +/* case REG_DWORD_LITTLE_ENDIAN: */ +/* case REG_QWORD_LITTLE_ENDIAN: */ + printf("not yet implemented: %d\n", data->type); + return false; + default: + printf("invalid reg type defined: %d\n", data->type); + return false; + + } + + entry = TALLOC_ZERO_P(mem_ctx, struct gp_registry_entry); + if (!entry) + return false; + + entry->key = key; + entry->value = value; + entry->data = data; + entry->action = action; + + *reg_entry = entry; + + return true; +} + +/**************************************************************** +* [key;value;type;size;data][key;value;type;size;data]... +****************************************************************/ + +static bool reg_parse_entries(TALLOC_CTX *mem_ctx, + const char *desc, + struct gp_registry_entry **entries, + size_t *num_entries, + prs_struct *ps, + int depth) +{ + + if (!entries || !num_entries) + return false; + + prs_debug(ps, depth, desc, "reg_parse_entries"); + depth++; + + *entries = NULL; + *num_entries = 0; + + while (ps->buffer_size > ps->data_offset) { + + struct gp_registry_file_entry f_entry; + struct gp_registry_entry *r_entry = NULL; + + if (!reg_parse_entry(mem_ctx, desc, &f_entry, + ps, depth)) + return false; + + if (!gp_reg_entry_from_file_entry(mem_ctx, + &f_entry, + &r_entry)) + return false; + + if (!add_gp_registry_entry_to_array(mem_ctx, + r_entry, + entries, + num_entries)) + return false; + } + + return true; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS reg_parse_registry(TALLOC_CTX *mem_ctx, + uint32_t flags, + const char *filename, + struct gp_registry_entry **entries, + size_t *num_entries) +{ + uint16_t *buf = NULL; + size_t n = 0; + NTSTATUS status; + prs_struct ps; + struct gp_registry_file *reg_file; + const char *real_filename = NULL; + + reg_file = TALLOC_ZERO_P(mem_ctx, struct gp_registry_file); + NT_STATUS_HAVE_NO_MEMORY(reg_file); + + status = gp_find_file(mem_ctx, + flags, + filename, + GP_REGPOL_FILE, + &real_filename); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(reg_file); + return status; + } + + buf = (uint16 *)file_load(real_filename, &n, 0); + if (!buf) { + TALLOC_FREE(reg_file); + return NT_STATUS_CANNOT_LOAD_REGISTRY_FILE; + } + + if (!prs_init(&ps, n, mem_ctx, UNMARSHALL)) { + status = NT_STATUS_NO_MEMORY; + goto out; + } + + if (!prs_copy_data_in(&ps, (char *)buf, n)) { + status = NT_STATUS_NO_MEMORY; + goto out; + } + + prs_set_offset(&ps, 0); + + if (!reg_parse_header("header", ®_file->header, &ps, 0)) { + status = NT_STATUS_REGISTRY_IO_FAILED; + goto out; + } + + if (reg_file->header.signature != GP_REGPOL_FILE_SIGNATURE) { + status = NT_STATUS_INVALID_PARAMETER; + goto out; + } + + if (reg_file->header.version != GP_REGPOL_FILE_VERSION) { + status = NT_STATUS_INVALID_PARAMETER; + goto out; + } + + if (!reg_parse_entries(mem_ctx, "entries", ®_file->entries, + ®_file->num_entries, &ps, 0)) { + status = NT_STATUS_REGISTRY_IO_FAILED; + goto out; + } + + *entries = reg_file->entries; + *num_entries = reg_file->num_entries; + + status = NT_STATUS_OK; + + out: + SAFE_FREE(buf); + prs_mem_free(&ps); + + return status; +} + +/**************************************************************** +****************************************************************/ + +static WERROR reg_apply_registry(TALLOC_CTX *mem_ctx, + const struct nt_user_token *token, + struct registry_key *root_key, + uint32_t flags, + struct gp_registry_entry *entries, + size_t num_entries) +{ + struct gp_registry_context *reg_ctx = NULL; + WERROR werr; + size_t i; + + if (num_entries == 0) { + return WERR_OK; + } + +#if 0 + if (flags & GPO_LIST_FLAG_MACHINE) { + werr = gp_init_reg_ctx(mem_ctx, KEY_HKLM, REG_KEY_WRITE, + get_system_token(), + ®_ctx); + } else { + werr = gp_init_reg_ctx(mem_ctx, KEY_HKCU, REG_KEY_WRITE, + token, + ®_ctx); + } + W_ERROR_NOT_OK_RETURN(werr); +#endif + for (i=0; ifile_sys_path, + &server, &share, &nt_path, unix_path); +} + +/**************************************************************** +****************************************************************/ + char *gpo_flag_str(uint32_t flags) { fstring str = ""; -- cgit From 3afcd3ab8399c15154a020f5dd80e217f41899a3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 17:45:25 +0100 Subject: what a wurst. (This used to be commit ab687104c1371c84c510eca7ef2caad7c21ea8fc) --- source3/lib/util_nttoken.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ source3/libgpo/gpo_util.c | 25 +++++++++++++++++++++++ 2 files changed, 75 insertions(+) (limited to 'source3') diff --git a/source3/lib/util_nttoken.c b/source3/lib/util_nttoken.c index 13c66a5f45..f81191af58 100644 --- a/source3/lib/util_nttoken.c +++ b/source3/lib/util_nttoken.c @@ -7,6 +7,7 @@ * Copyright (C) Rafal Szczesniak 2002 * Copyright (C) Volker Lendecke 2006 * Copyright (C) Michael Adam 2007 + * Copyright (C) Guenther Deschner 2007 * * 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 @@ -67,3 +68,52 @@ NT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, const NT_USER_TOKEN *ptoken) return token; } +/**************************************************************************** + merge NT tokens +****************************************************************************/ + +NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx, + const struct nt_user_token *token_1, + const struct nt_user_token *token_2, + struct nt_user_token **token_out) +{ + struct nt_user_token *token = NULL; + NTSTATUS status; + int i; + + if (!token_1 || !token_2 || !token_out) { + return NT_STATUS_INVALID_PARAMETER; + } + + token = TALLOC_ZERO_P(mem_ctx, struct nt_user_token); + NT_STATUS_HAVE_NO_MEMORY(token); + + for (i=0; i < token_1->num_sids; i++) { + status = add_sid_to_array_unique(mem_ctx, + &token_1->user_sids[i], + &token->user_sids, + &token->num_sids); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(token); + return status; + } + } + + for (i=0; i < token_2->num_sids; i++) { + status = add_sid_to_array_unique(mem_ctx, + &token_2->user_sids[i], + &token->user_sids, + &token->num_sids); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(token); + return status; + } + } + + se_priv_add(&token->privileges, &token_1->privileges); + se_priv_add(&token->privileges, &token_2->privileges); + + *token_out = token; + + return NT_STATUS_OK; +} diff --git a/source3/libgpo/gpo_util.c b/source3/libgpo/gpo_util.c index 79f2690245..b9053d0ae5 100644 --- a/source3/libgpo/gpo_util.c +++ b/source3/libgpo/gpo_util.c @@ -750,3 +750,28 @@ NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_SUCH_FILE; } +/**************************************************************** +****************************************************************/ + +ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *dn, + struct nt_user_token **token) +{ + struct nt_user_token *ad_token = NULL; + ADS_STATUS status; + NTSTATUS ntstatus; + + status = ads_get_sid_token(ads, mem_ctx, dn, &ad_token); + if (!ADS_ERR_OK(status)) { + return status; + } + + ntstatus = merge_nt_token(mem_ctx, ad_token, get_system_token(), + token); + if (!NT_STATUS_IS_OK(ntstatus)) { + return ADS_ERROR_NT(ntstatus); + } + + return ADS_SUCCESS; +} -- cgit From f3efceace4ad097882f6574b533318d332bff6b1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 18:19:06 +0100 Subject: Revert "what a wurst." That commit message was just too silly, this happens to me during interactive rebase all the time... This reverts commit ab687104c1371c84c510eca7ef2caad7c21ea8fc. (This used to be commit a3a1edab0d5ac07d42e64a5a82dd71fe0c3fdfeb) --- source3/lib/util_nttoken.c | 50 ---------------------------------------------- source3/libgpo/gpo_util.c | 25 ----------------------- 2 files changed, 75 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_nttoken.c b/source3/lib/util_nttoken.c index f81191af58..13c66a5f45 100644 --- a/source3/lib/util_nttoken.c +++ b/source3/lib/util_nttoken.c @@ -7,7 +7,6 @@ * Copyright (C) Rafal Szczesniak 2002 * Copyright (C) Volker Lendecke 2006 * Copyright (C) Michael Adam 2007 - * Copyright (C) Guenther Deschner 2007 * * 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 @@ -68,52 +67,3 @@ NT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, const NT_USER_TOKEN *ptoken) return token; } -/**************************************************************************** - merge NT tokens -****************************************************************************/ - -NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx, - const struct nt_user_token *token_1, - const struct nt_user_token *token_2, - struct nt_user_token **token_out) -{ - struct nt_user_token *token = NULL; - NTSTATUS status; - int i; - - if (!token_1 || !token_2 || !token_out) { - return NT_STATUS_INVALID_PARAMETER; - } - - token = TALLOC_ZERO_P(mem_ctx, struct nt_user_token); - NT_STATUS_HAVE_NO_MEMORY(token); - - for (i=0; i < token_1->num_sids; i++) { - status = add_sid_to_array_unique(mem_ctx, - &token_1->user_sids[i], - &token->user_sids, - &token->num_sids); - if (!NT_STATUS_IS_OK(status)) { - TALLOC_FREE(token); - return status; - } - } - - for (i=0; i < token_2->num_sids; i++) { - status = add_sid_to_array_unique(mem_ctx, - &token_2->user_sids[i], - &token->user_sids, - &token->num_sids); - if (!NT_STATUS_IS_OK(status)) { - TALLOC_FREE(token); - return status; - } - } - - se_priv_add(&token->privileges, &token_1->privileges); - se_priv_add(&token->privileges, &token_2->privileges); - - *token_out = token; - - return NT_STATUS_OK; -} diff --git a/source3/libgpo/gpo_util.c b/source3/libgpo/gpo_util.c index b9053d0ae5..79f2690245 100644 --- a/source3/libgpo/gpo_util.c +++ b/source3/libgpo/gpo_util.c @@ -750,28 +750,3 @@ NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_SUCH_FILE; } -/**************************************************************** -****************************************************************/ - -ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, - TALLOC_CTX *mem_ctx, - const char *dn, - struct nt_user_token **token) -{ - struct nt_user_token *ad_token = NULL; - ADS_STATUS status; - NTSTATUS ntstatus; - - status = ads_get_sid_token(ads, mem_ctx, dn, &ad_token); - if (!ADS_ERR_OK(status)) { - return status; - } - - ntstatus = merge_nt_token(mem_ctx, ad_token, get_system_token(), - token); - if (!NT_STATUS_IS_OK(ntstatus)) { - return ADS_ERROR_NT(ntstatus); - } - - return ADS_SUCCESS; -} -- cgit From 72b8392f9c48d87dcd351ec3a24cc6f68516011f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 18:23:53 +0100 Subject: Add gp_get_machine_token(). Guenther (This used to be commit 2f1bc7ddad97b9137ae4cce696bf4e08f9b7ca20) --- source3/lib/util_nttoken.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ source3/libgpo/gpo_util.c | 25 +++++++++++++++++++++++ 2 files changed, 75 insertions(+) (limited to 'source3') diff --git a/source3/lib/util_nttoken.c b/source3/lib/util_nttoken.c index 13c66a5f45..f81191af58 100644 --- a/source3/lib/util_nttoken.c +++ b/source3/lib/util_nttoken.c @@ -7,6 +7,7 @@ * Copyright (C) Rafal Szczesniak 2002 * Copyright (C) Volker Lendecke 2006 * Copyright (C) Michael Adam 2007 + * Copyright (C) Guenther Deschner 2007 * * 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 @@ -67,3 +68,52 @@ NT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, const NT_USER_TOKEN *ptoken) return token; } +/**************************************************************************** + merge NT tokens +****************************************************************************/ + +NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx, + const struct nt_user_token *token_1, + const struct nt_user_token *token_2, + struct nt_user_token **token_out) +{ + struct nt_user_token *token = NULL; + NTSTATUS status; + int i; + + if (!token_1 || !token_2 || !token_out) { + return NT_STATUS_INVALID_PARAMETER; + } + + token = TALLOC_ZERO_P(mem_ctx, struct nt_user_token); + NT_STATUS_HAVE_NO_MEMORY(token); + + for (i=0; i < token_1->num_sids; i++) { + status = add_sid_to_array_unique(mem_ctx, + &token_1->user_sids[i], + &token->user_sids, + &token->num_sids); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(token); + return status; + } + } + + for (i=0; i < token_2->num_sids; i++) { + status = add_sid_to_array_unique(mem_ctx, + &token_2->user_sids[i], + &token->user_sids, + &token->num_sids); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(token); + return status; + } + } + + se_priv_add(&token->privileges, &token_1->privileges); + se_priv_add(&token->privileges, &token_2->privileges); + + *token_out = token; + + return NT_STATUS_OK; +} diff --git a/source3/libgpo/gpo_util.c b/source3/libgpo/gpo_util.c index 79f2690245..b9053d0ae5 100644 --- a/source3/libgpo/gpo_util.c +++ b/source3/libgpo/gpo_util.c @@ -750,3 +750,28 @@ NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_SUCH_FILE; } +/**************************************************************** +****************************************************************/ + +ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *dn, + struct nt_user_token **token) +{ + struct nt_user_token *ad_token = NULL; + ADS_STATUS status; + NTSTATUS ntstatus; + + status = ads_get_sid_token(ads, mem_ctx, dn, &ad_token); + if (!ADS_ERR_OK(status)) { + return status; + } + + ntstatus = merge_nt_token(mem_ctx, ad_token, get_system_token(), + token); + if (!NT_STATUS_IS_OK(ntstatus)) { + return ADS_ERROR_NT(ntstatus); + } + + return ADS_SUCCESS; +} -- cgit From c5249935d49456c58beac32565402212e98421d4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 29 Feb 2008 20:52:35 +0100 Subject: Fix the build w/o ldap. Guenther (This used to be commit 5f592d030b7e94331a634e0d625aefc60cfb1f70) --- source3/libgpo/gpo_util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libgpo/gpo_util.c b/source3/libgpo/gpo_util.c index b9053d0ae5..f2d7c6924a 100644 --- a/source3/libgpo/gpo_util.c +++ b/source3/libgpo/gpo_util.c @@ -1,7 +1,7 @@ /* * Unix SMB/CIFS implementation. * Group Policy Object Support - * Copyright (C) Guenther Deschner 2005-2007 + * Copyright (C) Guenther Deschner 2005-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 @@ -762,6 +762,9 @@ ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, ADS_STATUS status; NTSTATUS ntstatus; +#ifndef HAVE_ADS + return ADS_ERROR_NT(NT_STATUS_NOT_SUPPORTED); +#endif status = ads_get_sid_token(ads, mem_ctx, dn, &ad_token); if (!ADS_ERR_OK(status)) { return status; -- cgit From 45615d62838123bdf620a9c409d9868d47977800 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 29 Feb 2008 22:33:35 +0100 Subject: Check the right variable for being NULL (This used to be commit f2c67803792f1fd3929e922c1f626f8247e08992) --- source3/libsmb/ntlmssp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index 35c20ed647..8355669d9f 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/libsmb/ntlmssp.c @@ -571,7 +571,7 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state, strlower_m(dnsdomname); dnsname = get_mydnsfullname(); - if (!dnsdomname) { + if (!dnsname) { return NT_STATUS_INVALID_COMPUTER_NAME; } -- cgit From 5e0d86c4076f9b04a2c79ab47b497924248050aa Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 29 Feb 2008 22:38:10 +0100 Subject: Restore 3.0 behaviour with empty /etc/hosts Jeremy, in 3.0 we allowed get_mydnsdomname and get_mydnsfullname to fail without filling in anything useful. Worked fine. Without this patch and a empty /etc/hosts and no DNS configured, session setup would return NT_STATUS_BAD_NETWORK_NAME. This is confusing at best, BAD_NETWORK_NAME afaik is only ever returned from tcon normally. This restores the 3.0 behaviour. Comments? Volker (This used to be commit 2bd3b7d474768f842921945d283eac10da2a1684) --- source3/libsmb/ntlmssp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index 8355669d9f..7082ea7e4e 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/libsmb/ntlmssp.c @@ -566,13 +566,16 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state, /* This should be a 'netbios domain -> DNS domain' mapping */ dnsdomname = get_mydnsdomname(ntlmssp_state->mem_ctx); if (!dnsdomname) { - return NT_STATUS_BAD_NETWORK_NAME; + dnsdomname = talloc_strdup(ntlmssp_state->mem_ctx, ""); + } + if (!dnsdomname) { + return NT_STATUS_NO_MEMORY; } strlower_m(dnsdomname); dnsname = get_mydnsfullname(); if (!dnsname) { - return NT_STATUS_INVALID_COMPUTER_NAME; + dnsname = ""; } /* This creates the 'blob' of names that appears at the end of the packet */ -- cgit From 87222d3f11ee4b9ca62d5d66f48772d85dbc7f84 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 1 Mar 2008 00:32:36 +0100 Subject: Fix init_registry_data for subkeyless top-level keys. On a fresh install with no existing registry.tdb, make sure we are able to create our initial top-level entries. Michael, Volker, please check. Guenther (This used to be commit 956bc602062825493e1c357e2388fee1e5514b50) --- source3/registry/reg_backend_db.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 52e0fd4289..518078a062 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -454,7 +454,8 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr) regdb_fetch_keys(key, old_subkeys); - if (ctr->num_subkeys == old_subkeys->num_subkeys) { + if ((ctr->num_subkeys && old_subkeys->num_subkeys) && + (ctr->num_subkeys == old_subkeys->num_subkeys)) { for (i = 0; inum_subkeys; i++) { if (strcmp(ctr->subkeys[i], @@ -550,6 +551,22 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr) /* now create records for any subkeys that don't already exist */ num_subkeys = regsubkey_ctr_numkeys(ctr); + + if (num_subkeys == 0) { + if (!(subkeys = TALLOC_ZERO_P(ctr, REGSUBKEY_CTR)) ) { + DEBUG(0,("regdb_store_keys: talloc() failure!\n")); + goto fail; + } + + if (!regdb_store_keys_internal(key, subkeys)) { + DEBUG(0,("regdb_store_keys: Failed to store " + "new record for key [%s]\n", key)); + goto fail; + } + TALLOC_FREE(subkeys); + + } + for (i=0; i Date: Sat, 1 Mar 2008 09:25:52 +0100 Subject: Revert "Fix warnings" This reverts commit 9a966e5593ae4474014aec5d8c68c489ac8ce0c9. (This used to be commit 413695e8d0d8232a9c35e693f9a4a8009418ede4) --- source3/client/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index c97f6223a7..1410fc2f33 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -979,10 +979,11 @@ static int do_get(const char *rname, const char *lname_in, bool reget) int handle = 0, fnum; bool newhandle = false; struct timeval tp_start; + int read_size = io_bufsize; uint16 attr; SMB_OFF_T size; off_t start = 0; - ssize_t nread = 0; + off_t nread = 0; int rc = 0; struct cli_state *targetcli = NULL; char *targetname = NULL; -- cgit From 342859edfc244f2c80b6d080aa4edb214eb34a7b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 1 Mar 2008 09:26:06 +0100 Subject: Revert "Convert cli_read to use cli_pull" This reverts commit 719527f55e88f0c5fdceda5c807475aba299c79f. (This used to be commit ac301fada257e2d3b50148109a3d44fa1421b0b4) --- source3/libsmb/clireadwrite.c | 178 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 163 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index c618509f01..5aee8f18bd 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -444,27 +444,175 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum, return result; } -static NTSTATUS cli_read_sink(char *buf, size_t n, void *priv) +/**************************************************************************** +Issue a single SMBread and don't wait for a reply. +****************************************************************************/ + +static bool cli_issue_read(struct cli_state *cli, int fnum, off_t offset, + size_t size, int i) { - char **pbuf = (char **)priv; - memcpy(*pbuf, buf, n); - *pbuf += n; - return NT_STATUS_OK; + bool bigoffset = False; + + memset(cli->outbuf,'\0',smb_size); + memset(cli->inbuf,'\0',smb_size); + + if ((SMB_BIG_UINT)offset >> 32) + bigoffset = True; + + cli_set_message(cli->outbuf,bigoffset ? 12 : 10,0,True); + + SCVAL(cli->outbuf,smb_com,SMBreadX); + SSVAL(cli->outbuf,smb_tid,cli->cnum); + cli_setup_packet(cli); + + SCVAL(cli->outbuf,smb_vwv0,0xFF); + SSVAL(cli->outbuf,smb_vwv2,fnum); + SIVAL(cli->outbuf,smb_vwv3,offset); + SSVAL(cli->outbuf,smb_vwv5,size); + SSVAL(cli->outbuf,smb_vwv6,size); + SSVAL(cli->outbuf,smb_vwv7,(size >> 16)); + SSVAL(cli->outbuf,smb_mid,cli->mid + i); + + if (bigoffset) { + SIVAL(cli->outbuf,smb_vwv10,(((SMB_BIG_UINT)offset)>>32) & 0xffffffff); + } + + return cli_send_smb(cli); } -ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, - off_t offset, size_t size) +/**************************************************************************** + Read size bytes at offset offset using SMBreadX. +****************************************************************************/ + +ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size) { - NTSTATUS status; - ssize_t ret; + char *p; + size_t size2; + size_t readsize; + ssize_t total = 0; + /* We can only do direct reads if not signing or encrypting. */ + bool direct_reads = !client_is_signing_on(cli) && !cli_encryption_on(cli); - status = cli_pull(cli, fnum, offset, size, size, - cli_read_sink, &buf, &ret); - if (!NT_STATUS_IS_OK(status)) { - cli_set_error(cli, status); - return -1; + if (size == 0) + return 0; + + /* + * Set readsize to the maximum size we can handle in one readX, + * rounded down to a multiple of 1024. + */ + + if (client_is_signing_on(cli) == false && + cli_encryption_on(cli) == false && + (cli->posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) { + readsize = CLI_SAMBA_MAX_POSIX_LARGE_READX_SIZE; + } else if (cli->capabilities & CAP_LARGE_READX) { + if (cli->is_samba) { + readsize = CLI_SAMBA_MAX_LARGE_READX_SIZE; + } else { + readsize = CLI_WINDOWS_MAX_LARGE_READX_SIZE; + } + } else { + readsize = (cli->max_xmit - (smb_size+32)) & ~1023; + } + + while (total < size) { + readsize = MIN(readsize, size-total); + + /* Issue a read and receive a reply */ + + if (!cli_issue_read(cli, fnum, offset, readsize, 0)) + return -1; + + if (direct_reads) { + if (!cli_receive_smb_readX_header(cli)) + return -1; + } else { + if (!cli_receive_smb(cli)) + return -1; + } + + /* Check for error. Make sure to check for DOS and NT + errors. */ + + if (cli_is_error(cli)) { + bool recoverable_error = False; + NTSTATUS status = NT_STATUS_OK; + uint8 eclass = 0; + uint32 ecode = 0; + + if (cli_is_nt_error(cli)) + status = cli_nt_error(cli); + else + cli_dos_error(cli, &eclass, &ecode); + + /* + * ERRDOS ERRmoredata or STATUS_MORE_ENRTIES is a + * recoverable error, plus we have valid data in the + * packet so don't error out here. + */ + + if ((eclass == ERRDOS && ecode == ERRmoredata) || + NT_STATUS_V(status) == NT_STATUS_V(STATUS_MORE_ENTRIES)) + recoverable_error = True; + + if (!recoverable_error) + return -1; + } + + /* size2 is the number of bytes the server returned. + * Might be zero. */ + size2 = SVAL(cli->inbuf, smb_vwv5); + size2 |= (((unsigned int)(SVAL(cli->inbuf, smb_vwv7))) << 16); + + if (size2 > readsize) { + DEBUG(5,("server returned more than we wanted!\n")); + return -1; + } else if (size2 < 0) { + DEBUG(5,("read return < 0!\n")); + return -1; + } + + if (size2) { + /* smb_vwv6 is the offset in the packet of the returned + * data bytes. Only valid if size2 != 0. */ + + if (!direct_reads) { + /* Copy data into buffer */ + p = smb_base(cli->inbuf) + SVAL(cli->inbuf,smb_vwv6); + memcpy(buf + total, p, size2); + } else { + /* Ensure the remaining data matches the return size. */ + ssize_t toread = smb_len_large(cli->inbuf) - SVAL(cli->inbuf,smb_vwv6); + + /* Ensure the size is correct. */ + if (toread != size2) { + DEBUG(5,("direct read logic fail toread (%d) != size2 (%u)\n", + (int)toread, (unsigned int)size2 )); + return -1; + } + + /* Read data directly into buffer */ + toread = cli_receive_smb_data(cli,buf+total,size2); + if (toread != size2) { + DEBUG(5,("direct read read failure toread (%d) != size2 (%u)\n", + (int)toread, (unsigned int)size2 )); + return -1; + } + } + } + + total += size2; + offset += size2; + + /* + * If the server returned less than we asked for we're at EOF. + */ + + if (size2 < readsize) + break; } - return ret; + + return total; } #if 0 /* relies on client_receive_smb(), now a static in libsmb/clientgen.c */ -- cgit From a34d158880b84cb4d14cc8055f4d5122d873bfbf Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 1 Mar 2008 09:26:18 +0100 Subject: Revert "Add async cli_pull support" This reverts commit 844a163458c7585e4306a21ffdae5d08e03d6e4d. (This used to be commit 5ab1cfda500de07ff3c712442ab2fc74eecc8886) --- source3/client/client.c | 42 +++-- source3/libsmb/clireadwrite.c | 425 ------------------------------------------ 2 files changed, 27 insertions(+), 440 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 1410fc2f33..f7ed33ad8a 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -964,20 +964,12 @@ static int cmd_echo(void) Get a file from rname to lname ****************************************************************************/ -static NTSTATUS writefile_sink(char *buf, size_t n, void *priv) -{ - int *pfd = (int *)priv; - if (writefile(*pfd, buf, n) == -1) { - return map_nt_error_from_unix(errno); - } - return NT_STATUS_OK; -} - static int do_get(const char *rname, const char *lname_in, bool reget) { TALLOC_CTX *ctx = talloc_tos(); int handle = 0, fnum; bool newhandle = false; + char *data = NULL; struct timeval tp_start; int read_size = io_bufsize; uint16 attr; @@ -988,7 +980,6 @@ static int do_get(const char *rname, const char *lname_in, bool reget) struct cli_state *targetcli = NULL; char *targetname = NULL; char *lname = NULL; - NTSTATUS status; lname = talloc_strdup(ctx, lname_in); if (!lname) { @@ -1047,15 +1038,36 @@ static int do_get(const char *rname, const char *lname_in, bool reget) DEBUG(1,("getting file %s of size %.0f as %s ", rname, (double)size, lname)); - status = cli_pull(targetcli, fnum, start, size, 1024*1024, - writefile_sink, (void *)&handle, &nread); - if (!NT_STATUS_IS_OK(status)) { - d_fprintf(stderr, "parallel_read returned %s\n", - nt_errstr(status)); + if(!(data = (char *)SMB_MALLOC(read_size))) { + d_printf("malloc fail for size %d\n", read_size); cli_close(targetcli, fnum); return 1; } + while (1) { + int n = cli_read(targetcli, fnum, data, nread + start, read_size); + + if (n <= 0) + break; + + if (writefile(handle,data, n) != n) { + d_printf("Error writing local file\n"); + rc = 1; + break; + } + + nread += n; + } + + if (nread + start < size) { + DEBUG (0, ("Short read when getting file %s. Only got %ld bytes.\n", + rname, (long)nread)); + + rc = 1; + } + + SAFE_FREE(data); + if (!cli_close(targetcli, fnum)) { d_printf("Error %s closing remote file\n",cli_errstr(cli)); rc = 1; diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index 5aee8f18bd..af13ed8f73 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -19,431 +19,6 @@ #include "includes.h" -/**************************************************************************** - Calculate the recommended read buffer size -****************************************************************************/ -static size_t cli_read_max_bufsize(struct cli_state *cli) -{ - if (!client_is_signing_on(cli) && !cli_encryption_on(cli) == false - && (cli->posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) { - return CLI_SAMBA_MAX_POSIX_LARGE_READX_SIZE; - } - if (cli->capabilities & CAP_LARGE_READX) { - return cli->is_samba - ? CLI_SAMBA_MAX_LARGE_READX_SIZE - : CLI_WINDOWS_MAX_LARGE_READX_SIZE; - } - return (cli->max_xmit - (smb_size+32)) & ~1023; -} - -/* - * Send a read&x request - */ - -struct async_req *cli_read_andx_send(TALLOC_CTX *mem_ctx, - struct cli_state *cli, int fnum, - off_t offset, size_t size) -{ - struct async_req *result; - struct cli_request *req; - bool bigoffset = False; - char *enc_buf; - - if (size > cli_read_max_bufsize(cli)) { - DEBUG(0, ("cli_read_andx_send got size=%d, can only handle " - "size=%d\n", (int)size, - (int)cli_read_max_bufsize(cli))); - return NULL; - } - - result = cli_request_new(mem_ctx, cli->event_ctx, cli, 12, 0, &req); - if (result == NULL) { - DEBUG(0, ("cli_request_new failed\n")); - return NULL; - } - - req = cli_request_get(result); - - req->data.read.ofs = offset; - req->data.read.size = size; - req->data.read.received = 0; - req->data.read.rcvbuf = NULL; - - if ((SMB_BIG_UINT)offset >> 32) - bigoffset = True; - - cli_set_message(req->outbuf, bigoffset ? 12 : 10, 0, False); - - SCVAL(req->outbuf,smb_com,SMBreadX); - SSVAL(req->outbuf,smb_tid,cli->cnum); - cli_setup_packet_buf(cli, req->outbuf); - - SCVAL(req->outbuf,smb_vwv0,0xFF); - SCVAL(req->outbuf,smb_vwv0+1,0); - SSVAL(req->outbuf,smb_vwv1,0); - SSVAL(req->outbuf,smb_vwv2,fnum); - SIVAL(req->outbuf,smb_vwv3,offset); - SSVAL(req->outbuf,smb_vwv5,size); - SSVAL(req->outbuf,smb_vwv6,size); - SSVAL(req->outbuf,smb_vwv7,(size >> 16)); - SSVAL(req->outbuf,smb_vwv8,0); - SSVAL(req->outbuf,smb_vwv9,0); - SSVAL(req->outbuf,smb_mid,req->mid); - - if (bigoffset) { - SIVAL(req->outbuf, smb_vwv10, - (((SMB_BIG_UINT)offset)>>32) & 0xffffffff); - } - - cli_calculate_sign_mac(cli, req->outbuf); - - event_fd_set_writeable(cli->fd_event); - - if (cli_encryption_on(cli)) { - NTSTATUS status; - status = cli_encrypt_message(cli, req->outbuf, &enc_buf); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("Error in encrypting client message. " - "Error %s\n", nt_errstr(status))); - TALLOC_FREE(req); - return NULL; - } - req->outbuf = enc_buf; - req->enc_state = cli->trans_enc_state; - } - - return result; -} - -/* - * Pull the data out of a finished async read_and_x request. rcvbuf is - * talloced from the request, so better make sure that you copy it away before - * you talloc_free(req). "rcvbuf" is NOT a talloc_ctx of its own, so do not - * talloc_move it! - */ - -NTSTATUS cli_read_andx_recv(struct async_req *req, ssize_t *received, - uint8_t **rcvbuf) -{ - struct cli_request *cli_req = cli_request_get(req); - NTSTATUS status; - size_t size; - - SMB_ASSERT(req->state >= ASYNC_REQ_DONE); - if (req->state == ASYNC_REQ_ERROR) { - return req->status; - } - - status = cli_pull_error(cli_req->inbuf); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - /* size is the number of bytes the server returned. - * Might be zero. */ - size = SVAL(cli_req->inbuf, smb_vwv5); - size |= (((unsigned int)(SVAL(cli_req->inbuf, smb_vwv7))) << 16); - - if (size > cli_req->data.read.size) { - DEBUG(5,("server returned more than we wanted!\n")); - return NT_STATUS_UNEXPECTED_IO_ERROR; - } - - if (size < 0) { - DEBUG(5,("read return < 0!\n")); - return NT_STATUS_UNEXPECTED_IO_ERROR; - } - - *rcvbuf = (uint8_t *) - (smb_base(cli_req->inbuf) + SVAL(cli_req->inbuf, smb_vwv6)); - *received = size; - return NT_STATUS_OK; -} - -/* - * Parallel read support. - * - * cli_pull sends as many read&x requests as the server would allow via - * max_mux at a time. When replies flow back in, the data is written into - * the callback function "sink" in the right order. - */ - -struct cli_pull_state { - struct async_req *req; - - struct cli_state *cli; - uint16_t fnum; - off_t start_offset; - size_t size; - - NTSTATUS (*sink)(char *buf, size_t n, void *priv); - void *priv; - - size_t chunk_size; - - /* - * Outstanding requests - */ - int num_reqs; - struct async_req **reqs; - - /* - * For how many bytes did we send requests already? - */ - off_t requested; - - /* - * Next request index to push into "sink". This walks around the "req" - * array, taking care that the requests are pushed to "sink" in the - * right order. If necessary (i.e. replies don't come in in the right - * order), replies are held back in "reqs". - */ - int top_req; - - /* - * How many bytes did we push into "sink"? - */ - - off_t pushed; -}; - -static char *cli_pull_print(TALLOC_CTX *mem_ctx, struct async_req *req) -{ - struct cli_pull_state *state = talloc_get_type_abort( - req->private_data, struct cli_pull_state); - char *result; - - result = async_req_print(mem_ctx, req); - if (result == NULL) { - return NULL; - } - - return talloc_asprintf_append_buffer( - result, "num_reqs=%d, top_req=%d", - state->num_reqs, state->top_req); -} - -static void cli_pull_read_done(struct async_req *read_req); - -/* - * Prepare an async pull request - */ - -struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx, struct cli_state *cli, - uint16_t fnum, off_t start_offset, - size_t size, size_t window_size, - NTSTATUS (*sink)(char *buf, size_t n, - void *priv), - void *priv) -{ - struct async_req *result; - struct cli_pull_state *state; - int i; - - result = async_req_new(mem_ctx, cli->event_ctx); - if (result == NULL) { - goto failed; - } - state = talloc(result, struct cli_pull_state); - if (state == NULL) { - goto failed; - } - result->private_data = state; - result->print = cli_pull_print; - state->req = result; - - state->cli = cli; - state->fnum = fnum; - state->start_offset = start_offset; - state->size = size; - state->sink = sink; - state->priv = priv; - - state->pushed = 0; - state->top_req = 0; - state->chunk_size = cli_read_max_bufsize(cli); - - state->num_reqs = MAX(window_size/state->chunk_size, 1); - state->num_reqs = MIN(state->num_reqs, cli->max_mux); - - state->reqs = TALLOC_ZERO_ARRAY(state, struct async_req *, - state->num_reqs); - if (state->reqs == NULL) { - goto failed; - } - - state->requested = 0; - - for (i=0; inum_reqs; i++) { - size_t size_left, request_thistime; - - if (state->requested >= size) { - state->num_reqs = i; - break; - } - - size_left = size - state->requested; - request_thistime = MIN(size_left, state->chunk_size); - - state->reqs[i] = cli_read_andx_send( - state->reqs, cli, fnum, - state->start_offset + state->requested, - request_thistime); - - if (state->reqs[i] == NULL) { - goto failed; - } - - state->reqs[i]->async.fn = cli_pull_read_done; - state->reqs[i]->async.priv = result; - - state->requested += request_thistime; - } - return result; - -failed: - TALLOC_FREE(result); - return NULL; -} - -/* - * Handle incoming read replies, push the data into sink and send out new - * requests if necessary. - */ - -static void cli_pull_read_done(struct async_req *read_req) -{ - struct async_req *pull_req = talloc_get_type_abort( - read_req->async.priv, struct async_req); - struct cli_pull_state *state = talloc_get_type_abort( - pull_req->private_data, struct cli_pull_state); - struct cli_request *read_state = cli_request_get(read_req); - NTSTATUS status; - - status = cli_read_andx_recv(read_req, &read_state->data.read.received, - &read_state->data.read.rcvbuf); - if (!NT_STATUS_IS_OK(status)) { - async_req_error(state->req, status); - return; - } - - /* - * This loop is the one to take care of out-of-order replies. All - * pending requests are in state->reqs, state->reqs[top_req] is the - * one that is to be pushed next. If however a request later than - * top_req is replied to, then we can't push yet. If top_req is - * replied to at a later point then, we need to push all the finished - * requests. - */ - - while (state->reqs[state->top_req] != NULL) { - struct cli_request *top_read; - - DEBUG(11, ("cli_pull_read_done: top_req = %d\n", - state->top_req)); - - if (state->reqs[state->top_req]->state < ASYNC_REQ_DONE) { - DEBUG(11, ("cli_pull_read_done: top request not yet " - "done\n")); - return; - } - - top_read = cli_request_get(state->reqs[state->top_req]); - - DEBUG(10, ("cli_pull_read_done: Pushing %d bytes, %d already " - "pushed\n", (int)top_read->data.read.received, - (int)state->pushed)); - - status = state->sink((char *)top_read->data.read.rcvbuf, - top_read->data.read.received, - state->priv); - if (!NT_STATUS_IS_OK(status)) { - async_req_error(state->req, status); - return; - } - state->pushed += top_read->data.read.received; - - TALLOC_FREE(state->reqs[state->top_req]); - - if (state->requested < state->size) { - struct async_req *new_req; - size_t size_left, request_thistime; - - size_left = state->size - state->requested; - request_thistime = MIN(size_left, state->chunk_size); - - DEBUG(10, ("cli_pull_read_done: Requesting %d bytes " - "at %d, position %d\n", - (int)request_thistime, - (int)(state->start_offset - + state->requested), - state->top_req)); - - new_req = cli_read_andx_send( - state->reqs, state->cli, state->fnum, - state->start_offset + state->requested, - request_thistime); - - if (async_req_nomem(new_req, state->req)) { - return; - } - - new_req->async.fn = cli_pull_read_done; - new_req->async.priv = pull_req; - - state->reqs[state->top_req] = new_req; - state->requested += request_thistime; - } - - state->top_req = (state->top_req+1) % state->num_reqs; - } - - async_req_done(pull_req); -} - -NTSTATUS cli_pull_recv(struct async_req *req, ssize_t *received) -{ - struct cli_pull_state *state = talloc_get_type_abort( - req->private_data, struct cli_pull_state); - - SMB_ASSERT(req->state >= ASYNC_REQ_DONE); - if (req->state == ASYNC_REQ_ERROR) { - return req->status; - } - *received = state->pushed; - return NT_STATUS_OK; -} - -NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum, - off_t start_offset, size_t size, size_t window_size, - NTSTATUS (*sink)(char *buf, size_t n, void *priv), - void *priv, ssize_t *received) -{ - TALLOC_CTX *frame = talloc_stackframe(); - struct async_req *req; - NTSTATUS result = NT_STATUS_NO_MEMORY; - - if (cli_tmp_event_ctx(frame, cli) == NULL) { - goto nomem; - } - - req = cli_pull_send(frame, cli, fnum, start_offset, size, window_size, - sink, priv); - if (req == NULL) { - goto nomem; - } - - while (req->state < ASYNC_REQ_DONE) { - event_loop_once(cli->event_ctx); - } - - result = cli_pull_recv(req, received); - nomem: - TALLOC_FREE(frame); - return result; -} - /**************************************************************************** Issue a single SMBread and don't wait for a reply. ****************************************************************************/ -- cgit From 45a877f392a5449f4c3b7d39f9f8c78b57733d39 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 1 Mar 2008 09:26:27 +0100 Subject: Revert "Add infrastructure to support async SMB requests" This reverts commit f5356825698a02df2d400b51dd95d1f857c83e81. (This used to be commit 5f53a62be8a21b8d92ac44b18d202882500356e8) --- source3/Makefile.in | 2 +- source3/include/async_smb.h | 62 ------ source3/include/client.h | 30 --- source3/include/includes.h | 1 - source3/libsmb/async_smb.c | 483 -------------------------------------------- 5 files changed, 1 insertion(+), 577 deletions(-) delete mode 100644 source3/include/async_smb.h delete mode 100644 source3/libsmb/async_smb.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index d01abc9afc..2cd25087c6 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -415,7 +415,7 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \ libsmb/clistr.o libsmb/cliquota.o libsmb/clifsinfo.o libsmb/clidfs.o \ libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \ libsmb/clioplock.o $(ERRORMAP_OBJ) libsmb/clirap2.o \ - libsmb/smb_seal.o $(DOSERR_OBJ) libsmb/async_smb.o \ + libsmb/smb_seal.o $(DOSERR_OBJ) \ $(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(LIBNMB_OBJ) RPC_CLIENT_OBJ1 = rpc_client/cli_netlogon.o rpc_client/cli_srvsvc.o diff --git a/source3/include/async_smb.h b/source3/include/async_smb.h deleted file mode 100644 index 19408be74b..0000000000 --- a/source3/include/async_smb.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Infrastructure for async SMB client requests - Copyright (C) Volker Lendecke 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 "includes.h" - -/* - * Create a fresh async smb request - */ - -struct async_req *cli_request_new(TALLOC_CTX *mem_ctx, - struct event_context *ev, - struct cli_state *cli, - uint8_t num_words, size_t num_bytes, - struct cli_request **preq); - -/* - * Convenience function to get the SMB part out of an async_req - */ - -struct cli_request *cli_request_get(struct async_req *req); - -/* - * Fetch an error out of a NBT packet - */ - -NTSTATUS cli_pull_error(char *buf); - -/* - * Compatibility helper for the sync APIs: Fake NTSTATUS in cli->inbuf - */ - -void cli_set_error(struct cli_state *cli, NTSTATUS status); - -/* - * Create a temporary event context for use in the sync helper functions - */ - -struct cli_tmp_event *cli_tmp_event_ctx(TALLOC_CTX *mem_ctx, - struct cli_state *cli); - -/* - * Attach an event context permanently to a cli_struct - */ - -NTSTATUS cli_add_event_ctx(struct cli_state *cli, - struct event_context *event_ctx); diff --git a/source3/include/client.h b/source3/include/client.h index 52dc513d65..d29a2e7341 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -192,36 +192,6 @@ struct cli_state { bool force_dos_errors; bool case_sensitive; /* False by default. */ - - struct event_context *event_ctx; - struct fd_event *fd_event; - char *evt_inbuf; - - struct cli_request *outstanding_requests; -}; - -struct cli_request { - struct cli_request *prev, *next; - struct async_req *async; - - struct cli_state *cli; - - struct smb_trans_enc_state *enc_state; - - uint16_t mid; - - char *outbuf; - size_t sent; - char *inbuf; - - union { - struct { - off_t ofs; - size_t size; - ssize_t received; - uint8_t *rcvbuf; - } read; - } data; }; typedef struct file_info { diff --git a/source3/include/includes.h b/source3/include/includes.h index 36c71d7533..8d4bfc0f8e 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -724,7 +724,6 @@ typedef char fstring[FSTRING_LEN]; #include "talloc_stack.h" #include "memcache.h" #include "async_req.h" -#include "async_smb.h" /* used in net.c */ struct functable { diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c deleted file mode 100644 index 21bcd5b9b1..0000000000 --- a/source3/libsmb/async_smb.c +++ /dev/null @@ -1,483 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Infrastructure for async SMB client requests - Copyright (C) Volker Lendecke 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 "includes.h" - -/* - * Fetch an error out of a NBT packet - */ - -NTSTATUS cli_pull_error(char *buf) -{ - uint32_t flags2 = SVAL(buf, smb_flg2); - - if (flags2 & FLAGS2_32_BIT_ERROR_CODES) { - return NT_STATUS(IVAL(buf, smb_rcls)); - } - - return NT_STATUS_DOS(CVAL(buf, smb_rcls), SVAL(buf,smb_err)); -} - -/* - * Compatibility helper for the sync APIs: Fake NTSTATUS in cli->inbuf - */ - -void cli_set_error(struct cli_state *cli, NTSTATUS status) -{ - uint32_t flags2 = SVAL(cli->inbuf, smb_flg2); - - if (NT_STATUS_IS_DOS(status)) { - SSVAL(cli->inbuf, smb_flg2, - flags2 & ~FLAGS2_32_BIT_ERROR_CODES); - SCVAL(cli->inbuf, smb_rcls, NT_STATUS_DOS_CLASS(status)); - SSVAL(cli->inbuf, smb_err, NT_STATUS_DOS_CODE(status)); - return; - } - - SSVAL(cli->inbuf, smb_flg2, flags2 | FLAGS2_32_BIT_ERROR_CODES); - SIVAL(cli->inbuf, smb_rcls, NT_STATUS_V(status)); - return; -} - -/* - * Allocate a new mid - */ - -static uint16_t cli_new_mid(struct cli_state *cli) -{ - uint16_t result; - struct cli_request *req; - - while (true) { - result = cli->mid++; - if (result == 0) { - continue; - } - - for (req = cli->outstanding_requests; req; req = req->next) { - if (result == req->mid) { - break; - } - } - - if (req == NULL) { - return result; - } - } -} - -static char *cli_request_print(TALLOC_CTX *mem_ctx, struct async_req *req) -{ - char *result = async_req_print(mem_ctx, req); - struct cli_request *cli_req = cli_request_get(req); - - if (result == NULL) { - return NULL; - } - - return talloc_asprintf_append_buffer( - result, "mid=%d\n", cli_req->mid); -} - -static int cli_request_destructor(struct cli_request *req) -{ - if (req->enc_state != NULL) { - common_free_enc_buffer(req->enc_state, req->outbuf); - } - DLIST_REMOVE(req->cli->outstanding_requests, req); - return 0; -} - -/* - * Create a fresh async smb request - */ - -struct async_req *cli_request_new(TALLOC_CTX *mem_ctx, - struct event_context *ev, - struct cli_state *cli, - uint8_t num_words, size_t num_bytes, - struct cli_request **preq) -{ - struct async_req *result; - struct cli_request *cli_req; - size_t bufsize = smb_size + num_words * 2 + num_bytes; - - result = async_req_new(mem_ctx, ev); - if (result == NULL) { - return NULL; - } - - cli_req = (struct cli_request *)talloc_size( - result, sizeof(*cli_req) + bufsize); - if (cli_req == NULL) { - TALLOC_FREE(result); - return NULL; - } - talloc_set_name_const(cli_req, "struct cli_request"); - result->private_data = cli_req; - result->print = cli_request_print; - - cli_req->async = result; - cli_req->cli = cli; - cli_req->outbuf = ((char *)cli_req + sizeof(*cli_req)); - cli_req->sent = 0; - cli_req->mid = cli_new_mid(cli); - cli_req->inbuf = NULL; - cli_req->enc_state = NULL; - - SCVAL(cli_req->outbuf, smb_wct, num_words); - SSVAL(cli_req->outbuf, smb_vwv + num_words * 2, num_bytes); - - DLIST_ADD_END(cli->outstanding_requests, cli_req, - struct cli_request *); - talloc_set_destructor(cli_req, cli_request_destructor); - - DEBUG(10, ("cli_request_new: mid=%d\n", cli_req->mid)); - - *preq = cli_req; - return result; -} - -/* - * Convenience function to get the SMB part out of an async_req - */ - -struct cli_request *cli_request_get(struct async_req *req) -{ - if (req == NULL) { - return NULL; - } - return talloc_get_type_abort(req->private_data, struct cli_request); -} - -/* - * A PDU has arrived on cli->evt_inbuf - */ - -static void handle_incoming_pdu(struct cli_state *cli) -{ - struct cli_request *req; - uint16_t mid; - size_t raw_pdu_len, buf_len, pdu_len; - size_t rest_len; - NTSTATUS status; - - /* - * The encrypted PDU len might differ from the unencrypted one - */ - raw_pdu_len = smb_len(cli->evt_inbuf) + 4; - - /* - * TODO: Handle oplock break requests - */ - - if (cli_encryption_on(cli) && CVAL(cli->evt_inbuf, 0) == 0) { - uint16_t enc_ctx_num; - - status = get_enc_ctx_num((uint8_t *)cli->evt_inbuf, - &enc_ctx_num); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("get_enc_ctx_num returned %s\n", - nt_errstr(status))); - goto invalidate_requests; - } - - if (enc_ctx_num != cli->trans_enc_state->enc_ctx_num) { - DEBUG(10, ("wrong enc_ctx %d, expected %d\n", - enc_ctx_num, - cli->trans_enc_state->enc_ctx_num)); - status = NT_STATUS_INVALID_HANDLE; - goto invalidate_requests; - } - - status = common_decrypt_buffer(cli->trans_enc_state, - cli->evt_inbuf); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("common_decrypt_buffer returned %s\n", - nt_errstr(status))); - goto invalidate_requests; - } - } - - if (!cli_check_sign_mac(cli, cli->evt_inbuf)) { - DEBUG(10, ("cli_check_sign_mac failed\n")); - status = NT_STATUS_ACCESS_DENIED; - goto invalidate_requests; - } - - mid = SVAL(cli->evt_inbuf, smb_mid); - - DEBUG(10, ("handle_incoming_pdu: got mid %d\n", mid)); - - for (req = cli->outstanding_requests; req; req = req->next) { - if (req->mid == mid) { - break; - } - } - - buf_len = talloc_get_size(cli->evt_inbuf); - pdu_len = smb_len(cli->evt_inbuf) + 4; - rest_len = buf_len - raw_pdu_len; - - if (req == NULL) { - DEBUG(3, ("Request for mid %d not found, dumping PDU\n", mid)); - - memmove(cli->evt_inbuf, cli->evt_inbuf + raw_pdu_len, - buf_len - raw_pdu_len); - - cli->evt_inbuf = TALLOC_REALLOC_ARRAY(NULL, cli->evt_inbuf, - char, rest_len); - return; - } - - if (buf_len == pdu_len) { - /* - * Optimal case: Exactly one PDU was in the socket buffer - */ - req->inbuf = talloc_move(req, &cli->evt_inbuf); - goto done; - } - - DEBUG(11, ("buf_len = %d, pdu_len = %d, splitting buffer\n", - (int)buf_len, (int)pdu_len)); - - if (pdu_len < rest_len) { - /* - * The PDU is shorter, talloc_memdup that one. - */ - req->inbuf = (char *)talloc_memdup( - req, cli->evt_inbuf, pdu_len); - - memmove(cli->evt_inbuf, - cli->evt_inbuf + raw_pdu_len, - buf_len - raw_pdu_len); - - cli->evt_inbuf = TALLOC_REALLOC_ARRAY( - NULL, cli->evt_inbuf, char, rest_len); - } - else { - /* - * The PDU is larger than the rest, - * talloc_memdup the rest - */ - req->inbuf = talloc_move(req, &cli->evt_inbuf); - - cli->evt_inbuf = (char *)talloc_memdup( - cli, req->inbuf + raw_pdu_len, - rest_len); - } - - if ((req->inbuf == NULL) || (cli->evt_inbuf == NULL)) { - status = NT_STATUS_NO_MEMORY; - goto invalidate_requests; - } - - done: - async_req_done(req->async); - return; - - invalidate_requests: - - DEBUG(10, ("handle_incoming_pdu: Aborting with %s\n", - nt_errstr(status))); - - for (req = cli->outstanding_requests; req; req = req->next) { - async_req_error(req->async, status); - } - return; -} - -/* - * fd event callback. This is the basic connection to the socket - */ - -static void cli_state_handler(struct event_context *event_ctx, - struct fd_event *event, uint16 flags, void *p) -{ - struct cli_state *cli = (struct cli_state *)p; - struct cli_request *req; - - DEBUG(11, ("cli_state_handler called with flags %d\n", flags)); - - if (flags & EVENT_FD_READ) { - int res, available; - size_t old_size, new_size; - char *tmp; - - res = ioctl(cli->fd, FIONREAD, &available); - if (res == -1) { - DEBUG(10, ("ioctl(FIONREAD) failed: %s\n", - strerror(errno))); - goto sock_error; - } - - if (available == 0) { - /* EOF */ - goto sock_error; - } - - old_size = talloc_get_size(cli->evt_inbuf); - new_size = old_size + available; - - if (new_size < old_size) { - /* wrap */ - goto sock_error; - } - - tmp = TALLOC_REALLOC_ARRAY(cli, cli->evt_inbuf, char, - new_size); - if (tmp == NULL) { - /* nomem */ - goto sock_error; - } - cli->evt_inbuf = tmp; - - res = recv(cli->fd, cli->evt_inbuf + old_size, available, 0); - if (res == -1) { - DEBUG(10, ("recv failed: %s\n", strerror(errno))); - goto sock_error; - } - - DEBUG(11, ("cli_state_handler: received %d bytes, " - "smb_len(evt_inbuf) = %d\n", (int)res, - smb_len(cli->evt_inbuf))); - - /* recv *might* have returned less than announced */ - new_size = old_size + res; - - /* shrink, so I don't expect errors here */ - cli->evt_inbuf = TALLOC_REALLOC_ARRAY(cli, cli->evt_inbuf, - char, new_size); - - while ((cli->evt_inbuf != NULL) - && ((smb_len(cli->evt_inbuf) + 4) <= new_size)) { - /* - * we've got a complete NBT level PDU in evt_inbuf - */ - handle_incoming_pdu(cli); - new_size = talloc_get_size(cli->evt_inbuf); - } - } - - if (flags & EVENT_FD_WRITE) { - size_t to_send; - ssize_t sent; - - for (req = cli->outstanding_requests; req; req = req->next) { - to_send = smb_len(req->outbuf)+4; - if (to_send > req->sent) { - break; - } - } - - if (req == NULL) { - event_fd_set_not_writeable(event); - return; - } - - sent = send(cli->fd, req->outbuf + req->sent, - to_send - req->sent, 0); - - if (sent < 0) { - goto sock_error; - } - - req->sent += sent; - - if (req->sent == to_send) { - return; - } - } - return; - - sock_error: - for (req = cli->outstanding_requests; req; req = req->next) { - req->async->state = ASYNC_REQ_ERROR; - req->async->status = map_nt_error_from_unix(errno); - } - TALLOC_FREE(cli->fd_event); - close(cli->fd); - cli->fd = -1; -} - -/* - * Holder for a talloc_destructor, we need to zero out the pointers in cli - * when deleting - */ -struct cli_tmp_event { - struct cli_state *cli; -}; - -static int cli_tmp_event_destructor(struct cli_tmp_event *e) -{ - TALLOC_FREE(e->cli->fd_event); - TALLOC_FREE(e->cli->event_ctx); - return 0; -} - -/* - * Create a temporary event context for use in the sync helper functions - */ - -struct cli_tmp_event *cli_tmp_event_ctx(TALLOC_CTX *mem_ctx, - struct cli_state *cli) -{ - struct cli_tmp_event *state; - - if (cli->event_ctx != NULL) { - return NULL; - } - - state = talloc(mem_ctx, struct cli_tmp_event); - if (state == NULL) { - return NULL; - } - state->cli = cli; - talloc_set_destructor(state, cli_tmp_event_destructor); - - cli->event_ctx = event_context_init(state); - if (cli->event_ctx == NULL) { - TALLOC_FREE(state); - return NULL; - } - - cli->fd_event = event_add_fd(cli->event_ctx, state, cli->fd, - EVENT_FD_READ, cli_state_handler, cli); - if (cli->fd_event == NULL) { - TALLOC_FREE(state); - return NULL; - } - return state; -} - -/* - * Attach an event context permanently to a cli_struct - */ - -NTSTATUS cli_add_event_ctx(struct cli_state *cli, - struct event_context *event_ctx) -{ - cli->event_ctx = event_ctx; - cli->fd_event = event_add_fd(event_ctx, cli, cli->fd, EVENT_FD_READ, - cli_state_handler, cli); - if (cli->fd_event == NULL) { - return NT_STATUS_NO_MEMORY; - } - return NT_STATUS_OK; -} -- cgit From c3cb59ae2b7dc5d89e57ea9d674d256637f891fd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 1 Mar 2008 09:26:43 +0100 Subject: Revert "Add basic infrastructure for general async requests" This reverts commit ae254cb61f4b9331755848c47ebc34e90dd80390. (This used to be commit 030bef7f22f7a73466204b7860f397dbca9f2ab0) --- source3/Makefile.in | 2 +- source3/include/async_req.h | 89 --------------------------------------------- source3/include/includes.h | 1 - source3/lib/async_req.c | 68 ---------------------------------- 4 files changed, 1 insertion(+), 159 deletions(-) delete mode 100644 source3/include/async_req.h delete mode 100644 source3/lib/async_req.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 2cd25087c6..3840498a56 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -326,7 +326,7 @@ LIB_WITHOUT_PROTO_OBJ = $(LIBSAMBAUTIL_OBJ) \ lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \ lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o lib/talloc_stack.o \ lib/interfaces.o lib/rbtree.o lib/memcache.o \ - lib/util_transfer_file.o lib/async_req.o + lib/util_transfer_file.o LIB_WITH_PROTO_OBJ = $(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \ lib/interface.o lib/md4.o \ diff --git a/source3/include/async_req.h b/source3/include/async_req.h deleted file mode 100644 index 6df53602b2..0000000000 --- a/source3/include/async_req.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Infrastructure for async requests - Copyright (C) Volker Lendecke 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 . -*/ - -#ifndef __ASYNC_REQ_H__ -#define __ASYNC_REQ_H__ - -#include "includes.h" - -/* - * An async request moves between the following 4 states. - */ -enum async_req_state { - ASYNC_REQ_INIT, /* we are creating the request */ - ASYNC_REQ_IN_PROGRESS, /* we are waiting the request to complete */ - ASYNC_REQ_DONE, /* the request is finished */ - ASYNC_REQ_ERROR }; /* an error has occured */ - -struct async_req { - /* the external state - will be queried by the caller */ - enum async_req_state state; - - /* a private pointer for use by the async function implementation */ - void *private_data; - - /* print yourself, for debugging purposes */ - char *(*print)(TALLOC_CTX *mem_ctx, struct async_req *); - - /* status code when finished */ - NTSTATUS status; - - /* the event context we are using */ - struct event_context *event_ctx; - - /* information on what to do on completion */ - struct { - void (*fn)(struct async_req *); - void *priv; - } async; -}; - -/* - * Print an async_req structure for debugging purposes - */ -char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req); - -/* - * Create an async request - */ -struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev); - -/* - * An async request has successfully finished, invoke the callback - */ -void async_req_done(struct async_req *req); - -/* - * An async request has seen an error, invoke the callback - */ -void async_req_error(struct async_req *req, NTSTATUS status); - -/* - * Convenience helper to easily check alloc failure within a callback. - * - * Call pattern would be - * p = talloc(mem_ctx, bla); - * if (async_req_nomem(p, req)) { - * return; - * } - * - */ -bool async_req_nomem(const void *p, struct async_req *req); - -#endif diff --git a/source3/include/includes.h b/source3/include/includes.h index 8d4bfc0f8e..c54afd8933 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -723,7 +723,6 @@ typedef char fstring[FSTRING_LEN]; #include "ctdbd_conn.h" #include "talloc_stack.h" #include "memcache.h" -#include "async_req.h" /* used in net.c */ struct functable { diff --git a/source3/lib/async_req.c b/source3/lib/async_req.c deleted file mode 100644 index 01154ca436..0000000000 --- a/source3/lib/async_req.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Infrastructure for async requests - Copyright (C) Volker Lendecke 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 "includes.h" - -char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req) -{ - return talloc_asprintf(mem_ctx, "async_req: state=%d, status=%s, " - "priv=%s", req->state, nt_errstr(req->status), - talloc_get_name(req->private_data)); -} - -struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev) -{ - struct async_req *result; - - result = TALLOC_ZERO_P(mem_ctx, struct async_req); - if (result == NULL) { - return NULL; - } - result->state = ASYNC_REQ_IN_PROGRESS; - result->event_ctx = ev; - result->print = async_req_print; - return result; -} - -void async_req_done(struct async_req *req) -{ - req->status = NT_STATUS_OK; - req->state = ASYNC_REQ_DONE; - if (req->async.fn != NULL) { - req->async.fn(req); - } -} - -void async_req_error(struct async_req *req, NTSTATUS status) -{ - req->status = status; - req->state = ASYNC_REQ_ERROR; - if (req->async.fn != NULL) { - req->async.fn(req); - } -} - -bool async_req_nomem(const void *p, struct async_req *req) -{ - if (p != NULL) { - return false; - } - async_req_error(req, NT_STATUS_NO_MEMORY); - return true; -} -- cgit From 422af9a516dd36fa291a28fd5753a05c139aaecb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 1 Mar 2008 16:13:25 +0100 Subject: Make sure we are still able to join Windows 2008. Guenther (This used to be commit aa9c0f587718f4d647e87b9662acbedba042b9cb) --- source3/libnet/libnet_join.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 1a8486f5b5..866d1c06e1 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -928,9 +928,8 @@ NTSTATUS libnet_join_ok(const char *netbios_domain_name, const char *machine_name, const char *dc_name) { - uint32_t neg_flags = NETLOGON_NEG_AUTH2_FLAGS | + uint32_t neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS | NETLOGON_NEG_SCHANNEL; - /* FIXME: NETLOGON_NEG_SELECT_AUTH2_FLAGS */ struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_hnd = NULL; struct rpc_pipe_client *netlogon_pipe = NULL; -- cgit From 257b7b09298f7cb983b2f31b87fc5e46e0f62f0c Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 28 Feb 2008 11:23:20 -0500 Subject: Initial revamp of the libsmbclient interface. The libsmbclient interface has suffered from difficulty of improvement and feature enrichment without causing ABI breakage. Although there were a number of issues, the primary ones were: (a) the user of the library would manually manipulate the context structure members, meaning that nothing in the context structure could change other than adding stuff at the end; (b) there were three methods of setting options: setting bits in a flags field within the context structure, setting explicit options variables within an options structure in the context structure, and by calling the smbc_option_set() function; (c) the authentication callback did not traditionally provide enough information to the callee which required adding an option for a callback with a different signature, and now there are requests for even more information at the callback, requiring yet a third signature and option to set it (if we implement that feature). This commit provides a reorganization of the code which fixes (a) and (b). The context structure is now entirely opaque, and there are setter and getter functions for manipulating it. This makes maintaining ABI consistency much, much easier. Additionally, the options setting/getting has been unified into a single mechanism using smbc_option_set() and smbc_option_get(). Yet to be completed is a refactoring of the authentication callback (c). The test programs in examples/libsmbclient have been modified (if necessary; some applications require no changes at all) for the new API and a few have been minimally tested. Derrell (This used to be commit d4b4bae8ded824d06ad5ab0e219f71187ee5c771) --- source3/Makefile.in | 12 +- source3/include/libsmb_internal.h | 538 ++- source3/include/libsmbclient.h | 495 +-- source3/libsmb/libsmb_cache.c | 74 +- source3/libsmb/libsmb_compat.c | 329 +- source3/libsmb/libsmb_context.c | 1283 +++++++ source3/libsmb/libsmb_dir.c | 1928 ++++++++++ source3/libsmb/libsmb_file.c | 859 +++++ source3/libsmb/libsmb_misc.c | 73 + source3/libsmb/libsmb_path.c | 399 ++ source3/libsmb/libsmb_printjob.c | 334 ++ source3/libsmb/libsmb_server.c | 675 ++++ source3/libsmb/libsmb_stat.c | 302 ++ source3/libsmb/libsmb_xattr.c | 2293 ++++++++++++ source3/libsmb/libsmbclient.c | 7233 ------------------------------------- 15 files changed, 9206 insertions(+), 7621 deletions(-) create mode 100644 source3/libsmb/libsmb_context.c create mode 100644 source3/libsmb/libsmb_dir.c create mode 100644 source3/libsmb/libsmb_file.c create mode 100644 source3/libsmb/libsmb_misc.c create mode 100644 source3/libsmb/libsmb_path.c create mode 100644 source3/libsmb/libsmb_printjob.c create mode 100644 source3/libsmb/libsmb_server.c create mode 100644 source3/libsmb/libsmb_stat.c create mode 100644 source3/libsmb/libsmb_xattr.c delete mode 100644 source3/libsmb/libsmbclient.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 3840498a56..5f57f67e64 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -763,8 +763,18 @@ RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \ PAM_WINBIND_OBJ = nsswitch/pam_winbind.o $(WBCOMMON_OBJ) \ $(LIBREPLACE_OBJ) @BUILD_INIPARSER@ -LIBSMBCLIENT_OBJ0 = libsmb/libsmbclient.o libsmb/libsmb_compat.o \ +LIBSMBCLIENT_OBJ0 = \ libsmb/libsmb_cache.o \ + libsmb/libsmb_compat.o \ + libsmb/libsmb_context.o \ + libsmb/libsmb_dir.o \ + libsmb/libsmb_file.o \ + libsmb/libsmb_misc.o \ + libsmb/libsmb_path.o \ + libsmb/libsmb_printjob.o \ + libsmb/libsmb_server.o \ + libsmb/libsmb_stat.o \ + libsmb/libsmb_xattr.o \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \ diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index 6c7dc80da8..353575dce8 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -1,12 +1,71 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" + + #ifndef _LIBSMB_INTERNAL_H_ #define _LIBSMB_INTERNAL_H_ +#include "../include/libsmbclient.h" + #define SMBC_MAX_NAME 1023 #define SMBC_FILE_MODE (S_IFREG | 0444) #define SMBC_DIR_MODE (S_IFDIR | 0555) +/* + * DOS Attribute values (used internally) + */ +typedef struct DOS_ATTR_DESC { + int mode; + SMB_OFF_T size; + time_t create_time; + time_t access_time; + time_t write_time; + time_t change_time; + SMB_INO_T inode; +} DOS_ATTR_DESC; + + +/* + * Internal flags for extended attributes + */ + +/* internal mode values */ +#define SMBC_XATTR_MODE_ADD 1 +#define SMBC_XATTR_MODE_REMOVE 2 +#define SMBC_XATTR_MODE_REMOVE_ALL 3 +#define SMBC_XATTR_MODE_SET 4 +#define SMBC_XATTR_MODE_CHOWN 5 +#define SMBC_XATTR_MODE_CHGRP 6 + +#define CREATE_ACCESS_READ READ_CONTROL_ACCESS -#include "include/libsmbclient.h" +/*We should test for this in configure ... */ +#ifndef ENOTSUP +#define ENOTSUP EOPNOTSUPP +#endif struct _SMBCSRV { @@ -46,12 +105,28 @@ struct _SMBCFILE { }; -struct smbc_internal_data { +/* + * Context structure + */ +struct _SMBCCTX { - /* - * Is this handle initialized ? - */ - bool _initialized; + /* True when this handle is initialized */ + bool initialized; + + /* Netbios name used for making connections */ + char * netbios_name; + + /* Workgroup used for making connections */ + char * workgroup; + + /* Username used for making connections */ + char * user; + + /* Debug level */ + int debug; + + /* Connection timeout value */ + int timeout; /* dirent pointer location * @@ -64,22 +139,22 @@ struct smbc_internal_data { * According to , NAME_MAX is 255. Is it longer * anyplace else? */ - char _dirent[1024]; + char dirent[1024]; /* * server connection list */ - SMBCSRV * _servers; + SMBCSRV * servers; /* * open file/dir list */ - SMBCFILE * _files; + SMBCFILE * files; /* * Log to standard error instead of the more typical standard output */ - bool _debug_stderr; + bool debug_stderr; /* * Support "Create Time" in get/set with the *xattr() functions, if @@ -88,33 +163,456 @@ struct smbc_internal_data { * CREATE_TIME. Default is FALSE, i.e. to use the old-style shorter * names and to not support CREATE time, for backward compatibility. */ - bool _full_time_names; + bool full_time_names; /* * The share mode of a file being opened. To match POSIX semantics * (and maintain backward compatibility), DENY_NONE is the default. */ - smbc_share_mode _share_mode; - - /* - * Authentication function which includes the context. This will be - * used if set; otherwise context->callbacks.auth_fn() will be used. - */ - smbc_get_auth_data_with_context_fn _auth_fn_with_context; + smbc_share_mode share_mode; /* * An opaque (to this library) user data handle which can be set * and retrieved with smbc_option_set() and smbc_option_get(). */ - void * _user_data; + void * user_data; /* * Should we attempt UNIX smb encryption ? * Set to 0 if we should never attempt, set to 1 if * encryption requested, set to 2 if encryption required. */ - int _smb_encryption_level; + int smb_encryption_level; + + /* + * From how many local master browsers should the list of + * workgroups be retrieved? It can take up to 12 minutes or + * longer after a server becomes a local master browser, for + * it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client + * never knows which local master browser will be found first, + * the one which is found first and used to retrieve a browse + * list may have an incomplete or empty browse list. By + * requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small + * networks (few workgroups), it is recommended that this + * value be set to 0, causing the browse lists from all found + * local master browsers to be retrieved and merged. For + * networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ + int browse_max_lmb_count; + + /* + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ + bool urlencode_readdir_entries; + + /* + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ + bool one_share_per_server; + + /* Kerberos-related flags */ + bool use_kerberos; + bool fallback_after_kerberos; + + /* Don't try to do automatic anonymous login */ + bool no_auto_anonymous_login; + + /* Server-related functions */ + struct + { + smbc_get_auth_data_fn get_auth_data_fn; + smbc_check_server_fn check_server_fn; + smbc_remove_unused_server_fn remove_unused_server_fn; + } server; + + /* Cache-related functions */ + struct + { + struct smbc_server_cache * server_cache_data; + smbc_add_cached_srv_fn add_cached_server_fn; + smbc_get_cached_srv_fn get_cached_server_fn; + smbc_remove_cached_srv_fn remove_cached_server_fn; + smbc_purge_cached_srv_fn purge_cached_server_fn; + } cache; + + /* POSIX emulation functions */ + struct + { + smbc_open_fn open_fn; + smbc_creat_fn creat_fn; + smbc_read_fn read_fn; + smbc_write_fn write_fn; + smbc_unlink_fn unlink_fn; + smbc_rename_fn rename_fn; + smbc_lseek_fn lseek_fn; + smbc_ftruncate_fn ftruncate_fn; + smbc_stat_fn stat_fn; + smbc_fstat_fn fstat_fn; + smbc_close_fn close_fn; + smbc_opendir_fn opendir_fn; + smbc_closedir_fn closedir_fn; + smbc_readdir_fn readdir_fn; + smbc_getdents_fn getdents_fn; + smbc_mkdir_fn mkdir_fn; + smbc_rmdir_fn rmdir_fn; + smbc_telldir_fn telldir_fn; + smbc_lseekdir_fn lseekdir_fn; + smbc_fstatdir_fn fstatdir_fn; + smbc_chmod_fn chmod_fn; + smbc_utimes_fn utimes_fn; + smbc_setxattr_fn setxattr_fn; + smbc_getxattr_fn getxattr_fn; + smbc_removexattr_fn removexattr_fn; + smbc_listxattr_fn listxattr_fn; + } posix_emu; + + /* Printing-related functions */ + struct + { + smbc_print_file_fn print_file_fn; + smbc_open_print_job_fn open_print_job_fn; + smbc_list_print_jobs_fn list_print_jobs_fn; + smbc_unlink_print_job_fn unlink_print_job_fn; + } printing; + +#if 0 /* not yet */ + /* SMB high-level functions */ + struct + { + } smb; + +#endif }; +/* Functions in libsmb_cache.c */ +int +SMBC_add_cached_server(SMBCCTX * context, + SMBCSRV * newsrv, + const char * server, + const char * share, + const char * workgroup, + const char * username); + +SMBCSRV * +SMBC_get_cached_server(SMBCCTX * context, + const char * server, + const char * share, + const char * workgroup, + const char * user); + +int +SMBC_remove_cached_server(SMBCCTX * context, + SMBCSRV * server); + +int +SMBC_purge_cached_servers(SMBCCTX * context); + + +/* Functions in libsmb_dir.c */ +int +SMBC_check_options(char *server, + char *share, + char *path, + char *options); + +SMBCFILE * +SMBC_opendir_ctx(SMBCCTX *context, + const char *fname); + +int +SMBC_closedir_ctx(SMBCCTX *context, + SMBCFILE *dir); + +struct smbc_dirent * +SMBC_readdir_ctx(SMBCCTX *context, + SMBCFILE *dir); + +int +SMBC_getdents_ctx(SMBCCTX *context, + SMBCFILE *dir, + struct smbc_dirent *dirp, + int count); + +int +SMBC_mkdir_ctx(SMBCCTX *context, + const char *fname, + mode_t mode); + +int +SMBC_rmdir_ctx(SMBCCTX *context, + const char *fname); + +off_t +SMBC_telldir_ctx(SMBCCTX *context, + SMBCFILE *dir); + +int +SMBC_lseekdir_ctx(SMBCCTX *context, + SMBCFILE *dir, + off_t offset); + +int +SMBC_fstatdir_ctx(SMBCCTX *context, + SMBCFILE *dir, + struct stat *st); + +int +SMBC_chmod_ctx(SMBCCTX *context, + const char *fname, + mode_t newmode); + +int +SMBC_utimes_ctx(SMBCCTX *context, + const char *fname, + struct timeval *tbuf); + +int +SMBC_unlink_ctx(SMBCCTX *context, + const char *fname); + +int +SMBC_rename_ctx(SMBCCTX *ocontext, + const char *oname, + SMBCCTX *ncontext, + const char *nname); + + +/* Functions in libsmb_file.c */ +SMBCFILE * +SMBC_open_ctx(SMBCCTX *context, + const char *fname, + int flags, + mode_t mode); + +SMBCFILE * +SMBC_creat_ctx(SMBCCTX *context, + const char *path, + mode_t mode); + +ssize_t +SMBC_read_ctx(SMBCCTX *context, + SMBCFILE *file, + void *buf, + size_t count); + +ssize_t +SMBC_write_ctx(SMBCCTX *context, + SMBCFILE *file, + void *buf, + size_t count); + +int +SMBC_close_ctx(SMBCCTX *context, + SMBCFILE *file); + +bool +SMBC_getatr(SMBCCTX * context, + SMBCSRV *srv, + char *path, + uint16 *mode, + SMB_OFF_T *size, + struct timespec *create_time_ts, + struct timespec *access_time_ts, + struct timespec *write_time_ts, + struct timespec *change_time_ts, + SMB_INO_T *ino); + +bool +SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, + time_t create_time, + time_t access_time, + time_t write_time, + time_t change_time, + uint16 mode); + +off_t +SMBC_lseek_ctx(SMBCCTX *context, + SMBCFILE *file, + off_t offset, + int whence); + +int +SMBC_ftruncate_ctx(SMBCCTX *context, + SMBCFILE *file, + off_t length); + + +/* Functions in libsmb_misc.c */ +int +SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p); + +int +SMBC_errno(SMBCCTX *context, + struct cli_state *c); + + +/* Functions in libsmb_path.c */ +int +SMBC_urldecode(char *dest, + char *src, + size_t max_dest_len); + +int +SMBC_urlencode(char *dest, + char *src, + int max_dest_len); + +int +SMBC_parse_path(TALLOC_CTX *ctx, + SMBCCTX *context, + const char *fname, + char **pp_workgroup, + char **pp_server, + char **pp_share, + char **pp_path, + char **pp_user, + char **pp_password, + char **pp_options); + + +/* Functions in libsmb_printjob.c */ +SMBCFILE * +SMBC_open_print_job_ctx(SMBCCTX *context, + const char *fname); + +int +SMBC_print_file_ctx(SMBCCTX *c_file, + const char *fname, + SMBCCTX *c_print, + const char *printq); + +int +SMBC_list_print_jobs_ctx(SMBCCTX *context, + const char *fname, + smbc_list_print_job_fn fn); + +int +SMBC_unlink_print_job_ctx(SMBCCTX *context, + const char *fname, + int id); + + +/* Functions in libsmb_server.c */ +int +SMBC_check_server(SMBCCTX * context, + SMBCSRV * server); + +int +SMBC_remove_unused_server(SMBCCTX * context, + SMBCSRV * srv); + +void +SMBC_call_auth_fn(TALLOC_CTX *ctx, + SMBCCTX *context, + const char *server, + const char *share, + char **pp_workgroup, + char **pp_username, + char **pp_password); + +void +SMBC_get_auth_data(const char *server, const char *share, + char *workgroup_buf, int workgroup_buf_len, + char *username_buf, int username_buf_len, + char *password_buf, int password_buf_len); + +SMBCSRV * +SMBC_find_server(TALLOC_CTX *ctx, + SMBCCTX *context, + const char *server, + const char *share, + char **pp_workgroup, + char **pp_username, + char **pp_password); + +SMBCSRV * +SMBC_server(TALLOC_CTX *ctx, + SMBCCTX *context, + bool connect_if_not_found, + const char *server, + const char *share, + char **pp_workgroup, + char **pp_username, + char **pp_password); + +SMBCSRV * +SMBC_attr_server(TALLOC_CTX *ctx, + SMBCCTX *context, + const char *server, + const char *share, + char **pp_workgroup, + char **pp_username, + char **pp_password); + + +/* Functions in libsmb_stat.c */ +int +SMBC_stat_ctx(SMBCCTX *context, + const char *fname, + struct stat *st); + +int +SMBC_fstat_ctx(SMBCCTX *context, + SMBCFILE *file, + struct stat *st); + + +/* Functions in libsmb_xattr.c */ +int +SMBC_setxattr_ctx(SMBCCTX *context, + const char *fname, + const char *name, + const void *value, + size_t size, + int flags); + +int +SMBC_getxattr_ctx(SMBCCTX *context, + const char *fname, + const char *name, + const void *value, + size_t size); + +int +SMBC_removexattr_ctx(SMBCCTX *context, + const char *fname, + const char *name); + +int +SMBC_listxattr_ctx(SMBCCTX *context, + const char *fname, + char *list, + size_t size); + #endif diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 64afc09499..a998bcee69 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -386,221 +386,310 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); * @return 0 when found and removed. 1 on failure. * */ -typedef int (*smbc_purge_cached_fn) (SMBCCTX * c); +typedef int (*smbc_purge_cached_srv_fn) (SMBCCTX * c); -/**@ingroup structure - * Structure that contains a client context information - * This structure is know as SMBCCTX +/** Get the debug level */ +int smbc_getDebug(SMBCCTX *c); + +/** Set the debug level */ +void smbc_setDebug(SMBCCTX *c, int debug); + +/** Get the netbios name used for making connections */ +char * smbc_getNetbiosName(SMBCCTX *c); + +/** Set the netbios name used for making connections */ +void smbc_setNetbiosName(SMBCCTX *c, char * netbios_name); + +/** Get the workgroup used for making connections */ +char * smbc_getWorkgroup(SMBCCTX *c); + +/** Set the workgroup used for making connections */ +void smbc_setWorkgroup(SMBCCTX *c, char * workgroup); + +/** Get the username used for making connections */ +char * smbc_getUser(SMBCCTX *c); + +/** Set the username used for making connections */ +void smbc_setUser(SMBCCTX *c, char * user); + +/** + * Get the timeout used for waiting on connections and response data + * (in milliseconds) */ -struct _SMBCCTX { - /** debug level - */ - int debug; - - /** netbios name used for making connections - */ - char * netbios_name; +int smbc_getTimeout(SMBCCTX *c); - /** workgroup name used for making connections - */ - char * workgroup; +/** + * Set the timeout used for waiting on connections and response data + * (in milliseconds) + */ +void smbc_setTimeout(SMBCCTX *c, int timeout); - /** username used for making connections - */ - char * user; +/** Get the function for obtaining authentication data */ +smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); - /** timeout used for waiting on connections / response data (in milliseconds) - */ - int timeout; - - /** callable functions for files: - * For usage and return values see the smbc_* functions - */ - SMBCFILE * (*open) (SMBCCTX *c, const char *fname, int flags, mode_t mode); - SMBCFILE * (*creat) (SMBCCTX *c, const char *path, mode_t mode); - ssize_t (*read) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); - ssize_t (*write) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); - int (*unlink) (SMBCCTX *c, const char *fname); - int (*rename) (SMBCCTX *ocontext, const char *oname, - SMBCCTX *ncontext, const char *nname); - off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); - int (*stat) (SMBCCTX *c, const char *fname, struct stat *st); - int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st); - /* ftruncate added near _internal for ABI compatibility */ - - int (*close_fn) (SMBCCTX *c, SMBCFILE *file); - - /** callable functions for dirs - */ - SMBCFILE * (*opendir) (SMBCCTX *c, const char *fname); - int (*closedir)(SMBCCTX *c, SMBCFILE *dir); - struct smbc_dirent * (*readdir)(SMBCCTX *c, SMBCFILE *dir); - int (*getdents)(SMBCCTX *c, SMBCFILE *dir, - struct smbc_dirent *dirp, int count); - int (*mkdir) (SMBCCTX *c, const char *fname, mode_t mode); - int (*rmdir) (SMBCCTX *c, const char *fname); - off_t (*telldir) (SMBCCTX *c, SMBCFILE *dir); - int (*lseekdir)(SMBCCTX *c, SMBCFILE *dir, off_t offset); - int (*fstatdir)(SMBCCTX *c, SMBCFILE *dir, struct stat *st); - int (*chmod)(SMBCCTX *c, const char *fname, mode_t mode); - int (*utimes)(SMBCCTX *c, - const char *fname, struct timeval *tbuf); - int (*setxattr)(SMBCCTX *context, - const char *fname, - const char *name, - const void *value, - size_t size, - int flags); - int (*getxattr)(SMBCCTX *context, - const char *fname, - const char *name, - const void *value, - size_t size); - int (*removexattr)(SMBCCTX *context, - const char *fname, - const char *name); - int (*listxattr)(SMBCCTX *context, +/** Set the function for obtaining authentication data */ +void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn f); + +/** Get the function for checking if a server is still good */ +smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c); + +/** Set the function for checking if a server is still good */ +void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn f); + +/** Get the function for removing a server if unused */ +smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c); + +/** Set the function for removing a server if unused */ +void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, + smbc_remove_unused_server_fn f); + +/** Get the function for adding a cached server */ +smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c); + +/** Set the function for adding a cached server */ +void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn f); + +/** Get the function for server cache lookup */ +smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c); + +/** Set the function for server cache lookup */ +void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn f); + +/** Get the function for server cache removal */ +smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c); + +/** Set the function for server cache removal */ +void smbc_setFunctionRemoveCachedServer(SMBCCTX *c, + smbc_remove_cached_srv_fn f); + +/** + * Get the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); + +/** + * Set the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, + smbc_purge_cached_srv_fn f); + +/** Get the function to store private data of the server cache */ +struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); + +/** Set the function to store private data of the server cache */ +void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache); + + +/** + * Callable functions for files. + */ + +typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c, + const char *fname, + int flags, + mode_t mode); +smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c); +void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn f); + +typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c, + const char *path, + mode_t mode); +smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c); +void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn); + +typedef ssize_t (*smbc_read_fn)(SMBCCTX *c, + SMBCFILE *file, + void *buf, + size_t count); +smbc_read_fn smbc_getFunctionRead(SMBCCTX *c); +void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn f); + +typedef ssize_t (*smbc_write_fn)(SMBCCTX *c, + SMBCFILE *file, + void *buf, + size_t count); +smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c); +void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn f); + +typedef int (*smbc_unlink_fn)(SMBCCTX *c, + const char *fname); +smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c); +void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn f); + +typedef int (*smbc_rename_fn)(SMBCCTX *ocontext, + const char *oname, + SMBCCTX *ncontext, + const char *nname); +smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c); +void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn f); + +typedef off_t (*smbc_lseek_fn)(SMBCCTX *c, + SMBCFILE * file, + off_t offset, + int whence); +smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c); +void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn f); + +typedef int (*smbc_stat_fn)(SMBCCTX *c, + const char *fname, + struct stat *st); +smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c); +void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn f); + +typedef int (*smbc_fstat_fn)(SMBCCTX *c, + SMBCFILE *file, + struct stat *st); +smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c); +void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn f); + +typedef int (*smbc_ftruncate_fn)(SMBCCTX *c, + SMBCFILE *f, + off_t size); +smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c); +void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn f); + +typedef int (*smbc_close_fn)(SMBCCTX *c, + SMBCFILE *file); +smbc_close_fn smbc_getFunctionClose(SMBCCTX *c); +void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn f); + + +/** + * Callable functions for directories. + */ + +typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c, + const char *fname); +smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c); +void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn f); + +typedef int (*smbc_closedir_fn)(SMBCCTX *c, + SMBCFILE *dir); +smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c); +void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn f); + +typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c, + SMBCFILE *dir); +smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c); +void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn f); + +typedef int (*smbc_getdents_fn)(SMBCCTX *c, + SMBCFILE *dir, + struct smbc_dirent *dirp, + int count); +smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c); +void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn f); + +typedef int (*smbc_mkdir_fn)(SMBCCTX *c, + const char *fname, + mode_t mode); +smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c); +void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn f); + +typedef int (*smbc_rmdir_fn)(SMBCCTX *c, + const char *fname); +smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c); +void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn f); + +typedef off_t (*smbc_telldir_fn)(SMBCCTX *c, + SMBCFILE *dir); +smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c); +void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn f); + +typedef int (*smbc_lseekdir_fn)(SMBCCTX *c, + SMBCFILE *dir, + off_t offset); +smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c); +void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn f); + +typedef int (*smbc_fstatdir_fn)(SMBCCTX *c, + SMBCFILE *dir, + struct stat *st); +smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c); +void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn f); + + +/** + * Callable functions applicable to both files and directories. + */ + +typedef int (*smbc_chmod_fn)(SMBCCTX *c, + const char *fname, + mode_t mode); +smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c); +void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn f); + +typedef int (*smbc_utimes_fn)(SMBCCTX *c, + const char *fname, + struct timeval *tbuf); +smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c); +void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn f); + +typedef int (*smbc_setxattr_fn)(SMBCCTX *context, + const char *fname, + const char *name, + const void *value, + size_t size, + int flags); +smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c); +void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn f); + +typedef int (*smbc_getxattr_fn)(SMBCCTX *context, const char *fname, - char *list, + const char *name, + const void *value, size_t size); +smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c); +void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn f); - /** callable functions for printing - */ - int (*print_file)(SMBCCTX *c_file, const char *fname, - SMBCCTX *c_print, const char *printq); - SMBCFILE * (*open_print_job)(SMBCCTX *c, const char *fname); - int (*list_print_jobs)(SMBCCTX *c, const char *fname, smbc_list_print_job_fn fn); - int (*unlink_print_job)(SMBCCTX *c, const char *fname, int id); - - - /* - ** Callbacks - * These callbacks _always_ have to be initialized because they will - * not be checked at dereference for increased speed. - */ - struct _smbc_callbacks { - /** authentication function callback: called upon auth requests - */ - smbc_get_auth_data_fn auth_fn; - - /** check if a server is still good - */ - smbc_check_server_fn check_server_fn; - - /** remove a server if unused - */ - smbc_remove_unused_server_fn remove_unused_server_fn; - - /** Cache subsystem - * For an example cache system see samba/source/libsmb/libsmb_cache.c - * Cache subsystem functions follow. - */ - - /** server cache addition - */ - smbc_add_cached_srv_fn add_cached_srv_fn; - - /** server cache lookup - */ - smbc_get_cached_srv_fn get_cached_srv_fn; - - /** server cache removal - */ - smbc_remove_cached_srv_fn remove_cached_srv_fn; - - /** server cache purging, try to remove all cached servers (disconnect) - */ - smbc_purge_cached_fn purge_cached_fn; - } callbacks; +typedef int (*smbc_removexattr_fn)(SMBCCTX *context, + const char *fname, + const char *name); +smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c); +void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn f); +typedef int (*smbc_listxattr_fn)(SMBCCTX *context, + const char *fname, + char *list, + size_t size); +smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c); +void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn f); - /** Space to store private data of the server cache. - */ - struct smbc_server_cache * server_cache; - - int flags; - - /** user options selections that apply to this session - * - * NEW OPTIONS ARE NOT ADDED HERE! - * - * We must maintain ABI backward compatibility. We now use - * smbc_option_set() and smbc_option_get() for all newly added - * options. - */ - struct _smbc_options { - - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ - int browse_max_lmb_count; - - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ - int urlencode_readdir_entries; - - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ - int one_share_per_server; - } options; - - /* Add additional functions here for ABI backward compatibility */ - int (*ftruncate)(SMBCCTX *c, SMBCFILE *f, off_t size); - - /** INTERNAL DATA - * do _NOT_ touch this from your program ! - */ - struct smbc_internal_data * internal; -}; -/* Flags for SMBCCTX->flags */ -#define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) -#define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) -#define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */ +/** + * Callable functions related to printing + */ + +typedef int (*smbc_print_file_fn)(SMBCCTX *c_file, + const char *fname, + SMBCCTX *c_print, + const char *printq); +smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c); +void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn f); + +typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c, + const char *fname); +smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c); +void smbc_setFunctionOpenPrintJob(SMBCCTX *c, + smbc_open_print_job_fn f); + +typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c, + const char *fname, + smbc_list_print_job_fn fn); +smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c); +void smbc_setFunctionListPrintJobs(SMBCCTX *c, + smbc_list_print_jobs_fn f); + +typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c, + const char *fname, + int id); +smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c); +void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, + smbc_unlink_print_job_fn f); + /**@ingroup misc * Create a new SBMCCTX (a context). diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c index b98df024fa..e0571fa9fe 100644 --- a/source3/libsmb/libsmb_cache.c +++ b/source3/libsmb/libsmb_cache.c @@ -22,11 +22,8 @@ */ #include "includes.h" - -#include "include/libsmbclient.h" -#include "../include/libsmb_internal.h" - -int smbc_default_cache_functions(SMBCCTX * context); +#include "libsmbclient.h" +#include "libsmb_internal.h" /* * Structure we use if internal caching mechanism is used @@ -48,9 +45,13 @@ struct smbc_server_cache { * Add a new connection to the server cache. * This function is only used if the external cache is not enabled */ -static int smbc_add_cached_server(SMBCCTX * context, SMBCSRV * newsrv, - const char * server, const char * share, - const char * workgroup, const char * username) +int +SMBC_add_cached_server(SMBCCTX * context, + SMBCSRV * newsrv, + const char * server, + const char * share, + const char * workgroup, + const char * username) { struct smbc_server_cache * srvcache = NULL; @@ -88,7 +89,7 @@ static int smbc_add_cached_server(SMBCCTX * context, SMBCSRV * newsrv, goto failed; } - DLIST_ADD((context->server_cache), srvcache); + DLIST_ADD((context->cache.server_cache_data), srvcache); return 0; failed: @@ -108,13 +109,17 @@ static int smbc_add_cached_server(SMBCCTX * context, SMBCSRV * newsrv, * returns server handle on success, NULL on error (not found) * This function is only used if the external cache is not enabled */ -static SMBCSRV * smbc_get_cached_server(SMBCCTX * context, const char * server, - const char * share, const char * workgroup, const char * user) +SMBCSRV * +SMBC_get_cached_server(SMBCCTX * context, + const char * server, + const char * share, + const char * workgroup, + const char * user) { struct smbc_server_cache * srv = NULL; /* Search the cache lines */ - for (srv=((struct smbc_server_cache *)context->server_cache);srv;srv=srv->next) { + for (srv = context->cache.server_cache_data; srv; srv = srv->next) { if (strcmp(server,srv->server_name) == 0 && strcmp(workgroup,srv->workgroup) == 0 && @@ -146,7 +151,7 @@ static SMBCSRV * smbc_get_cached_server(SMBCCTX * context, const char * server, * a connection to the server (other than the * attribute server connection) is cool. */ - if (context->options.one_share_per_server) { + if (context->one_share_per_server) { /* * The currently connected share name * doesn't match the requested share, so @@ -156,7 +161,7 @@ static SMBCSRV * smbc_get_cached_server(SMBCCTX * context, const char * server, /* Sigh. Couldn't disconnect. */ cli_shutdown(srv->server->cli); srv->server->cli = NULL; - context->callbacks.remove_cached_srv_fn(context, srv->server); + context->cache.remove_cached_server_fn(context, srv->server); continue; } @@ -171,7 +176,7 @@ static SMBCSRV * smbc_get_cached_server(SMBCCTX * context, const char * server, /* Out of memory. */ cli_shutdown(srv->server->cli); srv->server->cli = NULL; - context->callbacks.remove_cached_srv_fn(context, srv->server); + context->cache.remove_cached_server_fn(context, srv->server); continue; } @@ -190,15 +195,17 @@ static SMBCSRV * smbc_get_cached_server(SMBCCTX * context, const char * server, * returns 0 on success * This function is only used if the external cache is not enabled */ -static int smbc_remove_cached_server(SMBCCTX * context, SMBCSRV * server) +int +SMBC_remove_cached_server(SMBCCTX * context, + SMBCSRV * server) { struct smbc_server_cache * srv = NULL; - for (srv=((struct smbc_server_cache *)context->server_cache);srv;srv=srv->next) { + for (srv = context->cache.server_cache_data; srv; srv = srv->next) { if (server == srv->server) { /* remove this sucker */ - DLIST_REMOVE(context->server_cache, srv); + DLIST_REMOVE(context->cache.server_cache_data, srv); SAFE_FREE(srv->server_name); SAFE_FREE(srv->share_name); SAFE_FREE(srv->workgroup); @@ -216,40 +223,23 @@ static int smbc_remove_cached_server(SMBCCTX * context, SMBCSRV * server) * Try to remove all the servers in cache * returns 1 on failure and 0 if all servers could be removed. */ -static int smbc_purge_cached(SMBCCTX * context) +int +SMBC_purge_cached_servers(SMBCCTX * context) { struct smbc_server_cache * srv; struct smbc_server_cache * next; int could_not_purge_all = 0; - for (srv = ((struct smbc_server_cache *) context->server_cache), - next = (srv ? srv->next :NULL); + for (srv = context->cache.server_cache_data, + next = (srv ? srv->next :NULL); srv; - srv = next, next = (srv ? srv->next : NULL)) { + srv = next, + next = (srv ? srv->next : NULL)) { - if (smbc_remove_unused_server(context, srv->server)) { + if (SMBC_remove_unused_server(context, srv->server)) { /* could not be removed */ could_not_purge_all = 1; } } return could_not_purge_all; } - - - -/* - * This functions initializes all server-cache related functions - * to the default (internal) system. - * - * We use this to make the rest of the cache system static. - */ - -int smbc_default_cache_functions(SMBCCTX * context) -{ - context->callbacks.add_cached_srv_fn = smbc_add_cached_server; - context->callbacks.get_cached_srv_fn = smbc_get_cached_server; - context->callbacks.remove_cached_srv_fn = smbc_remove_cached_server; - context->callbacks.purge_cached_fn = smbc_purge_cached; - - return 0; -} diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 6042464fd2..7a0536a92d 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -5,7 +5,7 @@ Copyright (C) Richard Sharpe 2000 Copyright (C) John Terpstra 2000 Copyright (C) Tom Jansen (Ninja ISD) 2002 - Copyright (C) Derrell Lipman 2003 + Copyright (C) Derrell Lipman 2003, 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 @@ -23,8 +23,7 @@ #include "includes.h" - -#include "include/libsmb_internal.h" +#include "libsmb_internal.h" struct smbc_compat_fdlist { SMBCFILE * file; @@ -39,7 +38,8 @@ static struct smbc_compat_fdlist * smbc_compat_fd_in_use = NULL; static struct smbc_compat_fdlist * smbc_compat_fd_avail = NULL; /* Find an fd and return the SMBCFILE * or NULL on failure */ -static SMBCFILE * find_fd(int fd) +static SMBCFILE * +find_fd(int fd) { struct smbc_compat_fdlist * f = smbc_compat_fd_in_use; while (f) { @@ -51,7 +51,8 @@ static SMBCFILE * find_fd(int fd) } /* Add an fd, returns 0 on success, -1 on error with errno set */ -static int add_fd(SMBCFILE * file) +static int +add_fd(SMBCFILE * file) { struct smbc_compat_fdlist * f = smbc_compat_fd_avail; @@ -90,7 +91,8 @@ static int add_fd(SMBCFILE * file) /* Delete an fd, returns 0 on success */ -static int del_fd(int fd) +static int +del_fd(int fd) { struct smbc_compat_fdlist * f = smbc_compat_fd_in_use; @@ -112,15 +114,17 @@ static int del_fd(int fd) -int smbc_init(smbc_get_auth_data_fn fn, int debug) +int +smbc_init(smbc_get_auth_data_fn fn, + int debug) { if (!smbc_compat_initialized) { statcont = smbc_new_context(); if (!statcont) return -1; - statcont->debug = debug; - statcont->callbacks.auth_fn = fn; + smbc_setDebug(statcont, debug); + smbc_setFunctionAuthData(statcont, fn); if (!smbc_init_context(statcont)) { smbc_free_context(statcont, False); @@ -135,7 +139,8 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug) } -SMBCCTX *smbc_set_context(SMBCCTX * context) +SMBCCTX * +smbc_set_context(SMBCCTX * context) { SMBCCTX *old_context = statcont; @@ -151,307 +156,387 @@ SMBCCTX *smbc_set_context(SMBCCTX * context) } -int smbc_open(const char *furl, int flags, mode_t mode) +int +smbc_open(const char *furl, + int flags, + mode_t mode) { SMBCFILE * file; int fd; - file = (statcont->open)(statcont, furl, flags, mode); + file = smbc_getFunctionOpen(statcont)(statcont, furl, flags, mode); if (!file) return -1; fd = add_fd(file); if (fd == -1) - (statcont->close_fn)(statcont, file); + smbc_getFunctionClose(statcont)(statcont, file); return fd; } -int smbc_creat(const char *furl, mode_t mode) +int +smbc_creat(const char *furl, + mode_t mode) { SMBCFILE * file; int fd; - file = (statcont->creat)(statcont, furl, mode); + file = smbc_getFunctionCreat(statcont)(statcont, furl, mode); if (!file) return -1; fd = add_fd(file); if (fd == -1) { /* Hmm... should we delete the file too ? I guess we could try */ - (statcont->close_fn)(statcont, file); - (statcont->unlink)(statcont, furl); + smbc_getFunctionClose(statcont)(statcont, file); + smbc_getFunctionUnlink(statcont)(statcont, furl); } return fd; } -ssize_t smbc_read(int fd, void *buf, size_t bufsize) +ssize_t +smbc_read(int fd, + void *buf, + size_t bufsize) { SMBCFILE * file = find_fd(fd); - return (statcont->read)(statcont, file, buf, bufsize); + return smbc_getFunctionRead(statcont)(statcont, file, buf, bufsize); } -ssize_t smbc_write(int fd, void *buf, size_t bufsize) +ssize_t +smbc_write(int fd, + void *buf, + size_t bufsize) { SMBCFILE * file = find_fd(fd); - return (statcont->write)(statcont, file, buf, bufsize); + return smbc_getFunctionWrite(statcont)(statcont, file, buf, bufsize); } -off_t smbc_lseek(int fd, off_t offset, int whence) +off_t +smbc_lseek(int fd, + off_t offset, + int whence) { SMBCFILE * file = find_fd(fd); - return (statcont->lseek)(statcont, file, offset, whence); + return smbc_getFunctionLseek(statcont)(statcont, file, offset, whence); } -int smbc_close(int fd) +int +smbc_close(int fd) { SMBCFILE * file = find_fd(fd); del_fd(fd); - return (statcont->close_fn)(statcont, file); + return smbc_getFunctionClose(statcont)(statcont, file); } -int smbc_unlink(const char *fname) +int +smbc_unlink(const char *fname) { - return (statcont->unlink)(statcont, fname); + return smbc_getFunctionUnlink(statcont)(statcont, fname); } -int smbc_rename(const char *ourl, const char *nurl) +int +smbc_rename(const char *ourl, + const char *nurl) { - return (statcont->rename)(statcont, ourl, statcont, nurl); + return smbc_getFunctionRename(statcont)(statcont, ourl, + statcont, nurl); } -int smbc_opendir(const char *durl) +int +smbc_opendir(const char *durl) { SMBCFILE * file; int fd; - file = (statcont->opendir)(statcont, durl); + file = smbc_getFunctionOpendir(statcont)(statcont, durl); if (!file) return -1; fd = add_fd(file); if (fd == -1) - (statcont->closedir)(statcont, file); + smbc_getFunctionClosedir(statcont)(statcont, file); return fd; } -int smbc_closedir(int dh) +int +smbc_closedir(int dh) { SMBCFILE * file = find_fd(dh); del_fd(dh); - return (statcont->closedir)(statcont, file); + return smbc_getFunctionClosedir(statcont)(statcont, file); } -int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count) +int +smbc_getdents(unsigned int dh, + struct smbc_dirent *dirp, + int count) { SMBCFILE * file = find_fd(dh); - return (statcont->getdents)(statcont, file,dirp, count); + return smbc_getFunctionGetdents(statcont)(statcont, file, dirp, count); } -struct smbc_dirent* smbc_readdir(unsigned int dh) +struct smbc_dirent * +smbc_readdir(unsigned int dh) { SMBCFILE * file = find_fd(dh); - return (statcont->readdir)(statcont, file); + return smbc_getFunctionReaddir(statcont)(statcont, file); } -off_t smbc_telldir(int dh) +off_t +smbc_telldir(int dh) { SMBCFILE * file = find_fd(dh); - return (statcont->telldir)(statcont, file); + return smbc_getFunctionTelldir(statcont)(statcont, file); } -int smbc_lseekdir(int fd, off_t offset) +int +smbc_lseekdir(int fd, + off_t offset) { SMBCFILE * file = find_fd(fd); - return (statcont->lseekdir)(statcont, file, offset); + return smbc_getFunctionLseekdir(statcont)(statcont, file, offset); } -int smbc_mkdir(const char *durl, mode_t mode) +int +smbc_mkdir(const char *durl, + mode_t mode) { - return (statcont->mkdir)(statcont, durl, mode); + return smbc_getFunctionMkdir(statcont)(statcont, durl, mode); } -int smbc_rmdir(const char *durl) +int +smbc_rmdir(const char *durl) { - return (statcont->rmdir)(statcont, durl); + return smbc_getFunctionRmdir(statcont)(statcont, durl); } -int smbc_stat(const char *url, struct stat *st) +int +smbc_stat(const char *url, + struct stat *st) { - return (statcont->stat)(statcont, url, st); + return smbc_getFunctionStat(statcont)(statcont, url, st); } -int smbc_fstat(int fd, struct stat *st) +int +smbc_fstat(int fd, + struct stat *st) { SMBCFILE * file = find_fd(fd); - return (statcont->fstat)(statcont, file, st); + return smbc_getFunctionFstat(statcont)(statcont, file, st); } -int smbc_ftruncate(int fd, off_t size) +int +smbc_ftruncate(int fd, + off_t size) { SMBCFILE * file = find_fd(fd); - return (statcont->ftruncate)(statcont, file, size); + return smbc_getFunctionFtruncate(statcont)(statcont, file, size); } -int smbc_chmod(const char *url, mode_t mode) +int +smbc_chmod(const char *url, + mode_t mode) { - return (statcont->chmod)(statcont, url, mode); + return smbc_getFunctionChmod(statcont)(statcont, url, mode); } -int smbc_utimes(const char *fname, struct timeval *tbuf) +int +smbc_utimes(const char *fname, + struct timeval *tbuf) { - return (statcont->utimes)(statcont, fname, tbuf); + return smbc_getFunctionUtimes(statcont)(statcont, fname, tbuf); } #ifdef HAVE_UTIME_H -int smbc_utime(const char *fname, struct utimbuf *utbuf) +int +smbc_utime(const char *fname, + struct utimbuf *utbuf) { struct timeval tv[2]; if (utbuf == NULL) - return (statcont->utimes)(statcont, fname, NULL); + return smbc_getFunctionUtimes(statcont)(statcont, fname, NULL); tv[0].tv_sec = utbuf->actime; tv[1].tv_sec = utbuf->modtime; tv[0].tv_usec = tv[1].tv_usec = 0; - return (statcont->utimes)(statcont, fname, tv); + return smbc_getFunctionUtimes(statcont)(statcont, fname, tv); } #endif -int smbc_setxattr(const char *fname, - const char *name, - const void *value, - size_t size, - int flags) +int +smbc_setxattr(const char *fname, + const char *name, + const void *value, + size_t size, + int flags) { - return (statcont->setxattr)(statcont, fname, name, value, size, flags); + return smbc_getFunctionSetxattr(statcont)(statcont, + fname, name, + value, size, flags); } -int smbc_lsetxattr(const char *fname, - const char *name, - const void *value, - size_t size, - int flags) +int +smbc_lsetxattr(const char *fname, + const char *name, + const void *value, + size_t size, + int flags) { - return (statcont->setxattr)(statcont, fname, name, value, size, flags); + return smbc_getFunctionSetxattr(statcont)(statcont, + fname, name, + value, size, flags); } -int smbc_fsetxattr(int fd, - const char *name, - const void *value, - size_t size, - int flags) +int +smbc_fsetxattr(int fd, + const char *name, + const void *value, + size_t size, + int flags) { SMBCFILE * file = find_fd(fd); if (file == NULL) { errno = EBADF; return -1; } - return (statcont->setxattr)(statcont, file->fname, - name, value, size, flags); + return smbc_getFunctionSetxattr(statcont)(statcont, + file->fname, name, + value, size, flags); } -int smbc_getxattr(const char *fname, - const char *name, - const void *value, - size_t size) +int +smbc_getxattr(const char *fname, + const char *name, + const void *value, + size_t size) { - return (statcont->getxattr)(statcont, fname, name, value, size); + return smbc_getFunctionGetxattr(statcont)(statcont, + fname, name, + value, size); } -int smbc_lgetxattr(const char *fname, - const char *name, - const void *value, - size_t size) +int +smbc_lgetxattr(const char *fname, + const char *name, + const void *value, + size_t size) { - return (statcont->getxattr)(statcont, fname, name, value, size); + return smbc_getFunctionGetxattr(statcont)(statcont, + fname, name, + value, size); } -int smbc_fgetxattr(int fd, - const char *name, - const void *value, - size_t size) +int +smbc_fgetxattr(int fd, + const char *name, + const void *value, + size_t size) { SMBCFILE * file = find_fd(fd); if (file == NULL) { errno = EBADF; return -1; } - return (statcont->getxattr)(statcont, file->fname, name, value, size); + return smbc_getFunctionGetxattr(statcont)(statcont, + file->fname, name, + value, size); } -int smbc_removexattr(const char *fname, - const char *name) +int +smbc_removexattr(const char *fname, + const char *name) { - return (statcont->removexattr)(statcont, fname, name); + return smbc_getFunctionRemovexattr(statcont)(statcont, fname, name); } -int smbc_lremovexattr(const char *fname, - const char *name) +int +smbc_lremovexattr(const char *fname, + const char *name) { - return (statcont->removexattr)(statcont, fname, name); + return smbc_getFunctionRemovexattr(statcont)(statcont, fname, name); } -int smbc_fremovexattr(int fd, - const char *name) +int +smbc_fremovexattr(int fd, + const char *name) { SMBCFILE * file = find_fd(fd); if (file == NULL) { errno = EBADF; return -1; } - return (statcont->removexattr)(statcont, file->fname, name); + return smbc_getFunctionRemovexattr(statcont)(statcont, + file->fname, name); } -int smbc_listxattr(const char *fname, - char *list, - size_t size) +int +smbc_listxattr(const char *fname, + char *list, + size_t size) { - return (statcont->listxattr)(statcont, fname, list, size); + return smbc_getFunctionListxattr(statcont)(statcont, + fname, list, size); } -int smbc_llistxattr(const char *fname, - char *list, - size_t size) +int +smbc_llistxattr(const char *fname, + char *list, + size_t size) { - return (statcont->listxattr)(statcont, fname, list, size); + return smbc_getFunctionListxattr(statcont)(statcont, + fname, list, size); } -int smbc_flistxattr(int fd, - char *list, - size_t size) +int +smbc_flistxattr(int fd, + char *list, + size_t size) { SMBCFILE * file = find_fd(fd); if (file == NULL) { errno = EBADF; return -1; } - return (statcont->listxattr)(statcont, file->fname, list, size); + return smbc_getFunctionListxattr(statcont)(statcont, + file->fname, list, size); } -int smbc_print_file(const char *fname, const char *printq) +int +smbc_print_file(const char *fname, + const char *printq) { - return (statcont->print_file)(statcont, fname, statcont, printq); + return smbc_getFunctionPrintFile(statcont)(statcont, fname, + statcont, printq); } -int smbc_open_print_job(const char *fname) +int +smbc_open_print_job(const char *fname) { - SMBCFILE * file = (statcont->open_print_job)(statcont, fname); + SMBCFILE * file; + + file = smbc_getFunctionOpenPrintJob(statcont)(statcont, fname); if (!file) return -1; return file->cli_fd; } -int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn) +int +smbc_list_print_jobs(const char *purl, + smbc_list_print_job_fn fn) { - return (statcont->list_print_jobs)(statcont, purl, fn); + return smbc_getFunctionListPrintJobs(statcont)(statcont, purl, fn); } -int smbc_unlink_print_job(const char *purl, int id) +int +smbc_unlink_print_job(const char *purl, + int id) { - return (statcont->unlink_print_job)(statcont, purl, id); + return smbc_getFunctionUnlinkPrintJob(statcont)(statcont, purl, id); } diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c new file mode 100644 index 0000000000..1505d50a43 --- /dev/null +++ b/source3/libsmb/libsmb_context.c @@ -0,0 +1,1283 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* + * Is the logging working / configfile read ? + */ +static int SMBC_initialized = 0; + + + +/* + * Get a new empty handle to fill in with your own info + */ +SMBCCTX * +smbc_new_context(void) +{ + SMBCCTX *context; + + context = SMB_MALLOC_P(SMBCCTX); + if (!context) { + errno = ENOMEM; + return NULL; + } + + + /* Initialize the context and establish reasonable defaults */ + ZERO_STRUCTP(context); + + context->debug = 0; + context->timeout = 20000; /* 20 seconds */ + + context->full_time_names = False; + context->share_mode = SMBC_SHAREMODE_DENY_NONE; + context->smb_encryption_level = 0; + context->browse_max_lmb_count = 3; /* # LMBs to query */ + context->urlencode_readdir_entries = False; + context->one_share_per_server = False; + context->use_kerberos = False; + context->fallback_after_kerberos = False; + context->no_auto_anonymous_login = False; + + context->server.get_auth_data_fn = SMBC_get_auth_data; + context->server.check_server_fn = SMBC_check_server; + context->server.remove_unused_server_fn = SMBC_remove_unused_server; + + context->cache.server_cache_data = NULL; + context->cache.add_cached_server_fn = SMBC_add_cached_server; + context->cache.get_cached_server_fn = SMBC_get_cached_server; + context->cache.remove_cached_server_fn = SMBC_remove_cached_server; + context->cache.purge_cached_server_fn = SMBC_purge_cached_servers; + + context->posix_emu.open_fn = SMBC_open_ctx; + context->posix_emu.creat_fn = SMBC_creat_ctx; + context->posix_emu.read_fn = SMBC_read_ctx; + context->posix_emu.write_fn = SMBC_write_ctx; + context->posix_emu.close_fn = SMBC_close_ctx; + context->posix_emu.unlink_fn = SMBC_unlink_ctx; + context->posix_emu.rename_fn = SMBC_rename_ctx; + context->posix_emu.lseek_fn = SMBC_lseek_ctx; + context->posix_emu.ftruncate_fn = SMBC_ftruncate_ctx; + context->posix_emu.stat_fn = SMBC_stat_ctx; + context->posix_emu.fstat_fn = SMBC_fstat_ctx; + context->posix_emu.opendir_fn = SMBC_opendir_ctx; + context->posix_emu.closedir_fn = SMBC_closedir_ctx; + context->posix_emu.readdir_fn = SMBC_readdir_ctx; + context->posix_emu.getdents_fn = SMBC_getdents_ctx; + context->posix_emu.mkdir_fn = SMBC_mkdir_ctx; + context->posix_emu.rmdir_fn = SMBC_rmdir_ctx; + context->posix_emu.telldir_fn = SMBC_telldir_ctx; + context->posix_emu.lseekdir_fn = SMBC_lseekdir_ctx; + context->posix_emu.fstatdir_fn = SMBC_fstatdir_ctx; + context->posix_emu.chmod_fn = SMBC_chmod_ctx; + context->posix_emu.utimes_fn = SMBC_utimes_ctx; + context->posix_emu.setxattr_fn = SMBC_setxattr_ctx; + context->posix_emu.getxattr_fn = SMBC_getxattr_ctx; + context->posix_emu.removexattr_fn = SMBC_removexattr_ctx; + context->posix_emu.listxattr_fn = SMBC_listxattr_ctx; + + context->printing.open_print_job_fn = SMBC_open_print_job_ctx; + context->printing.print_file_fn = SMBC_print_file_ctx; + context->printing.list_print_jobs_fn = SMBC_list_print_jobs_ctx; + context->printing.unlink_print_job_fn = SMBC_unlink_print_job_ctx; + + return context; +} + +/* + * Free a context + * + * Returns 0 on success. Otherwise returns 1, the SMBCCTX is _not_ freed + * and thus you'll be leaking memory if not handled properly. + * + */ +int +smbc_free_context(SMBCCTX *context, + int shutdown_ctx) +{ + if (!context) { + errno = EBADF; + return 1; + } + + if (shutdown_ctx) { + SMBCFILE * f; + DEBUG(1,("Performing aggressive shutdown.\n")); + + f = context->files; + while (f) { + (context->posix_emu.close_fn)(context, f); + f = f->next; + } + context->files = NULL; + + /* First try to remove the servers the nice way. */ + if (context->cache.purge_cached_server_fn(context)) { + SMBCSRV * s; + SMBCSRV * next; + DEBUG(1, ("Could not purge all servers, " + "Nice way shutdown failed.\n")); + s = context->servers; + while (s) { + DEBUG(1, ("Forced shutdown: %p (fd=%d)\n", + s, s->cli->fd)); + cli_shutdown(s->cli); + (context->cache.remove_cached_server_fn)(context, + s); + next = s->next; + DLIST_REMOVE(context->servers, s); + SAFE_FREE(s); + s = next; + } + context->servers = NULL; + } + } + else { + /* This is the polite way */ + if ((context->cache.purge_cached_server_fn)(context)) { + DEBUG(1, ("Could not purge all servers, " + "free_context failed.\n")); + errno = EBUSY; + return 1; + } + if (context->servers) { + DEBUG(1, ("Active servers in context, " + "free_context failed.\n")); + errno = EBUSY; + return 1; + } + if (context->files) { + DEBUG(1, ("Active files in context, " + "free_context failed.\n")); + errno = EBUSY; + return 1; + } + } + + /* Things we have to clean up */ + SAFE_FREE(context->workgroup); + SAFE_FREE(context->netbios_name); + SAFE_FREE(context->user); + + DEBUG(3, ("Context %p successfully freed\n", context)); + SAFE_FREE(context); + return 0; +} + + +/* + * Each time the context structure is changed, we have binary backward + * compatibility issues. Instead of modifying the public portions of the + * context structure to add new options, instead, we put them in the internal + * portion of the context structure and provide a set function for these new + * options. + */ +void +smbc_option_set(SMBCCTX *context, + char *option_name, + ... /* option_value */) +{ + va_list ap; + union { + int i; + bool b; + smbc_get_auth_data_with_context_fn auth_fn; + void *v; + const char *s; + } option_value; + + va_start(ap, option_name); + + if (strcmp(option_name, "debug_to_stderr") == 0) { + /* + * Log to standard error instead of standard output. + */ + option_value.b = (bool) va_arg(ap, int); + context->debug_stderr = option_value.b; + + } else if (strcmp(option_name, "full_time_names") == 0) { + /* + * Use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also + * setting/getting CREATE_TIME which was previously + * unimplemented. (Note that the old C_TIME was supposed to + * be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ + option_value.b = (bool) va_arg(ap, int); + context->full_time_names = option_value.b; + + } else if (strcmp(option_name, "open_share_mode") == 0) { + /* + * The share mode to use for files opened with + * SMBC_open_ctx(). The default is SMBC_SHAREMODE_DENY_NONE. + */ + option_value.i = va_arg(ap, int); + context->share_mode = (smbc_share_mode) option_value.i; + + } else if (strcmp(option_name, "user_data") == 0) { + /* + * Save a user data handle which may be retrieved by the user + * with smbc_option_get() + */ + option_value.v = va_arg(ap, void *); + context->user_data = option_value.v; + } else if (strcmp(option_name, "smb_encrypt_level") == 0) { + /* + * Save an encoded value for encryption level. + * 0 = off, 1 = attempt, 2 = required. + */ + option_value.s = va_arg(ap, const char *); + if (strcmp(option_value.s, "none") == 0) { + context->smb_encryption_level = 0; + } else if (strcmp(option_value.s, "request") == 0) { + context->smb_encryption_level = 1; + } else if (strcmp(option_value.s, "require") == 0) { + context->smb_encryption_level = 2; + } + } else if (strcmp(option_name, "browse_max_lmb_count") == 0) { + /* + * From how many local master browsers should the list of + * workgroups be retrieved? It can take up to 12 minutes or + * longer after a server becomes a local master browser, for + * it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client + * never knows which local master browser will be found first, + * the one which is found first and used to retrieve a browse + * list may have an incomplete or empty browse list. By + * requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small + * networks (few workgroups), it is recommended that this + * value be set to 0, causing the browse lists from all found + * local master browsers to be retrieved and merged. For + * networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ + option_value.i = va_arg(ap, int); + context->browse_max_lmb_count = option_value.i; + + } else if (strcmp(option_name, "urlencode_readdir_entries") == 0) { + /* + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ + option_value.b = (bool) va_arg(ap, int); + context->urlencode_readdir_entries = option_value.b; + + } else if (strcmp(option_name, "one_share_per_server") == 0) { + /* + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ + option_value.b = (bool) va_arg(ap, int); + context->one_share_per_server = option_value.b; + + } else if (strcmp(option_name, "use_kerberos") == 0) { + option_value.b = (bool) va_arg(ap, int); + context->use_kerberos = option_value.b; + + } else if (strcmp(option_name, "fallback_after_kerberos") == 0) { + option_value.b = (bool) va_arg(ap, int); + context->fallback_after_kerberos = option_value.b; + + } else if (strcmp(option_name, "no_auto_anonymous_login") == 0) { + option_value.b = (bool) va_arg(ap, int); + context->no_auto_anonymous_login = option_value.b; + } + + va_end(ap); +} + + +/* + * Retrieve the current value of an option + */ +void * +smbc_option_get(SMBCCTX *context, + char *option_name) +{ + if (strcmp(option_name, "debug_stderr") == 0) { + /* + * Log to standard error instead of standard output. + */ +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) context->debug_stderr; +#else + return (void *) context->debug_stderr; +#endif + + } else if (strcmp(option_name, "full_time_names") == 0) { + /* + * Use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also + * setting/getting CREATE_TIME which was previously + * unimplemented. (Note that the old C_TIME was supposed to + * be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) context->full_time_names; +#else + return (void *) context->full_time_names; +#endif + + } else if (strcmp(option_name, "user_data") == 0) { + /* + * Return the user data handle which was saved by the user + * with smbc_option_set() + */ + return context->user_data; + + } else if (strcmp(option_name, "smb_encrypt_level") == 0) { + /* + * Return the current smb encrypt negotiate option as a string. + */ + switch (context->smb_encryption_level) { + case 0: + return (void *) "none"; + case 1: + return (void *) "request"; + case 2: + return (void *) "require"; + } + + } else if (strcmp(option_name, "smb_encrypt_on") == 0) { + /* + * Return the current smb encrypt status option as a bool. + * false = off, true = on. We don't know what server is + * being requested, so we only return true if all servers + * are using an encrypted connection. + */ + SMBCSRV *s; + unsigned int num_servers = 0; + + for (s = context->servers; s; s = s->next) { + num_servers++; + if (s->cli->trans_enc_state == NULL) { + return (void *)false; + } + } +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) (bool) (num_servers > 0); +#else + return (void *) (bool) (num_servers > 0); +#endif + + } else if (strcmp(option_name, "browse_max_lmb_count") == 0) { + /* + * From how many local master browsers should the list of + * workgroups be retrieved? It can take up to 12 minutes or + * longer after a server becomes a local master browser, for + * it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client + * never knows which local master browser will be found first, + * the one which is found first and used to retrieve a browse + * list may have an incomplete or empty browse list. By + * requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small + * networks (few workgroups), it is recommended that this + * value be set to 0, causing the browse lists from all found + * local master browsers to be retrieved and merged. For + * networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) context->browse_max_lmb_count; +#else + return (void *) context->browse_max_lmb_count; +#endif + + } else if (strcmp(option_name, "urlencode_readdir_entries") == 0) { + /* + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) context->urlencode_readdir_entries; +#else + return (void *) (bool) context->urlencode_readdir_entries; +#endif + + } else if (strcmp(option_name, "one_share_per_server") == 0) { + /* + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) context->one_share_per_server; +#else + return (void *) (bool) context->one_share_per_server; +#endif + + } else if (strcmp(option_name, "use_kerberos") == 0) { +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) context->use_kerberos; +#else + return (void *) (bool) context->use_kerberos; +#endif + + } else if (strcmp(option_name, "fallback_after_kerberos") == 0) { +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) context->fallback_after_kerberos; +#else + return (void *) (bool) context->fallback_after_kerberos; +#endif + + } else if (strcmp(option_name, "no_auto_anonymous_login") == 0) { +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) context->no_auto_anonymous_login; +#else + return (void *) (bool) context->no_auto_anonymous_login; +#endif + } + + return NULL; +} + + +/* + * Initialize the library, etc. + * + * We accept a struct containing handle information. + * valid values for info->debug from 0 to 100, + * and insist that info->fn must be non-null. + */ +SMBCCTX * +smbc_init_context(SMBCCTX *context) +{ + int pid; + char *user = NULL; + char *home = NULL; + extern bool in_client; + + if (!context) { + errno = EBADF; + return NULL; + } + + /* Do not initialise the same client twice */ + if (context->initialized) { + return 0; + } + + if (!context->server.get_auth_data_fn || + context->debug < 0 || + context->debug > 100) { + + errno = EINVAL; + return NULL; + + } + + if (!SMBC_initialized) { + /* + * Do some library-wide intializations the first time we get + * called + */ + bool conf_loaded = False; + TALLOC_CTX *frame = talloc_stackframe(); + + /* Set this to what the user wants */ + DEBUGLEVEL = context->debug; + + load_case_tables(); + + setup_logging("libsmbclient", True); + if (context->debug_stderr) { + dbf = x_stderr; + x_setbuf(x_stderr, NULL); + } + + /* Here we would open the smb.conf file if needed ... */ + + in_client = True; /* FIXME, make a param */ + + home = getenv("HOME"); + if (home) { + char *conf = NULL; + if (asprintf(&conf, "%s/.smb/smb.conf", home) > 0) { + if (lp_load(conf, True, False, False, True)) { + conf_loaded = True; + } else { + DEBUG(5, ("Could not load config file: %s\n", + conf)); + } + SAFE_FREE(conf); + } + } + + if (!conf_loaded) { + /* + * Well, if that failed, try the get_dyn_CONFIGFILE + * Which points to the standard locn, and if that + * fails, silently ignore it and use the internal + * defaults ... + */ + + if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, False)) { + DEBUG(5, ("Could not load config file: %s\n", + get_dyn_CONFIGFILE())); + } else if (home) { + char *conf; + /* + * We loaded the global config file. Now lets + * load user-specific modifications to the + * global config. + */ + if (asprintf(&conf, + "%s/.smb/smb.conf.append", + home) > 0) { + if (!lp_load(conf, True, False, False, False)) { + DEBUG(10, + ("Could not append config file: " + "%s\n", + conf)); + } + SAFE_FREE(conf); + } + } + } + + load_interfaces(); /* Load the list of interfaces ... */ + + reopen_logs(); /* Get logging working ... */ + + /* + * Block SIGPIPE (from lib/util_sock.c: write()) + * It is not needed and should not stop execution + */ + BlockSignals(True, SIGPIPE); + + /* Done with one-time initialisation */ + SMBC_initialized = 1; + + TALLOC_FREE(frame); + } + + if (!context->user) { + /* + * FIXME: Is this the best way to get the user info? + */ + user = getenv("USER"); + /* walk around as "guest" if no username can be found */ + if (!user) context->user = SMB_STRDUP("guest"); + else context->user = SMB_STRDUP(user); + } + + if (!context->netbios_name) { + /* + * We try to get our netbios name from the config. If that + * fails we fall back on constructing our netbios name from + * our hostname etc + */ + if (global_myname()) { + context->netbios_name = SMB_STRDUP(global_myname()); + } + else { + /* + * Hmmm, I want to get hostname as well, but I am too + * lazy for the moment + */ + pid = sys_getpid(); + context->netbios_name = (char *)SMB_MALLOC(17); + if (!context->netbios_name) { + errno = ENOMEM; + return NULL; + } + slprintf(context->netbios_name, 16, + "smbc%s%d", context->user, pid); + } + } + + DEBUG(1, ("Using netbios name %s.\n", context->netbios_name)); + + if (!context->workgroup) { + if (lp_workgroup()) { + context->workgroup = SMB_STRDUP(lp_workgroup()); + } + else { + /* TODO: Think about a decent default workgroup */ + context->workgroup = SMB_STRDUP("samba"); + } + } + + DEBUG(1, ("Using workgroup %s.\n", context->workgroup)); + + /* shortest timeout is 1 second */ + if (context->timeout > 0 && context->timeout < 1000) + context->timeout = 1000; + + /* + * FIXME: Should we check the function pointers here? + */ + + context->initialized = True; + + return context; +} + + +/* Return the verion of samba, and thus libsmbclient */ +const char * +smbc_version(void) +{ + return samba_version_string(); +} + + +/** Get the netbios name used for making connections */ +char * +smbc_getNetbiosName(SMBCCTX *c) +{ + return c->netbios_name; +} + +/** Set the netbios name used for making connections */ +void +smbc_setNetbiosName(SMBCCTX *c, char * netbios_name) +{ + c->netbios_name = netbios_name; +} + +/** Get the workgroup used for making connections */ +char * +smbc_getWorkgroup(SMBCCTX *c) +{ + return c->workgroup; +} + +/** Set the workgroup used for making connections */ +void +smbc_setWorkgroup(SMBCCTX *c, char * workgroup) +{ + c->workgroup = workgroup; +} + +/** Get the username used for making connections */ +char * +smbc_getUser(SMBCCTX *c) +{ + return c->user; +} + +/** Set the username used for making connections */ +void +smbc_setUser(SMBCCTX *c, char * user) +{ + c->user = user; +} + +/** Get the debug level */ +int +smbc_getDebug(SMBCCTX *c) +{ + return c->debug; +} + +/** Set the debug level */ +void +smbc_setDebug(SMBCCTX *c, int debug) +{ + c->debug = debug; +} + +/** + * Get the timeout used for waiting on connections and response data + * (in milliseconds) + */ +int +smbc_getTimeout(SMBCCTX *c) +{ + return c->timeout; +} + +/** + * Set the timeout used for waiting on connections and response data + * (in milliseconds) + */ +void +smbc_setTimeout(SMBCCTX *c, int timeout) +{ + c->timeout = timeout; +} + +/** Get the function for obtaining authentication data */ + +smbc_get_auth_data_fn +smbc_getFunctionAuthData(SMBCCTX *c) +{ + return c->server.get_auth_data_fn; +} + +/** Set the function for obtaining authentication data */ +void +smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn) +{ + c->server.get_auth_data_fn = fn; +} + +/** Get the function for checking if a server is still good */ +smbc_check_server_fn +smbc_getFunctionCheckServer(SMBCCTX *c) +{ + return c->server.check_server_fn; +} + +/** Set the function for checking if a server is still good */ +void +smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn) +{ + c->server.check_server_fn = fn; +} + +/** Get the function for removing a server if unused */ +smbc_remove_unused_server_fn +smbc_getFunctionRemoveUnusedServer(SMBCCTX *c) +{ + return c->server.remove_unused_server_fn; +} + +/** Set the function for removing a server if unused */ +void +smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, + smbc_remove_unused_server_fn fn) +{ + c->server.remove_unused_server_fn = fn; +} + +/** Get the function to store private data of the server cache */ +struct +smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c) +{ + return c->cache.server_cache_data; +} + +/** Set the function to store private data of the server cache */ +void +smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache) +{ + c->cache.server_cache_data = cache; +} + + +/** Get the function for adding a cached server */ +smbc_add_cached_srv_fn +smbc_getFunctionAddCachedServer(SMBCCTX *c) +{ + return c->cache.add_cached_server_fn; +} + +/** Set the function for adding a cached server */ +void +smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn) +{ + c->cache.add_cached_server_fn = fn; +} + +/** Get the function for server cache lookup */ +smbc_get_cached_srv_fn +smbc_getFunctionGetCachedServer(SMBCCTX *c) +{ + return c->cache.get_cached_server_fn; +} + +/** Set the function for server cache lookup */ +void +smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn) +{ + c->cache.get_cached_server_fn = fn; +} + +/** Get the function for server cache removal */ +smbc_remove_cached_srv_fn +smbc_getFunctionRemoveCachedServer(SMBCCTX *c) +{ + return c->cache.remove_cached_server_fn; +} + +/** Set the function for server cache removal */ +void +smbc_setFunctionRemoveCachedServer(SMBCCTX *c, + smbc_remove_cached_srv_fn fn) +{ + c->cache.remove_cached_server_fn = fn; +} + +/** + * Get the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +smbc_purge_cached_srv_fn +smbc_getFunctionPurgeCachedServers(SMBCCTX *c) +{ + return c->cache.purge_cached_server_fn; +} + +/** + * Set the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +void +smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_srv_fn fn) +{ + c->cache.purge_cached_server_fn = fn; +} + +/** + * Callable functions for files. + */ + +smbc_open_fn +smbc_getFunctionOpen(SMBCCTX *c) +{ + return c->posix_emu.open_fn; +} + +void +smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn) +{ + c->posix_emu.open_fn = fn; +} + +smbc_creat_fn +smbc_getFunctionCreat(SMBCCTX *c) +{ + return c->posix_emu.creat_fn; +} + +void +smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn fn) +{ + c->posix_emu.creat_fn = fn; +} + +smbc_read_fn +smbc_getFunctionRead(SMBCCTX *c) +{ + return c->posix_emu.read_fn; +} + +void +smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn) +{ + c->posix_emu.read_fn = fn; +} + +smbc_write_fn +smbc_getFunctionWrite(SMBCCTX *c) +{ + return c->posix_emu.write_fn; +} + +void +smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn) +{ + c->posix_emu.write_fn = fn; +} + +smbc_unlink_fn +smbc_getFunctionUnlink(SMBCCTX *c) +{ + return c->posix_emu.unlink_fn; +} + +void +smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn) +{ + c->posix_emu.unlink_fn = fn; +} + +smbc_rename_fn +smbc_getFunctionRename(SMBCCTX *c) +{ + return c->posix_emu.rename_fn; +} + +void +smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn) +{ + c->posix_emu.rename_fn = fn; +} + +smbc_lseek_fn +smbc_getFunctionLseek(SMBCCTX *c) +{ + return c->posix_emu.lseek_fn; +} + +void +smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn) +{ + c->posix_emu.lseek_fn = fn; +} + +smbc_stat_fn +smbc_getFunctionStat(SMBCCTX *c) +{ + return c->posix_emu.stat_fn; +} + +void +smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn) +{ + c->posix_emu.stat_fn = fn; +} + +smbc_fstat_fn +smbc_getFunctionFstat(SMBCCTX *c) +{ + return c->posix_emu.fstat_fn; +} + +void +smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn) +{ + c->posix_emu.fstat_fn = fn; +} + +smbc_ftruncate_fn +smbc_getFunctionFtruncate(SMBCCTX *c) +{ + return c->posix_emu.ftruncate_fn; +} + +void +smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn) +{ + c->posix_emu.ftruncate_fn = fn; +} + +smbc_close_fn +smbc_getFunctionClose(SMBCCTX *c) +{ + return c->posix_emu.close_fn; +} + +void +smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn) +{ + c->posix_emu.close_fn = fn; +} + + +/** + * Callable functions for directories. + */ + +smbc_opendir_fn +smbc_getFunctionOpendir(SMBCCTX *c) +{ + return c->posix_emu.opendir_fn; +} + +void +smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn) +{ + c->posix_emu.opendir_fn = fn; +} + +smbc_closedir_fn +smbc_getFunctionClosedir(SMBCCTX *c) +{ + return c->posix_emu.closedir_fn; +} + +void +smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn) +{ + c->posix_emu.closedir_fn = fn; +} + +smbc_readdir_fn +smbc_getFunctionReaddir(SMBCCTX *c) +{ + return c->posix_emu.readdir_fn; +} + +void +smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn) +{ + c->posix_emu.readdir_fn = fn; +} + +smbc_getdents_fn +smbc_getFunctionGetdents(SMBCCTX *c) +{ + return c->posix_emu.getdents_fn; +} + +void +smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn) +{ + c->posix_emu.getdents_fn = fn; +} + +smbc_mkdir_fn +smbc_getFunctionMkdir(SMBCCTX *c) +{ + return c->posix_emu.mkdir_fn; +} + +void +smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn) +{ + c->posix_emu.mkdir_fn = fn; +} + +smbc_rmdir_fn +smbc_getFunctionRmdir(SMBCCTX *c) +{ + return c->posix_emu.rmdir_fn; +} + +void +smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn) +{ + c->posix_emu.rmdir_fn = fn; +} + +smbc_telldir_fn +smbc_getFunctionTelldir(SMBCCTX *c) +{ + return c->posix_emu.telldir_fn; +} + +void +smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn) +{ + c->posix_emu.telldir_fn = fn; +} + +smbc_lseekdir_fn +smbc_getFunctionLseekdir(SMBCCTX *c) +{ + return c->posix_emu.lseekdir_fn; +} + +void +smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn) +{ + c->posix_emu.lseekdir_fn = fn; +} + +smbc_fstatdir_fn +smbc_getFunctionFstatdir(SMBCCTX *c) +{ + return c->posix_emu.fstatdir_fn; +} + +void +smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn) +{ + c->posix_emu.fstatdir_fn = fn; +} + + +/** + * Callable functions applicable to both files and directories. + */ + +smbc_chmod_fn +smbc_getFunctionChmod(SMBCCTX *c) +{ + return c->posix_emu.chmod_fn; +} + +void +smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn) +{ + c->posix_emu.chmod_fn = fn; +} + +smbc_utimes_fn +smbc_getFunctionUtimes(SMBCCTX *c) +{ + return c->posix_emu.utimes_fn; +} + +void +smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn) +{ + c->posix_emu.utimes_fn = fn; +} + +smbc_setxattr_fn +smbc_getFunctionSetxattr(SMBCCTX *c) +{ + return c->posix_emu.setxattr_fn; +} + +void +smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn) +{ + c->posix_emu.setxattr_fn = fn; +} + +smbc_getxattr_fn +smbc_getFunctionGetxattr(SMBCCTX *c) +{ + return c->posix_emu.getxattr_fn; +} + +void +smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn) +{ + c->posix_emu.getxattr_fn = fn; +} + +smbc_removexattr_fn +smbc_getFunctionRemovexattr(SMBCCTX *c) +{ + return c->posix_emu.removexattr_fn; +} + +void +smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn) +{ + c->posix_emu.removexattr_fn = fn; +} + +smbc_listxattr_fn +smbc_getFunctionListxattr(SMBCCTX *c) +{ + return c->posix_emu.listxattr_fn; +} + +void +smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn) +{ + c->posix_emu.listxattr_fn = fn; +} + + +/** + * Callable functions related to printing + */ + +smbc_print_file_fn +smbc_getFunctionPrintFile(SMBCCTX *c) +{ + return c->printing.print_file_fn; +} + +void +smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn) +{ + c->printing.print_file_fn = fn; +} + +smbc_open_print_job_fn +smbc_getFunctionOpenPrintJob(SMBCCTX *c) +{ + return c->printing.open_print_job_fn; +} + +void +smbc_setFunctionOpenPrintJob(SMBCCTX *c, + smbc_open_print_job_fn fn) +{ + c->printing.open_print_job_fn = fn; +} + +smbc_list_print_jobs_fn +smbc_getFunctionListPrintJobs(SMBCCTX *c) +{ + return c->printing.list_print_jobs_fn; +} + +void +smbc_setFunctionListPrintJobs(SMBCCTX *c, + smbc_list_print_jobs_fn fn) +{ + c->printing.list_print_jobs_fn = fn; +} + +smbc_unlink_print_job_fn +smbc_getFunctionUnlinkPrintJob(SMBCCTX *c) +{ + return c->printing.unlink_print_job_fn; +} + +void +smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, + smbc_unlink_print_job_fn fn) +{ + c->printing.unlink_print_job_fn = fn; +} + diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c new file mode 100644 index 0000000000..9cb3351433 --- /dev/null +++ b/source3/libsmb/libsmb_dir.c @@ -0,0 +1,1928 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* + * Routine to open a directory + * We accept the URL syntax explained in SMBC_parse_path(), above. + */ + +static void +remove_dir(SMBCFILE *dir) +{ + struct smbc_dir_list *d,*f; + + d = dir->dir_list; + while (d) { + + f = d; d = d->next; + + SAFE_FREE(f->dirent); + SAFE_FREE(f); + + } + + dir->dir_list = dir->dir_end = dir->dir_next = NULL; + +} + +static int +add_dirent(SMBCFILE *dir, + const char *name, + const char *comment, + uint32 type) +{ + struct smbc_dirent *dirent; + int size; + int name_length = (name == NULL ? 0 : strlen(name)); + int comment_len = (comment == NULL ? 0 : strlen(comment)); + + /* + * Allocate space for the dirent, which must be increased by the + * size of the name and the comment and 1 each for the null terminator. + */ + + size = sizeof(struct smbc_dirent) + name_length + comment_len + 2; + + dirent = (struct smbc_dirent *)SMB_MALLOC(size); + + if (!dirent) { + + dir->dir_error = ENOMEM; + return -1; + + } + + ZERO_STRUCTP(dirent); + + if (dir->dir_list == NULL) { + + dir->dir_list = SMB_MALLOC_P(struct smbc_dir_list); + if (!dir->dir_list) { + + SAFE_FREE(dirent); + dir->dir_error = ENOMEM; + return -1; + + } + ZERO_STRUCTP(dir->dir_list); + + dir->dir_end = dir->dir_next = dir->dir_list; + } + else { + + dir->dir_end->next = SMB_MALLOC_P(struct smbc_dir_list); + + if (!dir->dir_end->next) { + + SAFE_FREE(dirent); + dir->dir_error = ENOMEM; + return -1; + + } + ZERO_STRUCTP(dir->dir_end->next); + + dir->dir_end = dir->dir_end->next; + } + + dir->dir_end->next = NULL; + dir->dir_end->dirent = dirent; + + dirent->smbc_type = type; + dirent->namelen = name_length; + dirent->commentlen = comment_len; + dirent->dirlen = size; + + /* + * dirent->namelen + 1 includes the null (no null termination needed) + * Ditto for dirent->commentlen. + * The space for the two null bytes was allocated. + */ + strncpy(dirent->name, (name?name:""), dirent->namelen + 1); + dirent->comment = (char *)(&dirent->name + dirent->namelen + 1); + strncpy(dirent->comment, (comment?comment:""), dirent->commentlen + 1); + + return 0; + +} + +static void +list_unique_wg_fn(const char *name, + uint32 type, + const char *comment, + void *state) +{ + SMBCFILE *dir = (SMBCFILE *)state; + struct smbc_dir_list *dir_list; + struct smbc_dirent *dirent; + int dirent_type; + int do_remove = 0; + + dirent_type = dir->dir_type; + + if (add_dirent(dir, name, comment, dirent_type) < 0) { + + /* An error occurred, what do we do? */ + /* FIXME: Add some code here */ + } + + /* Point to the one just added */ + dirent = dir->dir_end->dirent; + + /* See if this was a duplicate */ + for (dir_list = dir->dir_list; + dir_list != dir->dir_end; + dir_list = dir_list->next) { + if (! do_remove && + strcmp(dir_list->dirent->name, dirent->name) == 0) { + /* Duplicate. End end of list need to be removed. */ + do_remove = 1; + } + + if (do_remove && dir_list->next == dir->dir_end) { + /* Found the end of the list. Remove it. */ + dir->dir_end = dir_list; + free(dir_list->next); + free(dirent); + dir_list->next = NULL; + break; + } + } +} + +static void +list_fn(const char *name, + uint32 type, + const char *comment, + void *state) +{ + SMBCFILE *dir = (SMBCFILE *)state; + int dirent_type; + + /* + * We need to process the type a little ... + * + * Disk share = 0x00000000 + * Print share = 0x00000001 + * Comms share = 0x00000002 (obsolete?) + * IPC$ share = 0x00000003 + * + * administrative shares: + * ADMIN$, IPC$, C$, D$, E$ ... are type |= 0x80000000 + */ + + if (dir->dir_type == SMBC_FILE_SHARE) { + switch (type) { + case 0 | 0x80000000: + case 0: + dirent_type = SMBC_FILE_SHARE; + break; + + case 1: + dirent_type = SMBC_PRINTER_SHARE; + break; + + case 2: + dirent_type = SMBC_COMMS_SHARE; + break; + + case 3 | 0x80000000: + case 3: + dirent_type = SMBC_IPC_SHARE; + break; + + default: + dirent_type = SMBC_FILE_SHARE; /* FIXME, error? */ + break; + } + } + else { + dirent_type = dir->dir_type; + } + + if (add_dirent(dir, name, comment, dirent_type) < 0) { + + /* An error occurred, what do we do? */ + /* FIXME: Add some code here */ + + } +} + +static void +dir_list_fn(const char *mnt, + file_info *finfo, + const char *mask, + void *state) +{ + + if (add_dirent((SMBCFILE *)state, finfo->name, "", + (finfo->mode&aDIR?SMBC_DIR:SMBC_FILE)) < 0) { + + /* Handle an error ... */ + + /* FIXME: Add some code ... */ + + } + +} + +static int +net_share_enum_rpc(struct cli_state *cli, + void (*fn)(const char *name, + uint32 type, + const char *comment, + void *state), + void *state) +{ + int i; + WERROR result; + ENUM_HND enum_hnd; + uint32 info_level = 1; + uint32 preferred_len = 0xffffffff; + uint32 type; + SRV_SHARE_INFO_CTR ctr; + fstring name = ""; + fstring comment = ""; + struct rpc_pipe_client *pipe_hnd; + NTSTATUS nt_status; + + /* Open the server service pipe */ + pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &nt_status); + if (!pipe_hnd) { + DEBUG(1, ("net_share_enum_rpc pipe open fail!\n")); + return -1; + } + + /* Issue the NetShareEnum RPC call and retrieve the response */ + init_enum_hnd(&enum_hnd, 0); + result = rpccli_srvsvc_net_share_enum(pipe_hnd, + talloc_tos(), + info_level, + &ctr, + preferred_len, + &enum_hnd); + + /* Was it successful? */ + if (!W_ERROR_IS_OK(result) || ctr.num_entries == 0) { + /* Nope. Go clean up. */ + goto done; + } + + /* For each returned entry... */ + for (i = 0; i < ctr.num_entries; i++) { + + /* pull out the share name */ + rpcstr_pull_unistr2_fstring( + name, &ctr.share.info1[i].info_1_str.uni_netname); + + /* pull out the share's comment */ + rpcstr_pull_unistr2_fstring( + comment, &ctr.share.info1[i].info_1_str.uni_remark); + + /* Get the type value */ + type = ctr.share.info1[i].info_1.type; + + /* Add this share to the list */ + (*fn)(name, type, comment, state); + } + +done: + /* Close the server service pipe */ + cli_rpc_pipe_close(pipe_hnd); + + /* Tell 'em if it worked */ + return W_ERROR_IS_OK(result) ? 0 : -1; +} + + +/* + * Verify that the options specified in a URL are valid + */ +int +SMBC_check_options(char *server, + char *share, + char *path, + char *options) +{ + DEBUG(4, ("SMBC_check_options(): server='%s' share='%s' " + "path='%s' options='%s'\n", + server, share, path, options)); + + /* No options at all is always ok */ + if (! *options) return 0; + + /* Currently, we don't support any options. */ + return -1; +} + + +SMBCFILE * +SMBC_opendir_ctx(SMBCCTX *context, + const char *fname) +{ + int saved_errno; + char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *options = NULL; + char *workgroup = NULL; + char *path = NULL; + uint16 mode; + char *p = NULL; + SMBCSRV *srv = NULL; + SMBCFILE *dir = NULL; + struct sockaddr_storage rem_ss; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + DEBUG(4, ("no valid context\n")); + errno = EINVAL + 8192; + TALLOC_FREE(frame); + return NULL; + + } + + if (!fname) { + DEBUG(4, ("no valid fname\n")); + errno = EINVAL + 8193; + TALLOC_FREE(frame); + return NULL; + } + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + &options)) { + DEBUG(4, ("no valid path\n")); + errno = EINVAL + 8194; + TALLOC_FREE(frame); + return NULL; + } + + DEBUG(4, ("parsed path: fname='%s' server='%s' share='%s' " + "path='%s' options='%s'\n", + fname, server, share, path, options)); + + /* Ensure the options are valid */ + if (SMBC_check_options(server, share, path, options)) { + DEBUG(4, ("unacceptable options (%s)\n", options)); + errno = EINVAL + 8195; + TALLOC_FREE(frame); + return NULL; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return NULL; + } + } + + dir = SMB_MALLOC_P(SMBCFILE); + + if (!dir) { + errno = ENOMEM; + TALLOC_FREE(frame); + return NULL; + } + + ZERO_STRUCTP(dir); + + dir->cli_fd = 0; + dir->fname = SMB_STRDUP(fname); + dir->srv = NULL; + dir->offset = 0; + dir->file = False; + dir->dir_list = dir->dir_next = dir->dir_end = NULL; + + if (server[0] == (char)0) { + + int i; + int count; + int max_lmb_count; + struct ip_service *ip_list; + struct ip_service server_addr; + struct user_auth_info u_info; + + if (share[0] != (char)0 || path[0] != (char)0) { + + errno = EINVAL + 8196; + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + } + + /* Determine how many local master browsers to query */ + max_lmb_count = (context->browse_max_lmb_count == 0 + ? INT_MAX + : context->browse_max_lmb_count); + + memset(&u_info, '\0', sizeof(u_info)); + u_info.username = talloc_strdup(frame,user); + u_info.password = talloc_strdup(frame,password); + if (!u_info.username || !u_info.password) { + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + } + + /* + * We have server and share and path empty but options + * requesting that we scan all master browsers for their list + * of workgroups/domains. This implies that we must first try + * broadcast queries to find all master browsers, and if that + * doesn't work, then try our other methods which return only + * a single master browser. + */ + + ip_list = NULL; + if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list, + &count))) + { + + SAFE_FREE(ip_list); + + if (!find_master_ip(workgroup, &server_addr.ss)) { + + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + errno = ENOENT; + TALLOC_FREE(frame); + return NULL; + } + + ip_list = (struct ip_service *)memdup( + &server_addr, sizeof(server_addr)); + if (ip_list == NULL) { + errno = ENOMEM; + TALLOC_FREE(frame); + return NULL; + } + count = 1; + } + + for (i = 0; i < count && i < max_lmb_count; i++) { + char addr[INET6_ADDRSTRLEN]; + char *wg_ptr = NULL; + struct cli_state *cli = NULL; + + print_sockaddr(addr, sizeof(addr), &ip_list[i].ss); + DEBUG(99, ("Found master browser %d of %d: %s\n", + i+1, MAX(count, max_lmb_count), + addr)); + + cli = get_ipc_connect_master_ip(talloc_tos(), + &ip_list[i], + &u_info, + &wg_ptr); + /* cli == NULL is the master browser refused to talk or + could not be found */ + if (!cli) { + continue; + } + + workgroup = talloc_strdup(frame, wg_ptr); + server = talloc_strdup(frame, cli->desthost); + + cli_shutdown(cli); + + if (!workgroup || !server) { + errno = ENOMEM; + TALLOC_FREE(frame); + return NULL; + } + + DEBUG(4, ("using workgroup %s %s\n", + workgroup, server)); + + /* + * For each returned master browser IP address, get a + * connection to IPC$ on the server if we do not + * already have one, and determine the + * workgroups/domains that it knows about. + */ + + srv = SMBC_server(frame, context, True, server, "IPC$", + &workgroup, &user, &password); + if (!srv) { + continue; + } + + dir->srv = srv; + dir->dir_type = SMBC_WORKGROUP; + + /* Now, list the stuff ... */ + + if (!cli_NetServerEnum(srv->cli, + workgroup, + SV_TYPE_DOMAIN_ENUM, + list_unique_wg_fn, + (void *)dir)) { + continue; + } + } + + SAFE_FREE(ip_list); + } else { + /* + * Server not an empty string ... Check the rest and see what + * gives + */ + if (*share == '\0') { + if (*path != '\0') { + + /* Should not have empty share with path */ + errno = EINVAL + 8197; + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + + } + + /* + * We don't know if is really a server name + * or is a workgroup/domain name. If we already have + * a server structure for it, we'll use it. + * Otherwise, check to see if <1D>, + * <1B>, or <20> translates. We check + * to see if is an IP address first. + */ + + /* + * See if we have an existing server. Do not + * establish a connection if one does not already + * exist. + */ + srv = SMBC_server(frame, context, False, server, "IPC$", + &workgroup, &user, &password); + + /* + * If no existing server and not an IP addr, look for + * LMB or DMB + */ + if (!srv && + !is_ipaddress(server) && + (resolve_name(server, &rem_ss, 0x1d) || /* LMB */ + resolve_name(server, &rem_ss, 0x1b) )) { /* DMB */ + + fstring buserver; + + dir->dir_type = SMBC_SERVER; + + /* + * Get the backup list ... + */ + if (!name_status_find(server, 0, 0, + &rem_ss, buserver)) { + + DEBUG(0, ("Could not get name of " + "local/domain master browser " + "for server %s\n", server)); + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + errno = EPERM; + TALLOC_FREE(frame); + return NULL; + + } + + /* + * Get a connection to IPC$ on the server if + * we do not already have one + */ + srv = SMBC_server(frame, context, True, + buserver, "IPC$", + &workgroup, &user, &password); + if (!srv) { + DEBUG(0, ("got no contact to IPC$\n")); + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + + } + + dir->srv = srv; + + /* Now, list the servers ... */ + if (!cli_NetServerEnum(srv->cli, server, + 0x0000FFFE, list_fn, + (void *)dir)) { + + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + } + } else if (srv || + (resolve_name(server, &rem_ss, 0x20))) { + + /* If we hadn't found the server, get one now */ + if (!srv) { + srv = SMBC_server(frame, context, True, + server, "IPC$", + &workgroup, + &user, &password); + } + + if (!srv) { + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + + } + + dir->dir_type = SMBC_FILE_SHARE; + dir->srv = srv; + + /* List the shares ... */ + + if (net_share_enum_rpc( + srv->cli, + list_fn, + (void *) dir) < 0 && + cli_RNetShareEnum( + srv->cli, + list_fn, + (void *)dir) < 0) { + + errno = cli_errno(srv->cli); + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + + } + } else { + /* Neither the workgroup nor server exists */ + errno = ECONNREFUSED; + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + } + + } + else { + /* + * The server and share are specified ... work from + * there ... + */ + char *targetpath; + struct cli_state *targetcli; + + /* We connect to the server and list the directory */ + dir->dir_type = SMBC_FILE_SHARE; + + srv = SMBC_server(frame, context, True, server, share, + &workgroup, &user, &password); + + if (!srv) { + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + } + + dir->srv = srv; + + /* Now, list the files ... */ + + p = path + strlen(path); + path = talloc_asprintf_append(path, "\\*"); + if (!path) { + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + } + + if (!cli_resolve_path(frame, "", srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + TALLOC_FREE(frame); + return NULL; + } + + if (cli_list(targetcli, targetpath, + aDIR | aSYSTEM | aHIDDEN, + dir_list_fn, (void *)dir) < 0) { + + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + saved_errno = SMBC_errno(context, targetcli); + + if (saved_errno == EINVAL) { + /* + * See if they asked to opendir something + * other than a directory. If so, the + * converted error value we got would have + * been EINVAL rather than ENOTDIR. + */ + *p = '\0'; /* restore original path */ + + if (SMBC_getatr(context, srv, path, + &mode, NULL, + NULL, NULL, NULL, NULL, + NULL) && + ! IS_DOS_DIR(mode)) { + + /* It is. Correct the error value */ + saved_errno = ENOTDIR; + } + } + + /* + * If there was an error and the server is no + * good any more... + */ + if (cli_is_error(targetcli) && + (context->server.check_server_fn)(context, srv)) { + + /* ... then remove it. */ + if ((context->server.remove_unused_server_fn)(context, + srv)) { + /* + * We could not remove the + * server completely, remove + * it from the cache so we + * will not get it again. It + * will be removed when the + * last file/dir is closed. + */ + (context->cache.remove_cached_server_fn)(context, srv); + } + } + + errno = saved_errno; + TALLOC_FREE(frame); + return NULL; + } + } + + } + + DLIST_ADD(context->files, dir); + TALLOC_FREE(frame); + return dir; + +} + +/* + * Routine to close a directory + */ + +int +SMBC_closedir_ctx(SMBCCTX *context, + SMBCFILE *dir) +{ + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!dir || !SMBC_dlist_contains(context->files, dir)) { + errno = EBADF; + TALLOC_FREE(frame); + return -1; + } + + remove_dir(dir); /* Clean it up */ + + DLIST_REMOVE(context->files, dir); + + if (dir) { + + SAFE_FREE(dir->fname); + SAFE_FREE(dir); /* Free the space too */ + } + + TALLOC_FREE(frame); + return 0; + +} + +static void +smbc_readdir_internal(SMBCCTX * context, + struct smbc_dirent *dest, + struct smbc_dirent *src, + int max_namebuf_len) +{ + if (context->urlencode_readdir_entries) { + + /* url-encode the name. get back remaining buffer space */ + max_namebuf_len = + SMBC_urlencode(dest->name, src->name, max_namebuf_len); + + /* We now know the name length */ + dest->namelen = strlen(dest->name); + + /* Save the pointer to the beginning of the comment */ + dest->comment = dest->name + dest->namelen + 1; + + /* Copy the comment */ + strncpy(dest->comment, src->comment, max_namebuf_len - 1); + dest->comment[max_namebuf_len - 1] = '\0'; + + /* Save other fields */ + dest->smbc_type = src->smbc_type; + dest->commentlen = strlen(dest->comment); + dest->dirlen = ((dest->comment + dest->commentlen + 1) - + (char *) dest); + } else { + + /* No encoding. Just copy the entry as is. */ + memcpy(dest, src, src->dirlen); + dest->comment = (char *)(&dest->name + src->namelen + 1); + } + +} + +/* + * Routine to get a directory entry + */ + +struct smbc_dirent * +SMBC_readdir_ctx(SMBCCTX *context, + SMBCFILE *dir) +{ + int maxlen; + struct smbc_dirent *dirp, *dirent; + TALLOC_CTX *frame = talloc_stackframe(); + + /* Check that all is ok first ... */ + + if (!context || !context->initialized) { + + errno = EINVAL; + DEBUG(0, ("Invalid context in SMBC_readdir_ctx()\n")); + TALLOC_FREE(frame); + return NULL; + + } + + if (!dir || !SMBC_dlist_contains(context->files, dir)) { + + errno = EBADF; + DEBUG(0, ("Invalid dir in SMBC_readdir_ctx()\n")); + TALLOC_FREE(frame); + return NULL; + + } + + if (dir->file != False) { /* FIXME, should be dir, perhaps */ + + errno = ENOTDIR; + DEBUG(0, ("Found file vs directory in SMBC_readdir_ctx()\n")); + TALLOC_FREE(frame); + return NULL; + + } + + if (!dir->dir_next) { + TALLOC_FREE(frame); + return NULL; + } + + dirent = dir->dir_next->dirent; + if (!dirent) { + + errno = ENOENT; + TALLOC_FREE(frame); + return NULL; + + } + + dirp = (struct smbc_dirent *)context->dirent; + maxlen = (sizeof(context->dirent) - + sizeof(struct smbc_dirent)); + + smbc_readdir_internal(context, dirp, dirent, maxlen); + + dir->dir_next = dir->dir_next->next; + + TALLOC_FREE(frame); + return dirp; +} + +/* + * Routine to get directory entries + */ + +int +SMBC_getdents_ctx(SMBCCTX *context, + SMBCFILE *dir, + struct smbc_dirent *dirp, + int count) +{ + int rem = count; + int reqd; + int maxlen; + char *ndir = (char *)dirp; + struct smbc_dir_list *dirlist; + TALLOC_CTX *frame = talloc_stackframe(); + + /* Check that all is ok first ... */ + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + if (!dir || !SMBC_dlist_contains(context->files, dir)) { + + errno = EBADF; + TALLOC_FREE(frame); + return -1; + + } + + if (dir->file != False) { /* FIXME, should be dir, perhaps */ + + errno = ENOTDIR; + TALLOC_FREE(frame); + return -1; + + } + + /* + * Now, retrieve the number of entries that will fit in what was passed + * We have to figure out if the info is in the list, or we need to + * send a request to the server to get the info. + */ + + while ((dirlist = dir->dir_next)) { + struct smbc_dirent *dirent; + + if (!dirlist->dirent) { + + errno = ENOENT; /* Bad error */ + TALLOC_FREE(frame); + return -1; + + } + + /* Do urlencoding of next entry, if so selected */ + dirent = (struct smbc_dirent *)context->dirent; + maxlen = (sizeof(context->dirent) - + sizeof(struct smbc_dirent)); + smbc_readdir_internal(context, dirent, dirlist->dirent, maxlen); + + reqd = dirent->dirlen; + + if (rem < reqd) { + + if (rem < count) { /* We managed to copy something */ + + errno = 0; + TALLOC_FREE(frame); + return count - rem; + + } + else { /* Nothing copied ... */ + + errno = EINVAL; /* Not enough space ... */ + TALLOC_FREE(frame); + return -1; + + } + + } + + memcpy(ndir, dirent, reqd); /* Copy the data in ... */ + + ((struct smbc_dirent *)ndir)->comment = + (char *)(&((struct smbc_dirent *)ndir)->name + + dirent->namelen + + 1); + + ndir += reqd; + + rem -= reqd; + + dir->dir_next = dirlist = dirlist -> next; + } + + TALLOC_FREE(frame); + + if (rem == count) + return 0; + else + return count - rem; + +} + +/* + * Routine to create a directory ... + */ + +int +SMBC_mkdir_ctx(SMBCCTX *context, + const char *fname, + mode_t mode) +{ + SMBCSRV *srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_mkdir(%s)\n", fname)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + + } + + /*d_printf(">>>mkdir: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>mkdir: resolved path as %s\n", targetpath);*/ + + if (!cli_mkdir(targetcli, targetpath)) { + + errno = SMBC_errno(context, targetcli); + TALLOC_FREE(frame); + return -1; + + } + + TALLOC_FREE(frame); + return 0; + +} + +/* + * Our list function simply checks to see if a directory is not empty + */ + +static int smbc_rmdir_dirempty = True; + +static void +rmdir_list_fn(const char *mnt, + file_info *finfo, + const char *mask, + void *state) +{ + if (strncmp(finfo->name, ".", 1) != 0 && + strncmp(finfo->name, "..", 2) != 0) { + smbc_rmdir_dirempty = False; + } +} + +/* + * Routine to remove a directory + */ + +int +SMBC_rmdir_ctx(SMBCCTX *context, + const char *fname) +{ + SMBCSRV *srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_rmdir(%s)\n", fname)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + + } + + /*d_printf(">>>rmdir: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>rmdir: resolved path as %s\n", targetpath);*/ + + + if (!cli_rmdir(targetcli, targetpath)) { + + errno = SMBC_errno(context, targetcli); + + if (errno == EACCES) { /* Check if the dir empty or not */ + + /* Local storage to avoid buffer overflows */ + char *lpath; + + smbc_rmdir_dirempty = True; /* Make this so ... */ + + lpath = talloc_asprintf(frame, "%s\\*", + targetpath); + if (!lpath) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + + if (cli_list(targetcli, lpath, + aDIR | aSYSTEM | aHIDDEN, + rmdir_list_fn, NULL) < 0) { + + /* Fix errno to ignore latest error ... */ + DEBUG(5, ("smbc_rmdir: " + "cli_list returned an error: %d\n", + SMBC_errno(context, targetcli))); + errno = EACCES; + + } + + if (smbc_rmdir_dirempty) + errno = EACCES; + else + errno = ENOTEMPTY; + + } + + TALLOC_FREE(frame); + return -1; + + } + + TALLOC_FREE(frame); + return 0; + +} + +/* + * Routine to return the current directory position + */ + +off_t +SMBC_telldir_ctx(SMBCCTX *context, + SMBCFILE *dir) +{ + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + if (!dir || !SMBC_dlist_contains(context->files, dir)) { + + errno = EBADF; + TALLOC_FREE(frame); + return -1; + + } + + if (dir->file != False) { /* FIXME, should be dir, perhaps */ + + errno = ENOTDIR; + TALLOC_FREE(frame); + return -1; + + } + + /* See if we're already at the end. */ + if (dir->dir_next == NULL) { + /* We are. */ + TALLOC_FREE(frame); + return -1; + } + + /* + * We return the pointer here as the offset + */ + TALLOC_FREE(frame); + return (off_t)(long)dir->dir_next->dirent; +} + +/* + * A routine to run down the list and see if the entry is OK + */ + +static struct smbc_dir_list * +check_dir_ent(struct smbc_dir_list *list, + struct smbc_dirent *dirent) +{ + + /* Run down the list looking for what we want */ + + if (dirent) { + + struct smbc_dir_list *tmp = list; + + while (tmp) { + + if (tmp->dirent == dirent) + return tmp; + + tmp = tmp->next; + + } + + } + + return NULL; /* Not found, or an error */ + +} + + +/* + * Routine to seek on a directory + */ + +int +SMBC_lseekdir_ctx(SMBCCTX *context, + SMBCFILE *dir, + off_t offset) +{ + long int l_offset = offset; /* Handle problems of size */ + struct smbc_dirent *dirent = (struct smbc_dirent *)l_offset; + struct smbc_dir_list *list_ent = (struct smbc_dir_list *)NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + if (dir->file != False) { /* FIXME, should be dir, perhaps */ + + errno = ENOTDIR; + TALLOC_FREE(frame); + return -1; + + } + + /* Now, check what we were passed and see if it is OK ... */ + + if (dirent == NULL) { /* Seek to the begining of the list */ + + dir->dir_next = dir->dir_list; + TALLOC_FREE(frame); + return 0; + + } + + if (offset == -1) { /* Seek to the end of the list */ + dir->dir_next = NULL; + TALLOC_FREE(frame); + return 0; + } + + /* Now, run down the list and make sure that the entry is OK */ + /* This may need to be changed if we change the format of the list */ + + if ((list_ent = check_dir_ent(dir->dir_list, dirent)) == NULL) { + errno = EINVAL; /* Bad entry */ + TALLOC_FREE(frame); + return -1; + } + + dir->dir_next = list_ent; + + TALLOC_FREE(frame); + return 0; +} + +/* + * Routine to fstat a dir + */ + +int +SMBC_fstatdir_ctx(SMBCCTX *context, + SMBCFILE *dir, + struct stat *st) +{ + + if (!context || !context->initialized) { + + errno = EINVAL; + return -1; + } + + /* No code yet ... */ + return 0; +} + +int +SMBC_chmod_ctx(SMBCCTX *context, + const char *fname, + mode_t newmode) +{ + SMBCSRV *srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + uint16 mode; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_chmod(%s, 0%3o)\n", fname, newmode)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + } + + mode = 0; + + if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= aRONLY; + if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH; + if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM; + if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN; + + if (!cli_setatr(srv->cli, path, mode, 0)) { + errno = SMBC_errno(context, srv->cli); + TALLOC_FREE(frame); + return -1; + } + + TALLOC_FREE(frame); + return 0; +} + +int +SMBC_utimes_ctx(SMBCCTX *context, + const char *fname, + struct timeval *tbuf) +{ + SMBCSRV *srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + time_t access_time; + time_t write_time; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (tbuf == NULL) { + access_time = write_time = time(NULL); + } else { + access_time = tbuf[0].tv_sec; + write_time = tbuf[1].tv_sec; + } + + if (DEBUGLVL(4)) { + char *p; + char atimebuf[32]; + char mtimebuf[32]; + + strncpy(atimebuf, ctime(&access_time), sizeof(atimebuf) - 1); + atimebuf[sizeof(atimebuf) - 1] = '\0'; + if ((p = strchr(atimebuf, '\n')) != NULL) { + *p = '\0'; + } + + strncpy(mtimebuf, ctime(&write_time), sizeof(mtimebuf) - 1); + mtimebuf[sizeof(mtimebuf) - 1] = '\0'; + if ((p = strchr(mtimebuf, '\n')) != NULL) { + *p = '\0'; + } + + dbgtext("smbc_utimes(%s, atime = %s mtime = %s)\n", + fname, atimebuf, mtimebuf); + } + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + } + + if (!SMBC_setatr(context, srv, path, + 0, access_time, write_time, 0, 0)) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_setatr */ + } + + TALLOC_FREE(frame); + return 0; +} + +/* + * Routine to unlink() a file + */ + +int +SMBC_unlink_ctx(SMBCCTX *context, + const char *fname) +{ + char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *workgroup = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + SMBCSRV *srv = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return -1; + + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + TALLOC_FREE(frame); + return -1; /* SMBC_server sets errno */ + + } + + /*d_printf(">>>unlink: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>unlink: resolved path as %s\n", targetpath);*/ + + if (!cli_unlink(targetcli, targetpath)) { + + errno = SMBC_errno(context, targetcli); + + if (errno == EACCES) { /* Check if the file is a directory */ + + int saverr = errno; + SMB_OFF_T size = 0; + uint16 mode = 0; + struct timespec write_time_ts; + struct timespec access_time_ts; + struct timespec change_time_ts; + SMB_INO_T ino = 0; + + if (!SMBC_getatr(context, srv, path, &mode, &size, + NULL, + &access_time_ts, + &write_time_ts, + &change_time_ts, + &ino)) { + + /* Hmmm, bad error ... What? */ + + errno = SMBC_errno(context, targetcli); + TALLOC_FREE(frame); + return -1; + + } + else { + + if (IS_DOS_DIR(mode)) + errno = EISDIR; + else + errno = saverr; /* Restore this */ + + } + } + + TALLOC_FREE(frame); + return -1; + + } + + TALLOC_FREE(frame); + return 0; /* Success ... */ + +} + +/* + * Routine to rename() a file + */ + +int +SMBC_rename_ctx(SMBCCTX *ocontext, + const char *oname, + SMBCCTX *ncontext, + const char *nname) +{ + char *server1 = NULL; + char *share1 = NULL; + char *server2 = NULL; + char *share2 = NULL; + char *user1 = NULL; + char *user2 = NULL; + char *password1 = NULL; + char *password2 = NULL; + char *workgroup = NULL; + char *path1 = NULL; + char *path2 = NULL; + char *targetpath1 = NULL; + char *targetpath2 = NULL; + struct cli_state *targetcli1 = NULL; + struct cli_state *targetcli2 = NULL; + SMBCSRV *srv = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!ocontext || !ncontext || + !ocontext->initialized || + !ncontext->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return -1; + } + + if (!oname || !nname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_rename(%s,%s)\n", oname, nname)); + + if (SMBC_parse_path(frame, + ocontext, + oname, + &workgroup, + &server1, + &share1, + &path1, + &user1, + &password1, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user1 || user1[0] == (char)0) { + user1 = talloc_strdup(frame, ocontext->user); + if (!user1) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + if (SMBC_parse_path(frame, + ncontext, + nname, + NULL, + &server2, + &share2, + &path2, + &user2, + &password2, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user2 || user2[0] == (char)0) { + user2 = talloc_strdup(frame, ncontext->user); + if (!user2) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + if (strcmp(server1, server2) || strcmp(share1, share2) || + strcmp(user1, user2)) { + /* Can't rename across file systems, or users?? */ + errno = EXDEV; + TALLOC_FREE(frame); + return -1; + } + + srv = SMBC_server(frame, ocontext, True, + server1, share1, &workgroup, &user1, &password1); + if (!srv) { + TALLOC_FREE(frame); + return -1; + + } + + /*d_printf(">>>rename: resolving %s\n", path1);*/ + if (!cli_resolve_path(frame, "", srv->cli, path1, + &targetcli1, &targetpath1)) { + d_printf("Could not resolve %s\n", path1); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>rename: resolved path as %s\n", targetpath1);*/ + /*d_printf(">>>rename: resolving %s\n", path2);*/ + if (!cli_resolve_path(frame, "", srv->cli, path2, + &targetcli2, &targetpath2)) { + d_printf("Could not resolve %s\n", path2); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>rename: resolved path as %s\n", targetpath2);*/ + + if (strcmp(targetcli1->desthost, targetcli2->desthost) || + strcmp(targetcli1->share, targetcli2->share)) + { + /* can't rename across file systems */ + errno = EXDEV; + TALLOC_FREE(frame); + return -1; + } + + if (!cli_rename(targetcli1, targetpath1, targetpath2)) { + int eno = SMBC_errno(ocontext, targetcli1); + + if (eno != EEXIST || + !cli_unlink(targetcli1, targetpath2) || + !cli_rename(targetcli1, targetpath1, targetpath2)) { + + errno = eno; + TALLOC_FREE(frame); + return -1; + + } + } + + TALLOC_FREE(frame); + return 0; /* Success */ +} + diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c new file mode 100644 index 0000000000..619176697b --- /dev/null +++ b/source3/libsmb/libsmb_file.c @@ -0,0 +1,859 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* + * Routine to open() a file ... + */ + +SMBCFILE * +SMBC_open_ctx(SMBCCTX *context, + const char *fname, + int flags, + mode_t mode) +{ + char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *workgroup = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + SMBCSRV *srv = NULL; + SMBCFILE *file = NULL; + int fd; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return NULL; + + } + + if (!fname) { + + errno = EINVAL; + TALLOC_FREE(frame); + return NULL; + + } + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return NULL; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return NULL; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + if (errno == EPERM) errno = EACCES; + TALLOC_FREE(frame); + return NULL; /* SMBC_server sets errno */ + } + + /* Hmmm, the test for a directory is suspect here ... FIXME */ + + if (strlen(path) > 0 && path[strlen(path) - 1] == '\\') { + fd = -1; + } else { + file = SMB_MALLOC_P(SMBCFILE); + + if (!file) { + errno = ENOMEM; + TALLOC_FREE(frame); + return NULL; + } + + ZERO_STRUCTP(file); + + /*d_printf(">>>open: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", srv->cli, path, &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + SAFE_FREE(file); + TALLOC_FREE(frame); + return NULL; + } + /*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/ + + if ((fd = cli_open(targetcli, targetpath, flags, + context->share_mode)) < 0) { + + /* Handle the error ... */ + + SAFE_FREE(file); + errno = SMBC_errno(context, targetcli); + TALLOC_FREE(frame); + return NULL; + + } + + /* Fill in file struct */ + + file->cli_fd = fd; + file->fname = SMB_STRDUP(fname); + file->srv = srv; + file->offset = 0; + file->file = True; + + DLIST_ADD(context->files, file); + + /* + * If the file was opened in O_APPEND mode, all write + * operations should be appended to the file. To do that, + * though, using this protocol, would require a getattrE() + * call for each and every write, to determine where the end + * of the file is. (There does not appear to be an append flag + * in the protocol.) Rather than add all of that overhead of + * retrieving the current end-of-file offset prior to each + * write operation, we'll assume that most append operations + * will continuously write, so we'll just set the offset to + * the end of the file now and hope that's adequate. + * + * Note to self: If this proves inadequate, and O_APPEND + * should, in some cases, be forced for each write, add a + * field in the context options structure, for + * "strict_append_mode" which would select between the current + * behavior (if FALSE) or issuing a getattrE() prior to each + * write and forcing the write to the end of the file (if + * TRUE). Adding that capability will likely require adding + * an "append" flag into the _SMBCFILE structure to track + * whether a file was opened in O_APPEND mode. -- djl + */ + if (flags & O_APPEND) { + if (SMBC_lseek_ctx(context, file, 0, SEEK_END) < 0) { + (void) SMBC_close_ctx(context, file); + errno = ENXIO; + TALLOC_FREE(frame); + return NULL; + } + } + + TALLOC_FREE(frame); + return file; + + } + + /* Check if opendir needed ... */ + + if (fd == -1) { + int eno = 0; + + eno = SMBC_errno(context, srv->cli); + file = (context->posix_emu.opendir_fn)(context, fname); + if (!file) errno = eno; + TALLOC_FREE(frame); + return file; + + } + + errno = EINVAL; /* FIXME, correct errno ? */ + TALLOC_FREE(frame); + return NULL; + +} + +/* + * Routine to create a file + */ + +static int creat_bits = O_WRONLY | O_CREAT | O_TRUNC; /* FIXME: Do we need this */ + +SMBCFILE * +SMBC_creat_ctx(SMBCCTX *context, + const char *path, + mode_t mode) +{ + + if (!context || !context->initialized) { + + errno = EINVAL; + return NULL; + + } + + return SMBC_open_ctx(context, path, creat_bits, mode); +} + +/* + * Routine to read() a file ... + */ + +ssize_t +SMBC_read_ctx(SMBCCTX *context, + SMBCFILE *file, + void *buf, + size_t count) +{ + int ret; + char *server = NULL, *share = NULL, *user = NULL, *password = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + /* + * offset: + * + * Compiler bug (possibly) -- gcc (GCC) 3.3.5 (Debian 1:3.3.5-2) -- + * appears to pass file->offset (which is type off_t) differently than + * a local variable of type off_t. Using local variable "offset" in + * the call to cli_read() instead of file->offset fixes a problem + * retrieving data at an offset greater than 4GB. + */ + off_t offset; + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count)); + + if (!file || !SMBC_dlist_contains(context->files, file)) { + errno = EBADF; + TALLOC_FREE(frame); + return -1; + + } + + offset = file->offset; + + /* Check that the buffer exists ... */ + + if (buf == NULL) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + /*d_printf(">>>read: parsing %s\n", file->fname);*/ + if (SMBC_parse_path(frame, + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>read: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", file->srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ + + ret = cli_read(targetcli, file->cli_fd, (char *)buf, offset, count); + + if (ret < 0) { + + errno = SMBC_errno(context, targetcli); + TALLOC_FREE(frame); + return -1; + + } + + file->offset += ret; + + DEBUG(4, (" --> %d\n", ret)); + + TALLOC_FREE(frame); + return ret; /* Success, ret bytes of data ... */ + +} + +/* + * Routine to write() a file ... + */ + +ssize_t +SMBC_write_ctx(SMBCCTX *context, + SMBCFILE *file, + void *buf, + size_t count) +{ + int ret; + off_t offset; + char *server = NULL, *share = NULL, *user = NULL, *password = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + /* First check all pointers before dereferencing them */ + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + if (!file || !SMBC_dlist_contains(context->files, file)) { + errno = EBADF; + TALLOC_FREE(frame); + return -1; + } + + /* Check that the buffer exists ... */ + + if (buf == NULL) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + offset = file->offset; /* See "offset" comment in SMBC_read_ctx() */ + + /*d_printf(">>>write: parsing %s\n", file->fname);*/ + if (SMBC_parse_path(frame, + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>write: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", file->srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>write: resolved path as %s\n", targetpath);*/ + + ret = cli_write(targetcli, file->cli_fd, 0, (char *)buf, offset, count); + + if (ret <= 0) { + errno = SMBC_errno(context, targetcli); + TALLOC_FREE(frame); + return -1; + + } + + file->offset += ret; + + TALLOC_FREE(frame); + return ret; /* Success, 0 bytes of data ... */ +} + +/* + * Routine to close() a file ... + */ + +int +SMBC_close_ctx(SMBCCTX *context, + SMBCFILE *file) +{ + SMBCSRV *srv; + char *server = NULL, *share = NULL, *user = NULL, *password = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!file || !SMBC_dlist_contains(context->files, file)) { + errno = EBADF; + TALLOC_FREE(frame); + return -1; + } + + /* IS a dir ... */ + if (!file->file) { + TALLOC_FREE(frame); + return (context->posix_emu.closedir_fn)(context, file); + } + + /*d_printf(">>>close: parsing %s\n", file->fname);*/ + if (SMBC_parse_path(frame, + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>close: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", file->srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>close: resolved path as %s\n", targetpath);*/ + + if (!cli_close(targetcli, file->cli_fd)) { + + DEBUG(3, ("cli_close failed on %s. purging server.\n", + file->fname)); + /* Deallocate slot and remove the server + * from the server cache if unused */ + errno = SMBC_errno(context, targetcli); + srv = file->srv; + DLIST_REMOVE(context->files, file); + SAFE_FREE(file->fname); + SAFE_FREE(file); + (context->server.remove_unused_server_fn)(context, srv); + TALLOC_FREE(frame); + return -1; + + } + + DLIST_REMOVE(context->files, file); + SAFE_FREE(file->fname); + SAFE_FREE(file); + TALLOC_FREE(frame); + + return 0; +} + +/* + * Get info from an SMB server on a file. Use a qpathinfo call first + * and if that fails, use getatr, as Win95 sometimes refuses qpathinfo + */ +bool +SMBC_getatr(SMBCCTX * context, + SMBCSRV *srv, + char *path, + uint16 *mode, + SMB_OFF_T *size, + struct timespec *create_time_ts, + struct timespec *access_time_ts, + struct timespec *write_time_ts, + struct timespec *change_time_ts, + SMB_INO_T *ino) +{ + char *fixedpath = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + time_t write_time; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /* path fixup for . and .. */ + if (strequal(path, ".") || strequal(path, "..")) { + fixedpath = talloc_strdup(frame, "\\"); + if (!fixedpath) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } else { + fixedpath = talloc_strdup(frame, path); + if (!fixedpath) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + trim_string(fixedpath, NULL, "\\.."); + trim_string(fixedpath, NULL, "\\."); + } + DEBUG(4,("SMBC_getatr: sending qpathinfo\n")); + + if (!cli_resolve_path(frame, "", srv->cli, fixedpath, + &targetcli, &targetpath)) { + d_printf("Couldn't resolve %s\n", path); + TALLOC_FREE(frame); + return False; + } + + if (!srv->no_pathinfo2 && + cli_qpathinfo2(targetcli, targetpath, + create_time_ts, + access_time_ts, + write_time_ts, + change_time_ts, + size, mode, ino)) { + TALLOC_FREE(frame); + return True; + } + + /* if this is NT then don't bother with the getatr */ + if (targetcli->capabilities & CAP_NT_SMBS) { + errno = EPERM; + TALLOC_FREE(frame); + return False; + } + + if (cli_getatr(targetcli, targetpath, mode, size, &write_time)) { + + struct timespec w_time_ts; + + w_time_ts = convert_time_t_to_timespec(write_time); + + if (write_time_ts != NULL) { + *write_time_ts = w_time_ts; + } + + if (create_time_ts != NULL) { + *create_time_ts = w_time_ts; + } + + if (access_time_ts != NULL) { + *access_time_ts = w_time_ts; + } + + if (change_time_ts != NULL) { + *change_time_ts = w_time_ts; + } + + srv->no_pathinfo2 = True; + TALLOC_FREE(frame); + return True; + } + + errno = EPERM; + TALLOC_FREE(frame); + return False; + +} + +/* + * Set file info on an SMB server. Use setpathinfo call first. If that + * fails, use setattrE.. + * + * Access and modification time parameters are always used and must be + * provided. Create time, if zero, will be determined from the actual create + * time of the file. If non-zero, the create time will be set as well. + * + * "mode" (attributes) parameter may be set to -1 if it is not to be set. + */ +bool +SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, + time_t create_time, + time_t access_time, + time_t write_time, + time_t change_time, + uint16 mode) +{ + int fd; + int ret; + TALLOC_CTX *frame = talloc_stackframe(); + + /* + * First, try setpathinfo (if qpathinfo succeeded), for it is the + * modern function for "new code" to be using, and it works given a + * filename rather than requiring that the file be opened to have its + * attributes manipulated. + */ + if (srv->no_pathinfo || + ! cli_setpathinfo(srv->cli, path, + create_time, + access_time, + write_time, + change_time, + mode)) { + + /* + * setpathinfo is not supported; go to plan B. + * + * cli_setatr() does not work on win98, and it also doesn't + * support setting the access time (only the modification + * time), so in all cases, we open the specified file and use + * cli_setattrE() which should work on all OS versions, and + * supports both times. + */ + + /* Don't try {q,set}pathinfo() again, with this server */ + srv->no_pathinfo = True; + + /* Open the file */ + if ((fd = cli_open(srv->cli, path, O_RDWR, DENY_NONE)) < 0) { + + errno = SMBC_errno(context, srv->cli); + TALLOC_FREE(frame); + return -1; + } + + /* Set the new attributes */ + ret = cli_setattrE(srv->cli, fd, + change_time, + access_time, + write_time); + + /* Close the file */ + cli_close(srv->cli, fd); + + /* + * Unfortunately, setattrE() doesn't have a provision for + * setting the access mode (attributes). We'll have to try + * cli_setatr() for that, and with only this parameter, it + * seems to work on win98. + */ + if (ret && mode != (uint16) -1) { + ret = cli_setatr(srv->cli, path, mode, 0); + } + + if (! ret) { + errno = SMBC_errno(context, srv->cli); + TALLOC_FREE(frame); + return False; + } + } + + TALLOC_FREE(frame); + return True; +} + +/* + * A routine to lseek() a file + */ + +off_t +SMBC_lseek_ctx(SMBCCTX *context, + SMBCFILE *file, + off_t offset, + int whence) +{ + SMB_OFF_T size; + char *server = NULL, *share = NULL, *user = NULL, *password = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!file || !SMBC_dlist_contains(context->files, file)) { + + errno = EBADF; + TALLOC_FREE(frame); + return -1; + + } + + if (!file->file) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; /* Can't lseek a dir ... */ + + } + + switch (whence) { + case SEEK_SET: + file->offset = offset; + break; + + case SEEK_CUR: + file->offset += offset; + break; + + case SEEK_END: + /*d_printf(">>>lseek: parsing %s\n", file->fname);*/ + if (SMBC_parse_path(frame, + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>lseek: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", file->srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>lseek: resolved path as %s\n", targetpath);*/ + + if (!cli_qfileinfo(targetcli, file->cli_fd, NULL, + &size, NULL, NULL, NULL, NULL, NULL)) + { + SMB_OFF_T b_size = size; + if (!cli_getattrE(targetcli, file->cli_fd, + NULL, &b_size, NULL, NULL, NULL)) + { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } else + size = b_size; + } + file->offset = size + offset; + break; + + default: + errno = EINVAL; + break; + + } + + TALLOC_FREE(frame); + return file->offset; + +} + + +/* + * Routine to truncate a file given by its file descriptor, to a specified size + */ + +int +SMBC_ftruncate_ctx(SMBCCTX *context, + SMBCFILE *file, + off_t length) +{ + SMB_OFF_T size = length; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!file || !SMBC_dlist_contains(context->files, file)) { + errno = EBADF; + TALLOC_FREE(frame); + return -1; + } + + if (!file->file) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ + if (SMBC_parse_path(frame, + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>fstat: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", file->srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ + + if (!cli_ftruncate(targetcli, file->cli_fd, size)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + TALLOC_FREE(frame); + return 0; + +} diff --git a/source3/libsmb/libsmb_misc.c b/source3/libsmb/libsmb_misc.c new file mode 100644 index 0000000000..f2fd919ef6 --- /dev/null +++ b/source3/libsmb/libsmb_misc.c @@ -0,0 +1,73 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* + * check if an element is part of the list. + */ +int +SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p) +{ + if (!p || !list) return False; + do { + if (p == list) return True; + list = list->next; + } while (list); + return False; +} + + +/* + * Convert an SMB error into a UNIX error ... + */ +int +SMBC_errno(SMBCCTX *context, + struct cli_state *c) +{ + int ret = cli_errno(c); + + if (cli_is_dos_error(c)) { + uint8 eclass; + uint32 ecode; + + cli_dos_error(c, &eclass, &ecode); + + DEBUG(3,("smbc_error %d %d (0x%x) -> %d\n", + (int)eclass, (int)ecode, (int)ecode, ret)); + } else { + NTSTATUS status; + + status = cli_nt_error(c); + + DEBUG(3,("smbc errno %s -> %d\n", + nt_errstr(status), ret)); + } + + return ret; +} + diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c new file mode 100644 index 0000000000..2533f536c3 --- /dev/null +++ b/source3/libsmb/libsmb_path.c @@ -0,0 +1,399 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* Used by urldecode_talloc() */ +static int +hex2int( unsigned int _char ) +{ + if ( _char >= 'A' && _char <='F') + return _char - 'A' + 10; + if ( _char >= 'a' && _char <='f') + return _char - 'a' + 10; + if ( _char >= '0' && _char <='9') + return _char - '0'; + return -1; +} + +/* + * SMBC_urldecode() + * and urldecode_talloc() (internal fn.) + * + * Convert strings of %xx to their single character equivalent. Each 'x' must + * be a valid hexadecimal digit, or that % sequence is left undecoded. + * + * dest may, but need not be, the same pointer as src. + * + * Returns the number of % sequences which could not be converted due to lack + * of two following hexadecimal digits. + */ +static int +urldecode_talloc(TALLOC_CTX *ctx, char **pp_dest, const char *src) +{ + int old_length = strlen(src); + int i = 0; + int err_count = 0; + size_t newlen = 1; + char *p, *dest; + + if (old_length == 0) { + return 0; + } + + *pp_dest = NULL; + for (i = 0; i < old_length; ) { + unsigned char character = src[i++]; + + if (character == '%') { + int a = i+1 < old_length ? hex2int(src[i]) : -1; + int b = i+1 < old_length ? hex2int(src[i+1]) : -1; + + /* Replace valid sequence */ + if (a != -1 && b != -1) { + /* Replace valid %xx sequence with %dd */ + character = (a * 16) + b; + if (character == '\0') { + break; /* Stop at %00 */ + } + i += 2; + } else { + err_count++; + } + } + newlen++; + } + + dest = TALLOC_ARRAY(ctx, char, newlen); + if (!dest) { + return err_count; + } + + err_count = 0; + for (p = dest, i = 0; i < old_length; ) { + unsigned char character = src[i++]; + + if (character == '%') { + int a = i+1 < old_length ? hex2int(src[i]) : -1; + int b = i+1 < old_length ? hex2int(src[i+1]) : -1; + + /* Replace valid sequence */ + if (a != -1 && b != -1) { + /* Replace valid %xx sequence with %dd */ + character = (a * 16) + b; + if (character == '\0') { + break; /* Stop at %00 */ + } + i += 2; + } else { + err_count++; + } + } + *p++ = character; + } + + *p = '\0'; + *pp_dest = dest; + return err_count; +} + +int +SMBC_urldecode(char *dest, + char *src, + size_t max_dest_len) +{ + TALLOC_CTX *frame = talloc_stackframe(); + char *pdest; + int ret = urldecode_talloc(frame, &pdest, src); + + if (pdest) { + strlcpy(dest, pdest, max_dest_len); + } + TALLOC_FREE(frame); + return ret; +} + +/* + * SMBC_urlencode() + * + * Convert any characters not specifically allowed in a URL into their %xx + * equivalent. + * + * Returns the remaining buffer length. + */ +int +SMBC_urlencode(char *dest, + char *src, + int max_dest_len) +{ + char hex[] = "0123456789ABCDEF"; + + for (; *src != '\0' && max_dest_len >= 3; src++) { + + if ((*src < '0' && + *src != '-' && + *src != '.') || + (*src > '9' && + *src < 'A') || + (*src > 'Z' && + *src < 'a' && + *src != '_') || + (*src > 'z')) { + *dest++ = '%'; + *dest++ = hex[(*src >> 4) & 0x0f]; + *dest++ = hex[*src & 0x0f]; + max_dest_len -= 3; + } else { + *dest++ = *src; + max_dest_len--; + } + } + + *dest++ = '\0'; + max_dest_len--; + + return max_dest_len; +} + +/* + * Function to parse a path and turn it into components + * + * The general format of an SMB URI is explain in Christopher Hertel's CIFS + * book, at http://ubiqx.org/cifs/Appendix-D.html. We accept a subset of the + * general format ("smb:" only; we do not look for "cifs:"). + * + * + * We accept: + * smb://[[[domain;]user[:password]@]server[/share[/path[/file]]]][?options] + * + * Meaning of URLs: + * + * smb:// Show all workgroups. + * + * The method of locating the list of workgroups varies + * depending upon the setting of the context variable + * context->browse_max_lmb_count. This value determines + * the maximum number of local master browsers to query + * for the list of workgroups. In order to ensure that + * a complete list of workgroups is obtained, all master + * browsers must be queried, but if there are many + * workgroups, the time spent querying can begin to add up. + * For small networks (not many workgroups), it is suggested + * that this variable be set to 0, indicating query all local + * master browsers. When the network has many workgroups, a + * reasonable setting for this variable might be around 3. + * + * smb://name/ if name<1D> or name<1B> exists, list servers in + * workgroup, else, if name<20> exists, list all shares + * for server ... + * + * If "options" are provided, this function returns the entire option list as a + * string, for later parsing by the caller. Note that currently, no options + * are supported. + */ + +static const char *smbc_prefix = "smb:"; + +int +SMBC_parse_path(TALLOC_CTX *ctx, + SMBCCTX *context, + const char *fname, + char **pp_workgroup, + char **pp_server, + char **pp_share, + char **pp_path, + char **pp_user, + char **pp_password, + char **pp_options) +{ + char *s; + const char *p; + char *q, *r; + int len; + + /* Ensure these returns are at least valid pointers. */ + *pp_server = talloc_strdup(ctx, ""); + *pp_share = talloc_strdup(ctx, ""); + *pp_path = talloc_strdup(ctx, ""); + *pp_user = talloc_strdup(ctx, ""); + *pp_password = talloc_strdup(ctx, ""); + + if (!*pp_server || !*pp_share || !*pp_path || + !*pp_user || !*pp_password) { + return -1; + } + + /* + * Assume we wont find an authentication domain to parse, so default + * to the workgroup in the provided context. + */ + if (pp_workgroup != NULL) { + *pp_workgroup = talloc_strdup(ctx, context->workgroup); + } + + if (pp_options) { + *pp_options = talloc_strdup(ctx, ""); + } + s = talloc_strdup(ctx, fname); + + /* see if it has the right prefix */ + len = strlen(smbc_prefix); + if (strncmp(s,smbc_prefix,len) || (s[len] != '/' && s[len] != 0)) { + return -1; /* What about no smb: ? */ + } + + p = s + len; + + /* Watch the test below, we are testing to see if we should exit */ + + if (strncmp(p, "//", 2) && strncmp(p, "\\\\", 2)) { + DEBUG(1, ("Invalid path (does not begin with smb://")); + return -1; + } + + p += 2; /* Skip the double slash */ + + /* See if any options were specified */ + if ((q = strrchr(p, '?')) != NULL ) { + /* There are options. Null terminate here and point to them */ + *q++ = '\0'; + + DEBUG(4, ("Found options '%s'", q)); + + /* Copy the options */ + if (*pp_options != NULL) { + TALLOC_FREE(*pp_options); + *pp_options = talloc_strdup(ctx, q); + } + } + + if (*p == '\0') { + goto decoding; + } + + if (*p == '/') { + int wl = strlen(context->workgroup); + + if (wl > 16) { + wl = 16; + } + + *pp_server = talloc_strdup(ctx, context->workgroup); + if (!*pp_server) { + return -1; + } + *pp_server[wl] = '\0'; + return 0; + } + + /* + * ok, its for us. Now parse out the server, share etc. + * + * However, we want to parse out [[domain;]user[:password]@] if it + * exists ... + */ + + /* check that '@' occurs before '/', if '/' exists at all */ + q = strchr_m(p, '@'); + r = strchr_m(p, '/'); + if (q && (!r || q < r)) { + char *userinfo = NULL; + const char *u; + + next_token_no_ltrim_talloc(ctx, &p, &userinfo, "@"); + if (!userinfo) { + return -1; + } + u = userinfo; + + if (strchr_m(u, ';')) { + char *workgroup; + next_token_no_ltrim_talloc(ctx, &u, &workgroup, ";"); + if (!workgroup) { + return -1; + } + if (pp_workgroup) { + *pp_workgroup = workgroup; + } + } + + if (strchr_m(u, ':')) { + next_token_no_ltrim_talloc(ctx, &u, pp_user, ":"); + if (!*pp_user) { + return -1; + } + *pp_password = talloc_strdup(ctx, u); + if (!*pp_password) { + return -1; + } + } else { + *pp_user = talloc_strdup(ctx, u); + if (!*pp_user) { + return -1; + } + } + } + + if (!next_token_talloc(ctx, &p, pp_server, "/")) { + return -1; + } + + if (*p == (char)0) { + goto decoding; /* That's it ... */ + } + + if (!next_token_talloc(ctx, &p, pp_share, "/")) { + return -1; + } + + /* + * Prepend a leading slash if there's a file path, as required by + * NetApp filers. + */ + if (*p != '\0') { + *pp_path = talloc_asprintf(ctx, + "\\%s", + p); + } else { + *pp_path = talloc_strdup(ctx, ""); + } + if (!*pp_path) { + return -1; + } + string_replace(*pp_path, '/', '\\'); + + decoding: + + (void) urldecode_talloc(ctx, pp_path, *pp_path); + (void) urldecode_talloc(ctx, pp_server, *pp_server); + (void) urldecode_talloc(ctx, pp_share, *pp_share); + (void) urldecode_talloc(ctx, pp_user, *pp_user); + (void) urldecode_talloc(ctx, pp_password, *pp_password); + + return 0; +} + diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c new file mode 100644 index 0000000000..f106080b6f --- /dev/null +++ b/source3/libsmb/libsmb_printjob.c @@ -0,0 +1,334 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* + * Open a print file to be written to by other calls + */ + +SMBCFILE * +SMBC_open_print_job_ctx(SMBCCTX *context, + const char *fname) +{ + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *path = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return NULL; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return NULL; + } + + DEBUG(4, ("SMBC_open_print_job_ctx(%s)\n", fname)); + + if (SMBC_parse_path(frame, + context, + fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return NULL; + } + + /* What if the path is empty, or the file exists? */ + + TALLOC_FREE(frame); + return (context->posix_emu.open_fn)(context, fname, O_WRONLY, 666); +} + +/* + * Routine to print a file on a remote server ... + * + * We open the file, which we assume to be on a remote server, and then + * copy it to a print file on the share specified by printq. + */ + +int +SMBC_print_file_ctx(SMBCCTX *c_file, + const char *fname, + SMBCCTX *c_print, + const char *printq) +{ + SMBCFILE *fid1; + SMBCFILE *fid2; + int bytes; + int saverr; + int tot_bytes = 0; + char buf[4096]; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!c_file || !c_file->initialized || + !c_print || !c_print->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + if (!fname && !printq) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + /* Try to open the file for reading ... */ + + if ((long)(fid1 = smbc_getFunctionOpen(c_file)(c_file, fname, O_RDONLY, 0666)) < 0) { + DEBUG(3, ("Error, fname=%s, errno=%i\n", fname, errno)); + TALLOC_FREE(frame); + return -1; /* smbc_open sets errno */ + } + + /* Now, try to open the printer file for writing */ + + if ((long)(fid2 = smbc_getFunctionOpenPrintJob(c_print)(c_print, printq)) < 0) { + + saverr = errno; /* Save errno */ + smbc_getFunctionClose(c_file)(c_file, fid1); + errno = saverr; + TALLOC_FREE(frame); + return -1; + + } + + while ((bytes = smbc_getFunctionRead(c_file)(c_file, fid1, + buf, sizeof(buf))) > 0) { + + tot_bytes += bytes; + + if ((smbc_getFunctionWrite(c_print)(c_print, fid2, + buf, bytes)) < 0) { + + saverr = errno; + smbc_getFunctionClose(c_file)(c_file, fid1); + smbc_getFunctionClose(c_print)(c_print, fid2); + errno = saverr; + + } + + } + + saverr = errno; + + smbc_getFunctionClose(c_file)(c_file, fid1); /* We have to close these anyway */ + smbc_getFunctionClose(c_print)(c_print, fid2); + + if (bytes < 0) { + + errno = saverr; + TALLOC_FREE(frame); + return -1; + + } + + TALLOC_FREE(frame); + return tot_bytes; + +} + +/* + * Routine to list print jobs on a printer share ... + */ + +int +SMBC_list_print_jobs_ctx(SMBCCTX *context, + const char *fname, + smbc_list_print_job_fn fn) +{ + SMBCSRV *srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_list_print_jobs(%s)\n", fname)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + } + + if (cli_print_queue(srv->cli, + (void (*)(struct print_job_info *))fn) < 0) { + errno = SMBC_errno(context, srv->cli); + TALLOC_FREE(frame); + return -1; + } + + TALLOC_FREE(frame); + return 0; + +} + +/* + * Delete a print job from a remote printer share + */ + +int +SMBC_unlink_print_job_ctx(SMBCCTX *context, + const char *fname, + int id) +{ + SMBCSRV *srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + int err; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_unlink_print_job(%s)\n", fname)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + + } + + if ((err = cli_printjob_del(srv->cli, id)) != 0) { + + if (err < 0) + errno = SMBC_errno(context, srv->cli); + else if (err == ERRnosuchprintjob) + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + + } + + TALLOC_FREE(frame); + return 0; + +} + diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c new file mode 100644 index 0000000000..978a843d30 --- /dev/null +++ b/source3/libsmb/libsmb_server.c @@ -0,0 +1,675 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* + * Check a server for being alive and well. + * returns 0 if the server is in shape. Returns 1 on error + * + * Also useable outside libsmbclient to enable external cache + * to do some checks too. + */ +int +SMBC_check_server(SMBCCTX * context, + SMBCSRV * server) +{ + socklen_t size; + struct sockaddr addr; + + size = sizeof(addr); + return (getpeername(server->cli->fd, &addr, &size) == -1); +} + +/* + * Remove a server from the cached server list it's unused. + * On success, 0 is returned. 1 is returned if the server could not be removed. + * + * Also useable outside libsmbclient + */ +int +SMBC_remove_unused_server(SMBCCTX * context, + SMBCSRV * srv) +{ + SMBCFILE * file; + + /* are we being fooled ? */ + if (!context || !context->initialized || !srv) { + return 1; + } + + /* Check all open files/directories for a relation with this server */ + for (file = context->files; file; file = file->next) { + if (file->srv == srv) { + /* Still used */ + DEBUG(3, ("smbc_remove_usused_server: " + "%p still used by %p.\n", + srv, file)); + return 1; + } + } + + DLIST_REMOVE(context->servers, srv); + + cli_shutdown(srv->cli); + srv->cli = NULL; + + DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv)); + + (context->cache.remove_cached_server_fn)(context, srv); + + SAFE_FREE(srv); + return 0; +} + +/**************************************************************** + * Call the auth_fn with fixed size (fstring) buffers. + ***************************************************************/ +void +SMBC_call_auth_fn(TALLOC_CTX *ctx, + SMBCCTX *context, + const char *server, + const char *share, + char **pp_workgroup, + char **pp_username, + char **pp_password) +{ + fstring workgroup; + fstring username; + fstring password; + + strlcpy(workgroup, *pp_workgroup, sizeof(workgroup)); + strlcpy(username, *pp_username, sizeof(username)); + strlcpy(password, *pp_password, sizeof(password)); + + (context->server.get_auth_data_fn)( + server, share, + workgroup, sizeof(workgroup), + username, sizeof(username), + password, sizeof(password)); + + TALLOC_FREE(*pp_workgroup); + TALLOC_FREE(*pp_username); + TALLOC_FREE(*pp_password); + + *pp_workgroup = talloc_strdup(ctx, workgroup); + *pp_username = talloc_strdup(ctx, username); + *pp_password = talloc_strdup(ctx, password); +} + + +void +SMBC_get_auth_data(const char *server, const char *share, + char *workgroup_buf, int workgroup_buf_len, + char *username_buf, int username_buf_len, + char *password_buf, int password_buf_len) +{ + /* Default function just uses provided data. Nothing to do. */ +} + + + +SMBCSRV * +SMBC_find_server(TALLOC_CTX *ctx, + SMBCCTX *context, + const char *server, + const char *share, + char **pp_workgroup, + char **pp_username, + char **pp_password) +{ + SMBCSRV *srv; + int auth_called = 0; + + check_server_cache: + + srv = (context->cache.get_cached_server_fn)(context, + server, share, + *pp_workgroup, + *pp_username); + + if (!auth_called && !srv && (!*pp_username || !(*pp_username)[0] || + !*pp_password || !(*pp_password)[0])) { + SMBC_call_auth_fn(ctx, context, server, share, + pp_workgroup, pp_username, pp_password); + + if (!pp_workgroup || !pp_username || !pp_password) { + return NULL; + } + + /* + * However, smbc_auth_fn may have picked up info relating to + * an existing connection, so try for an existing connection + * again ... + */ + auth_called = 1; + goto check_server_cache; + + } + + if (srv) { + if ((context->server.check_server_fn)(context, srv)) { + /* + * This server is no good anymore + * Try to remove it and check for more possible + * servers in the cache + */ + if ((context->server.remove_unused_server_fn)(context, + srv)) { + /* + * We could not remove the server completely, + * remove it from the cache so we will not get + * it again. It will be removed when the last + * file/dir is closed. + */ + (context->cache.remove_cached_server_fn)(context, + srv); + } + + /* + * Maybe there are more cached connections to this + * server + */ + goto check_server_cache; + } + + return srv; + } + + return NULL; +} + +/* + * Connect to a server, possibly on an existing connection + * + * Here, what we want to do is: If the server and username + * match an existing connection, reuse that, otherwise, establish a + * new connection. + * + * If we have to create a new connection, call the auth_fn to get the + * info we need, unless the username and password were passed in. + */ + +SMBCSRV * +SMBC_server(TALLOC_CTX *ctx, + SMBCCTX *context, + bool connect_if_not_found, + const char *server, + const char *share, + char **pp_workgroup, + char **pp_username, + char **pp_password) +{ + SMBCSRV *srv=NULL; + struct cli_state *c; + struct nmb_name called, calling; + const char *server_n = server; + struct sockaddr_storage ss; + int tried_reverse = 0; + int port_try_first; + int port_try_next; + const char *username_used; + NTSTATUS status; + + zero_addr(&ss); + ZERO_STRUCT(c); + + if (server[0] == 0) { + errno = EPERM; + return NULL; + } + + /* Look for a cached connection */ + srv = SMBC_find_server(ctx, context, server, share, + pp_workgroup, pp_username, pp_password); + + /* + * If we found a connection and we're only allowed one share per + * server... + */ + if (srv && *share != '\0' && context->one_share_per_server) { + + /* + * ... then if there's no current connection to the share, + * connect to it. SMBC_find_server(), or rather the function + * pointed to by context->cache.get_cached_srv_fn which + * was called by SMBC_find_server(), will have issued a tree + * disconnect if the requested share is not the same as the + * one that was already connected. + */ + if (srv->cli->cnum == (uint16) -1) { + /* Ensure we have accurate auth info */ + SMBC_call_auth_fn(ctx, context, server, share, + pp_workgroup, pp_username, pp_password); + + if (!*pp_workgroup || !*pp_username || !*pp_password) { + errno = ENOMEM; + cli_shutdown(srv->cli); + srv->cli = NULL; + (context->cache.remove_cached_server_fn)(context, + srv); + return NULL; + } + + /* + * We don't need to renegotiate encryption + * here as the encryption context is not per + * tid. + */ + + if (!cli_send_tconX(srv->cli, share, "?????", + *pp_password, + strlen(*pp_password)+1)) { + + errno = SMBC_errno(context, srv->cli); + cli_shutdown(srv->cli); + srv->cli = NULL; + (context->cache.remove_cached_server_fn)(context, + srv); + srv = NULL; + } + + /* + * Regenerate the dev value since it's based on both + * server and share + */ + if (srv) { + srv->dev = (dev_t)(str_checksum(server) ^ + str_checksum(share)); + } + } + } + + /* If we have a connection... */ + if (srv) { + + /* ... then we're done here. Give 'em what they came for. */ + return srv; + } + + /* If we're not asked to connect when a connection doesn't exist... */ + if (! connect_if_not_found) { + /* ... then we're done here. */ + return NULL; + } + + if (!*pp_workgroup || !*pp_username || !*pp_password) { + errno = ENOMEM; + return NULL; + } + + make_nmb_name(&calling, context->netbios_name, 0x0); + make_nmb_name(&called , server, 0x20); + + DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server)); + + DEBUG(4,(" -> server_n=[%s] server=[%s]\n", server_n, server)); + + again: + + zero_addr(&ss); + + /* have to open a new connection */ + if ((c = cli_initialise()) == NULL) { + errno = ENOMEM; + return NULL; + } + + if (context->use_kerberos) { + c->use_kerberos = True; + } + if (context->fallback_after_kerberos) { + c->fallback_after_kerberos = True; + } + + c->timeout = context->timeout; + + /* + * Force use of port 139 for first try if share is $IPC, empty, or + * null, so browse lists can work + */ + if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0) { + port_try_first = 139; + port_try_next = 445; + } else { + port_try_first = 445; + port_try_next = 139; + } + + c->port = port_try_first; + + status = cli_connect(c, server_n, &ss); + if (!NT_STATUS_IS_OK(status)) { + + /* First connection attempt failed. Try alternate port. */ + c->port = port_try_next; + + status = cli_connect(c, server_n, &ss); + if (!NT_STATUS_IS_OK(status)) { + cli_shutdown(c); + errno = ETIMEDOUT; + return NULL; + } + } + + if (!cli_session_request(c, &calling, &called)) { + cli_shutdown(c); + if (strcmp(called.name, "*SMBSERVER")) { + make_nmb_name(&called , "*SMBSERVER", 0x20); + goto again; + } else { /* Try one more time, but ensure we don't loop */ + + /* Only try this if server is an IP address ... */ + + if (is_ipaddress(server) && !tried_reverse) { + fstring remote_name; + struct sockaddr_storage rem_ss; + + if (!interpret_string_addr(&rem_ss, server, + NI_NUMERICHOST)) { + DEBUG(4, ("Could not convert IP address " + "%s to struct sockaddr_storage\n", + server)); + errno = ETIMEDOUT; + return NULL; + } + + tried_reverse++; /* Yuck */ + + if (name_status_find("*", 0, 0, &rem_ss, remote_name)) { + make_nmb_name(&called, remote_name, 0x20); + goto again; + } + } + } + errno = ETIMEDOUT; + return NULL; + } + + DEBUG(4,(" session request ok\n")); + + if (!cli_negprot(c)) { + cli_shutdown(c); + errno = ETIMEDOUT; + return NULL; + } + + username_used = *pp_username; + + if (!NT_STATUS_IS_OK(cli_session_setup(c, username_used, + *pp_password, strlen(*pp_password), + *pp_password, strlen(*pp_password), + *pp_workgroup))) { + + /* Failed. Try an anonymous login, if allowed by flags. */ + username_used = ""; + + if (context->no_auto_anonymous_login || + !NT_STATUS_IS_OK(cli_session_setup(c, username_used, + *pp_password, 1, + *pp_password, 0, + *pp_workgroup))) { + + cli_shutdown(c); + errno = EPERM; + return NULL; + } + } + + DEBUG(4,(" session setup ok\n")); + + if (!cli_send_tconX(c, share, "?????", + *pp_password, strlen(*pp_password)+1)) { + errno = SMBC_errno(context, c); + cli_shutdown(c); + return NULL; + } + + DEBUG(4,(" tconx ok\n")); + + if (context->smb_encryption_level) { + /* Attempt UNIX smb encryption. */ + if (!NT_STATUS_IS_OK(cli_force_encryption(c, + username_used, + *pp_password, + *pp_workgroup))) { + + /* + * context->smb_encryption_level == 1 + * means don't fail if encryption can't be negotiated, + * == 2 means fail if encryption can't be negotiated. + */ + + DEBUG(4,(" SMB encrypt failed\n")); + + if (context->smb_encryption_level == 2) { + cli_shutdown(c); + errno = EPERM; + return NULL; + } + } + DEBUG(4,(" SMB encrypt ok\n")); + } + + /* + * Ok, we have got a nice connection + * Let's allocate a server structure. + */ + + srv = SMB_MALLOC_P(SMBCSRV); + if (!srv) { + errno = ENOMEM; + goto failed; + } + + ZERO_STRUCTP(srv); + srv->cli = c; + srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share)); + srv->no_pathinfo = False; + srv->no_pathinfo2 = False; + srv->no_nt_session = False; + + /* now add it to the cache (internal or external) */ + /* Let the cache function set errno if it wants to */ + errno = 0; + if ((context->cache.add_cached_server_fn)(context, srv, + server, share, + *pp_workgroup, + *pp_username)) { + int saved_errno = errno; + DEBUG(3, (" Failed to add server to cache\n")); + errno = saved_errno; + if (errno == 0) { + errno = ENOMEM; + } + goto failed; + } + + DEBUG(2, ("Server connect ok: //%s/%s: %p\n", + server, share, srv)); + + DLIST_ADD(context->servers, srv); + return srv; + + failed: + cli_shutdown(c); + if (!srv) { + return NULL; + } + + SAFE_FREE(srv); + return NULL; +} + +/* + * Connect to a server for getting/setting attributes, possibly on an existing + * connection. This works similarly to SMBC_server(). + */ +SMBCSRV * +SMBC_attr_server(TALLOC_CTX *ctx, + SMBCCTX *context, + const char *server, + const char *share, + char **pp_workgroup, + char **pp_username, + char **pp_password) +{ + int flags; + struct sockaddr_storage ss; + struct cli_state *ipc_cli; + struct rpc_pipe_client *pipe_hnd; + NTSTATUS nt_status; + SMBCSRV *ipc_srv=NULL; + + /* + * See if we've already created this special connection. Reference + * our "special" share name '*IPC$', which is an impossible real share + * name due to the leading asterisk. + */ + ipc_srv = SMBC_find_server(ctx, context, server, "*IPC$", + pp_workgroup, pp_username, pp_password); + if (!ipc_srv) { + + /* We didn't find a cached connection. Get the password */ + if (!*pp_password || (*pp_password)[0] == '\0') { + /* ... then retrieve it now. */ + SMBC_call_auth_fn(ctx, context, server, share, + pp_workgroup, pp_username, pp_password); + if (!*pp_workgroup || !*pp_username || !*pp_password) { + errno = ENOMEM; + return NULL; + } + } + + flags = 0; + if (context->use_kerberos) { + flags |= CLI_FULL_CONNECTION_USE_KERBEROS; + } + + zero_addr(&ss); + nt_status = cli_full_connection(&ipc_cli, + global_myname(), server, + &ss, 0, "IPC$", "?????", + *pp_username, + *pp_workgroup, + *pp_password, + flags, + Undefined, NULL); + if (! NT_STATUS_IS_OK(nt_status)) { + DEBUG(1,("cli_full_connection failed! (%s)\n", + nt_errstr(nt_status))); + errno = ENOTSUP; + return NULL; + } + + if (context->smb_encryption_level) { + /* Attempt UNIX smb encryption. */ + if (!NT_STATUS_IS_OK(cli_force_encryption(ipc_cli, + *pp_username, + *pp_password, + *pp_workgroup))) { + + /* + * context->smb_encryption_level == + * 1 means don't fail if encryption can't be + * negotiated, == 2 means fail if encryption + * can't be negotiated. + */ + + DEBUG(4,(" SMB encrypt failed on IPC$\n")); + + if (context->smb_encryption_level == 2) { + cli_shutdown(ipc_cli); + errno = EPERM; + return NULL; + } + } + DEBUG(4,(" SMB encrypt ok on IPC$\n")); + } + + ipc_srv = SMB_MALLOC_P(SMBCSRV); + if (!ipc_srv) { + errno = ENOMEM; + cli_shutdown(ipc_cli); + return NULL; + } + + ZERO_STRUCTP(ipc_srv); + ipc_srv->cli = ipc_cli; + + pipe_hnd = cli_rpc_pipe_open_noauth(ipc_srv->cli, + PI_LSARPC, + &nt_status); + if (!pipe_hnd) { + DEBUG(1, ("cli_nt_session_open fail!\n")); + errno = ENOTSUP; + cli_shutdown(ipc_srv->cli); + free(ipc_srv); + return NULL; + } + + /* + * Some systems don't support + * SEC_RIGHTS_MAXIMUM_ALLOWED, but NT sends 0x2000000 + * so we might as well do it too. + */ + + nt_status = rpccli_lsa_open_policy( + pipe_hnd, + talloc_tos(), + True, + GENERIC_EXECUTE_ACCESS, + &ipc_srv->pol); + + if (!NT_STATUS_IS_OK(nt_status)) { + errno = SMBC_errno(context, ipc_srv->cli); + cli_shutdown(ipc_srv->cli); + return NULL; + } + + /* now add it to the cache (internal or external) */ + + errno = 0; /* let cache function set errno if it likes */ + if ((context->cache.add_cached_server_fn)(context, ipc_srv, + server, + "*IPC$", + *pp_workgroup, + *pp_username)) { + DEBUG(3, (" Failed to add server to cache\n")); + if (errno == 0) { + errno = ENOMEM; + } + cli_shutdown(ipc_srv->cli); + free(ipc_srv); + return NULL; + } + + DLIST_ADD(context->servers, ipc_srv); + } + + return ipc_srv; +} diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c new file mode 100644 index 0000000000..06238863b7 --- /dev/null +++ b/source3/libsmb/libsmb_stat.c @@ -0,0 +1,302 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* + * Generate an inode number from file name for those things that need it + */ + +static ino_t +generate_inode(SMBCCTX *context, + const char *name) +{ + if (!context || !context->initialized) { + + errno = EINVAL; + return -1; + + } + + if (!*name) return 2; /* FIXME, why 2 ??? */ + return (ino_t)str_checksum(name); + +} + +/* + * Routine to put basic stat info into a stat structure ... Used by stat and + * fstat below. + */ + +static int +setup_stat(SMBCCTX *context, + struct stat *st, + char *fname, + SMB_OFF_T size, + int mode) +{ + TALLOC_CTX *frame = talloc_stackframe(); + + st->st_mode = 0; + + if (IS_DOS_DIR(mode)) { + st->st_mode = SMBC_DIR_MODE; + } else { + st->st_mode = SMBC_FILE_MODE; + } + + if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR; + if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP; + if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH; + if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR; + + st->st_size = size; +#ifdef HAVE_STAT_ST_BLKSIZE + st->st_blksize = 512; +#endif +#ifdef HAVE_STAT_ST_BLOCKS + st->st_blocks = (size+511)/512; +#endif +#ifdef HAVE_STRUCT_STAT_ST_RDEV + st->st_rdev = 0; +#endif + st->st_uid = getuid(); + st->st_gid = getgid(); + + if (IS_DOS_DIR(mode)) { + st->st_nlink = 2; + } else { + st->st_nlink = 1; + } + + if (st->st_ino == 0) { + st->st_ino = generate_inode(context, fname); + } + + TALLOC_FREE(frame); + return True; /* FIXME: Is this needed ? */ + +} + +/* + * Routine to stat a file given a name + */ + +int +SMBC_stat_ctx(SMBCCTX *context, + const char *fname, + struct stat *st) +{ + SMBCSRV *srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + struct timespec write_time_ts; + struct timespec access_time_ts; + struct timespec change_time_ts; + SMB_OFF_T size = 0; + uint16 mode = 0; + SMB_INO_T ino = 0; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_stat(%s)\n", fname)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame,context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + + if (!srv) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + } + + if (!SMBC_getatr(context, srv, path, &mode, &size, + NULL, + &access_time_ts, + &write_time_ts, + &change_time_ts, + &ino)) { + errno = SMBC_errno(context, srv->cli); + TALLOC_FREE(frame); + return -1; + } + + st->st_ino = ino; + + setup_stat(context, st, (char *) fname, size, mode); + + set_atimespec(st, access_time_ts); + set_ctimespec(st, change_time_ts); + set_mtimespec(st, write_time_ts); + st->st_dev = srv->dev; + + TALLOC_FREE(frame); + return 0; + +} + +/* + * Routine to stat a file given an fd + */ + +int +SMBC_fstat_ctx(SMBCCTX *context, + SMBCFILE *file, + struct stat *st) +{ + struct timespec change_time_ts; + struct timespec access_time_ts; + struct timespec write_time_ts; + SMB_OFF_T size; + uint16 mode; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *path = NULL; + char *targetpath = NULL; + struct cli_state *targetcli = NULL; + SMB_INO_T ino = 0; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!file || !SMBC_dlist_contains(context->files, file)) { + errno = EBADF; + TALLOC_FREE(frame); + return -1; + } + + if (!file->file) { + TALLOC_FREE(frame); + return (context->posix_emu.fstatdir_fn)(context, file, st); + } + + /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ + if (SMBC_parse_path(frame, + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + /*d_printf(">>>fstat: resolving %s\n", path);*/ + if (!cli_resolve_path(frame, "", file->srv->cli, path, + &targetcli, &targetpath)) { + d_printf("Could not resolve %s\n", path); + TALLOC_FREE(frame); + return -1; + } + /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ + + if (!cli_qfileinfo(targetcli, file->cli_fd, &mode, &size, + NULL, + &access_time_ts, + &write_time_ts, + &change_time_ts, + &ino)) { + + time_t change_time, access_time, write_time; + + if (!cli_getattrE(targetcli, file->cli_fd, &mode, &size, + &change_time, &access_time, &write_time)) { + + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + change_time_ts = convert_time_t_to_timespec(change_time); + access_time_ts = convert_time_t_to_timespec(access_time); + write_time_ts = convert_time_t_to_timespec(write_time); + } + + st->st_ino = ino; + + setup_stat(context, st, file->fname, size, mode); + + set_atimespec(st, access_time_ts); + set_ctimespec(st, change_time_ts); + set_mtimespec(st, write_time_ts); + st->st_dev = file->srv->dev; + + TALLOC_FREE(frame); + return 0; + +} diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c new file mode 100644 index 0000000000..93ca0706b2 --- /dev/null +++ b/source3/libsmb/libsmb_xattr.c @@ -0,0 +1,2293 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/* + * Find an lsa pipe handle associated with a cli struct. + */ +static struct rpc_pipe_client * +find_lsa_pipe_hnd(struct cli_state *ipc_cli) +{ + struct rpc_pipe_client *pipe_hnd; + + for (pipe_hnd = ipc_cli->pipe_list; + pipe_hnd; + pipe_hnd = pipe_hnd->next) { + + if (pipe_hnd->pipe_idx == PI_LSARPC) { + return pipe_hnd; + } + } + + return NULL; +} + +/* + * Sort ACEs according to the documentation at + * http://support.microsoft.com/kb/269175, at least as far as it defines the + * order. + */ + +static int +ace_compare(SEC_ACE *ace1, + SEC_ACE *ace2) +{ + bool b1; + bool b2; + + /* If the ACEs are equal, we have nothing more to do. */ + if (sec_ace_equal(ace1, ace2)) { + return 0; + } + + /* Inherited follow non-inherited */ + b1 = ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) != 0); + b2 = ((ace2->flags & SEC_ACE_FLAG_INHERITED_ACE) != 0); + if (b1 != b2) { + return (b1 ? 1 : -1); + } + + /* + * What shall we do with AUDITs and ALARMs? It's undefined. We'll + * sort them after DENY and ALLOW. + */ + b1 = (ace1->type != SEC_ACE_TYPE_ACCESS_ALLOWED && + ace1->type != SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT && + ace1->type != SEC_ACE_TYPE_ACCESS_DENIED && + ace1->type != SEC_ACE_TYPE_ACCESS_DENIED_OBJECT); + b2 = (ace2->type != SEC_ACE_TYPE_ACCESS_ALLOWED && + ace2->type != SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT && + ace2->type != SEC_ACE_TYPE_ACCESS_DENIED && + ace2->type != SEC_ACE_TYPE_ACCESS_DENIED_OBJECT); + if (b1 != b2) { + return (b1 ? 1 : -1); + } + + /* Allowed ACEs follow denied ACEs */ + b1 = (ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED || + ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT); + b2 = (ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED || + ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT); + if (b1 != b2) { + return (b1 ? 1 : -1); + } + + /* + * ACEs applying to an entity's object follow those applying to the + * entity itself + */ + b1 = (ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT || + ace1->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT); + b2 = (ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT || + ace2->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT); + if (b1 != b2) { + return (b1 ? 1 : -1); + } + + /* + * If we get this far, the ACEs are similar as far as the + * characteristics we typically care about (those defined by the + * referenced MS document). We'll now sort by characteristics that + * just seems reasonable. + */ + + if (ace1->type != ace2->type) { + return ace2->type - ace1->type; + } + + if (sid_compare(&ace1->trustee, &ace2->trustee)) { + return sid_compare(&ace1->trustee, &ace2->trustee); + } + + if (ace1->flags != ace2->flags) { + return ace1->flags - ace2->flags; + } + + if (ace1->access_mask != ace2->access_mask) { + return ace1->access_mask - ace2->access_mask; + } + + if (ace1->size != ace2->size) { + return ace1->size - ace2->size; + } + + return memcmp(ace1, ace2, sizeof(SEC_ACE)); +} + + +static void +sort_acl(SEC_ACL *the_acl) +{ + uint32 i; + if (!the_acl) return; + + qsort(the_acl->aces, the_acl->num_aces, sizeof(the_acl->aces[0]), + QSORT_CAST ace_compare); + + for (i=1;inum_aces;) { + if (sec_ace_equal(&the_acl->aces[i-1], &the_acl->aces[i])) { + int j; + for (j=i; jnum_aces-1; j++) { + the_acl->aces[j] = the_acl->aces[j+1]; + } + the_acl->num_aces--; + } else { + i++; + } + } +} + +/* convert a SID to a string, either numeric or username/group */ +static void +convert_sid_to_string(struct cli_state *ipc_cli, + POLICY_HND *pol, + fstring str, + bool numeric, + DOM_SID *sid) +{ + char **domains = NULL; + char **names = NULL; + enum lsa_SidType *types = NULL; + struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli); + TALLOC_CTX *ctx; + + sid_to_fstring(str, sid); + + if (numeric) { + return; /* no lookup desired */ + } + + if (!pipe_hnd) { + return; + } + + /* Ask LSA to convert the sid to a name */ + + ctx = talloc_stackframe(); + + if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(pipe_hnd, ctx, + pol, 1, sid, &domains, + &names, &types)) || + !domains || !domains[0] || !names || !names[0]) { + TALLOC_FREE(ctx); + return; + } + + TALLOC_FREE(ctx); + /* Converted OK */ + + slprintf(str, sizeof(fstring) - 1, "%s%s%s", + domains[0], lp_winbind_separator(), + names[0]); +} + +/* convert a string to a SID, either numeric or username/group */ +static bool +convert_string_to_sid(struct cli_state *ipc_cli, + POLICY_HND *pol, + bool numeric, + DOM_SID *sid, + const char *str) +{ + enum lsa_SidType *types = NULL; + DOM_SID *sids = NULL; + bool result = True; + TALLOC_CTX *ctx = NULL; + struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli); + + if (!pipe_hnd) { + return False; + } + + if (numeric) { + if (strncmp(str, "S-", 2) == 0) { + return string_to_sid(sid, str); + } + + result = False; + goto done; + } + + ctx = talloc_stackframe(); + if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(pipe_hnd, ctx, + pol, 1, &str, NULL, 1, &sids, + &types))) { + result = False; + goto done; + } + + sid_copy(sid, &sids[0]); + done: + + TALLOC_FREE(ctx); + return result; +} + + +/* parse an ACE in the same format as print_ace() */ +static bool +parse_ace(struct cli_state *ipc_cli, + POLICY_HND *pol, + SEC_ACE *ace, + bool numeric, + char *str) +{ + char *p; + const char *cp; + char *tok; + unsigned int atype; + unsigned int aflags; + unsigned int amask; + DOM_SID sid; + SEC_ACCESS mask; + const struct perm_value *v; + struct perm_value { + const char *perm; + uint32 mask; + }; + TALLOC_CTX *frame = talloc_stackframe(); + + /* These values discovered by inspection */ + static const struct perm_value special_values[] = { + { "R", 0x00120089 }, + { "W", 0x00120116 }, + { "X", 0x001200a0 }, + { "D", 0x00010000 }, + { "P", 0x00040000 }, + { "O", 0x00080000 }, + { NULL, 0 }, + }; + + static const struct perm_value standard_values[] = { + { "READ", 0x001200a9 }, + { "CHANGE", 0x001301bf }, + { "FULL", 0x001f01ff }, + { NULL, 0 }, + }; + + + ZERO_STRUCTP(ace); + p = strchr_m(str,':'); + if (!p) { + TALLOC_FREE(frame); + return False; + } + *p = '\0'; + p++; + /* Try to parse numeric form */ + + if (sscanf(p, "%i/%i/%i", &atype, &aflags, &amask) == 3 && + convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) { + goto done; + } + + /* Try to parse text form */ + + if (!convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) { + TALLOC_FREE(frame); + return false; + } + + cp = p; + if (!next_token_talloc(frame, &cp, &tok, "/")) { + TALLOC_FREE(frame); + return false; + } + + if (StrnCaseCmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) { + atype = SEC_ACE_TYPE_ACCESS_ALLOWED; + } else if (StrnCaseCmp(tok, "DENIED", strlen("DENIED")) == 0) { + atype = SEC_ACE_TYPE_ACCESS_DENIED; + } else { + TALLOC_FREE(frame); + return false; + } + + /* Only numeric form accepted for flags at present */ + + if (!(next_token_talloc(frame, &cp, &tok, "/") && + sscanf(tok, "%i", &aflags))) { + TALLOC_FREE(frame); + return false; + } + + if (!next_token_talloc(frame, &cp, &tok, "/")) { + TALLOC_FREE(frame); + return false; + } + + if (strncmp(tok, "0x", 2) == 0) { + if (sscanf(tok, "%i", &amask) != 1) { + TALLOC_FREE(frame); + return false; + } + goto done; + } + + for (v = standard_values; v->perm; v++) { + if (strcmp(tok, v->perm) == 0) { + amask = v->mask; + goto done; + } + } + + p = tok; + + while(*p) { + bool found = False; + + for (v = special_values; v->perm; v++) { + if (v->perm[0] == *p) { + amask |= v->mask; + found = True; + } + } + + if (!found) { + TALLOC_FREE(frame); + return false; + } + p++; + } + + if (*p) { + TALLOC_FREE(frame); + return false; + } + + done: + mask = amask; + init_sec_ace(ace, &sid, atype, mask, aflags); + TALLOC_FREE(frame); + return true; +} + +/* add an ACE to a list of ACEs in a SEC_ACL */ +static bool +add_ace(SEC_ACL **the_acl, + SEC_ACE *ace, + TALLOC_CTX *ctx) +{ + SEC_ACL *newacl; + SEC_ACE *aces; + + if (! *the_acl) { + (*the_acl) = make_sec_acl(ctx, 3, 1, ace); + return True; + } + + if ((aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces)) == NULL) { + return False; + } + memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(SEC_ACE)); + memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE)); + newacl = make_sec_acl(ctx, (*the_acl)->revision, + 1+(*the_acl)->num_aces, aces); + SAFE_FREE(aces); + (*the_acl) = newacl; + return True; +} + + +/* parse a ascii version of a security descriptor */ +static SEC_DESC * +sec_desc_parse(TALLOC_CTX *ctx, + struct cli_state *ipc_cli, + POLICY_HND *pol, + bool numeric, + char *str) +{ + const char *p = str; + char *tok; + SEC_DESC *ret = NULL; + size_t sd_size; + DOM_SID *group_sid=NULL; + DOM_SID *owner_sid=NULL; + SEC_ACL *dacl=NULL; + int revision=1; + + while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) { + + if (StrnCaseCmp(tok,"REVISION:", 9) == 0) { + revision = strtol(tok+9, NULL, 16); + continue; + } + + if (StrnCaseCmp(tok,"OWNER:", 6) == 0) { + if (owner_sid) { + DEBUG(5, ("OWNER specified more than once!\n")); + goto done; + } + owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); + if (!owner_sid || + !convert_string_to_sid(ipc_cli, pol, + numeric, + owner_sid, tok+6)) { + DEBUG(5, ("Failed to parse owner sid\n")); + goto done; + } + continue; + } + + if (StrnCaseCmp(tok,"OWNER+:", 7) == 0) { + if (owner_sid) { + DEBUG(5, ("OWNER specified more than once!\n")); + goto done; + } + owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); + if (!owner_sid || + !convert_string_to_sid(ipc_cli, pol, + False, + owner_sid, tok+7)) { + DEBUG(5, ("Failed to parse owner sid\n")); + goto done; + } + continue; + } + + if (StrnCaseCmp(tok,"GROUP:", 6) == 0) { + if (group_sid) { + DEBUG(5, ("GROUP specified more than once!\n")); + goto done; + } + group_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); + if (!group_sid || + !convert_string_to_sid(ipc_cli, pol, + numeric, + group_sid, tok+6)) { + DEBUG(5, ("Failed to parse group sid\n")); + goto done; + } + continue; + } + + if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) { + if (group_sid) { + DEBUG(5, ("GROUP specified more than once!\n")); + goto done; + } + group_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); + if (!group_sid || + !convert_string_to_sid(ipc_cli, pol, + False, + group_sid, tok+6)) { + DEBUG(5, ("Failed to parse group sid\n")); + goto done; + } + continue; + } + + if (StrnCaseCmp(tok,"ACL:", 4) == 0) { + SEC_ACE ace; + if (!parse_ace(ipc_cli, pol, &ace, numeric, tok+4)) { + DEBUG(5, ("Failed to parse ACL %s\n", tok)); + goto done; + } + if(!add_ace(&dacl, &ace, ctx)) { + DEBUG(5, ("Failed to add ACL %s\n", tok)); + goto done; + } + continue; + } + + if (StrnCaseCmp(tok,"ACL+:", 5) == 0) { + SEC_ACE ace; + if (!parse_ace(ipc_cli, pol, &ace, False, tok+5)) { + DEBUG(5, ("Failed to parse ACL %s\n", tok)); + goto done; + } + if(!add_ace(&dacl, &ace, ctx)) { + DEBUG(5, ("Failed to add ACL %s\n", tok)); + goto done; + } + continue; + } + + DEBUG(5, ("Failed to parse security descriptor\n")); + goto done; + } + + ret = make_sec_desc(ctx, revision, SEC_DESC_SELF_RELATIVE, + owner_sid, group_sid, NULL, dacl, &sd_size); + + done: + SAFE_FREE(group_sid); + SAFE_FREE(owner_sid); + + return ret; +} + + +/* Obtain the current dos attributes */ +static DOS_ATTR_DESC * +dos_attr_query(SMBCCTX *context, + TALLOC_CTX *ctx, + const char *filename, + SMBCSRV *srv) +{ + struct timespec create_time_ts; + struct timespec write_time_ts; + struct timespec access_time_ts; + struct timespec change_time_ts; + SMB_OFF_T size = 0; + uint16 mode = 0; + SMB_INO_T inode = 0; + DOS_ATTR_DESC *ret; + + ret = TALLOC_P(ctx, DOS_ATTR_DESC); + if (!ret) { + errno = ENOMEM; + return NULL; + } + + /* Obtain the DOS attributes */ + if (!SMBC_getatr(context, srv, CONST_DISCARD(char *, filename), + &mode, &size, + &create_time_ts, + &access_time_ts, + &write_time_ts, + &change_time_ts, + &inode)) { + errno = SMBC_errno(context, srv->cli); + DEBUG(5, ("dos_attr_query Failed to query old attributes\n")); + return NULL; + } + + ret->mode = mode; + ret->size = size; + ret->create_time = convert_timespec_to_time_t(create_time_ts); + ret->access_time = convert_timespec_to_time_t(access_time_ts); + ret->write_time = convert_timespec_to_time_t(write_time_ts); + ret->change_time = convert_timespec_to_time_t(change_time_ts); + ret->inode = inode; + + return ret; +} + + +/* parse a ascii version of a security descriptor */ +static void +dos_attr_parse(SMBCCTX *context, + DOS_ATTR_DESC *dad, + SMBCSRV *srv, + char *str) +{ + int n; + const char *p = str; + char *tok = NULL; + TALLOC_CTX *frame = NULL; + struct { + const char * create_time_attr; + const char * access_time_attr; + const char * write_time_attr; + const char * change_time_attr; + } attr_strings; + + /* Determine whether to use old-style or new-style attribute names */ + if (context->full_time_names) { + /* new-style names */ + attr_strings.create_time_attr = "CREATE_TIME"; + attr_strings.access_time_attr = "ACCESS_TIME"; + attr_strings.write_time_attr = "WRITE_TIME"; + attr_strings.change_time_attr = "CHANGE_TIME"; + } else { + /* old-style names */ + attr_strings.create_time_attr = NULL; + attr_strings.access_time_attr = "A_TIME"; + attr_strings.write_time_attr = "M_TIME"; + attr_strings.change_time_attr = "C_TIME"; + } + + /* if this is to set the entire ACL... */ + if (*str == '*') { + /* ... then increment past the first colon if there is one */ + if ((p = strchr(str, ':')) != NULL) { + ++p; + } else { + p = str; + } + } + + frame = talloc_stackframe(); + while (next_token_talloc(frame, &p, &tok, "\t,\r\n")) { + if (StrnCaseCmp(tok, "MODE:", 5) == 0) { + long request = strtol(tok+5, NULL, 16); + if (request == 0) { + dad->mode = (request | + (IS_DOS_DIR(dad->mode) + ? FILE_ATTRIBUTE_DIRECTORY + : FILE_ATTRIBUTE_NORMAL)); + } else { + dad->mode = request; + } + continue; + } + + if (StrnCaseCmp(tok, "SIZE:", 5) == 0) { + dad->size = (SMB_OFF_T)atof(tok+5); + continue; + } + + n = strlen(attr_strings.access_time_attr); + if (StrnCaseCmp(tok, attr_strings.access_time_attr, n) == 0) { + dad->access_time = (time_t)strtol(tok+n+1, NULL, 10); + continue; + } + + n = strlen(attr_strings.change_time_attr); + if (StrnCaseCmp(tok, attr_strings.change_time_attr, n) == 0) { + dad->change_time = (time_t)strtol(tok+n+1, NULL, 10); + continue; + } + + n = strlen(attr_strings.write_time_attr); + if (StrnCaseCmp(tok, attr_strings.write_time_attr, n) == 0) { + dad->write_time = (time_t)strtol(tok+n+1, NULL, 10); + continue; + } + + if (attr_strings.create_time_attr != NULL) { + n = strlen(attr_strings.create_time_attr); + if (StrnCaseCmp(tok, attr_strings.create_time_attr, + n) == 0) { + dad->create_time = (time_t)strtol(tok+n+1, + NULL, 10); + continue; + } + } + + if (StrnCaseCmp(tok, "INODE:", 6) == 0) { + dad->inode = (SMB_INO_T)atof(tok+6); + continue; + } + } + TALLOC_FREE(frame); +} + +/***************************************************** + Retrieve the acls for a file. +*******************************************************/ + +static int +cacl_get(SMBCCTX *context, + TALLOC_CTX *ctx, + SMBCSRV *srv, + struct cli_state *ipc_cli, + POLICY_HND *pol, + char *filename, + char *attr_name, + char *buf, + int bufsize) +{ + uint32 i; + int n = 0; + int n_used; + bool all; + bool all_nt; + bool all_nt_acls; + bool all_dos; + bool some_nt; + bool some_dos; + bool exclude_nt_revision = False; + bool exclude_nt_owner = False; + bool exclude_nt_group = False; + bool exclude_nt_acl = False; + bool exclude_dos_mode = False; + bool exclude_dos_size = False; + bool exclude_dos_create_time = False; + bool exclude_dos_access_time = False; + bool exclude_dos_write_time = False; + bool exclude_dos_change_time = False; + bool exclude_dos_inode = False; + bool numeric = True; + bool determine_size = (bufsize == 0); + int fnum = -1; + SEC_DESC *sd; + fstring sidstr; + fstring name_sandbox; + char *name; + char *pExclude; + char *p; + struct timespec create_time_ts; + struct timespec write_time_ts; + struct timespec access_time_ts; + struct timespec change_time_ts; + time_t create_time = (time_t)0; + time_t write_time = (time_t)0; + time_t access_time = (time_t)0; + time_t change_time = (time_t)0; + SMB_OFF_T size = 0; + uint16 mode = 0; + SMB_INO_T ino = 0; + struct cli_state *cli = srv->cli; + struct { + const char * create_time_attr; + const char * access_time_attr; + const char * write_time_attr; + const char * change_time_attr; + } attr_strings; + struct { + const char * create_time_attr; + const char * access_time_attr; + const char * write_time_attr; + const char * change_time_attr; + } excl_attr_strings; + + /* Determine whether to use old-style or new-style attribute names */ + if (context->full_time_names) { + /* new-style names */ + attr_strings.create_time_attr = "CREATE_TIME"; + attr_strings.access_time_attr = "ACCESS_TIME"; + attr_strings.write_time_attr = "WRITE_TIME"; + attr_strings.change_time_attr = "CHANGE_TIME"; + + excl_attr_strings.create_time_attr = "CREATE_TIME"; + excl_attr_strings.access_time_attr = "ACCESS_TIME"; + excl_attr_strings.write_time_attr = "WRITE_TIME"; + excl_attr_strings.change_time_attr = "CHANGE_TIME"; + } else { + /* old-style names */ + attr_strings.create_time_attr = NULL; + attr_strings.access_time_attr = "A_TIME"; + attr_strings.write_time_attr = "M_TIME"; + attr_strings.change_time_attr = "C_TIME"; + + excl_attr_strings.create_time_attr = NULL; + excl_attr_strings.access_time_attr = "dos_attr.A_TIME"; + excl_attr_strings.write_time_attr = "dos_attr.M_TIME"; + excl_attr_strings.change_time_attr = "dos_attr.C_TIME"; + } + + /* Copy name so we can strip off exclusions (if any are specified) */ + strncpy(name_sandbox, attr_name, sizeof(name_sandbox) - 1); + + /* Ensure name is null terminated */ + name_sandbox[sizeof(name_sandbox) - 1] = '\0'; + + /* Play in the sandbox */ + name = name_sandbox; + + /* If there are any exclusions, point to them and mask them from name */ + if ((pExclude = strchr(name, '!')) != NULL) + { + *pExclude++ = '\0'; + } + + all = (StrnCaseCmp(name, "system.*", 8) == 0); + all_nt = (StrnCaseCmp(name, "system.nt_sec_desc.*", 20) == 0); + all_nt_acls = (StrnCaseCmp(name, "system.nt_sec_desc.acl.*", 24) == 0); + all_dos = (StrnCaseCmp(name, "system.dos_attr.*", 17) == 0); + some_nt = (StrnCaseCmp(name, "system.nt_sec_desc.", 19) == 0); + some_dos = (StrnCaseCmp(name, "system.dos_attr.", 16) == 0); + numeric = (* (name + strlen(name) - 1) != '+'); + + /* Look for exclusions from "all" requests */ + if (all || all_nt || all_dos) { + + /* Exclusions are delimited by '!' */ + for (; + pExclude != NULL; + pExclude = (p == NULL ? NULL : p + 1)) { + + /* Find end of this exclusion name */ + if ((p = strchr(pExclude, '!')) != NULL) + { + *p = '\0'; + } + + /* Which exclusion name is this? */ + if (StrCaseCmp(pExclude, "nt_sec_desc.revision") == 0) { + exclude_nt_revision = True; + } + else if (StrCaseCmp(pExclude, "nt_sec_desc.owner") == 0) { + exclude_nt_owner = True; + } + else if (StrCaseCmp(pExclude, "nt_sec_desc.group") == 0) { + exclude_nt_group = True; + } + else if (StrCaseCmp(pExclude, "nt_sec_desc.acl") == 0) { + exclude_nt_acl = True; + } + else if (StrCaseCmp(pExclude, "dos_attr.mode") == 0) { + exclude_dos_mode = True; + } + else if (StrCaseCmp(pExclude, "dos_attr.size") == 0) { + exclude_dos_size = True; + } + else if (excl_attr_strings.create_time_attr != NULL && + StrCaseCmp(pExclude, + excl_attr_strings.change_time_attr) == 0) { + exclude_dos_create_time = True; + } + else if (StrCaseCmp(pExclude, + excl_attr_strings.access_time_attr) == 0) { + exclude_dos_access_time = True; + } + else if (StrCaseCmp(pExclude, + excl_attr_strings.write_time_attr) == 0) { + exclude_dos_write_time = True; + } + else if (StrCaseCmp(pExclude, + excl_attr_strings.change_time_attr) == 0) { + exclude_dos_change_time = True; + } + else if (StrCaseCmp(pExclude, "dos_attr.inode") == 0) { + exclude_dos_inode = True; + } + else { + DEBUG(5, ("cacl_get received unknown exclusion: %s\n", + pExclude)); + errno = ENOATTR; + return -1; + } + } + } + + n_used = 0; + + /* + * If we are (possibly) talking to an NT or new system and some NT + * attributes have been requested... + */ + if (ipc_cli && (all || some_nt || all_nt_acls)) { + /* Point to the portion after "system.nt_sec_desc." */ + name += 19; /* if (all) this will be invalid but unused */ + + /* ... then obtain any NT attributes which were requested */ + fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ); + + if (fnum == -1) { + DEBUG(5, ("cacl_get failed to open %s: %s\n", + filename, cli_errstr(cli))); + errno = 0; + return -1; + } + + sd = cli_query_secdesc(cli, fnum, ctx); + + if (!sd) { + DEBUG(5, + ("cacl_get Failed to query old descriptor\n")); + errno = 0; + return -1; + } + + cli_close(cli, fnum); + + if (! exclude_nt_revision) { + if (all || all_nt) { + if (determine_size) { + p = talloc_asprintf(ctx, + "REVISION:%d", + sd->revision); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "REVISION:%d", + sd->revision); + } + } else if (StrCaseCmp(name, "revision") == 0) { + if (determine_size) { + p = talloc_asprintf(ctx, "%d", + sd->revision); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, "%d", + sd->revision); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_nt_owner) { + /* Get owner and group sid */ + if (sd->owner_sid) { + convert_sid_to_string(ipc_cli, pol, + sidstr, + numeric, + sd->owner_sid); + } else { + fstrcpy(sidstr, ""); + } + + if (all || all_nt) { + if (determine_size) { + p = talloc_asprintf(ctx, ",OWNER:%s", + sidstr); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else if (sidstr[0] != '\0') { + n = snprintf(buf, bufsize, + ",OWNER:%s", sidstr); + } + } else if (StrnCaseCmp(name, "owner", 5) == 0) { + if (determine_size) { + p = talloc_asprintf(ctx, "%s", sidstr); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, "%s", + sidstr); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_nt_group) { + if (sd->group_sid) { + convert_sid_to_string(ipc_cli, pol, + sidstr, numeric, + sd->group_sid); + } else { + fstrcpy(sidstr, ""); + } + + if (all || all_nt) { + if (determine_size) { + p = talloc_asprintf(ctx, ",GROUP:%s", + sidstr); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else if (sidstr[0] != '\0') { + n = snprintf(buf, bufsize, + ",GROUP:%s", sidstr); + } + } else if (StrnCaseCmp(name, "group", 5) == 0) { + if (determine_size) { + p = talloc_asprintf(ctx, "%s", sidstr); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%s", sidstr); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_nt_acl) { + /* Add aces to value buffer */ + for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) { + + SEC_ACE *ace = &sd->dacl->aces[i]; + convert_sid_to_string(ipc_cli, pol, + sidstr, numeric, + &ace->trustee); + + if (all || all_nt) { + if (determine_size) { + p = talloc_asprintf( + ctx, + ",ACL:" + "%s:%d/%d/0x%08x", + sidstr, + ace->type, + ace->flags, + ace->access_mask); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf( + buf, bufsize, + ",ACL:%s:%d/%d/0x%08x", + sidstr, + ace->type, + ace->flags, + ace->access_mask); + } + } else if ((StrnCaseCmp(name, "acl", 3) == 0 && + StrCaseCmp(name+3, sidstr) == 0) || + (StrnCaseCmp(name, "acl+", 4) == 0 && + StrCaseCmp(name+4, sidstr) == 0)) { + if (determine_size) { + p = talloc_asprintf( + ctx, + "%d/%d/0x%08x", + ace->type, + ace->flags, + ace->access_mask); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%d/%d/0x%08x", + ace->type, + ace->flags, + ace->access_mask); + } + } else if (all_nt_acls) { + if (determine_size) { + p = talloc_asprintf( + ctx, + "%s%s:%d/%d/0x%08x", + i ? "," : "", + sidstr, + ace->type, + ace->flags, + ace->access_mask); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%s%s:%d/%d/0x%08x", + i ? "," : "", + sidstr, + ace->type, + ace->flags, + ace->access_mask); + } + } + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + } + + /* Restore name pointer to its original value */ + name -= 19; + } + + if (all || some_dos) { + /* Point to the portion after "system.dos_attr." */ + name += 16; /* if (all) this will be invalid but unused */ + + /* Obtain the DOS attributes */ + if (!SMBC_getatr(context, srv, filename, &mode, &size, + &create_time_ts, + &access_time_ts, + &write_time_ts, + &change_time_ts, + &ino)) { + + errno = SMBC_errno(context, srv->cli); + return -1; + + } + + create_time = convert_timespec_to_time_t(create_time_ts); + access_time = convert_timespec_to_time_t(access_time_ts); + write_time = convert_timespec_to_time_t(write_time_ts); + change_time = convert_timespec_to_time_t(change_time_ts); + + if (! exclude_dos_mode) { + if (all || all_dos) { + if (determine_size) { + p = talloc_asprintf(ctx, + "%sMODE:0x%x", + (ipc_cli && + (all || some_nt) + ? "," + : ""), + mode); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%sMODE:0x%x", + (ipc_cli && + (all || some_nt) + ? "," + : ""), + mode); + } + } else if (StrCaseCmp(name, "mode") == 0) { + if (determine_size) { + p = talloc_asprintf(ctx, "0x%x", mode); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "0x%x", mode); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_dos_size) { + if (all || all_dos) { + if (determine_size) { + p = talloc_asprintf( + ctx, + ",SIZE:%.0f", + (double)size); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + ",SIZE:%.0f", + (double)size); + } + } else if (StrCaseCmp(name, "size") == 0) { + if (determine_size) { + p = talloc_asprintf( + ctx, + "%.0f", + (double)size); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%.0f", + (double)size); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_dos_create_time && + attr_strings.create_time_attr != NULL) { + if (all || all_dos) { + if (determine_size) { + p = talloc_asprintf(ctx, + ",%s:%lu", + attr_strings.create_time_attr, + create_time); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + ",%s:%lu", + attr_strings.create_time_attr, + create_time); + } + } else if (StrCaseCmp(name, attr_strings.create_time_attr) == 0) { + if (determine_size) { + p = talloc_asprintf(ctx, "%lu", create_time); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%lu", create_time); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_dos_access_time) { + if (all || all_dos) { + if (determine_size) { + p = talloc_asprintf(ctx, + ",%s:%lu", + attr_strings.access_time_attr, + access_time); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + ",%s:%lu", + attr_strings.access_time_attr, + access_time); + } + } else if (StrCaseCmp(name, attr_strings.access_time_attr) == 0) { + if (determine_size) { + p = talloc_asprintf(ctx, "%lu", access_time); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%lu", access_time); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_dos_write_time) { + if (all || all_dos) { + if (determine_size) { + p = talloc_asprintf(ctx, + ",%s:%lu", + attr_strings.write_time_attr, + write_time); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + ",%s:%lu", + attr_strings.write_time_attr, + write_time); + } + } else if (StrCaseCmp(name, attr_strings.write_time_attr) == 0) { + if (determine_size) { + p = talloc_asprintf(ctx, "%lu", write_time); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%lu", write_time); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_dos_change_time) { + if (all || all_dos) { + if (determine_size) { + p = talloc_asprintf(ctx, + ",%s:%lu", + attr_strings.change_time_attr, + change_time); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + ",%s:%lu", + attr_strings.change_time_attr, + change_time); + } + } else if (StrCaseCmp(name, attr_strings.change_time_attr) == 0) { + if (determine_size) { + p = talloc_asprintf(ctx, "%lu", change_time); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%lu", change_time); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + if (! exclude_dos_inode) { + if (all || all_dos) { + if (determine_size) { + p = talloc_asprintf( + ctx, + ",INODE:%.0f", + (double)ino); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + ",INODE:%.0f", + (double) ino); + } + } else if (StrCaseCmp(name, "inode") == 0) { + if (determine_size) { + p = talloc_asprintf( + ctx, + "%.0f", + (double) ino); + if (!p) { + errno = ENOMEM; + return -1; + } + n = strlen(p); + } else { + n = snprintf(buf, bufsize, + "%.0f", + (double) ino); + } + } + + if (!determine_size && n > bufsize) { + errno = ERANGE; + return -1; + } + buf += n; + n_used += n; + bufsize -= n; + n = 0; + } + + /* Restore name pointer to its original value */ + name -= 16; + } + + if (n_used == 0) { + errno = ENOATTR; + return -1; + } + + return n_used; +} + +/***************************************************** +set the ACLs on a file given an ascii description +*******************************************************/ +static int +cacl_set(TALLOC_CTX *ctx, + struct cli_state *cli, + struct cli_state *ipc_cli, + POLICY_HND *pol, + const char *filename, + const char *the_acl, + int mode, + int flags) +{ + int fnum; + int err = 0; + SEC_DESC *sd = NULL, *old; + SEC_ACL *dacl = NULL; + DOM_SID *owner_sid = NULL; + DOM_SID *group_sid = NULL; + uint32 i, j; + size_t sd_size; + int ret = 0; + char *p; + bool numeric = True; + + /* the_acl will be null for REMOVE_ALL operations */ + if (the_acl) { + numeric = ((p = strchr(the_acl, ':')) != NULL && + p > the_acl && + p[-1] != '+'); + + /* if this is to set the entire ACL... */ + if (*the_acl == '*') { + /* ... then increment past the first colon */ + the_acl = p + 1; + } + + sd = sec_desc_parse(ctx, ipc_cli, pol, numeric, + CONST_DISCARD(char *, the_acl)); + + if (!sd) { + errno = EINVAL; + return -1; + } + } + + /* SMBC_XATTR_MODE_REMOVE_ALL is the only caller + that doesn't deref sd */ + + if (!sd && (mode != SMBC_XATTR_MODE_REMOVE_ALL)) { + errno = EINVAL; + return -1; + } + + /* The desired access below is the only one I could find that works + with NT4, W2KP and Samba */ + + fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ); + + if (fnum == -1) { + DEBUG(5, ("cacl_set failed to open %s: %s\n", + filename, cli_errstr(cli))); + errno = 0; + return -1; + } + + old = cli_query_secdesc(cli, fnum, ctx); + + if (!old) { + DEBUG(5, ("cacl_set Failed to query old descriptor\n")); + errno = 0; + return -1; + } + + cli_close(cli, fnum); + + switch (mode) { + case SMBC_XATTR_MODE_REMOVE_ALL: + old->dacl->num_aces = 0; + dacl = old->dacl; + break; + + case SMBC_XATTR_MODE_REMOVE: + for (i=0;sd->dacl && idacl->num_aces;i++) { + bool found = False; + + for (j=0;old->dacl && jdacl->num_aces;j++) { + if (sec_ace_equal(&sd->dacl->aces[i], + &old->dacl->aces[j])) { + uint32 k; + for (k=j; kdacl->num_aces-1;k++) { + old->dacl->aces[k] = + old->dacl->aces[k+1]; + } + old->dacl->num_aces--; + found = True; + dacl = old->dacl; + break; + } + } + + if (!found) { + err = ENOATTR; + ret = -1; + goto failed; + } + } + break; + + case SMBC_XATTR_MODE_ADD: + for (i=0;sd->dacl && idacl->num_aces;i++) { + bool found = False; + + for (j=0;old->dacl && jdacl->num_aces;j++) { + if (sid_equal(&sd->dacl->aces[i].trustee, + &old->dacl->aces[j].trustee)) { + if (!(flags & SMBC_XATTR_FLAG_CREATE)) { + err = EEXIST; + ret = -1; + goto failed; + } + old->dacl->aces[j] = sd->dacl->aces[i]; + ret = -1; + found = True; + } + } + + if (!found && (flags & SMBC_XATTR_FLAG_REPLACE)) { + err = ENOATTR; + ret = -1; + goto failed; + } + + for (i=0;sd->dacl && idacl->num_aces;i++) { + add_ace(&old->dacl, &sd->dacl->aces[i], ctx); + } + } + dacl = old->dacl; + break; + + case SMBC_XATTR_MODE_SET: + old = sd; + owner_sid = old->owner_sid; + group_sid = old->group_sid; + dacl = old->dacl; + break; + + case SMBC_XATTR_MODE_CHOWN: + owner_sid = sd->owner_sid; + break; + + case SMBC_XATTR_MODE_CHGRP: + group_sid = sd->group_sid; + break; + } + + /* Denied ACE entries must come before allowed ones */ + sort_acl(old->dacl); + + /* Create new security descriptor and set it */ + sd = make_sec_desc(ctx, old->revision, SEC_DESC_SELF_RELATIVE, + owner_sid, group_sid, NULL, dacl, &sd_size); + + fnum = cli_nt_create(cli, filename, + WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS); + + if (fnum == -1) { + DEBUG(5, ("cacl_set failed to open %s: %s\n", + filename, cli_errstr(cli))); + errno = 0; + return -1; + } + + if (!cli_set_secdesc(cli, fnum, sd)) { + DEBUG(5, ("ERROR: secdesc set failed: %s\n", cli_errstr(cli))); + ret = -1; + } + + /* Clean up */ + + failed: + cli_close(cli, fnum); + + if (err != 0) { + errno = err; + } + + return ret; +} + + +int +SMBC_setxattr_ctx(SMBCCTX *context, + const char *fname, + const char *name, + const void *value, + size_t size, + int flags) +{ + int ret; + int ret2; + SMBCSRV *srv = NULL; + SMBCSRV *ipc_srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + DOS_ATTR_DESC *dad = NULL; + struct { + const char * create_time_attr; + const char * access_time_attr; + const char * write_time_attr; + const char * change_time_attr; + } attr_strings; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_setxattr(%s, %s, %.*s)\n", + fname, name, (int) size, (const char*)value)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + if (!srv) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + } + + if (! srv->no_nt_session) { + ipc_srv = SMBC_attr_server(frame, context, server, share, + &workgroup, &user, &password); + if (! ipc_srv) { + srv->no_nt_session = True; + } + } else { + ipc_srv = NULL; + } + + /* + * Are they asking to set the entire set of known attributes? + */ + if (StrCaseCmp(name, "system.*") == 0 || + StrCaseCmp(name, "system.*+") == 0) { + /* Yup. */ + char *namevalue = + talloc_asprintf(talloc_tos(), "%s:%s", + name+7, (const char *) value); + if (! namevalue) { + errno = ENOMEM; + ret = -1; + TALLOC_FREE(frame); + return -1; + } + + if (ipc_srv) { + ret = cacl_set(talloc_tos(), srv->cli, + ipc_srv->cli, &ipc_srv->pol, path, + namevalue, + (*namevalue == '*' + ? SMBC_XATTR_MODE_SET + : SMBC_XATTR_MODE_ADD), + flags); + } else { + ret = 0; + } + + /* get a DOS Attribute Descriptor with current attributes */ + dad = dos_attr_query(context, talloc_tos(), path, srv); + if (dad) { + /* Overwrite old with new, using what was provided */ + dos_attr_parse(context, dad, srv, namevalue); + + /* Set the new DOS attributes */ + if (! SMBC_setatr(context, srv, path, + dad->create_time, + dad->access_time, + dad->write_time, + dad->change_time, + dad->mode)) { + + /* cause failure if NT failed too */ + dad = NULL; + } + } + + /* we only fail if both NT and DOS sets failed */ + if (ret < 0 && ! dad) { + ret = -1; /* in case dad was null */ + } + else { + ret = 0; + } + + TALLOC_FREE(frame); + return ret; + } + + /* + * Are they asking to set an access control element or to set + * the entire access control list? + */ + if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 || + StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 || + StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) { + + /* Yup. */ + char *namevalue = + talloc_asprintf(talloc_tos(), "%s:%s", + name+19, (const char *) value); + + if (! ipc_srv) { + ret = -1; /* errno set by SMBC_server() */ + } + else if (! namevalue) { + errno = ENOMEM; + ret = -1; + } else { + ret = cacl_set(talloc_tos(), srv->cli, + ipc_srv->cli, &ipc_srv->pol, path, + namevalue, + (*namevalue == '*' + ? SMBC_XATTR_MODE_SET + : SMBC_XATTR_MODE_ADD), + flags); + } + TALLOC_FREE(frame); + return ret; + } + + /* + * Are they asking to set the owner? + */ + if (StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0) { + + /* Yup. */ + char *namevalue = + talloc_asprintf(talloc_tos(), "%s:%s", + name+19, (const char *) value); + + if (! ipc_srv) { + ret = -1; /* errno set by SMBC_server() */ + } + else if (! namevalue) { + errno = ENOMEM; + ret = -1; + } else { + ret = cacl_set(talloc_tos(), srv->cli, + ipc_srv->cli, &ipc_srv->pol, path, + namevalue, SMBC_XATTR_MODE_CHOWN, 0); + } + TALLOC_FREE(frame); + return ret; + } + + /* + * Are they asking to set the group? + */ + if (StrCaseCmp(name, "system.nt_sec_desc.group") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.group+") == 0) { + + /* Yup. */ + char *namevalue = + talloc_asprintf(talloc_tos(), "%s:%s", + name+19, (const char *) value); + + if (! ipc_srv) { + /* errno set by SMBC_server() */ + ret = -1; + } + else if (! namevalue) { + errno = ENOMEM; + ret = -1; + } else { + ret = cacl_set(talloc_tos(), srv->cli, + ipc_srv->cli, &ipc_srv->pol, path, + namevalue, SMBC_XATTR_MODE_CHGRP, 0); + } + TALLOC_FREE(frame); + return ret; + } + + /* Determine whether to use old-style or new-style attribute names */ + if (context->full_time_names) { + /* new-style names */ + attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME"; + attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME"; + attr_strings.write_time_attr = "system.dos_attr.WRITE_TIME"; + attr_strings.change_time_attr = "system.dos_attr.CHANGE_TIME"; + } else { + /* old-style names */ + attr_strings.create_time_attr = NULL; + attr_strings.access_time_attr = "system.dos_attr.A_TIME"; + attr_strings.write_time_attr = "system.dos_attr.M_TIME"; + attr_strings.change_time_attr = "system.dos_attr.C_TIME"; + } + + /* + * Are they asking to set a DOS attribute? + */ + if (StrCaseCmp(name, "system.dos_attr.*") == 0 || + StrCaseCmp(name, "system.dos_attr.mode") == 0 || + (attr_strings.create_time_attr != NULL && + StrCaseCmp(name, attr_strings.create_time_attr) == 0) || + StrCaseCmp(name, attr_strings.access_time_attr) == 0 || + StrCaseCmp(name, attr_strings.write_time_attr) == 0 || + StrCaseCmp(name, attr_strings.change_time_attr) == 0) { + + /* get a DOS Attribute Descriptor with current attributes */ + dad = dos_attr_query(context, talloc_tos(), path, srv); + if (dad) { + char *namevalue = + talloc_asprintf(talloc_tos(), "%s:%s", + name+16, (const char *) value); + if (! namevalue) { + errno = ENOMEM; + ret = -1; + } else { + /* Overwrite old with provided new params */ + dos_attr_parse(context, dad, srv, namevalue); + + /* Set the new DOS attributes */ + ret2 = SMBC_setatr(context, srv, path, + dad->create_time, + dad->access_time, + dad->write_time, + dad->change_time, + dad->mode); + + /* ret2 has True (success) / False (failure) */ + if (ret2) { + ret = 0; + } else { + ret = -1; + } + } + } else { + ret = -1; + } + + TALLOC_FREE(frame); + return ret; + } + + /* Unsupported attribute name */ + errno = EINVAL; + TALLOC_FREE(frame); + return -1; +} + +int +SMBC_getxattr_ctx(SMBCCTX *context, + const char *fname, + const char *name, + const void *value, + size_t size) +{ + int ret; + SMBCSRV *srv = NULL; + SMBCSRV *ipc_srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + struct { + const char * create_time_attr; + const char * access_time_attr; + const char * write_time_attr; + const char * change_time_attr; + } attr_strings; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_getxattr(%s, %s)\n", fname, name)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + if (!srv) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + } + + if (! srv->no_nt_session) { + ipc_srv = SMBC_attr_server(frame, context, server, share, + &workgroup, &user, &password); + if (! ipc_srv) { + srv->no_nt_session = True; + } + } else { + ipc_srv = NULL; + } + + /* Determine whether to use old-style or new-style attribute names */ + if (context->full_time_names) { + /* new-style names */ + attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME"; + attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME"; + attr_strings.write_time_attr = "system.dos_attr.WRITE_TIME"; + attr_strings.change_time_attr = "system.dos_attr.CHANGE_TIME"; + } else { + /* old-style names */ + attr_strings.create_time_attr = NULL; + attr_strings.access_time_attr = "system.dos_attr.A_TIME"; + attr_strings.write_time_attr = "system.dos_attr.M_TIME"; + attr_strings.change_time_attr = "system.dos_attr.C_TIME"; + } + + /* Are they requesting a supported attribute? */ + if (StrCaseCmp(name, "system.*") == 0 || + StrnCaseCmp(name, "system.*!", 9) == 0 || + StrCaseCmp(name, "system.*+") == 0 || + StrnCaseCmp(name, "system.*+!", 10) == 0 || + StrCaseCmp(name, "system.nt_sec_desc.*") == 0 || + StrnCaseCmp(name, "system.nt_sec_desc.*!", 21) == 0 || + StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 || + StrnCaseCmp(name, "system.nt_sec_desc.*+!", 22) == 0 || + StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.group") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 || + StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 || + StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0 || + StrCaseCmp(name, "system.dos_attr.*") == 0 || + StrnCaseCmp(name, "system.dos_attr.*!", 18) == 0 || + StrCaseCmp(name, "system.dos_attr.mode") == 0 || + StrCaseCmp(name, "system.dos_attr.size") == 0 || + (attr_strings.create_time_attr != NULL && + StrCaseCmp(name, attr_strings.create_time_attr) == 0) || + StrCaseCmp(name, attr_strings.access_time_attr) == 0 || + StrCaseCmp(name, attr_strings.write_time_attr) == 0 || + StrCaseCmp(name, attr_strings.change_time_attr) == 0 || + StrCaseCmp(name, "system.dos_attr.inode") == 0) { + + /* Yup. */ + ret = cacl_get(context, talloc_tos(), srv, + ipc_srv == NULL ? NULL : ipc_srv->cli, + &ipc_srv->pol, path, + CONST_DISCARD(char *, name), + CONST_DISCARD(char *, value), size); + if (ret < 0 && errno == 0) { + errno = SMBC_errno(context, srv->cli); + } + TALLOC_FREE(frame); + return ret; + } + + /* Unsupported attribute name */ + errno = EINVAL; + TALLOC_FREE(frame); + return -1; +} + + +int +SMBC_removexattr_ctx(SMBCCTX *context, + const char *fname, + const char *name) +{ + int ret; + SMBCSRV *srv = NULL; + SMBCSRV *ipc_srv = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; + char *path = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!context || !context->initialized) { + + errno = EINVAL; /* Best I can think of ... */ + TALLOC_FREE(frame); + return -1; + } + + if (!fname) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + DEBUG(4, ("smbc_removexattr(%s, %s)\n", fname, name)); + + if (SMBC_parse_path(frame, + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } + + if (!user || user[0] == (char)0) { + user = talloc_strdup(frame, context->user); + if (!user) { + errno = ENOMEM; + TALLOC_FREE(frame); + return -1; + } + } + + srv = SMBC_server(frame, context, True, + server, share, &workgroup, &user, &password); + if (!srv) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_server */ + } + + if (! srv->no_nt_session) { + ipc_srv = SMBC_attr_server(frame, context, server, share, + &workgroup, &user, &password); + if (! ipc_srv) { + srv->no_nt_session = True; + } + } else { + ipc_srv = NULL; + } + + if (! ipc_srv) { + TALLOC_FREE(frame); + return -1; /* errno set by SMBC_attr_server */ + } + + /* Are they asking to set the entire ACL? */ + if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.*+") == 0) { + + /* Yup. */ + ret = cacl_set(talloc_tos(), srv->cli, + ipc_srv->cli, &ipc_srv->pol, path, + NULL, SMBC_XATTR_MODE_REMOVE_ALL, 0); + TALLOC_FREE(frame); + return ret; + } + + /* + * Are they asking to remove one or more spceific security descriptor + * attributes? + */ + if (StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.group") == 0 || + StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 || + StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 || + StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) { + + /* Yup. */ + ret = cacl_set(talloc_tos(), srv->cli, + ipc_srv->cli, &ipc_srv->pol, path, + name + 19, SMBC_XATTR_MODE_REMOVE, 0); + TALLOC_FREE(frame); + return ret; + } + + /* Unsupported attribute name */ + errno = EINVAL; + TALLOC_FREE(frame); + return -1; +} + +int +SMBC_listxattr_ctx(SMBCCTX *context, + const char *fname, + char *list, + size_t size) +{ + /* + * This isn't quite what listxattr() is supposed to do. This returns + * the complete set of attribute names, always, rather than only those + * attribute names which actually exist for a file. Hmmm... + */ + size_t retsize; + const char supported_old[] = + "system.*\0" + "system.*+\0" + "system.nt_sec_desc.revision\0" + "system.nt_sec_desc.owner\0" + "system.nt_sec_desc.owner+\0" + "system.nt_sec_desc.group\0" + "system.nt_sec_desc.group+\0" + "system.nt_sec_desc.acl.*\0" + "system.nt_sec_desc.acl\0" + "system.nt_sec_desc.acl+\0" + "system.nt_sec_desc.*\0" + "system.nt_sec_desc.*+\0" + "system.dos_attr.*\0" + "system.dos_attr.mode\0" + "system.dos_attr.c_time\0" + "system.dos_attr.a_time\0" + "system.dos_attr.m_time\0" + ; + const char supported_new[] = + "system.*\0" + "system.*+\0" + "system.nt_sec_desc.revision\0" + "system.nt_sec_desc.owner\0" + "system.nt_sec_desc.owner+\0" + "system.nt_sec_desc.group\0" + "system.nt_sec_desc.group+\0" + "system.nt_sec_desc.acl.*\0" + "system.nt_sec_desc.acl\0" + "system.nt_sec_desc.acl+\0" + "system.nt_sec_desc.*\0" + "system.nt_sec_desc.*+\0" + "system.dos_attr.*\0" + "system.dos_attr.mode\0" + "system.dos_attr.create_time\0" + "system.dos_attr.access_time\0" + "system.dos_attr.write_time\0" + "system.dos_attr.change_time\0" + ; + const char * supported; + + if (context->full_time_names) { + supported = supported_new; + retsize = sizeof(supported_new); + } else { + supported = supported_old; + retsize = sizeof(supported_old); + } + + if (size == 0) { + return retsize; + } + + if (retsize > size) { + errno = ERANGE; + return -1; + } + + /* this can't be strcpy() because there are embedded null characters */ + memcpy(list, supported, retsize); + return retsize; +} diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c deleted file mode 100644 index fe008ed6b6..0000000000 --- a/source3/libsmb/libsmbclient.c +++ /dev/null @@ -1,7233 +0,0 @@ -/* - Unix SMB/Netbios implementation. - SMB client library implementation - Copyright (C) Andrew Tridgell 1998 - Copyright (C) Richard Sharpe 2000, 2002 - Copyright (C) John Terpstra 2000 - Copyright (C) Tom Jansen (Ninja ISD) 2002 - Copyright (C) Derrell Lipman 2003, 2004 - Copyright (C) Jeremy Allison 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 - 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 "includes.h" - -#include "include/libsmb_internal.h" - -struct smbc_dirent *smbc_readdir_ctx(SMBCCTX *context, SMBCFILE *dir); -struct smbc_dir_list *smbc_check_dir_ent(struct smbc_dir_list *list, - struct smbc_dirent *dirent); - -/* - * DOS Attribute values (used internally) - */ -typedef struct DOS_ATTR_DESC { - int mode; - SMB_OFF_T size; - time_t create_time; - time_t access_time; - time_t write_time; - time_t change_time; - SMB_INO_T inode; -} DOS_ATTR_DESC; - - -/* - * Internal flags for extended attributes - */ - -/* internal mode values */ -#define SMBC_XATTR_MODE_ADD 1 -#define SMBC_XATTR_MODE_REMOVE 2 -#define SMBC_XATTR_MODE_REMOVE_ALL 3 -#define SMBC_XATTR_MODE_SET 4 -#define SMBC_XATTR_MODE_CHOWN 5 -#define SMBC_XATTR_MODE_CHGRP 6 - -#define CREATE_ACCESS_READ READ_CONTROL_ACCESS - -/*We should test for this in configure ... */ -#ifndef ENOTSUP -#define ENOTSUP EOPNOTSUPP -#endif - -/* - * Functions exported by libsmb_cache.c that we need here - */ -int smbc_default_cache_functions(SMBCCTX *context); - -/* - * check if an element is part of the list. - * FIXME: Does not belong here ! - * Can anyone put this in a macro in dlinklist.h ? - * -- Tom - */ -static int DLIST_CONTAINS(SMBCFILE * list, SMBCFILE *p) { - if (!p || !list) return False; - do { - if (p == list) return True; - list = list->next; - } while (list); - return False; -} - -/* - * Find an lsa pipe handle associated with a cli struct. - */ -static struct rpc_pipe_client * -find_lsa_pipe_hnd(struct cli_state *ipc_cli) -{ - struct rpc_pipe_client *pipe_hnd; - - for (pipe_hnd = ipc_cli->pipe_list; - pipe_hnd; - pipe_hnd = pipe_hnd->next) { - - if (pipe_hnd->pipe_idx == PI_LSARPC) { - return pipe_hnd; - } - } - - return NULL; -} - -static int -smbc_close_ctx(SMBCCTX *context, - SMBCFILE *file); -static off_t -smbc_lseek_ctx(SMBCCTX *context, - SMBCFILE *file, - off_t offset, - int whence); - -extern bool in_client; - -/* - * Is the logging working / configfile read ? - */ -static int smbc_initialized = 0; - -static int -hex2int( unsigned int _char ) -{ - if ( _char >= 'A' && _char <='F') - return _char - 'A' + 10; - if ( _char >= 'a' && _char <='f') - return _char - 'a' + 10; - if ( _char >= '0' && _char <='9') - return _char - '0'; - return -1; -} - -/* - * smbc_urldecode() - * and smbc_urldecode_talloc() (internal fn.) - * - * Convert strings of %xx to their single character equivalent. Each 'x' must - * be a valid hexadecimal digit, or that % sequence is left undecoded. - * - * dest may, but need not be, the same pointer as src. - * - * Returns the number of % sequences which could not be converted due to lack - * of two following hexadecimal digits. - */ -static int -smbc_urldecode_talloc(TALLOC_CTX *ctx, char **pp_dest, const char *src) -{ - int old_length = strlen(src); - int i = 0; - int err_count = 0; - size_t newlen = 1; - char *p, *dest; - - if (old_length == 0) { - return 0; - } - - *pp_dest = NULL; - for (i = 0; i < old_length; ) { - unsigned char character = src[i++]; - - if (character == '%') { - int a = i+1 < old_length ? hex2int(src[i]) : -1; - int b = i+1 < old_length ? hex2int(src[i+1]) : -1; - - /* Replace valid sequence */ - if (a != -1 && b != -1) { - /* Replace valid %xx sequence with %dd */ - character = (a * 16) + b; - if (character == '\0') { - break; /* Stop at %00 */ - } - i += 2; - } else { - err_count++; - } - } - newlen++; - } - - dest = TALLOC_ARRAY(ctx, char, newlen); - if (!dest) { - return err_count; - } - - err_count = 0; - for (p = dest, i = 0; i < old_length; ) { - unsigned char character = src[i++]; - - if (character == '%') { - int a = i+1 < old_length ? hex2int(src[i]) : -1; - int b = i+1 < old_length ? hex2int(src[i+1]) : -1; - - /* Replace valid sequence */ - if (a != -1 && b != -1) { - /* Replace valid %xx sequence with %dd */ - character = (a * 16) + b; - if (character == '\0') { - break; /* Stop at %00 */ - } - i += 2; - } else { - err_count++; - } - } - *p++ = character; - } - - *p = '\0'; - *pp_dest = dest; - return err_count; -} - -int -smbc_urldecode(char *dest, char *src, size_t max_dest_len) -{ - TALLOC_CTX *frame = talloc_stackframe(); - char *pdest; - int ret = smbc_urldecode_talloc(frame, &pdest, src); - - if (pdest) { - strlcpy(dest, pdest, max_dest_len); - } - TALLOC_FREE(frame); - return ret; -} - -/* - * smbc_urlencode() - * - * Convert any characters not specifically allowed in a URL into their %xx - * equivalent. - * - * Returns the remaining buffer length. - */ -int -smbc_urlencode(char *dest, char *src, int max_dest_len) -{ - char hex[] = "0123456789ABCDEF"; - - for (; *src != '\0' && max_dest_len >= 3; src++) { - - if ((*src < '0' && - *src != '-' && - *src != '.') || - (*src > '9' && - *src < 'A') || - (*src > 'Z' && - *src < 'a' && - *src != '_') || - (*src > 'z')) { - *dest++ = '%'; - *dest++ = hex[(*src >> 4) & 0x0f]; - *dest++ = hex[*src & 0x0f]; - max_dest_len -= 3; - } else { - *dest++ = *src; - max_dest_len--; - } - } - - *dest++ = '\0'; - max_dest_len--; - - return max_dest_len; -} - -/* - * Function to parse a path and turn it into components - * - * The general format of an SMB URI is explain in Christopher Hertel's CIFS - * book, at http://ubiqx.org/cifs/Appendix-D.html. We accept a subset of the - * general format ("smb:" only; we do not look for "cifs:"). - * - * - * We accept: - * smb://[[[domain;]user[:password]@]server[/share[/path[/file]]]][?options] - * - * Meaning of URLs: - * - * smb:// Show all workgroups. - * - * The method of locating the list of workgroups varies - * depending upon the setting of the context variable - * context->options.browse_max_lmb_count. This value - * determine the maximum number of local master browsers to - * query for the list of workgroups. In order to ensure that - * a complete list of workgroups is obtained, all master - * browsers must be queried, but if there are many - * workgroups, the time spent querying can begin to add up. - * For small networks (not many workgroups), it is suggested - * that this variable be set to 0, indicating query all local - * master browsers. When the network has many workgroups, a - * reasonable setting for this variable might be around 3. - * - * smb://name/ if name<1D> or name<1B> exists, list servers in - * workgroup, else, if name<20> exists, list all shares - * for server ... - * - * If "options" are provided, this function returns the entire option list as a - * string, for later parsing by the caller. Note that currently, no options - * are supported. - */ - -static const char *smbc_prefix = "smb:"; - -static int -smbc_parse_path(TALLOC_CTX *ctx, - SMBCCTX *context, - const char *fname, - char **pp_workgroup, - char **pp_server, - char **pp_share, - char **pp_path, - char **pp_user, - char **pp_password, - char **pp_options) -{ - char *s; - const char *p; - char *q, *r; - int len; - - /* Ensure these returns are at least valid pointers. */ - *pp_server = talloc_strdup(ctx, ""); - *pp_share = talloc_strdup(ctx, ""); - *pp_path = talloc_strdup(ctx, ""); - *pp_user = talloc_strdup(ctx, ""); - *pp_password = talloc_strdup(ctx, ""); - - if (!*pp_server || !*pp_share || !*pp_path || - !*pp_user || !*pp_password) { - return -1; - } - - /* - * Assume we wont find an authentication domain to parse, so default - * to the workgroup in the provided context. - */ - if (pp_workgroup != NULL) { - *pp_workgroup = talloc_strdup(ctx, context->workgroup); - } - - if (pp_options) { - *pp_options = talloc_strdup(ctx, ""); - } - s = talloc_strdup(ctx, fname); - - /* see if it has the right prefix */ - len = strlen(smbc_prefix); - if (strncmp(s,smbc_prefix,len) || (s[len] != '/' && s[len] != 0)) { - return -1; /* What about no smb: ? */ - } - - p = s + len; - - /* Watch the test below, we are testing to see if we should exit */ - - if (strncmp(p, "//", 2) && strncmp(p, "\\\\", 2)) { - DEBUG(1, ("Invalid path (does not begin with smb://")); - return -1; - } - - p += 2; /* Skip the double slash */ - - /* See if any options were specified */ - if ((q = strrchr(p, '?')) != NULL ) { - /* There are options. Null terminate here and point to them */ - *q++ = '\0'; - - DEBUG(4, ("Found options '%s'", q)); - - /* Copy the options */ - if (*pp_options != NULL) { - TALLOC_FREE(*pp_options); - *pp_options = talloc_strdup(ctx, q); - } - } - - if (*p == '\0') { - goto decoding; - } - - if (*p == '/') { - int wl = strlen(context->workgroup); - - if (wl > 16) { - wl = 16; - } - - *pp_server = talloc_strdup(ctx, context->workgroup); - if (!*pp_server) { - return -1; - } - *pp_server[wl] = '\0'; - return 0; - } - - /* - * ok, its for us. Now parse out the server, share etc. - * - * However, we want to parse out [[domain;]user[:password]@] if it - * exists ... - */ - - /* check that '@' occurs before '/', if '/' exists at all */ - q = strchr_m(p, '@'); - r = strchr_m(p, '/'); - if (q && (!r || q < r)) { - char *userinfo = NULL; - const char *u; - - next_token_no_ltrim_talloc(ctx, &p, &userinfo, "@"); - if (!userinfo) { - return -1; - } - u = userinfo; - - if (strchr_m(u, ';')) { - char *workgroup; - next_token_no_ltrim_talloc(ctx, &u, &workgroup, ";"); - if (!workgroup) { - return -1; - } - if (pp_workgroup) { - *pp_workgroup = workgroup; - } - } - - if (strchr_m(u, ':')) { - next_token_no_ltrim_talloc(ctx, &u, pp_user, ":"); - if (!*pp_user) { - return -1; - } - *pp_password = talloc_strdup(ctx, u); - if (!*pp_password) { - return -1; - } - } else { - *pp_user = talloc_strdup(ctx, u); - if (!*pp_user) { - return -1; - } - } - } - - if (!next_token_talloc(ctx, &p, pp_server, "/")) { - return -1; - } - - if (*p == (char)0) { - goto decoding; /* That's it ... */ - } - - if (!next_token_talloc(ctx, &p, pp_share, "/")) { - return -1; - } - - /* - * Prepend a leading slash if there's a file path, as required by - * NetApp filers. - */ - if (*p != '\0') { - *pp_path = talloc_asprintf(ctx, - "\\%s", - p); - } else { - *pp_path = talloc_strdup(ctx, ""); - } - if (!*pp_path) { - return -1; - } - string_replace(*pp_path, '/', '\\'); - - decoding: - - (void) smbc_urldecode_talloc(ctx, pp_path, *pp_path); - (void) smbc_urldecode_talloc(ctx, pp_server, *pp_server); - (void) smbc_urldecode_talloc(ctx, pp_share, *pp_share); - (void) smbc_urldecode_talloc(ctx, pp_user, *pp_user); - (void) smbc_urldecode_talloc(ctx, pp_password, *pp_password); - - return 0; -} - -/* - * Verify that the options specified in a URL are valid - */ -static int -smbc_check_options(char *server, - char *share, - char *path, - char *options) -{ - DEBUG(4, ("smbc_check_options(): server='%s' share='%s' " - "path='%s' options='%s'\n", - server, share, path, options)); - - /* No options at all is always ok */ - if (! *options) return 0; - - /* Currently, we don't support any options. */ - return -1; -} - -/* - * Convert an SMB error into a UNIX error ... - */ -static int -smbc_errno(SMBCCTX *context, - struct cli_state *c) -{ - int ret = cli_errno(c); - - if (cli_is_dos_error(c)) { - uint8 eclass; - uint32 ecode; - - cli_dos_error(c, &eclass, &ecode); - - DEBUG(3,("smbc_error %d %d (0x%x) -> %d\n", - (int)eclass, (int)ecode, (int)ecode, ret)); - } else { - NTSTATUS status; - - status = cli_nt_error(c); - - DEBUG(3,("smbc errno %s -> %d\n", - nt_errstr(status), ret)); - } - - return ret; -} - -/* - * Check a server for being alive and well. - * returns 0 if the server is in shape. Returns 1 on error - * - * Also useable outside libsmbclient to enable external cache - * to do some checks too. - */ -static int -smbc_check_server(SMBCCTX * context, - SMBCSRV * server) -{ - socklen_t size; - struct sockaddr addr; - - size = sizeof(addr); - return (getpeername(server->cli->fd, &addr, &size) == -1); -} - -/* - * Remove a server from the cached server list it's unused. - * On success, 0 is returned. 1 is returned if the server could not be removed. - * - * Also useable outside libsmbclient - */ -int -smbc_remove_unused_server(SMBCCTX * context, - SMBCSRV * srv) -{ - SMBCFILE * file; - - /* are we being fooled ? */ - if (!context || !context->internal || - !context->internal->_initialized || !srv) return 1; - - - /* Check all open files/directories for a relation with this server */ - for (file = context->internal->_files; file; file=file->next) { - if (file->srv == srv) { - /* Still used */ - DEBUG(3, ("smbc_remove_usused_server: " - "%p still used by %p.\n", - srv, file)); - return 1; - } - } - - DLIST_REMOVE(context->internal->_servers, srv); - - cli_shutdown(srv->cli); - srv->cli = NULL; - - DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv)); - - (context->callbacks.remove_cached_srv_fn)(context, srv); - - SAFE_FREE(srv); - return 0; -} - -/**************************************************************** - * Call the auth_fn with fixed size (fstring) buffers. - ***************************************************************/ - -static void call_auth_fn(TALLOC_CTX *ctx, - SMBCCTX *context, - const char *server, - const char *share, - char **pp_workgroup, - char **pp_username, - char **pp_password) -{ - fstring workgroup; - fstring username; - fstring password; - - strlcpy(workgroup, *pp_workgroup, sizeof(workgroup)); - strlcpy(username, *pp_username, sizeof(username)); - strlcpy(password, *pp_password, sizeof(password)); - - if (context->internal->_auth_fn_with_context != NULL) { - (context->internal->_auth_fn_with_context)( - context, - server, share, - workgroup, sizeof(workgroup), - username, sizeof(username), - password, sizeof(password)); - } else { - (context->callbacks.auth_fn)( - server, share, - workgroup, sizeof(workgroup), - username, sizeof(username), - password, sizeof(password)); - } - - TALLOC_FREE(*pp_workgroup); - TALLOC_FREE(*pp_username); - TALLOC_FREE(*pp_password); - - *pp_workgroup = talloc_strdup(ctx, workgroup); - *pp_username = talloc_strdup(ctx, username); - *pp_password = talloc_strdup(ctx, password); -} - -static SMBCSRV * -find_server(TALLOC_CTX *ctx, - SMBCCTX *context, - const char *server, - const char *share, - char **pp_workgroup, - char **pp_username, - char **pp_password) -{ - SMBCSRV *srv; - int auth_called = 0; - - check_server_cache: - - srv = (context->callbacks.get_cached_srv_fn)(context, server, share, - *pp_workgroup, *pp_username); - - if (!auth_called && !srv && (!*pp_username || !(*pp_username)[0] || - !*pp_password || !(*pp_password)[0])) { - call_auth_fn(ctx, context, server, share, - pp_workgroup, pp_username, pp_password); - - if (!pp_workgroup || !pp_username || !pp_password) { - return NULL; - } - - /* - * However, smbc_auth_fn may have picked up info relating to - * an existing connection, so try for an existing connection - * again ... - */ - auth_called = 1; - goto check_server_cache; - - } - - if (srv) { - if ((context->callbacks.check_server_fn)(context, srv)) { - /* - * This server is no good anymore - * Try to remove it and check for more possible - * servers in the cache - */ - if ((context->callbacks.remove_unused_server_fn)(context, - srv)) { - /* - * We could not remove the server completely, - * remove it from the cache so we will not get - * it again. It will be removed when the last - * file/dir is closed. - */ - (context->callbacks.remove_cached_srv_fn)(context, - srv); - } - - /* - * Maybe there are more cached connections to this - * server - */ - goto check_server_cache; - } - - return srv; - } - - return NULL; -} - -/* - * Connect to a server, possibly on an existing connection - * - * Here, what we want to do is: If the server and username - * match an existing connection, reuse that, otherwise, establish a - * new connection. - * - * If we have to create a new connection, call the auth_fn to get the - * info we need, unless the username and password were passed in. - */ - -static SMBCSRV * -smbc_server(TALLOC_CTX *ctx, - SMBCCTX *context, - bool connect_if_not_found, - const char *server, - const char *share, - char **pp_workgroup, - char **pp_username, - char **pp_password) -{ - SMBCSRV *srv=NULL; - struct cli_state *c; - struct nmb_name called, calling; - const char *server_n = server; - struct sockaddr_storage ss; - int tried_reverse = 0; - int port_try_first; - int port_try_next; - const char *username_used; - NTSTATUS status; - - zero_addr(&ss); - ZERO_STRUCT(c); - - if (server[0] == 0) { - errno = EPERM; - return NULL; - } - - /* Look for a cached connection */ - srv = find_server(ctx, context, server, share, - pp_workgroup, pp_username, pp_password); - - /* - * If we found a connection and we're only allowed one share per - * server... - */ - if (srv && *share != '\0' && context->options.one_share_per_server) { - - /* - * ... then if there's no current connection to the share, - * connect to it. find_server(), or rather the function - * pointed to by context->callbacks.get_cached_srv_fn which - * was called by find_server(), will have issued a tree - * disconnect if the requested share is not the same as the - * one that was already connected. - */ - if (srv->cli->cnum == (uint16) -1) { - /* Ensure we have accurate auth info */ - call_auth_fn(ctx, context, server, share, - pp_workgroup, pp_username, pp_password); - - if (!*pp_workgroup || !*pp_username || !*pp_password) { - errno = ENOMEM; - cli_shutdown(srv->cli); - srv->cli = NULL; - (context->callbacks.remove_cached_srv_fn)(context, - srv); - return NULL; - } - - /* - * We don't need to renegotiate encryption - * here as the encryption context is not per - * tid. - */ - - if (!cli_send_tconX(srv->cli, share, "?????", - *pp_password, - strlen(*pp_password)+1)) { - - errno = smbc_errno(context, srv->cli); - cli_shutdown(srv->cli); - srv->cli = NULL; - (context->callbacks.remove_cached_srv_fn)(context, - srv); - srv = NULL; - } - - /* - * Regenerate the dev value since it's based on both - * server and share - */ - if (srv) { - srv->dev = (dev_t)(str_checksum(server) ^ - str_checksum(share)); - } - } - } - - /* If we have a connection... */ - if (srv) { - - /* ... then we're done here. Give 'em what they came for. */ - return srv; - } - - /* If we're not asked to connect when a connection doesn't exist... */ - if (! connect_if_not_found) { - /* ... then we're done here. */ - return NULL; - } - - if (!*pp_workgroup || !*pp_username || !*pp_password) { - errno = ENOMEM; - return NULL; - } - - make_nmb_name(&calling, context->netbios_name, 0x0); - make_nmb_name(&called , server, 0x20); - - DEBUG(4,("smbc_server: server_n=[%s] server=[%s]\n", server_n, server)); - - DEBUG(4,(" -> server_n=[%s] server=[%s]\n", server_n, server)); - - again: - - zero_addr(&ss); - - /* have to open a new connection */ - if ((c = cli_initialise()) == NULL) { - errno = ENOMEM; - return NULL; - } - - if (context->flags & SMB_CTX_FLAG_USE_KERBEROS) { - c->use_kerberos = True; - } - if (context->flags & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) { - c->fallback_after_kerberos = True; - } - - c->timeout = context->timeout; - - /* - * Force use of port 139 for first try if share is $IPC, empty, or - * null, so browse lists can work - */ - if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0) { - port_try_first = 139; - port_try_next = 445; - } else { - port_try_first = 445; - port_try_next = 139; - } - - c->port = port_try_first; - - status = cli_connect(c, server_n, &ss); - if (!NT_STATUS_IS_OK(status)) { - - /* First connection attempt failed. Try alternate port. */ - c->port = port_try_next; - - status = cli_connect(c, server_n, &ss); - if (!NT_STATUS_IS_OK(status)) { - cli_shutdown(c); - errno = ETIMEDOUT; - return NULL; - } - } - - if (!cli_session_request(c, &calling, &called)) { - cli_shutdown(c); - if (strcmp(called.name, "*SMBSERVER")) { - make_nmb_name(&called , "*SMBSERVER", 0x20); - goto again; - } else { /* Try one more time, but ensure we don't loop */ - - /* Only try this if server is an IP address ... */ - - if (is_ipaddress(server) && !tried_reverse) { - fstring remote_name; - struct sockaddr_storage rem_ss; - - if (!interpret_string_addr(&rem_ss, server, - NI_NUMERICHOST)) { - DEBUG(4, ("Could not convert IP address " - "%s to struct sockaddr_storage\n", - server)); - errno = ETIMEDOUT; - return NULL; - } - - tried_reverse++; /* Yuck */ - - if (name_status_find("*", 0, 0, &rem_ss, remote_name)) { - make_nmb_name(&called, remote_name, 0x20); - goto again; - } - } - } - errno = ETIMEDOUT; - return NULL; - } - - DEBUG(4,(" session request ok\n")); - - if (!cli_negprot(c)) { - cli_shutdown(c); - errno = ETIMEDOUT; - return NULL; - } - - username_used = *pp_username; - - if (!NT_STATUS_IS_OK(cli_session_setup(c, username_used, - *pp_password, strlen(*pp_password), - *pp_password, strlen(*pp_password), - *pp_workgroup))) { - - /* Failed. Try an anonymous login, if allowed by flags. */ - username_used = ""; - - if ((context->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) || - !NT_STATUS_IS_OK(cli_session_setup(c, username_used, - *pp_password, 1, - *pp_password, 0, - *pp_workgroup))) { - - cli_shutdown(c); - errno = EPERM; - return NULL; - } - } - - DEBUG(4,(" session setup ok\n")); - - if (!cli_send_tconX(c, share, "?????", - *pp_password, strlen(*pp_password)+1)) { - errno = smbc_errno(context, c); - cli_shutdown(c); - return NULL; - } - - DEBUG(4,(" tconx ok\n")); - - if (context->internal->_smb_encryption_level) { - /* Attempt UNIX smb encryption. */ - if (!NT_STATUS_IS_OK(cli_force_encryption(c, - username_used, - *pp_password, - *pp_workgroup))) { - - /* - * context->internal->_smb_encryption_level == 1 - * means don't fail if encryption can't be negotiated, - * == 2 means fail if encryption can't be negotiated. - */ - - DEBUG(4,(" SMB encrypt failed\n")); - - if (context->internal->_smb_encryption_level == 2) { - cli_shutdown(c); - errno = EPERM; - return NULL; - } - } - DEBUG(4,(" SMB encrypt ok\n")); - } - - /* - * Ok, we have got a nice connection - * Let's allocate a server structure. - */ - - srv = SMB_MALLOC_P(SMBCSRV); - if (!srv) { - errno = ENOMEM; - goto failed; - } - - ZERO_STRUCTP(srv); - srv->cli = c; - srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share)); - srv->no_pathinfo = False; - srv->no_pathinfo2 = False; - srv->no_nt_session = False; - - /* now add it to the cache (internal or external) */ - /* Let the cache function set errno if it wants to */ - errno = 0; - if ((context->callbacks.add_cached_srv_fn)(context, srv, - server, share, - *pp_workgroup, - *pp_username)) { - int saved_errno = errno; - DEBUG(3, (" Failed to add server to cache\n")); - errno = saved_errno; - if (errno == 0) { - errno = ENOMEM; - } - goto failed; - } - - DEBUG(2, ("Server connect ok: //%s/%s: %p\n", - server, share, srv)); - - DLIST_ADD(context->internal->_servers, srv); - return srv; - - failed: - cli_shutdown(c); - if (!srv) { - return NULL; - } - - SAFE_FREE(srv); - return NULL; -} - -/* - * Connect to a server for getting/setting attributes, possibly on an existing - * connection. This works similarly to smbc_server(). - */ -static SMBCSRV * -smbc_attr_server(TALLOC_CTX *ctx, - SMBCCTX *context, - const char *server, - const char *share, - char **pp_workgroup, - char **pp_username, - char **pp_password) -{ - int flags; - struct sockaddr_storage ss; - struct cli_state *ipc_cli; - struct rpc_pipe_client *pipe_hnd; - NTSTATUS nt_status; - SMBCSRV *ipc_srv=NULL; - - /* - * See if we've already created this special connection. Reference - * our "special" share name '*IPC$', which is an impossible real share - * name due to the leading asterisk. - */ - ipc_srv = find_server(ctx, context, server, "*IPC$", - pp_workgroup, pp_username, pp_password); - if (!ipc_srv) { - - /* We didn't find a cached connection. Get the password */ - if (!*pp_password || (*pp_password)[0] == '\0') { - /* ... then retrieve it now. */ - call_auth_fn(ctx, context, server, share, - pp_workgroup, pp_username, pp_password); - if (!*pp_workgroup || !*pp_username || !*pp_password) { - errno = ENOMEM; - return NULL; - } - } - - flags = 0; - if (context->flags & SMB_CTX_FLAG_USE_KERBEROS) { - flags |= CLI_FULL_CONNECTION_USE_KERBEROS; - } - - zero_addr(&ss); - nt_status = cli_full_connection(&ipc_cli, - global_myname(), server, - &ss, 0, "IPC$", "?????", - *pp_username, - *pp_workgroup, - *pp_password, - flags, - Undefined, NULL); - if (! NT_STATUS_IS_OK(nt_status)) { - DEBUG(1,("cli_full_connection failed! (%s)\n", - nt_errstr(nt_status))); - errno = ENOTSUP; - return NULL; - } - - if (context->internal->_smb_encryption_level) { - /* Attempt UNIX smb encryption. */ - if (!NT_STATUS_IS_OK(cli_force_encryption(ipc_cli, - *pp_username, - *pp_password, - *pp_workgroup))) { - - /* - * context->internal->_smb_encryption_level == 1 - * means don't fail if encryption can't be negotiated, - * == 2 means fail if encryption can't be negotiated. - */ - - DEBUG(4,(" SMB encrypt failed on IPC$\n")); - - if (context->internal->_smb_encryption_level == 2) { - cli_shutdown(ipc_cli); - errno = EPERM; - return NULL; - } - } - DEBUG(4,(" SMB encrypt ok on IPC$\n")); - } - - ipc_srv = SMB_MALLOC_P(SMBCSRV); - if (!ipc_srv) { - errno = ENOMEM; - cli_shutdown(ipc_cli); - return NULL; - } - - ZERO_STRUCTP(ipc_srv); - ipc_srv->cli = ipc_cli; - - pipe_hnd = cli_rpc_pipe_open_noauth(ipc_srv->cli, - PI_LSARPC, - &nt_status); - if (!pipe_hnd) { - DEBUG(1, ("cli_nt_session_open fail!\n")); - errno = ENOTSUP; - cli_shutdown(ipc_srv->cli); - free(ipc_srv); - return NULL; - } - - /* - * Some systems don't support - * SEC_RIGHTS_MAXIMUM_ALLOWED, but NT sends 0x2000000 - * so we might as well do it too. - */ - - nt_status = rpccli_lsa_open_policy( - pipe_hnd, - talloc_tos(), - True, - GENERIC_EXECUTE_ACCESS, - &ipc_srv->pol); - - if (!NT_STATUS_IS_OK(nt_status)) { - errno = smbc_errno(context, ipc_srv->cli); - cli_shutdown(ipc_srv->cli); - return NULL; - } - - /* now add it to the cache (internal or external) */ - - errno = 0; /* let cache function set errno if it likes */ - if ((context->callbacks.add_cached_srv_fn)(context, ipc_srv, - server, - "*IPC$", - *pp_workgroup, - *pp_username)) { - DEBUG(3, (" Failed to add server to cache\n")); - if (errno == 0) { - errno = ENOMEM; - } - cli_shutdown(ipc_srv->cli); - free(ipc_srv); - return NULL; - } - - DLIST_ADD(context->internal->_servers, ipc_srv); - } - - return ipc_srv; -} - -/* - * Routine to open() a file ... - */ - -static SMBCFILE * -smbc_open_ctx(SMBCCTX *context, - const char *fname, - int flags, - mode_t mode) -{ - char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *workgroup = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - SMBCSRV *srv = NULL; - SMBCFILE *file = NULL; - int fd; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return NULL; - - } - - if (!fname) { - - errno = EINVAL; - TALLOC_FREE(frame); - return NULL; - - } - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return NULL; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return NULL; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - if (errno == EPERM) errno = EACCES; - TALLOC_FREE(frame); - return NULL; /* smbc_server sets errno */ - } - - /* Hmmm, the test for a directory is suspect here ... FIXME */ - - if (strlen(path) > 0 && path[strlen(path) - 1] == '\\') { - fd = -1; - } else { - file = SMB_MALLOC_P(SMBCFILE); - - if (!file) { - errno = ENOMEM; - TALLOC_FREE(frame); - return NULL; - } - - ZERO_STRUCTP(file); - - /*d_printf(">>>open: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", srv->cli, path, &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - SAFE_FREE(file); - TALLOC_FREE(frame); - return NULL; - } - /*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/ - - if ((fd = cli_open(targetcli, targetpath, flags, - context->internal->_share_mode)) < 0) { - - /* Handle the error ... */ - - SAFE_FREE(file); - errno = smbc_errno(context, targetcli); - TALLOC_FREE(frame); - return NULL; - - } - - /* Fill in file struct */ - - file->cli_fd = fd; - file->fname = SMB_STRDUP(fname); - file->srv = srv; - file->offset = 0; - file->file = True; - - DLIST_ADD(context->internal->_files, file); - - /* - * If the file was opened in O_APPEND mode, all write - * operations should be appended to the file. To do that, - * though, using this protocol, would require a getattrE() - * call for each and every write, to determine where the end - * of the file is. (There does not appear to be an append flag - * in the protocol.) Rather than add all of that overhead of - * retrieving the current end-of-file offset prior to each - * write operation, we'll assume that most append operations - * will continuously write, so we'll just set the offset to - * the end of the file now and hope that's adequate. - * - * Note to self: If this proves inadequate, and O_APPEND - * should, in some cases, be forced for each write, add a - * field in the context options structure, for - * "strict_append_mode" which would select between the current - * behavior (if FALSE) or issuing a getattrE() prior to each - * write and forcing the write to the end of the file (if - * TRUE). Adding that capability will likely require adding - * an "append" flag into the _SMBCFILE structure to track - * whether a file was opened in O_APPEND mode. -- djl - */ - if (flags & O_APPEND) { - if (smbc_lseek_ctx(context, file, 0, SEEK_END) < 0) { - (void) smbc_close_ctx(context, file); - errno = ENXIO; - TALLOC_FREE(frame); - return NULL; - } - } - - TALLOC_FREE(frame); - return file; - - } - - /* Check if opendir needed ... */ - - if (fd == -1) { - int eno = 0; - - eno = smbc_errno(context, srv->cli); - file = (context->opendir)(context, fname); - if (!file) errno = eno; - TALLOC_FREE(frame); - return file; - - } - - errno = EINVAL; /* FIXME, correct errno ? */ - TALLOC_FREE(frame); - return NULL; - -} - -/* - * Routine to create a file - */ - -static int creat_bits = O_WRONLY | O_CREAT | O_TRUNC; /* FIXME: Do we need this */ - -static SMBCFILE * -smbc_creat_ctx(SMBCCTX *context, - const char *path, - mode_t mode) -{ - - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; - return NULL; - - } - - return smbc_open_ctx(context, path, creat_bits, mode); -} - -/* - * Routine to read() a file ... - */ - -static ssize_t -smbc_read_ctx(SMBCCTX *context, - SMBCFILE *file, - void *buf, - size_t count) -{ - int ret; - char *server = NULL, *share = NULL, *user = NULL, *password = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - /* - * offset: - * - * Compiler bug (possibly) -- gcc (GCC) 3.3.5 (Debian 1:3.3.5-2) -- - * appears to pass file->offset (which is type off_t) differently than - * a local variable of type off_t. Using local variable "offset" in - * the call to cli_read() instead of file->offset fixes a problem - * retrieving data at an offset greater than 4GB. - */ - off_t offset; - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count)); - - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { - errno = EBADF; - TALLOC_FREE(frame); - return -1; - - } - - offset = file->offset; - - /* Check that the buffer exists ... */ - - if (buf == NULL) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - /*d_printf(">>>read: parsing %s\n", file->fname);*/ - if (smbc_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - /*d_printf(">>>read: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", file->srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ - - ret = cli_read(targetcli, file->cli_fd, (char *)buf, offset, count); - - if (ret < 0) { - - errno = smbc_errno(context, targetcli); - TALLOC_FREE(frame); - return -1; - - } - - file->offset += ret; - - DEBUG(4, (" --> %d\n", ret)); - - TALLOC_FREE(frame); - return ret; /* Success, ret bytes of data ... */ - -} - -/* - * Routine to write() a file ... - */ - -static ssize_t -smbc_write_ctx(SMBCCTX *context, - SMBCFILE *file, - void *buf, - size_t count) -{ - int ret; - off_t offset; - char *server = NULL, *share = NULL, *user = NULL, *password = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - /* First check all pointers before dereferencing them */ - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { - errno = EBADF; - TALLOC_FREE(frame); - return -1; - } - - /* Check that the buffer exists ... */ - - if (buf == NULL) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - offset = file->offset; /* See "offset" comment in smbc_read_ctx() */ - - /*d_printf(">>>write: parsing %s\n", file->fname);*/ - if (smbc_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - /*d_printf(">>>write: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", file->srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>write: resolved path as %s\n", targetpath);*/ - - ret = cli_write(targetcli, file->cli_fd, 0, (char *)buf, offset, count); - - if (ret <= 0) { - errno = smbc_errno(context, targetcli); - TALLOC_FREE(frame); - return -1; - - } - - file->offset += ret; - - TALLOC_FREE(frame); - return ret; /* Success, 0 bytes of data ... */ -} - -/* - * Routine to close() a file ... - */ - -static int -smbc_close_ctx(SMBCCTX *context, - SMBCFILE *file) -{ - SMBCSRV *srv; - char *server = NULL, *share = NULL, *user = NULL, *password = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { - errno = EBADF; - TALLOC_FREE(frame); - return -1; - } - - /* IS a dir ... */ - if (!file->file) { - TALLOC_FREE(frame); - return (context->closedir)(context, file); - } - - /*d_printf(">>>close: parsing %s\n", file->fname);*/ - if (smbc_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - /*d_printf(">>>close: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", file->srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>close: resolved path as %s\n", targetpath);*/ - - if (!cli_close(targetcli, file->cli_fd)) { - - DEBUG(3, ("cli_close failed on %s. purging server.\n", - file->fname)); - /* Deallocate slot and remove the server - * from the server cache if unused */ - errno = smbc_errno(context, targetcli); - srv = file->srv; - DLIST_REMOVE(context->internal->_files, file); - SAFE_FREE(file->fname); - SAFE_FREE(file); - (context->callbacks.remove_unused_server_fn)(context, srv); - TALLOC_FREE(frame); - return -1; - - } - - DLIST_REMOVE(context->internal->_files, file); - SAFE_FREE(file->fname); - SAFE_FREE(file); - TALLOC_FREE(frame); - - return 0; -} - -/* - * Get info from an SMB server on a file. Use a qpathinfo call first - * and if that fails, use getatr, as Win95 sometimes refuses qpathinfo - */ -static bool -smbc_getatr(SMBCCTX * context, - SMBCSRV *srv, - char *path, - uint16 *mode, - SMB_OFF_T *size, - struct timespec *create_time_ts, - struct timespec *access_time_ts, - struct timespec *write_time_ts, - struct timespec *change_time_ts, - SMB_INO_T *ino) -{ - char *fixedpath = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - time_t write_time; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - /* path fixup for . and .. */ - if (strequal(path, ".") || strequal(path, "..")) { - fixedpath = talloc_strdup(frame, "\\"); - if (!fixedpath) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } else { - fixedpath = talloc_strdup(frame, path); - if (!fixedpath) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - trim_string(fixedpath, NULL, "\\.."); - trim_string(fixedpath, NULL, "\\."); - } - DEBUG(4,("smbc_getatr: sending qpathinfo\n")); - - if (!cli_resolve_path(frame, "", srv->cli, fixedpath, - &targetcli, &targetpath)) { - d_printf("Couldn't resolve %s\n", path); - TALLOC_FREE(frame); - return False; - } - - if (!srv->no_pathinfo2 && - cli_qpathinfo2(targetcli, targetpath, - create_time_ts, - access_time_ts, - write_time_ts, - change_time_ts, - size, mode, ino)) { - TALLOC_FREE(frame); - return True; - } - - /* if this is NT then don't bother with the getatr */ - if (targetcli->capabilities & CAP_NT_SMBS) { - errno = EPERM; - TALLOC_FREE(frame); - return False; - } - - if (cli_getatr(targetcli, targetpath, mode, size, &write_time)) { - - struct timespec w_time_ts; - - w_time_ts = convert_time_t_to_timespec(write_time); - - if (write_time_ts != NULL) { - *write_time_ts = w_time_ts; - } - - if (create_time_ts != NULL) { - *create_time_ts = w_time_ts; - } - - if (access_time_ts != NULL) { - *access_time_ts = w_time_ts; - } - - if (change_time_ts != NULL) { - *change_time_ts = w_time_ts; - } - - srv->no_pathinfo2 = True; - TALLOC_FREE(frame); - return True; - } - - errno = EPERM; - TALLOC_FREE(frame); - return False; - -} - -/* - * Set file info on an SMB server. Use setpathinfo call first. If that - * fails, use setattrE.. - * - * Access and modification time parameters are always used and must be - * provided. Create time, if zero, will be determined from the actual create - * time of the file. If non-zero, the create time will be set as well. - * - * "mode" (attributes) parameter may be set to -1 if it is not to be set. - */ -static bool -smbc_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, - time_t create_time, - time_t access_time, - time_t write_time, - time_t change_time, - uint16 mode) -{ - int fd; - int ret; - TALLOC_CTX *frame = talloc_stackframe(); - - /* - * First, try setpathinfo (if qpathinfo succeeded), for it is the - * modern function for "new code" to be using, and it works given a - * filename rather than requiring that the file be opened to have its - * attributes manipulated. - */ - if (srv->no_pathinfo || - ! cli_setpathinfo(srv->cli, path, - create_time, - access_time, - write_time, - change_time, - mode)) { - - /* - * setpathinfo is not supported; go to plan B. - * - * cli_setatr() does not work on win98, and it also doesn't - * support setting the access time (only the modification - * time), so in all cases, we open the specified file and use - * cli_setattrE() which should work on all OS versions, and - * supports both times. - */ - - /* Don't try {q,set}pathinfo() again, with this server */ - srv->no_pathinfo = True; - - /* Open the file */ - if ((fd = cli_open(srv->cli, path, O_RDWR, DENY_NONE)) < 0) { - - errno = smbc_errno(context, srv->cli); - TALLOC_FREE(frame); - return -1; - } - - /* Set the new attributes */ - ret = cli_setattrE(srv->cli, fd, - change_time, - access_time, - write_time); - - /* Close the file */ - cli_close(srv->cli, fd); - - /* - * Unfortunately, setattrE() doesn't have a provision for - * setting the access mode (attributes). We'll have to try - * cli_setatr() for that, and with only this parameter, it - * seems to work on win98. - */ - if (ret && mode != (uint16) -1) { - ret = cli_setatr(srv->cli, path, mode, 0); - } - - if (! ret) { - errno = smbc_errno(context, srv->cli); - TALLOC_FREE(frame); - return False; - } - } - - TALLOC_FREE(frame); - return True; -} - - /* - * Routine to unlink() a file - */ - -static int -smbc_unlink_ctx(SMBCCTX *context, - const char *fname) -{ - char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *workgroup = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - SMBCSRV *srv = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return -1; - - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - TALLOC_FREE(frame); - return -1; /* smbc_server sets errno */ - - } - - /*d_printf(">>>unlink: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>unlink: resolved path as %s\n", targetpath);*/ - - if (!cli_unlink(targetcli, targetpath)) { - - errno = smbc_errno(context, targetcli); - - if (errno == EACCES) { /* Check if the file is a directory */ - - int saverr = errno; - SMB_OFF_T size = 0; - uint16 mode = 0; - struct timespec write_time_ts; - struct timespec access_time_ts; - struct timespec change_time_ts; - SMB_INO_T ino = 0; - - if (!smbc_getatr(context, srv, path, &mode, &size, - NULL, - &access_time_ts, - &write_time_ts, - &change_time_ts, - &ino)) { - - /* Hmmm, bad error ... What? */ - - errno = smbc_errno(context, targetcli); - TALLOC_FREE(frame); - return -1; - - } - else { - - if (IS_DOS_DIR(mode)) - errno = EISDIR; - else - errno = saverr; /* Restore this */ - - } - } - - TALLOC_FREE(frame); - return -1; - - } - - TALLOC_FREE(frame); - return 0; /* Success ... */ - -} - -/* - * Routine to rename() a file - */ - -static int -smbc_rename_ctx(SMBCCTX *ocontext, - const char *oname, - SMBCCTX *ncontext, - const char *nname) -{ - char *server1 = NULL; - char *share1 = NULL; - char *server2 = NULL; - char *share2 = NULL; - char *user1 = NULL; - char *user2 = NULL; - char *password1 = NULL; - char *password2 = NULL; - char *workgroup = NULL; - char *path1 = NULL; - char *path2 = NULL; - char *targetpath1 = NULL; - char *targetpath2 = NULL; - struct cli_state *targetcli1 = NULL; - struct cli_state *targetcli2 = NULL; - SMBCSRV *srv = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!ocontext || !ncontext || - !ocontext->internal || !ncontext->internal || - !ocontext->internal->_initialized || - !ncontext->internal->_initialized) { - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return -1; - } - - if (!oname || !nname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_rename(%s,%s)\n", oname, nname)); - - if (smbc_parse_path(frame, - ocontext, - oname, - &workgroup, - &server1, - &share1, - &path1, - &user1, - &password1, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user1 || user1[0] == (char)0) { - user1 = talloc_strdup(frame, ocontext->user); - if (!user1) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - if (smbc_parse_path(frame, - ncontext, - nname, - NULL, - &server2, - &share2, - &path2, - &user2, - &password2, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user2 || user2[0] == (char)0) { - user2 = talloc_strdup(frame, ncontext->user); - if (!user2) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - if (strcmp(server1, server2) || strcmp(share1, share2) || - strcmp(user1, user2)) { - /* Can't rename across file systems, or users?? */ - errno = EXDEV; - TALLOC_FREE(frame); - return -1; - } - - srv = smbc_server(frame, ocontext, True, - server1, share1, &workgroup, &user1, &password1); - if (!srv) { - TALLOC_FREE(frame); - return -1; - - } - - /*d_printf(">>>rename: resolving %s\n", path1);*/ - if (!cli_resolve_path(frame, "", srv->cli, path1, - &targetcli1, &targetpath1)) { - d_printf("Could not resolve %s\n", path1); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>rename: resolved path as %s\n", targetpath1);*/ - /*d_printf(">>>rename: resolving %s\n", path2);*/ - if (!cli_resolve_path(frame, "", srv->cli, path2, - &targetcli2, &targetpath2)) { - d_printf("Could not resolve %s\n", path2); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>rename: resolved path as %s\n", targetpath2);*/ - - if (strcmp(targetcli1->desthost, targetcli2->desthost) || - strcmp(targetcli1->share, targetcli2->share)) - { - /* can't rename across file systems */ - errno = EXDEV; - TALLOC_FREE(frame); - return -1; - } - - if (!cli_rename(targetcli1, targetpath1, targetpath2)) { - int eno = smbc_errno(ocontext, targetcli1); - - if (eno != EEXIST || - !cli_unlink(targetcli1, targetpath2) || - !cli_rename(targetcli1, targetpath1, targetpath2)) { - - errno = eno; - TALLOC_FREE(frame); - return -1; - - } - } - - TALLOC_FREE(frame); - return 0; /* Success */ -} - -/* - * A routine to lseek() a file - */ - -static off_t -smbc_lseek_ctx(SMBCCTX *context, - SMBCFILE *file, - off_t offset, - int whence) -{ - SMB_OFF_T size; - char *server = NULL, *share = NULL, *user = NULL, *password = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { - - errno = EBADF; - TALLOC_FREE(frame); - return -1; - - } - - if (!file->file) { - - errno = EINVAL; - TALLOC_FREE(frame); - return -1; /* Can't lseek a dir ... */ - - } - - switch (whence) { - case SEEK_SET: - file->offset = offset; - break; - - case SEEK_CUR: - file->offset += offset; - break; - - case SEEK_END: - /*d_printf(">>>lseek: parsing %s\n", file->fname);*/ - if (smbc_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - /*d_printf(">>>lseek: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", file->srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>lseek: resolved path as %s\n", targetpath);*/ - - if (!cli_qfileinfo(targetcli, file->cli_fd, NULL, - &size, NULL, NULL, NULL, NULL, NULL)) - { - SMB_OFF_T b_size = size; - if (!cli_getattrE(targetcli, file->cli_fd, - NULL, &b_size, NULL, NULL, NULL)) - { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } else - size = b_size; - } - file->offset = size + offset; - break; - - default: - errno = EINVAL; - break; - - } - - TALLOC_FREE(frame); - return file->offset; - -} - -/* - * Generate an inode number from file name for those things that need it - */ - -static ino_t -smbc_inode(SMBCCTX *context, - const char *name) -{ - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; - return -1; - - } - - if (!*name) return 2; /* FIXME, why 2 ??? */ - return (ino_t)str_checksum(name); - -} - -/* - * Routine to put basic stat info into a stat structure ... Used by stat and - * fstat below. - */ - -static int -smbc_setup_stat(SMBCCTX *context, - struct stat *st, - char *fname, - SMB_OFF_T size, - int mode) -{ - TALLOC_CTX *frame = talloc_stackframe(); - - st->st_mode = 0; - - if (IS_DOS_DIR(mode)) { - st->st_mode = SMBC_DIR_MODE; - } else { - st->st_mode = SMBC_FILE_MODE; - } - - if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR; - if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP; - if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH; - if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR; - - st->st_size = size; -#ifdef HAVE_STAT_ST_BLKSIZE - st->st_blksize = 512; -#endif -#ifdef HAVE_STAT_ST_BLOCKS - st->st_blocks = (size+511)/512; -#endif -#ifdef HAVE_STRUCT_STAT_ST_RDEV - st->st_rdev = 0; -#endif - st->st_uid = getuid(); - st->st_gid = getgid(); - - if (IS_DOS_DIR(mode)) { - st->st_nlink = 2; - } else { - st->st_nlink = 1; - } - - if (st->st_ino == 0) { - st->st_ino = smbc_inode(context, fname); - } - - TALLOC_FREE(frame); - return True; /* FIXME: Is this needed ? */ - -} - -/* - * Routine to stat a file given a name - */ - -static int -smbc_stat_ctx(SMBCCTX *context, - const char *fname, - struct stat *st) -{ - SMBCSRV *srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - struct timespec write_time_ts; - struct timespec access_time_ts; - struct timespec change_time_ts; - SMB_OFF_T size = 0; - uint16 mode = 0; - SMB_INO_T ino = 0; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_stat(%s)\n", fname)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame,context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - } - - if (!smbc_getatr(context, srv, path, &mode, &size, - NULL, - &access_time_ts, - &write_time_ts, - &change_time_ts, - &ino)) { - errno = smbc_errno(context, srv->cli); - TALLOC_FREE(frame); - return -1; - } - - st->st_ino = ino; - - smbc_setup_stat(context, st, (char *) fname, size, mode); - - set_atimespec(st, access_time_ts); - set_ctimespec(st, change_time_ts); - set_mtimespec(st, write_time_ts); - st->st_dev = srv->dev; - - TALLOC_FREE(frame); - return 0; - -} - -/* - * Routine to stat a file given an fd - */ - -static int -smbc_fstat_ctx(SMBCCTX *context, - SMBCFILE *file, - struct stat *st) -{ - struct timespec change_time_ts; - struct timespec access_time_ts; - struct timespec write_time_ts; - SMB_OFF_T size; - uint16 mode; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - SMB_INO_T ino = 0; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { - errno = EBADF; - TALLOC_FREE(frame); - return -1; - } - - if (!file->file) { - TALLOC_FREE(frame); - return (context->fstatdir)(context, file, st); - } - - /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ - if (smbc_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - /*d_printf(">>>fstat: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", file->srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ - - if (!cli_qfileinfo(targetcli, file->cli_fd, &mode, &size, - NULL, - &access_time_ts, - &write_time_ts, - &change_time_ts, - &ino)) { - - time_t change_time, access_time, write_time; - - if (!cli_getattrE(targetcli, file->cli_fd, &mode, &size, - &change_time, &access_time, &write_time)) { - - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - change_time_ts = convert_time_t_to_timespec(change_time); - access_time_ts = convert_time_t_to_timespec(access_time); - write_time_ts = convert_time_t_to_timespec(write_time); - } - - st->st_ino = ino; - - smbc_setup_stat(context, st, file->fname, size, mode); - - set_atimespec(st, access_time_ts); - set_ctimespec(st, change_time_ts); - set_mtimespec(st, write_time_ts); - st->st_dev = file->srv->dev; - - TALLOC_FREE(frame); - return 0; - -} - -/* - * Routine to truncate a file given by its file descriptor, to a specified size - */ - -static int -smbc_ftruncate_ctx(SMBCCTX *context, - SMBCFILE *file, - off_t length) -{ - SMB_OFF_T size = length; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!file || !DLIST_CONTAINS(context->internal->_files, file)) { - errno = EBADF; - TALLOC_FREE(frame); - return -1; - } - - if (!file->file) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ - if (smbc_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - /*d_printf(">>>fstat: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", file->srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ - - if (!cli_ftruncate(targetcli, file->cli_fd, size)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - TALLOC_FREE(frame); - return 0; - -} - -/* - * Routine to open a directory - * We accept the URL syntax explained in smbc_parse_path(), above. - */ - -static void -smbc_remove_dir(SMBCFILE *dir) -{ - struct smbc_dir_list *d,*f; - - d = dir->dir_list; - while (d) { - - f = d; d = d->next; - - SAFE_FREE(f->dirent); - SAFE_FREE(f); - - } - - dir->dir_list = dir->dir_end = dir->dir_next = NULL; - -} - -static int -add_dirent(SMBCFILE *dir, - const char *name, - const char *comment, - uint32 type) -{ - struct smbc_dirent *dirent; - int size; - int name_length = (name == NULL ? 0 : strlen(name)); - int comment_len = (comment == NULL ? 0 : strlen(comment)); - - /* - * Allocate space for the dirent, which must be increased by the - * size of the name and the comment and 1 each for the null terminator. - */ - - size = sizeof(struct smbc_dirent) + name_length + comment_len + 2; - - dirent = (struct smbc_dirent *)SMB_MALLOC(size); - - if (!dirent) { - - dir->dir_error = ENOMEM; - return -1; - - } - - ZERO_STRUCTP(dirent); - - if (dir->dir_list == NULL) { - - dir->dir_list = SMB_MALLOC_P(struct smbc_dir_list); - if (!dir->dir_list) { - - SAFE_FREE(dirent); - dir->dir_error = ENOMEM; - return -1; - - } - ZERO_STRUCTP(dir->dir_list); - - dir->dir_end = dir->dir_next = dir->dir_list; - } - else { - - dir->dir_end->next = SMB_MALLOC_P(struct smbc_dir_list); - - if (!dir->dir_end->next) { - - SAFE_FREE(dirent); - dir->dir_error = ENOMEM; - return -1; - - } - ZERO_STRUCTP(dir->dir_end->next); - - dir->dir_end = dir->dir_end->next; - } - - dir->dir_end->next = NULL; - dir->dir_end->dirent = dirent; - - dirent->smbc_type = type; - dirent->namelen = name_length; - dirent->commentlen = comment_len; - dirent->dirlen = size; - - /* - * dirent->namelen + 1 includes the null (no null termination needed) - * Ditto for dirent->commentlen. - * The space for the two null bytes was allocated. - */ - strncpy(dirent->name, (name?name:""), dirent->namelen + 1); - dirent->comment = (char *)(&dirent->name + dirent->namelen + 1); - strncpy(dirent->comment, (comment?comment:""), dirent->commentlen + 1); - - return 0; - -} - -static void -list_unique_wg_fn(const char *name, - uint32 type, - const char *comment, - void *state) -{ - SMBCFILE *dir = (SMBCFILE *)state; - struct smbc_dir_list *dir_list; - struct smbc_dirent *dirent; - int dirent_type; - int do_remove = 0; - - dirent_type = dir->dir_type; - - if (add_dirent(dir, name, comment, dirent_type) < 0) { - - /* An error occurred, what do we do? */ - /* FIXME: Add some code here */ - } - - /* Point to the one just added */ - dirent = dir->dir_end->dirent; - - /* See if this was a duplicate */ - for (dir_list = dir->dir_list; - dir_list != dir->dir_end; - dir_list = dir_list->next) { - if (! do_remove && - strcmp(dir_list->dirent->name, dirent->name) == 0) { - /* Duplicate. End end of list need to be removed. */ - do_remove = 1; - } - - if (do_remove && dir_list->next == dir->dir_end) { - /* Found the end of the list. Remove it. */ - dir->dir_end = dir_list; - free(dir_list->next); - free(dirent); - dir_list->next = NULL; - break; - } - } -} - -static void -list_fn(const char *name, - uint32 type, - const char *comment, - void *state) -{ - SMBCFILE *dir = (SMBCFILE *)state; - int dirent_type; - - /* - * We need to process the type a little ... - * - * Disk share = 0x00000000 - * Print share = 0x00000001 - * Comms share = 0x00000002 (obsolete?) - * IPC$ share = 0x00000003 - * - * administrative shares: - * ADMIN$, IPC$, C$, D$, E$ ... are type |= 0x80000000 - */ - - if (dir->dir_type == SMBC_FILE_SHARE) { - switch (type) { - case 0 | 0x80000000: - case 0: - dirent_type = SMBC_FILE_SHARE; - break; - - case 1: - dirent_type = SMBC_PRINTER_SHARE; - break; - - case 2: - dirent_type = SMBC_COMMS_SHARE; - break; - - case 3 | 0x80000000: - case 3: - dirent_type = SMBC_IPC_SHARE; - break; - - default: - dirent_type = SMBC_FILE_SHARE; /* FIXME, error? */ - break; - } - } - else { - dirent_type = dir->dir_type; - } - - if (add_dirent(dir, name, comment, dirent_type) < 0) { - - /* An error occurred, what do we do? */ - /* FIXME: Add some code here */ - - } -} - -static void -dir_list_fn(const char *mnt, - file_info *finfo, - const char *mask, - void *state) -{ - - if (add_dirent((SMBCFILE *)state, finfo->name, "", - (finfo->mode&aDIR?SMBC_DIR:SMBC_FILE)) < 0) { - - /* Handle an error ... */ - - /* FIXME: Add some code ... */ - - } - -} - -static int -net_share_enum_rpc(struct cli_state *cli, - void (*fn)(const char *name, - uint32 type, - const char *comment, - void *state), - void *state) -{ - int i; - WERROR result; - ENUM_HND enum_hnd; - uint32 info_level = 1; - uint32 preferred_len = 0xffffffff; - uint32 type; - SRV_SHARE_INFO_CTR ctr; - fstring name = ""; - fstring comment = ""; - struct rpc_pipe_client *pipe_hnd; - NTSTATUS nt_status; - - /* Open the server service pipe */ - pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &nt_status); - if (!pipe_hnd) { - DEBUG(1, ("net_share_enum_rpc pipe open fail!\n")); - return -1; - } - - /* Issue the NetShareEnum RPC call and retrieve the response */ - init_enum_hnd(&enum_hnd, 0); - result = rpccli_srvsvc_net_share_enum(pipe_hnd, - talloc_tos(), - info_level, - &ctr, - preferred_len, - &enum_hnd); - - /* Was it successful? */ - if (!W_ERROR_IS_OK(result) || ctr.num_entries == 0) { - /* Nope. Go clean up. */ - goto done; - } - - /* For each returned entry... */ - for (i = 0; i < ctr.num_entries; i++) { - - /* pull out the share name */ - rpcstr_pull_unistr2_fstring( - name, &ctr.share.info1[i].info_1_str.uni_netname); - - /* pull out the share's comment */ - rpcstr_pull_unistr2_fstring( - comment, &ctr.share.info1[i].info_1_str.uni_remark); - - /* Get the type value */ - type = ctr.share.info1[i].info_1.type; - - /* Add this share to the list */ - (*fn)(name, type, comment, state); - } - -done: - /* Close the server service pipe */ - cli_rpc_pipe_close(pipe_hnd); - - /* Tell 'em if it worked */ - return W_ERROR_IS_OK(result) ? 0 : -1; -} - - - -static SMBCFILE * -smbc_opendir_ctx(SMBCCTX *context, - const char *fname) -{ - int saved_errno; - char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *options = NULL; - char *workgroup = NULL; - char *path = NULL; - uint16 mode; - char *p = NULL; - SMBCSRV *srv = NULL; - SMBCFILE *dir = NULL; - struct _smbc_callbacks *cb = NULL; - struct sockaddr_storage rem_ss; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - DEBUG(4, ("no valid context\n")); - errno = EINVAL + 8192; - TALLOC_FREE(frame); - return NULL; - - } - - if (!fname) { - DEBUG(4, ("no valid fname\n")); - errno = EINVAL + 8193; - TALLOC_FREE(frame); - return NULL; - } - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - &options)) { - DEBUG(4, ("no valid path\n")); - errno = EINVAL + 8194; - TALLOC_FREE(frame); - return NULL; - } - - DEBUG(4, ("parsed path: fname='%s' server='%s' share='%s' " - "path='%s' options='%s'\n", - fname, server, share, path, options)); - - /* Ensure the options are valid */ - if (smbc_check_options(server, share, path, options)) { - DEBUG(4, ("unacceptable options (%s)\n", options)); - errno = EINVAL + 8195; - TALLOC_FREE(frame); - return NULL; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return NULL; - } - } - - dir = SMB_MALLOC_P(SMBCFILE); - - if (!dir) { - errno = ENOMEM; - TALLOC_FREE(frame); - return NULL; - } - - ZERO_STRUCTP(dir); - - dir->cli_fd = 0; - dir->fname = SMB_STRDUP(fname); - dir->srv = NULL; - dir->offset = 0; - dir->file = False; - dir->dir_list = dir->dir_next = dir->dir_end = NULL; - - if (server[0] == (char)0) { - - int i; - int count; - int max_lmb_count; - struct ip_service *ip_list; - struct ip_service server_addr; - struct user_auth_info u_info; - - if (share[0] != (char)0 || path[0] != (char)0) { - - errno = EINVAL + 8196; - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - } - - /* Determine how many local master browsers to query */ - max_lmb_count = (context->options.browse_max_lmb_count == 0 - ? INT_MAX - : context->options.browse_max_lmb_count); - - memset(&u_info, '\0', sizeof(u_info)); - u_info.username = talloc_strdup(frame,user); - u_info.password = talloc_strdup(frame,password); - if (!u_info.username || !u_info.password) { - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - } - - /* - * We have server and share and path empty but options - * requesting that we scan all master browsers for their list - * of workgroups/domains. This implies that we must first try - * broadcast queries to find all master browsers, and if that - * doesn't work, then try our other methods which return only - * a single master browser. - */ - - ip_list = NULL; - if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list, - &count))) - { - - SAFE_FREE(ip_list); - - if (!find_master_ip(workgroup, &server_addr.ss)) { - - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - errno = ENOENT; - TALLOC_FREE(frame); - return NULL; - } - - ip_list = (struct ip_service *)memdup( - &server_addr, sizeof(server_addr)); - if (ip_list == NULL) { - errno = ENOMEM; - TALLOC_FREE(frame); - return NULL; - } - count = 1; - } - - for (i = 0; i < count && i < max_lmb_count; i++) { - char addr[INET6_ADDRSTRLEN]; - char *wg_ptr = NULL; - struct cli_state *cli = NULL; - - print_sockaddr(addr, sizeof(addr), &ip_list[i].ss); - DEBUG(99, ("Found master browser %d of %d: %s\n", - i+1, MAX(count, max_lmb_count), - addr)); - - cli = get_ipc_connect_master_ip(talloc_tos(), - &ip_list[i], - &u_info, - &wg_ptr); - /* cli == NULL is the master browser refused to talk or - could not be found */ - if (!cli) { - continue; - } - - workgroup = talloc_strdup(frame, wg_ptr); - server = talloc_strdup(frame, cli->desthost); - - cli_shutdown(cli); - - if (!workgroup || !server) { - errno = ENOMEM; - TALLOC_FREE(frame); - return NULL; - } - - DEBUG(4, ("using workgroup %s %s\n", - workgroup, server)); - - /* - * For each returned master browser IP address, get a - * connection to IPC$ on the server if we do not - * already have one, and determine the - * workgroups/domains that it knows about. - */ - - srv = smbc_server(frame, context, True, server, "IPC$", - &workgroup, &user, &password); - if (!srv) { - continue; - } - - dir->srv = srv; - dir->dir_type = SMBC_WORKGROUP; - - /* Now, list the stuff ... */ - - if (!cli_NetServerEnum(srv->cli, - workgroup, - SV_TYPE_DOMAIN_ENUM, - list_unique_wg_fn, - (void *)dir)) { - continue; - } - } - - SAFE_FREE(ip_list); - } else { - /* - * Server not an empty string ... Check the rest and see what - * gives - */ - if (*share == '\0') { - if (*path != '\0') { - - /* Should not have empty share with path */ - errno = EINVAL + 8197; - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - - } - - /* - * We don't know if is really a server name - * or is a workgroup/domain name. If we already have - * a server structure for it, we'll use it. - * Otherwise, check to see if <1D>, - * <1B>, or <20> translates. We check - * to see if is an IP address first. - */ - - /* - * See if we have an existing server. Do not - * establish a connection if one does not already - * exist. - */ - srv = smbc_server(frame, context, False, server, "IPC$", - &workgroup, &user, &password); - - /* - * If no existing server and not an IP addr, look for - * LMB or DMB - */ - if (!srv && - !is_ipaddress(server) && - (resolve_name(server, &rem_ss, 0x1d) || /* LMB */ - resolve_name(server, &rem_ss, 0x1b) )) { /* DMB */ - - fstring buserver; - - dir->dir_type = SMBC_SERVER; - - /* - * Get the backup list ... - */ - if (!name_status_find(server, 0, 0, - &rem_ss, buserver)) { - - DEBUG(0, ("Could not get name of " - "local/domain master browser " - "for server %s\n", server)); - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - errno = EPERM; - TALLOC_FREE(frame); - return NULL; - - } - - /* - * Get a connection to IPC$ on the server if - * we do not already have one - */ - srv = smbc_server(frame, context, True, - buserver, "IPC$", - &workgroup, &user, &password); - if (!srv) { - DEBUG(0, ("got no contact to IPC$\n")); - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - - } - - dir->srv = srv; - - /* Now, list the servers ... */ - if (!cli_NetServerEnum(srv->cli, server, - 0x0000FFFE, list_fn, - (void *)dir)) { - - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - } - } else if (srv || - (resolve_name(server, &rem_ss, 0x20))) { - - /* If we hadn't found the server, get one now */ - if (!srv) { - srv = smbc_server(frame, context, True, - server, "IPC$", - &workgroup, - &user, &password); - } - - if (!srv) { - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - - } - - dir->dir_type = SMBC_FILE_SHARE; - dir->srv = srv; - - /* List the shares ... */ - - if (net_share_enum_rpc( - srv->cli, - list_fn, - (void *) dir) < 0 && - cli_RNetShareEnum( - srv->cli, - list_fn, - (void *)dir) < 0) { - - errno = cli_errno(srv->cli); - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - - } - } else { - /* Neither the workgroup nor server exists */ - errno = ECONNREFUSED; - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - } - - } - else { - /* - * The server and share are specified ... work from - * there ... - */ - char *targetpath; - struct cli_state *targetcli; - - /* We connect to the server and list the directory */ - dir->dir_type = SMBC_FILE_SHARE; - - srv = smbc_server(frame, context, True, server, share, - &workgroup, &user, &password); - - if (!srv) { - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - } - - dir->srv = srv; - - /* Now, list the files ... */ - - p = path + strlen(path); - path = talloc_asprintf_append(path, "\\*"); - if (!path) { - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - } - - if (!cli_resolve_path(frame, "", srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - TALLOC_FREE(frame); - return NULL; - } - - if (cli_list(targetcli, targetpath, - aDIR | aSYSTEM | aHIDDEN, - dir_list_fn, (void *)dir) < 0) { - - if (dir) { - SAFE_FREE(dir->fname); - SAFE_FREE(dir); - } - saved_errno = smbc_errno(context, targetcli); - - if (saved_errno == EINVAL) { - /* - * See if they asked to opendir something - * other than a directory. If so, the - * converted error value we got would have - * been EINVAL rather than ENOTDIR. - */ - *p = '\0'; /* restore original path */ - - if (smbc_getatr(context, srv, path, - &mode, NULL, - NULL, NULL, NULL, NULL, - NULL) && - ! IS_DOS_DIR(mode)) { - - /* It is. Correct the error value */ - saved_errno = ENOTDIR; - } - } - - /* - * If there was an error and the server is no - * good any more... - */ - cb = &context->callbacks; - if (cli_is_error(targetcli) && - (cb->check_server_fn)(context, srv)) { - - /* ... then remove it. */ - if ((cb->remove_unused_server_fn)(context, - srv)) { - /* - * We could not remove the - * server completely, remove - * it from the cache so we - * will not get it again. It - * will be removed when the - * last file/dir is closed. - */ - (cb->remove_cached_srv_fn)(context, - srv); - } - } - - errno = saved_errno; - TALLOC_FREE(frame); - return NULL; - } - } - - } - - DLIST_ADD(context->internal->_files, dir); - TALLOC_FREE(frame); - return dir; - -} - -/* - * Routine to close a directory - */ - -static int -smbc_closedir_ctx(SMBCCTX *context, - SMBCFILE *dir) -{ - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!dir || !DLIST_CONTAINS(context->internal->_files, dir)) { - errno = EBADF; - TALLOC_FREE(frame); - return -1; - } - - smbc_remove_dir(dir); /* Clean it up */ - - DLIST_REMOVE(context->internal->_files, dir); - - if (dir) { - - SAFE_FREE(dir->fname); - SAFE_FREE(dir); /* Free the space too */ - } - - TALLOC_FREE(frame); - return 0; - -} - -static void -smbc_readdir_internal(SMBCCTX * context, - struct smbc_dirent *dest, - struct smbc_dirent *src, - int max_namebuf_len) -{ - if (context->options.urlencode_readdir_entries) { - - /* url-encode the name. get back remaining buffer space */ - max_namebuf_len = - smbc_urlencode(dest->name, src->name, max_namebuf_len); - - /* We now know the name length */ - dest->namelen = strlen(dest->name); - - /* Save the pointer to the beginning of the comment */ - dest->comment = dest->name + dest->namelen + 1; - - /* Copy the comment */ - strncpy(dest->comment, src->comment, max_namebuf_len - 1); - dest->comment[max_namebuf_len - 1] = '\0'; - - /* Save other fields */ - dest->smbc_type = src->smbc_type; - dest->commentlen = strlen(dest->comment); - dest->dirlen = ((dest->comment + dest->commentlen + 1) - - (char *) dest); - } else { - - /* No encoding. Just copy the entry as is. */ - memcpy(dest, src, src->dirlen); - dest->comment = (char *)(&dest->name + src->namelen + 1); - } - -} - -/* - * Routine to get a directory entry - */ - -struct smbc_dirent * -smbc_readdir_ctx(SMBCCTX *context, - SMBCFILE *dir) -{ - int maxlen; - struct smbc_dirent *dirp, *dirent; - TALLOC_CTX *frame = talloc_stackframe(); - - /* Check that all is ok first ... */ - - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; - DEBUG(0, ("Invalid context in smbc_readdir_ctx()\n")); - TALLOC_FREE(frame); - return NULL; - - } - - if (!dir || !DLIST_CONTAINS(context->internal->_files, dir)) { - - errno = EBADF; - DEBUG(0, ("Invalid dir in smbc_readdir_ctx()\n")); - TALLOC_FREE(frame); - return NULL; - - } - - if (dir->file != False) { /* FIXME, should be dir, perhaps */ - - errno = ENOTDIR; - DEBUG(0, ("Found file vs directory in smbc_readdir_ctx()\n")); - TALLOC_FREE(frame); - return NULL; - - } - - if (!dir->dir_next) { - TALLOC_FREE(frame); - return NULL; - } - - dirent = dir->dir_next->dirent; - if (!dirent) { - - errno = ENOENT; - TALLOC_FREE(frame); - return NULL; - - } - - dirp = (struct smbc_dirent *)context->internal->_dirent; - maxlen = (sizeof(context->internal->_dirent) - - sizeof(struct smbc_dirent)); - - smbc_readdir_internal(context, dirp, dirent, maxlen); - - dir->dir_next = dir->dir_next->next; - - TALLOC_FREE(frame); - return dirp; -} - -/* - * Routine to get directory entries - */ - -static int -smbc_getdents_ctx(SMBCCTX *context, - SMBCFILE *dir, - struct smbc_dirent *dirp, - int count) -{ - int rem = count; - int reqd; - int maxlen; - char *ndir = (char *)dirp; - struct smbc_dir_list *dirlist; - TALLOC_CTX *frame = talloc_stackframe(); - - /* Check that all is ok first ... */ - - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - if (!dir || !DLIST_CONTAINS(context->internal->_files, dir)) { - - errno = EBADF; - TALLOC_FREE(frame); - return -1; - - } - - if (dir->file != False) { /* FIXME, should be dir, perhaps */ - - errno = ENOTDIR; - TALLOC_FREE(frame); - return -1; - - } - - /* - * Now, retrieve the number of entries that will fit in what was passed - * We have to figure out if the info is in the list, or we need to - * send a request to the server to get the info. - */ - - while ((dirlist = dir->dir_next)) { - struct smbc_dirent *dirent; - - if (!dirlist->dirent) { - - errno = ENOENT; /* Bad error */ - TALLOC_FREE(frame); - return -1; - - } - - /* Do urlencoding of next entry, if so selected */ - dirent = (struct smbc_dirent *)context->internal->_dirent; - maxlen = (sizeof(context->internal->_dirent) - - sizeof(struct smbc_dirent)); - smbc_readdir_internal(context, dirent, dirlist->dirent, maxlen); - - reqd = dirent->dirlen; - - if (rem < reqd) { - - if (rem < count) { /* We managed to copy something */ - - errno = 0; - TALLOC_FREE(frame); - return count - rem; - - } - else { /* Nothing copied ... */ - - errno = EINVAL; /* Not enough space ... */ - TALLOC_FREE(frame); - return -1; - - } - - } - - memcpy(ndir, dirent, reqd); /* Copy the data in ... */ - - ((struct smbc_dirent *)ndir)->comment = - (char *)(&((struct smbc_dirent *)ndir)->name + - dirent->namelen + - 1); - - ndir += reqd; - - rem -= reqd; - - dir->dir_next = dirlist = dirlist -> next; - } - - TALLOC_FREE(frame); - - if (rem == count) - return 0; - else - return count - rem; - -} - -/* - * Routine to create a directory ... - */ - -static int -smbc_mkdir_ctx(SMBCCTX *context, - const char *fname, - mode_t mode) -{ - SMBCSRV *srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_mkdir(%s)\n", fname)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - - } - - /*d_printf(">>>mkdir: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>mkdir: resolved path as %s\n", targetpath);*/ - - if (!cli_mkdir(targetcli, targetpath)) { - - errno = smbc_errno(context, targetcli); - TALLOC_FREE(frame); - return -1; - - } - - TALLOC_FREE(frame); - return 0; - -} - -/* - * Our list function simply checks to see if a directory is not empty - */ - -static int smbc_rmdir_dirempty = True; - -static void -rmdir_list_fn(const char *mnt, - file_info *finfo, - const char *mask, - void *state) -{ - if (strncmp(finfo->name, ".", 1) != 0 && - strncmp(finfo->name, "..", 2) != 0) { - smbc_rmdir_dirempty = False; - } -} - -/* - * Routine to remove a directory - */ - -static int -smbc_rmdir_ctx(SMBCCTX *context, - const char *fname) -{ - SMBCSRV *srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - char *targetpath = NULL; - struct cli_state *targetcli = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_rmdir(%s)\n", fname)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - - } - - /*d_printf(">>>rmdir: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", srv->cli, path, - &targetcli, &targetpath)) { - d_printf("Could not resolve %s\n", path); - TALLOC_FREE(frame); - return -1; - } - /*d_printf(">>>rmdir: resolved path as %s\n", targetpath);*/ - - - if (!cli_rmdir(targetcli, targetpath)) { - - errno = smbc_errno(context, targetcli); - - if (errno == EACCES) { /* Check if the dir empty or not */ - - /* Local storage to avoid buffer overflows */ - char *lpath; - - smbc_rmdir_dirempty = True; /* Make this so ... */ - - lpath = talloc_asprintf(frame, "%s\\*", - targetpath); - if (!lpath) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - - if (cli_list(targetcli, lpath, - aDIR | aSYSTEM | aHIDDEN, - rmdir_list_fn, NULL) < 0) { - - /* Fix errno to ignore latest error ... */ - DEBUG(5, ("smbc_rmdir: " - "cli_list returned an error: %d\n", - smbc_errno(context, targetcli))); - errno = EACCES; - - } - - if (smbc_rmdir_dirempty) - errno = EACCES; - else - errno = ENOTEMPTY; - - } - - TALLOC_FREE(frame); - return -1; - - } - - TALLOC_FREE(frame); - return 0; - -} - -/* - * Routine to return the current directory position - */ - -static off_t -smbc_telldir_ctx(SMBCCTX *context, - SMBCFILE *dir) -{ - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - if (!dir || !DLIST_CONTAINS(context->internal->_files, dir)) { - - errno = EBADF; - TALLOC_FREE(frame); - return -1; - - } - - if (dir->file != False) { /* FIXME, should be dir, perhaps */ - - errno = ENOTDIR; - TALLOC_FREE(frame); - return -1; - - } - - /* See if we're already at the end. */ - if (dir->dir_next == NULL) { - /* We are. */ - TALLOC_FREE(frame); - return -1; - } - - /* - * We return the pointer here as the offset - */ - TALLOC_FREE(frame); - return (off_t)(long)dir->dir_next->dirent; -} - -/* - * A routine to run down the list and see if the entry is OK - */ - -struct smbc_dir_list * -smbc_check_dir_ent(struct smbc_dir_list *list, - struct smbc_dirent *dirent) -{ - - /* Run down the list looking for what we want */ - - if (dirent) { - - struct smbc_dir_list *tmp = list; - - while (tmp) { - - if (tmp->dirent == dirent) - return tmp; - - tmp = tmp->next; - - } - - } - - return NULL; /* Not found, or an error */ - -} - - -/* - * Routine to seek on a directory - */ - -static int -smbc_lseekdir_ctx(SMBCCTX *context, - SMBCFILE *dir, - off_t offset) -{ - long int l_offset = offset; /* Handle problems of size */ - struct smbc_dirent *dirent = (struct smbc_dirent *)l_offset; - struct smbc_dir_list *list_ent = (struct smbc_dir_list *)NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - if (dir->file != False) { /* FIXME, should be dir, perhaps */ - - errno = ENOTDIR; - TALLOC_FREE(frame); - return -1; - - } - - /* Now, check what we were passed and see if it is OK ... */ - - if (dirent == NULL) { /* Seek to the begining of the list */ - - dir->dir_next = dir->dir_list; - TALLOC_FREE(frame); - return 0; - - } - - if (offset == -1) { /* Seek to the end of the list */ - dir->dir_next = NULL; - TALLOC_FREE(frame); - return 0; - } - - /* Now, run down the list and make sure that the entry is OK */ - /* This may need to be changed if we change the format of the list */ - - if ((list_ent = smbc_check_dir_ent(dir->dir_list, dirent)) == NULL) { - errno = EINVAL; /* Bad entry */ - TALLOC_FREE(frame); - return -1; - } - - dir->dir_next = list_ent; - - TALLOC_FREE(frame); - return 0; -} - -/* - * Routine to fstat a dir - */ - -static int -smbc_fstatdir_ctx(SMBCCTX *context, - SMBCFILE *dir, - struct stat *st) -{ - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - return -1; - } - - /* No code yet ... */ - return 0; -} - -static int -smbc_chmod_ctx(SMBCCTX *context, - const char *fname, - mode_t newmode) -{ - SMBCSRV *srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - uint16 mode; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_chmod(%s, 0%3o)\n", fname, newmode)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - } - - mode = 0; - - if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= aRONLY; - if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH; - if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM; - if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN; - - if (!cli_setatr(srv->cli, path, mode, 0)) { - errno = smbc_errno(context, srv->cli); - TALLOC_FREE(frame); - return -1; - } - - TALLOC_FREE(frame); - return 0; -} - -static int -smbc_utimes_ctx(SMBCCTX *context, - const char *fname, - struct timeval *tbuf) -{ - SMBCSRV *srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - time_t access_time; - time_t write_time; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (tbuf == NULL) { - access_time = write_time = time(NULL); - } else { - access_time = tbuf[0].tv_sec; - write_time = tbuf[1].tv_sec; - } - - if (DEBUGLVL(4)) { - char *p; - char atimebuf[32]; - char mtimebuf[32]; - - strncpy(atimebuf, ctime(&access_time), sizeof(atimebuf) - 1); - atimebuf[sizeof(atimebuf) - 1] = '\0'; - if ((p = strchr(atimebuf, '\n')) != NULL) { - *p = '\0'; - } - - strncpy(mtimebuf, ctime(&write_time), sizeof(mtimebuf) - 1); - mtimebuf[sizeof(mtimebuf) - 1] = '\0'; - if ((p = strchr(mtimebuf, '\n')) != NULL) { - *p = '\0'; - } - - dbgtext("smbc_utimes(%s, atime = %s mtime = %s)\n", - fname, atimebuf, mtimebuf); - } - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - } - - if (!smbc_setatr(context, srv, path, - 0, access_time, write_time, 0, 0)) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_setatr */ - } - - TALLOC_FREE(frame); - return 0; -} - - -/* - * Sort ACEs according to the documentation at - * http://support.microsoft.com/kb/269175, at least as far as it defines the - * order. - */ - -static int -ace_compare(SEC_ACE *ace1, - SEC_ACE *ace2) -{ - bool b1; - bool b2; - - /* If the ACEs are equal, we have nothing more to do. */ - if (sec_ace_equal(ace1, ace2)) { - return 0; - } - - /* Inherited follow non-inherited */ - b1 = ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) != 0); - b2 = ((ace2->flags & SEC_ACE_FLAG_INHERITED_ACE) != 0); - if (b1 != b2) { - return (b1 ? 1 : -1); - } - - /* - * What shall we do with AUDITs and ALARMs? It's undefined. We'll - * sort them after DENY and ALLOW. - */ - b1 = (ace1->type != SEC_ACE_TYPE_ACCESS_ALLOWED && - ace1->type != SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT && - ace1->type != SEC_ACE_TYPE_ACCESS_DENIED && - ace1->type != SEC_ACE_TYPE_ACCESS_DENIED_OBJECT); - b2 = (ace2->type != SEC_ACE_TYPE_ACCESS_ALLOWED && - ace2->type != SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT && - ace2->type != SEC_ACE_TYPE_ACCESS_DENIED && - ace2->type != SEC_ACE_TYPE_ACCESS_DENIED_OBJECT); - if (b1 != b2) { - return (b1 ? 1 : -1); - } - - /* Allowed ACEs follow denied ACEs */ - b1 = (ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED || - ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT); - b2 = (ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED || - ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT); - if (b1 != b2) { - return (b1 ? 1 : -1); - } - - /* - * ACEs applying to an entity's object follow those applying to the - * entity itself - */ - b1 = (ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT || - ace1->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT); - b2 = (ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT || - ace2->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT); - if (b1 != b2) { - return (b1 ? 1 : -1); - } - - /* - * If we get this far, the ACEs are similar as far as the - * characteristics we typically care about (those defined by the - * referenced MS document). We'll now sort by characteristics that - * just seems reasonable. - */ - - if (ace1->type != ace2->type) { - return ace2->type - ace1->type; - } - - if (sid_compare(&ace1->trustee, &ace2->trustee)) { - return sid_compare(&ace1->trustee, &ace2->trustee); - } - - if (ace1->flags != ace2->flags) { - return ace1->flags - ace2->flags; - } - - if (ace1->access_mask != ace2->access_mask) { - return ace1->access_mask - ace2->access_mask; - } - - if (ace1->size != ace2->size) { - return ace1->size - ace2->size; - } - - return memcmp(ace1, ace2, sizeof(SEC_ACE)); -} - - -static void -sort_acl(SEC_ACL *the_acl) -{ - uint32 i; - if (!the_acl) return; - - qsort(the_acl->aces, the_acl->num_aces, sizeof(the_acl->aces[0]), - QSORT_CAST ace_compare); - - for (i=1;inum_aces;) { - if (sec_ace_equal(&the_acl->aces[i-1], &the_acl->aces[i])) { - int j; - for (j=i; jnum_aces-1; j++) { - the_acl->aces[j] = the_acl->aces[j+1]; - } - the_acl->num_aces--; - } else { - i++; - } - } -} - -/* convert a SID to a string, either numeric or username/group */ -static void -convert_sid_to_string(struct cli_state *ipc_cli, - POLICY_HND *pol, - fstring str, - bool numeric, - DOM_SID *sid) -{ - char **domains = NULL; - char **names = NULL; - enum lsa_SidType *types = NULL; - struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli); - TALLOC_CTX *ctx; - - sid_to_fstring(str, sid); - - if (numeric) { - return; /* no lookup desired */ - } - - if (!pipe_hnd) { - return; - } - - /* Ask LSA to convert the sid to a name */ - - ctx = talloc_stackframe(); - - if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(pipe_hnd, ctx, - pol, 1, sid, &domains, - &names, &types)) || - !domains || !domains[0] || !names || !names[0]) { - TALLOC_FREE(ctx); - return; - } - - TALLOC_FREE(ctx); - /* Converted OK */ - - slprintf(str, sizeof(fstring) - 1, "%s%s%s", - domains[0], lp_winbind_separator(), - names[0]); -} - -/* convert a string to a SID, either numeric or username/group */ -static bool -convert_string_to_sid(struct cli_state *ipc_cli, - POLICY_HND *pol, - bool numeric, - DOM_SID *sid, - const char *str) -{ - enum lsa_SidType *types = NULL; - DOM_SID *sids = NULL; - bool result = True; - TALLOC_CTX *ctx = NULL; - struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli); - - if (!pipe_hnd) { - return False; - } - - if (numeric) { - if (strncmp(str, "S-", 2) == 0) { - return string_to_sid(sid, str); - } - - result = False; - goto done; - } - - ctx = talloc_stackframe(); - if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(pipe_hnd, ctx, - pol, 1, &str, NULL, 1, &sids, - &types))) { - result = False; - goto done; - } - - sid_copy(sid, &sids[0]); - done: - - TALLOC_FREE(ctx); - return result; -} - - -/* parse an ACE in the same format as print_ace() */ -static bool -parse_ace(struct cli_state *ipc_cli, - POLICY_HND *pol, - SEC_ACE *ace, - bool numeric, - char *str) -{ - char *p; - const char *cp; - char *tok; - unsigned int atype; - unsigned int aflags; - unsigned int amask; - DOM_SID sid; - SEC_ACCESS mask; - const struct perm_value *v; - struct perm_value { - const char *perm; - uint32 mask; - }; - TALLOC_CTX *frame = talloc_stackframe(); - - /* These values discovered by inspection */ - static const struct perm_value special_values[] = { - { "R", 0x00120089 }, - { "W", 0x00120116 }, - { "X", 0x001200a0 }, - { "D", 0x00010000 }, - { "P", 0x00040000 }, - { "O", 0x00080000 }, - { NULL, 0 }, - }; - - static const struct perm_value standard_values[] = { - { "READ", 0x001200a9 }, - { "CHANGE", 0x001301bf }, - { "FULL", 0x001f01ff }, - { NULL, 0 }, - }; - - - ZERO_STRUCTP(ace); - p = strchr_m(str,':'); - if (!p) { - TALLOC_FREE(frame); - return False; - } - *p = '\0'; - p++; - /* Try to parse numeric form */ - - if (sscanf(p, "%i/%i/%i", &atype, &aflags, &amask) == 3 && - convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) { - goto done; - } - - /* Try to parse text form */ - - if (!convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) { - TALLOC_FREE(frame); - return false; - } - - cp = p; - if (!next_token_talloc(frame, &cp, &tok, "/")) { - TALLOC_FREE(frame); - return false; - } - - if (StrnCaseCmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) { - atype = SEC_ACE_TYPE_ACCESS_ALLOWED; - } else if (StrnCaseCmp(tok, "DENIED", strlen("DENIED")) == 0) { - atype = SEC_ACE_TYPE_ACCESS_DENIED; - } else { - TALLOC_FREE(frame); - return false; - } - - /* Only numeric form accepted for flags at present */ - - if (!(next_token_talloc(frame, &cp, &tok, "/") && - sscanf(tok, "%i", &aflags))) { - TALLOC_FREE(frame); - return false; - } - - if (!next_token_talloc(frame, &cp, &tok, "/")) { - TALLOC_FREE(frame); - return false; - } - - if (strncmp(tok, "0x", 2) == 0) { - if (sscanf(tok, "%i", &amask) != 1) { - TALLOC_FREE(frame); - return false; - } - goto done; - } - - for (v = standard_values; v->perm; v++) { - if (strcmp(tok, v->perm) == 0) { - amask = v->mask; - goto done; - } - } - - p = tok; - - while(*p) { - bool found = False; - - for (v = special_values; v->perm; v++) { - if (v->perm[0] == *p) { - amask |= v->mask; - found = True; - } - } - - if (!found) { - TALLOC_FREE(frame); - return false; - } - p++; - } - - if (*p) { - TALLOC_FREE(frame); - return false; - } - - done: - mask = amask; - init_sec_ace(ace, &sid, atype, mask, aflags); - TALLOC_FREE(frame); - return true; -} - -/* add an ACE to a list of ACEs in a SEC_ACL */ -static bool -add_ace(SEC_ACL **the_acl, - SEC_ACE *ace, - TALLOC_CTX *ctx) -{ - SEC_ACL *newacl; - SEC_ACE *aces; - - if (! *the_acl) { - (*the_acl) = make_sec_acl(ctx, 3, 1, ace); - return True; - } - - if ((aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces)) == NULL) { - return False; - } - memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(SEC_ACE)); - memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE)); - newacl = make_sec_acl(ctx, (*the_acl)->revision, - 1+(*the_acl)->num_aces, aces); - SAFE_FREE(aces); - (*the_acl) = newacl; - return True; -} - - -/* parse a ascii version of a security descriptor */ -static SEC_DESC * -sec_desc_parse(TALLOC_CTX *ctx, - struct cli_state *ipc_cli, - POLICY_HND *pol, - bool numeric, - char *str) -{ - const char *p = str; - char *tok; - SEC_DESC *ret = NULL; - size_t sd_size; - DOM_SID *group_sid=NULL; - DOM_SID *owner_sid=NULL; - SEC_ACL *dacl=NULL; - int revision=1; - - while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) { - - if (StrnCaseCmp(tok,"REVISION:", 9) == 0) { - revision = strtol(tok+9, NULL, 16); - continue; - } - - if (StrnCaseCmp(tok,"OWNER:", 6) == 0) { - if (owner_sid) { - DEBUG(5, ("OWNER specified more than once!\n")); - goto done; - } - owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); - if (!owner_sid || - !convert_string_to_sid(ipc_cli, pol, - numeric, - owner_sid, tok+6)) { - DEBUG(5, ("Failed to parse owner sid\n")); - goto done; - } - continue; - } - - if (StrnCaseCmp(tok,"OWNER+:", 7) == 0) { - if (owner_sid) { - DEBUG(5, ("OWNER specified more than once!\n")); - goto done; - } - owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); - if (!owner_sid || - !convert_string_to_sid(ipc_cli, pol, - False, - owner_sid, tok+7)) { - DEBUG(5, ("Failed to parse owner sid\n")); - goto done; - } - continue; - } - - if (StrnCaseCmp(tok,"GROUP:", 6) == 0) { - if (group_sid) { - DEBUG(5, ("GROUP specified more than once!\n")); - goto done; - } - group_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); - if (!group_sid || - !convert_string_to_sid(ipc_cli, pol, - numeric, - group_sid, tok+6)) { - DEBUG(5, ("Failed to parse group sid\n")); - goto done; - } - continue; - } - - if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) { - if (group_sid) { - DEBUG(5, ("GROUP specified more than once!\n")); - goto done; - } - group_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); - if (!group_sid || - !convert_string_to_sid(ipc_cli, pol, - False, - group_sid, tok+6)) { - DEBUG(5, ("Failed to parse group sid\n")); - goto done; - } - continue; - } - - if (StrnCaseCmp(tok,"ACL:", 4) == 0) { - SEC_ACE ace; - if (!parse_ace(ipc_cli, pol, &ace, numeric, tok+4)) { - DEBUG(5, ("Failed to parse ACL %s\n", tok)); - goto done; - } - if(!add_ace(&dacl, &ace, ctx)) { - DEBUG(5, ("Failed to add ACL %s\n", tok)); - goto done; - } - continue; - } - - if (StrnCaseCmp(tok,"ACL+:", 5) == 0) { - SEC_ACE ace; - if (!parse_ace(ipc_cli, pol, &ace, False, tok+5)) { - DEBUG(5, ("Failed to parse ACL %s\n", tok)); - goto done; - } - if(!add_ace(&dacl, &ace, ctx)) { - DEBUG(5, ("Failed to add ACL %s\n", tok)); - goto done; - } - continue; - } - - DEBUG(5, ("Failed to parse security descriptor\n")); - goto done; - } - - ret = make_sec_desc(ctx, revision, SEC_DESC_SELF_RELATIVE, - owner_sid, group_sid, NULL, dacl, &sd_size); - - done: - SAFE_FREE(group_sid); - SAFE_FREE(owner_sid); - - return ret; -} - - -/* Obtain the current dos attributes */ -static DOS_ATTR_DESC * -dos_attr_query(SMBCCTX *context, - TALLOC_CTX *ctx, - const char *filename, - SMBCSRV *srv) -{ - struct timespec create_time_ts; - struct timespec write_time_ts; - struct timespec access_time_ts; - struct timespec change_time_ts; - SMB_OFF_T size = 0; - uint16 mode = 0; - SMB_INO_T inode = 0; - DOS_ATTR_DESC *ret; - - ret = TALLOC_P(ctx, DOS_ATTR_DESC); - if (!ret) { - errno = ENOMEM; - return NULL; - } - - /* Obtain the DOS attributes */ - if (!smbc_getatr(context, srv, CONST_DISCARD(char *, filename), - &mode, &size, - &create_time_ts, - &access_time_ts, - &write_time_ts, - &change_time_ts, - &inode)) { - errno = smbc_errno(context, srv->cli); - DEBUG(5, ("dos_attr_query Failed to query old attributes\n")); - return NULL; - } - - ret->mode = mode; - ret->size = size; - ret->create_time = convert_timespec_to_time_t(create_time_ts); - ret->access_time = convert_timespec_to_time_t(access_time_ts); - ret->write_time = convert_timespec_to_time_t(write_time_ts); - ret->change_time = convert_timespec_to_time_t(change_time_ts); - ret->inode = inode; - - return ret; -} - - -/* parse a ascii version of a security descriptor */ -static void -dos_attr_parse(SMBCCTX *context, - DOS_ATTR_DESC *dad, - SMBCSRV *srv, - char *str) -{ - int n; - const char *p = str; - char *tok = NULL; - TALLOC_CTX *frame = NULL; - struct { - const char * create_time_attr; - const char * access_time_attr; - const char * write_time_attr; - const char * change_time_attr; - } attr_strings; - - /* Determine whether to use old-style or new-style attribute names */ - if (context->internal->_full_time_names) { - /* new-style names */ - attr_strings.create_time_attr = "CREATE_TIME"; - attr_strings.access_time_attr = "ACCESS_TIME"; - attr_strings.write_time_attr = "WRITE_TIME"; - attr_strings.change_time_attr = "CHANGE_TIME"; - } else { - /* old-style names */ - attr_strings.create_time_attr = NULL; - attr_strings.access_time_attr = "A_TIME"; - attr_strings.write_time_attr = "M_TIME"; - attr_strings.change_time_attr = "C_TIME"; - } - - /* if this is to set the entire ACL... */ - if (*str == '*') { - /* ... then increment past the first colon if there is one */ - if ((p = strchr(str, ':')) != NULL) { - ++p; - } else { - p = str; - } - } - - frame = talloc_stackframe(); - while (next_token_talloc(frame, &p, &tok, "\t,\r\n")) { - if (StrnCaseCmp(tok, "MODE:", 5) == 0) { - long request = strtol(tok+5, NULL, 16); - if (request == 0) { - dad->mode = (request | - (IS_DOS_DIR(dad->mode) - ? FILE_ATTRIBUTE_DIRECTORY - : FILE_ATTRIBUTE_NORMAL)); - } else { - dad->mode = request; - } - continue; - } - - if (StrnCaseCmp(tok, "SIZE:", 5) == 0) { - dad->size = (SMB_OFF_T)atof(tok+5); - continue; - } - - n = strlen(attr_strings.access_time_attr); - if (StrnCaseCmp(tok, attr_strings.access_time_attr, n) == 0) { - dad->access_time = (time_t)strtol(tok+n+1, NULL, 10); - continue; - } - - n = strlen(attr_strings.change_time_attr); - if (StrnCaseCmp(tok, attr_strings.change_time_attr, n) == 0) { - dad->change_time = (time_t)strtol(tok+n+1, NULL, 10); - continue; - } - - n = strlen(attr_strings.write_time_attr); - if (StrnCaseCmp(tok, attr_strings.write_time_attr, n) == 0) { - dad->write_time = (time_t)strtol(tok+n+1, NULL, 10); - continue; - } - - if (attr_strings.create_time_attr != NULL) { - n = strlen(attr_strings.create_time_attr); - if (StrnCaseCmp(tok, attr_strings.create_time_attr, - n) == 0) { - dad->create_time = (time_t)strtol(tok+n+1, - NULL, 10); - continue; - } - } - - if (StrnCaseCmp(tok, "INODE:", 6) == 0) { - dad->inode = (SMB_INO_T)atof(tok+6); - continue; - } - } - TALLOC_FREE(frame); -} - -/***************************************************** - Retrieve the acls for a file. -*******************************************************/ - -static int -cacl_get(SMBCCTX *context, - TALLOC_CTX *ctx, - SMBCSRV *srv, - struct cli_state *ipc_cli, - POLICY_HND *pol, - char *filename, - char *attr_name, - char *buf, - int bufsize) -{ - uint32 i; - int n = 0; - int n_used; - bool all; - bool all_nt; - bool all_nt_acls; - bool all_dos; - bool some_nt; - bool some_dos; - bool exclude_nt_revision = False; - bool exclude_nt_owner = False; - bool exclude_nt_group = False; - bool exclude_nt_acl = False; - bool exclude_dos_mode = False; - bool exclude_dos_size = False; - bool exclude_dos_create_time = False; - bool exclude_dos_access_time = False; - bool exclude_dos_write_time = False; - bool exclude_dos_change_time = False; - bool exclude_dos_inode = False; - bool numeric = True; - bool determine_size = (bufsize == 0); - int fnum = -1; - SEC_DESC *sd; - fstring sidstr; - fstring name_sandbox; - char *name; - char *pExclude; - char *p; - struct timespec create_time_ts; - struct timespec write_time_ts; - struct timespec access_time_ts; - struct timespec change_time_ts; - time_t create_time = (time_t)0; - time_t write_time = (time_t)0; - time_t access_time = (time_t)0; - time_t change_time = (time_t)0; - SMB_OFF_T size = 0; - uint16 mode = 0; - SMB_INO_T ino = 0; - struct cli_state *cli = srv->cli; - struct { - const char * create_time_attr; - const char * access_time_attr; - const char * write_time_attr; - const char * change_time_attr; - } attr_strings; - struct { - const char * create_time_attr; - const char * access_time_attr; - const char * write_time_attr; - const char * change_time_attr; - } excl_attr_strings; - - /* Determine whether to use old-style or new-style attribute names */ - if (context->internal->_full_time_names) { - /* new-style names */ - attr_strings.create_time_attr = "CREATE_TIME"; - attr_strings.access_time_attr = "ACCESS_TIME"; - attr_strings.write_time_attr = "WRITE_TIME"; - attr_strings.change_time_attr = "CHANGE_TIME"; - - excl_attr_strings.create_time_attr = "CREATE_TIME"; - excl_attr_strings.access_time_attr = "ACCESS_TIME"; - excl_attr_strings.write_time_attr = "WRITE_TIME"; - excl_attr_strings.change_time_attr = "CHANGE_TIME"; - } else { - /* old-style names */ - attr_strings.create_time_attr = NULL; - attr_strings.access_time_attr = "A_TIME"; - attr_strings.write_time_attr = "M_TIME"; - attr_strings.change_time_attr = "C_TIME"; - - excl_attr_strings.create_time_attr = NULL; - excl_attr_strings.access_time_attr = "dos_attr.A_TIME"; - excl_attr_strings.write_time_attr = "dos_attr.M_TIME"; - excl_attr_strings.change_time_attr = "dos_attr.C_TIME"; - } - - /* Copy name so we can strip off exclusions (if any are specified) */ - strncpy(name_sandbox, attr_name, sizeof(name_sandbox) - 1); - - /* Ensure name is null terminated */ - name_sandbox[sizeof(name_sandbox) - 1] = '\0'; - - /* Play in the sandbox */ - name = name_sandbox; - - /* If there are any exclusions, point to them and mask them from name */ - if ((pExclude = strchr(name, '!')) != NULL) - { - *pExclude++ = '\0'; - } - - all = (StrnCaseCmp(name, "system.*", 8) == 0); - all_nt = (StrnCaseCmp(name, "system.nt_sec_desc.*", 20) == 0); - all_nt_acls = (StrnCaseCmp(name, "system.nt_sec_desc.acl.*", 24) == 0); - all_dos = (StrnCaseCmp(name, "system.dos_attr.*", 17) == 0); - some_nt = (StrnCaseCmp(name, "system.nt_sec_desc.", 19) == 0); - some_dos = (StrnCaseCmp(name, "system.dos_attr.", 16) == 0); - numeric = (* (name + strlen(name) - 1) != '+'); - - /* Look for exclusions from "all" requests */ - if (all || all_nt || all_dos) { - - /* Exclusions are delimited by '!' */ - for (; - pExclude != NULL; - pExclude = (p == NULL ? NULL : p + 1)) { - - /* Find end of this exclusion name */ - if ((p = strchr(pExclude, '!')) != NULL) - { - *p = '\0'; - } - - /* Which exclusion name is this? */ - if (StrCaseCmp(pExclude, "nt_sec_desc.revision") == 0) { - exclude_nt_revision = True; - } - else if (StrCaseCmp(pExclude, "nt_sec_desc.owner") == 0) { - exclude_nt_owner = True; - } - else if (StrCaseCmp(pExclude, "nt_sec_desc.group") == 0) { - exclude_nt_group = True; - } - else if (StrCaseCmp(pExclude, "nt_sec_desc.acl") == 0) { - exclude_nt_acl = True; - } - else if (StrCaseCmp(pExclude, "dos_attr.mode") == 0) { - exclude_dos_mode = True; - } - else if (StrCaseCmp(pExclude, "dos_attr.size") == 0) { - exclude_dos_size = True; - } - else if (excl_attr_strings.create_time_attr != NULL && - StrCaseCmp(pExclude, - excl_attr_strings.change_time_attr) == 0) { - exclude_dos_create_time = True; - } - else if (StrCaseCmp(pExclude, - excl_attr_strings.access_time_attr) == 0) { - exclude_dos_access_time = True; - } - else if (StrCaseCmp(pExclude, - excl_attr_strings.write_time_attr) == 0) { - exclude_dos_write_time = True; - } - else if (StrCaseCmp(pExclude, - excl_attr_strings.change_time_attr) == 0) { - exclude_dos_change_time = True; - } - else if (StrCaseCmp(pExclude, "dos_attr.inode") == 0) { - exclude_dos_inode = True; - } - else { - DEBUG(5, ("cacl_get received unknown exclusion: %s\n", - pExclude)); - errno = ENOATTR; - return -1; - } - } - } - - n_used = 0; - - /* - * If we are (possibly) talking to an NT or new system and some NT - * attributes have been requested... - */ - if (ipc_cli && (all || some_nt || all_nt_acls)) { - /* Point to the portion after "system.nt_sec_desc." */ - name += 19; /* if (all) this will be invalid but unused */ - - /* ... then obtain any NT attributes which were requested */ - fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ); - - if (fnum == -1) { - DEBUG(5, ("cacl_get failed to open %s: %s\n", - filename, cli_errstr(cli))); - errno = 0; - return -1; - } - - sd = cli_query_secdesc(cli, fnum, ctx); - - if (!sd) { - DEBUG(5, - ("cacl_get Failed to query old descriptor\n")); - errno = 0; - return -1; - } - - cli_close(cli, fnum); - - if (! exclude_nt_revision) { - if (all || all_nt) { - if (determine_size) { - p = talloc_asprintf(ctx, - "REVISION:%d", - sd->revision); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "REVISION:%d", - sd->revision); - } - } else if (StrCaseCmp(name, "revision") == 0) { - if (determine_size) { - p = talloc_asprintf(ctx, "%d", - sd->revision); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, "%d", - sd->revision); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_nt_owner) { - /* Get owner and group sid */ - if (sd->owner_sid) { - convert_sid_to_string(ipc_cli, pol, - sidstr, - numeric, - sd->owner_sid); - } else { - fstrcpy(sidstr, ""); - } - - if (all || all_nt) { - if (determine_size) { - p = talloc_asprintf(ctx, ",OWNER:%s", - sidstr); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else if (sidstr[0] != '\0') { - n = snprintf(buf, bufsize, - ",OWNER:%s", sidstr); - } - } else if (StrnCaseCmp(name, "owner", 5) == 0) { - if (determine_size) { - p = talloc_asprintf(ctx, "%s", sidstr); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, "%s", - sidstr); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_nt_group) { - if (sd->group_sid) { - convert_sid_to_string(ipc_cli, pol, - sidstr, numeric, - sd->group_sid); - } else { - fstrcpy(sidstr, ""); - } - - if (all || all_nt) { - if (determine_size) { - p = talloc_asprintf(ctx, ",GROUP:%s", - sidstr); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else if (sidstr[0] != '\0') { - n = snprintf(buf, bufsize, - ",GROUP:%s", sidstr); - } - } else if (StrnCaseCmp(name, "group", 5) == 0) { - if (determine_size) { - p = talloc_asprintf(ctx, "%s", sidstr); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%s", sidstr); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_nt_acl) { - /* Add aces to value buffer */ - for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) { - - SEC_ACE *ace = &sd->dacl->aces[i]; - convert_sid_to_string(ipc_cli, pol, - sidstr, numeric, - &ace->trustee); - - if (all || all_nt) { - if (determine_size) { - p = talloc_asprintf( - ctx, - ",ACL:" - "%s:%d/%d/0x%08x", - sidstr, - ace->type, - ace->flags, - ace->access_mask); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf( - buf, bufsize, - ",ACL:%s:%d/%d/0x%08x", - sidstr, - ace->type, - ace->flags, - ace->access_mask); - } - } else if ((StrnCaseCmp(name, "acl", 3) == 0 && - StrCaseCmp(name+3, sidstr) == 0) || - (StrnCaseCmp(name, "acl+", 4) == 0 && - StrCaseCmp(name+4, sidstr) == 0)) { - if (determine_size) { - p = talloc_asprintf( - ctx, - "%d/%d/0x%08x", - ace->type, - ace->flags, - ace->access_mask); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%d/%d/0x%08x", - ace->type, - ace->flags, - ace->access_mask); - } - } else if (all_nt_acls) { - if (determine_size) { - p = talloc_asprintf( - ctx, - "%s%s:%d/%d/0x%08x", - i ? "," : "", - sidstr, - ace->type, - ace->flags, - ace->access_mask); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%s%s:%d/%d/0x%08x", - i ? "," : "", - sidstr, - ace->type, - ace->flags, - ace->access_mask); - } - } - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - } - - /* Restore name pointer to its original value */ - name -= 19; - } - - if (all || some_dos) { - /* Point to the portion after "system.dos_attr." */ - name += 16; /* if (all) this will be invalid but unused */ - - /* Obtain the DOS attributes */ - if (!smbc_getatr(context, srv, filename, &mode, &size, - &create_time_ts, - &access_time_ts, - &write_time_ts, - &change_time_ts, - &ino)) { - - errno = smbc_errno(context, srv->cli); - return -1; - - } - - create_time = convert_timespec_to_time_t(create_time_ts); - access_time = convert_timespec_to_time_t(access_time_ts); - write_time = convert_timespec_to_time_t(write_time_ts); - change_time = convert_timespec_to_time_t(change_time_ts); - - if (! exclude_dos_mode) { - if (all || all_dos) { - if (determine_size) { - p = talloc_asprintf(ctx, - "%sMODE:0x%x", - (ipc_cli && - (all || some_nt) - ? "," - : ""), - mode); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%sMODE:0x%x", - (ipc_cli && - (all || some_nt) - ? "," - : ""), - mode); - } - } else if (StrCaseCmp(name, "mode") == 0) { - if (determine_size) { - p = talloc_asprintf(ctx, "0x%x", mode); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "0x%x", mode); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_dos_size) { - if (all || all_dos) { - if (determine_size) { - p = talloc_asprintf( - ctx, - ",SIZE:%.0f", - (double)size); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - ",SIZE:%.0f", - (double)size); - } - } else if (StrCaseCmp(name, "size") == 0) { - if (determine_size) { - p = talloc_asprintf( - ctx, - "%.0f", - (double)size); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%.0f", - (double)size); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_dos_create_time && - attr_strings.create_time_attr != NULL) { - if (all || all_dos) { - if (determine_size) { - p = talloc_asprintf(ctx, - ",%s:%lu", - attr_strings.create_time_attr, - create_time); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - ",%s:%lu", - attr_strings.create_time_attr, - create_time); - } - } else if (StrCaseCmp(name, attr_strings.create_time_attr) == 0) { - if (determine_size) { - p = talloc_asprintf(ctx, "%lu", create_time); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%lu", create_time); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_dos_access_time) { - if (all || all_dos) { - if (determine_size) { - p = talloc_asprintf(ctx, - ",%s:%lu", - attr_strings.access_time_attr, - access_time); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - ",%s:%lu", - attr_strings.access_time_attr, - access_time); - } - } else if (StrCaseCmp(name, attr_strings.access_time_attr) == 0) { - if (determine_size) { - p = talloc_asprintf(ctx, "%lu", access_time); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%lu", access_time); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_dos_write_time) { - if (all || all_dos) { - if (determine_size) { - p = talloc_asprintf(ctx, - ",%s:%lu", - attr_strings.write_time_attr, - write_time); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - ",%s:%lu", - attr_strings.write_time_attr, - write_time); - } - } else if (StrCaseCmp(name, attr_strings.write_time_attr) == 0) { - if (determine_size) { - p = talloc_asprintf(ctx, "%lu", write_time); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%lu", write_time); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_dos_change_time) { - if (all || all_dos) { - if (determine_size) { - p = talloc_asprintf(ctx, - ",%s:%lu", - attr_strings.change_time_attr, - change_time); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - ",%s:%lu", - attr_strings.change_time_attr, - change_time); - } - } else if (StrCaseCmp(name, attr_strings.change_time_attr) == 0) { - if (determine_size) { - p = talloc_asprintf(ctx, "%lu", change_time); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%lu", change_time); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - if (! exclude_dos_inode) { - if (all || all_dos) { - if (determine_size) { - p = talloc_asprintf( - ctx, - ",INODE:%.0f", - (double)ino); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - ",INODE:%.0f", - (double) ino); - } - } else if (StrCaseCmp(name, "inode") == 0) { - if (determine_size) { - p = talloc_asprintf( - ctx, - "%.0f", - (double) ino); - if (!p) { - errno = ENOMEM; - return -1; - } - n = strlen(p); - } else { - n = snprintf(buf, bufsize, - "%.0f", - (double) ino); - } - } - - if (!determine_size && n > bufsize) { - errno = ERANGE; - return -1; - } - buf += n; - n_used += n; - bufsize -= n; - n = 0; - } - - /* Restore name pointer to its original value */ - name -= 16; - } - - if (n_used == 0) { - errno = ENOATTR; - return -1; - } - - return n_used; -} - -/***************************************************** -set the ACLs on a file given an ascii description -*******************************************************/ -static int -cacl_set(TALLOC_CTX *ctx, - struct cli_state *cli, - struct cli_state *ipc_cli, - POLICY_HND *pol, - const char *filename, - const char *the_acl, - int mode, - int flags) -{ - int fnum; - int err = 0; - SEC_DESC *sd = NULL, *old; - SEC_ACL *dacl = NULL; - DOM_SID *owner_sid = NULL; - DOM_SID *group_sid = NULL; - uint32 i, j; - size_t sd_size; - int ret = 0; - char *p; - bool numeric = True; - - /* the_acl will be null for REMOVE_ALL operations */ - if (the_acl) { - numeric = ((p = strchr(the_acl, ':')) != NULL && - p > the_acl && - p[-1] != '+'); - - /* if this is to set the entire ACL... */ - if (*the_acl == '*') { - /* ... then increment past the first colon */ - the_acl = p + 1; - } - - sd = sec_desc_parse(ctx, ipc_cli, pol, numeric, - CONST_DISCARD(char *, the_acl)); - - if (!sd) { - errno = EINVAL; - return -1; - } - } - - /* SMBC_XATTR_MODE_REMOVE_ALL is the only caller - that doesn't deref sd */ - - if (!sd && (mode != SMBC_XATTR_MODE_REMOVE_ALL)) { - errno = EINVAL; - return -1; - } - - /* The desired access below is the only one I could find that works - with NT4, W2KP and Samba */ - - fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ); - - if (fnum == -1) { - DEBUG(5, ("cacl_set failed to open %s: %s\n", - filename, cli_errstr(cli))); - errno = 0; - return -1; - } - - old = cli_query_secdesc(cli, fnum, ctx); - - if (!old) { - DEBUG(5, ("cacl_set Failed to query old descriptor\n")); - errno = 0; - return -1; - } - - cli_close(cli, fnum); - - switch (mode) { - case SMBC_XATTR_MODE_REMOVE_ALL: - old->dacl->num_aces = 0; - dacl = old->dacl; - break; - - case SMBC_XATTR_MODE_REMOVE: - for (i=0;sd->dacl && idacl->num_aces;i++) { - bool found = False; - - for (j=0;old->dacl && jdacl->num_aces;j++) { - if (sec_ace_equal(&sd->dacl->aces[i], - &old->dacl->aces[j])) { - uint32 k; - for (k=j; kdacl->num_aces-1;k++) { - old->dacl->aces[k] = - old->dacl->aces[k+1]; - } - old->dacl->num_aces--; - found = True; - dacl = old->dacl; - break; - } - } - - if (!found) { - err = ENOATTR; - ret = -1; - goto failed; - } - } - break; - - case SMBC_XATTR_MODE_ADD: - for (i=0;sd->dacl && idacl->num_aces;i++) { - bool found = False; - - for (j=0;old->dacl && jdacl->num_aces;j++) { - if (sid_equal(&sd->dacl->aces[i].trustee, - &old->dacl->aces[j].trustee)) { - if (!(flags & SMBC_XATTR_FLAG_CREATE)) { - err = EEXIST; - ret = -1; - goto failed; - } - old->dacl->aces[j] = sd->dacl->aces[i]; - ret = -1; - found = True; - } - } - - if (!found && (flags & SMBC_XATTR_FLAG_REPLACE)) { - err = ENOATTR; - ret = -1; - goto failed; - } - - for (i=0;sd->dacl && idacl->num_aces;i++) { - add_ace(&old->dacl, &sd->dacl->aces[i], ctx); - } - } - dacl = old->dacl; - break; - - case SMBC_XATTR_MODE_SET: - old = sd; - owner_sid = old->owner_sid; - group_sid = old->group_sid; - dacl = old->dacl; - break; - - case SMBC_XATTR_MODE_CHOWN: - owner_sid = sd->owner_sid; - break; - - case SMBC_XATTR_MODE_CHGRP: - group_sid = sd->group_sid; - break; - } - - /* Denied ACE entries must come before allowed ones */ - sort_acl(old->dacl); - - /* Create new security descriptor and set it */ - sd = make_sec_desc(ctx, old->revision, SEC_DESC_SELF_RELATIVE, - owner_sid, group_sid, NULL, dacl, &sd_size); - - fnum = cli_nt_create(cli, filename, - WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS); - - if (fnum == -1) { - DEBUG(5, ("cacl_set failed to open %s: %s\n", - filename, cli_errstr(cli))); - errno = 0; - return -1; - } - - if (!cli_set_secdesc(cli, fnum, sd)) { - DEBUG(5, ("ERROR: secdesc set failed: %s\n", cli_errstr(cli))); - ret = -1; - } - - /* Clean up */ - - failed: - cli_close(cli, fnum); - - if (err != 0) { - errno = err; - } - - return ret; -} - - -static int -smbc_setxattr_ctx(SMBCCTX *context, - const char *fname, - const char *name, - const void *value, - size_t size, - int flags) -{ - int ret; - int ret2; - SMBCSRV *srv = NULL; - SMBCSRV *ipc_srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - DOS_ATTR_DESC *dad = NULL; - struct { - const char * create_time_attr; - const char * access_time_attr; - const char * write_time_attr; - const char * change_time_attr; - } attr_strings; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_setxattr(%s, %s, %.*s)\n", - fname, name, (int) size, (const char*)value)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - if (!srv) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - } - - if (! srv->no_nt_session) { - ipc_srv = smbc_attr_server(frame, context, server, share, - &workgroup, &user, &password); - if (! ipc_srv) { - srv->no_nt_session = True; - } - } else { - ipc_srv = NULL; - } - - /* - * Are they asking to set the entire set of known attributes? - */ - if (StrCaseCmp(name, "system.*") == 0 || - StrCaseCmp(name, "system.*+") == 0) { - /* Yup. */ - char *namevalue = - talloc_asprintf(talloc_tos(), "%s:%s", - name+7, (const char *) value); - if (! namevalue) { - errno = ENOMEM; - ret = -1; - TALLOC_FREE(frame); - return -1; - } - - if (ipc_srv) { - ret = cacl_set(talloc_tos(), srv->cli, - ipc_srv->cli, &ipc_srv->pol, path, - namevalue, - (*namevalue == '*' - ? SMBC_XATTR_MODE_SET - : SMBC_XATTR_MODE_ADD), - flags); - } else { - ret = 0; - } - - /* get a DOS Attribute Descriptor with current attributes */ - dad = dos_attr_query(context, talloc_tos(), path, srv); - if (dad) { - /* Overwrite old with new, using what was provided */ - dos_attr_parse(context, dad, srv, namevalue); - - /* Set the new DOS attributes */ - if (! smbc_setatr(context, srv, path, - dad->create_time, - dad->access_time, - dad->write_time, - dad->change_time, - dad->mode)) { - - /* cause failure if NT failed too */ - dad = NULL; - } - } - - /* we only fail if both NT and DOS sets failed */ - if (ret < 0 && ! dad) { - ret = -1; /* in case dad was null */ - } - else { - ret = 0; - } - - TALLOC_FREE(frame); - return ret; - } - - /* - * Are they asking to set an access control element or to set - * the entire access control list? - */ - if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 || - StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 || - StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) { - - /* Yup. */ - char *namevalue = - talloc_asprintf(talloc_tos(), "%s:%s", - name+19, (const char *) value); - - if (! ipc_srv) { - ret = -1; /* errno set by smbc_server() */ - } - else if (! namevalue) { - errno = ENOMEM; - ret = -1; - } else { - ret = cacl_set(talloc_tos(), srv->cli, - ipc_srv->cli, &ipc_srv->pol, path, - namevalue, - (*namevalue == '*' - ? SMBC_XATTR_MODE_SET - : SMBC_XATTR_MODE_ADD), - flags); - } - TALLOC_FREE(frame); - return ret; - } - - /* - * Are they asking to set the owner? - */ - if (StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0) { - - /* Yup. */ - char *namevalue = - talloc_asprintf(talloc_tos(), "%s:%s", - name+19, (const char *) value); - - if (! ipc_srv) { - ret = -1; /* errno set by smbc_server() */ - } - else if (! namevalue) { - errno = ENOMEM; - ret = -1; - } else { - ret = cacl_set(talloc_tos(), srv->cli, - ipc_srv->cli, &ipc_srv->pol, path, - namevalue, SMBC_XATTR_MODE_CHOWN, 0); - } - TALLOC_FREE(frame); - return ret; - } - - /* - * Are they asking to set the group? - */ - if (StrCaseCmp(name, "system.nt_sec_desc.group") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.group+") == 0) { - - /* Yup. */ - char *namevalue = - talloc_asprintf(talloc_tos(), "%s:%s", - name+19, (const char *) value); - - if (! ipc_srv) { - /* errno set by smbc_server() */ - ret = -1; - } - else if (! namevalue) { - errno = ENOMEM; - ret = -1; - } else { - ret = cacl_set(talloc_tos(), srv->cli, - ipc_srv->cli, &ipc_srv->pol, path, - namevalue, SMBC_XATTR_MODE_CHGRP, 0); - } - TALLOC_FREE(frame); - return ret; - } - - /* Determine whether to use old-style or new-style attribute names */ - if (context->internal->_full_time_names) { - /* new-style names */ - attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME"; - attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME"; - attr_strings.write_time_attr = "system.dos_attr.WRITE_TIME"; - attr_strings.change_time_attr = "system.dos_attr.CHANGE_TIME"; - } else { - /* old-style names */ - attr_strings.create_time_attr = NULL; - attr_strings.access_time_attr = "system.dos_attr.A_TIME"; - attr_strings.write_time_attr = "system.dos_attr.M_TIME"; - attr_strings.change_time_attr = "system.dos_attr.C_TIME"; - } - - /* - * Are they asking to set a DOS attribute? - */ - if (StrCaseCmp(name, "system.dos_attr.*") == 0 || - StrCaseCmp(name, "system.dos_attr.mode") == 0 || - (attr_strings.create_time_attr != NULL && - StrCaseCmp(name, attr_strings.create_time_attr) == 0) || - StrCaseCmp(name, attr_strings.access_time_attr) == 0 || - StrCaseCmp(name, attr_strings.write_time_attr) == 0 || - StrCaseCmp(name, attr_strings.change_time_attr) == 0) { - - /* get a DOS Attribute Descriptor with current attributes */ - dad = dos_attr_query(context, talloc_tos(), path, srv); - if (dad) { - char *namevalue = - talloc_asprintf(talloc_tos(), "%s:%s", - name+16, (const char *) value); - if (! namevalue) { - errno = ENOMEM; - ret = -1; - } else { - /* Overwrite old with provided new params */ - dos_attr_parse(context, dad, srv, namevalue); - - /* Set the new DOS attributes */ - ret2 = smbc_setatr(context, srv, path, - dad->create_time, - dad->access_time, - dad->write_time, - dad->change_time, - dad->mode); - - /* ret2 has True (success) / False (failure) */ - if (ret2) { - ret = 0; - } else { - ret = -1; - } - } - } else { - ret = -1; - } - - TALLOC_FREE(frame); - return ret; - } - - /* Unsupported attribute name */ - errno = EINVAL; - TALLOC_FREE(frame); - return -1; -} - -static int -smbc_getxattr_ctx(SMBCCTX *context, - const char *fname, - const char *name, - const void *value, - size_t size) -{ - int ret; - SMBCSRV *srv = NULL; - SMBCSRV *ipc_srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - struct { - const char * create_time_attr; - const char * access_time_attr; - const char * write_time_attr; - const char * change_time_attr; - } attr_strings; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_getxattr(%s, %s)\n", fname, name)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - if (!srv) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - } - - if (! srv->no_nt_session) { - ipc_srv = smbc_attr_server(frame, context, server, share, - &workgroup, &user, &password); - if (! ipc_srv) { - srv->no_nt_session = True; - } - } else { - ipc_srv = NULL; - } - - /* Determine whether to use old-style or new-style attribute names */ - if (context->internal->_full_time_names) { - /* new-style names */ - attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME"; - attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME"; - attr_strings.write_time_attr = "system.dos_attr.WRITE_TIME"; - attr_strings.change_time_attr = "system.dos_attr.CHANGE_TIME"; - } else { - /* old-style names */ - attr_strings.create_time_attr = NULL; - attr_strings.access_time_attr = "system.dos_attr.A_TIME"; - attr_strings.write_time_attr = "system.dos_attr.M_TIME"; - attr_strings.change_time_attr = "system.dos_attr.C_TIME"; - } - - /* Are they requesting a supported attribute? */ - if (StrCaseCmp(name, "system.*") == 0 || - StrnCaseCmp(name, "system.*!", 9) == 0 || - StrCaseCmp(name, "system.*+") == 0 || - StrnCaseCmp(name, "system.*+!", 10) == 0 || - StrCaseCmp(name, "system.nt_sec_desc.*") == 0 || - StrnCaseCmp(name, "system.nt_sec_desc.*!", 21) == 0 || - StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 || - StrnCaseCmp(name, "system.nt_sec_desc.*+!", 22) == 0 || - StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.group") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 || - StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 || - StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0 || - StrCaseCmp(name, "system.dos_attr.*") == 0 || - StrnCaseCmp(name, "system.dos_attr.*!", 18) == 0 || - StrCaseCmp(name, "system.dos_attr.mode") == 0 || - StrCaseCmp(name, "system.dos_attr.size") == 0 || - (attr_strings.create_time_attr != NULL && - StrCaseCmp(name, attr_strings.create_time_attr) == 0) || - StrCaseCmp(name, attr_strings.access_time_attr) == 0 || - StrCaseCmp(name, attr_strings.write_time_attr) == 0 || - StrCaseCmp(name, attr_strings.change_time_attr) == 0 || - StrCaseCmp(name, "system.dos_attr.inode") == 0) { - - /* Yup. */ - ret = cacl_get(context, talloc_tos(), srv, - ipc_srv == NULL ? NULL : ipc_srv->cli, - &ipc_srv->pol, path, - CONST_DISCARD(char *, name), - CONST_DISCARD(char *, value), size); - if (ret < 0 && errno == 0) { - errno = smbc_errno(context, srv->cli); - } - TALLOC_FREE(frame); - return ret; - } - - /* Unsupported attribute name */ - errno = EINVAL; - TALLOC_FREE(frame); - return -1; -} - - -static int -smbc_removexattr_ctx(SMBCCTX *context, - const char *fname, - const char *name) -{ - int ret; - SMBCSRV *srv = NULL; - SMBCSRV *ipc_srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; /* Best I can think of ... */ - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_removexattr(%s, %s)\n", fname, name)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - if (!srv) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - } - - if (! srv->no_nt_session) { - ipc_srv = smbc_attr_server(frame, context, server, share, - &workgroup, &user, &password); - if (! ipc_srv) { - srv->no_nt_session = True; - } - } else { - ipc_srv = NULL; - } - - if (! ipc_srv) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_attr_server */ - } - - /* Are they asking to set the entire ACL? */ - if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.*+") == 0) { - - /* Yup. */ - ret = cacl_set(talloc_tos(), srv->cli, - ipc_srv->cli, &ipc_srv->pol, path, - NULL, SMBC_XATTR_MODE_REMOVE_ALL, 0); - TALLOC_FREE(frame); - return ret; - } - - /* - * Are they asking to remove one or more spceific security descriptor - * attributes? - */ - if (StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.group") == 0 || - StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 || - StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 || - StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) { - - /* Yup. */ - ret = cacl_set(talloc_tos(), srv->cli, - ipc_srv->cli, &ipc_srv->pol, path, - name + 19, SMBC_XATTR_MODE_REMOVE, 0); - TALLOC_FREE(frame); - return ret; - } - - /* Unsupported attribute name */ - errno = EINVAL; - TALLOC_FREE(frame); - return -1; -} - -static int -smbc_listxattr_ctx(SMBCCTX *context, - const char *fname, - char *list, - size_t size) -{ - /* - * This isn't quite what listxattr() is supposed to do. This returns - * the complete set of attribute names, always, rather than only those - * attribute names which actually exist for a file. Hmmm... - */ - size_t retsize; - const char supported_old[] = - "system.*\0" - "system.*+\0" - "system.nt_sec_desc.revision\0" - "system.nt_sec_desc.owner\0" - "system.nt_sec_desc.owner+\0" - "system.nt_sec_desc.group\0" - "system.nt_sec_desc.group+\0" - "system.nt_sec_desc.acl.*\0" - "system.nt_sec_desc.acl\0" - "system.nt_sec_desc.acl+\0" - "system.nt_sec_desc.*\0" - "system.nt_sec_desc.*+\0" - "system.dos_attr.*\0" - "system.dos_attr.mode\0" - "system.dos_attr.c_time\0" - "system.dos_attr.a_time\0" - "system.dos_attr.m_time\0" - ; - const char supported_new[] = - "system.*\0" - "system.*+\0" - "system.nt_sec_desc.revision\0" - "system.nt_sec_desc.owner\0" - "system.nt_sec_desc.owner+\0" - "system.nt_sec_desc.group\0" - "system.nt_sec_desc.group+\0" - "system.nt_sec_desc.acl.*\0" - "system.nt_sec_desc.acl\0" - "system.nt_sec_desc.acl+\0" - "system.nt_sec_desc.*\0" - "system.nt_sec_desc.*+\0" - "system.dos_attr.*\0" - "system.dos_attr.mode\0" - "system.dos_attr.create_time\0" - "system.dos_attr.access_time\0" - "system.dos_attr.write_time\0" - "system.dos_attr.change_time\0" - ; - const char * supported; - - if (context->internal->_full_time_names) { - supported = supported_new; - retsize = sizeof(supported_new); - } else { - supported = supported_old; - retsize = sizeof(supported_old); - } - - if (size == 0) { - return retsize; - } - - if (retsize > size) { - errno = ERANGE; - return -1; - } - - /* this can't be strcpy() because there are embedded null characters */ - memcpy(list, supported, retsize); - return retsize; -} - - -/* - * Open a print file to be written to by other calls - */ - -static SMBCFILE * -smbc_open_print_job_ctx(SMBCCTX *context, - const char *fname) -{ - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *path = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return NULL; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return NULL; - } - - DEBUG(4, ("smbc_open_print_job_ctx(%s)\n", fname)); - - if (smbc_parse_path(frame, - context, - fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return NULL; - } - - /* What if the path is empty, or the file exists? */ - - TALLOC_FREE(frame); - return (context->open)(context, fname, O_WRONLY, 666); -} - -/* - * Routine to print a file on a remote server ... - * - * We open the file, which we assume to be on a remote server, and then - * copy it to a print file on the share specified by printq. - */ - -static int -smbc_print_file_ctx(SMBCCTX *c_file, - const char *fname, - SMBCCTX *c_print, - const char *printq) -{ - SMBCFILE *fid1; - SMBCFILE *fid2; - int bytes; - int saverr; - int tot_bytes = 0; - char buf[4096]; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!c_file || !c_file->internal->_initialized || !c_print || - !c_print->internal->_initialized) { - - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - if (!fname && !printq) { - - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - /* Try to open the file for reading ... */ - - if ((long)(fid1 = (c_file->open)(c_file, fname, O_RDONLY, 0666)) < 0) { - DEBUG(3, ("Error, fname=%s, errno=%i\n", fname, errno)); - TALLOC_FREE(frame); - return -1; /* smbc_open sets errno */ - } - - /* Now, try to open the printer file for writing */ - - if ((long)(fid2 = (c_print->open_print_job)(c_print, printq)) < 0) { - - saverr = errno; /* Save errno */ - (c_file->close_fn)(c_file, fid1); - errno = saverr; - TALLOC_FREE(frame); - return -1; - - } - - while ((bytes = (c_file->read)(c_file, fid1, buf, sizeof(buf))) > 0) { - - tot_bytes += bytes; - - if (((c_print->write)(c_print, fid2, buf, bytes)) < 0) { - - saverr = errno; - (c_file->close_fn)(c_file, fid1); - (c_print->close_fn)(c_print, fid2); - errno = saverr; - - } - - } - - saverr = errno; - - (c_file->close_fn)(c_file, fid1); /* We have to close these anyway */ - (c_print->close_fn)(c_print, fid2); - - if (bytes < 0) { - - errno = saverr; - TALLOC_FREE(frame); - return -1; - - } - - TALLOC_FREE(frame); - return tot_bytes; - -} - -/* - * Routine to list print jobs on a printer share ... - */ - -static int -smbc_list_print_jobs_ctx(SMBCCTX *context, - const char *fname, - smbc_list_print_job_fn fn) -{ - SMBCSRV *srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_list_print_jobs(%s)\n", fname)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - } - - if (cli_print_queue(srv->cli, - (void (*)(struct print_job_info *))fn) < 0) { - errno = smbc_errno(context, srv->cli); - TALLOC_FREE(frame); - return -1; - } - - TALLOC_FREE(frame); - return 0; - -} - -/* - * Delete a print job from a remote printer share - */ - -static int -smbc_unlink_print_job_ctx(SMBCCTX *context, - const char *fname, - int id) -{ - SMBCSRV *srv = NULL; - char *server = NULL; - char *share = NULL; - char *user = NULL; - char *password = NULL; - char *workgroup = NULL; - char *path = NULL; - int err; - TALLOC_CTX *frame = talloc_stackframe(); - - if (!context || !context->internal || - !context->internal->_initialized) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!fname) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - DEBUG(4, ("smbc_unlink_print_job(%s)\n", fname)); - - if (smbc_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } - - if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); - if (!user) { - errno = ENOMEM; - TALLOC_FREE(frame); - return -1; - } - } - - srv = smbc_server(frame, context, True, - server, share, &workgroup, &user, &password); - - if (!srv) { - - TALLOC_FREE(frame); - return -1; /* errno set by smbc_server */ - - } - - if ((err = cli_printjob_del(srv->cli, id)) != 0) { - - if (err < 0) - errno = smbc_errno(context, srv->cli); - else if (err == ERRnosuchprintjob) - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - - } - - TALLOC_FREE(frame); - return 0; - -} - -/* - * Get a new empty handle to fill in with your own info - */ -SMBCCTX * -smbc_new_context(void) -{ - SMBCCTX *context; - - context = SMB_MALLOC_P(SMBCCTX); - if (!context) { - errno = ENOMEM; - return NULL; - } - - ZERO_STRUCTP(context); - - context->internal = SMB_MALLOC_P(struct smbc_internal_data); - if (!context->internal) { - SAFE_FREE(context); - errno = ENOMEM; - return NULL; - } - - ZERO_STRUCTP(context->internal); - - /* ADD REASONABLE DEFAULTS */ - context->debug = 0; - context->timeout = 20000; /* 20 seconds */ - - context->options.browse_max_lmb_count = 3; /* # LMBs to query */ - context->options.urlencode_readdir_entries = False;/* backward compat */ - context->options.one_share_per_server = False;/* backward compat */ - context->internal->_share_mode = SMBC_SHAREMODE_DENY_NONE; - /* backward compat */ - - context->open = smbc_open_ctx; - context->creat = smbc_creat_ctx; - context->read = smbc_read_ctx; - context->write = smbc_write_ctx; - context->close_fn = smbc_close_ctx; - context->unlink = smbc_unlink_ctx; - context->rename = smbc_rename_ctx; - context->lseek = smbc_lseek_ctx; - context->stat = smbc_stat_ctx; - context->fstat = smbc_fstat_ctx; - context->opendir = smbc_opendir_ctx; - context->closedir = smbc_closedir_ctx; - context->readdir = smbc_readdir_ctx; - context->getdents = smbc_getdents_ctx; - context->mkdir = smbc_mkdir_ctx; - context->rmdir = smbc_rmdir_ctx; - context->telldir = smbc_telldir_ctx; - context->lseekdir = smbc_lseekdir_ctx; - context->fstatdir = smbc_fstatdir_ctx; - context->ftruncate = smbc_ftruncate_ctx; - context->chmod = smbc_chmod_ctx; - context->utimes = smbc_utimes_ctx; - context->setxattr = smbc_setxattr_ctx; - context->getxattr = smbc_getxattr_ctx; - context->removexattr = smbc_removexattr_ctx; - context->listxattr = smbc_listxattr_ctx; - context->open_print_job = smbc_open_print_job_ctx; - context->print_file = smbc_print_file_ctx; - context->list_print_jobs = smbc_list_print_jobs_ctx; - context->unlink_print_job = smbc_unlink_print_job_ctx; - - context->callbacks.check_server_fn = smbc_check_server; - context->callbacks.remove_unused_server_fn = smbc_remove_unused_server; - - smbc_default_cache_functions(context); - - return context; -} - -/* - * Free a context - * - * Returns 0 on success. Otherwise returns 1, the SMBCCTX is _not_ freed - * and thus you'll be leaking memory if not handled properly. - * - */ -int -smbc_free_context(SMBCCTX *context, - int shutdown_ctx) -{ - if (!context) { - errno = EBADF; - return 1; - } - - if (shutdown_ctx) { - SMBCFILE * f; - DEBUG(1,("Performing aggressive shutdown.\n")); - - f = context->internal->_files; - while (f) { - (context->close_fn)(context, f); - f = f->next; - } - context->internal->_files = NULL; - - /* First try to remove the servers the nice way. */ - if (context->callbacks.purge_cached_fn(context)) { - SMBCSRV * s; - SMBCSRV * next; - DEBUG(1, ("Could not purge all servers, " - "Nice way shutdown failed.\n")); - s = context->internal->_servers; - while (s) { - DEBUG(1, ("Forced shutdown: %p (fd=%d)\n", - s, s->cli->fd)); - cli_shutdown(s->cli); - (context->callbacks.remove_cached_srv_fn)(context, - s); - next = s->next; - DLIST_REMOVE(context->internal->_servers, s); - SAFE_FREE(s); - s = next; - } - context->internal->_servers = NULL; - } - } - else { - /* This is the polite way */ - if ((context->callbacks.purge_cached_fn)(context)) { - DEBUG(1, ("Could not purge all servers, " - "free_context failed.\n")); - errno = EBUSY; - return 1; - } - if (context->internal->_servers) { - DEBUG(1, ("Active servers in context, " - "free_context failed.\n")); - errno = EBUSY; - return 1; - } - if (context->internal->_files) { - DEBUG(1, ("Active files in context, " - "free_context failed.\n")); - errno = EBUSY; - return 1; - } - } - - /* Things we have to clean up */ - SAFE_FREE(context->workgroup); - SAFE_FREE(context->netbios_name); - SAFE_FREE(context->user); - - DEBUG(3, ("Context %p successfully freed\n", context)); - SAFE_FREE(context->internal); - SAFE_FREE(context); - return 0; -} - - -/* - * Each time the context structure is changed, we have binary backward - * compatibility issues. Instead of modifying the public portions of the - * context structure to add new options, instead, we put them in the internal - * portion of the context structure and provide a set function for these new - * options. - */ -void -smbc_option_set(SMBCCTX *context, - char *option_name, - ... /* option_value */) -{ - va_list ap; - union { - int i; - bool b; - smbc_get_auth_data_with_context_fn auth_fn; - void *v; - const char *s; - } option_value; - - va_start(ap, option_name); - - if (strcmp(option_name, "debug_to_stderr") == 0) { - /* - * Log to standard error instead of standard output. - */ - option_value.b = (bool) va_arg(ap, int); - context->internal->_debug_stderr = option_value.b; - - } else if (strcmp(option_name, "full_time_names") == 0) { - /* - * Use new-style time attribute names, e.g. WRITE_TIME rather - * than the old-style names such as M_TIME. This allows also - * setting/getting CREATE_TIME which was previously - * unimplemented. (Note that the old C_TIME was supposed to - * be CHANGE_TIME but was confused and sometimes referred to - * CREATE_TIME.) - */ - option_value.b = (bool) va_arg(ap, int); - context->internal->_full_time_names = option_value.b; - - } else if (strcmp(option_name, "open_share_mode") == 0) { - /* - * The share mode to use for files opened with - * smbc_open_ctx(). The default is SMBC_SHAREMODE_DENY_NONE. - */ - option_value.i = va_arg(ap, int); - context->internal->_share_mode = - (smbc_share_mode) option_value.i; - - } else if (strcmp(option_name, "auth_function") == 0) { - /* - * Use the new-style authentication function which includes - * the context. - */ - option_value.auth_fn = - va_arg(ap, smbc_get_auth_data_with_context_fn); - context->internal->_auth_fn_with_context = - option_value.auth_fn; - } else if (strcmp(option_name, "user_data") == 0) { - /* - * Save a user data handle which may be retrieved by the user - * with smbc_option_get() - */ - option_value.v = va_arg(ap, void *); - context->internal->_user_data = option_value.v; - } else if (strcmp(option_name, "smb_encrypt_level") == 0) { - /* - * Save an encoded value for encryption level. - * 0 = off, 1 = attempt, 2 = required. - */ - option_value.s = va_arg(ap, const char *); - if (strcmp(option_value.s, "none") == 0) { - context->internal->_smb_encryption_level = 0; - } else if (strcmp(option_value.s, "request") == 0) { - context->internal->_smb_encryption_level = 1; - } else if (strcmp(option_value.s, "require") == 0) { - context->internal->_smb_encryption_level = 2; - } - } - - va_end(ap); -} - - -/* - * Retrieve the current value of an option - */ -void * -smbc_option_get(SMBCCTX *context, - char *option_name) -{ - if (strcmp(option_name, "debug_stderr") == 0) { - /* - * Log to standard error instead of standard output. - */ -#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->internal->_debug_stderr; -#else - return (void *) context->internal->_debug_stderr; -#endif - } else if (strcmp(option_name, "full_time_names") == 0) { - /* - * Use new-style time attribute names, e.g. WRITE_TIME rather - * than the old-style names such as M_TIME. This allows also - * setting/getting CREATE_TIME which was previously - * unimplemented. (Note that the old C_TIME was supposed to - * be CHANGE_TIME but was confused and sometimes referred to - * CREATE_TIME.) - */ -#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->internal->_full_time_names; -#else - return (void *) context->internal->_full_time_names; -#endif - - } else if (strcmp(option_name, "auth_function") == 0) { - /* - * Use the new-style authentication function which includes - * the context. - */ - return (void *) context->internal->_auth_fn_with_context; - } else if (strcmp(option_name, "user_data") == 0) { - /* - * Save a user data handle which may be retrieved by the user - * with smbc_option_get() - */ - return context->internal->_user_data; - } else if (strcmp(option_name, "smb_encrypt_level") == 0) { - /* - * Return the current smb encrypt negotiate option as a string. - */ - switch (context->internal->_smb_encryption_level) { - case 0: - return (void *) "none"; - case 1: - return (void *) "request"; - case 2: - return (void *) "require"; - } - } else if (strcmp(option_name, "smb_encrypt_on") == 0) { - /* - * Return the current smb encrypt status option as a bool. - * false = off, true = on. We don't know what server is - * being requested, so we only return true if all servers - * are using an encrypted connection. - */ - SMBCSRV *s; - unsigned int num_servers = 0; - - for (s = context->internal->_servers; s; s = s->next) { - num_servers++; - if (s->cli->trans_enc_state == NULL) { - return (void *)false; - } - } - return (void *) (bool) (num_servers > 0); - } - - return NULL; -} - - -/* - * Initialise the library etc - * - * We accept a struct containing handle information. - * valid values for info->debug from 0 to 100, - * and insist that info->fn must be non-null. - */ -SMBCCTX * -smbc_init_context(SMBCCTX *context) -{ - int pid; - char *user = NULL; - char *home = NULL; - - if (!context || !context->internal) { - errno = EBADF; - return NULL; - } - - /* Do not initialise the same client twice */ - if (context->internal->_initialized) { - return 0; - } - - if ((!context->callbacks.auth_fn && - !context->internal->_auth_fn_with_context) || - context->debug < 0 || - context->debug > 100) { - - errno = EINVAL; - return NULL; - - } - - if (!smbc_initialized) { - /* - * Do some library-wide intializations the first time we get - * called - */ - bool conf_loaded = False; - TALLOC_CTX *frame = talloc_stackframe(); - - /* Set this to what the user wants */ - DEBUGLEVEL = context->debug; - - load_case_tables(); - - setup_logging("libsmbclient", True); - if (context->internal->_debug_stderr) { - dbf = x_stderr; - x_setbuf(x_stderr, NULL); - } - - /* Here we would open the smb.conf file if needed ... */ - - in_client = True; /* FIXME, make a param */ - - home = getenv("HOME"); - if (home) { - char *conf = NULL; - if (asprintf(&conf, "%s/.smb/smb.conf", home) > 0) { - if (lp_load(conf, True, False, False, True)) { - conf_loaded = True; - } else { - DEBUG(5, ("Could not load config file: %s\n", - conf)); - } - SAFE_FREE(conf); - } - } - - if (!conf_loaded) { - /* - * Well, if that failed, try the get_dyn_CONFIGFILE - * Which points to the standard locn, and if that - * fails, silently ignore it and use the internal - * defaults ... - */ - - if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, False)) { - DEBUG(5, ("Could not load config file: %s\n", - get_dyn_CONFIGFILE())); - } else if (home) { - char *conf; - /* - * We loaded the global config file. Now lets - * load user-specific modifications to the - * global config. - */ - if (asprintf(&conf, - "%s/.smb/smb.conf.append", - home) > 0) { - if (!lp_load(conf, True, False, False, False)) { - DEBUG(10, - ("Could not append config file: " - "%s\n", - conf)); - } - SAFE_FREE(conf); - } - } - } - - load_interfaces(); /* Load the list of interfaces ... */ - - reopen_logs(); /* Get logging working ... */ - - /* - * Block SIGPIPE (from lib/util_sock.c: write()) - * It is not needed and should not stop execution - */ - BlockSignals(True, SIGPIPE); - - /* Done with one-time initialisation */ - smbc_initialized = 1; - - TALLOC_FREE(frame); - } - - if (!context->user) { - /* - * FIXME: Is this the best way to get the user info? - */ - user = getenv("USER"); - /* walk around as "guest" if no username can be found */ - if (!user) context->user = SMB_STRDUP("guest"); - else context->user = SMB_STRDUP(user); - } - - if (!context->netbios_name) { - /* - * We try to get our netbios name from the config. If that - * fails we fall back on constructing our netbios name from - * our hostname etc - */ - if (global_myname()) { - context->netbios_name = SMB_STRDUP(global_myname()); - } - else { - /* - * Hmmm, I want to get hostname as well, but I am too - * lazy for the moment - */ - pid = sys_getpid(); - context->netbios_name = (char *)SMB_MALLOC(17); - if (!context->netbios_name) { - errno = ENOMEM; - return NULL; - } - slprintf(context->netbios_name, 16, - "smbc%s%d", context->user, pid); - } - } - - DEBUG(1, ("Using netbios name %s.\n", context->netbios_name)); - - if (!context->workgroup) { - if (lp_workgroup()) { - context->workgroup = SMB_STRDUP(lp_workgroup()); - } - else { - /* TODO: Think about a decent default workgroup */ - context->workgroup = SMB_STRDUP("samba"); - } - } - - DEBUG(1, ("Using workgroup %s.\n", context->workgroup)); - - /* shortest timeout is 1 second */ - if (context->timeout > 0 && context->timeout < 1000) - context->timeout = 1000; - - /* - * FIXME: Should we check the function pointers here? - */ - - context->internal->_initialized = True; - - return context; -} - - -/* Return the verion of samba, and thus libsmbclient */ -const char * -smbc_version(void) -{ - return samba_version_string(); -} -- cgit From 4ba42cbe0f6bbd25848786e1a87c06aca79b98ea Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Fri, 29 Feb 2008 13:34:35 -0500 Subject: Modified revamp of the libsmbclient interface. Given the tacit (if that) approval by some people, and clear disapproval by others for my proposed clean-up and reorganization of libsmbclient, I've come up with a slightly different approach. This commit changes back to the original libsmbclient.h SMBCCTX structure which will maintain ABI compatibility. I retain, here, the setter and getter functions which all new code should use. Older programs already compiled should continue to work fine. Older programs being recompiled will encounter compile-time errors (intentionally!) so that the code can be corrected to use the setter/getter interfaces. Although this doesn't clean up the interface in the way I had wanted, the code reorganization and requirement for new programs to use the setters and getters allows future progress to be made on libsmbclient without further muddying up the interface, while retaining the ABI compatibility that was the big issue causing disapproval. I hope that this compromise is adequate. Derrell (This used to be commit 56429a3d60b2a48963342f6340b3c01469a892c6) --- source3/include/libsmb_internal.h | 16 +- source3/include/libsmbclient.h | 282 ++++++++++++++++++++++++++++++++++- source3/libsmb/libsmb_cache.c | 2 +- source3/libsmb/libsmb_context.c | 305 ++++++++++++++++++++++---------------- source3/libsmb/libsmb_dir.c | 70 ++++----- source3/libsmb/libsmb_file.c | 36 ++--- source3/libsmb/libsmb_path.c | 7 +- source3/libsmb/libsmb_printjob.c | 14 +- source3/libsmb/libsmb_server.c | 33 +++-- source3/libsmb/libsmb_stat.c | 10 +- source3/libsmb/libsmb_xattr.c | 22 +-- 11 files changed, 566 insertions(+), 231 deletions(-) (limited to 'source3') diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index 353575dce8..555b6ac138 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -108,11 +108,12 @@ struct _SMBCFILE { /* * Context structure */ -struct _SMBCCTX { +struct SMBC_internal_data { /* True when this handle is initialized */ bool initialized; +#if 0 /* Left in libsmbclient.h for backward compatibility */ /* Netbios name used for making connections */ char * netbios_name; @@ -127,6 +128,7 @@ struct _SMBCCTX { /* Connection timeout value */ int timeout; +#endif /* dirent pointer location * @@ -240,6 +242,7 @@ struct _SMBCCTX { */ bool one_share_per_server; +#if 0 /* Left in libsmbclient.h (flags) for backward compatibility */ /* Kerberos-related flags */ bool use_kerberos; bool fallback_after_kerberos; @@ -264,10 +267,12 @@ struct _SMBCCTX { smbc_remove_cached_srv_fn remove_cached_server_fn; smbc_purge_cached_srv_fn purge_cached_server_fn; } cache; +#endif /* POSIX emulation functions */ struct { +#if 0 /* Left in libsmbclient.h for backward compatibility */ smbc_open_fn open_fn; smbc_creat_fn creat_fn; smbc_read_fn read_fn; @@ -275,9 +280,11 @@ struct _SMBCCTX { smbc_unlink_fn unlink_fn; smbc_rename_fn rename_fn; smbc_lseek_fn lseek_fn; - smbc_ftruncate_fn ftruncate_fn; smbc_stat_fn stat_fn; smbc_fstat_fn fstat_fn; +#endif + smbc_ftruncate_fn ftruncate_fn; +#if 0 /* Left in libsmbclient.h for backward compatibility */ smbc_close_fn close_fn; smbc_opendir_fn opendir_fn; smbc_closedir_fn closedir_fn; @@ -294,8 +301,10 @@ struct _SMBCCTX { smbc_getxattr_fn getxattr_fn; smbc_removexattr_fn removexattr_fn; smbc_listxattr_fn listxattr_fn; +#endif } posix_emu; +#if 0 /* Left in libsmbclient.h for backward compatibility */ /* Printing-related functions */ struct { @@ -304,8 +313,9 @@ struct _SMBCCTX { smbc_list_print_jobs_fn list_print_jobs_fn; smbc_unlink_print_job_fn unlink_print_job_fn; } printing; +#endif -#if 0 /* not yet */ +#if 0 /* None available yet */ /* SMB high-level functions */ struct { diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index a998bcee69..4d78bb2568 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -5,7 +5,7 @@ Copyright (C) Richard Sharpe 2000 Copyright (C) John Terpsra 2000 Copyright (C) Tom Jansen (Ninja ISD) 2002 - Copyright (C) Derrell Lipman 2003 + Copyright (C) Derrell Lipman 2003-2008 This program is free software; you can redistribute it and/or modify @@ -213,6 +213,15 @@ typedef struct _SMBCFILE SMBCFILE; typedef struct _SMBCCTX SMBCCTX; +/* + * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. + * For these options, use smbc_option_set() and smbc_option_get(). + */ + +/* Flags for SMBCCTX->flags */ +# define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) +# define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) +# define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) @@ -2311,4 +2320,275 @@ smbc_version(void); #endif +/** + * @ingroup structure + * Structure that contains a client context information + * This structure is known as SMBCCTX + * + * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context + * structure should all be considered private to the library. It remains here + * only for backward compatibility. + * + * See the comments herein for use of the setter and getter functions which + * should now be used for manipulating these values. New features, functions, + * etc., are not added here but rather in _internal where they are not + * directly visible to applications. This makes it much easier to maintain + * ABI compatibility. + */ +struct _SMBCCTX { + struct + { + /** + * debug level + * + * Use smbc_getDebug() and smbc_setDebug() + */ + int debug; + + /** + * netbios name used for making connections + * + * Use smbc_getNetbiosName() and smbc_setNetbiosName() + */ + char * netbios_name; + + /** + * workgroup name used for making connections + * + * Use smbc_getWorkgroup() and smbc_setWorkgroup() + */ + char * workgroup; + + /** + * username used for making connections + * + * Use smbc_getUser() and smbc_setUser() + */ + char * user; + + /** + * timeout used for waiting on connections / response data (in + * milliseconds) + * + * Use smbc_getTimeout() and smbc_setTimeout() + */ + int timeout; + } config; + + /** + * callable functions for files: + * For usage and return values see the SMBC_* functions + * + * Use smbc_getFunction*() and smbc_setFunction*(), e.g. + * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. + */ + struct + { + smbc_open_fn open_fn; + smbc_creat_fn creat_fn; + smbc_read_fn read_fn; + smbc_write_fn write_fn; + smbc_unlink_fn unlink_fn; + smbc_rename_fn rename_fn; + smbc_lseek_fn lseek_fn; + smbc_stat_fn stat_fn; + smbc_fstat_fn fstat_fn; +#if 0 /* internal */ + smbc_ftruncate_fn ftruncate_fn; +#endif + smbc_close_fn close_fn; + smbc_opendir_fn opendir_fn; + smbc_closedir_fn closedir_fn; + smbc_readdir_fn readdir_fn; + smbc_getdents_fn getdents_fn; + smbc_mkdir_fn mkdir_fn; + smbc_rmdir_fn rmdir_fn; + smbc_telldir_fn telldir_fn; + smbc_lseekdir_fn lseekdir_fn; + smbc_fstatdir_fn fstatdir_fn; + smbc_chmod_fn chmod_fn; + smbc_utimes_fn utimes_fn; + smbc_setxattr_fn setxattr_fn; + smbc_getxattr_fn getxattr_fn; + smbc_removexattr_fn removexattr_fn; + smbc_listxattr_fn listxattr_fn; + } posix_emu; + + /* Printing-related functions */ + struct + { + smbc_print_file_fn print_file_fn; + smbc_open_print_job_fn open_print_job_fn; + smbc_list_print_jobs_fn list_print_jobs_fn; + smbc_unlink_print_job_fn unlink_print_job_fn; + } printing; + + /* + ** Callbacks + * These callbacks _always_ have to be initialized because they will + * not be checked at dereference for increased speed. + */ + struct + { + /** + * authentication function callback: called upon auth requests + * + * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() + */ + smbc_get_auth_data_fn get_auth_data_fn; + + /** + * check if a server is still good + * + * Use smbc_getFunctionCheckServer(), + * smbc_setFunctionCheckServer() + */ + smbc_check_server_fn check_server_fn; + + /** + * remove a server if unused + * + * Use smbc_getFunctionRemoveUnusedServer(), + * smbc_setFunctionCheckServer() + */ + smbc_remove_unused_server_fn remove_unused_server_fn; + } server; + + struct + { + /** Cache subsystem + * + * For an example cache system see + * samba/source/libsmb/libsmb_cache.c + * + * Cache subsystem * functions follow. + */ + + /** + * server cache addition + * + * Use smbc_getFunctionAddCachedServer(), + * smbc_setFunctionAddCachedServer() + */ + smbc_add_cached_srv_fn add_cached_server_fn; + + /** + * server cache lookup + * + * Use smbc_getFunctionGetCachedServer(), + * smbc_setFunctionGetCachedServer() + */ + smbc_get_cached_srv_fn get_cached_server_fn; + + /** + * server cache removal + * + * Use smbc_getFunctionRemoveCachedServer(), + * smbc_setFunctionRemoveCachedServer() + */ + smbc_remove_cached_srv_fn remove_cached_server_fn; + + /** + * server cache purging, try to remove all cached servers + * (disconnect) + * + * Use smbc_getFunctionPurgeCachedServers(), + * smbc_setFunctionPurgeCachedServers() + */ + smbc_purge_cached_srv_fn purge_cached_servers_fn; + + /** + * Space to store private data of the server cache. + * + * Use smbc_getServerCacheData(), smbc_setServerCacheData() + */ + struct smbc_server_cache * server_cache_data; + } cache; + + /* + * Very old configuration options. + * + * Use smbc_option_set() and smbc_option_get() instead. + */ + struct + { + int bits; + } flags; + + /** user options selections that apply to this session + * + * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. + * + * NEW OPTIONS ARE NOT ADDED HERE! + * + * We must maintain ABI backward compatibility. We now use + * smbc_option_set() and smbc_option_get() for all newly added + * options. + */ + struct _smbc_options { + + /* + * From how many local master browsers should the list of + * workgroups be retrieved? It can take up to 12 minutes or + * longer after a server becomes a local master browser, for + * it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client + * never knows which local master browser will be found first, + * the one which is found first and used to retrieve a browse + * list may have an incomplete or empty browse list. By + * requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small + * networks (few workgroups), it is recommended that this + * value be set to 0, causing the browse lists from all found + * local master browsers to be retrieved and merged. For + * networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ + int browse_max_lmb_count; + + /* + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ + int urlencode_readdir_entries; + + /* + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ + int one_share_per_server; + } options; + + /** INTERNAL DATA + * do _NOT_ touch this from your program ! + */ + struct SMBC_internal_data * internal; +}; + + #endif /* SMBCLIENT_H_INCLUDED */ diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c index e0571fa9fe..7ff92f1b4e 100644 --- a/source3/libsmb/libsmb_cache.c +++ b/source3/libsmb/libsmb_cache.c @@ -151,7 +151,7 @@ SMBC_get_cached_server(SMBCCTX * context, * a connection to the server (other than the * attribute server connection) is cool. */ - if (context->one_share_per_server) { + if (context->options.one_share_per_server) { /* * The currently connected share name * doesn't match the requested share, so diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index 1505d50a43..6b7a19e1e4 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -41,6 +41,15 @@ SMBCCTX * smbc_new_context(void) { SMBCCTX *context; + + /* + * All newly added context fields should be placed in SMBC_internal_data, + * not directly in SMBCCTX. + */ +# undef OLD +# define OLD(field) context->field +# undef NEW +# define NEW(field) context->internal->field context = SMB_MALLOC_P(SMBCCTX); if (!context) { @@ -48,66 +57,73 @@ smbc_new_context(void) return NULL; } - - /* Initialize the context and establish reasonable defaults */ ZERO_STRUCTP(context); + + context->internal = SMB_MALLOC_P(struct SMBC_internal_data); + if (!context->internal) { + SAFE_FREE(context); + errno = ENOMEM; + return NULL; + } + + /* Initialize the context and establish reasonable defaults */ + ZERO_STRUCTP(context->internal); - context->debug = 0; - context->timeout = 20000; /* 20 seconds */ + OLD(config.debug) = 0; + OLD(config.timeout) = 20000; /* 20 seconds */ - context->full_time_names = False; - context->share_mode = SMBC_SHAREMODE_DENY_NONE; - context->smb_encryption_level = 0; - context->browse_max_lmb_count = 3; /* # LMBs to query */ - context->urlencode_readdir_entries = False; - context->one_share_per_server = False; - context->use_kerberos = False; - context->fallback_after_kerberos = False; - context->no_auto_anonymous_login = False; + NEW(full_time_names) = False; + NEW(share_mode) = SMBC_SHAREMODE_DENY_NONE; + NEW(smb_encryption_level) = 0; + NEW(browse_max_lmb_count) = 3; /* # LMBs to query */ + NEW(urlencode_readdir_entries) = False; + NEW(one_share_per_server) = False; - context->server.get_auth_data_fn = SMBC_get_auth_data; - context->server.check_server_fn = SMBC_check_server; - context->server.remove_unused_server_fn = SMBC_remove_unused_server; + OLD(server.get_auth_data_fn) = SMBC_get_auth_data; + OLD(server.check_server_fn) = SMBC_check_server; + OLD(server.remove_unused_server_fn) = SMBC_remove_unused_server; - context->cache.server_cache_data = NULL; - context->cache.add_cached_server_fn = SMBC_add_cached_server; - context->cache.get_cached_server_fn = SMBC_get_cached_server; - context->cache.remove_cached_server_fn = SMBC_remove_cached_server; - context->cache.purge_cached_server_fn = SMBC_purge_cached_servers; + OLD(cache.server_cache_data) = NULL; + OLD(cache.add_cached_server_fn) = SMBC_add_cached_server; + OLD(cache.get_cached_server_fn) = SMBC_get_cached_server; + OLD(cache.remove_cached_server_fn) = SMBC_remove_cached_server; + OLD(cache.purge_cached_servers_fn) = SMBC_purge_cached_servers; - context->posix_emu.open_fn = SMBC_open_ctx; - context->posix_emu.creat_fn = SMBC_creat_ctx; - context->posix_emu.read_fn = SMBC_read_ctx; - context->posix_emu.write_fn = SMBC_write_ctx; - context->posix_emu.close_fn = SMBC_close_ctx; - context->posix_emu.unlink_fn = SMBC_unlink_ctx; - context->posix_emu.rename_fn = SMBC_rename_ctx; - context->posix_emu.lseek_fn = SMBC_lseek_ctx; - context->posix_emu.ftruncate_fn = SMBC_ftruncate_ctx; - context->posix_emu.stat_fn = SMBC_stat_ctx; - context->posix_emu.fstat_fn = SMBC_fstat_ctx; - context->posix_emu.opendir_fn = SMBC_opendir_ctx; - context->posix_emu.closedir_fn = SMBC_closedir_ctx; - context->posix_emu.readdir_fn = SMBC_readdir_ctx; - context->posix_emu.getdents_fn = SMBC_getdents_ctx; - context->posix_emu.mkdir_fn = SMBC_mkdir_ctx; - context->posix_emu.rmdir_fn = SMBC_rmdir_ctx; - context->posix_emu.telldir_fn = SMBC_telldir_ctx; - context->posix_emu.lseekdir_fn = SMBC_lseekdir_ctx; - context->posix_emu.fstatdir_fn = SMBC_fstatdir_ctx; - context->posix_emu.chmod_fn = SMBC_chmod_ctx; - context->posix_emu.utimes_fn = SMBC_utimes_ctx; - context->posix_emu.setxattr_fn = SMBC_setxattr_ctx; - context->posix_emu.getxattr_fn = SMBC_getxattr_ctx; - context->posix_emu.removexattr_fn = SMBC_removexattr_ctx; - context->posix_emu.listxattr_fn = SMBC_listxattr_ctx; + OLD(posix_emu.open_fn) = SMBC_open_ctx; + OLD(posix_emu.creat_fn) = SMBC_creat_ctx; + OLD(posix_emu.read_fn) = SMBC_read_ctx; + OLD(posix_emu.write_fn) = SMBC_write_ctx; + OLD(posix_emu.close_fn) = SMBC_close_ctx; + OLD(posix_emu.unlink_fn) = SMBC_unlink_ctx; + OLD(posix_emu.rename_fn) = SMBC_rename_ctx; + OLD(posix_emu.lseek_fn) = SMBC_lseek_ctx; + NEW(posix_emu.ftruncate_fn) = SMBC_ftruncate_ctx; + OLD(posix_emu.stat_fn) = SMBC_stat_ctx; + OLD(posix_emu.fstat_fn) = SMBC_fstat_ctx; + OLD(posix_emu.opendir_fn) = SMBC_opendir_ctx; + OLD(posix_emu.closedir_fn) = SMBC_closedir_ctx; + OLD(posix_emu.readdir_fn) = SMBC_readdir_ctx; + OLD(posix_emu.getdents_fn) = SMBC_getdents_ctx; + OLD(posix_emu.mkdir_fn) = SMBC_mkdir_ctx; + OLD(posix_emu.rmdir_fn) = SMBC_rmdir_ctx; + OLD(posix_emu.telldir_fn) = SMBC_telldir_ctx; + OLD(posix_emu.lseekdir_fn) = SMBC_lseekdir_ctx; + OLD(posix_emu.fstatdir_fn) = SMBC_fstatdir_ctx; + OLD(posix_emu.chmod_fn) = SMBC_chmod_ctx; + OLD(posix_emu.utimes_fn) = SMBC_utimes_ctx; + OLD(posix_emu.setxattr_fn) = SMBC_setxattr_ctx; + OLD(posix_emu.getxattr_fn) = SMBC_getxattr_ctx; + OLD(posix_emu.removexattr_fn) = SMBC_removexattr_ctx; + OLD(posix_emu.listxattr_fn) = SMBC_listxattr_ctx; - context->printing.open_print_job_fn = SMBC_open_print_job_ctx; - context->printing.print_file_fn = SMBC_print_file_ctx; - context->printing.list_print_jobs_fn = SMBC_list_print_jobs_ctx; - context->printing.unlink_print_job_fn = SMBC_unlink_print_job_ctx; + OLD(printing.open_print_job_fn) = SMBC_open_print_job_ctx; + OLD(printing.print_file_fn) = SMBC_print_file_ctx; + OLD(printing.list_print_jobs_fn) = SMBC_list_print_jobs_ctx; + OLD(printing.unlink_print_job_fn) = SMBC_unlink_print_job_ctx; return context; +#undef OLD +#undef NEW } /* @@ -130,20 +146,20 @@ smbc_free_context(SMBCCTX *context, SMBCFILE * f; DEBUG(1,("Performing aggressive shutdown.\n")); - f = context->files; + f = context->internal->files; while (f) { (context->posix_emu.close_fn)(context, f); f = f->next; } - context->files = NULL; + context->internal->files = NULL; /* First try to remove the servers the nice way. */ - if (context->cache.purge_cached_server_fn(context)) { + if (context->cache.purge_cached_servers_fn(context)) { SMBCSRV * s; SMBCSRV * next; DEBUG(1, ("Could not purge all servers, " "Nice way shutdown failed.\n")); - s = context->servers; + s = context->internal->servers; while (s) { DEBUG(1, ("Forced shutdown: %p (fd=%d)\n", s, s->cli->fd)); @@ -151,28 +167,28 @@ smbc_free_context(SMBCCTX *context, (context->cache.remove_cached_server_fn)(context, s); next = s->next; - DLIST_REMOVE(context->servers, s); + DLIST_REMOVE(context->internal->servers, s); SAFE_FREE(s); s = next; } - context->servers = NULL; + context->internal->servers = NULL; } } else { /* This is the polite way */ - if ((context->cache.purge_cached_server_fn)(context)) { + if ((context->cache.purge_cached_servers_fn)(context)) { DEBUG(1, ("Could not purge all servers, " "free_context failed.\n")); errno = EBUSY; return 1; } - if (context->servers) { + if (context->internal->servers) { DEBUG(1, ("Active servers in context, " "free_context failed.\n")); errno = EBUSY; return 1; } - if (context->files) { + if (context->internal->files) { DEBUG(1, ("Active files in context, " "free_context failed.\n")); errno = EBUSY; @@ -181,9 +197,9 @@ smbc_free_context(SMBCCTX *context, } /* Things we have to clean up */ - SAFE_FREE(context->workgroup); - SAFE_FREE(context->netbios_name); - SAFE_FREE(context->user); + SAFE_FREE(context->config.workgroup); + SAFE_FREE(context->config.netbios_name); + SAFE_FREE(context->config.user); DEBUG(3, ("Context %p successfully freed\n", context)); SAFE_FREE(context); @@ -219,7 +235,7 @@ smbc_option_set(SMBCCTX *context, * Log to standard error instead of standard output. */ option_value.b = (bool) va_arg(ap, int); - context->debug_stderr = option_value.b; + context->internal->debug_stderr = option_value.b; } else if (strcmp(option_name, "full_time_names") == 0) { /* @@ -231,7 +247,7 @@ smbc_option_set(SMBCCTX *context, * CREATE_TIME.) */ option_value.b = (bool) va_arg(ap, int); - context->full_time_names = option_value.b; + context->internal->full_time_names = option_value.b; } else if (strcmp(option_name, "open_share_mode") == 0) { /* @@ -239,7 +255,7 @@ smbc_option_set(SMBCCTX *context, * SMBC_open_ctx(). The default is SMBC_SHAREMODE_DENY_NONE. */ option_value.i = va_arg(ap, int); - context->share_mode = (smbc_share_mode) option_value.i; + context->internal->share_mode = (smbc_share_mode) option_value.i; } else if (strcmp(option_name, "user_data") == 0) { /* @@ -247,7 +263,7 @@ smbc_option_set(SMBCCTX *context, * with smbc_option_get() */ option_value.v = va_arg(ap, void *); - context->user_data = option_value.v; + context->internal->user_data = option_value.v; } else if (strcmp(option_name, "smb_encrypt_level") == 0) { /* * Save an encoded value for encryption level. @@ -255,11 +271,11 @@ smbc_option_set(SMBCCTX *context, */ option_value.s = va_arg(ap, const char *); if (strcmp(option_value.s, "none") == 0) { - context->smb_encryption_level = 0; + context->internal->smb_encryption_level = 0; } else if (strcmp(option_value.s, "request") == 0) { - context->smb_encryption_level = 1; + context->internal->smb_encryption_level = 1; } else if (strcmp(option_value.s, "require") == 0) { - context->smb_encryption_level = 2; + context->internal->smb_encryption_level = 2; } } else if (strcmp(option_name, "browse_max_lmb_count") == 0) { /* @@ -280,7 +296,7 @@ smbc_option_set(SMBCCTX *context, * variable is probably somewhere around 3. (Default: 3). */ option_value.i = va_arg(ap, int); - context->browse_max_lmb_count = option_value.i; + context->internal->browse_max_lmb_count = option_value.i; } else if (strcmp(option_name, "urlencode_readdir_entries") == 0) { /* @@ -307,7 +323,7 @@ smbc_option_set(SMBCCTX *context, * For backwards compatibility, this option defaults to False. */ option_value.b = (bool) va_arg(ap, int); - context->urlencode_readdir_entries = option_value.b; + context->internal->urlencode_readdir_entries = option_value.b; } else if (strcmp(option_name, "one_share_per_server") == 0) { /* @@ -321,19 +337,31 @@ smbc_option_set(SMBCCTX *context, * and issuing a new TREE CONNECT when the share is accessed. */ option_value.b = (bool) va_arg(ap, int); - context->one_share_per_server = option_value.b; + context->options.one_share_per_server = option_value.b; } else if (strcmp(option_name, "use_kerberos") == 0) { option_value.b = (bool) va_arg(ap, int); - context->use_kerberos = option_value.b; + if (option_value.b) { + context->flags.bits |= SMB_CTX_FLAG_USE_KERBEROS; + } else { + context->flags.bits &= ~SMB_CTX_FLAG_USE_KERBEROS; + } } else if (strcmp(option_name, "fallback_after_kerberos") == 0) { option_value.b = (bool) va_arg(ap, int); - context->fallback_after_kerberos = option_value.b; + if (option_value.b) { + context->flags.bits |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + } else { + context->flags.bits &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + } } else if (strcmp(option_name, "no_auto_anonymous_login") == 0) { option_value.b = (bool) va_arg(ap, int); - context->no_auto_anonymous_login = option_value.b; + if (option_value.b) { + context->flags.bits |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; + } else { + context->flags.bits &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; + } } va_end(ap); @@ -347,14 +375,16 @@ void * smbc_option_get(SMBCCTX *context, char *option_name) { + int bits; + if (strcmp(option_name, "debug_stderr") == 0) { /* * Log to standard error instead of standard output. */ #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->debug_stderr; + return (void *) (intptr_t) context->internal->debug_stderr; #else - return (void *) context->debug_stderr; + return (void *) context->internal->debug_stderr; #endif } else if (strcmp(option_name, "full_time_names") == 0) { @@ -367,9 +397,9 @@ smbc_option_get(SMBCCTX *context, * CREATE_TIME.) */ #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->full_time_names; + return (void *) (intptr_t) context->internal->full_time_names; #else - return (void *) context->full_time_names; + return (void *) context->internal->full_time_names; #endif } else if (strcmp(option_name, "user_data") == 0) { @@ -377,13 +407,13 @@ smbc_option_get(SMBCCTX *context, * Return the user data handle which was saved by the user * with smbc_option_set() */ - return context->user_data; + return context->internal->user_data; } else if (strcmp(option_name, "smb_encrypt_level") == 0) { /* * Return the current smb encrypt negotiate option as a string. */ - switch (context->smb_encryption_level) { + switch (context->internal->smb_encryption_level) { case 0: return (void *) "none"; case 1: @@ -402,7 +432,7 @@ smbc_option_get(SMBCCTX *context, SMBCSRV *s; unsigned int num_servers = 0; - for (s = context->servers; s; s = s->next) { + for (s = context->internal->servers; s; s = s->next) { num_servers++; if (s->cli->trans_enc_state == NULL) { return (void *)false; @@ -433,9 +463,9 @@ smbc_option_get(SMBCCTX *context, * variable is probably somewhere around 3. (Default: 3). */ #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->browse_max_lmb_count; + return (void *) (intptr_t) context->internal->browse_max_lmb_count; #else - return (void *) context->browse_max_lmb_count; + return (void *) context->internal->browse_max_lmb_count; #endif } else if (strcmp(option_name, "urlencode_readdir_entries") == 0) { @@ -463,9 +493,9 @@ smbc_option_get(SMBCCTX *context, * For backwards compatibility, this option defaults to False. */ #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->urlencode_readdir_entries; + return (void *)(intptr_t) context->internal->urlencode_readdir_entries; #else - return (void *) (bool) context->urlencode_readdir_entries; + return (void *) (bool) context->internal->urlencode_readdir_entries; #endif } else if (strcmp(option_name, "one_share_per_server") == 0) { @@ -480,30 +510,43 @@ smbc_option_get(SMBCCTX *context, * and issuing a new TREE CONNECT when the share is accessed. */ #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->one_share_per_server; + return (void *) (intptr_t) context->internal->one_share_per_server; #else - return (void *) (bool) context->one_share_per_server; + return (void *) (bool) context->internal->one_share_per_server; #endif } else if (strcmp(option_name, "use_kerberos") == 0) { + bits = context->flags.bits; #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->use_kerberos; + return (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS + ? (void *) (intptr_t) 1 + : (void *) (intptr_t) 0); #else - return (void *) (bool) context->use_kerberos; + return (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS + ? (void *) (bool) 1 + : (void *) (bool) 0); #endif } else if (strcmp(option_name, "fallback_after_kerberos") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->fallback_after_kerberos; + return (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS + ? (void *) (intptr_t) 1 + : (void *) (intptr_t) 0); #else - return (void *) (bool) context->fallback_after_kerberos; + return (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS + ? (void *) (bool) 1 + : (void *) (bool) 0); #endif } else if (strcmp(option_name, "no_auto_anonymous_login") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->no_auto_anonymous_login; + return (context->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON + ? (void *) (intptr_t) 1 + : (void *) (intptr_t) 0); #else - return (void *) (bool) context->no_auto_anonymous_login; + return (context->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON + ? (void *) (bool) 1 + : (void *) (bool) 0); #endif } @@ -532,13 +575,13 @@ smbc_init_context(SMBCCTX *context) } /* Do not initialise the same client twice */ - if (context->initialized) { + if (context->internal->initialized) { return 0; } if (!context->server.get_auth_data_fn || - context->debug < 0 || - context->debug > 100) { + context->config.debug < 0 || + context->config.debug > 100) { errno = EINVAL; return NULL; @@ -554,12 +597,12 @@ smbc_init_context(SMBCCTX *context) TALLOC_CTX *frame = talloc_stackframe(); /* Set this to what the user wants */ - DEBUGLEVEL = context->debug; + DEBUGLEVEL = context->config.debug; load_case_tables(); setup_logging("libsmbclient", True); - if (context->debug_stderr) { + if (context->internal->debug_stderr) { dbf = x_stderr; x_setbuf(x_stderr, NULL); } @@ -630,24 +673,24 @@ smbc_init_context(SMBCCTX *context) TALLOC_FREE(frame); } - if (!context->user) { + if (!context->config.user) { /* * FIXME: Is this the best way to get the user info? */ user = getenv("USER"); /* walk around as "guest" if no username can be found */ - if (!user) context->user = SMB_STRDUP("guest"); - else context->user = SMB_STRDUP(user); + if (!user) context->config.user = SMB_STRDUP("guest"); + else context->config.user = SMB_STRDUP(user); } - if (!context->netbios_name) { + if (!context->config.netbios_name) { /* * We try to get our netbios name from the config. If that * fails we fall back on constructing our netbios name from * our hostname etc */ if (global_myname()) { - context->netbios_name = SMB_STRDUP(global_myname()); + context->config.netbios_name = SMB_STRDUP(global_myname()); } else { /* @@ -655,39 +698,39 @@ smbc_init_context(SMBCCTX *context) * lazy for the moment */ pid = sys_getpid(); - context->netbios_name = (char *)SMB_MALLOC(17); - if (!context->netbios_name) { + context->config.netbios_name = (char *)SMB_MALLOC(17); + if (!context->config.netbios_name) { errno = ENOMEM; return NULL; } - slprintf(context->netbios_name, 16, - "smbc%s%d", context->user, pid); + slprintf(context->config.netbios_name, 16, + "smbc%s%d", context->config.user, pid); } } - DEBUG(1, ("Using netbios name %s.\n", context->netbios_name)); + DEBUG(1, ("Using netbios name %s.\n", context->config.netbios_name)); - if (!context->workgroup) { + if (!context->config.workgroup) { if (lp_workgroup()) { - context->workgroup = SMB_STRDUP(lp_workgroup()); + context->config.workgroup = SMB_STRDUP(lp_workgroup()); } else { /* TODO: Think about a decent default workgroup */ - context->workgroup = SMB_STRDUP("samba"); + context->config.workgroup = SMB_STRDUP("samba"); } } - DEBUG(1, ("Using workgroup %s.\n", context->workgroup)); + DEBUG(1, ("Using workgroup %s.\n", context->config.workgroup)); /* shortest timeout is 1 second */ - if (context->timeout > 0 && context->timeout < 1000) - context->timeout = 1000; + if (context->config.timeout > 0 && context->config.timeout < 1000) + context->config.timeout = 1000; /* * FIXME: Should we check the function pointers here? */ - context->initialized = True; + context->internal->initialized = True; return context; } @@ -705,56 +748,56 @@ smbc_version(void) char * smbc_getNetbiosName(SMBCCTX *c) { - return c->netbios_name; + return c->config.netbios_name; } /** Set the netbios name used for making connections */ void smbc_setNetbiosName(SMBCCTX *c, char * netbios_name) { - c->netbios_name = netbios_name; + c->config.netbios_name = netbios_name; } /** Get the workgroup used for making connections */ char * smbc_getWorkgroup(SMBCCTX *c) { - return c->workgroup; + return c->config.workgroup; } /** Set the workgroup used for making connections */ void smbc_setWorkgroup(SMBCCTX *c, char * workgroup) { - c->workgroup = workgroup; + c->config.workgroup = workgroup; } /** Get the username used for making connections */ char * smbc_getUser(SMBCCTX *c) { - return c->user; + return c->config.user; } /** Set the username used for making connections */ void smbc_setUser(SMBCCTX *c, char * user) { - c->user = user; + c->config.user = user; } /** Get the debug level */ int smbc_getDebug(SMBCCTX *c) { - return c->debug; + return c->config.debug; } /** Set the debug level */ void smbc_setDebug(SMBCCTX *c, int debug) { - c->debug = debug; + c->config.debug = debug; } /** @@ -764,7 +807,7 @@ smbc_setDebug(SMBCCTX *c, int debug) int smbc_getTimeout(SMBCCTX *c) { - return c->timeout; + return c->config.timeout; } /** @@ -774,7 +817,7 @@ smbc_getTimeout(SMBCCTX *c) void smbc_setTimeout(SMBCCTX *c, int timeout) { - c->timeout = timeout; + c->config.timeout = timeout; } /** Get the function for obtaining authentication data */ @@ -886,7 +929,7 @@ smbc_setFunctionRemoveCachedServer(SMBCCTX *c, smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c) { - return c->cache.purge_cached_server_fn; + return c->cache.purge_cached_servers_fn; } /** @@ -896,7 +939,7 @@ smbc_getFunctionPurgeCachedServers(SMBCCTX *c) void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_srv_fn fn) { - c->cache.purge_cached_server_fn = fn; + c->cache.purge_cached_servers_fn = fn; } /** @@ -1014,13 +1057,13 @@ smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn) smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c) { - return c->posix_emu.ftruncate_fn; + return c->internal->posix_emu.ftruncate_fn; } void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn) { - c->posix_emu.ftruncate_fn = fn; + c->internal->posix_emu.ftruncate_fn = fn; } smbc_close_fn diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 9cb3351433..25020762a2 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -356,7 +356,7 @@ SMBC_opendir_ctx(SMBCCTX *context, struct sockaddr_storage rem_ss; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { DEBUG(4, ("no valid context\n")); errno = EINVAL + 8192; TALLOC_FREE(frame); @@ -400,7 +400,7 @@ SMBC_opendir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -446,9 +446,9 @@ SMBC_opendir_ctx(SMBCCTX *context, } /* Determine how many local master browsers to query */ - max_lmb_count = (context->browse_max_lmb_count == 0 + max_lmb_count = (context->internal->browse_max_lmb_count == 0 ? INT_MAX - : context->browse_max_lmb_count); + : context->internal->browse_max_lmb_count); memset(&u_info, '\0', sizeof(u_info)); u_info.username = talloc_strdup(frame,user); @@ -826,7 +826,7 @@ SMBC_opendir_ctx(SMBCCTX *context, } - DLIST_ADD(context->files, dir); + DLIST_ADD(context->internal->files, dir); TALLOC_FREE(frame); return dir; @@ -842,13 +842,13 @@ SMBC_closedir_ctx(SMBCCTX *context, { TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - if (!dir || !SMBC_dlist_contains(context->files, dir)) { + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -856,7 +856,7 @@ SMBC_closedir_ctx(SMBCCTX *context, remove_dir(dir); /* Clean it up */ - DLIST_REMOVE(context->files, dir); + DLIST_REMOVE(context->internal->files, dir); if (dir) { @@ -875,7 +875,7 @@ smbc_readdir_internal(SMBCCTX * context, struct smbc_dirent *src, int max_namebuf_len) { - if (context->urlencode_readdir_entries) { + if (context->internal->urlencode_readdir_entries) { /* url-encode the name. get back remaining buffer space */ max_namebuf_len = @@ -919,7 +919,7 @@ SMBC_readdir_ctx(SMBCCTX *context, /* Check that all is ok first ... */ - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; DEBUG(0, ("Invalid context in SMBC_readdir_ctx()\n")); @@ -928,7 +928,7 @@ SMBC_readdir_ctx(SMBCCTX *context, } - if (!dir || !SMBC_dlist_contains(context->files, dir)) { + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; DEBUG(0, ("Invalid dir in SMBC_readdir_ctx()\n")); @@ -960,8 +960,8 @@ SMBC_readdir_ctx(SMBCCTX *context, } - dirp = (struct smbc_dirent *)context->dirent; - maxlen = (sizeof(context->dirent) - + dirp = (struct smbc_dirent *)context->internal->dirent; + maxlen = (sizeof(context->internal->dirent) - sizeof(struct smbc_dirent)); smbc_readdir_internal(context, dirp, dirent, maxlen); @@ -991,7 +991,7 @@ SMBC_getdents_ctx(SMBCCTX *context, /* Check that all is ok first ... */ - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -999,7 +999,7 @@ SMBC_getdents_ctx(SMBCCTX *context, } - if (!dir || !SMBC_dlist_contains(context->files, dir)) { + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); @@ -1033,8 +1033,8 @@ SMBC_getdents_ctx(SMBCCTX *context, } /* Do urlencoding of next entry, if so selected */ - dirent = (struct smbc_dirent *)context->dirent; - maxlen = (sizeof(context->dirent) - + dirent = (struct smbc_dirent *)context->internal->dirent; + maxlen = (sizeof(context->internal->dirent) - sizeof(struct smbc_dirent)); smbc_readdir_internal(context, dirent, dirlist->dirent, maxlen); @@ -1102,7 +1102,7 @@ SMBC_mkdir_ctx(SMBCCTX *context, struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; @@ -1132,7 +1132,7 @@ SMBC_mkdir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1209,7 +1209,7 @@ SMBC_rmdir_ctx(SMBCCTX *context, struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; @@ -1239,7 +1239,7 @@ SMBC_rmdir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1325,7 +1325,7 @@ SMBC_telldir_ctx(SMBCCTX *context, { TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -1333,7 +1333,7 @@ SMBC_telldir_ctx(SMBCCTX *context, } - if (!dir || !SMBC_dlist_contains(context->files, dir)) { + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); @@ -1408,7 +1408,7 @@ SMBC_lseekdir_ctx(SMBCCTX *context, struct smbc_dir_list *list_ent = (struct smbc_dir_list *)NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -1465,7 +1465,7 @@ SMBC_fstatdir_ctx(SMBCCTX *context, struct stat *st) { - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; return -1; @@ -1490,7 +1490,7 @@ SMBC_chmod_ctx(SMBCCTX *context, uint16 mode; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -1521,7 +1521,7 @@ SMBC_chmod_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1570,7 +1570,7 @@ SMBC_utimes_ctx(SMBCCTX *context, time_t write_time; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -1627,7 +1627,7 @@ SMBC_utimes_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1668,7 +1668,7 @@ SMBC_unlink_ctx(SMBCCTX *context, SMBCSRV *srv = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -1699,7 +1699,7 @@ SMBC_unlink_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1802,8 +1802,8 @@ SMBC_rename_ctx(SMBCCTX *ocontext, TALLOC_CTX *frame = talloc_stackframe(); if (!ocontext || !ncontext || - !ocontext->initialized || - !ncontext->initialized) { + !ocontext->internal->initialized || + !ncontext->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -1834,7 +1834,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext, } if (!user1 || user1[0] == (char)0) { - user1 = talloc_strdup(frame, ocontext->user); + user1 = talloc_strdup(frame, ocontext->config.user); if (!user1) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1858,7 +1858,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext, } if (!user2 || user2[0] == (char)0) { - user2 = talloc_strdup(frame, ncontext->user); + user2 = talloc_strdup(frame, ncontext->config.user); if (!user2) { errno = ENOMEM; TALLOC_FREE(frame); diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 619176697b..62b990ed00 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -46,7 +46,7 @@ SMBC_open_ctx(SMBCCTX *context, int fd; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -78,7 +78,7 @@ SMBC_open_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -120,7 +120,7 @@ SMBC_open_ctx(SMBCCTX *context, /*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/ if ((fd = cli_open(targetcli, targetpath, flags, - context->share_mode)) < 0) { + context->internal->share_mode)) < 0) { /* Handle the error ... */ @@ -139,7 +139,7 @@ SMBC_open_ctx(SMBCCTX *context, file->offset = 0; file->file = True; - DLIST_ADD(context->files, file); + DLIST_ADD(context->internal->files, file); /* * If the file was opened in O_APPEND mode, all write @@ -208,7 +208,7 @@ SMBC_creat_ctx(SMBCCTX *context, mode_t mode) { - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; return NULL; @@ -246,7 +246,7 @@ SMBC_read_ctx(SMBCCTX *context, */ off_t offset; - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -256,7 +256,7 @@ SMBC_read_ctx(SMBCCTX *context, DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count)); - if (!file || !SMBC_dlist_contains(context->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -338,7 +338,7 @@ SMBC_write_ctx(SMBCCTX *context, /* First check all pointers before dereferencing them */ - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -346,7 +346,7 @@ SMBC_write_ctx(SMBCCTX *context, } - if (!file || !SMBC_dlist_contains(context->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -418,14 +418,14 @@ SMBC_close_ctx(SMBCCTX *context, struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - if (!file || !SMBC_dlist_contains(context->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -470,7 +470,7 @@ SMBC_close_ctx(SMBCCTX *context, * from the server cache if unused */ errno = SMBC_errno(context, targetcli); srv = file->srv; - DLIST_REMOVE(context->files, file); + DLIST_REMOVE(context->internal->files, file); SAFE_FREE(file->fname); SAFE_FREE(file); (context->server.remove_unused_server_fn)(context, srv); @@ -479,7 +479,7 @@ SMBC_close_ctx(SMBCCTX *context, } - DLIST_REMOVE(context->files, file); + DLIST_REMOVE(context->internal->files, file); SAFE_FREE(file->fname); SAFE_FREE(file); TALLOC_FREE(frame); @@ -509,7 +509,7 @@ SMBC_getatr(SMBCCTX * context, time_t write_time; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -698,14 +698,14 @@ SMBC_lseek_ctx(SMBCCTX *context, struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - if (!file || !SMBC_dlist_contains(context->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); @@ -803,14 +803,14 @@ SMBC_ftruncate_ctx(SMBCCTX *context, struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - if (!file || !SMBC_dlist_contains(context->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c index 2533f536c3..6706a59ba8 100644 --- a/source3/libsmb/libsmb_path.c +++ b/source3/libsmb/libsmb_path.c @@ -252,7 +252,8 @@ SMBC_parse_path(TALLOC_CTX *ctx, * to the workgroup in the provided context. */ if (pp_workgroup != NULL) { - *pp_workgroup = talloc_strdup(ctx, context->workgroup); + *pp_workgroup = + talloc_strdup(ctx, context->config.workgroup); } if (pp_options) { @@ -296,13 +297,13 @@ SMBC_parse_path(TALLOC_CTX *ctx, } if (*p == '/') { - int wl = strlen(context->workgroup); + int wl = strlen(context->config.workgroup); if (wl > 16) { wl = 16; } - *pp_server = talloc_strdup(ctx, context->workgroup); + *pp_server = talloc_strdup(ctx, context->config.workgroup); if (!*pp_server) { return -1; } diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c index f106080b6f..a03c15e024 100644 --- a/source3/libsmb/libsmb_printjob.c +++ b/source3/libsmb/libsmb_printjob.c @@ -42,7 +42,7 @@ SMBC_open_print_job_ctx(SMBCCTX *context, char *path = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -99,8 +99,8 @@ SMBC_print_file_ctx(SMBCCTX *c_file, char buf[4096]; TALLOC_CTX *frame = talloc_stackframe(); - if (!c_file || !c_file->initialized || - !c_print || !c_print->initialized) { + if (!c_file || !c_file->internal->initialized || + !c_print || !c_print->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -189,7 +189,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context, char *path = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -220,7 +220,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -267,7 +267,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context, int err; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); @@ -298,7 +298,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 978a843d30..70e0d57273 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -58,12 +58,12 @@ SMBC_remove_unused_server(SMBCCTX * context, SMBCFILE * file; /* are we being fooled ? */ - if (!context || !context->initialized || !srv) { + if (!context || !context->internal->initialized || !srv) { return 1; } /* Check all open files/directories for a relation with this server */ - for (file = context->files; file; file = file->next) { + for (file = context->internal->files; file; file = file->next) { if (file->srv == srv) { /* Still used */ DEBUG(3, ("smbc_remove_usused_server: " @@ -73,7 +73,7 @@ SMBC_remove_unused_server(SMBCCTX * context, } } - DLIST_REMOVE(context->servers, srv); + DLIST_REMOVE(context->internal->servers, srv); cli_shutdown(srv->cli); srv->cli = NULL; @@ -251,7 +251,7 @@ SMBC_server(TALLOC_CTX *ctx, * If we found a connection and we're only allowed one share per * server... */ - if (srv && *share != '\0' && context->one_share_per_server) { + if (srv && *share != '\0' && context->internal->one_share_per_server) { /* * ... then if there's no current connection to the share, @@ -322,7 +322,7 @@ SMBC_server(TALLOC_CTX *ctx, return NULL; } - make_nmb_name(&calling, context->netbios_name, 0x0); + make_nmb_name(&calling, context->config.netbios_name, 0x0); make_nmb_name(&called , server, 0x20); DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server)); @@ -339,14 +339,14 @@ SMBC_server(TALLOC_CTX *ctx, return NULL; } - if (context->use_kerberos) { + if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) { c->use_kerberos = True; } - if (context->fallback_after_kerberos) { + if (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) { c->fallback_after_kerberos = True; } - c->timeout = context->timeout; + c->timeout = context->config.timeout; /* * Force use of port 139 for first try if share is $IPC, empty, or @@ -428,7 +428,8 @@ SMBC_server(TALLOC_CTX *ctx, /* Failed. Try an anonymous login, if allowed by flags. */ username_used = ""; - if (context->no_auto_anonymous_login || + if ((context->flags.bits & + SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) || !NT_STATUS_IS_OK(cli_session_setup(c, username_used, *pp_password, 1, *pp_password, 0, @@ -451,7 +452,7 @@ SMBC_server(TALLOC_CTX *ctx, DEBUG(4,(" tconx ok\n")); - if (context->smb_encryption_level) { + if (context->internal->smb_encryption_level) { /* Attempt UNIX smb encryption. */ if (!NT_STATUS_IS_OK(cli_force_encryption(c, username_used, @@ -466,7 +467,7 @@ SMBC_server(TALLOC_CTX *ctx, DEBUG(4,(" SMB encrypt failed\n")); - if (context->smb_encryption_level == 2) { + if (context->internal->smb_encryption_level == 2) { cli_shutdown(c); errno = EPERM; return NULL; @@ -512,7 +513,7 @@ SMBC_server(TALLOC_CTX *ctx, DEBUG(2, ("Server connect ok: //%s/%s: %p\n", server, share, srv)); - DLIST_ADD(context->servers, srv); + DLIST_ADD(context->internal->servers, srv); return srv; failed: @@ -566,7 +567,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, } flags = 0; - if (context->use_kerberos) { + if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) { flags |= CLI_FULL_CONNECTION_USE_KERBEROS; } @@ -586,7 +587,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, return NULL; } - if (context->smb_encryption_level) { + if (context->internal->smb_encryption_level) { /* Attempt UNIX smb encryption. */ if (!NT_STATUS_IS_OK(cli_force_encryption(ipc_cli, *pp_username, @@ -602,7 +603,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, DEBUG(4,(" SMB encrypt failed on IPC$\n")); - if (context->smb_encryption_level == 2) { + if (context->internal->smb_encryption_level == 2) { cli_shutdown(ipc_cli); errno = EPERM; return NULL; @@ -668,7 +669,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, return NULL; } - DLIST_ADD(context->servers, ipc_srv); + DLIST_ADD(context->internal->servers, ipc_srv); } return ipc_srv; diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index 06238863b7..6072547e08 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -35,7 +35,7 @@ static ino_t generate_inode(SMBCCTX *context, const char *name) { - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; return -1; @@ -126,7 +126,7 @@ SMBC_stat_ctx(SMBCCTX *context, SMB_INO_T ino = 0; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -157,7 +157,7 @@ SMBC_stat_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame,context->user); + user = talloc_strdup(frame,context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -222,14 +222,14 @@ SMBC_fstat_ctx(SMBCCTX *context, SMB_INO_T ino = 0; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - if (!file || !SMBC_dlist_contains(context->files, file)) { + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index 93ca0706b2..a420299341 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -609,7 +609,7 @@ dos_attr_parse(SMBCCTX *context, } attr_strings; /* Determine whether to use old-style or new-style attribute names */ - if (context->full_time_names) { + if (context->internal->full_time_names) { /* new-style names */ attr_strings.create_time_attr = "CREATE_TIME"; attr_strings.access_time_attr = "ACCESS_TIME"; @@ -759,7 +759,7 @@ cacl_get(SMBCCTX *context, } excl_attr_strings; /* Determine whether to use old-style or new-style attribute names */ - if (context->full_time_names) { + if (context->internal->full_time_names) { /* new-style names */ attr_strings.create_time_attr = "CREATE_TIME"; attr_strings.access_time_attr = "ACCESS_TIME"; @@ -1689,7 +1689,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, } attr_strings; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -1721,7 +1721,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1893,7 +1893,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, } /* Determine whether to use old-style or new-style attribute names */ - if (context->full_time_names) { + if (context->internal->full_time_names) { /* new-style names */ attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME"; attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME"; @@ -1984,7 +1984,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, } attr_strings; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -2015,7 +2015,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -2041,7 +2041,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, } /* Determine whether to use old-style or new-style attribute names */ - if (context->full_time_names) { + if (context->internal->full_time_names) { /* new-style names */ attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME"; attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME"; @@ -2118,7 +2118,7 @@ SMBC_removexattr_ctx(SMBCCTX *context, char *path = NULL; TALLOC_CTX *frame = talloc_stackframe(); - if (!context || !context->initialized) { + if (!context || !context->internal->initialized) { errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); @@ -2149,7 +2149,7 @@ SMBC_removexattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->user); + user = talloc_strdup(frame, context->config.user); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -2270,7 +2270,7 @@ SMBC_listxattr_ctx(SMBCCTX *context, ; const char * supported; - if (context->full_time_names) { + if (context->internal->full_time_names) { supported = supported_new; retsize = sizeof(supported_new); } else { -- cgit From 223940d9a887c5b98a5c873797302a6a9407ad7f Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 20:44:21 -0500 Subject: Additional revamped libsmbclient documentation - Ensured that all public functions have documentation in libsmbclient.h - Reformatted for "proper" indentation - Re-added temporarily-disabled alternate authentication function capability Derrell (This used to be commit 64b7150d92849a1e1e2416b9dcc12fae8d6bea99) --- source3/include/libsmb_internal.h | 48 +- source3/include/libsmbclient.h | 401 ++++++++-- source3/libsmb/libsmb_cache.c | 54 +- source3/libsmb/libsmb_compat.c | 52 +- source3/libsmb/libsmb_context.c | 1508 ++++++++++++++++++++----------------- source3/libsmb/libsmb_dir.c | 930 ++++++++++++----------- source3/libsmb/libsmb_file.c | 393 +++++----- source3/libsmb/libsmb_misc.c | 10 +- source3/libsmb/libsmb_path.c | 114 +-- source3/libsmb/libsmb_printjob.c | 178 ++--- source3/libsmb/libsmb_server.c | 275 +++---- source3/libsmb/libsmb_stat.c | 132 ++-- source3/libsmb/libsmb_xattr.c | 636 ++++++++-------- 13 files changed, 2579 insertions(+), 2152 deletions(-) (limited to 'source3') diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index 555b6ac138..e687e24268 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -111,23 +111,23 @@ struct _SMBCFILE { struct SMBC_internal_data { /* True when this handle is initialized */ - bool initialized; + bool initialized; #if 0 /* Left in libsmbclient.h for backward compatibility */ /* Netbios name used for making connections */ - char * netbios_name; + char * netbios_name; /* Workgroup used for making connections */ - char * workgroup; + char * workgroup; /* Username used for making connections */ - char * user; + char * user; /* Debug level */ - int debug; + int debug; /* Connection timeout value */ - int timeout; + int timeout; #endif /* dirent pointer location @@ -141,22 +141,22 @@ struct SMBC_internal_data { * According to , NAME_MAX is 255. Is it longer * anyplace else? */ - char dirent[1024]; + char dirent[1024]; /* * server connection list */ - SMBCSRV * servers; + SMBCSRV * servers; /* * open file/dir list */ - SMBCFILE * files; + SMBCFILE * files; /* * Log to standard error instead of the more typical standard output */ - bool debug_stderr; + bool debug_stderr; /* * Support "Create Time" in get/set with the *xattr() functions, if @@ -165,27 +165,34 @@ struct SMBC_internal_data { * CREATE_TIME. Default is FALSE, i.e. to use the old-style shorter * names and to not support CREATE time, for backward compatibility. */ - bool full_time_names; + bool full_time_names; /* * The share mode of a file being opened. To match POSIX semantics * (and maintain backward compatibility), DENY_NONE is the default. */ - smbc_share_mode share_mode; + smbc_share_mode share_mode; + + /* + * Authentication function which includes the context. This will be + * used if set; otherwise context->callbacks.auth_fn() will be used. + */ + smbc_get_auth_data_with_context_fn auth_fn_with_context; /* * An opaque (to this library) user data handle which can be set * and retrieved with smbc_option_set() and smbc_option_get(). */ - void * user_data; + void * user_data; /* * Should we attempt UNIX smb encryption ? * Set to 0 if we should never attempt, set to 1 if * encryption requested, set to 2 if encryption required. */ - int smb_encryption_level; + smbc_smb_encrypt_level smb_encryption_level; +#if 0 /* Left in libsmbclient.h for backward compatibility */ /* * From how many local master browsers should the list of * workgroups be retrieved? It can take up to 12 minutes or @@ -203,7 +210,7 @@ struct SMBC_internal_data { * networks with many workgroups, a suitable value for this * variable is probably somewhere around 3. (Default: 3). */ - int browse_max_lmb_count; + int browse_max_lmb_count; /* * There is a difference in the desired return strings from @@ -228,7 +235,7 @@ struct SMBC_internal_data { * * For backwards compatibility, this option defaults to False. */ - bool urlencode_readdir_entries; + bool urlencode_readdir_entries; /* * Some Windows versions appear to have a limit to the number @@ -240,15 +247,14 @@ struct SMBC_internal_data { * avoided by using only a single connection to each server, * and issuing a new TREE CONNECT when the share is accessed. */ - bool one_share_per_server; + bool one_share_per_server; -#if 0 /* Left in libsmbclient.h (flags) for backward compatibility */ /* Kerberos-related flags */ - bool use_kerberos; - bool fallback_after_kerberos; + bool use_kerberos; + bool fallback_after_kerberos; /* Don't try to do automatic anonymous login */ - bool no_auto_anonymous_login; + bool no_auto_anonymous_login; /* Server-related functions */ struct diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 4d78bb2568..28cad351de 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -155,6 +155,21 @@ typedef enum smbc_share_mode } smbc_share_mode; +/** + * Values for option SMB Encryption Level, as set and retrieved with + * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel() + */ +typedef enum smbc_smb_encrypt_level +{ + SMBC_ENCRYPTLEVEL_NONE = 0, + SMBC_ENCRYPTLEVEL_REQUEST = 1, + SMBC_ENCRYPTLEVEL_REQUIRE = 2 +} smbc_smb_encrypt_level; + + +typedef int smbc_bool; + + #ifndef ENOATTR # define ENOATTR ENOENT /* No such attribute */ #endif @@ -214,11 +229,17 @@ typedef struct _SMBCCTX SMBCCTX; /* + * Flags for SMBCCTX->flags + * * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. - * For these options, use smbc_option_set() and smbc_option_get(). + * Instead, use: + * smbc_setOptionUseKerberos() + * smbc_getOptionUseKerberos() + * smbc_setOptionFallbackAfterKerberos() + * smbc_getOptionFallbackAFterKerberos() + * smbc_setOptionNoAutoAnonymousLogin() + * smbc_getOptionNoAutoAnonymousLogin() */ - -/* Flags for SMBCCTX->flags */ # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) @@ -398,48 +419,286 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); typedef int (*smbc_purge_cached_srv_fn) (SMBCCTX * c); + +/***************************************** + * Getters and setters for CONFIGURATION * + *****************************************/ + /** Get the debug level */ -int smbc_getDebug(SMBCCTX *c); +int +smbc_getDebug(SMBCCTX *c); /** Set the debug level */ -void smbc_setDebug(SMBCCTX *c, int debug); +void +smbc_setDebug(SMBCCTX *c, int debug); /** Get the netbios name used for making connections */ -char * smbc_getNetbiosName(SMBCCTX *c); +char * +smbc_getNetbiosName(SMBCCTX *c); /** Set the netbios name used for making connections */ -void smbc_setNetbiosName(SMBCCTX *c, char * netbios_name); +void +smbc_setNetbiosName(SMBCCTX *c, char * netbios_name); /** Get the workgroup used for making connections */ -char * smbc_getWorkgroup(SMBCCTX *c); +char * +smbc_getWorkgroup(SMBCCTX *c); /** Set the workgroup used for making connections */ void smbc_setWorkgroup(SMBCCTX *c, char * workgroup); /** Get the username used for making connections */ -char * smbc_getUser(SMBCCTX *c); +char * +smbc_getUser(SMBCCTX *c); /** Set the username used for making connections */ -void smbc_setUser(SMBCCTX *c, char * user); +void +smbc_setUser(SMBCCTX *c, char * user); /** * Get the timeout used for waiting on connections and response data * (in milliseconds) */ -int smbc_getTimeout(SMBCCTX *c); +int +smbc_getTimeout(SMBCCTX *c); /** * Set the timeout used for waiting on connections and response data * (in milliseconds) */ -void smbc_setTimeout(SMBCCTX *c, int timeout); +void +smbc_setTimeout(SMBCCTX *c, int timeout); + + + +/*********************************** + * Getters and setters for OPTIONS * + ***********************************/ + +/** Get whether to log to standard error instead of standard output */ +smbc_bool +smbc_getOptionDebugToStderr(SMBCCTX *c); + +/** Set whether to log to standard error instead of standard output */ +void +smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b); + +/** + * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +smbc_bool +smbc_getOptionFullTimeNames(SMBCCTX *c); + +/** + * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +void +smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b); + +/** + * Get the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +smbc_share_mode +smbc_getOptionOpenShareMode(SMBCCTX *c); + +/** + * Set the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +void +smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode); + +/** Retrieve a previously saved user data handle */ +void * +smbc_getOptionUserData(SMBCCTX *c); + +/** Save a user data handle */ +void +smbc_setOptionUserData(SMBCCTX *c, void *user_data); + +/** Get the encoded value for encryption level. */ +smbc_smb_encrypt_level +smbc_getOptionSmbEncryptionLevel(SMBCCTX *c); + +/** Set the encoded value for encryption level. */ +void +smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level); + +/** + * Get from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +int +smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c); + +/** + * Set from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +void +smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count); + +/** + * Get whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +smbc_bool +smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c); + +/** + * Set whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +void +smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b); + +/** + * Get whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +smbc_bool +smbc_getOptionOneSharePerServer(SMBCCTX *c); + +/** + * Set whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +void +smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b); + +/** Get whether to enable use of kerberos */ +smbc_bool +smbc_getOptionUseKerberos(SMBCCTX *c); + +/** Set whether to enable use of kerberos */ +void +smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b); + +/** Get whether to fallback after kerberos */ +smbc_bool +smbc_getOptionFallbackAfterKerberos(SMBCCTX *c); + +/** Set whether to fallback after kerberos */ +void +smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b); + +/** Get whether to automatically select anonymous login */ +smbc_bool +smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c); + +/** Set whether to automatically select anonymous login */ +void +smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b); /** Get the function for obtaining authentication data */ smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); + + + +/************************************* + * Getters and setters for FUNCTIONS * + *************************************/ + /** Set the function for obtaining authentication data */ void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn f); +/** Get the new-style authentication function which includes the context. */ +smbc_get_auth_data_with_context_fn +smbc_getFunctionAuthDataWithContext(SMBCCTX *c); + +/** Set the new-style authentication function which includes the context. */ +void +smbc_setFunctionAuthDataWithContext(SMBCCTX *c, + smbc_get_auth_data_with_context_fn fn); + /** Get the function for checking if a server is still good */ smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c); @@ -492,9 +751,12 @@ struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache); -/** - * Callable functions for files. - */ + +/***************************************************************** + * Callable functions for files. * + * Each callable has a function signature typedef, a declaration * + * for the getter, and a declaration for the setter. * + *****************************************************************/ typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c, const char *fname, @@ -566,9 +828,12 @@ smbc_close_fn smbc_getFunctionClose(SMBCCTX *c); void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn f); -/** - * Callable functions for directories. - */ + +/***************************************************************** + * Callable functions for directories. * + * Each callable has a function signature typedef, a declaration * + * for the getter, and a declaration for the setter. * + *****************************************************************/ typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c, const char *fname); @@ -621,9 +886,12 @@ smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c); void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn f); -/** - * Callable functions applicable to both files and directories. - */ + +/***************************************************************** + * Callable functions applicable to both files and directories. * + * Each callable has a function signature typedef, a declaration * + * for the getter, and a declaration for the setter. * + *****************************************************************/ typedef int (*smbc_chmod_fn)(SMBCCTX *c, const char *fname, @@ -668,9 +936,12 @@ smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c); void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn f); -/** - * Callable functions related to printing - */ + +/***************************************************************** + * Callable functions for printing. * + * Each callable has a function signature typedef, a declaration * + * for the getter, and a declaration for the setter. * + *****************************************************************/ typedef int (*smbc_print_file_fn)(SMBCCTX *c_file, const char *fname, @@ -2341,6 +2612,7 @@ struct _SMBCCTX { /** * debug level * + * Manually setting/retrieving this value is deprecated. * Use smbc_getDebug() and smbc_setDebug() */ int debug; @@ -2348,6 +2620,7 @@ struct _SMBCCTX { /** * netbios name used for making connections * + * Manually setting/retrieving this value is deprecated. * Use smbc_getNetbiosName() and smbc_setNetbiosName() */ char * netbios_name; @@ -2355,6 +2628,7 @@ struct _SMBCCTX { /** * workgroup name used for making connections * + * Manually setting/retrieving this value is deprecated. * Use smbc_getWorkgroup() and smbc_setWorkgroup() */ char * workgroup; @@ -2362,6 +2636,7 @@ struct _SMBCCTX { /** * username used for making connections * + * Manually setting/retrieving this value is deprecated. * Use smbc_getUser() and smbc_setUser() */ char * user; @@ -2370,6 +2645,7 @@ struct _SMBCCTX { * timeout used for waiting on connections / response data (in * milliseconds) * + * Manually setting/retrieving this value is deprecated. * Use smbc_getTimeout() and smbc_setTimeout() */ int timeout; @@ -2379,6 +2655,8 @@ struct _SMBCCTX { * callable functions for files: * For usage and return values see the SMBC_* functions * + * Manually setting/retrieving these values is deprecated. + * * Use smbc_getFunction*() and smbc_setFunction*(), e.g. * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. */ @@ -2433,6 +2711,7 @@ struct _SMBCCTX { /** * authentication function callback: called upon auth requests * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() */ smbc_get_auth_data_fn get_auth_data_fn; @@ -2440,6 +2719,7 @@ struct _SMBCCTX { /** * check if a server is still good * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionCheckServer(), * smbc_setFunctionCheckServer() */ @@ -2448,6 +2728,7 @@ struct _SMBCCTX { /** * remove a server if unused * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionRemoveUnusedServer(), * smbc_setFunctionCheckServer() */ @@ -2467,6 +2748,7 @@ struct _SMBCCTX { /** * server cache addition * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionAddCachedServer(), * smbc_setFunctionAddCachedServer() */ @@ -2475,6 +2757,7 @@ struct _SMBCCTX { /** * server cache lookup * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionGetCachedServer(), * smbc_setFunctionGetCachedServer() */ @@ -2483,6 +2766,7 @@ struct _SMBCCTX { /** * server cache removal * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionRemoveCachedServer(), * smbc_setFunctionRemoveCachedServer() */ @@ -2492,6 +2776,7 @@ struct _SMBCCTX { * server cache purging, try to remove all cached servers * (disconnect) * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionPurgeCachedServers(), * smbc_setFunctionPurgeCachedServers() */ @@ -2500,6 +2785,7 @@ struct _SMBCCTX { /** * Space to store private data of the server cache. * + * Manually setting/retrieving this value is deprecated. * Use smbc_getServerCacheData(), smbc_setServerCacheData() */ struct smbc_server_cache * server_cache_data; @@ -2508,7 +2794,14 @@ struct _SMBCCTX { /* * Very old configuration options. * - * Use smbc_option_set() and smbc_option_get() instead. + * Manually setting/retrieving this value is deprecated. + * Use one of the following functions instead: + * smbc_setOptionUseKerberos() + * smbc_getOptionUseKerberos() + * smbc_setOptionFallbackAfterKerberos() + * smbc_getOptionFallbackAfterKerberos() + * smbc_setOptionNoAutoAnonymousLogin() + * smbc_getOptionNoAutoAnonymousLogin() */ struct { @@ -2521,66 +2814,12 @@ struct _SMBCCTX { * * NEW OPTIONS ARE NOT ADDED HERE! * - * We must maintain ABI backward compatibility. We now use - * smbc_option_set() and smbc_option_get() for all newly added - * options. + * To set and retrieve options, use the smbc_setOption*() and + * smbc_getOption*() functions. */ struct _smbc_options { - - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ int browse_max_lmb_count; - - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ int urlencode_readdir_entries; - - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ int one_share_per_server; } options; diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c index 7ff92f1b4e..ff13fd7eac 100644 --- a/source3/libsmb/libsmb_cache.c +++ b/source3/libsmb/libsmb_cache.c @@ -35,10 +35,10 @@ struct smbc_server_cache { char *workgroup; char *username; SMBCSRV *server; - + struct smbc_server_cache *next, *prev; }; - + /* @@ -54,51 +54,51 @@ SMBC_add_cached_server(SMBCCTX * context, const char * username) { struct smbc_server_cache * srvcache = NULL; - + if (!(srvcache = SMB_MALLOC_P(struct smbc_server_cache))) { errno = ENOMEM; DEBUG(3, ("Not enough space for server cache allocation\n")); return 1; } - + ZERO_STRUCTP(srvcache); - + srvcache->server = newsrv; - + srvcache->server_name = SMB_STRDUP(server); if (!srvcache->server_name) { errno = ENOMEM; goto failed; } - + srvcache->share_name = SMB_STRDUP(share); if (!srvcache->share_name) { errno = ENOMEM; goto failed; } - + srvcache->workgroup = SMB_STRDUP(workgroup); if (!srvcache->workgroup) { errno = ENOMEM; goto failed; } - + srvcache->username = SMB_STRDUP(username); if (!srvcache->username) { errno = ENOMEM; goto failed; } - + DLIST_ADD((context->cache.server_cache_data), srvcache); return 0; - - failed: + +failed: SAFE_FREE(srvcache->server_name); SAFE_FREE(srvcache->share_name); SAFE_FREE(srvcache->workgroup); SAFE_FREE(srvcache->username); SAFE_FREE(srvcache); - + return 1; } @@ -117,19 +117,19 @@ SMBC_get_cached_server(SMBCCTX * context, const char * user) { struct smbc_server_cache * srv = NULL; - + /* Search the cache lines */ for (srv = context->cache.server_cache_data; srv; srv = srv->next) { - + if (strcmp(server,srv->server_name) == 0 && strcmp(workgroup,srv->workgroup) == 0 && strcmp(user, srv->username) == 0) { - + /* If the share name matches, we're cool */ if (strcmp(share, srv->share_name) == 0) { return srv->server; } - + /* * We only return an empty share name or the attribute * server on an exact match (which would have been @@ -137,7 +137,7 @@ SMBC_get_cached_server(SMBCCTX * context, */ if (*share == '\0' || strcmp(share, "*IPC$") == 0) continue; - + /* * Never return an empty share name or the attribute * server if it wasn't what was requested. @@ -145,7 +145,7 @@ SMBC_get_cached_server(SMBCCTX * context, if (*srv->share_name == '\0' || strcmp(srv->share_name, "*IPC$") == 0) continue; - + /* * If we're only allowing one share per server, then * a connection to the server (other than the @@ -164,7 +164,7 @@ SMBC_get_cached_server(SMBCCTX * context, context->cache.remove_cached_server_fn(context, srv->server); continue; } - + /* * Save the new share name. We've * disconnected from the old share, and are @@ -179,13 +179,13 @@ SMBC_get_cached_server(SMBCCTX * context, context->cache.remove_cached_server_fn(context, srv->server); continue; } - - + + return srv->server; } } } - + return NULL; } @@ -200,10 +200,10 @@ SMBC_remove_cached_server(SMBCCTX * context, SMBCSRV * server) { struct smbc_server_cache * srv = NULL; - + for (srv = context->cache.server_cache_data; srv; srv = srv->next) { if (server == srv->server) { - + /* remove this sucker */ DLIST_REMOVE(context->cache.server_cache_data, srv); SAFE_FREE(srv->server_name); @@ -229,13 +229,13 @@ SMBC_purge_cached_servers(SMBCCTX * context) struct smbc_server_cache * srv; struct smbc_server_cache * next; int could_not_purge_all = 0; - + for (srv = context->cache.server_cache_data, next = (srv ? srv->next :NULL); srv; srv = next, next = (srv ? srv->next : NULL)) { - + if (SMBC_remove_unused_server(context, srv->server)) { /* could not be removed */ could_not_purge_all = 1; diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 7a0536a92d..9ef5e51fa9 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -55,11 +55,11 @@ static int add_fd(SMBCFILE * file) { struct smbc_compat_fdlist * f = smbc_compat_fd_avail; - + if (f) { /* We found one that's available */ DLIST_REMOVE(smbc_compat_fd_avail, f); - + } else { /* * None were available, so allocate one. Keep the number of @@ -72,19 +72,19 @@ add_fd(SMBCFILE * file) errno = EMFILE; return -1; } - + f = SMB_MALLOC_P(struct smbc_compat_fdlist); if (!f) { errno = ENOMEM; return -1; } - + f->fd = SMBC_BASE_FD + smbc_compat_nextfd++; } - + f->file = file; DLIST_ADD(smbc_compat_fd_in_use, f); - + return f->fd; } @@ -95,13 +95,13 @@ static int del_fd(int fd) { struct smbc_compat_fdlist * f = smbc_compat_fd_in_use; - + while (f) { if (f->fd == fd) break; f = f->next; } - + if (f) { /* found */ DLIST_REMOVE(smbc_compat_fd_in_use, f); @@ -111,7 +111,7 @@ del_fd(int fd) } return 1; } - + int @@ -122,17 +122,17 @@ smbc_init(smbc_get_auth_data_fn fn, statcont = smbc_new_context(); if (!statcont) return -1; - + smbc_setDebug(statcont, debug); smbc_setFunctionAuthData(statcont, fn); - + if (!smbc_init_context(statcont)) { smbc_free_context(statcont, False); return -1; } - + smbc_compat_initialized = 1; - + return 0; } return 0; @@ -143,11 +143,11 @@ SMBCCTX * smbc_set_context(SMBCCTX * context) { SMBCCTX *old_context = statcont; - + if (context) { /* Save provided context. It must have been initialized! */ statcont = context; - + /* You'd better know what you're doing. We won't help you. */ smbc_compat_initialized = 1; } @@ -163,11 +163,11 @@ smbc_open(const char *furl, { SMBCFILE * file; int fd; - + file = smbc_getFunctionOpen(statcont)(statcont, furl, flags, mode); if (!file) return -1; - + fd = add_fd(file); if (fd == -1) smbc_getFunctionClose(statcont)(statcont, file); @@ -181,11 +181,11 @@ smbc_creat(const char *furl, { SMBCFILE * file; int fd; - + file = smbc_getFunctionCreat(statcont)(statcont, furl, mode); if (!file) return -1; - + fd = add_fd(file); if (fd == -1) { /* Hmm... should we delete the file too ? I guess we could try */ @@ -250,15 +250,15 @@ smbc_opendir(const char *durl) { SMBCFILE * file; int fd; - + file = smbc_getFunctionOpendir(statcont)(statcont, durl); if (!file) return -1; - + fd = add_fd(file); if (fd == -1) smbc_getFunctionClosedir(statcont)(statcont, file); - + return fd; } @@ -357,14 +357,14 @@ smbc_utime(const char *fname, struct utimbuf *utbuf) { struct timeval tv[2]; - + if (utbuf == NULL) return smbc_getFunctionUtimes(statcont)(statcont, fname, NULL); - + tv[0].tv_sec = utbuf->actime; tv[1].tv_sec = utbuf->modtime; tv[0].tv_usec = tv[1].tv_usec = 0; - + return smbc_getFunctionUtimes(statcont)(statcont, fname, tv); } #endif @@ -519,7 +519,7 @@ int smbc_open_print_job(const char *fname) { SMBCFILE * file; - + file = smbc_getFunctionOpenPrintJob(statcont)(statcont, fname); if (!file) return -1; return file->cli_fd; diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index 6b7a19e1e4..8af49d12be 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -40,88 +40,88 @@ static int SMBC_initialized = 0; SMBCCTX * smbc_new_context(void) { - SMBCCTX *context; - - /* - * All newly added context fields should be placed in SMBC_internal_data, - * not directly in SMBCCTX. - */ -# undef OLD -# define OLD(field) context->field -# undef NEW -# define NEW(field) context->internal->field - - context = SMB_MALLOC_P(SMBCCTX); - if (!context) { - errno = ENOMEM; - return NULL; - } - - ZERO_STRUCTP(context); - - context->internal = SMB_MALLOC_P(struct SMBC_internal_data); - if (!context->internal) { - SAFE_FREE(context); - errno = ENOMEM; - return NULL; - } - - /* Initialize the context and establish reasonable defaults */ - ZERO_STRUCTP(context->internal); - - OLD(config.debug) = 0; - OLD(config.timeout) = 20000; /* 20 seconds */ - - NEW(full_time_names) = False; - NEW(share_mode) = SMBC_SHAREMODE_DENY_NONE; - NEW(smb_encryption_level) = 0; - NEW(browse_max_lmb_count) = 3; /* # LMBs to query */ - NEW(urlencode_readdir_entries) = False; - NEW(one_share_per_server) = False; - - OLD(server.get_auth_data_fn) = SMBC_get_auth_data; - OLD(server.check_server_fn) = SMBC_check_server; - OLD(server.remove_unused_server_fn) = SMBC_remove_unused_server; - - OLD(cache.server_cache_data) = NULL; - OLD(cache.add_cached_server_fn) = SMBC_add_cached_server; - OLD(cache.get_cached_server_fn) = SMBC_get_cached_server; - OLD(cache.remove_cached_server_fn) = SMBC_remove_cached_server; - OLD(cache.purge_cached_servers_fn) = SMBC_purge_cached_servers; - - OLD(posix_emu.open_fn) = SMBC_open_ctx; - OLD(posix_emu.creat_fn) = SMBC_creat_ctx; - OLD(posix_emu.read_fn) = SMBC_read_ctx; - OLD(posix_emu.write_fn) = SMBC_write_ctx; - OLD(posix_emu.close_fn) = SMBC_close_ctx; - OLD(posix_emu.unlink_fn) = SMBC_unlink_ctx; - OLD(posix_emu.rename_fn) = SMBC_rename_ctx; - OLD(posix_emu.lseek_fn) = SMBC_lseek_ctx; - NEW(posix_emu.ftruncate_fn) = SMBC_ftruncate_ctx; - OLD(posix_emu.stat_fn) = SMBC_stat_ctx; - OLD(posix_emu.fstat_fn) = SMBC_fstat_ctx; - OLD(posix_emu.opendir_fn) = SMBC_opendir_ctx; - OLD(posix_emu.closedir_fn) = SMBC_closedir_ctx; - OLD(posix_emu.readdir_fn) = SMBC_readdir_ctx; - OLD(posix_emu.getdents_fn) = SMBC_getdents_ctx; - OLD(posix_emu.mkdir_fn) = SMBC_mkdir_ctx; - OLD(posix_emu.rmdir_fn) = SMBC_rmdir_ctx; - OLD(posix_emu.telldir_fn) = SMBC_telldir_ctx; - OLD(posix_emu.lseekdir_fn) = SMBC_lseekdir_ctx; - OLD(posix_emu.fstatdir_fn) = SMBC_fstatdir_ctx; - OLD(posix_emu.chmod_fn) = SMBC_chmod_ctx; - OLD(posix_emu.utimes_fn) = SMBC_utimes_ctx; - OLD(posix_emu.setxattr_fn) = SMBC_setxattr_ctx; - OLD(posix_emu.getxattr_fn) = SMBC_getxattr_ctx; - OLD(posix_emu.removexattr_fn) = SMBC_removexattr_ctx; - OLD(posix_emu.listxattr_fn) = SMBC_listxattr_ctx; - - OLD(printing.open_print_job_fn) = SMBC_open_print_job_ctx; - OLD(printing.print_file_fn) = SMBC_print_file_ctx; - OLD(printing.list_print_jobs_fn) = SMBC_list_print_jobs_ctx; - OLD(printing.unlink_print_job_fn) = SMBC_unlink_print_job_ctx; - - return context; + SMBCCTX *context; + + /* + * All newly added context fields should be placed in + * SMBC_internal_data, not directly in SMBCCTX. + */ +#undef OLD +#define OLD(field) context->field +#undef NEW +#define NEW(field) context->internal->field + + context = SMB_MALLOC_P(SMBCCTX); + if (!context) { + errno = ENOMEM; + return NULL; + } + + ZERO_STRUCTP(context); + + context->internal = SMB_MALLOC_P(struct SMBC_internal_data); + if (!context->internal) { + SAFE_FREE(context); + errno = ENOMEM; + return NULL; + } + + /* Initialize the context and establish reasonable defaults */ + ZERO_STRUCTP(context->internal); + + OLD(config.debug) = 0; + OLD(config.timeout) = 20000; /* 20 seconds */ + + NEW(full_time_names) = False; + NEW(share_mode) = SMBC_SHAREMODE_DENY_NONE; + NEW(smb_encryption_level) = 0; + OLD(options.browse_max_lmb_count) = 3; /* # LMBs to query */ + OLD(options.urlencode_readdir_entries) = False; + OLD(options.one_share_per_server) = False; + + OLD(server.get_auth_data_fn) = SMBC_get_auth_data; + OLD(server.check_server_fn) = SMBC_check_server; + OLD(server.remove_unused_server_fn) = SMBC_remove_unused_server; + + OLD(cache.server_cache_data) = NULL; + OLD(cache.add_cached_server_fn) = SMBC_add_cached_server; + OLD(cache.get_cached_server_fn) = SMBC_get_cached_server; + OLD(cache.remove_cached_server_fn) = SMBC_remove_cached_server; + OLD(cache.purge_cached_servers_fn) = SMBC_purge_cached_servers; + + OLD(posix_emu.open_fn) = SMBC_open_ctx; + OLD(posix_emu.creat_fn) = SMBC_creat_ctx; + OLD(posix_emu.read_fn) = SMBC_read_ctx; + OLD(posix_emu.write_fn) = SMBC_write_ctx; + OLD(posix_emu.close_fn) = SMBC_close_ctx; + OLD(posix_emu.unlink_fn) = SMBC_unlink_ctx; + OLD(posix_emu.rename_fn) = SMBC_rename_ctx; + OLD(posix_emu.lseek_fn) = SMBC_lseek_ctx; + NEW(posix_emu.ftruncate_fn) = SMBC_ftruncate_ctx; + OLD(posix_emu.stat_fn) = SMBC_stat_ctx; + OLD(posix_emu.fstat_fn) = SMBC_fstat_ctx; + OLD(posix_emu.opendir_fn) = SMBC_opendir_ctx; + OLD(posix_emu.closedir_fn) = SMBC_closedir_ctx; + OLD(posix_emu.readdir_fn) = SMBC_readdir_ctx; + OLD(posix_emu.getdents_fn) = SMBC_getdents_ctx; + OLD(posix_emu.mkdir_fn) = SMBC_mkdir_ctx; + OLD(posix_emu.rmdir_fn) = SMBC_rmdir_ctx; + OLD(posix_emu.telldir_fn) = SMBC_telldir_ctx; + OLD(posix_emu.lseekdir_fn) = SMBC_lseekdir_ctx; + OLD(posix_emu.fstatdir_fn) = SMBC_fstatdir_ctx; + OLD(posix_emu.chmod_fn) = SMBC_chmod_ctx; + OLD(posix_emu.utimes_fn) = SMBC_utimes_ctx; + OLD(posix_emu.setxattr_fn) = SMBC_setxattr_ctx; + OLD(posix_emu.getxattr_fn) = SMBC_getxattr_ctx; + OLD(posix_emu.removexattr_fn) = SMBC_removexattr_ctx; + OLD(posix_emu.listxattr_fn) = SMBC_listxattr_ctx; + + OLD(printing.open_print_job_fn) = SMBC_open_print_job_ctx; + OLD(printing.print_file_fn) = SMBC_print_file_ctx; + OLD(printing.list_print_jobs_fn) = SMBC_list_print_jobs_ctx; + OLD(printing.unlink_print_job_fn) = SMBC_unlink_print_job_ctx; + + return context; #undef OLD #undef NEW } @@ -137,420 +137,268 @@ int smbc_free_context(SMBCCTX *context, int shutdown_ctx) { - if (!context) { - errno = EBADF; - return 1; - } - - if (shutdown_ctx) { - SMBCFILE * f; - DEBUG(1,("Performing aggressive shutdown.\n")); - - f = context->internal->files; - while (f) { - (context->posix_emu.close_fn)(context, f); - f = f->next; + if (!context) { + errno = EBADF; + return 1; } - context->internal->files = NULL; - /* First try to remove the servers the nice way. */ - if (context->cache.purge_cached_servers_fn(context)) { - SMBCSRV * s; - SMBCSRV * next; - DEBUG(1, ("Could not purge all servers, " - "Nice way shutdown failed.\n")); - s = context->internal->servers; - while (s) { - DEBUG(1, ("Forced shutdown: %p (fd=%d)\n", - s, s->cli->fd)); - cli_shutdown(s->cli); - (context->cache.remove_cached_server_fn)(context, - s); - next = s->next; - DLIST_REMOVE(context->internal->servers, s); - SAFE_FREE(s); - s = next; - } - context->internal->servers = NULL; - } - } - else { - /* This is the polite way */ - if ((context->cache.purge_cached_servers_fn)(context)) { - DEBUG(1, ("Could not purge all servers, " - "free_context failed.\n")); - errno = EBUSY; - return 1; - } - if (context->internal->servers) { - DEBUG(1, ("Active servers in context, " - "free_context failed.\n")); - errno = EBUSY; - return 1; + if (shutdown_ctx) { + SMBCFILE * f; + DEBUG(1,("Performing aggressive shutdown.\n")); + + f = context->internal->files; + while (f) { + (context->posix_emu.close_fn)(context, f); + f = f->next; + } + context->internal->files = NULL; + + /* First try to remove the servers the nice way. */ + if (context->cache.purge_cached_servers_fn(context)) { + SMBCSRV * s; + SMBCSRV * next; + DEBUG(1, ("Could not purge all servers, " + "Nice way shutdown failed.\n")); + s = context->internal->servers; + while (s) { + DEBUG(1, ("Forced shutdown: %p (fd=%d)\n", + s, s->cli->fd)); + cli_shutdown(s->cli); + (context->cache.remove_cached_server_fn)(context, + s); + next = s->next; + DLIST_REMOVE(context->internal->servers, s); + SAFE_FREE(s); + s = next; + } + context->internal->servers = NULL; + } } - if (context->internal->files) { - DEBUG(1, ("Active files in context, " - "free_context failed.\n")); - errno = EBUSY; - return 1; + else { + /* This is the polite way */ + if ((context->cache.purge_cached_servers_fn)(context)) { + DEBUG(1, ("Could not purge all servers, " + "free_context failed.\n")); + errno = EBUSY; + return 1; + } + if (context->internal->servers) { + DEBUG(1, ("Active servers in context, " + "free_context failed.\n")); + errno = EBUSY; + return 1; + } + if (context->internal->files) { + DEBUG(1, ("Active files in context, " + "free_context failed.\n")); + errno = EBUSY; + return 1; + } } - } - - /* Things we have to clean up */ - SAFE_FREE(context->config.workgroup); - SAFE_FREE(context->config.netbios_name); - SAFE_FREE(context->config.user); - - DEBUG(3, ("Context %p successfully freed\n", context)); - SAFE_FREE(context); - return 0; + + /* Things we have to clean up */ + SAFE_FREE(context->config.workgroup); + SAFE_FREE(context->config.netbios_name); + SAFE_FREE(context->config.user); + + DEBUG(3, ("Context %p successfully freed\n", context)); + SAFE_FREE(context); + return 0; } -/* - * Each time the context structure is changed, we have binary backward - * compatibility issues. Instead of modifying the public portions of the - * context structure to add new options, instead, we put them in the internal - * portion of the context structure and provide a set function for these new - * options. +/** + * Deprecated interface. Do not use. Instead, use the various + * smbc_setOption*() functions or smbc_setFunctionAuthDataWithContext(). */ void smbc_option_set(SMBCCTX *context, char *option_name, ... /* option_value */) { - va_list ap; - union { - int i; - bool b; - smbc_get_auth_data_with_context_fn auth_fn; - void *v; - const char *s; - } option_value; - - va_start(ap, option_name); - - if (strcmp(option_name, "debug_to_stderr") == 0) { - /* - * Log to standard error instead of standard output. - */ - option_value.b = (bool) va_arg(ap, int); - context->internal->debug_stderr = option_value.b; - - } else if (strcmp(option_name, "full_time_names") == 0) { - /* - * Use new-style time attribute names, e.g. WRITE_TIME rather - * than the old-style names such as M_TIME. This allows also - * setting/getting CREATE_TIME which was previously - * unimplemented. (Note that the old C_TIME was supposed to - * be CHANGE_TIME but was confused and sometimes referred to - * CREATE_TIME.) - */ - option_value.b = (bool) va_arg(ap, int); - context->internal->full_time_names = option_value.b; - - } else if (strcmp(option_name, "open_share_mode") == 0) { - /* - * The share mode to use for files opened with - * SMBC_open_ctx(). The default is SMBC_SHAREMODE_DENY_NONE. - */ - option_value.i = va_arg(ap, int); - context->internal->share_mode = (smbc_share_mode) option_value.i; - - } else if (strcmp(option_name, "user_data") == 0) { - /* - * Save a user data handle which may be retrieved by the user - * with smbc_option_get() - */ - option_value.v = va_arg(ap, void *); - context->internal->user_data = option_value.v; - } else if (strcmp(option_name, "smb_encrypt_level") == 0) { - /* - * Save an encoded value for encryption level. - * 0 = off, 1 = attempt, 2 = required. - */ - option_value.s = va_arg(ap, const char *); - if (strcmp(option_value.s, "none") == 0) { - context->internal->smb_encryption_level = 0; - } else if (strcmp(option_value.s, "request") == 0) { - context->internal->smb_encryption_level = 1; - } else if (strcmp(option_value.s, "require") == 0) { - context->internal->smb_encryption_level = 2; - } - } else if (strcmp(option_name, "browse_max_lmb_count") == 0) { - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ - option_value.i = va_arg(ap, int); - context->internal->browse_max_lmb_count = option_value.i; + va_list ap; + union { + int i; + bool b; + smbc_get_auth_data_with_context_fn auth_fn; + void *v; + const char *s; + } option_value; - } else if (strcmp(option_name, "urlencode_readdir_entries") == 0) { - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ - option_value.b = (bool) va_arg(ap, int); - context->internal->urlencode_readdir_entries = option_value.b; + va_start(ap, option_name); - } else if (strcmp(option_name, "one_share_per_server") == 0) { - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ - option_value.b = (bool) va_arg(ap, int); - context->options.one_share_per_server = option_value.b; - - } else if (strcmp(option_name, "use_kerberos") == 0) { - option_value.b = (bool) va_arg(ap, int); - if (option_value.b) { - context->flags.bits |= SMB_CTX_FLAG_USE_KERBEROS; - } else { - context->flags.bits &= ~SMB_CTX_FLAG_USE_KERBEROS; - } - - } else if (strcmp(option_name, "fallback_after_kerberos") == 0) { - option_value.b = (bool) va_arg(ap, int); - if (option_value.b) { - context->flags.bits |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; - } else { - context->flags.bits &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + if (strcmp(option_name, "debug_to_stderr") == 0) { + option_value.b = (bool) va_arg(ap, int); + smbc_setOptionDebugToStderr(context, option_value.b); + + } else if (strcmp(option_name, "full_time_names") == 0) { + option_value.b = (bool) va_arg(ap, int); + smbc_setOptionFullTimeNames(context, option_value.b); + + } else if (strcmp(option_name, "open_share_mode") == 0) { + option_value.i = va_arg(ap, int); + smbc_setOptionOpenShareMode(context, option_value.i); + + } else if (strcmp(option_name, "auth_function") == 0) { + option_value.auth_fn = + va_arg(ap, smbc_get_auth_data_with_context_fn); + smbc_setFunctionAuthDataWithContext(context, option_value.auth_fn); + + } else if (strcmp(option_name, "user_data") == 0) { + option_value.v = va_arg(ap, void *); + smbc_setOptionUserData(context, option_value.v); + + } else if (strcmp(option_name, "smb_encrypt_level") == 0) { + option_value.s = va_arg(ap, const char *); + if (strcmp(option_value.s, "none") == 0) { + smbc_setOptionSmbEncryptionLevel(context, + SMBC_ENCRYPTLEVEL_NONE); + } else if (strcmp(option_value.s, "request") == 0) { + smbc_setOptionSmbEncryptionLevel(context, + SMBC_ENCRYPTLEVEL_REQUEST); + } else if (strcmp(option_value.s, "require") == 0) { + smbc_setOptionSmbEncryptionLevel(context, + SMBC_ENCRYPTLEVEL_REQUIRE); + } + + } else if (strcmp(option_name, "browse_max_lmb_count") == 0) { + option_value.i = va_arg(ap, int); + smbc_setOptionBrowseMaxLmbCount(context, option_value.i); + + } else if (strcmp(option_name, "urlencode_readdir_entries") == 0) { + option_value.b = (bool) va_arg(ap, int); + smbc_setOptionUrlEncodeReaddirEntries(context, option_value.b); + + } else if (strcmp(option_name, "one_share_per_server") == 0) { + option_value.b = (bool) va_arg(ap, int); + smbc_setOptionOneSharePerServer(context, option_value.b); + + } else if (strcmp(option_name, "use_kerberos") == 0) { + option_value.b = (bool) va_arg(ap, int); + smbc_setOptionUseKerberos(context, option_value.b); + + } else if (strcmp(option_name, "fallback_after_kerberos") == 0) { + option_value.b = (bool) va_arg(ap, int); + smbc_setOptionFallbackAfterKerberos(context, option_value.b); + + } else if (strcmp(option_name, "no_auto_anonymous_login") == 0) { + option_value.b = (bool) va_arg(ap, int); + smbc_setOptionNoAutoAnonymousLogin(context, option_value.b); } - } else if (strcmp(option_name, "no_auto_anonymous_login") == 0) { - option_value.b = (bool) va_arg(ap, int); - if (option_value.b) { - context->flags.bits |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; - } else { - context->flags.bits &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; - } - } - - va_end(ap); + va_end(ap); } /* - * Retrieve the current value of an option + * Deprecated interface. Do not use. Instead, use the various + * smbc_getOption*() functions. */ void * smbc_option_get(SMBCCTX *context, char *option_name) { - int bits; - - if (strcmp(option_name, "debug_stderr") == 0) { - /* - * Log to standard error instead of standard output. - */ + int bits; + + if (strcmp(option_name, "debug_stderr") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->internal->debug_stderr; + return (void *) (intptr_t) smbc_getOptionDebugToStderr(context); #else - return (void *) context->internal->debug_stderr; + return (void *) smbc_getOptionDebugToStderr(context); #endif - - } else if (strcmp(option_name, "full_time_names") == 0) { - /* - * Use new-style time attribute names, e.g. WRITE_TIME rather - * than the old-style names such as M_TIME. This allows also - * setting/getting CREATE_TIME which was previously - * unimplemented. (Note that the old C_TIME was supposed to - * be CHANGE_TIME but was confused and sometimes referred to - * CREATE_TIME.) - */ + + } else if (strcmp(option_name, "full_time_names") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->internal->full_time_names; + return (void *) (intptr_t) smbc_getOptionFullTimeNames(context); #else - return (void *) context->internal->full_time_names; + return (void *) smbc_getOptionFullTimeNames(context); #endif - - } else if (strcmp(option_name, "user_data") == 0) { - /* - * Return the user data handle which was saved by the user - * with smbc_option_set() - */ - return context->internal->user_data; - - } else if (strcmp(option_name, "smb_encrypt_level") == 0) { - /* - * Return the current smb encrypt negotiate option as a string. - */ - switch (context->internal->smb_encryption_level) { - case 0: - return (void *) "none"; - case 1: - return (void *) "request"; - case 2: - return (void *) "require"; - } - - } else if (strcmp(option_name, "smb_encrypt_on") == 0) { - /* - * Return the current smb encrypt status option as a bool. - * false = off, true = on. We don't know what server is - * being requested, so we only return true if all servers - * are using an encrypted connection. - */ - SMBCSRV *s; - unsigned int num_servers = 0; - - for (s = context->internal->servers; s; s = s->next) { - num_servers++; - if (s->cli->trans_enc_state == NULL) { - return (void *)false; - } - } + + } else if (strcmp(option_name, "open_share_mode") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) (bool) (num_servers > 0); + return (void *) (intptr_t) smbc_getOptionOpenShareMode(context); #else - return (void *) (bool) (num_servers > 0); + return (void *) smbc_getOptionOpenShareMode(context); #endif - - } else if (strcmp(option_name, "browse_max_lmb_count") == 0) { - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ + + } else if (strcmp(option_name, "auth_function") == 0) { + return (void *) smbc_getFunctionAuthDataWithContext(context); + + } else if (strcmp(option_name, "user_data") == 0) { + return smbc_getOptionUserData(context); + + } else if (strcmp(option_name, "smb_encrypt_level") == 0) { + switch(smbc_getOptionSmbEncryptionLevel(context)) + { + case 0: + return (void *) "none"; + case 1: + return (void *) "request"; + case 2: + return (void *) "require"; + } + + } else if (strcmp(option_name, "smb_encrypt_on") == 0) { + SMBCSRV *s; + unsigned int num_servers = 0; + + for (s = context->internal->servers; s; s = s->next) { + num_servers++; + if (s->cli->trans_enc_state == NULL) { + return (void *)false; + } + } #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->internal->browse_max_lmb_count; + return (void *) (intptr_t) (bool) (num_servers > 0); #else - return (void *) context->internal->browse_max_lmb_count; + return (void *) (bool) (num_servers > 0); #endif - - } else if (strcmp(option_name, "urlencode_readdir_entries") == 0) { - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ + + } else if (strcmp(option_name, "browse_max_lmb_count") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *)(intptr_t) context->internal->urlencode_readdir_entries; + return (void *) (intptr_t) smbc_getOptionBrowseMaxLmbCount(context); #else - return (void *) (bool) context->internal->urlencode_readdir_entries; + return (void *) smbc_getOptionBrowseMaxLmbCount(context); #endif - - } else if (strcmp(option_name, "one_share_per_server") == 0) { - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ + + } else if (strcmp(option_name, "urlencode_readdir_entries") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (void *) (intptr_t) context->internal->one_share_per_server; + return (void *)(intptr_t) smbc_getOptionUrlEncodeReaddirEntries(context); #else - return (void *) (bool) context->internal->one_share_per_server; + return (void *) (bool) smbc_getOptionUrlEncodeReaddirEntries(context); #endif - - } else if (strcmp(option_name, "use_kerberos") == 0) { - bits = context->flags.bits; + + } else if (strcmp(option_name, "one_share_per_server") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS - ? (void *) (intptr_t) 1 - : (void *) (intptr_t) 0); + return (void *) (intptr_t) smbc_getOptionOneSharePerServer(context); #else - return (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS - ? (void *) (bool) 1 - : (void *) (bool) 0); + return (void *) (bool) smbc_getOptionOneSharePerServer(context); #endif - - } else if (strcmp(option_name, "fallback_after_kerberos") == 0) { + + } else if (strcmp(option_name, "use_kerberos") == 0) { + bits = context->flags.bits; #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS - ? (void *) (intptr_t) 1 - : (void *) (intptr_t) 0); + return (void *) (intptr_t) smbc_getOptionUseKerberos(context); #else - return (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS - ? (void *) (bool) 1 - : (void *) (bool) 0); + return (void *) (bool) smbc_getOptionUseKerberos(context); #endif - - } else if (strcmp(option_name, "no_auto_anonymous_login") == 0) { + + } else if (strcmp(option_name, "fallback_after_kerberos") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) - return (context->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON - ? (void *) (intptr_t) 1 - : (void *) (intptr_t) 0); + return (void *)(intptr_t) smbc_getOptionFallbackAfterKerberos(context); #else - return (context->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON - ? (void *) (bool) 1 - : (void *) (bool) 0); + return (void *) (bool) smbc_getOptionFallbackAfterKerberos(context); #endif - } - - return NULL; + + } else if (strcmp(option_name, "no_auto_anonymous_login") == 0) { +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) + return (void *) (intptr_t) smbc_getOptionNoAutoAnonymousLogin(context); +#else + return (void *) (bool) smbc_getOptionNoAutoAnonymousLogin(context); +#endif + } + + return NULL; } @@ -564,175 +412,175 @@ smbc_option_get(SMBCCTX *context, SMBCCTX * smbc_init_context(SMBCCTX *context) { - int pid; - char *user = NULL; - char *home = NULL; - extern bool in_client; - - if (!context) { - errno = EBADF; - return NULL; - } - - /* Do not initialise the same client twice */ - if (context->internal->initialized) { - return 0; - } - - if (!context->server.get_auth_data_fn || - context->config.debug < 0 || - context->config.debug > 100) { + int pid; + char *user = NULL; + char *home = NULL; + extern bool in_client; - errno = EINVAL; - return NULL; - - } - - if (!SMBC_initialized) { - /* - * Do some library-wide intializations the first time we get - * called - */ - bool conf_loaded = False; - TALLOC_CTX *frame = talloc_stackframe(); - - /* Set this to what the user wants */ - DEBUGLEVEL = context->config.debug; - - load_case_tables(); - - setup_logging("libsmbclient", True); - if (context->internal->debug_stderr) { - dbf = x_stderr; - x_setbuf(x_stderr, NULL); + if (!context) { + errno = EBADF; + return NULL; } - /* Here we would open the smb.conf file if needed ... */ + /* Do not initialise the same client twice */ + if (context->internal->initialized) { + return 0; + } - in_client = True; /* FIXME, make a param */ + if (!context->server.get_auth_data_fn || + context->config.debug < 0 || + context->config.debug > 100) { + + errno = EINVAL; + return NULL; + + } - home = getenv("HOME"); - if (home) { - char *conf = NULL; - if (asprintf(&conf, "%s/.smb/smb.conf", home) > 0) { - if (lp_load(conf, True, False, False, True)) { - conf_loaded = True; - } else { - DEBUG(5, ("Could not load config file: %s\n", - conf)); + if (!SMBC_initialized) { + /* + * Do some library-wide intializations the first time we get + * called + */ + bool conf_loaded = False; + TALLOC_CTX *frame = talloc_stackframe(); + + /* Set this to what the user wants */ + DEBUGLEVEL = context->config.debug; + + load_case_tables(); + + setup_logging("libsmbclient", True); + if (context->internal->debug_stderr) { + dbf = x_stderr; + x_setbuf(x_stderr, NULL); } - SAFE_FREE(conf); - } + + /* Here we would open the smb.conf file if needed ... */ + + in_client = True; /* FIXME, make a param */ + + home = getenv("HOME"); + if (home) { + char *conf = NULL; + if (asprintf(&conf, "%s/.smb/smb.conf", home) > 0) { + if (lp_load(conf, True, False, False, True)) { + conf_loaded = True; + } else { + DEBUG(5, ("Could not load config file: %s\n", + conf)); + } + SAFE_FREE(conf); + } + } + + if (!conf_loaded) { + /* + * Well, if that failed, try the get_dyn_CONFIGFILE + * Which points to the standard locn, and if that + * fails, silently ignore it and use the internal + * defaults ... + */ + + if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, False)) { + DEBUG(5, ("Could not load config file: %s\n", + get_dyn_CONFIGFILE())); + } else if (home) { + char *conf; + /* + * We loaded the global config file. Now lets + * load user-specific modifications to the + * global config. + */ + if (asprintf(&conf, + "%s/.smb/smb.conf.append", + home) > 0) { + if (!lp_load(conf, True, False, False, False)) { + DEBUG(10, + ("Could not append config file: " + "%s\n", + conf)); + } + SAFE_FREE(conf); + } + } + } + + load_interfaces(); /* Load the list of interfaces ... */ + + reopen_logs(); /* Get logging working ... */ + + /* + * Block SIGPIPE (from lib/util_sock.c: write()) + * It is not needed and should not stop execution + */ + BlockSignals(True, SIGPIPE); + + /* Done with one-time initialisation */ + SMBC_initialized = 1; + + TALLOC_FREE(frame); } - if (!conf_loaded) { - /* - * Well, if that failed, try the get_dyn_CONFIGFILE - * Which points to the standard locn, and if that - * fails, silently ignore it and use the internal - * defaults ... - */ - - if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, False)) { - DEBUG(5, ("Could not load config file: %s\n", - get_dyn_CONFIGFILE())); - } else if (home) { - char *conf; + if (!context->config.user) { /* - * We loaded the global config file. Now lets - * load user-specific modifications to the - * global config. + * FIXME: Is this the best way to get the user info? */ - if (asprintf(&conf, - "%s/.smb/smb.conf.append", - home) > 0) { - if (!lp_load(conf, True, False, False, False)) { - DEBUG(10, - ("Could not append config file: " - "%s\n", - conf)); - } - SAFE_FREE(conf); + user = getenv("USER"); + /* walk around as "guest" if no username can be found */ + if (!user) context->config.user = SMB_STRDUP("guest"); + else context->config.user = SMB_STRDUP(user); + } + + if (!context->config.netbios_name) { + /* + * We try to get our netbios name from the config. If that + * fails we fall back on constructing our netbios name from + * our hostname etc + */ + if (global_myname()) { + context->config.netbios_name = SMB_STRDUP(global_myname()); + } + else { + /* + * Hmmm, I want to get hostname as well, but I am too + * lazy for the moment + */ + pid = sys_getpid(); + context->config.netbios_name = (char *)SMB_MALLOC(17); + if (!context->config.netbios_name) { + errno = ENOMEM; + return NULL; + } + slprintf(context->config.netbios_name, 16, + "smbc%s%d", context->config.user, pid); + } + } + + DEBUG(1, ("Using netbios name %s.\n", context->config.netbios_name)); + + if (!context->config.workgroup) { + if (lp_workgroup()) { + context->config.workgroup = SMB_STRDUP(lp_workgroup()); + } + else { + /* TODO: Think about a decent default workgroup */ + context->config.workgroup = SMB_STRDUP("samba"); } - } } - load_interfaces(); /* Load the list of interfaces ... */ + DEBUG(1, ("Using workgroup %s.\n", context->config.workgroup)); - reopen_logs(); /* Get logging working ... */ + /* shortest timeout is 1 second */ + if (context->config.timeout > 0 && context->config.timeout < 1000) + context->config.timeout = 1000; /* - * Block SIGPIPE (from lib/util_sock.c: write()) - * It is not needed and should not stop execution + * FIXME: Should we check the function pointers here? */ - BlockSignals(True, SIGPIPE); - /* Done with one-time initialisation */ - SMBC_initialized = 1; + context->internal->initialized = True; - TALLOC_FREE(frame); - } - - if (!context->config.user) { - /* - * FIXME: Is this the best way to get the user info? - */ - user = getenv("USER"); - /* walk around as "guest" if no username can be found */ - if (!user) context->config.user = SMB_STRDUP("guest"); - else context->config.user = SMB_STRDUP(user); - } - - if (!context->config.netbios_name) { - /* - * We try to get our netbios name from the config. If that - * fails we fall back on constructing our netbios name from - * our hostname etc - */ - if (global_myname()) { - context->config.netbios_name = SMB_STRDUP(global_myname()); - } - else { - /* - * Hmmm, I want to get hostname as well, but I am too - * lazy for the moment - */ - pid = sys_getpid(); - context->config.netbios_name = (char *)SMB_MALLOC(17); - if (!context->config.netbios_name) { - errno = ENOMEM; - return NULL; - } - slprintf(context->config.netbios_name, 16, - "smbc%s%d", context->config.user, pid); - } - } - - DEBUG(1, ("Using netbios name %s.\n", context->config.netbios_name)); - - if (!context->config.workgroup) { - if (lp_workgroup()) { - context->config.workgroup = SMB_STRDUP(lp_workgroup()); - } - else { - /* TODO: Think about a decent default workgroup */ - context->config.workgroup = SMB_STRDUP("samba"); - } - } - - DEBUG(1, ("Using workgroup %s.\n", context->config.workgroup)); - - /* shortest timeout is 1 second */ - if (context->config.timeout > 0 && context->config.timeout < 1000) - context->config.timeout = 1000; - - /* - * FIXME: Should we check the function pointers here? - */ - - context->internal->initialized = True; - - return context; + return context; } @@ -740,7 +588,7 @@ smbc_init_context(SMBCCTX *context) const char * smbc_version(void) { - return samba_version_string(); + return samba_version_string(); } @@ -748,56 +596,56 @@ smbc_version(void) char * smbc_getNetbiosName(SMBCCTX *c) { - return c->config.netbios_name; + return c->config.netbios_name; } /** Set the netbios name used for making connections */ void smbc_setNetbiosName(SMBCCTX *c, char * netbios_name) { - c->config.netbios_name = netbios_name; + c->config.netbios_name = netbios_name; } /** Get the workgroup used for making connections */ char * smbc_getWorkgroup(SMBCCTX *c) { - return c->config.workgroup; + return c->config.workgroup; } /** Set the workgroup used for making connections */ void smbc_setWorkgroup(SMBCCTX *c, char * workgroup) { - c->config.workgroup = workgroup; + c->config.workgroup = workgroup; } /** Get the username used for making connections */ char * smbc_getUser(SMBCCTX *c) { - return c->config.user; + return c->config.user; } /** Set the username used for making connections */ void smbc_setUser(SMBCCTX *c, char * user) { - c->config.user = user; + c->config.user = user; } /** Get the debug level */ int smbc_getDebug(SMBCCTX *c) { - return c->config.debug; + return c->config.debug; } /** Set the debug level */ void smbc_setDebug(SMBCCTX *c, int debug) { - c->config.debug = debug; + c->config.debug = debug; } /** @@ -807,7 +655,7 @@ smbc_setDebug(SMBCCTX *c, int debug) int smbc_getTimeout(SMBCCTX *c) { - return c->config.timeout; + return c->config.timeout; } /** @@ -817,43 +665,339 @@ smbc_getTimeout(SMBCCTX *c) void smbc_setTimeout(SMBCCTX *c, int timeout) { - c->config.timeout = timeout; + c->config.timeout = timeout; } -/** Get the function for obtaining authentication data */ +/** Get whether to log to standard error instead of standard output */ +smbc_bool +smbc_getOptionDebugToStderr(SMBCCTX *c) +{ + return c->internal->debug_stderr; +} + +/** Set whether to log to standard error instead of standard output */ +void +smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b) +{ + c->internal->debug_stderr = b; +} + +/** + * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +smbc_bool +smbc_getOptionFullTimeNames(SMBCCTX *c) +{ + return c->internal->full_time_names; +} + +/** + * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +void +smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b) +{ + c->internal->full_time_names = b; +} + +/** + * Get the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +smbc_share_mode +smbc_getOptionOpenShareMode(SMBCCTX *c) +{ + return c->internal->share_mode; +} + +/** + * Set the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +void +smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode) +{ + c->internal->share_mode = share_mode; +} + +/** Retrieve a previously set user data handle */ +void * +smbc_getOptionUserData(SMBCCTX *c) +{ + return c->internal->user_data; +} + +/** Save a user data handle */ +void +smbc_setOptionUserData(SMBCCTX *c, void *user_data) +{ + c->internal->user_data = user_data; +} +/** Get the encoded value for encryption level. */ +smbc_smb_encrypt_level +smbc_getOptionSmbEncryptionLevel(SMBCCTX *c) +{ + return c->internal->smb_encryption_level; +} + +/** Set the encoded value for encryption level. */ +void +smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level) +{ + c->internal->smb_encryption_level = level; +} + +/** + * Get from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +int +smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c) +{ + return c->options.browse_max_lmb_count; +} + +/** + * Set from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +void +smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count) +{ + c->options.browse_max_lmb_count = count; +} + +/** + * Get whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +smbc_bool +smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c) +{ + return c->options.urlencode_readdir_entries; +} + +/** + * Set whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +void +smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b) +{ + c->options.urlencode_readdir_entries = b; +} + +/** + * Get whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +smbc_bool +smbc_getOptionOneSharePerServer(SMBCCTX *c) +{ + return c->options.one_share_per_server; +} + +/** + * Set whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +void +smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b) +{ + c->options.one_share_per_server = b; +} + +/** Get whether to enable use of kerberos */ +smbc_bool +smbc_getOptionUseKerberos(SMBCCTX *c) +{ + return c->flags.bits & SMB_CTX_FLAG_USE_KERBEROS ? True : False; +} + +/** Set whether to enable use of kerberos */ +void +smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags.bits |= SMB_CTX_FLAG_USE_KERBEROS; + } else { + c->flags.bits &= ~SMB_CTX_FLAG_USE_KERBEROS; + } +} + +/** Get whether to fallback after kerberos */ +smbc_bool +smbc_getOptionFallbackAfterKerberos(SMBCCTX *c) +{ + return c->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS ? True : False; +} + +/** Set whether to fallback after kerberos */ +void +smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags.bits |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + } else { + c->flags.bits &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + } +} + +/** Get whether to automatically select anonymous login */ +smbc_bool +smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c) +{ + return c->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON ? True : False; +} + +/** Set whether to automatically select anonymous login */ +void +smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags.bits |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; + } else { + c->flags.bits &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; + } +} + +/** Get the function for obtaining authentication data */ smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c) { - return c->server.get_auth_data_fn; + return c->server.get_auth_data_fn; } /** Set the function for obtaining authentication data */ void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn) { - c->server.get_auth_data_fn = fn; + c->internal->auth_fn_with_context = NULL; + c->server.get_auth_data_fn = fn; +} + +/** Get the new-style authentication function which includes the context. */ +smbc_get_auth_data_with_context_fn +smbc_getFunctionAuthDataWithContext(SMBCCTX *c) +{ + return c->internal->auth_fn_with_context; +} + +/** Set the new-style authentication function which includes the context. */ +void +smbc_setFunctionAuthDataWithContext(SMBCCTX *c, + smbc_get_auth_data_with_context_fn fn) +{ + c->server.get_auth_data_fn = NULL; + c->internal->auth_fn_with_context = fn; } /** Get the function for checking if a server is still good */ smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c) { - return c->server.check_server_fn; + return c->server.check_server_fn; } /** Set the function for checking if a server is still good */ void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn) { - c->server.check_server_fn = fn; + c->server.check_server_fn = fn; } /** Get the function for removing a server if unused */ smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c) { - return c->server.remove_unused_server_fn; + return c->server.remove_unused_server_fn; } /** Set the function for removing a server if unused */ @@ -861,21 +1005,21 @@ void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, smbc_remove_unused_server_fn fn) { - c->server.remove_unused_server_fn = fn; + c->server.remove_unused_server_fn = fn; } /** Get the function to store private data of the server cache */ struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c) { - return c->cache.server_cache_data; + return c->cache.server_cache_data; } /** Set the function to store private data of the server cache */ void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache) { - c->cache.server_cache_data = cache; + c->cache.server_cache_data = cache; } @@ -883,35 +1027,35 @@ smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache) smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c) { - return c->cache.add_cached_server_fn; + return c->cache.add_cached_server_fn; } /** Set the function for adding a cached server */ void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn) { - c->cache.add_cached_server_fn = fn; + c->cache.add_cached_server_fn = fn; } /** Get the function for server cache lookup */ smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c) { - return c->cache.get_cached_server_fn; + return c->cache.get_cached_server_fn; } /** Set the function for server cache lookup */ void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn) { - c->cache.get_cached_server_fn = fn; + c->cache.get_cached_server_fn = fn; } /** Get the function for server cache removal */ smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c) { - return c->cache.remove_cached_server_fn; + return c->cache.remove_cached_server_fn; } /** Set the function for server cache removal */ @@ -919,7 +1063,7 @@ void smbc_setFunctionRemoveCachedServer(SMBCCTX *c, smbc_remove_cached_srv_fn fn) { - c->cache.remove_cached_server_fn = fn; + c->cache.remove_cached_server_fn = fn; } /** @@ -929,7 +1073,7 @@ smbc_setFunctionRemoveCachedServer(SMBCCTX *c, smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c) { - return c->cache.purge_cached_servers_fn; + return c->cache.purge_cached_servers_fn; } /** @@ -939,7 +1083,7 @@ smbc_getFunctionPurgeCachedServers(SMBCCTX *c) void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_srv_fn fn) { - c->cache.purge_cached_servers_fn = fn; + c->cache.purge_cached_servers_fn = fn; } /** @@ -949,133 +1093,133 @@ smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_srv_fn fn) smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c) { - return c->posix_emu.open_fn; + return c->posix_emu.open_fn; } void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn) { - c->posix_emu.open_fn = fn; + c->posix_emu.open_fn = fn; } smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c) { - return c->posix_emu.creat_fn; + return c->posix_emu.creat_fn; } void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn fn) { - c->posix_emu.creat_fn = fn; + c->posix_emu.creat_fn = fn; } smbc_read_fn smbc_getFunctionRead(SMBCCTX *c) { - return c->posix_emu.read_fn; + return c->posix_emu.read_fn; } void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn) { - c->posix_emu.read_fn = fn; + c->posix_emu.read_fn = fn; } smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c) { - return c->posix_emu.write_fn; + return c->posix_emu.write_fn; } void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn) { - c->posix_emu.write_fn = fn; + c->posix_emu.write_fn = fn; } smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c) { - return c->posix_emu.unlink_fn; + return c->posix_emu.unlink_fn; } void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn) { - c->posix_emu.unlink_fn = fn; + c->posix_emu.unlink_fn = fn; } smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c) { - return c->posix_emu.rename_fn; + return c->posix_emu.rename_fn; } void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn) { - c->posix_emu.rename_fn = fn; + c->posix_emu.rename_fn = fn; } smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c) { - return c->posix_emu.lseek_fn; + return c->posix_emu.lseek_fn; } void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn) { - c->posix_emu.lseek_fn = fn; + c->posix_emu.lseek_fn = fn; } smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c) { - return c->posix_emu.stat_fn; + return c->posix_emu.stat_fn; } void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn) { - c->posix_emu.stat_fn = fn; + c->posix_emu.stat_fn = fn; } smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c) { - return c->posix_emu.fstat_fn; + return c->posix_emu.fstat_fn; } void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn) { - c->posix_emu.fstat_fn = fn; + c->posix_emu.fstat_fn = fn; } smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c) { - return c->internal->posix_emu.ftruncate_fn; + return c->internal->posix_emu.ftruncate_fn; } void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn) { - c->internal->posix_emu.ftruncate_fn = fn; + c->internal->posix_emu.ftruncate_fn = fn; } smbc_close_fn smbc_getFunctionClose(SMBCCTX *c) { - return c->posix_emu.close_fn; + return c->posix_emu.close_fn; } void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn) { - c->posix_emu.close_fn = fn; + c->posix_emu.close_fn = fn; } @@ -1086,109 +1230,109 @@ smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn) smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c) { - return c->posix_emu.opendir_fn; + return c->posix_emu.opendir_fn; } void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn) { - c->posix_emu.opendir_fn = fn; + c->posix_emu.opendir_fn = fn; } smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c) { - return c->posix_emu.closedir_fn; + return c->posix_emu.closedir_fn; } void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn) { - c->posix_emu.closedir_fn = fn; + c->posix_emu.closedir_fn = fn; } smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c) { - return c->posix_emu.readdir_fn; + return c->posix_emu.readdir_fn; } void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn) { - c->posix_emu.readdir_fn = fn; + c->posix_emu.readdir_fn = fn; } smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c) { - return c->posix_emu.getdents_fn; + return c->posix_emu.getdents_fn; } void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn) { - c->posix_emu.getdents_fn = fn; + c->posix_emu.getdents_fn = fn; } smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c) { - return c->posix_emu.mkdir_fn; + return c->posix_emu.mkdir_fn; } void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn) { - c->posix_emu.mkdir_fn = fn; + c->posix_emu.mkdir_fn = fn; } smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c) { - return c->posix_emu.rmdir_fn; + return c->posix_emu.rmdir_fn; } void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn) { - c->posix_emu.rmdir_fn = fn; + c->posix_emu.rmdir_fn = fn; } smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c) { - return c->posix_emu.telldir_fn; + return c->posix_emu.telldir_fn; } void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn) { - c->posix_emu.telldir_fn = fn; + c->posix_emu.telldir_fn = fn; } smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c) { - return c->posix_emu.lseekdir_fn; + return c->posix_emu.lseekdir_fn; } void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn) { - c->posix_emu.lseekdir_fn = fn; + c->posix_emu.lseekdir_fn = fn; } smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c) { - return c->posix_emu.fstatdir_fn; + return c->posix_emu.fstatdir_fn; } void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn) { - c->posix_emu.fstatdir_fn = fn; + c->posix_emu.fstatdir_fn = fn; } @@ -1199,73 +1343,73 @@ smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn) smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c) { - return c->posix_emu.chmod_fn; + return c->posix_emu.chmod_fn; } void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn) { - c->posix_emu.chmod_fn = fn; + c->posix_emu.chmod_fn = fn; } smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c) { - return c->posix_emu.utimes_fn; + return c->posix_emu.utimes_fn; } void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn) { - c->posix_emu.utimes_fn = fn; + c->posix_emu.utimes_fn = fn; } smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c) { - return c->posix_emu.setxattr_fn; + return c->posix_emu.setxattr_fn; } void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn) { - c->posix_emu.setxattr_fn = fn; + c->posix_emu.setxattr_fn = fn; } smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c) { - return c->posix_emu.getxattr_fn; + return c->posix_emu.getxattr_fn; } void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn) { - c->posix_emu.getxattr_fn = fn; + c->posix_emu.getxattr_fn = fn; } smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c) { - return c->posix_emu.removexattr_fn; + return c->posix_emu.removexattr_fn; } void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn) { - c->posix_emu.removexattr_fn = fn; + c->posix_emu.removexattr_fn = fn; } smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c) { - return c->posix_emu.listxattr_fn; + return c->posix_emu.listxattr_fn; } void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn) { - c->posix_emu.listxattr_fn = fn; + c->posix_emu.listxattr_fn = fn; } @@ -1276,51 +1420,51 @@ smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn) smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c) { - return c->printing.print_file_fn; + return c->printing.print_file_fn; } void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn) { - c->printing.print_file_fn = fn; + c->printing.print_file_fn = fn; } smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c) { - return c->printing.open_print_job_fn; + return c->printing.open_print_job_fn; } void smbc_setFunctionOpenPrintJob(SMBCCTX *c, smbc_open_print_job_fn fn) { - c->printing.open_print_job_fn = fn; + c->printing.open_print_job_fn = fn; } smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c) { - return c->printing.list_print_jobs_fn; + return c->printing.list_print_jobs_fn; } void smbc_setFunctionListPrintJobs(SMBCCTX *c, smbc_list_print_jobs_fn fn) { - c->printing.list_print_jobs_fn = fn; + c->printing.list_print_jobs_fn = fn; } smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c) { - return c->printing.unlink_print_job_fn; + return c->printing.unlink_print_job_fn; } void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, - smbc_unlink_print_job_fn fn) + smbc_unlink_print_job_fn fn) { - c->printing.unlink_print_job_fn = fn; + c->printing.unlink_print_job_fn = fn; } diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 25020762a2..2ece2ab8ed 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -36,19 +36,19 @@ static void remove_dir(SMBCFILE *dir) { struct smbc_dir_list *d,*f; - + d = dir->dir_list; while (d) { - + f = d; d = d->next; - + SAFE_FREE(f->dirent); SAFE_FREE(f); - + } - + dir->dir_list = dir->dir_end = dir->dir_next = NULL; - + } static int @@ -61,63 +61,63 @@ add_dirent(SMBCFILE *dir, int size; int name_length = (name == NULL ? 0 : strlen(name)); int comment_len = (comment == NULL ? 0 : strlen(comment)); - + /* * Allocate space for the dirent, which must be increased by the * size of the name and the comment and 1 each for the null terminator. */ - + size = sizeof(struct smbc_dirent) + name_length + comment_len + 2; - + dirent = (struct smbc_dirent *)SMB_MALLOC(size); - + if (!dirent) { - + dir->dir_error = ENOMEM; return -1; - + } - + ZERO_STRUCTP(dirent); - + if (dir->dir_list == NULL) { - + dir->dir_list = SMB_MALLOC_P(struct smbc_dir_list); if (!dir->dir_list) { - + SAFE_FREE(dirent); dir->dir_error = ENOMEM; return -1; - + } ZERO_STRUCTP(dir->dir_list); - + dir->dir_end = dir->dir_next = dir->dir_list; } else { - + dir->dir_end->next = SMB_MALLOC_P(struct smbc_dir_list); - + if (!dir->dir_end->next) { - + SAFE_FREE(dirent); dir->dir_error = ENOMEM; return -1; - + } ZERO_STRUCTP(dir->dir_end->next); - + dir->dir_end = dir->dir_end->next; } - + dir->dir_end->next = NULL; dir->dir_end->dirent = dirent; - + dirent->smbc_type = type; dirent->namelen = name_length; dirent->commentlen = comment_len; dirent->dirlen = size; - + /* * dirent->namelen + 1 includes the null (no null termination needed) * Ditto for dirent->commentlen. @@ -126,9 +126,9 @@ add_dirent(SMBCFILE *dir, strncpy(dirent->name, (name?name:""), dirent->namelen + 1); dirent->comment = (char *)(&dirent->name + dirent->namelen + 1); strncpy(dirent->comment, (comment?comment:""), dirent->commentlen + 1); - + return 0; - + } static void @@ -142,18 +142,18 @@ list_unique_wg_fn(const char *name, struct smbc_dirent *dirent; int dirent_type; int do_remove = 0; - + dirent_type = dir->dir_type; - + if (add_dirent(dir, name, comment, dirent_type) < 0) { - + /* An error occurred, what do we do? */ /* FIXME: Add some code here */ } - + /* Point to the one just added */ dirent = dir->dir_end->dirent; - + /* See if this was a duplicate */ for (dir_list = dir->dir_list; dir_list != dir->dir_end; @@ -163,7 +163,7 @@ list_unique_wg_fn(const char *name, /* Duplicate. End end of list need to be removed. */ do_remove = 1; } - + if (do_remove && dir_list->next == dir->dir_end) { /* Found the end of the list. Remove it. */ dir->dir_end = dir_list; @@ -183,7 +183,7 @@ list_fn(const char *name, { SMBCFILE *dir = (SMBCFILE *)state; int dirent_type; - + /* * We need to process the type a little ... * @@ -195,27 +195,27 @@ list_fn(const char *name, * administrative shares: * ADMIN$, IPC$, C$, D$, E$ ... are type |= 0x80000000 */ - + if (dir->dir_type == SMBC_FILE_SHARE) { switch (type) { case 0 | 0x80000000: case 0: dirent_type = SMBC_FILE_SHARE; break; - + case 1: dirent_type = SMBC_PRINTER_SHARE; break; - + case 2: dirent_type = SMBC_COMMS_SHARE; break; - + case 3 | 0x80000000: case 3: dirent_type = SMBC_IPC_SHARE; break; - + default: dirent_type = SMBC_FILE_SHARE; /* FIXME, error? */ break; @@ -224,12 +224,12 @@ list_fn(const char *name, else { dirent_type = dir->dir_type; } - + if (add_dirent(dir, name, comment, dirent_type) < 0) { - + /* An error occurred, what do we do? */ /* FIXME: Add some code here */ - + } } @@ -239,16 +239,16 @@ dir_list_fn(const char *mnt, const char *mask, void *state) { - + if (add_dirent((SMBCFILE *)state, finfo->name, "", (finfo->mode&aDIR?SMBC_DIR:SMBC_FILE)) < 0) { - + /* Handle an error ... */ - + /* FIXME: Add some code ... */ - + } - + } static int @@ -270,14 +270,14 @@ net_share_enum_rpc(struct cli_state *cli, fstring comment = ""; struct rpc_pipe_client *pipe_hnd; NTSTATUS nt_status; - + /* Open the server service pipe */ pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &nt_status); if (!pipe_hnd) { DEBUG(1, ("net_share_enum_rpc pipe open fail!\n")); return -1; } - + /* Issue the NetShareEnum RPC call and retrieve the response */ init_enum_hnd(&enum_hnd, 0); result = rpccli_srvsvc_net_share_enum(pipe_hnd, @@ -286,35 +286,35 @@ net_share_enum_rpc(struct cli_state *cli, &ctr, preferred_len, &enum_hnd); - + /* Was it successful? */ if (!W_ERROR_IS_OK(result) || ctr.num_entries == 0) { /* Nope. Go clean up. */ goto done; } - + /* For each returned entry... */ for (i = 0; i < ctr.num_entries; i++) { - + /* pull out the share name */ rpcstr_pull_unistr2_fstring( name, &ctr.share.info1[i].info_1_str.uni_netname); - + /* pull out the share's comment */ rpcstr_pull_unistr2_fstring( comment, &ctr.share.info1[i].info_1_str.uni_remark); - + /* Get the type value */ type = ctr.share.info1[i].info_1.type; - + /* Add this share to the list */ (*fn)(name, type, comment, state); } - + done: /* Close the server service pipe */ cli_rpc_pipe_close(pipe_hnd); - + /* Tell 'em if it worked */ return W_ERROR_IS_OK(result) ? 0 : -1; } @@ -332,10 +332,10 @@ SMBC_check_options(char *server, DEBUG(4, ("SMBC_check_options(): server='%s' share='%s' " "path='%s' options='%s'\n", server, share, path, options)); - + /* No options at all is always ok */ if (! *options) return 0; - + /* Currently, we don't support any options. */ return -1; } @@ -346,7 +346,11 @@ SMBC_opendir_ctx(SMBCCTX *context, const char *fname) { int saved_errno; - char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *options = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *options = NULL; char *workgroup = NULL; char *path = NULL; uint16 mode; @@ -355,42 +359,42 @@ SMBC_opendir_ctx(SMBCCTX *context, SMBCFILE *dir = NULL; struct sockaddr_storage rem_ss; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { DEBUG(4, ("no valid context\n")); errno = EINVAL + 8192; TALLOC_FREE(frame); return NULL; - + } - + if (!fname) { DEBUG(4, ("no valid fname\n")); errno = EINVAL + 8193; TALLOC_FREE(frame); return NULL; } - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - &options)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + &options)) { DEBUG(4, ("no valid path\n")); errno = EINVAL + 8194; TALLOC_FREE(frame); return NULL; } - + DEBUG(4, ("parsed path: fname='%s' server='%s' share='%s' " "path='%s' options='%s'\n", fname, server, share, path, options)); - + /* Ensure the options are valid */ if (SMBC_check_options(server, share, path, options)) { DEBUG(4, ("unacceptable options (%s)\n", options)); @@ -398,7 +402,7 @@ SMBC_opendir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return NULL; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -407,35 +411,35 @@ SMBC_opendir_ctx(SMBCCTX *context, return NULL; } } - + dir = SMB_MALLOC_P(SMBCFILE); - + if (!dir) { errno = ENOMEM; TALLOC_FREE(frame); return NULL; } - + ZERO_STRUCTP(dir); - + dir->cli_fd = 0; dir->fname = SMB_STRDUP(fname); dir->srv = NULL; dir->offset = 0; dir->file = False; dir->dir_list = dir->dir_next = dir->dir_end = NULL; - + if (server[0] == (char)0) { - + int i; int count; int max_lmb_count; struct ip_service *ip_list; struct ip_service server_addr; struct user_auth_info u_info; - + if (share[0] != (char)0 || path[0] != (char)0) { - + errno = EINVAL + 8196; if (dir) { SAFE_FREE(dir->fname); @@ -444,12 +448,12 @@ SMBC_opendir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return NULL; } - + /* Determine how many local master browsers to query */ - max_lmb_count = (context->internal->browse_max_lmb_count == 0 + max_lmb_count = (context->options.browse_max_lmb_count == 0 ? INT_MAX - : context->internal->browse_max_lmb_count); - + : context->options.browse_max_lmb_count); + memset(&u_info, '\0', sizeof(u_info)); u_info.username = talloc_strdup(frame,user); u_info.password = talloc_strdup(frame,password); @@ -461,7 +465,7 @@ SMBC_opendir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return NULL; } - + /* * We have server and share and path empty but options * requesting that we scan all master browsers for their list @@ -470,16 +474,16 @@ SMBC_opendir_ctx(SMBCCTX *context, * doesn't work, then try our other methods which return only * a single master browser. */ - + ip_list = NULL; if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list, - &count))) + &count))) { - + SAFE_FREE(ip_list); - + if (!find_master_ip(workgroup, &server_addr.ss)) { - + if (dir) { SAFE_FREE(dir->fname); SAFE_FREE(dir); @@ -488,7 +492,7 @@ SMBC_opendir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return NULL; } - + ip_list = (struct ip_service *)memdup( &server_addr, sizeof(server_addr)); if (ip_list == NULL) { @@ -498,17 +502,17 @@ SMBC_opendir_ctx(SMBCCTX *context, } count = 1; } - + for (i = 0; i < count && i < max_lmb_count; i++) { char addr[INET6_ADDRSTRLEN]; char *wg_ptr = NULL; struct cli_state *cli = NULL; - + print_sockaddr(addr, sizeof(addr), &ip_list[i].ss); DEBUG(99, ("Found master browser %d of %d: %s\n", i+1, MAX(count, max_lmb_count), addr)); - + cli = get_ipc_connect_master_ip(talloc_tos(), &ip_list[i], &u_info, @@ -518,39 +522,39 @@ SMBC_opendir_ctx(SMBCCTX *context, if (!cli) { continue; } - + workgroup = talloc_strdup(frame, wg_ptr); server = talloc_strdup(frame, cli->desthost); - + cli_shutdown(cli); - + if (!workgroup || !server) { errno = ENOMEM; TALLOC_FREE(frame); return NULL; } - + DEBUG(4, ("using workgroup %s %s\n", workgroup, server)); - + /* * For each returned master browser IP address, get a * connection to IPC$ on the server if we do not * already have one, and determine the * workgroups/domains that it knows about. */ - + srv = SMBC_server(frame, context, True, server, "IPC$", &workgroup, &user, &password); if (!srv) { continue; } - + dir->srv = srv; dir->dir_type = SMBC_WORKGROUP; - + /* Now, list the stuff ... */ - + if (!cli_NetServerEnum(srv->cli, workgroup, SV_TYPE_DOMAIN_ENUM, @@ -559,7 +563,7 @@ SMBC_opendir_ctx(SMBCCTX *context, continue; } } - + SAFE_FREE(ip_list); } else { /* @@ -568,7 +572,7 @@ SMBC_opendir_ctx(SMBCCTX *context, */ if (*share == '\0') { if (*path != '\0') { - + /* Should not have empty share with path */ errno = EINVAL + 8197; if (dir) { @@ -577,9 +581,9 @@ SMBC_opendir_ctx(SMBCCTX *context, } TALLOC_FREE(frame); return NULL; - + } - + /* * We don't know if is really a server name * or is a workgroup/domain name. If we already have @@ -588,15 +592,16 @@ SMBC_opendir_ctx(SMBCCTX *context, * <1B>, or <20> translates. We check * to see if is an IP address first. */ - + /* * See if we have an existing server. Do not * establish a connection if one does not already * exist. */ - srv = SMBC_server(frame, context, False, server, "IPC$", + srv = SMBC_server(frame, context, False, + server, "IPC$", &workgroup, &user, &password); - + /* * If no existing server and not an IP addr, look for * LMB or DMB @@ -605,20 +610,20 @@ SMBC_opendir_ctx(SMBCCTX *context, !is_ipaddress(server) && (resolve_name(server, &rem_ss, 0x1d) || /* LMB */ resolve_name(server, &rem_ss, 0x1b) )) { /* DMB */ - + fstring buserver; - + dir->dir_type = SMBC_SERVER; - + /* * Get the backup list ... */ if (!name_status_find(server, 0, 0, &rem_ss, buserver)) { - - DEBUG(0, ("Could not get name of " - "local/domain master browser " - "for server %s\n", server)); + + DEBUG(0,("Could not get name of " + "local/domain master browser " + "for server %s\n", server)); if (dir) { SAFE_FREE(dir->fname); SAFE_FREE(dir); @@ -626,16 +631,17 @@ SMBC_opendir_ctx(SMBCCTX *context, errno = EPERM; TALLOC_FREE(frame); return NULL; - + } - + /* * Get a connection to IPC$ on the server if * we do not already have one */ srv = SMBC_server(frame, context, True, buserver, "IPC$", - &workgroup, &user, &password); + &workgroup, + &user, &password); if (!srv) { DEBUG(0, ("got no contact to IPC$\n")); if (dir) { @@ -644,16 +650,16 @@ SMBC_opendir_ctx(SMBCCTX *context, } TALLOC_FREE(frame); return NULL; - + } - + dir->srv = srv; - + /* Now, list the servers ... */ if (!cli_NetServerEnum(srv->cli, server, 0x0000FFFE, list_fn, (void *)dir)) { - + if (dir) { SAFE_FREE(dir->fname); SAFE_FREE(dir); @@ -663,15 +669,17 @@ SMBC_opendir_ctx(SMBCCTX *context, } } else if (srv || (resolve_name(server, &rem_ss, 0x20))) { - - /* If we hadn't found the server, get one now */ + + /* + * If we hadn't found the server, get one now + */ if (!srv) { srv = SMBC_server(frame, context, True, server, "IPC$", &workgroup, &user, &password); } - + if (!srv) { if (dir) { SAFE_FREE(dir->fname); @@ -679,14 +687,14 @@ SMBC_opendir_ctx(SMBCCTX *context, } TALLOC_FREE(frame); return NULL; - + } - + dir->dir_type = SMBC_FILE_SHARE; dir->srv = srv; - + /* List the shares ... */ - + if (net_share_enum_rpc( srv->cli, list_fn, @@ -695,7 +703,7 @@ SMBC_opendir_ctx(SMBCCTX *context, srv->cli, list_fn, (void *)dir) < 0) { - + errno = cli_errno(srv->cli); if (dir) { SAFE_FREE(dir->fname); @@ -703,7 +711,7 @@ SMBC_opendir_ctx(SMBCCTX *context, } TALLOC_FREE(frame); return NULL; - + } } else { /* Neither the workgroup nor server exists */ @@ -715,7 +723,7 @@ SMBC_opendir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return NULL; } - + } else { /* @@ -724,13 +732,13 @@ SMBC_opendir_ctx(SMBCCTX *context, */ char *targetpath; struct cli_state *targetcli; - + /* We connect to the server and list the directory */ dir->dir_type = SMBC_FILE_SHARE; - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { if (dir) { SAFE_FREE(dir->fname); @@ -739,11 +747,11 @@ SMBC_opendir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return NULL; } - + dir->srv = srv; - + /* Now, list the files ... */ - + p = path + strlen(path); path = talloc_asprintf_append(path, "\\*"); if (!path) { @@ -754,7 +762,7 @@ SMBC_opendir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return NULL; } - + if (!cli_resolve_path(frame, "", srv->cli, path, &targetcli, &targetpath)) { d_printf("Could not resolve %s\n", path); @@ -765,47 +773,48 @@ SMBC_opendir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return NULL; } - + if (cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN, dir_list_fn, (void *)dir) < 0) { - + if (dir) { SAFE_FREE(dir->fname); SAFE_FREE(dir); } saved_errno = SMBC_errno(context, targetcli); - + if (saved_errno == EINVAL) { - /* - * See if they asked to opendir something - * other than a directory. If so, the - * converted error value we got would have - * been EINVAL rather than ENOTDIR. - */ - *p = '\0'; /* restore original path */ - - if (SMBC_getatr(context, srv, path, - &mode, NULL, - NULL, NULL, NULL, NULL, - NULL) && - ! IS_DOS_DIR(mode)) { - - /* It is. Correct the error value */ - saved_errno = ENOTDIR; - } + /* + * See if they asked to opendir + * something other than a directory. + * If so, the converted error value we + * got would have been EINVAL rather + * than ENOTDIR. + */ + *p = '\0'; /* restore original path */ + + if (SMBC_getatr(context, srv, path, + &mode, NULL, + NULL, NULL, NULL, NULL, + NULL) && + ! IS_DOS_DIR(mode)) { + + /* It is. Correct the error value */ + saved_errno = ENOTDIR; + } } - + /* * If there was an error and the server is no * good any more... */ if (cli_is_error(targetcli) && (context->server.check_server_fn)(context, srv)) { - + /* ... then remove it. */ if ((context->server.remove_unused_server_fn)(context, - srv)) { + srv)) { /* * We could not remove the * server completely, remove @@ -817,19 +826,19 @@ SMBC_opendir_ctx(SMBCCTX *context, (context->cache.remove_cached_server_fn)(context, srv); } } - + errno = saved_errno; TALLOC_FREE(frame); return NULL; } } - + } - + DLIST_ADD(context->internal->files, dir); TALLOC_FREE(frame); return dir; - + } /* @@ -841,32 +850,32 @@ SMBC_closedir_ctx(SMBCCTX *context, SMBCFILE *dir) { TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); return -1; } - + remove_dir(dir); /* Clean it up */ - + DLIST_REMOVE(context->internal->files, dir); - + if (dir) { - + SAFE_FREE(dir->fname); SAFE_FREE(dir); /* Free the space too */ } - + TALLOC_FREE(frame); return 0; - + } static void @@ -875,29 +884,29 @@ smbc_readdir_internal(SMBCCTX * context, struct smbc_dirent *src, int max_namebuf_len) { - if (context->internal->urlencode_readdir_entries) { - + if (context->options.urlencode_readdir_entries) { + /* url-encode the name. get back remaining buffer space */ max_namebuf_len = SMBC_urlencode(dest->name, src->name, max_namebuf_len); - + /* We now know the name length */ dest->namelen = strlen(dest->name); - + /* Save the pointer to the beginning of the comment */ dest->comment = dest->name + dest->namelen + 1; - + /* Copy the comment */ strncpy(dest->comment, src->comment, max_namebuf_len - 1); dest->comment[max_namebuf_len - 1] = '\0'; - + /* Save other fields */ dest->smbc_type = src->smbc_type; dest->commentlen = strlen(dest->comment); dest->dirlen = ((dest->comment + dest->commentlen + 1) - (char *) dest); } else { - + /* No encoding. Just copy the entry as is. */ memcpy(dest, src, src->dirlen); dest->comment = (char *)(&dest->name + src->namelen + 1); @@ -916,58 +925,58 @@ SMBC_readdir_ctx(SMBCCTX *context, int maxlen; struct smbc_dirent *dirp, *dirent; TALLOC_CTX *frame = talloc_stackframe(); - + /* Check that all is ok first ... */ - + if (!context || !context->internal->initialized) { - + errno = EINVAL; DEBUG(0, ("Invalid context in SMBC_readdir_ctx()\n")); TALLOC_FREE(frame); return NULL; - + } - + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { - + errno = EBADF; DEBUG(0, ("Invalid dir in SMBC_readdir_ctx()\n")); TALLOC_FREE(frame); return NULL; - + } - + if (dir->file != False) { /* FIXME, should be dir, perhaps */ - + errno = ENOTDIR; DEBUG(0, ("Found file vs directory in SMBC_readdir_ctx()\n")); TALLOC_FREE(frame); return NULL; - + } - + if (!dir->dir_next) { TALLOC_FREE(frame); return NULL; } - + dirent = dir->dir_next->dirent; if (!dirent) { - + errno = ENOENT; TALLOC_FREE(frame); return NULL; - + } - + dirp = (struct smbc_dirent *)context->internal->dirent; maxlen = (sizeof(context->internal->dirent) - sizeof(struct smbc_dirent)); - + smbc_readdir_internal(context, dirp, dirent, maxlen); - + dir->dir_next = dir->dir_next->next; - + TALLOC_FREE(frame); return dirp; } @@ -988,98 +997,99 @@ SMBC_getdents_ctx(SMBCCTX *context, char *ndir = (char *)dirp; struct smbc_dir_list *dirlist; TALLOC_CTX *frame = talloc_stackframe(); - + /* Check that all is ok first ... */ - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { - + errno = EBADF; TALLOC_FREE(frame); return -1; - + } - + if (dir->file != False) { /* FIXME, should be dir, perhaps */ - + errno = ENOTDIR; TALLOC_FREE(frame); return -1; - + } - + /* * Now, retrieve the number of entries that will fit in what was passed * We have to figure out if the info is in the list, or we need to * send a request to the server to get the info. */ - + while ((dirlist = dir->dir_next)) { struct smbc_dirent *dirent; - + if (!dirlist->dirent) { - + errno = ENOENT; /* Bad error */ TALLOC_FREE(frame); return -1; - + } - + /* Do urlencoding of next entry, if so selected */ dirent = (struct smbc_dirent *)context->internal->dirent; maxlen = (sizeof(context->internal->dirent) - sizeof(struct smbc_dirent)); - smbc_readdir_internal(context, dirent, dirlist->dirent, maxlen); - + smbc_readdir_internal(context, dirent, + dirlist->dirent, maxlen); + reqd = dirent->dirlen; - + if (rem < reqd) { - + if (rem < count) { /* We managed to copy something */ - + errno = 0; TALLOC_FREE(frame); return count - rem; - + } else { /* Nothing copied ... */ - + errno = EINVAL; /* Not enough space ... */ TALLOC_FREE(frame); return -1; - + } - + } - + memcpy(ndir, dirent, reqd); /* Copy the data in ... */ - + ((struct smbc_dirent *)ndir)->comment = (char *)(&((struct smbc_dirent *)ndir)->name + dirent->namelen + 1); - + ndir += reqd; - + rem -= reqd; - + dir->dir_next = dirlist = dirlist -> next; } - + TALLOC_FREE(frame); - + if (rem == count) return 0; else return count - rem; - + } /* @@ -1101,36 +1111,36 @@ SMBC_mkdir_ctx(SMBCCTX *context, char *targetpath = NULL; struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_mkdir(%s)\n", fname)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -1139,37 +1149,37 @@ SMBC_mkdir_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { - + TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ - + } - + /*d_printf(">>>mkdir: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", srv->cli, path, - &targetcli, &targetpath)) { + &targetcli, &targetpath)) { d_printf("Could not resolve %s\n", path); TALLOC_FREE(frame); return -1; } /*d_printf(">>>mkdir: resolved path as %s\n", targetpath);*/ - + if (!cli_mkdir(targetcli, targetpath)) { - + errno = SMBC_errno(context, targetcli); TALLOC_FREE(frame); return -1; - + } - + TALLOC_FREE(frame); return 0; - + } /* @@ -1208,36 +1218,36 @@ SMBC_rmdir_ctx(SMBCCTX *context, char *targetpath = NULL; struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_rmdir(%s)\n", fname)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -1246,38 +1256,38 @@ SMBC_rmdir_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { - + TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ - + } - + /*d_printf(">>>rmdir: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", srv->cli, path, - &targetcli, &targetpath)) { + &targetcli, &targetpath)) { d_printf("Could not resolve %s\n", path); TALLOC_FREE(frame); return -1; } /*d_printf(">>>rmdir: resolved path as %s\n", targetpath);*/ - - + + if (!cli_rmdir(targetcli, targetpath)) { - + errno = SMBC_errno(context, targetcli); - + if (errno == EACCES) { /* Check if the dir empty or not */ - + /* Local storage to avoid buffer overflows */ char *lpath; - + smbc_rmdir_dirempty = True; /* Make this so ... */ - + lpath = talloc_asprintf(frame, "%s\\*", targetpath); if (!lpath) { @@ -1285,34 +1295,34 @@ SMBC_rmdir_ctx(SMBCCTX *context, TALLOC_FREE(frame); return -1; } - + if (cli_list(targetcli, lpath, aDIR | aSYSTEM | aHIDDEN, rmdir_list_fn, NULL) < 0) { - + /* Fix errno to ignore latest error ... */ DEBUG(5, ("smbc_rmdir: " "cli_list returned an error: %d\n", SMBC_errno(context, targetcli))); errno = EACCES; - + } - + if (smbc_rmdir_dirempty) errno = EACCES; else errno = ENOTEMPTY; - + } - + TALLOC_FREE(frame); return -1; - + } - + TALLOC_FREE(frame); return 0; - + } /* @@ -1324,38 +1334,38 @@ SMBC_telldir_ctx(SMBCCTX *context, SMBCFILE *dir) { TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { - + errno = EBADF; TALLOC_FREE(frame); return -1; - + } - + if (dir->file != False) { /* FIXME, should be dir, perhaps */ - + errno = ENOTDIR; TALLOC_FREE(frame); return -1; - + } - + /* See if we're already at the end. */ if (dir->dir_next == NULL) { /* We are. */ TALLOC_FREE(frame); return -1; } - + /* * We return the pointer here as the offset */ @@ -1369,28 +1379,28 @@ SMBC_telldir_ctx(SMBCCTX *context, static struct smbc_dir_list * check_dir_ent(struct smbc_dir_list *list, - struct smbc_dirent *dirent) + struct smbc_dirent *dirent) { - + /* Run down the list looking for what we want */ - + if (dirent) { - + struct smbc_dir_list *tmp = list; - + while (tmp) { - + if (tmp->dirent == dirent) return tmp; - + tmp = tmp->next; - + } - + } - + return NULL; /* Not found, or an error */ - + } @@ -1407,50 +1417,50 @@ SMBC_lseekdir_ctx(SMBCCTX *context, struct smbc_dirent *dirent = (struct smbc_dirent *)l_offset; struct smbc_dir_list *list_ent = (struct smbc_dir_list *)NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + if (dir->file != False) { /* FIXME, should be dir, perhaps */ - + errno = ENOTDIR; TALLOC_FREE(frame); return -1; - + } - + /* Now, check what we were passed and see if it is OK ... */ - + if (dirent == NULL) { /* Seek to the begining of the list */ - + dir->dir_next = dir->dir_list; TALLOC_FREE(frame); return 0; - + } - + if (offset == -1) { /* Seek to the end of the list */ dir->dir_next = NULL; TALLOC_FREE(frame); return 0; } - + /* Now, run down the list and make sure that the entry is OK */ /* This may need to be changed if we change the format of the list */ - + if ((list_ent = check_dir_ent(dir->dir_list, dirent)) == NULL) { errno = EINVAL; /* Bad entry */ TALLOC_FREE(frame); return -1; } - + dir->dir_next = list_ent; - + TALLOC_FREE(frame); return 0; } @@ -1464,13 +1474,13 @@ SMBC_fstatdir_ctx(SMBCCTX *context, SMBCFILE *dir, struct stat *st) { - + if (!context || !context->internal->initialized) { - + errno = EINVAL; return -1; } - + /* No code yet ... */ return 0; } @@ -1489,37 +1499,37 @@ SMBC_chmod_ctx(SMBCCTX *context, char *path = NULL; uint16 mode; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_chmod(%s, 0%3o)\n", fname, newmode)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -1528,28 +1538,28 @@ SMBC_chmod_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ } - + mode = 0; - + if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= aRONLY; if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH; if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM; if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN; - + if (!cli_setatr(srv->cli, path, mode, 0)) { errno = SMBC_errno(context, srv->cli); TALLOC_FREE(frame); return -1; } - + TALLOC_FREE(frame); return 0; } @@ -1569,63 +1579,63 @@ SMBC_utimes_ctx(SMBCCTX *context, time_t access_time; time_t write_time; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (tbuf == NULL) { access_time = write_time = time(NULL); } else { access_time = tbuf[0].tv_sec; write_time = tbuf[1].tv_sec; } - + if (DEBUGLVL(4)) { char *p; char atimebuf[32]; char mtimebuf[32]; - + strncpy(atimebuf, ctime(&access_time), sizeof(atimebuf) - 1); atimebuf[sizeof(atimebuf) - 1] = '\0'; if ((p = strchr(atimebuf, '\n')) != NULL) { *p = '\0'; } - + strncpy(mtimebuf, ctime(&write_time), sizeof(mtimebuf) - 1); mtimebuf[sizeof(mtimebuf) - 1] = '\0'; if ((p = strchr(mtimebuf, '\n')) != NULL) { *p = '\0'; } - + dbgtext("smbc_utimes(%s, atime = %s mtime = %s)\n", fname, atimebuf, mtimebuf); } - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -1634,21 +1644,21 @@ SMBC_utimes_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ } - + if (!SMBC_setatr(context, srv, path, 0, access_time, write_time, 0, 0)) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_setatr */ } - + TALLOC_FREE(frame); return 0; } @@ -1661,43 +1671,47 @@ int SMBC_unlink_ctx(SMBCCTX *context, const char *fname) { - char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *workgroup = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; char *path = NULL; char *targetpath = NULL; struct cli_state *targetcli = NULL; SMBCSRV *srv = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return -1; - + } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -1706,31 +1720,31 @@ SMBC_unlink_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { TALLOC_FREE(frame); return -1; /* SMBC_server sets errno */ - + } - + /*d_printf(">>>unlink: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", srv->cli, path, - &targetcli, &targetpath)) { + &targetcli, &targetpath)) { d_printf("Could not resolve %s\n", path); TALLOC_FREE(frame); return -1; } /*d_printf(">>>unlink: resolved path as %s\n", targetpath);*/ - + if (!cli_unlink(targetcli, targetpath)) { - + errno = SMBC_errno(context, targetcli); - + if (errno == EACCES) { /* Check if the file is a directory */ - + int saverr = errno; SMB_OFF_T size = 0; uint16 mode = 0; @@ -1738,39 +1752,39 @@ SMBC_unlink_ctx(SMBCCTX *context, struct timespec access_time_ts; struct timespec change_time_ts; SMB_INO_T ino = 0; - + if (!SMBC_getatr(context, srv, path, &mode, &size, NULL, &access_time_ts, &write_time_ts, &change_time_ts, &ino)) { - + /* Hmmm, bad error ... What? */ - + errno = SMBC_errno(context, targetcli); TALLOC_FREE(frame); return -1; - + } else { - + if (IS_DOS_DIR(mode)) errno = EISDIR; else errno = saverr; /* Restore this */ - + } } - + TALLOC_FREE(frame); return -1; - + } - + TALLOC_FREE(frame); return 0; /* Success ... */ - + } /* @@ -1800,39 +1814,39 @@ SMBC_rename_ctx(SMBCCTX *ocontext, struct cli_state *targetcli2 = NULL; SMBCSRV *srv = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!ocontext || !ncontext || !ocontext->internal->initialized || !ncontext->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return -1; } - + if (!oname || !nname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_rename(%s,%s)\n", oname, nname)); - + if (SMBC_parse_path(frame, - ocontext, - oname, - &workgroup, - &server1, - &share1, - &path1, - &user1, - &password1, - NULL)) { + ocontext, + oname, + &workgroup, + &server1, + &share1, + &path1, + &user1, + &password1, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user1 || user1[0] == (char)0) { user1 = talloc_strdup(frame, ocontext->config.user); if (!user1) { @@ -1841,22 +1855,22 @@ SMBC_rename_ctx(SMBCCTX *ocontext, return -1; } } - + if (SMBC_parse_path(frame, - ncontext, - nname, - NULL, - &server2, - &share2, - &path2, - &user2, - &password2, - NULL)) { + ncontext, + nname, + NULL, + &server2, + &share2, + &path2, + &user2, + &password2, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user2 || user2[0] == (char)0) { user2 = talloc_strdup(frame, ncontext->config.user); if (!user2) { @@ -1865,7 +1879,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext, return -1; } } - + if (strcmp(server1, server2) || strcmp(share1, share2) || strcmp(user1, user2)) { /* Can't rename across file systems, or users?? */ @@ -1873,18 +1887,18 @@ SMBC_rename_ctx(SMBCCTX *ocontext, TALLOC_FREE(frame); return -1; } - + srv = SMBC_server(frame, ocontext, True, server1, share1, &workgroup, &user1, &password1); if (!srv) { TALLOC_FREE(frame); return -1; - + } - + /*d_printf(">>>rename: resolving %s\n", path1);*/ if (!cli_resolve_path(frame, "", srv->cli, path1, - &targetcli1, &targetpath1)) { + &targetcli1, &targetpath1)) { d_printf("Could not resolve %s\n", path1); TALLOC_FREE(frame); return -1; @@ -1892,13 +1906,13 @@ SMBC_rename_ctx(SMBCCTX *ocontext, /*d_printf(">>>rename: resolved path as %s\n", targetpath1);*/ /*d_printf(">>>rename: resolving %s\n", path2);*/ if (!cli_resolve_path(frame, "", srv->cli, path2, - &targetcli2, &targetpath2)) { + &targetcli2, &targetpath2)) { d_printf("Could not resolve %s\n", path2); TALLOC_FREE(frame); return -1; } /*d_printf(">>>rename: resolved path as %s\n", targetpath2);*/ - + if (strcmp(targetcli1->desthost, targetcli2->desthost) || strcmp(targetcli1->share, targetcli2->share)) { @@ -1907,21 +1921,21 @@ SMBC_rename_ctx(SMBCCTX *ocontext, TALLOC_FREE(frame); return -1; } - + if (!cli_rename(targetcli1, targetpath1, targetpath2)) { int eno = SMBC_errno(ocontext, targetcli1); - + if (eno != EEXIST || !cli_unlink(targetcli1, targetpath2) || !cli_rename(targetcli1, targetpath1, targetpath2)) { - + errno = eno; TALLOC_FREE(frame); return -1; - + } } - + TALLOC_FREE(frame); return 0; /* Success */ } diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 62b990ed00..73c9b96978 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -37,7 +37,11 @@ SMBC_open_ctx(SMBCCTX *context, int flags, mode_t mode) { - char *server = NULL, *share = NULL, *user = NULL, *password = NULL, *workgroup = NULL; + char *server = NULL; + char *share = NULL; + char *user = NULL; + char *password = NULL; + char *workgroup = NULL; char *path = NULL; char *targetpath = NULL; struct cli_state *targetcli = NULL; @@ -45,38 +49,38 @@ SMBC_open_ctx(SMBCCTX *context, SMBCFILE *file = NULL; int fd; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return NULL; - + } - + if (!fname) { - + errno = EINVAL; TALLOC_FREE(frame); return NULL; - + } - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return NULL; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -85,62 +89,63 @@ SMBC_open_ctx(SMBCCTX *context, return NULL; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { if (errno == EPERM) errno = EACCES; TALLOC_FREE(frame); return NULL; /* SMBC_server sets errno */ } - + /* Hmmm, the test for a directory is suspect here ... FIXME */ - + if (strlen(path) > 0 && path[strlen(path) - 1] == '\\') { fd = -1; } else { file = SMB_MALLOC_P(SMBCFILE); - + if (!file) { errno = ENOMEM; TALLOC_FREE(frame); return NULL; } - + ZERO_STRUCTP(file); - + /*d_printf(">>>open: resolving %s\n", path);*/ - if (!cli_resolve_path(frame, "", srv->cli, path, &targetcli, &targetpath)) { + if (!cli_resolve_path(frame, "", srv->cli, path, + &targetcli, &targetpath)) { d_printf("Could not resolve %s\n", path); SAFE_FREE(file); TALLOC_FREE(frame); return NULL; } /*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/ - + if ((fd = cli_open(targetcli, targetpath, flags, context->internal->share_mode)) < 0) { - + /* Handle the error ... */ - + SAFE_FREE(file); errno = SMBC_errno(context, targetcli); TALLOC_FREE(frame); return NULL; - + } - + /* Fill in file struct */ - + file->cli_fd = fd; file->fname = SMB_STRDUP(fname); file->srv = srv; file->offset = 0; file->file = True; - + DLIST_ADD(context->internal->files, file); - + /* * If the file was opened in O_APPEND mode, all write * operations should be appended to the file. To do that, @@ -171,51 +176,50 @@ SMBC_open_ctx(SMBCCTX *context, return NULL; } } - + TALLOC_FREE(frame); return file; - + } - + /* Check if opendir needed ... */ - + if (fd == -1) { int eno = 0; - + eno = SMBC_errno(context, srv->cli); file = (context->posix_emu.opendir_fn)(context, fname); if (!file) errno = eno; TALLOC_FREE(frame); return file; - + } - + errno = EINVAL; /* FIXME, correct errno ? */ TALLOC_FREE(frame); return NULL; - + } /* * Routine to create a file */ -static int creat_bits = O_WRONLY | O_CREAT | O_TRUNC; /* FIXME: Do we need this */ - SMBCFILE * SMBC_creat_ctx(SMBCCTX *context, const char *path, mode_t mode) { - + if (!context || !context->internal->initialized) { - + errno = EINVAL; return NULL; - + } - - return SMBC_open_ctx(context, path, creat_bits, mode); + + return SMBC_open_ctx(context, path, + O_WRONLY | O_CREAT | O_TRUNC, mode); } /* @@ -234,7 +238,7 @@ SMBC_read_ctx(SMBCCTX *context, char *targetpath = NULL; struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + /* * offset: * @@ -245,51 +249,51 @@ SMBC_read_ctx(SMBCCTX *context, * retrieving data at an offset greater than 4GB. */ off_t offset; - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count)); - + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; - + } - + offset = file->offset; - + /* Check that the buffer exists ... */ - + if (buf == NULL) { errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + /*d_printf(">>>read: parsing %s\n", file->fname);*/ if (SMBC_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + /*d_printf(">>>read: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", file->srv->cli, path, &targetcli, &targetpath)) { @@ -298,24 +302,24 @@ SMBC_read_ctx(SMBCCTX *context, return -1; } /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ - + ret = cli_read(targetcli, file->cli_fd, (char *)buf, offset, count); - + if (ret < 0) { - + errno = SMBC_errno(context, targetcli); TALLOC_FREE(frame); return -1; - + } - + file->offset += ret; - + DEBUG(4, (" --> %d\n", ret)); - + TALLOC_FREE(frame); return ret; /* Success, ret bytes of data ... */ - + } /* @@ -335,50 +339,50 @@ SMBC_write_ctx(SMBCCTX *context, char *targetpath = NULL; struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + /* First check all pointers before dereferencing them */ - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; } - + /* Check that the buffer exists ... */ - + if (buf == NULL) { errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + offset = file->offset; /* See "offset" comment in SMBC_read_ctx() */ - + /*d_printf(">>>write: parsing %s\n", file->fname);*/ if (SMBC_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + /*d_printf(">>>write: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", file->srv->cli, path, &targetcli, &targetpath)) { @@ -387,18 +391,19 @@ SMBC_write_ctx(SMBCCTX *context, return -1; } /*d_printf(">>>write: resolved path as %s\n", targetpath);*/ - - ret = cli_write(targetcli, file->cli_fd, 0, (char *)buf, offset, count); - + + ret = cli_write(targetcli, file->cli_fd, + 0, (char *)buf, offset, count); + if (ret <= 0) { errno = SMBC_errno(context, targetcli); TALLOC_FREE(frame); return -1; - + } - + file->offset += ret; - + TALLOC_FREE(frame); return ret; /* Success, 0 bytes of data ... */ } @@ -417,42 +422,42 @@ SMBC_close_ctx(SMBCCTX *context, char *targetpath = NULL; struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; } - + /* IS a dir ... */ if (!file->file) { TALLOC_FREE(frame); return (context->posix_emu.closedir_fn)(context, file); } - + /*d_printf(">>>close: parsing %s\n", file->fname);*/ if (SMBC_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + /*d_printf(">>>close: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", file->srv->cli, path, &targetcli, &targetpath)) { @@ -461,9 +466,9 @@ SMBC_close_ctx(SMBCCTX *context, return -1; } /*d_printf(">>>close: resolved path as %s\n", targetpath);*/ - + if (!cli_close(targetcli, file->cli_fd)) { - + DEBUG(3, ("cli_close failed on %s. purging server.\n", file->fname)); /* Deallocate slot and remove the server @@ -476,14 +481,14 @@ SMBC_close_ctx(SMBCCTX *context, (context->server.remove_unused_server_fn)(context, srv); TALLOC_FREE(frame); return -1; - + } - + DLIST_REMOVE(context->internal->files, file); SAFE_FREE(file->fname); SAFE_FREE(file); TALLOC_FREE(frame); - + return 0; } @@ -508,14 +513,14 @@ SMBC_getatr(SMBCCTX * context, struct cli_state *targetcli = NULL; time_t write_time; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; } - + /* path fixup for . and .. */ if (strequal(path, ".") || strequal(path, "..")) { fixedpath = talloc_strdup(frame, "\\"); @@ -535,14 +540,14 @@ SMBC_getatr(SMBCCTX * context, trim_string(fixedpath, NULL, "\\."); } DEBUG(4,("SMBC_getatr: sending qpathinfo\n")); - + if (!cli_resolve_path(frame, "", srv->cli, fixedpath, - &targetcli, &targetpath)) { + &targetcli, &targetpath)) { d_printf("Couldn't resolve %s\n", path); TALLOC_FREE(frame); return False; } - + if (!srv->no_pathinfo2 && cli_qpathinfo2(targetcli, targetpath, create_time_ts, @@ -553,45 +558,45 @@ SMBC_getatr(SMBCCTX * context, TALLOC_FREE(frame); return True; } - + /* if this is NT then don't bother with the getatr */ if (targetcli->capabilities & CAP_NT_SMBS) { errno = EPERM; TALLOC_FREE(frame); return False; } - + if (cli_getatr(targetcli, targetpath, mode, size, &write_time)) { - + struct timespec w_time_ts; - + w_time_ts = convert_time_t_to_timespec(write_time); - + if (write_time_ts != NULL) { *write_time_ts = w_time_ts; } - + if (create_time_ts != NULL) { *create_time_ts = w_time_ts; } - + if (access_time_ts != NULL) { *access_time_ts = w_time_ts; } - + if (change_time_ts != NULL) { *change_time_ts = w_time_ts; } - + srv->no_pathinfo2 = True; TALLOC_FREE(frame); return True; } - + errno = EPERM; TALLOC_FREE(frame); return False; - + } /* @@ -615,7 +620,7 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, int fd; int ret; TALLOC_CTX *frame = talloc_stackframe(); - + /* * First, try setpathinfo (if qpathinfo succeeded), for it is the * modern function for "new code" to be using, and it works given a @@ -629,7 +634,7 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, write_time, change_time, mode)) { - + /* * setpathinfo is not supported; go to plan B. * @@ -639,27 +644,27 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, * cli_setattrE() which should work on all OS versions, and * supports both times. */ - + /* Don't try {q,set}pathinfo() again, with this server */ srv->no_pathinfo = True; - + /* Open the file */ if ((fd = cli_open(srv->cli, path, O_RDWR, DENY_NONE)) < 0) { - + errno = SMBC_errno(context, srv->cli); TALLOC_FREE(frame); return -1; } - + /* Set the new attributes */ ret = cli_setattrE(srv->cli, fd, change_time, access_time, write_time); - + /* Close the file */ cli_close(srv->cli, fd); - + /* * Unfortunately, setattrE() doesn't have a provision for * setting the access mode (attributes). We'll have to try @@ -669,14 +674,14 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, if (ret && mode != (uint16) -1) { ret = cli_setatr(srv->cli, path, mode, 0); } - + if (! ret) { errno = SMBC_errno(context, srv->cli); TALLOC_FREE(frame); return False; } } - + TALLOC_FREE(frame); return True; } @@ -697,56 +702,56 @@ SMBC_lseek_ctx(SMBCCTX *context, char *targetpath = NULL; struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { - + errno = EBADF; TALLOC_FREE(frame); return -1; - + } - + if (!file->file) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; /* Can't lseek a dir ... */ - + } - + switch (whence) { case SEEK_SET: file->offset = offset; break; - + case SEEK_CUR: file->offset += offset; break; - + case SEEK_END: /*d_printf(">>>lseek: parsing %s\n", file->fname);*/ if (SMBC_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + /*d_printf(">>>lseek: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", file->srv->cli, path, &targetcli, &targetpath)) { @@ -755,32 +760,32 @@ SMBC_lseek_ctx(SMBCCTX *context, return -1; } /*d_printf(">>>lseek: resolved path as %s\n", targetpath);*/ - + if (!cli_qfileinfo(targetcli, file->cli_fd, NULL, &size, NULL, NULL, NULL, NULL, NULL)) { - SMB_OFF_T b_size = size; + SMB_OFF_T b_size = size; if (!cli_getattrE(targetcli, file->cli_fd, NULL, &b_size, NULL, NULL, NULL)) - { - errno = EINVAL; - TALLOC_FREE(frame); - return -1; - } else - size = b_size; + { + errno = EINVAL; + TALLOC_FREE(frame); + return -1; + } else + size = b_size; } file->offset = size + offset; break; - + default: errno = EINVAL; break; - + } - + TALLOC_FREE(frame); return file->offset; - + } @@ -802,26 +807,26 @@ SMBC_ftruncate_ctx(SMBCCTX *context, char *targetpath = NULL; struct cli_state *targetcli = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; } - + if (!file->file) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ if (SMBC_parse_path(frame, context, @@ -837,7 +842,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context, TALLOC_FREE(frame); return -1; } - + /*d_printf(">>>fstat: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", file->srv->cli, path, &targetcli, &targetpath)) { @@ -846,14 +851,14 @@ SMBC_ftruncate_ctx(SMBCCTX *context, return -1; } /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ - + if (!cli_ftruncate(targetcli, file->cli_fd, size)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + TALLOC_FREE(frame); return 0; - + } diff --git a/source3/libsmb/libsmb_misc.c b/source3/libsmb/libsmb_misc.c index f2fd919ef6..dd7add5a61 100644 --- a/source3/libsmb/libsmb_misc.c +++ b/source3/libsmb/libsmb_misc.c @@ -50,24 +50,24 @@ SMBC_errno(SMBCCTX *context, struct cli_state *c) { int ret = cli_errno(c); - + if (cli_is_dos_error(c)) { uint8 eclass; uint32 ecode; - + cli_dos_error(c, &eclass, &ecode); DEBUG(3,("smbc_error %d %d (0x%x) -> %d\n", (int)eclass, (int)ecode, (int)ecode, ret)); } else { NTSTATUS status; - + status = cli_nt_error(c); - + DEBUG(3,("smbc errno %s -> %d\n", nt_errstr(status), ret)); } - + return ret; } diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c index 6706a59ba8..c962f898e0 100644 --- a/source3/libsmb/libsmb_path.c +++ b/source3/libsmb/libsmb_path.c @@ -31,13 +31,13 @@ static int hex2int( unsigned int _char ) { - if ( _char >= 'A' && _char <='F') - return _char - 'A' + 10; - if ( _char >= 'a' && _char <='f') - return _char - 'a' + 10; - if ( _char >= '0' && _char <='9') - return _char - '0'; - return -1; + if ( _char >= 'A' && _char <='F') + return _char - 'A' + 10; + if ( _char >= 'a' && _char <='f') + return _char - 'a' + 10; + if ( _char >= '0' && _char <='9') + return _char - '0'; + return -1; } /* @@ -60,19 +60,19 @@ urldecode_talloc(TALLOC_CTX *ctx, char **pp_dest, const char *src) int err_count = 0; size_t newlen = 1; char *p, *dest; - + if (old_length == 0) { return 0; } - + *pp_dest = NULL; for (i = 0; i < old_length; ) { unsigned char character = src[i++]; - + if (character == '%') { int a = i+1 < old_length ? hex2int(src[i]) : -1; int b = i+1 < old_length ? hex2int(src[i+1]) : -1; - + /* Replace valid sequence */ if (a != -1 && b != -1) { /* Replace valid %xx sequence with %dd */ @@ -87,20 +87,20 @@ urldecode_talloc(TALLOC_CTX *ctx, char **pp_dest, const char *src) } newlen++; } - + dest = TALLOC_ARRAY(ctx, char, newlen); if (!dest) { return err_count; } - + err_count = 0; for (p = dest, i = 0; i < old_length; ) { unsigned char character = src[i++]; - + if (character == '%') { int a = i+1 < old_length ? hex2int(src[i]) : -1; int b = i+1 < old_length ? hex2int(src[i+1]) : -1; - + /* Replace valid sequence */ if (a != -1 && b != -1) { /* Replace valid %xx sequence with %dd */ @@ -115,7 +115,7 @@ urldecode_talloc(TALLOC_CTX *ctx, char **pp_dest, const char *src) } *p++ = character; } - + *p = '\0'; *pp_dest = dest; return err_count; @@ -129,7 +129,7 @@ SMBC_urldecode(char *dest, TALLOC_CTX *frame = talloc_stackframe(); char *pdest; int ret = urldecode_talloc(frame, &pdest, src); - + if (pdest) { strlcpy(dest, pdest, max_dest_len); } @@ -151,9 +151,9 @@ SMBC_urlencode(char *dest, int max_dest_len) { char hex[] = "0123456789ABCDEF"; - + for (; *src != '\0' && max_dest_len >= 3; src++) { - + if ((*src < '0' && *src != '-' && *src != '.') || @@ -172,10 +172,10 @@ SMBC_urlencode(char *dest, max_dest_len--; } } - + *dest++ = '\0'; max_dest_len--; - + return max_dest_len; } @@ -196,9 +196,9 @@ SMBC_urlencode(char *dest, * * The method of locating the list of workgroups varies * depending upon the setting of the context variable - * context->browse_max_lmb_count. This value determines - * the maximum number of local master browsers to query - * for the list of workgroups. In order to ensure that + * context->options.browse_max_lmb_count. This value + * determines the maximum number of local master browsers to + * query for the list of workgroups. In order to ensure that * a complete list of workgroups is obtained, all master * browsers must be queried, but if there are many * workgroups, the time spent querying can begin to add up. @@ -234,75 +234,75 @@ SMBC_parse_path(TALLOC_CTX *ctx, const char *p; char *q, *r; int len; - + /* Ensure these returns are at least valid pointers. */ *pp_server = talloc_strdup(ctx, ""); *pp_share = talloc_strdup(ctx, ""); *pp_path = talloc_strdup(ctx, ""); *pp_user = talloc_strdup(ctx, ""); *pp_password = talloc_strdup(ctx, ""); - + if (!*pp_server || !*pp_share || !*pp_path || - !*pp_user || !*pp_password) { + !*pp_user || !*pp_password) { return -1; } - + /* * Assume we wont find an authentication domain to parse, so default * to the workgroup in the provided context. */ if (pp_workgroup != NULL) { *pp_workgroup = - talloc_strdup(ctx, context->config.workgroup); + talloc_strdup(ctx, context->config.workgroup); } - + if (pp_options) { *pp_options = talloc_strdup(ctx, ""); } s = talloc_strdup(ctx, fname); - + /* see if it has the right prefix */ len = strlen(smbc_prefix); if (strncmp(s,smbc_prefix,len) || (s[len] != '/' && s[len] != 0)) { return -1; /* What about no smb: ? */ } - + p = s + len; - + /* Watch the test below, we are testing to see if we should exit */ - + if (strncmp(p, "//", 2) && strncmp(p, "\\\\", 2)) { DEBUG(1, ("Invalid path (does not begin with smb://")); return -1; } - + p += 2; /* Skip the double slash */ - + /* See if any options were specified */ if ((q = strrchr(p, '?')) != NULL ) { /* There are options. Null terminate here and point to them */ *q++ = '\0'; - + DEBUG(4, ("Found options '%s'", q)); - + /* Copy the options */ if (*pp_options != NULL) { TALLOC_FREE(*pp_options); *pp_options = talloc_strdup(ctx, q); } } - + if (*p == '\0') { goto decoding; } - + if (*p == '/') { int wl = strlen(context->config.workgroup); - + if (wl > 16) { wl = 16; } - + *pp_server = talloc_strdup(ctx, context->config.workgroup); if (!*pp_server) { return -1; @@ -310,27 +310,27 @@ SMBC_parse_path(TALLOC_CTX *ctx, *pp_server[wl] = '\0'; return 0; } - + /* * ok, its for us. Now parse out the server, share etc. * * However, we want to parse out [[domain;]user[:password]@] if it * exists ... */ - + /* check that '@' occurs before '/', if '/' exists at all */ q = strchr_m(p, '@'); r = strchr_m(p, '/'); if (q && (!r || q < r)) { char *userinfo = NULL; const char *u; - + next_token_no_ltrim_talloc(ctx, &p, &userinfo, "@"); if (!userinfo) { return -1; } u = userinfo; - + if (strchr_m(u, ';')) { char *workgroup; next_token_no_ltrim_talloc(ctx, &u, &workgroup, ";"); @@ -341,7 +341,7 @@ SMBC_parse_path(TALLOC_CTX *ctx, *pp_workgroup = workgroup; } } - + if (strchr_m(u, ':')) { next_token_no_ltrim_talloc(ctx, &u, pp_user, ":"); if (!*pp_user) { @@ -358,27 +358,27 @@ SMBC_parse_path(TALLOC_CTX *ctx, } } } - + if (!next_token_talloc(ctx, &p, pp_server, "/")) { return -1; } - + if (*p == (char)0) { goto decoding; /* That's it ... */ } - + if (!next_token_talloc(ctx, &p, pp_share, "/")) { return -1; } - + /* * Prepend a leading slash if there's a file path, as required by * NetApp filers. */ if (*p != '\0') { *pp_path = talloc_asprintf(ctx, - "\\%s", - p); + "\\%s", + p); } else { *pp_path = talloc_strdup(ctx, ""); } @@ -386,15 +386,15 @@ SMBC_parse_path(TALLOC_CTX *ctx, return -1; } string_replace(*pp_path, '/', '\\'); - - decoding: - + +decoding: + (void) urldecode_talloc(ctx, pp_path, *pp_path); (void) urldecode_talloc(ctx, pp_server, *pp_server); (void) urldecode_talloc(ctx, pp_share, *pp_share); (void) urldecode_talloc(ctx, pp_user, *pp_user); (void) urldecode_talloc(ctx, pp_password, *pp_password); - + return 0; } diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c index a03c15e024..545225cae4 100644 --- a/source3/libsmb/libsmb_printjob.c +++ b/source3/libsmb/libsmb_printjob.c @@ -41,39 +41,39 @@ SMBC_open_print_job_ctx(SMBCCTX *context, char *password = NULL; char *path = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return NULL; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return NULL; } - + DEBUG(4, ("SMBC_open_print_job_ctx(%s)\n", fname)); - + if (SMBC_parse_path(frame, - context, - fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return NULL; } - + /* What if the path is empty, or the file exists? */ - + TALLOC_FREE(frame); return (context->posix_emu.open_fn)(context, fname, O_WRONLY, 666); } @@ -98,77 +98,79 @@ SMBC_print_file_ctx(SMBCCTX *c_file, int tot_bytes = 0; char buf[4096]; TALLOC_CTX *frame = talloc_stackframe(); - + if (!c_file || !c_file->internal->initialized || !c_print || !c_print->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + if (!fname && !printq) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + /* Try to open the file for reading ... */ - - if ((long)(fid1 = smbc_getFunctionOpen(c_file)(c_file, fname, O_RDONLY, 0666)) < 0) { + + if ((long)(fid1 = smbc_getFunctionOpen(c_file)(c_file, fname, + O_RDONLY, 0666)) < 0) { DEBUG(3, ("Error, fname=%s, errno=%i\n", fname, errno)); TALLOC_FREE(frame); return -1; /* smbc_open sets errno */ } - + /* Now, try to open the printer file for writing */ - - if ((long)(fid2 = smbc_getFunctionOpenPrintJob(c_print)(c_print, printq)) < 0) { - + + if ((long)(fid2 = smbc_getFunctionOpenPrintJob(c_print)(c_print, + printq)) < 0) { + saverr = errno; /* Save errno */ smbc_getFunctionClose(c_file)(c_file, fid1); errno = saverr; TALLOC_FREE(frame); return -1; - + } - + while ((bytes = smbc_getFunctionRead(c_file)(c_file, fid1, buf, sizeof(buf))) > 0) { - + tot_bytes += bytes; - + if ((smbc_getFunctionWrite(c_print)(c_print, fid2, buf, bytes)) < 0) { - + saverr = errno; smbc_getFunctionClose(c_file)(c_file, fid1); smbc_getFunctionClose(c_print)(c_print, fid2); errno = saverr; - + } - + } - + saverr = errno; - - smbc_getFunctionClose(c_file)(c_file, fid1); /* We have to close these anyway */ + + smbc_getFunctionClose(c_file)(c_file, fid1); smbc_getFunctionClose(c_print)(c_print, fid2); - + if (bytes < 0) { - + errno = saverr; TALLOC_FREE(frame); return -1; - + } - + TALLOC_FREE(frame); return tot_bytes; - + } /* @@ -188,37 +190,37 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context, char *workgroup = NULL; char *path = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_list_print_jobs(%s)\n", fname)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -227,25 +229,25 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ } - + if (cli_print_queue(srv->cli, (void (*)(struct print_job_info *))fn) < 0) { errno = SMBC_errno(context, srv->cli); TALLOC_FREE(frame); return -1; } - + TALLOC_FREE(frame); return 0; - + } /* @@ -266,37 +268,37 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context, char *path = NULL; int err; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_unlink_print_job(%s)\n", fname)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -305,30 +307,30 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { - + TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ - + } - + if ((err = cli_printjob_del(srv->cli, id)) != 0) { - + if (err < 0) errno = SMBC_errno(context, srv->cli); else if (err == ERRnosuchprintjob) errno = EINVAL; TALLOC_FREE(frame); return -1; - + } - + TALLOC_FREE(frame); return 0; - + } diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 70e0d57273..4f51388870 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -40,7 +40,7 @@ SMBC_check_server(SMBCCTX * context, { socklen_t size; struct sockaddr addr; - + size = sizeof(addr); return (getpeername(server->cli->fd, &addr, &size) == -1); } @@ -56,12 +56,12 @@ SMBC_remove_unused_server(SMBCCTX * context, SMBCSRV * srv) { SMBCFILE * file; - + /* are we being fooled ? */ if (!context || !context->internal->initialized || !srv) { return 1; } - + /* Check all open files/directories for a relation with this server */ for (file = context->internal->files; file; file = file->next) { if (file->srv == srv) { @@ -72,16 +72,16 @@ SMBC_remove_unused_server(SMBCCTX * context, return 1; } } - + DLIST_REMOVE(context->internal->servers, srv); - + cli_shutdown(srv->cli); srv->cli = NULL; - + DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv)); - + (context->cache.remove_cached_server_fn)(context, srv); - + SAFE_FREE(srv); return 0; } @@ -101,21 +101,21 @@ SMBC_call_auth_fn(TALLOC_CTX *ctx, fstring workgroup; fstring username; fstring password; - + strlcpy(workgroup, *pp_workgroup, sizeof(workgroup)); strlcpy(username, *pp_username, sizeof(username)); strlcpy(password, *pp_password, sizeof(password)); - + (context->server.get_auth_data_fn)( server, share, workgroup, sizeof(workgroup), username, sizeof(username), password, sizeof(password)); - + TALLOC_FREE(*pp_workgroup); TALLOC_FREE(*pp_username); TALLOC_FREE(*pp_password); - + *pp_workgroup = talloc_strdup(ctx, workgroup); *pp_username = talloc_strdup(ctx, username); *pp_password = talloc_strdup(ctx, password); @@ -144,23 +144,23 @@ SMBC_find_server(TALLOC_CTX *ctx, { SMBCSRV *srv; int auth_called = 0; - - check_server_cache: - + +check_server_cache: + srv = (context->cache.get_cached_server_fn)(context, server, share, *pp_workgroup, *pp_username); - + if (!auth_called && !srv && (!*pp_username || !(*pp_username)[0] || - !*pp_password || !(*pp_password)[0])) { + !*pp_password || !(*pp_password)[0])) { SMBC_call_auth_fn(ctx, context, server, share, - pp_workgroup, pp_username, pp_password); - + pp_workgroup, pp_username, pp_password); + if (!pp_workgroup || !pp_username || !pp_password) { return NULL; } - + /* * However, smbc_auth_fn may have picked up info relating to * an existing connection, so try for an existing connection @@ -168,9 +168,9 @@ SMBC_find_server(TALLOC_CTX *ctx, */ auth_called = 1; goto check_server_cache; - + } - + if (srv) { if ((context->server.check_server_fn)(context, srv)) { /* @@ -189,17 +189,17 @@ SMBC_find_server(TALLOC_CTX *ctx, (context->cache.remove_cached_server_fn)(context, srv); } - + /* * Maybe there are more cached connections to this * server */ goto check_server_cache; } - + return srv; } - + return NULL; } @@ -234,25 +234,25 @@ SMBC_server(TALLOC_CTX *ctx, int port_try_next; const char *username_used; NTSTATUS status; - + zero_addr(&ss); ZERO_STRUCT(c); - + if (server[0] == 0) { errno = EPERM; return NULL; } - + /* Look for a cached connection */ srv = SMBC_find_server(ctx, context, server, share, - pp_workgroup, pp_username, pp_password); - + pp_workgroup, pp_username, pp_password); + /* * If we found a connection and we're only allowed one share per * server... */ - if (srv && *share != '\0' && context->internal->one_share_per_server) { - + if (srv && *share != '\0' && context->options.one_share_per_server) { + /* * ... then if there's no current connection to the share, * connect to it. SMBC_find_server(), or rather the function @@ -264,8 +264,10 @@ SMBC_server(TALLOC_CTX *ctx, if (srv->cli->cnum == (uint16) -1) { /* Ensure we have accurate auth info */ SMBC_call_auth_fn(ctx, context, server, share, - pp_workgroup, pp_username, pp_password); - + pp_workgroup, + pp_username, + pp_password); + if (!*pp_workgroup || !*pp_username || !*pp_password) { errno = ENOMEM; cli_shutdown(srv->cli); @@ -274,17 +276,17 @@ SMBC_server(TALLOC_CTX *ctx, srv); return NULL; } - + /* * We don't need to renegotiate encryption * here as the encryption context is not per * tid. */ - + if (!cli_send_tconX(srv->cli, share, "?????", - *pp_password, - strlen(*pp_password)+1)) { - + *pp_password, + strlen(*pp_password)+1)) { + errno = SMBC_errno(context, srv->cli); cli_shutdown(srv->cli); srv->cli = NULL; @@ -292,7 +294,7 @@ SMBC_server(TALLOC_CTX *ctx, srv); srv = NULL; } - + /* * Regenerate the dev value since it's based on both * server and share @@ -303,51 +305,51 @@ SMBC_server(TALLOC_CTX *ctx, } } } - + /* If we have a connection... */ if (srv) { - + /* ... then we're done here. Give 'em what they came for. */ return srv; } - + /* If we're not asked to connect when a connection doesn't exist... */ if (! connect_if_not_found) { /* ... then we're done here. */ return NULL; } - + if (!*pp_workgroup || !*pp_username || !*pp_password) { errno = ENOMEM; return NULL; } - + make_nmb_name(&calling, context->config.netbios_name, 0x0); make_nmb_name(&called , server, 0x20); - + DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server)); - + DEBUG(4,(" -> server_n=[%s] server=[%s]\n", server_n, server)); - - again: - + +again: + zero_addr(&ss); - + /* have to open a new connection */ if ((c = cli_initialise()) == NULL) { errno = ENOMEM; return NULL; } - + if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) { c->use_kerberos = True; } if (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) { c->fallback_after_kerberos = True; } - + c->timeout = context->config.timeout; - + /* * Force use of port 139 for first try if share is $IPC, empty, or * null, so browse lists can work @@ -359,15 +361,15 @@ SMBC_server(TALLOC_CTX *ctx, port_try_first = 445; port_try_next = 139; } - + c->port = port_try_first; - + status = cli_connect(c, server_n, &ss); if (!NT_STATUS_IS_OK(status)) { - + /* First connection attempt failed. Try alternate port. */ c->port = port_try_next; - + status = cli_connect(c, server_n, &ss); if (!NT_STATUS_IS_OK(status)) { cli_shutdown(c); @@ -375,33 +377,36 @@ SMBC_server(TALLOC_CTX *ctx, return NULL; } } - + if (!cli_session_request(c, &calling, &called)) { cli_shutdown(c); if (strcmp(called.name, "*SMBSERVER")) { make_nmb_name(&called , "*SMBSERVER", 0x20); goto again; } else { /* Try one more time, but ensure we don't loop */ - + /* Only try this if server is an IP address ... */ - + if (is_ipaddress(server) && !tried_reverse) { fstring remote_name; struct sockaddr_storage rem_ss; - + if (!interpret_string_addr(&rem_ss, server, - NI_NUMERICHOST)) { + NI_NUMERICHOST)) { DEBUG(4, ("Could not convert IP address " - "%s to struct sockaddr_storage\n", - server)); + "%s to struct sockaddr_storage\n", + server)); errno = ETIMEDOUT; return NULL; } - + tried_reverse++; /* Yuck */ - - if (name_status_find("*", 0, 0, &rem_ss, remote_name)) { - make_nmb_name(&called, remote_name, 0x20); + + if (name_status_find("*", 0, 0, + &rem_ss, remote_name)) { + make_nmb_name(&called, + remote_name, + 0x20); goto again; } } @@ -409,64 +414,66 @@ SMBC_server(TALLOC_CTX *ctx, errno = ETIMEDOUT; return NULL; } - + DEBUG(4,(" session request ok\n")); - + if (!cli_negprot(c)) { cli_shutdown(c); errno = ETIMEDOUT; return NULL; } - + username_used = *pp_username; - + if (!NT_STATUS_IS_OK(cli_session_setup(c, username_used, - *pp_password, strlen(*pp_password), - *pp_password, strlen(*pp_password), + *pp_password, + strlen(*pp_password), + *pp_password, + strlen(*pp_password), *pp_workgroup))) { - + /* Failed. Try an anonymous login, if allowed by flags. */ username_used = ""; - + if ((context->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) || !NT_STATUS_IS_OK(cli_session_setup(c, username_used, *pp_password, 1, *pp_password, 0, *pp_workgroup))) { - + cli_shutdown(c); errno = EPERM; return NULL; } } - + DEBUG(4,(" session setup ok\n")); - + if (!cli_send_tconX(c, share, "?????", *pp_password, strlen(*pp_password)+1)) { errno = SMBC_errno(context, c); cli_shutdown(c); return NULL; } - + DEBUG(4,(" tconx ok\n")); - + if (context->internal->smb_encryption_level) { /* Attempt UNIX smb encryption. */ if (!NT_STATUS_IS_OK(cli_force_encryption(c, - username_used, - *pp_password, - *pp_workgroup))) { - + username_used, + *pp_password, + *pp_workgroup))) { + /* * context->smb_encryption_level == 1 * means don't fail if encryption can't be negotiated, * == 2 means fail if encryption can't be negotiated. */ - + DEBUG(4,(" SMB encrypt failed\n")); - + if (context->internal->smb_encryption_level == 2) { cli_shutdown(c); errno = EPERM; @@ -475,25 +482,25 @@ SMBC_server(TALLOC_CTX *ctx, } DEBUG(4,(" SMB encrypt ok\n")); } - + /* * Ok, we have got a nice connection * Let's allocate a server structure. */ - + srv = SMB_MALLOC_P(SMBCSRV); if (!srv) { errno = ENOMEM; goto failed; } - + ZERO_STRUCTP(srv); srv->cli = c; srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share)); srv->no_pathinfo = False; srv->no_pathinfo2 = False; srv->no_nt_session = False; - + /* now add it to the cache (internal or external) */ /* Let the cache function set errno if it wants to */ errno = 0; @@ -509,19 +516,19 @@ SMBC_server(TALLOC_CTX *ctx, } goto failed; } - + DEBUG(2, ("Server connect ok: //%s/%s: %p\n", server, share, srv)); - + DLIST_ADD(context->internal->servers, srv); return srv; - - failed: + +failed: cli_shutdown(c); if (!srv) { return NULL; } - + SAFE_FREE(srv); return NULL; } @@ -545,32 +552,34 @@ SMBC_attr_server(TALLOC_CTX *ctx, struct rpc_pipe_client *pipe_hnd; NTSTATUS nt_status; SMBCSRV *ipc_srv=NULL; - + /* * See if we've already created this special connection. Reference * our "special" share name '*IPC$', which is an impossible real share * name due to the leading asterisk. */ ipc_srv = SMBC_find_server(ctx, context, server, "*IPC$", - pp_workgroup, pp_username, pp_password); + pp_workgroup, pp_username, pp_password); if (!ipc_srv) { - + /* We didn't find a cached connection. Get the password */ if (!*pp_password || (*pp_password)[0] == '\0') { /* ... then retrieve it now. */ SMBC_call_auth_fn(ctx, context, server, share, - pp_workgroup, pp_username, pp_password); + pp_workgroup, + pp_username, + pp_password); if (!*pp_workgroup || !*pp_username || !*pp_password) { errno = ENOMEM; return NULL; } } - + flags = 0; if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) { flags |= CLI_FULL_CONNECTION_USE_KERBEROS; } - + zero_addr(&ss); nt_status = cli_full_connection(&ipc_cli, global_myname(), server, @@ -586,23 +595,23 @@ SMBC_attr_server(TALLOC_CTX *ctx, errno = ENOTSUP; return NULL; } - + if (context->internal->smb_encryption_level) { /* Attempt UNIX smb encryption. */ if (!NT_STATUS_IS_OK(cli_force_encryption(ipc_cli, - *pp_username, - *pp_password, - *pp_workgroup))) { - + *pp_username, + *pp_password, + *pp_workgroup))) { + /* * context->smb_encryption_level == * 1 means don't fail if encryption can't be * negotiated, == 2 means fail if encryption * can't be negotiated. */ - + DEBUG(4,(" SMB encrypt failed on IPC$\n")); - + if (context->internal->smb_encryption_level == 2) { cli_shutdown(ipc_cli); errno = EPERM; @@ -611,49 +620,49 @@ SMBC_attr_server(TALLOC_CTX *ctx, } DEBUG(4,(" SMB encrypt ok on IPC$\n")); } - + ipc_srv = SMB_MALLOC_P(SMBCSRV); if (!ipc_srv) { errno = ENOMEM; cli_shutdown(ipc_cli); return NULL; } - + ZERO_STRUCTP(ipc_srv); ipc_srv->cli = ipc_cli; - + pipe_hnd = cli_rpc_pipe_open_noauth(ipc_srv->cli, PI_LSARPC, &nt_status); if (!pipe_hnd) { - DEBUG(1, ("cli_nt_session_open fail!\n")); - errno = ENOTSUP; - cli_shutdown(ipc_srv->cli); - free(ipc_srv); - return NULL; + DEBUG(1, ("cli_nt_session_open fail!\n")); + errno = ENOTSUP; + cli_shutdown(ipc_srv->cli); + free(ipc_srv); + return NULL; } - + /* * Some systems don't support * SEC_RIGHTS_MAXIMUM_ALLOWED, but NT sends 0x2000000 * so we might as well do it too. */ - + nt_status = rpccli_lsa_open_policy( - pipe_hnd, - talloc_tos(), - True, - GENERIC_EXECUTE_ACCESS, - &ipc_srv->pol); - + pipe_hnd, + talloc_tos(), + True, + GENERIC_EXECUTE_ACCESS, + &ipc_srv->pol); + if (!NT_STATUS_IS_OK(nt_status)) { - errno = SMBC_errno(context, ipc_srv->cli); - cli_shutdown(ipc_srv->cli); - return NULL; + errno = SMBC_errno(context, ipc_srv->cli); + cli_shutdown(ipc_srv->cli); + return NULL; } - + /* now add it to the cache (internal or external) */ - + errno = 0; /* let cache function set errno if it likes */ if ((context->cache.add_cached_server_fn)(context, ipc_srv, server, @@ -668,9 +677,9 @@ SMBC_attr_server(TALLOC_CTX *ctx, free(ipc_srv); return NULL; } - + DLIST_ADD(context->internal->servers, ipc_srv); } - + return ipc_srv; } diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index 6072547e08..b733eab74f 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -33,18 +33,18 @@ static ino_t generate_inode(SMBCCTX *context, - const char *name) + const char *name) { if (!context || !context->internal->initialized) { - + errno = EINVAL; return -1; - + } - + if (!*name) return 2; /* FIXME, why 2 ??? */ return (ino_t)str_checksum(name); - + } /* @@ -54,26 +54,26 @@ generate_inode(SMBCCTX *context, static int setup_stat(SMBCCTX *context, - struct stat *st, - char *fname, - SMB_OFF_T size, - int mode) + struct stat *st, + char *fname, + SMB_OFF_T size, + int mode) { TALLOC_CTX *frame = talloc_stackframe(); - + st->st_mode = 0; - + if (IS_DOS_DIR(mode)) { st->st_mode = SMBC_DIR_MODE; } else { st->st_mode = SMBC_FILE_MODE; } - + if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR; if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP; if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH; if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR; - + st->st_size = size; #ifdef HAVE_STAT_ST_BLKSIZE st->st_blksize = 512; @@ -86,20 +86,20 @@ setup_stat(SMBCCTX *context, #endif st->st_uid = getuid(); st->st_gid = getgid(); - + if (IS_DOS_DIR(mode)) { st->st_nlink = 2; } else { st->st_nlink = 1; } - + if (st->st_ino == 0) { st->st_ino = generate_inode(context, fname); } - + TALLOC_FREE(frame); return True; /* FIXME: Is this needed ? */ - + } /* @@ -125,37 +125,37 @@ SMBC_stat_ctx(SMBCCTX *context, uint16 mode = 0; SMB_INO_T ino = 0; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_stat(%s)\n", fname)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame,context->config.user); if (!user) { @@ -164,15 +164,15 @@ SMBC_stat_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); - + if (!srv) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ } - + if (!SMBC_getatr(context, srv, path, &mode, &size, NULL, &access_time_ts, @@ -183,19 +183,19 @@ SMBC_stat_ctx(SMBCCTX *context, TALLOC_FREE(frame); return -1; } - + st->st_ino = ino; - + setup_stat(context, st, (char *) fname, size, mode); - + set_atimespec(st, access_time_ts); set_ctimespec(st, change_time_ts); set_mtimespec(st, write_time_ts); st->st_dev = srv->dev; - + TALLOC_FREE(frame); return 0; - + } /* @@ -221,41 +221,41 @@ SMBC_fstat_ctx(SMBCCTX *context, struct cli_state *targetcli = NULL; SMB_INO_T ino = 0; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!file || !SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; } - + if (!file->file) { TALLOC_FREE(frame); return (context->posix_emu.fstatdir_fn)(context, file, st); } - + /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ if (SMBC_parse_path(frame, - context, - file->fname, - NULL, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + file->fname, + NULL, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + /*d_printf(">>>fstat: resolving %s\n", path);*/ if (!cli_resolve_path(frame, "", file->srv->cli, path, &targetcli, &targetpath)) { @@ -264,39 +264,39 @@ SMBC_fstat_ctx(SMBCCTX *context, return -1; } /*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/ - + if (!cli_qfileinfo(targetcli, file->cli_fd, &mode, &size, NULL, &access_time_ts, &write_time_ts, &change_time_ts, &ino)) { - + time_t change_time, access_time, write_time; - + if (!cli_getattrE(targetcli, file->cli_fd, &mode, &size, - &change_time, &access_time, &write_time)) { - + &change_time, &access_time, &write_time)) { + errno = EINVAL; TALLOC_FREE(frame); return -1; } - + change_time_ts = convert_time_t_to_timespec(change_time); access_time_ts = convert_time_t_to_timespec(access_time); write_time_ts = convert_time_t_to_timespec(write_time); } - + st->st_ino = ino; - + setup_stat(context, st, file->fname, size, mode); - + set_atimespec(st, access_time_ts); set_ctimespec(st, change_time_ts); set_mtimespec(st, write_time_ts); st->st_dev = file->srv->dev; - + TALLOC_FREE(frame); return 0; - + } diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index a420299341..3c08412d59 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -34,16 +34,16 @@ static struct rpc_pipe_client * find_lsa_pipe_hnd(struct cli_state *ipc_cli) { struct rpc_pipe_client *pipe_hnd; - + for (pipe_hnd = ipc_cli->pipe_list; pipe_hnd; pipe_hnd = pipe_hnd->next) { - + if (pipe_hnd->pipe_idx == PI_LSARPC) { return pipe_hnd; } } - + return NULL; } @@ -59,19 +59,19 @@ ace_compare(SEC_ACE *ace1, { bool b1; bool b2; - + /* If the ACEs are equal, we have nothing more to do. */ if (sec_ace_equal(ace1, ace2)) { return 0; } - + /* Inherited follow non-inherited */ b1 = ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) != 0); b2 = ((ace2->flags & SEC_ACE_FLAG_INHERITED_ACE) != 0); if (b1 != b2) { return (b1 ? 1 : -1); } - + /* * What shall we do with AUDITs and ALARMs? It's undefined. We'll * sort them after DENY and ALLOW. @@ -87,7 +87,7 @@ ace_compare(SEC_ACE *ace1, if (b1 != b2) { return (b1 ? 1 : -1); } - + /* Allowed ACEs follow denied ACEs */ b1 = (ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED || ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT); @@ -96,7 +96,7 @@ ace_compare(SEC_ACE *ace1, if (b1 != b2) { return (b1 ? 1 : -1); } - + /* * ACEs applying to an entity's object follow those applying to the * entity itself @@ -108,34 +108,34 @@ ace_compare(SEC_ACE *ace1, if (b1 != b2) { return (b1 ? 1 : -1); } - + /* * If we get this far, the ACEs are similar as far as the * characteristics we typically care about (those defined by the * referenced MS document). We'll now sort by characteristics that * just seems reasonable. */ - + if (ace1->type != ace2->type) { return ace2->type - ace1->type; } - + if (sid_compare(&ace1->trustee, &ace2->trustee)) { return sid_compare(&ace1->trustee, &ace2->trustee); } - + if (ace1->flags != ace2->flags) { return ace1->flags - ace2->flags; } - + if (ace1->access_mask != ace2->access_mask) { return ace1->access_mask - ace2->access_mask; } - + if (ace1->size != ace2->size) { return ace1->size - ace2->size; } - + return memcmp(ace1, ace2, sizeof(SEC_ACE)); } @@ -145,10 +145,10 @@ sort_acl(SEC_ACL *the_acl) { uint32 i; if (!the_acl) return; - + qsort(the_acl->aces, the_acl->num_aces, sizeof(the_acl->aces[0]), QSORT_CAST ace_compare); - + for (i=1;inum_aces;) { if (sec_ace_equal(&the_acl->aces[i-1], &the_acl->aces[i])) { int j; @@ -175,32 +175,32 @@ convert_sid_to_string(struct cli_state *ipc_cli, enum lsa_SidType *types = NULL; struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli); TALLOC_CTX *ctx; - + sid_to_fstring(str, sid); - + if (numeric) { return; /* no lookup desired */ } - + if (!pipe_hnd) { return; } - + /* Ask LSA to convert the sid to a name */ - + ctx = talloc_stackframe(); - + if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(pipe_hnd, ctx, - pol, 1, sid, &domains, - &names, &types)) || + pol, 1, sid, &domains, + &names, &types)) || !domains || !domains[0] || !names || !names[0]) { TALLOC_FREE(ctx); return; } - + TALLOC_FREE(ctx); /* Converted OK */ - + slprintf(str, sizeof(fstring) - 1, "%s%s%s", domains[0], lp_winbind_separator(), names[0]); @@ -219,31 +219,32 @@ convert_string_to_sid(struct cli_state *ipc_cli, bool result = True; TALLOC_CTX *ctx = NULL; struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli); - + if (!pipe_hnd) { return False; } - + if (numeric) { if (strncmp(str, "S-", 2) == 0) { return string_to_sid(sid, str); } - + result = False; goto done; } - + ctx = talloc_stackframe(); if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(pipe_hnd, ctx, - pol, 1, &str, NULL, 1, &sids, - &types))) { + pol, 1, &str, + NULL, 1, &sids, + &types))) { result = False; goto done; } - + sid_copy(sid, &sids[0]); - done: - +done: + TALLOC_FREE(ctx); return result; } @@ -271,7 +272,7 @@ parse_ace(struct cli_state *ipc_cli, uint32 mask; }; TALLOC_CTX *frame = talloc_stackframe(); - + /* These values discovered by inspection */ static const struct perm_value special_values[] = { { "R", 0x00120089 }, @@ -282,15 +283,15 @@ parse_ace(struct cli_state *ipc_cli, { "O", 0x00080000 }, { NULL, 0 }, }; - + static const struct perm_value standard_values[] = { { "READ", 0x001200a9 }, { "CHANGE", 0x001301bf }, { "FULL", 0x001f01ff }, { NULL, 0 }, }; - - + + ZERO_STRUCTP(ace); p = strchr_m(str,':'); if (!p) { @@ -300,25 +301,25 @@ parse_ace(struct cli_state *ipc_cli, *p = '\0'; p++; /* Try to parse numeric form */ - + if (sscanf(p, "%i/%i/%i", &atype, &aflags, &amask) == 3 && convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) { goto done; } - + /* Try to parse text form */ - + if (!convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) { TALLOC_FREE(frame); return false; } - + cp = p; if (!next_token_talloc(frame, &cp, &tok, "/")) { TALLOC_FREE(frame); return false; } - + if (StrnCaseCmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) { atype = SEC_ACE_TYPE_ACCESS_ALLOWED; } else if (StrnCaseCmp(tok, "DENIED", strlen("DENIED")) == 0) { @@ -327,20 +328,20 @@ parse_ace(struct cli_state *ipc_cli, TALLOC_FREE(frame); return false; } - + /* Only numeric form accepted for flags at present */ - + if (!(next_token_talloc(frame, &cp, &tok, "/") && sscanf(tok, "%i", &aflags))) { TALLOC_FREE(frame); return false; } - + if (!next_token_talloc(frame, &cp, &tok, "/")) { TALLOC_FREE(frame); return false; } - + if (strncmp(tok, "0x", 2) == 0) { if (sscanf(tok, "%i", &amask) != 1) { TALLOC_FREE(frame); @@ -348,39 +349,39 @@ parse_ace(struct cli_state *ipc_cli, } goto done; } - + for (v = standard_values; v->perm; v++) { if (strcmp(tok, v->perm) == 0) { amask = v->mask; goto done; } } - + p = tok; - + while(*p) { bool found = False; - + for (v = special_values; v->perm; v++) { if (v->perm[0] == *p) { amask |= v->mask; found = True; } } - + if (!found) { TALLOC_FREE(frame); return false; } p++; } - + if (*p) { TALLOC_FREE(frame); return false; } - - done: + +done: mask = amask; init_sec_ace(ace, &sid, atype, mask, aflags); TALLOC_FREE(frame); @@ -395,13 +396,14 @@ add_ace(SEC_ACL **the_acl, { SEC_ACL *newacl; SEC_ACE *aces; - + if (! *the_acl) { (*the_acl) = make_sec_acl(ctx, 3, 1, ace); return True; } - - if ((aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces)) == NULL) { + + if ((aces = SMB_CALLOC_ARRAY(SEC_ACE, + 1+(*the_acl)->num_aces)) == NULL) { return False; } memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(SEC_ACE)); @@ -430,17 +432,17 @@ sec_desc_parse(TALLOC_CTX *ctx, DOM_SID *owner_sid=NULL; SEC_ACL *dacl=NULL; int revision=1; - + while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) { - + if (StrnCaseCmp(tok,"REVISION:", 9) == 0) { revision = strtol(tok+9, NULL, 16); continue; } - + if (StrnCaseCmp(tok,"OWNER:", 6) == 0) { if (owner_sid) { - DEBUG(5, ("OWNER specified more than once!\n")); + DEBUG(5,("OWNER specified more than once!\n")); goto done; } owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); @@ -453,10 +455,10 @@ sec_desc_parse(TALLOC_CTX *ctx, } continue; } - + if (StrnCaseCmp(tok,"OWNER+:", 7) == 0) { if (owner_sid) { - DEBUG(5, ("OWNER specified more than once!\n")); + DEBUG(5,("OWNER specified more than once!\n")); goto done; } owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); @@ -469,10 +471,10 @@ sec_desc_parse(TALLOC_CTX *ctx, } continue; } - + if (StrnCaseCmp(tok,"GROUP:", 6) == 0) { if (group_sid) { - DEBUG(5, ("GROUP specified more than once!\n")); + DEBUG(5,("GROUP specified more than once!\n")); goto done; } group_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); @@ -485,10 +487,10 @@ sec_desc_parse(TALLOC_CTX *ctx, } continue; } - + if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) { if (group_sid) { - DEBUG(5, ("GROUP specified more than once!\n")); + DEBUG(5,("GROUP specified more than once!\n")); goto done; } group_sid = SMB_CALLOC_ARRAY(DOM_SID, 1); @@ -501,7 +503,7 @@ sec_desc_parse(TALLOC_CTX *ctx, } continue; } - + if (StrnCaseCmp(tok,"ACL:", 4) == 0) { SEC_ACE ace; if (!parse_ace(ipc_cli, pol, &ace, numeric, tok+4)) { @@ -514,7 +516,7 @@ sec_desc_parse(TALLOC_CTX *ctx, } continue; } - + if (StrnCaseCmp(tok,"ACL+:", 5) == 0) { SEC_ACE ace; if (!parse_ace(ipc_cli, pol, &ace, False, tok+5)) { @@ -527,18 +529,18 @@ sec_desc_parse(TALLOC_CTX *ctx, } continue; } - + DEBUG(5, ("Failed to parse security descriptor\n")); goto done; } - + ret = make_sec_desc(ctx, revision, SEC_DESC_SELF_RELATIVE, owner_sid, group_sid, NULL, dacl, &sd_size); - - done: + +done: SAFE_FREE(group_sid); SAFE_FREE(owner_sid); - + return ret; } @@ -558,13 +560,13 @@ dos_attr_query(SMBCCTX *context, uint16 mode = 0; SMB_INO_T inode = 0; DOS_ATTR_DESC *ret; - + ret = TALLOC_P(ctx, DOS_ATTR_DESC); if (!ret) { errno = ENOMEM; return NULL; } - + /* Obtain the DOS attributes */ if (!SMBC_getatr(context, srv, CONST_DISCARD(char *, filename), &mode, &size, @@ -577,7 +579,7 @@ dos_attr_query(SMBCCTX *context, DEBUG(5, ("dos_attr_query Failed to query old attributes\n")); return NULL; } - + ret->mode = mode; ret->size = size; ret->create_time = convert_timespec_to_time_t(create_time_ts); @@ -585,7 +587,7 @@ dos_attr_query(SMBCCTX *context, ret->write_time = convert_timespec_to_time_t(write_time_ts); ret->change_time = convert_timespec_to_time_t(change_time_ts); ret->inode = inode; - + return ret; } @@ -607,7 +609,7 @@ dos_attr_parse(SMBCCTX *context, const char * write_time_attr; const char * change_time_attr; } attr_strings; - + /* Determine whether to use old-style or new-style attribute names */ if (context->internal->full_time_names) { /* new-style names */ @@ -622,7 +624,7 @@ dos_attr_parse(SMBCCTX *context, attr_strings.write_time_attr = "M_TIME"; attr_strings.change_time_attr = "C_TIME"; } - + /* if this is to set the entire ACL... */ if (*str == '*') { /* ... then increment past the first colon if there is one */ @@ -632,7 +634,7 @@ dos_attr_parse(SMBCCTX *context, p = str; } } - + frame = talloc_stackframe(); while (next_token_talloc(frame, &p, &tok, "\t,\r\n")) { if (StrnCaseCmp(tok, "MODE:", 5) == 0) { @@ -647,30 +649,30 @@ dos_attr_parse(SMBCCTX *context, } continue; } - + if (StrnCaseCmp(tok, "SIZE:", 5) == 0) { dad->size = (SMB_OFF_T)atof(tok+5); continue; } - + n = strlen(attr_strings.access_time_attr); if (StrnCaseCmp(tok, attr_strings.access_time_attr, n) == 0) { dad->access_time = (time_t)strtol(tok+n+1, NULL, 10); continue; } - + n = strlen(attr_strings.change_time_attr); if (StrnCaseCmp(tok, attr_strings.change_time_attr, n) == 0) { dad->change_time = (time_t)strtol(tok+n+1, NULL, 10); continue; } - + n = strlen(attr_strings.write_time_attr); if (StrnCaseCmp(tok, attr_strings.write_time_attr, n) == 0) { dad->write_time = (time_t)strtol(tok+n+1, NULL, 10); continue; } - + if (attr_strings.create_time_attr != NULL) { n = strlen(attr_strings.create_time_attr); if (StrnCaseCmp(tok, attr_strings.create_time_attr, @@ -680,7 +682,7 @@ dos_attr_parse(SMBCCTX *context, continue; } } - + if (StrnCaseCmp(tok, "INODE:", 6) == 0) { dad->inode = (SMB_INO_T)atof(tok+6); continue; @@ -757,7 +759,7 @@ cacl_get(SMBCCTX *context, const char * write_time_attr; const char * change_time_attr; } excl_attr_strings; - + /* Determine whether to use old-style or new-style attribute names */ if (context->internal->full_time_names) { /* new-style names */ @@ -765,7 +767,7 @@ cacl_get(SMBCCTX *context, attr_strings.access_time_attr = "ACCESS_TIME"; attr_strings.write_time_attr = "WRITE_TIME"; attr_strings.change_time_attr = "CHANGE_TIME"; - + excl_attr_strings.create_time_attr = "CREATE_TIME"; excl_attr_strings.access_time_attr = "ACCESS_TIME"; excl_attr_strings.write_time_attr = "WRITE_TIME"; @@ -776,28 +778,28 @@ cacl_get(SMBCCTX *context, attr_strings.access_time_attr = "A_TIME"; attr_strings.write_time_attr = "M_TIME"; attr_strings.change_time_attr = "C_TIME"; - + excl_attr_strings.create_time_attr = NULL; excl_attr_strings.access_time_attr = "dos_attr.A_TIME"; excl_attr_strings.write_time_attr = "dos_attr.M_TIME"; excl_attr_strings.change_time_attr = "dos_attr.C_TIME"; } - + /* Copy name so we can strip off exclusions (if any are specified) */ strncpy(name_sandbox, attr_name, sizeof(name_sandbox) - 1); - + /* Ensure name is null terminated */ name_sandbox[sizeof(name_sandbox) - 1] = '\0'; - + /* Play in the sandbox */ name = name_sandbox; - + /* If there are any exclusions, point to them and mask them from name */ if ((pExclude = strchr(name, '!')) != NULL) { *pExclude++ = '\0'; } - + all = (StrnCaseCmp(name, "system.*", 8) == 0); all_nt = (StrnCaseCmp(name, "system.nt_sec_desc.*", 20) == 0); all_nt_acls = (StrnCaseCmp(name, "system.nt_sec_desc.acl.*", 24) == 0); @@ -805,71 +807,77 @@ cacl_get(SMBCCTX *context, some_nt = (StrnCaseCmp(name, "system.nt_sec_desc.", 19) == 0); some_dos = (StrnCaseCmp(name, "system.dos_attr.", 16) == 0); numeric = (* (name + strlen(name) - 1) != '+'); - + /* Look for exclusions from "all" requests */ if (all || all_nt || all_dos) { - + /* Exclusions are delimited by '!' */ for (; pExclude != NULL; pExclude = (p == NULL ? NULL : p + 1)) { - - /* Find end of this exclusion name */ - if ((p = strchr(pExclude, '!')) != NULL) - { - *p = '\0'; - } - - /* Which exclusion name is this? */ - if (StrCaseCmp(pExclude, "nt_sec_desc.revision") == 0) { - exclude_nt_revision = True; - } - else if (StrCaseCmp(pExclude, "nt_sec_desc.owner") == 0) { - exclude_nt_owner = True; - } - else if (StrCaseCmp(pExclude, "nt_sec_desc.group") == 0) { - exclude_nt_group = True; - } - else if (StrCaseCmp(pExclude, "nt_sec_desc.acl") == 0) { - exclude_nt_acl = True; - } - else if (StrCaseCmp(pExclude, "dos_attr.mode") == 0) { - exclude_dos_mode = True; - } - else if (StrCaseCmp(pExclude, "dos_attr.size") == 0) { - exclude_dos_size = True; - } - else if (excl_attr_strings.create_time_attr != NULL && - StrCaseCmp(pExclude, - excl_attr_strings.change_time_attr) == 0) { - exclude_dos_create_time = True; - } - else if (StrCaseCmp(pExclude, - excl_attr_strings.access_time_attr) == 0) { - exclude_dos_access_time = True; - } - else if (StrCaseCmp(pExclude, - excl_attr_strings.write_time_attr) == 0) { - exclude_dos_write_time = True; - } - else if (StrCaseCmp(pExclude, - excl_attr_strings.change_time_attr) == 0) { - exclude_dos_change_time = True; - } - else if (StrCaseCmp(pExclude, "dos_attr.inode") == 0) { - exclude_dos_inode = True; - } - else { - DEBUG(5, ("cacl_get received unknown exclusion: %s\n", - pExclude)); - errno = ENOATTR; - return -1; + + /* Find end of this exclusion name */ + if ((p = strchr(pExclude, '!')) != NULL) + { + *p = '\0'; + } + + /* Which exclusion name is this? */ + if (StrCaseCmp(pExclude, + "nt_sec_desc.revision") == 0) { + exclude_nt_revision = True; + } + else if (StrCaseCmp(pExclude, + "nt_sec_desc.owner") == 0) { + exclude_nt_owner = True; + } + else if (StrCaseCmp(pExclude, + "nt_sec_desc.group") == 0) { + exclude_nt_group = True; + } + else if (StrCaseCmp(pExclude, + "nt_sec_desc.acl") == 0) { + exclude_nt_acl = True; + } + else if (StrCaseCmp(pExclude, + "dos_attr.mode") == 0) { + exclude_dos_mode = True; + } + else if (StrCaseCmp(pExclude, + "dos_attr.size") == 0) { + exclude_dos_size = True; + } + else if (excl_attr_strings.create_time_attr != NULL && + StrCaseCmp(pExclude, + excl_attr_strings.change_time_attr) == 0) { + exclude_dos_create_time = True; + } + else if (StrCaseCmp(pExclude, + excl_attr_strings.access_time_attr) == 0) { + exclude_dos_access_time = True; + } + else if (StrCaseCmp(pExclude, + excl_attr_strings.write_time_attr) == 0) { + exclude_dos_write_time = True; + } + else if (StrCaseCmp(pExclude, + excl_attr_strings.change_time_attr) == 0) { + exclude_dos_change_time = True; + } + else if (StrCaseCmp(pExclude, "dos_attr.inode") == 0) { + exclude_dos_inode = True; + } + else { + DEBUG(5, ("cacl_get received unknown exclusion: %s\n", + pExclude)); + errno = ENOATTR; + return -1; + } } - } } - + n_used = 0; - + /* * If we are (possibly) talking to an NT or new system and some NT * attributes have been requested... @@ -877,28 +885,28 @@ cacl_get(SMBCCTX *context, if (ipc_cli && (all || some_nt || all_nt_acls)) { /* Point to the portion after "system.nt_sec_desc." */ name += 19; /* if (all) this will be invalid but unused */ - + /* ... then obtain any NT attributes which were requested */ fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ); - + if (fnum == -1) { DEBUG(5, ("cacl_get failed to open %s: %s\n", filename, cli_errstr(cli))); errno = 0; return -1; } - + sd = cli_query_secdesc(cli, fnum, ctx); - + if (!sd) { DEBUG(5, ("cacl_get Failed to query old descriptor\n")); errno = 0; return -1; } - + cli_close(cli, fnum); - + if (! exclude_nt_revision) { if (all || all_nt) { if (determine_size) { @@ -929,7 +937,7 @@ cacl_get(SMBCCTX *context, sd->revision); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -939,7 +947,7 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_nt_owner) { /* Get owner and group sid */ if (sd->owner_sid) { @@ -950,7 +958,7 @@ cacl_get(SMBCCTX *context, } else { fstrcpy(sidstr, ""); } - + if (all || all_nt) { if (determine_size) { p = talloc_asprintf(ctx, ",OWNER:%s", @@ -977,7 +985,7 @@ cacl_get(SMBCCTX *context, sidstr); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -987,7 +995,7 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_nt_group) { if (sd->group_sid) { convert_sid_to_string(ipc_cli, pol, @@ -996,7 +1004,7 @@ cacl_get(SMBCCTX *context, } else { fstrcpy(sidstr, ""); } - + if (all || all_nt) { if (determine_size) { p = talloc_asprintf(ctx, ",GROUP:%s", @@ -1023,7 +1031,7 @@ cacl_get(SMBCCTX *context, "%s", sidstr); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -1033,16 +1041,16 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_nt_acl) { /* Add aces to value buffer */ for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) { - + SEC_ACE *ace = &sd->dacl->aces[i]; convert_sid_to_string(ipc_cli, pol, sidstr, numeric, &ace->trustee); - + if (all || all_nt) { if (determine_size) { p = talloc_asprintf( @@ -1125,15 +1133,15 @@ cacl_get(SMBCCTX *context, n = 0; } } - + /* Restore name pointer to its original value */ name -= 19; } - + if (all || some_dos) { /* Point to the portion after "system.dos_attr." */ name += 16; /* if (all) this will be invalid but unused */ - + /* Obtain the DOS attributes */ if (!SMBC_getatr(context, srv, filename, &mode, &size, &create_time_ts, @@ -1141,17 +1149,17 @@ cacl_get(SMBCCTX *context, &write_time_ts, &change_time_ts, &ino)) { - + errno = SMBC_errno(context, srv->cli); return -1; - + } - + create_time = convert_timespec_to_time_t(create_time_ts); access_time = convert_timespec_to_time_t(access_time_ts); write_time = convert_timespec_to_time_t(write_time_ts); change_time = convert_timespec_to_time_t(change_time_ts); - + if (! exclude_dos_mode) { if (all || all_dos) { if (determine_size) { @@ -1189,7 +1197,7 @@ cacl_get(SMBCCTX *context, "0x%x", mode); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -1199,7 +1207,7 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_dos_size) { if (all || all_dos) { if (determine_size) { @@ -1234,7 +1242,7 @@ cacl_get(SMBCCTX *context, (double)size); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -1244,7 +1252,7 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_dos_create_time && attr_strings.create_time_attr != NULL) { if (all || all_dos) { @@ -1277,7 +1285,7 @@ cacl_get(SMBCCTX *context, "%lu", create_time); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -1287,7 +1295,7 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_dos_access_time) { if (all || all_dos) { if (determine_size) { @@ -1319,7 +1327,7 @@ cacl_get(SMBCCTX *context, "%lu", access_time); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -1329,7 +1337,7 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_dos_write_time) { if (all || all_dos) { if (determine_size) { @@ -1361,7 +1369,7 @@ cacl_get(SMBCCTX *context, "%lu", write_time); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -1371,7 +1379,7 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_dos_change_time) { if (all || all_dos) { if (determine_size) { @@ -1403,7 +1411,7 @@ cacl_get(SMBCCTX *context, "%lu", change_time); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -1413,7 +1421,7 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + if (! exclude_dos_inode) { if (all || all_dos) { if (determine_size) { @@ -1448,7 +1456,7 @@ cacl_get(SMBCCTX *context, (double) ino); } } - + if (!determine_size && n > bufsize) { errno = ERANGE; return -1; @@ -1458,16 +1466,16 @@ cacl_get(SMBCCTX *context, bufsize -= n; n = 0; } - + /* Restore name pointer to its original value */ name -= 16; } - + if (n_used == 0) { errno = ENOATTR; return -1; } - + return n_used; } @@ -1495,68 +1503,68 @@ cacl_set(TALLOC_CTX *ctx, int ret = 0; char *p; bool numeric = True; - + /* the_acl will be null for REMOVE_ALL operations */ if (the_acl) { numeric = ((p = strchr(the_acl, ':')) != NULL && p > the_acl && p[-1] != '+'); - + /* if this is to set the entire ACL... */ if (*the_acl == '*') { /* ... then increment past the first colon */ the_acl = p + 1; } - + sd = sec_desc_parse(ctx, ipc_cli, pol, numeric, CONST_DISCARD(char *, the_acl)); - + if (!sd) { errno = EINVAL; return -1; } } - + /* SMBC_XATTR_MODE_REMOVE_ALL is the only caller that doesn't deref sd */ - + if (!sd && (mode != SMBC_XATTR_MODE_REMOVE_ALL)) { errno = EINVAL; return -1; } - + /* The desired access below is the only one I could find that works with NT4, W2KP and Samba */ - + fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ); - + if (fnum == -1) { DEBUG(5, ("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli))); errno = 0; return -1; } - + old = cli_query_secdesc(cli, fnum, ctx); - + if (!old) { DEBUG(5, ("cacl_set Failed to query old descriptor\n")); errno = 0; return -1; } - + cli_close(cli, fnum); - + switch (mode) { case SMBC_XATTR_MODE_REMOVE_ALL: old->dacl->num_aces = 0; dacl = old->dacl; break; - + case SMBC_XATTR_MODE_REMOVE: for (i=0;sd->dacl && idacl->num_aces;i++) { bool found = False; - + for (j=0;old->dacl && jdacl->num_aces;j++) { if (sec_ace_equal(&sd->dacl->aces[i], &old->dacl->aces[j])) { @@ -1571,7 +1579,7 @@ cacl_set(TALLOC_CTX *ctx, break; } } - + if (!found) { err = ENOATTR; ret = -1; @@ -1579,11 +1587,11 @@ cacl_set(TALLOC_CTX *ctx, } } break; - + case SMBC_XATTR_MODE_ADD: for (i=0;sd->dacl && idacl->num_aces;i++) { bool found = False; - + for (j=0;old->dacl && jdacl->num_aces;j++) { if (sid_equal(&sd->dacl->aces[i].trustee, &old->dacl->aces[j].trustee)) { @@ -1597,67 +1605,67 @@ cacl_set(TALLOC_CTX *ctx, found = True; } } - + if (!found && (flags & SMBC_XATTR_FLAG_REPLACE)) { err = ENOATTR; ret = -1; goto failed; } - + for (i=0;sd->dacl && idacl->num_aces;i++) { add_ace(&old->dacl, &sd->dacl->aces[i], ctx); } } dacl = old->dacl; break; - + case SMBC_XATTR_MODE_SET: old = sd; owner_sid = old->owner_sid; group_sid = old->group_sid; dacl = old->dacl; break; - + case SMBC_XATTR_MODE_CHOWN: owner_sid = sd->owner_sid; break; - + case SMBC_XATTR_MODE_CHGRP: group_sid = sd->group_sid; break; } - + /* Denied ACE entries must come before allowed ones */ sort_acl(old->dacl); - + /* Create new security descriptor and set it */ sd = make_sec_desc(ctx, old->revision, SEC_DESC_SELF_RELATIVE, owner_sid, group_sid, NULL, dacl, &sd_size); - + fnum = cli_nt_create(cli, filename, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS); - + if (fnum == -1) { DEBUG(5, ("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli))); errno = 0; return -1; } - + if (!cli_set_secdesc(cli, fnum, sd)) { DEBUG(5, ("ERROR: secdesc set failed: %s\n", cli_errstr(cli))); ret = -1; } - + /* Clean up */ - - failed: + +failed: cli_close(cli, fnum); - + if (err != 0) { errno = err; } - + return ret; } @@ -1688,38 +1696,38 @@ SMBC_setxattr_ctx(SMBCCTX *context, const char * change_time_attr; } attr_strings; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_setxattr(%s, %s, %.*s)\n", fname, name, (int) size, (const char*)value)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -1728,14 +1736,14 @@ SMBC_setxattr_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); if (!srv) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ } - + if (! srv->no_nt_session) { ipc_srv = SMBC_attr_server(frame, context, server, share, &workgroup, &user, &password); @@ -1745,7 +1753,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, } else { ipc_srv = NULL; } - + /* * Are they asking to set the entire set of known attributes? */ @@ -1761,7 +1769,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, TALLOC_FREE(frame); return -1; } - + if (ipc_srv) { ret = cacl_set(talloc_tos(), srv->cli, ipc_srv->cli, &ipc_srv->pol, path, @@ -1773,13 +1781,13 @@ SMBC_setxattr_ctx(SMBCCTX *context, } else { ret = 0; } - + /* get a DOS Attribute Descriptor with current attributes */ dad = dos_attr_query(context, talloc_tos(), path, srv); if (dad) { /* Overwrite old with new, using what was provided */ dos_attr_parse(context, dad, srv, namevalue); - + /* Set the new DOS attributes */ if (! SMBC_setatr(context, srv, path, dad->create_time, @@ -1787,12 +1795,12 @@ SMBC_setxattr_ctx(SMBCCTX *context, dad->write_time, dad->change_time, dad->mode)) { - + /* cause failure if NT failed too */ dad = NULL; } } - + /* we only fail if both NT and DOS sets failed */ if (ret < 0 && ! dad) { ret = -1; /* in case dad was null */ @@ -1800,11 +1808,11 @@ SMBC_setxattr_ctx(SMBCCTX *context, else { ret = 0; } - + TALLOC_FREE(frame); return ret; } - + /* * Are they asking to set an access control element or to set * the entire access control list? @@ -1814,12 +1822,12 @@ SMBC_setxattr_ctx(SMBCCTX *context, StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 || StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 || StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) { - + /* Yup. */ char *namevalue = talloc_asprintf(talloc_tos(), "%s:%s", name+19, (const char *) value); - + if (! ipc_srv) { ret = -1; /* errno set by SMBC_server() */ } @@ -1838,18 +1846,18 @@ SMBC_setxattr_ctx(SMBCCTX *context, TALLOC_FREE(frame); return ret; } - + /* * Are they asking to set the owner? */ if (StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 || StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0) { - + /* Yup. */ char *namevalue = talloc_asprintf(talloc_tos(), "%s:%s", name+19, (const char *) value); - + if (! ipc_srv) { ret = -1; /* errno set by SMBC_server() */ } @@ -1864,18 +1872,18 @@ SMBC_setxattr_ctx(SMBCCTX *context, TALLOC_FREE(frame); return ret; } - + /* * Are they asking to set the group? */ if (StrCaseCmp(name, "system.nt_sec_desc.group") == 0 || StrCaseCmp(name, "system.nt_sec_desc.group+") == 0) { - + /* Yup. */ char *namevalue = talloc_asprintf(talloc_tos(), "%s:%s", name+19, (const char *) value); - + if (! ipc_srv) { /* errno set by SMBC_server() */ ret = -1; @@ -1891,7 +1899,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, TALLOC_FREE(frame); return ret; } - + /* Determine whether to use old-style or new-style attribute names */ if (context->internal->full_time_names) { /* new-style names */ @@ -1906,7 +1914,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, attr_strings.write_time_attr = "system.dos_attr.M_TIME"; attr_strings.change_time_attr = "system.dos_attr.C_TIME"; } - + /* * Are they asking to set a DOS attribute? */ @@ -1917,7 +1925,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, StrCaseCmp(name, attr_strings.access_time_attr) == 0 || StrCaseCmp(name, attr_strings.write_time_attr) == 0 || StrCaseCmp(name, attr_strings.change_time_attr) == 0) { - + /* get a DOS Attribute Descriptor with current attributes */ dad = dos_attr_query(context, talloc_tos(), path, srv); if (dad) { @@ -1930,7 +1938,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, } else { /* Overwrite old with provided new params */ dos_attr_parse(context, dad, srv, namevalue); - + /* Set the new DOS attributes */ ret2 = SMBC_setatr(context, srv, path, dad->create_time, @@ -1938,7 +1946,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, dad->write_time, dad->change_time, dad->mode); - + /* ret2 has True (success) / False (failure) */ if (ret2) { ret = 0; @@ -1949,11 +1957,11 @@ SMBC_setxattr_ctx(SMBCCTX *context, } else { ret = -1; } - + TALLOC_FREE(frame); return ret; } - + /* Unsupported attribute name */ errno = EINVAL; TALLOC_FREE(frame); @@ -1983,37 +1991,37 @@ SMBC_getxattr_ctx(SMBCCTX *context, const char * change_time_attr; } attr_strings; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_getxattr(%s, %s)\n", fname, name)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -2022,14 +2030,14 @@ SMBC_getxattr_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); if (!srv) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ } - + if (! srv->no_nt_session) { ipc_srv = SMBC_attr_server(frame, context, server, share, &workgroup, &user, &password); @@ -2039,7 +2047,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, } else { ipc_srv = NULL; } - + /* Determine whether to use old-style or new-style attribute names */ if (context->internal->full_time_names) { /* new-style names */ @@ -2054,7 +2062,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, attr_strings.write_time_attr = "system.dos_attr.M_TIME"; attr_strings.change_time_attr = "system.dos_attr.C_TIME"; } - + /* Are they requesting a supported attribute? */ if (StrCaseCmp(name, "system.*") == 0 || StrnCaseCmp(name, "system.*!", 9) == 0 || @@ -2081,7 +2089,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, StrCaseCmp(name, attr_strings.write_time_attr) == 0 || StrCaseCmp(name, attr_strings.change_time_attr) == 0 || StrCaseCmp(name, "system.dos_attr.inode") == 0) { - + /* Yup. */ ret = cacl_get(context, talloc_tos(), srv, ipc_srv == NULL ? NULL : ipc_srv->cli, @@ -2094,7 +2102,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, TALLOC_FREE(frame); return ret; } - + /* Unsupported attribute name */ errno = EINVAL; TALLOC_FREE(frame); @@ -2117,37 +2125,37 @@ SMBC_removexattr_ctx(SMBCCTX *context, char *workgroup = NULL; char *path = NULL; TALLOC_CTX *frame = talloc_stackframe(); - + if (!context || !context->internal->initialized) { - + errno = EINVAL; /* Best I can think of ... */ TALLOC_FREE(frame); return -1; } - + if (!fname) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + DEBUG(4, ("smbc_removexattr(%s, %s)\n", fname, name)); - + if (SMBC_parse_path(frame, - context, - fname, - &workgroup, - &server, - &share, - &path, - &user, - &password, - NULL)) { + context, + fname, + &workgroup, + &server, + &share, + &path, + &user, + &password, + NULL)) { errno = EINVAL; TALLOC_FREE(frame); return -1; } - + if (!user || user[0] == (char)0) { user = talloc_strdup(frame, context->config.user); if (!user) { @@ -2156,14 +2164,14 @@ SMBC_removexattr_ctx(SMBCCTX *context, return -1; } } - + srv = SMBC_server(frame, context, True, server, share, &workgroup, &user, &password); if (!srv) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_server */ } - + if (! srv->no_nt_session) { ipc_srv = SMBC_attr_server(frame, context, server, share, &workgroup, &user, &password); @@ -2173,16 +2181,16 @@ SMBC_removexattr_ctx(SMBCCTX *context, } else { ipc_srv = NULL; } - + if (! ipc_srv) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_attr_server */ } - + /* Are they asking to set the entire ACL? */ if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 || StrCaseCmp(name, "system.nt_sec_desc.*+") == 0) { - + /* Yup. */ ret = cacl_set(talloc_tos(), srv->cli, ipc_srv->cli, &ipc_srv->pol, path, @@ -2190,7 +2198,7 @@ SMBC_removexattr_ctx(SMBCCTX *context, TALLOC_FREE(frame); return ret; } - + /* * Are they asking to remove one or more spceific security descriptor * attributes? @@ -2202,7 +2210,7 @@ SMBC_removexattr_ctx(SMBCCTX *context, StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 || StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 || StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) { - + /* Yup. */ ret = cacl_set(talloc_tos(), srv->cli, ipc_srv->cli, &ipc_srv->pol, path, @@ -2210,7 +2218,7 @@ SMBC_removexattr_ctx(SMBCCTX *context, TALLOC_FREE(frame); return ret; } - + /* Unsupported attribute name */ errno = EINVAL; TALLOC_FREE(frame); @@ -2269,7 +2277,7 @@ SMBC_listxattr_ctx(SMBCCTX *context, "system.dos_attr.change_time\0" ; const char * supported; - + if (context->internal->full_time_names) { supported = supported_new; retsize = sizeof(supported_new); @@ -2277,16 +2285,16 @@ SMBC_listxattr_ctx(SMBCCTX *context, supported = supported_old; retsize = sizeof(supported_old); } - + if (size == 0) { return retsize; } - + if (retsize > size) { errno = ERANGE; return -1; } - + /* this can't be strcpy() because there are embedded null characters */ memcpy(list, supported, retsize); return retsize; -- cgit From 0bd3df33eddf305f5d812ab1788232c925576c5e Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 20:55:21 -0500 Subject: Mark smbc_option_{get,set} as deprecated (This used to be commit a8b4b773d4647f28e7b92c5968469721d34eb550) --- source3/include/libsmbclient.h | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'source3') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 28cad351de..058ac64210 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -142,7 +142,7 @@ struct smbc_dirent /* * Valid values for the option "open_share_mode", when calling - * smbc_option_set() + * smbc_setOptionOpenShareMode() */ typedef enum smbc_share_mode { @@ -1010,35 +1010,15 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); /**@ingroup misc - * Each time the context structure is changed, we have binary backward - * compatibility issues. Instead of modifying the public portions of the - * context structure to add new options, instead, we put them in the internal - * portion of the context structure and provide a set function for these new - * options. - * - * @param context A pointer to a SMBCCTX obtained from smbc_new_context() - * - * @param option_name - * The name of the option for which the value is to be set - * - * @param option_value - * The new value of the option being set * + * @DEPRECATED. Use smbc_setOption*() functions instead. */ void smbc_option_set(SMBCCTX *context, char *option_name, ... /* option_value */); /* - * Retrieve the current value of an option - * - * @param context A pointer to a SMBCCTX obtained from smbc_new_context() - * - * @param option_name - * The name of the option for which the value is to be - * retrieved - * - * @return The value of the specified option. + * @DEPRECATED. Use smbc_getOption*() functions instead. */ void * smbc_option_get(SMBCCTX *context, -- cgit From b3c16a241d27b4220fd25dcf4d30974a787f6ce7 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 20:56:54 -0500 Subject: Comment was in wrong place (This used to be commit dec70fa3c0424c148016cc667a3c159e16d8a944) --- source3/include/libsmbclient.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 058ac64210..95ee64d0fe 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -677,16 +677,15 @@ smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c); void smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b); -/** Get the function for obtaining authentication data */ -smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); - - /************************************* * Getters and setters for FUNCTIONS * *************************************/ +/** Get the function for obtaining authentication data */ +smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); + /** Set the function for obtaining authentication data */ void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn f); -- cgit From 4a3410b766a1121804ec2d901bf788354aa197e6 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 21:19:15 -0500 Subject: change variable name from f to fn for function pointers (This used to be commit 1fd65359f6cd07539cfe43146ac367a48708a678) --- source3/include/libsmbclient.h | 74 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'source3') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 95ee64d0fe..78f5931221 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -687,7 +687,7 @@ smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b); smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); /** Set the function for obtaining authentication data */ -void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn f); +void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn); /** Get the new-style authentication function which includes the context. */ smbc_get_auth_data_with_context_fn @@ -696,39 +696,39 @@ smbc_getFunctionAuthDataWithContext(SMBCCTX *c); /** Set the new-style authentication function which includes the context. */ void smbc_setFunctionAuthDataWithContext(SMBCCTX *c, - smbc_get_auth_data_with_context_fn fn); + smbc_get_auth_data_with_context_fn fn); /** Get the function for checking if a server is still good */ smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c); /** Set the function for checking if a server is still good */ -void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn f); +void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn); /** Get the function for removing a server if unused */ smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c); /** Set the function for removing a server if unused */ void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, - smbc_remove_unused_server_fn f); + smbc_remove_unused_server_fn fn); /** Get the function for adding a cached server */ smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c); /** Set the function for adding a cached server */ -void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn f); +void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn); /** Get the function for server cache lookup */ smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c); /** Set the function for server cache lookup */ -void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn f); +void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn); /** Get the function for server cache removal */ smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c); /** Set the function for server cache removal */ void smbc_setFunctionRemoveCachedServer(SMBCCTX *c, - smbc_remove_cached_srv_fn f); + smbc_remove_cached_srv_fn fn); /** * Get the function for server cache purging. This function tries to @@ -741,7 +741,7 @@ smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); * remove all cached servers (e.g. on disconnect) */ void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, - smbc_purge_cached_srv_fn f); + smbc_purge_cached_srv_fn fn); /** Get the function to store private data of the server cache */ struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); @@ -762,7 +762,7 @@ typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c, int flags, mode_t mode); smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c); -void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn f); +void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn); typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c, const char *path, @@ -775,56 +775,56 @@ typedef ssize_t (*smbc_read_fn)(SMBCCTX *c, void *buf, size_t count); smbc_read_fn smbc_getFunctionRead(SMBCCTX *c); -void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn f); +void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn); typedef ssize_t (*smbc_write_fn)(SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c); -void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn f); +void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn); typedef int (*smbc_unlink_fn)(SMBCCTX *c, const char *fname); smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c); -void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn f); +void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn); typedef int (*smbc_rename_fn)(SMBCCTX *ocontext, const char *oname, SMBCCTX *ncontext, const char *nname); smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c); -void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn f); +void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn); typedef off_t (*smbc_lseek_fn)(SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c); -void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn f); +void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn); typedef int (*smbc_stat_fn)(SMBCCTX *c, const char *fname, struct stat *st); smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c); -void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn f); +void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn); typedef int (*smbc_fstat_fn)(SMBCCTX *c, SMBCFILE *file, struct stat *st); smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c); -void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn f); +void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn); typedef int (*smbc_ftruncate_fn)(SMBCCTX *c, SMBCFILE *f, off_t size); smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c); -void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn f); +void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn); typedef int (*smbc_close_fn)(SMBCCTX *c, SMBCFILE *file); smbc_close_fn smbc_getFunctionClose(SMBCCTX *c); -void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn f); +void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn); @@ -837,52 +837,52 @@ void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn f); typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c, const char *fname); smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c); -void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn f); +void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn); typedef int (*smbc_closedir_fn)(SMBCCTX *c, SMBCFILE *dir); smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c); -void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn f); +void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn); typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c, SMBCFILE *dir); smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c); -void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn f); +void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn); typedef int (*smbc_getdents_fn)(SMBCCTX *c, SMBCFILE *dir, struct smbc_dirent *dirp, int count); smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c); -void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn f); +void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn); typedef int (*smbc_mkdir_fn)(SMBCCTX *c, const char *fname, mode_t mode); smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c); -void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn f); +void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn); typedef int (*smbc_rmdir_fn)(SMBCCTX *c, const char *fname); smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c); -void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn f); +void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn); typedef off_t (*smbc_telldir_fn)(SMBCCTX *c, SMBCFILE *dir); smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c); -void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn f); +void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn); typedef int (*smbc_lseekdir_fn)(SMBCCTX *c, SMBCFILE *dir, off_t offset); smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c); -void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn f); +void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn); typedef int (*smbc_fstatdir_fn)(SMBCCTX *c, SMBCFILE *dir, struct stat *st); smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c); -void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn f); +void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn); @@ -896,13 +896,13 @@ typedef int (*smbc_chmod_fn)(SMBCCTX *c, const char *fname, mode_t mode); smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c); -void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn f); +void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn); typedef int (*smbc_utimes_fn)(SMBCCTX *c, const char *fname, struct timeval *tbuf); smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c); -void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn f); +void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn); typedef int (*smbc_setxattr_fn)(SMBCCTX *context, const char *fname, @@ -911,7 +911,7 @@ typedef int (*smbc_setxattr_fn)(SMBCCTX *context, size_t size, int flags); smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c); -void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn f); +void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn); typedef int (*smbc_getxattr_fn)(SMBCCTX *context, const char *fname, @@ -919,20 +919,20 @@ typedef int (*smbc_getxattr_fn)(SMBCCTX *context, const void *value, size_t size); smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c); -void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn f); +void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn); typedef int (*smbc_removexattr_fn)(SMBCCTX *context, const char *fname, const char *name); smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c); -void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn f); +void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn); typedef int (*smbc_listxattr_fn)(SMBCCTX *context, const char *fname, char *list, size_t size); smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c); -void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn f); +void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn); @@ -947,27 +947,27 @@ typedef int (*smbc_print_file_fn)(SMBCCTX *c_file, SMBCCTX *c_print, const char *printq); smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c); -void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn f); +void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn); typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c, const char *fname); smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c); void smbc_setFunctionOpenPrintJob(SMBCCTX *c, - smbc_open_print_job_fn f); + smbc_open_print_job_fn fn); typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c, const char *fname, smbc_list_print_job_fn fn); smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c); void smbc_setFunctionListPrintJobs(SMBCCTX *c, - smbc_list_print_jobs_fn f); + smbc_list_print_jobs_fn fn); typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c, const char *fname, int id); smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c); void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, - smbc_unlink_print_job_fn f); + smbc_unlink_print_job_fn fn); /**@ingroup misc -- cgit From fc65c6698e74e40828e218dc2e6de0c094bfe6e0 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 21:19:52 -0500 Subject: Return NULL, not 0, from a function which returns a pointer. (This used to be commit 23cb9c49e3724cecaa66655ef64c3111bf14c552) --- source3/libsmb/libsmb_cache.c | 1 - source3/libsmb/libsmb_context.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c index ff13fd7eac..c45aba4544 100644 --- a/source3/libsmb/libsmb_cache.c +++ b/source3/libsmb/libsmb_cache.c @@ -1,4 +1,3 @@ - /* Unix SMB/CIFS implementation. SMB client library implementation (server cache) diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index 8af49d12be..c107ab2220 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -424,7 +424,7 @@ smbc_init_context(SMBCCTX *context) /* Do not initialise the same client twice */ if (context->internal->initialized) { - return 0; + return NULL; } if (!context->server.get_auth_data_fn || @@ -446,7 +446,7 @@ smbc_init_context(SMBCCTX *context) /* Set this to what the user wants */ DEBUGLEVEL = context->config.debug; - + load_case_tables(); setup_logging("libsmbclient", True); -- cgit From bf950ea7586c558205a7315419d015263f53e4e4 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 2 Mar 2008 16:13:25 -0500 Subject: fixed missing white space (This used to be commit 71e86f13b0ace3841c6712084728c79db74ff803) --- source3/include/libsmbclient.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 78f5931221..bfed71de1c 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1016,6 +1016,7 @@ void smbc_option_set(SMBCCTX *context, char *option_name, ... /* option_value */); + /* * @DEPRECATED. Use smbc_getOption*() functions instead. */ -- cgit From 2418916460daf264179f07c5432c375ab91c0ea8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 3 Mar 2008 09:43:10 +0100 Subject: Fix gp_find_file() which broke during the pstring removal. Guenther (This used to be commit f18ba6c877fa934d19ecc6a65be74b8bad7ee7e4) --- source3/libgpo/gpo_util.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libgpo/gpo_util.c b/source3/libgpo/gpo_util.c index f2d7c6924a..f41bbc1817 100644 --- a/source3/libgpo/gpo_util.c +++ b/source3/libgpo/gpo_util.c @@ -738,8 +738,11 @@ NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - tmp = talloc_asprintf_strupper_m(mem_ctx, "%s/%s/%s", filename, path, - suffix); + path = talloc_strdup_upper(mem_ctx, path); + NT_STATUS_HAVE_NO_MEMORY(path); + + tmp = talloc_asprintf(mem_ctx, "%s/%s/%s", filename, + path, suffix); NT_STATUS_HAVE_NO_MEMORY(tmp); if (sys_stat(tmp, &sbuf) == 0) { -- cgit From 4aa0bfc9853fd0b6d2882c40c53d20e65fe2fa48 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 3 Mar 2008 18:12:26 +0100 Subject: Zero out the out policy handler in lsa_Close ... after a REALLY long session staring at sniffs we can now join XP to v3-2-test again... Apparently not doing this makes XP keep an internal handle to LSA open which confuses the hell out of it. Karolin, this needs to be in v3-2-stable :-) Volker (This used to be commit 2c42fc21d8bede226e411623aecd69038477373b) --- source3/rpc_server/srv_lsa_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 1333d656d4..ce3fd1a44f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1216,6 +1216,7 @@ NTSTATUS _lsa_Close(pipes_struct *p, struct lsa_Close *r) } close_policy_hnd(p, r->in.handle); + ZERO_STRUCTP(r->out.handle); return NT_STATUS_OK; } -- cgit From 1363ee9d65965704f716965c6cbcfc0693ca2401 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 3 Mar 2008 18:13:33 -0500 Subject: Continued revamping of libsmbclient. - James suggested using gcc's "deprecated" attribute to mark the context structure fields to generate warnings. This creates a scenario with the best of all worlds. I'm able to move to an organization that more easily allows future enhancements, while avoiding any mandatory changes by applications. Thanks, James! - Updated WHATSNEW.txt so that it accurately reflects the current state of affairs. Derrell (This used to be commit a67f96fbe9683b46c2149f7cb439d13f7f0e6ecd) --- source3/Makefile.in | 1 + source3/include/libsmb_internal.h | 100 +--- source3/include/libsmbclient.h | 247 +++++---- source3/libsmb/libsmb_cache.c | 16 +- source3/libsmb/libsmb_context.c | 1078 ++++--------------------------------- source3/libsmb/libsmb_dir.c | 30 +- source3/libsmb/libsmb_file.c | 8 +- source3/libsmb/libsmb_path.c | 6 +- source3/libsmb/libsmb_printjob.c | 6 +- source3/libsmb/libsmb_server.c | 75 +-- source3/libsmb/libsmb_setget.c | 905 +++++++++++++++++++++++++++++++ source3/libsmb/libsmb_stat.c | 4 +- source3/libsmb/libsmb_xattr.c | 6 +- 13 files changed, 1214 insertions(+), 1268 deletions(-) create mode 100644 source3/libsmb/libsmb_setget.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 5f57f67e64..f4b0344ad2 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -775,6 +775,7 @@ LIBSMBCLIENT_OBJ0 = \ libsmb/libsmb_server.o \ libsmb/libsmb_stat.o \ libsmb/libsmb_xattr.o \ + libsmb/libsmb_setget.o \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \ diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index e687e24268..6930812b29 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -113,23 +113,6 @@ struct SMBC_internal_data { /* True when this handle is initialized */ bool initialized; -#if 0 /* Left in libsmbclient.h for backward compatibility */ - /* Netbios name used for making connections */ - char * netbios_name; - - /* Workgroup used for making connections */ - char * workgroup; - - /* Username used for making connections */ - char * user; - - /* Debug level */ - int debug; - - /* Connection timeout value */ - int timeout; -#endif - /* dirent pointer location * * Leave room for any urlencoded filename and the comment field. @@ -192,88 +175,7 @@ struct SMBC_internal_data { */ smbc_smb_encrypt_level smb_encryption_level; -#if 0 /* Left in libsmbclient.h for backward compatibility */ - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ - int browse_max_lmb_count; - - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ - bool urlencode_readdir_entries; - - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ - bool one_share_per_server; - - /* Kerberos-related flags */ - bool use_kerberos; - bool fallback_after_kerberos; - - /* Don't try to do automatic anonymous login */ - bool no_auto_anonymous_login; - - /* Server-related functions */ - struct - { - smbc_get_auth_data_fn get_auth_data_fn; - smbc_check_server_fn check_server_fn; - smbc_remove_unused_server_fn remove_unused_server_fn; - } server; - - /* Cache-related functions */ - struct - { - struct smbc_server_cache * server_cache_data; - smbc_add_cached_srv_fn add_cached_server_fn; - smbc_get_cached_srv_fn get_cached_server_fn; - smbc_remove_cached_srv_fn remove_cached_server_fn; - smbc_purge_cached_srv_fn purge_cached_server_fn; - } cache; -#endif + struct smbc_server_cache * server_cache; /* POSIX emulation functions */ struct diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index bfed71de1c..a60c05fa7f 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -25,6 +25,13 @@ #ifndef SMBCLIENT_H_INCLUDED #define SMBCLIENT_H_INCLUDED +#undef _DEPRECATED_ +#if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__) +# define _DEPRECATED_ __attribute__ ((deprecated)) +#else +# define _DEPRECATED_ +#endif + #ifdef __cplusplus extern "C" { #endif @@ -416,7 +423,7 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); * @return 0 when found and removed. 1 on failure. * */ -typedef int (*smbc_purge_cached_srv_fn) (SMBCCTX * c); +typedef int (*smbc_purge_cached_fn) (SMBCCTX * c); @@ -734,14 +741,14 @@ void smbc_setFunctionRemoveCachedServer(SMBCCTX *c, * Get the function for server cache purging. This function tries to * remove all cached servers (e.g. on disconnect) */ -smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); +smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); /** * Set the function for server cache purging. This function tries to * remove all cached servers (e.g. on disconnect) */ void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, - smbc_purge_cached_srv_fn fn); + smbc_purge_cached_fn fn); /** Get the function to store private data of the server cache */ struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); @@ -1010,7 +1017,7 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); /**@ingroup misc * - * @DEPRECATED. Use smbc_setOption*() functions instead. + * @deprecated. Use smbc_setOption*() functions instead. */ void smbc_option_set(SMBCCTX *context, @@ -1018,7 +1025,7 @@ smbc_option_set(SMBCCTX *context, ... /* option_value */); /* - * @DEPRECATED. Use smbc_getOption*() functions instead. + * @deprecated. Use smbc_getOption*() functions instead. */ void * smbc_option_get(SMBCCTX *context, @@ -2570,7 +2577,6 @@ smbc_version(void); } #endif - /** * @ingroup structure * Structure that contains a client context information @@ -2586,137 +2592,129 @@ smbc_version(void); * directly visible to applications. This makes it much easier to maintain * ABI compatibility. */ -struct _SMBCCTX { - struct - { - /** - * debug level - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getDebug() and smbc_setDebug() - */ - int debug; +struct _SMBCCTX +{ + /** + * debug level + * + * DEPRECATED: + * Use smbc_getDebug() and smbc_setDebug() + */ + int debug _DEPRECATED_; - /** - * netbios name used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getNetbiosName() and smbc_setNetbiosName() - */ - char * netbios_name; + /** + * netbios name used for making connections + * + * DEPRECATED: + * Use smbc_getNetbiosName() and smbc_setNetbiosName() + */ + char * netbios_name _DEPRECATED_; - /** - * workgroup name used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getWorkgroup() and smbc_setWorkgroup() - */ - char * workgroup; + /** + * workgroup name used for making connections + * + * DEPRECATED: + * Use smbc_getWorkgroup() and smbc_setWorkgroup() + */ + char * workgroup _DEPRECATED_; - /** - * username used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getUser() and smbc_setUser() - */ - char * user; - - /** - * timeout used for waiting on connections / response data (in - * milliseconds) - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getTimeout() and smbc_setTimeout() - */ - int timeout; - } config; + /** + * username used for making connections + * + * DEPRECATED: + * Use smbc_getUser() and smbc_setUser() + */ + char * user _DEPRECATED_; + + /** + * timeout used for waiting on connections / response data (in + * milliseconds) + * + * DEPRECATED: + * Use smbc_getTimeout() and smbc_setTimeout() + */ + int timeout _DEPRECATED_; /** * callable functions for files: * For usage and return values see the SMBC_* functions * - * Manually setting/retrieving these values is deprecated. + * DEPRECATED: * * Use smbc_getFunction*() and smbc_setFunction*(), e.g. * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. */ - struct - { - smbc_open_fn open_fn; - smbc_creat_fn creat_fn; - smbc_read_fn read_fn; - smbc_write_fn write_fn; - smbc_unlink_fn unlink_fn; - smbc_rename_fn rename_fn; - smbc_lseek_fn lseek_fn; - smbc_stat_fn stat_fn; - smbc_fstat_fn fstat_fn; + smbc_open_fn open _DEPRECATED_; + smbc_creat_fn creat _DEPRECATED_; + smbc_read_fn read _DEPRECATED_; + smbc_write_fn write _DEPRECATED_; + smbc_unlink_fn unlink _DEPRECATED_; + smbc_rename_fn rename _DEPRECATED_; + smbc_lseek_fn lseek _DEPRECATED_; + smbc_stat_fn stat _DEPRECATED_; + smbc_fstat_fn fstat _DEPRECATED_; #if 0 /* internal */ - smbc_ftruncate_fn ftruncate_fn; + smbc_ftruncate_fn ftruncate_fn; #endif - smbc_close_fn close_fn; - smbc_opendir_fn opendir_fn; - smbc_closedir_fn closedir_fn; - smbc_readdir_fn readdir_fn; - smbc_getdents_fn getdents_fn; - smbc_mkdir_fn mkdir_fn; - smbc_rmdir_fn rmdir_fn; - smbc_telldir_fn telldir_fn; - smbc_lseekdir_fn lseekdir_fn; - smbc_fstatdir_fn fstatdir_fn; - smbc_chmod_fn chmod_fn; - smbc_utimes_fn utimes_fn; - smbc_setxattr_fn setxattr_fn; - smbc_getxattr_fn getxattr_fn; - smbc_removexattr_fn removexattr_fn; - smbc_listxattr_fn listxattr_fn; - } posix_emu; + smbc_close_fn close_fn _DEPRECATED_; + smbc_opendir_fn opendir _DEPRECATED_; + smbc_closedir_fn closedir _DEPRECATED_; + smbc_readdir_fn readdir _DEPRECATED_; + smbc_getdents_fn getdents _DEPRECATED_; + smbc_mkdir_fn mkdir _DEPRECATED_; + smbc_rmdir_fn rmdir _DEPRECATED_; + smbc_telldir_fn telldir _DEPRECATED_; + smbc_lseekdir_fn lseekdir _DEPRECATED_; + smbc_fstatdir_fn fstatdir _DEPRECATED_; + smbc_chmod_fn chmod _DEPRECATED_; + smbc_utimes_fn utimes _DEPRECATED_; + smbc_setxattr_fn setxattr _DEPRECATED_; + smbc_getxattr_fn getxattr _DEPRECATED_; + smbc_removexattr_fn removexattr _DEPRECATED_; + smbc_listxattr_fn listxattr _DEPRECATED_; /* Printing-related functions */ - struct - { - smbc_print_file_fn print_file_fn; - smbc_open_print_job_fn open_print_job_fn; - smbc_list_print_jobs_fn list_print_jobs_fn; - smbc_unlink_print_job_fn unlink_print_job_fn; - } printing; + smbc_print_file_fn print_file _DEPRECATED_; + smbc_open_print_job_fn open_print_job _DEPRECATED_; + smbc_list_print_jobs_fn list_print_jobs _DEPRECATED_; + smbc_unlink_print_job_fn unlink_print_job _DEPRECATED_; /* ** Callbacks - * These callbacks _always_ have to be initialized because they will - * not be checked at dereference for increased speed. + * + * DEPRECATED: + * + * See the comment above each field, for the getter and setter + * functions that should now be used. */ - struct + struct _smbc_callbacks { /** * authentication function callback: called upon auth requests * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() */ - smbc_get_auth_data_fn get_auth_data_fn; + smbc_get_auth_data_fn auth_fn _DEPRECATED_; /** * check if a server is still good * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionCheckServer(), * smbc_setFunctionCheckServer() */ - smbc_check_server_fn check_server_fn; + smbc_check_server_fn check_server_fn _DEPRECATED_; /** * remove a server if unused * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionRemoveUnusedServer(), * smbc_setFunctionCheckServer() */ - smbc_remove_unused_server_fn remove_unused_server_fn; - } server; + smbc_remove_unused_server_fn remove_unused_server_fn _DEPRECATED_; - struct - { /** Cache subsystem * * For an example cache system see @@ -2728,53 +2726,53 @@ struct _SMBCCTX { /** * server cache addition * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionAddCachedServer(), * smbc_setFunctionAddCachedServer() */ - smbc_add_cached_srv_fn add_cached_server_fn; + smbc_add_cached_srv_fn add_cached_srv_fn _DEPRECATED_; /** * server cache lookup * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionGetCachedServer(), * smbc_setFunctionGetCachedServer() */ - smbc_get_cached_srv_fn get_cached_server_fn; + smbc_get_cached_srv_fn get_cached_srv_fn _DEPRECATED_; /** * server cache removal * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionRemoveCachedServer(), * smbc_setFunctionRemoveCachedServer() */ - smbc_remove_cached_srv_fn remove_cached_server_fn; + smbc_remove_cached_srv_fn remove_cached_srv_fn _DEPRECATED_; /** * server cache purging, try to remove all cached servers * (disconnect) * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionPurgeCachedServers(), * smbc_setFunctionPurgeCachedServers() */ - smbc_purge_cached_srv_fn purge_cached_servers_fn; + smbc_purge_cached_fn purge_cached_fn _DEPRECATED_; + } callbacks; - /** - * Space to store private data of the server cache. - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getServerCacheData(), smbc_setServerCacheData() - */ - struct smbc_server_cache * server_cache_data; - } cache; + /** + * Space where the private data of the server cache used to be + * + * DEPRECATED: + * Use smbc_getServerCacheData(), smbc_setServerCacheData() + */ + void * reserved; /* space where server_cache_data used to be */ /* * Very old configuration options. * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use one of the following functions instead: * smbc_setOptionUseKerberos() * smbc_getOptionUseKerberos() @@ -2783,24 +2781,21 @@ struct _SMBCCTX { * smbc_setOptionNoAutoAnonymousLogin() * smbc_getOptionNoAutoAnonymousLogin() */ - struct - { - int bits; - } flags; + int flags _DEPRECATED_; - /** user options selections that apply to this session - * - * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. + /** + * user options selections that apply to this session * - * NEW OPTIONS ARE NOT ADDED HERE! + * NEW OPTIONS ARE NOT ADDED HERE! * - * To set and retrieve options, use the smbc_setOption*() and - * smbc_getOption*() functions. + * DEPRECATED: + * To set and retrieve options, use the smbc_setOption*() and + * smbc_getOption*() functions. */ struct _smbc_options { - int browse_max_lmb_count; - int urlencode_readdir_entries; - int one_share_per_server; + int browse_max_lmb_count _DEPRECATED_; + int urlencode_readdir_entries _DEPRECATED_; + int one_share_per_server _DEPRECATED_; } options; /** INTERNAL DATA diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c index c45aba4544..bfacea368d 100644 --- a/source3/libsmb/libsmb_cache.c +++ b/source3/libsmb/libsmb_cache.c @@ -88,7 +88,7 @@ SMBC_add_cached_server(SMBCCTX * context, goto failed; } - DLIST_ADD((context->cache.server_cache_data), srvcache); + DLIST_ADD(context->internal->server_cache, srvcache); return 0; failed: @@ -118,7 +118,7 @@ SMBC_get_cached_server(SMBCCTX * context, struct smbc_server_cache * srv = NULL; /* Search the cache lines */ - for (srv = context->cache.server_cache_data; srv; srv = srv->next) { + for (srv = context->internal->server_cache; srv; srv = srv->next) { if (strcmp(server,srv->server_name) == 0 && strcmp(workgroup,srv->workgroup) == 0 && @@ -150,7 +150,7 @@ SMBC_get_cached_server(SMBCCTX * context, * a connection to the server (other than the * attribute server connection) is cool. */ - if (context->options.one_share_per_server) { + if (smbc_getOptionOneSharePerServer(context)) { /* * The currently connected share name * doesn't match the requested share, so @@ -160,7 +160,7 @@ SMBC_get_cached_server(SMBCCTX * context, /* Sigh. Couldn't disconnect. */ cli_shutdown(srv->server->cli); srv->server->cli = NULL; - context->cache.remove_cached_server_fn(context, srv->server); + smbc_getFunctionRemoveCachedServer(context)(context, srv->server); continue; } @@ -175,7 +175,7 @@ SMBC_get_cached_server(SMBCCTX * context, /* Out of memory. */ cli_shutdown(srv->server->cli); srv->server->cli = NULL; - context->cache.remove_cached_server_fn(context, srv->server); + smbc_getFunctionRemoveCachedServer(context)(context, srv->server); continue; } @@ -200,11 +200,11 @@ SMBC_remove_cached_server(SMBCCTX * context, { struct smbc_server_cache * srv = NULL; - for (srv = context->cache.server_cache_data; srv; srv = srv->next) { + for (srv = context->internal->server_cache; srv; srv = srv->next) { if (server == srv->server) { /* remove this sucker */ - DLIST_REMOVE(context->cache.server_cache_data, srv); + DLIST_REMOVE(context->internal->server_cache, srv); SAFE_FREE(srv->server_name); SAFE_FREE(srv->share_name); SAFE_FREE(srv->workgroup); @@ -229,7 +229,7 @@ SMBC_purge_cached_servers(SMBCCTX * context) struct smbc_server_cache * next; int could_not_purge_all = 0; - for (srv = context->cache.server_cache_data, + for (srv = context->internal->server_cache, next = (srv ? srv->next :NULL); srv; srv = next, diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index c107ab2220..c04f751696 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -46,11 +46,6 @@ smbc_new_context(void) * All newly added context fields should be placed in * SMBC_internal_data, not directly in SMBCCTX. */ -#undef OLD -#define OLD(field) context->field -#undef NEW -#define NEW(field) context->internal->field - context = SMB_MALLOC_P(SMBCCTX); if (!context) { errno = ENOMEM; @@ -69,61 +64,59 @@ smbc_new_context(void) /* Initialize the context and establish reasonable defaults */ ZERO_STRUCTP(context->internal); - OLD(config.debug) = 0; - OLD(config.timeout) = 20000; /* 20 seconds */ - - NEW(full_time_names) = False; - NEW(share_mode) = SMBC_SHAREMODE_DENY_NONE; - NEW(smb_encryption_level) = 0; - OLD(options.browse_max_lmb_count) = 3; /* # LMBs to query */ - OLD(options.urlencode_readdir_entries) = False; - OLD(options.one_share_per_server) = False; - - OLD(server.get_auth_data_fn) = SMBC_get_auth_data; - OLD(server.check_server_fn) = SMBC_check_server; - OLD(server.remove_unused_server_fn) = SMBC_remove_unused_server; - - OLD(cache.server_cache_data) = NULL; - OLD(cache.add_cached_server_fn) = SMBC_add_cached_server; - OLD(cache.get_cached_server_fn) = SMBC_get_cached_server; - OLD(cache.remove_cached_server_fn) = SMBC_remove_cached_server; - OLD(cache.purge_cached_servers_fn) = SMBC_purge_cached_servers; - - OLD(posix_emu.open_fn) = SMBC_open_ctx; - OLD(posix_emu.creat_fn) = SMBC_creat_ctx; - OLD(posix_emu.read_fn) = SMBC_read_ctx; - OLD(posix_emu.write_fn) = SMBC_write_ctx; - OLD(posix_emu.close_fn) = SMBC_close_ctx; - OLD(posix_emu.unlink_fn) = SMBC_unlink_ctx; - OLD(posix_emu.rename_fn) = SMBC_rename_ctx; - OLD(posix_emu.lseek_fn) = SMBC_lseek_ctx; - NEW(posix_emu.ftruncate_fn) = SMBC_ftruncate_ctx; - OLD(posix_emu.stat_fn) = SMBC_stat_ctx; - OLD(posix_emu.fstat_fn) = SMBC_fstat_ctx; - OLD(posix_emu.opendir_fn) = SMBC_opendir_ctx; - OLD(posix_emu.closedir_fn) = SMBC_closedir_ctx; - OLD(posix_emu.readdir_fn) = SMBC_readdir_ctx; - OLD(posix_emu.getdents_fn) = SMBC_getdents_ctx; - OLD(posix_emu.mkdir_fn) = SMBC_mkdir_ctx; - OLD(posix_emu.rmdir_fn) = SMBC_rmdir_ctx; - OLD(posix_emu.telldir_fn) = SMBC_telldir_ctx; - OLD(posix_emu.lseekdir_fn) = SMBC_lseekdir_ctx; - OLD(posix_emu.fstatdir_fn) = SMBC_fstatdir_ctx; - OLD(posix_emu.chmod_fn) = SMBC_chmod_ctx; - OLD(posix_emu.utimes_fn) = SMBC_utimes_ctx; - OLD(posix_emu.setxattr_fn) = SMBC_setxattr_ctx; - OLD(posix_emu.getxattr_fn) = SMBC_getxattr_ctx; - OLD(posix_emu.removexattr_fn) = SMBC_removexattr_ctx; - OLD(posix_emu.listxattr_fn) = SMBC_listxattr_ctx; - - OLD(printing.open_print_job_fn) = SMBC_open_print_job_ctx; - OLD(printing.print_file_fn) = SMBC_print_file_ctx; - OLD(printing.list_print_jobs_fn) = SMBC_list_print_jobs_ctx; - OLD(printing.unlink_print_job_fn) = SMBC_unlink_print_job_ctx; + smbc_setDebug(context, 0); + smbc_setTimeout(context, 20000); + + smbc_setOptionFullTimeNames(context, False); + smbc_setOptionOpenShareMode(context, SMBC_SHAREMODE_DENY_NONE); + smbc_setOptionSmbEncryptionLevel(context, SMBC_ENCRYPTLEVEL_NONE); + smbc_setOptionBrowseMaxLmbCount(context, 3); /* # LMBs to query */ + smbc_setOptionUrlEncodeReaddirEntries(context, False); + smbc_setOptionOneSharePerServer(context, False); + + smbc_setFunctionAuthData(context, SMBC_get_auth_data); + smbc_setFunctionCheckServer(context, SMBC_check_server); + smbc_setFunctionRemoveUnusedServer(context, SMBC_remove_unused_server); + + smbc_setOptionUserData(context, NULL); + smbc_setFunctionAddCachedServer(context, SMBC_add_cached_server); + smbc_setFunctionGetCachedServer(context, SMBC_get_cached_server); + smbc_setFunctionRemoveCachedServer(context, SMBC_remove_cached_server); + smbc_setFunctionPurgeCachedServers(context, SMBC_purge_cached_servers); + + smbc_setFunctionOpen(context, SMBC_open_ctx); + smbc_setFunctionCreat(context, SMBC_creat_ctx); + smbc_setFunctionRead(context, SMBC_read_ctx); + smbc_setFunctionWrite(context, SMBC_write_ctx); + smbc_setFunctionClose(context, SMBC_close_ctx); + smbc_setFunctionUnlink(context, SMBC_unlink_ctx); + smbc_setFunctionRename(context, SMBC_rename_ctx); + smbc_setFunctionLseek(context, SMBC_lseek_ctx); + smbc_setFunctionFtruncate(context, SMBC_ftruncate_ctx); + smbc_setFunctionStat(context, SMBC_stat_ctx); + smbc_setFunctionFstat(context, SMBC_fstat_ctx); + smbc_setFunctionOpendir(context, SMBC_opendir_ctx); + smbc_setFunctionClosedir(context, SMBC_closedir_ctx); + smbc_setFunctionReaddir(context, SMBC_readdir_ctx); + smbc_setFunctionGetdents(context, SMBC_getdents_ctx); + smbc_setFunctionMkdir(context, SMBC_mkdir_ctx); + smbc_setFunctionRmdir(context, SMBC_rmdir_ctx); + smbc_setFunctionTelldir(context, SMBC_telldir_ctx); + smbc_setFunctionLseekdir(context, SMBC_lseekdir_ctx); + smbc_setFunctionFstatdir(context, SMBC_fstatdir_ctx); + smbc_setFunctionChmod(context, SMBC_chmod_ctx); + smbc_setFunctionUtimes(context, SMBC_utimes_ctx); + smbc_setFunctionSetxattr(context, SMBC_setxattr_ctx); + smbc_setFunctionGetxattr(context, SMBC_getxattr_ctx); + smbc_setFunctionRemovexattr(context, SMBC_removexattr_ctx); + smbc_setFunctionListxattr(context, SMBC_listxattr_ctx); + + smbc_setFunctionOpenPrintJob(context, SMBC_open_print_job_ctx); + smbc_setFunctionPrintFile(context, SMBC_print_file_ctx); + smbc_setFunctionListPrintJobs(context, SMBC_list_print_jobs_ctx); + smbc_setFunctionUnlinkPrintJob(context, SMBC_unlink_print_job_ctx); return context; -#undef OLD -#undef NEW } /* @@ -148,13 +141,13 @@ smbc_free_context(SMBCCTX *context, f = context->internal->files; while (f) { - (context->posix_emu.close_fn)(context, f); + smbc_getFunctionClose(context)(context, f); f = f->next; } context->internal->files = NULL; /* First try to remove the servers the nice way. */ - if (context->cache.purge_cached_servers_fn(context)) { + if (smbc_getFunctionPurgeCachedServers(context)(context)) { SMBCSRV * s; SMBCSRV * next; DEBUG(1, ("Could not purge all servers, " @@ -164,7 +157,7 @@ smbc_free_context(SMBCCTX *context, DEBUG(1, ("Forced shutdown: %p (fd=%d)\n", s, s->cli->fd)); cli_shutdown(s->cli); - (context->cache.remove_cached_server_fn)(context, + smbc_getFunctionRemoveCachedServer(context)(context, s); next = s->next; DLIST_REMOVE(context->internal->servers, s); @@ -176,7 +169,7 @@ smbc_free_context(SMBCCTX *context, } else { /* This is the polite way */ - if ((context->cache.purge_cached_servers_fn)(context)) { + if (smbc_getFunctionPurgeCachedServers(context)(context)) { DEBUG(1, ("Could not purge all servers, " "free_context failed.\n")); errno = EBUSY; @@ -197,9 +190,14 @@ smbc_free_context(SMBCCTX *context, } /* Things we have to clean up */ - SAFE_FREE(context->config.workgroup); - SAFE_FREE(context->config.netbios_name); - SAFE_FREE(context->config.user); + free(smbc_getWorkgroup(context)); + smbc_setWorkgroup(context, NULL); + + free(smbc_getNetbiosName(context)); + smbc_setNetbiosName(context, NULL); + + free(smbc_getUser(context)); + smbc_setUser(context, NULL); DEBUG(3, ("Context %p successfully freed\n", context)); SAFE_FREE(context); @@ -298,8 +296,6 @@ void * smbc_option_get(SMBCCTX *context, char *option_name) { - int bits; - if (strcmp(option_name, "debug_stderr") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) return (void *) (intptr_t) smbc_getOptionDebugToStderr(context); @@ -376,7 +372,6 @@ smbc_option_get(SMBCCTX *context, #endif } else if (strcmp(option_name, "use_kerberos") == 0) { - bits = context->flags.bits; #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) return (void *) (intptr_t) smbc_getOptionUseKerberos(context); #else @@ -427,9 +422,9 @@ smbc_init_context(SMBCCTX *context) return NULL; } - if (!context->server.get_auth_data_fn || - context->config.debug < 0 || - context->config.debug > 100) { + if (!smbc_getFunctionAuthData(context) || + smbc_getDebug(context) < 0 || + smbc_getDebug(context) > 100) { errno = EINVAL; return NULL; @@ -444,9 +439,6 @@ smbc_init_context(SMBCCTX *context) bool conf_loaded = False; TALLOC_CTX *frame = talloc_stackframe(); - /* Set this to what the user wants */ - DEBUGLEVEL = context->config.debug; - load_case_tables(); setup_logging("libsmbclient", True); @@ -521,58 +513,84 @@ smbc_init_context(SMBCCTX *context) TALLOC_FREE(frame); } - if (!context->config.user) { + if (!smbc_getUser(context)) { /* * FIXME: Is this the best way to get the user info? */ user = getenv("USER"); /* walk around as "guest" if no username can be found */ - if (!user) context->config.user = SMB_STRDUP("guest"); - else context->config.user = SMB_STRDUP(user); + if (!user) { + user = SMB_STRDUP("guest"); + } else { + user = SMB_STRDUP(user); + } + + if (!user) { + errno = ENOMEM; + return NULL; + } + + smbc_setUser(context, user); } - if (!context->config.netbios_name) { + if (!smbc_getNetbiosName(context)) { /* * We try to get our netbios name from the config. If that * fails we fall back on constructing our netbios name from * our hostname etc */ + char *netbios_name; if (global_myname()) { - context->config.netbios_name = SMB_STRDUP(global_myname()); - } - else { + netbios_name = SMB_STRDUP(global_myname()); + } else { /* * Hmmm, I want to get hostname as well, but I am too * lazy for the moment */ pid = sys_getpid(); - context->config.netbios_name = (char *)SMB_MALLOC(17); - if (!context->config.netbios_name) { + netbios_name = (char *)SMB_MALLOC(17); + if (!netbios_name) { errno = ENOMEM; return NULL; } - slprintf(context->config.netbios_name, 16, - "smbc%s%d", context->config.user, pid); + slprintf(netbios_name, 16, + "smbc%s%d", smbc_getUser(context), pid); } + + if (!netbios_name) { + errno = ENOMEM; + return NULL; + } + + smbc_setNetbiosName(context, netbios_name); } - DEBUG(1, ("Using netbios name %s.\n", context->config.netbios_name)); + DEBUG(1, ("Using netbios name %s.\n", smbc_getNetbiosName(context))); - if (!context->config.workgroup) { + if (!smbc_getWorkgroup(context)) { + char *workgroup; + if (lp_workgroup()) { - context->config.workgroup = SMB_STRDUP(lp_workgroup()); + workgroup = SMB_STRDUP(lp_workgroup()); } else { /* TODO: Think about a decent default workgroup */ - context->config.workgroup = SMB_STRDUP("samba"); + workgroup = SMB_STRDUP("samba"); } + + if (!workgroup) { + errno = ENOMEM; + return NULL; + } + + smbc_setWorkgroup(context, workgroup); } - DEBUG(1, ("Using workgroup %s.\n", context->config.workgroup)); + DEBUG(1, ("Using workgroup %s.\n", smbc_getWorkgroup(context))); /* shortest timeout is 1 second */ - if (context->config.timeout > 0 && context->config.timeout < 1000) - context->config.timeout = 1000; + if (smbc_getTimeout(context) > 0 && smbc_getTimeout(context) < 1000) + smbc_setTimeout(context, 1000); /* * FIXME: Should we check the function pointers here? @@ -592,879 +610,3 @@ smbc_version(void) } -/** Get the netbios name used for making connections */ -char * -smbc_getNetbiosName(SMBCCTX *c) -{ - return c->config.netbios_name; -} - -/** Set the netbios name used for making connections */ -void -smbc_setNetbiosName(SMBCCTX *c, char * netbios_name) -{ - c->config.netbios_name = netbios_name; -} - -/** Get the workgroup used for making connections */ -char * -smbc_getWorkgroup(SMBCCTX *c) -{ - return c->config.workgroup; -} - -/** Set the workgroup used for making connections */ -void -smbc_setWorkgroup(SMBCCTX *c, char * workgroup) -{ - c->config.workgroup = workgroup; -} - -/** Get the username used for making connections */ -char * -smbc_getUser(SMBCCTX *c) -{ - return c->config.user; -} - -/** Set the username used for making connections */ -void -smbc_setUser(SMBCCTX *c, char * user) -{ - c->config.user = user; -} - -/** Get the debug level */ -int -smbc_getDebug(SMBCCTX *c) -{ - return c->config.debug; -} - -/** Set the debug level */ -void -smbc_setDebug(SMBCCTX *c, int debug) -{ - c->config.debug = debug; -} - -/** - * Get the timeout used for waiting on connections and response data - * (in milliseconds) - */ -int -smbc_getTimeout(SMBCCTX *c) -{ - return c->config.timeout; -} - -/** - * Set the timeout used for waiting on connections and response data - * (in milliseconds) - */ -void -smbc_setTimeout(SMBCCTX *c, int timeout) -{ - c->config.timeout = timeout; -} - -/** Get whether to log to standard error instead of standard output */ -smbc_bool -smbc_getOptionDebugToStderr(SMBCCTX *c) -{ - return c->internal->debug_stderr; -} - -/** Set whether to log to standard error instead of standard output */ -void -smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b) -{ - c->internal->debug_stderr = b; -} - -/** - * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather - * than the old-style names such as M_TIME. This allows also setting/getting - * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME - * was supposed to be CHANGE_TIME but was confused and sometimes referred to - * CREATE_TIME.) - */ -smbc_bool -smbc_getOptionFullTimeNames(SMBCCTX *c) -{ - return c->internal->full_time_names; -} - -/** - * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather - * than the old-style names such as M_TIME. This allows also setting/getting - * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME - * was supposed to be CHANGE_TIME but was confused and sometimes referred to - * CREATE_TIME.) - */ -void -smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b) -{ - c->internal->full_time_names = b; -} - -/** - * Get the share mode to use for files opened with SMBC_open_ctx(). The - * default is SMBC_SHAREMODE_DENY_NONE. - */ -smbc_share_mode -smbc_getOptionOpenShareMode(SMBCCTX *c) -{ - return c->internal->share_mode; -} - -/** - * Set the share mode to use for files opened with SMBC_open_ctx(). The - * default is SMBC_SHAREMODE_DENY_NONE. - */ -void -smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode) -{ - c->internal->share_mode = share_mode; -} - -/** Retrieve a previously set user data handle */ -void * -smbc_getOptionUserData(SMBCCTX *c) -{ - return c->internal->user_data; -} - -/** Save a user data handle */ -void -smbc_setOptionUserData(SMBCCTX *c, void *user_data) -{ - c->internal->user_data = user_data; -} - -/** Get the encoded value for encryption level. */ -smbc_smb_encrypt_level -smbc_getOptionSmbEncryptionLevel(SMBCCTX *c) -{ - return c->internal->smb_encryption_level; -} - -/** Set the encoded value for encryption level. */ -void -smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level) -{ - c->internal->smb_encryption_level = level; -} - -/** - * Get from how many local master browsers should the list of workgroups be - * retrieved. It can take up to 12 minutes or longer after a server becomes a - * local master browser, for it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client never knows - * which local master browser will be found first, the one which is found - * first and used to retrieve a browse list may have an incomplete or empty - * browse list. By requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small networks (few - * workgroups), it is recommended that this value be set to 0, causing the - * browse lists from all found local master browsers to be retrieved and - * merged. For networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ -int -smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c) -{ - return c->options.browse_max_lmb_count; -} - -/** - * Set from how many local master browsers should the list of workgroups be - * retrieved. It can take up to 12 minutes or longer after a server becomes a - * local master browser, for it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client never knows - * which local master browser will be found first, the one which is found - * first and used to retrieve a browse list may have an incomplete or empty - * browse list. By requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small networks (few - * workgroups), it is recommended that this value be set to 0, causing the - * browse lists from all found local master browsers to be retrieved and - * merged. For networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ -void -smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count) -{ - c->options.browse_max_lmb_count = count; -} - -/** - * Get whether to url-encode readdir entries. - * - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ -smbc_bool -smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c) -{ - return c->options.urlencode_readdir_entries; -} - -/** - * Set whether to url-encode readdir entries. - * - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ -void -smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b) -{ - c->options.urlencode_readdir_entries = b; -} - -/** - * Get whether to use the same connection for all shares on a server. - * - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ -smbc_bool -smbc_getOptionOneSharePerServer(SMBCCTX *c) -{ - return c->options.one_share_per_server; -} - -/** - * Set whether to use the same connection for all shares on a server. - * - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ -void -smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b) -{ - c->options.one_share_per_server = b; -} - -/** Get whether to enable use of kerberos */ -smbc_bool -smbc_getOptionUseKerberos(SMBCCTX *c) -{ - return c->flags.bits & SMB_CTX_FLAG_USE_KERBEROS ? True : False; -} - -/** Set whether to enable use of kerberos */ -void -smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b) -{ - if (b) { - c->flags.bits |= SMB_CTX_FLAG_USE_KERBEROS; - } else { - c->flags.bits &= ~SMB_CTX_FLAG_USE_KERBEROS; - } -} - -/** Get whether to fallback after kerberos */ -smbc_bool -smbc_getOptionFallbackAfterKerberos(SMBCCTX *c) -{ - return c->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS ? True : False; -} - -/** Set whether to fallback after kerberos */ -void -smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b) -{ - if (b) { - c->flags.bits |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; - } else { - c->flags.bits &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; - } -} - -/** Get whether to automatically select anonymous login */ -smbc_bool -smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c) -{ - return c->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON ? True : False; -} - -/** Set whether to automatically select anonymous login */ -void -smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b) -{ - if (b) { - c->flags.bits |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; - } else { - c->flags.bits &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; - } -} - -/** Get the function for obtaining authentication data */ -smbc_get_auth_data_fn -smbc_getFunctionAuthData(SMBCCTX *c) -{ - return c->server.get_auth_data_fn; -} - -/** Set the function for obtaining authentication data */ -void -smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn) -{ - c->internal->auth_fn_with_context = NULL; - c->server.get_auth_data_fn = fn; -} - -/** Get the new-style authentication function which includes the context. */ -smbc_get_auth_data_with_context_fn -smbc_getFunctionAuthDataWithContext(SMBCCTX *c) -{ - return c->internal->auth_fn_with_context; -} - -/** Set the new-style authentication function which includes the context. */ -void -smbc_setFunctionAuthDataWithContext(SMBCCTX *c, - smbc_get_auth_data_with_context_fn fn) -{ - c->server.get_auth_data_fn = NULL; - c->internal->auth_fn_with_context = fn; -} - -/** Get the function for checking if a server is still good */ -smbc_check_server_fn -smbc_getFunctionCheckServer(SMBCCTX *c) -{ - return c->server.check_server_fn; -} - -/** Set the function for checking if a server is still good */ -void -smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn) -{ - c->server.check_server_fn = fn; -} - -/** Get the function for removing a server if unused */ -smbc_remove_unused_server_fn -smbc_getFunctionRemoveUnusedServer(SMBCCTX *c) -{ - return c->server.remove_unused_server_fn; -} - -/** Set the function for removing a server if unused */ -void -smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, - smbc_remove_unused_server_fn fn) -{ - c->server.remove_unused_server_fn = fn; -} - -/** Get the function to store private data of the server cache */ -struct -smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c) -{ - return c->cache.server_cache_data; -} - -/** Set the function to store private data of the server cache */ -void -smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache) -{ - c->cache.server_cache_data = cache; -} - - -/** Get the function for adding a cached server */ -smbc_add_cached_srv_fn -smbc_getFunctionAddCachedServer(SMBCCTX *c) -{ - return c->cache.add_cached_server_fn; -} - -/** Set the function for adding a cached server */ -void -smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn) -{ - c->cache.add_cached_server_fn = fn; -} - -/** Get the function for server cache lookup */ -smbc_get_cached_srv_fn -smbc_getFunctionGetCachedServer(SMBCCTX *c) -{ - return c->cache.get_cached_server_fn; -} - -/** Set the function for server cache lookup */ -void -smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn) -{ - c->cache.get_cached_server_fn = fn; -} - -/** Get the function for server cache removal */ -smbc_remove_cached_srv_fn -smbc_getFunctionRemoveCachedServer(SMBCCTX *c) -{ - return c->cache.remove_cached_server_fn; -} - -/** Set the function for server cache removal */ -void -smbc_setFunctionRemoveCachedServer(SMBCCTX *c, - smbc_remove_cached_srv_fn fn) -{ - c->cache.remove_cached_server_fn = fn; -} - -/** - * Get the function for server cache purging. This function tries to - * remove all cached servers (e.g. on disconnect) - */ -smbc_purge_cached_srv_fn -smbc_getFunctionPurgeCachedServers(SMBCCTX *c) -{ - return c->cache.purge_cached_servers_fn; -} - -/** - * Set the function for server cache purging. This function tries to - * remove all cached servers (e.g. on disconnect) - */ -void -smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_srv_fn fn) -{ - c->cache.purge_cached_servers_fn = fn; -} - -/** - * Callable functions for files. - */ - -smbc_open_fn -smbc_getFunctionOpen(SMBCCTX *c) -{ - return c->posix_emu.open_fn; -} - -void -smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn) -{ - c->posix_emu.open_fn = fn; -} - -smbc_creat_fn -smbc_getFunctionCreat(SMBCCTX *c) -{ - return c->posix_emu.creat_fn; -} - -void -smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn fn) -{ - c->posix_emu.creat_fn = fn; -} - -smbc_read_fn -smbc_getFunctionRead(SMBCCTX *c) -{ - return c->posix_emu.read_fn; -} - -void -smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn) -{ - c->posix_emu.read_fn = fn; -} - -smbc_write_fn -smbc_getFunctionWrite(SMBCCTX *c) -{ - return c->posix_emu.write_fn; -} - -void -smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn) -{ - c->posix_emu.write_fn = fn; -} - -smbc_unlink_fn -smbc_getFunctionUnlink(SMBCCTX *c) -{ - return c->posix_emu.unlink_fn; -} - -void -smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn) -{ - c->posix_emu.unlink_fn = fn; -} - -smbc_rename_fn -smbc_getFunctionRename(SMBCCTX *c) -{ - return c->posix_emu.rename_fn; -} - -void -smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn) -{ - c->posix_emu.rename_fn = fn; -} - -smbc_lseek_fn -smbc_getFunctionLseek(SMBCCTX *c) -{ - return c->posix_emu.lseek_fn; -} - -void -smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn) -{ - c->posix_emu.lseek_fn = fn; -} - -smbc_stat_fn -smbc_getFunctionStat(SMBCCTX *c) -{ - return c->posix_emu.stat_fn; -} - -void -smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn) -{ - c->posix_emu.stat_fn = fn; -} - -smbc_fstat_fn -smbc_getFunctionFstat(SMBCCTX *c) -{ - return c->posix_emu.fstat_fn; -} - -void -smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn) -{ - c->posix_emu.fstat_fn = fn; -} - -smbc_ftruncate_fn -smbc_getFunctionFtruncate(SMBCCTX *c) -{ - return c->internal->posix_emu.ftruncate_fn; -} - -void -smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn) -{ - c->internal->posix_emu.ftruncate_fn = fn; -} - -smbc_close_fn -smbc_getFunctionClose(SMBCCTX *c) -{ - return c->posix_emu.close_fn; -} - -void -smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn) -{ - c->posix_emu.close_fn = fn; -} - - -/** - * Callable functions for directories. - */ - -smbc_opendir_fn -smbc_getFunctionOpendir(SMBCCTX *c) -{ - return c->posix_emu.opendir_fn; -} - -void -smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn) -{ - c->posix_emu.opendir_fn = fn; -} - -smbc_closedir_fn -smbc_getFunctionClosedir(SMBCCTX *c) -{ - return c->posix_emu.closedir_fn; -} - -void -smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn) -{ - c->posix_emu.closedir_fn = fn; -} - -smbc_readdir_fn -smbc_getFunctionReaddir(SMBCCTX *c) -{ - return c->posix_emu.readdir_fn; -} - -void -smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn) -{ - c->posix_emu.readdir_fn = fn; -} - -smbc_getdents_fn -smbc_getFunctionGetdents(SMBCCTX *c) -{ - return c->posix_emu.getdents_fn; -} - -void -smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn) -{ - c->posix_emu.getdents_fn = fn; -} - -smbc_mkdir_fn -smbc_getFunctionMkdir(SMBCCTX *c) -{ - return c->posix_emu.mkdir_fn; -} - -void -smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn) -{ - c->posix_emu.mkdir_fn = fn; -} - -smbc_rmdir_fn -smbc_getFunctionRmdir(SMBCCTX *c) -{ - return c->posix_emu.rmdir_fn; -} - -void -smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn) -{ - c->posix_emu.rmdir_fn = fn; -} - -smbc_telldir_fn -smbc_getFunctionTelldir(SMBCCTX *c) -{ - return c->posix_emu.telldir_fn; -} - -void -smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn) -{ - c->posix_emu.telldir_fn = fn; -} - -smbc_lseekdir_fn -smbc_getFunctionLseekdir(SMBCCTX *c) -{ - return c->posix_emu.lseekdir_fn; -} - -void -smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn) -{ - c->posix_emu.lseekdir_fn = fn; -} - -smbc_fstatdir_fn -smbc_getFunctionFstatdir(SMBCCTX *c) -{ - return c->posix_emu.fstatdir_fn; -} - -void -smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn) -{ - c->posix_emu.fstatdir_fn = fn; -} - - -/** - * Callable functions applicable to both files and directories. - */ - -smbc_chmod_fn -smbc_getFunctionChmod(SMBCCTX *c) -{ - return c->posix_emu.chmod_fn; -} - -void -smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn) -{ - c->posix_emu.chmod_fn = fn; -} - -smbc_utimes_fn -smbc_getFunctionUtimes(SMBCCTX *c) -{ - return c->posix_emu.utimes_fn; -} - -void -smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn) -{ - c->posix_emu.utimes_fn = fn; -} - -smbc_setxattr_fn -smbc_getFunctionSetxattr(SMBCCTX *c) -{ - return c->posix_emu.setxattr_fn; -} - -void -smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn) -{ - c->posix_emu.setxattr_fn = fn; -} - -smbc_getxattr_fn -smbc_getFunctionGetxattr(SMBCCTX *c) -{ - return c->posix_emu.getxattr_fn; -} - -void -smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn) -{ - c->posix_emu.getxattr_fn = fn; -} - -smbc_removexattr_fn -smbc_getFunctionRemovexattr(SMBCCTX *c) -{ - return c->posix_emu.removexattr_fn; -} - -void -smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn) -{ - c->posix_emu.removexattr_fn = fn; -} - -smbc_listxattr_fn -smbc_getFunctionListxattr(SMBCCTX *c) -{ - return c->posix_emu.listxattr_fn; -} - -void -smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn) -{ - c->posix_emu.listxattr_fn = fn; -} - - -/** - * Callable functions related to printing - */ - -smbc_print_file_fn -smbc_getFunctionPrintFile(SMBCCTX *c) -{ - return c->printing.print_file_fn; -} - -void -smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn) -{ - c->printing.print_file_fn = fn; -} - -smbc_open_print_job_fn -smbc_getFunctionOpenPrintJob(SMBCCTX *c) -{ - return c->printing.open_print_job_fn; -} - -void -smbc_setFunctionOpenPrintJob(SMBCCTX *c, - smbc_open_print_job_fn fn) -{ - c->printing.open_print_job_fn = fn; -} - -smbc_list_print_jobs_fn -smbc_getFunctionListPrintJobs(SMBCCTX *c) -{ - return c->printing.list_print_jobs_fn; -} - -void -smbc_setFunctionListPrintJobs(SMBCCTX *c, - smbc_list_print_jobs_fn fn) -{ - c->printing.list_print_jobs_fn = fn; -} - -smbc_unlink_print_job_fn -smbc_getFunctionUnlinkPrintJob(SMBCCTX *c) -{ - return c->printing.unlink_print_job_fn; -} - -void -smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, - smbc_unlink_print_job_fn fn) -{ - c->printing.unlink_print_job_fn = fn; -} - diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 2ece2ab8ed..1486097d51 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -404,7 +404,7 @@ SMBC_opendir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -450,9 +450,9 @@ SMBC_opendir_ctx(SMBCCTX *context, } /* Determine how many local master browsers to query */ - max_lmb_count = (context->options.browse_max_lmb_count == 0 + max_lmb_count = (smbc_getOptionBrowseMaxLmbCount(context) == 0 ? INT_MAX - : context->options.browse_max_lmb_count); + : smbc_getOptionBrowseMaxLmbCount(context)); memset(&u_info, '\0', sizeof(u_info)); u_info.username = talloc_strdup(frame,user); @@ -810,11 +810,11 @@ SMBC_opendir_ctx(SMBCCTX *context, * good any more... */ if (cli_is_error(targetcli) && - (context->server.check_server_fn)(context, srv)) { + smbc_getFunctionCheckServer(context)(context, srv)) { /* ... then remove it. */ - if ((context->server.remove_unused_server_fn)(context, - srv)) { + if (smbc_getFunctionRemoveUnusedServer(context)(context, + srv)) { /* * We could not remove the * server completely, remove @@ -823,7 +823,7 @@ SMBC_opendir_ctx(SMBCCTX *context, * will be removed when the * last file/dir is closed. */ - (context->cache.remove_cached_server_fn)(context, srv); + smbc_getFunctionRemoveCachedServer(context)(context, srv); } } @@ -884,7 +884,7 @@ smbc_readdir_internal(SMBCCTX * context, struct smbc_dirent *src, int max_namebuf_len) { - if (context->options.urlencode_readdir_entries) { + if (smbc_getOptionUrlEncodeReaddirEntries(context)) { /* url-encode the name. get back remaining buffer space */ max_namebuf_len = @@ -1142,7 +1142,7 @@ SMBC_mkdir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1249,7 +1249,7 @@ SMBC_rmdir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1531,7 +1531,7 @@ SMBC_chmod_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1637,7 +1637,7 @@ SMBC_utimes_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1713,7 +1713,7 @@ SMBC_unlink_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1848,7 +1848,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext, } if (!user1 || user1[0] == (char)0) { - user1 = talloc_strdup(frame, ocontext->config.user); + user1 = talloc_strdup(frame, smbc_getUser(ocontext)); if (!user1) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1872,7 +1872,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext, } if (!user2 || user2[0] == (char)0) { - user2 = talloc_strdup(frame, ncontext->config.user); + user2 = talloc_strdup(frame, smbc_getUser(ncontext)); if (!user2) { errno = ENOMEM; TALLOC_FREE(frame); diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 73c9b96978..423450b23e 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -82,7 +82,7 @@ SMBC_open_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -188,7 +188,7 @@ SMBC_open_ctx(SMBCCTX *context, int eno = 0; eno = SMBC_errno(context, srv->cli); - file = (context->posix_emu.opendir_fn)(context, fname); + file = smbc_getFunctionOpendir(context)(context, fname); if (!file) errno = eno; TALLOC_FREE(frame); return file; @@ -439,7 +439,7 @@ SMBC_close_ctx(SMBCCTX *context, /* IS a dir ... */ if (!file->file) { TALLOC_FREE(frame); - return (context->posix_emu.closedir_fn)(context, file); + return smbc_getFunctionClosedir(context)(context, file); } /*d_printf(">>>close: parsing %s\n", file->fname);*/ @@ -478,7 +478,7 @@ SMBC_close_ctx(SMBCCTX *context, DLIST_REMOVE(context->internal->files, file); SAFE_FREE(file->fname); SAFE_FREE(file); - (context->server.remove_unused_server_fn)(context, srv); + smbc_getFunctionRemoveUnusedServer(context)(context, srv); TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c index c962f898e0..2c3a5f8866 100644 --- a/source3/libsmb/libsmb_path.c +++ b/source3/libsmb/libsmb_path.c @@ -253,7 +253,7 @@ SMBC_parse_path(TALLOC_CTX *ctx, */ if (pp_workgroup != NULL) { *pp_workgroup = - talloc_strdup(ctx, context->config.workgroup); + talloc_strdup(ctx, smbc_getWorkgroup(context)); } if (pp_options) { @@ -297,13 +297,13 @@ SMBC_parse_path(TALLOC_CTX *ctx, } if (*p == '/') { - int wl = strlen(context->config.workgroup); + int wl = strlen(smbc_getWorkgroup(context)); if (wl > 16) { wl = 16; } - *pp_server = talloc_strdup(ctx, context->config.workgroup); + *pp_server = talloc_strdup(ctx, smbc_getWorkgroup(context)); if (!*pp_server) { return -1; } diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c index 545225cae4..c8d7ad039d 100644 --- a/source3/libsmb/libsmb_printjob.c +++ b/source3/libsmb/libsmb_printjob.c @@ -75,7 +75,7 @@ SMBC_open_print_job_ctx(SMBCCTX *context, /* What if the path is empty, or the file exists? */ TALLOC_FREE(frame); - return (context->posix_emu.open_fn)(context, fname, O_WRONLY, 666); + return smbc_getFunctionOpen(context)(context, fname, O_WRONLY, 666); } /* @@ -222,7 +222,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -300,7 +300,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 4f51388870..64eb1ea584 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -80,7 +80,7 @@ SMBC_remove_unused_server(SMBCCTX * context, DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv)); - (context->cache.remove_cached_server_fn)(context, srv); + smbc_getFunctionRemoveCachedServer(context)(context, srv); SAFE_FREE(srv); return 0; @@ -106,11 +106,10 @@ SMBC_call_auth_fn(TALLOC_CTX *ctx, strlcpy(username, *pp_username, sizeof(username)); strlcpy(password, *pp_password, sizeof(password)); - (context->server.get_auth_data_fn)( - server, share, - workgroup, sizeof(workgroup), - username, sizeof(username), - password, sizeof(password)); + smbc_getFunctionAuthData(context)(server, share, + workgroup, sizeof(workgroup), + username, sizeof(username), + password, sizeof(password)); TALLOC_FREE(*pp_workgroup); TALLOC_FREE(*pp_username); @@ -147,10 +146,10 @@ SMBC_find_server(TALLOC_CTX *ctx, check_server_cache: - srv = (context->cache.get_cached_server_fn)(context, - server, share, - *pp_workgroup, - *pp_username); + srv = smbc_getFunctionGetCachedServer(context)(context, + server, share, + *pp_workgroup, + *pp_username); if (!auth_called && !srv && (!*pp_username || !(*pp_username)[0] || !*pp_password || !(*pp_password)[0])) { @@ -172,22 +171,22 @@ check_server_cache: } if (srv) { - if ((context->server.check_server_fn)(context, srv)) { + if (smbc_getFunctionCheckServer(context)(context, srv)) { /* * This server is no good anymore * Try to remove it and check for more possible * servers in the cache */ - if ((context->server.remove_unused_server_fn)(context, - srv)) { + if (smbc_getFunctionRemoveUnusedServer(context)(context, + srv)) { /* * We could not remove the server completely, * remove it from the cache so we will not get * it again. It will be removed when the last * file/dir is closed. */ - (context->cache.remove_cached_server_fn)(context, - srv); + smbc_getFunctionRemoveCachedServer(context)(context, + srv); } /* @@ -251,12 +250,14 @@ SMBC_server(TALLOC_CTX *ctx, * If we found a connection and we're only allowed one share per * server... */ - if (srv && *share != '\0' && context->options.one_share_per_server) { + if (srv && + *share != '\0' && + smbc_getOptionOneSharePerServer(context)) { /* * ... then if there's no current connection to the share, * connect to it. SMBC_find_server(), or rather the function - * pointed to by context->cache.get_cached_srv_fn which + * pointed to by context->get_cached_srv_fn which * was called by SMBC_find_server(), will have issued a tree * disconnect if the requested share is not the same as the * one that was already connected. @@ -272,8 +273,8 @@ SMBC_server(TALLOC_CTX *ctx, errno = ENOMEM; cli_shutdown(srv->cli); srv->cli = NULL; - (context->cache.remove_cached_server_fn)(context, - srv); + smbc_getFunctionRemoveCachedServer(context)(context, + srv); return NULL; } @@ -290,8 +291,8 @@ SMBC_server(TALLOC_CTX *ctx, errno = SMBC_errno(context, srv->cli); cli_shutdown(srv->cli); srv->cli = NULL; - (context->cache.remove_cached_server_fn)(context, - srv); + smbc_getFunctionRemoveCachedServer(context)(context, + srv); srv = NULL; } @@ -324,7 +325,7 @@ SMBC_server(TALLOC_CTX *ctx, return NULL; } - make_nmb_name(&calling, context->config.netbios_name, 0x0); + make_nmb_name(&calling, smbc_getNetbiosName(context), 0x0); make_nmb_name(&called , server, 0x20); DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server)); @@ -341,14 +342,15 @@ again: return NULL; } - if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) { + if (smbc_getOptionUseKerberos(context)) { c->use_kerberos = True; } - if (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) { + + if (smbc_getOptionFallbackAfterKerberos(context)) { c->fallback_after_kerberos = True; } - c->timeout = context->config.timeout; + c->timeout = smbc_getTimeout(context); /* * Force use of port 139 for first try if share is $IPC, empty, or @@ -435,8 +437,7 @@ again: /* Failed. Try an anonymous login, if allowed by flags. */ username_used = ""; - if ((context->flags.bits & - SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) || + if (smbc_getOptionNoAutoAnonymousLogin(context) || !NT_STATUS_IS_OK(cli_session_setup(c, username_used, *pp_password, 1, *pp_password, 0, @@ -504,10 +505,10 @@ again: /* now add it to the cache (internal or external) */ /* Let the cache function set errno if it wants to */ errno = 0; - if ((context->cache.add_cached_server_fn)(context, srv, - server, share, - *pp_workgroup, - *pp_username)) { + if (smbc_getFunctionAddCachedServer(context)(context, srv, + server, share, + *pp_workgroup, + *pp_username)) { int saved_errno = errno; DEBUG(3, (" Failed to add server to cache\n")); errno = saved_errno; @@ -576,7 +577,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, } flags = 0; - if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) { + if (smbc_getOptionUseKerberos(context)) { flags |= CLI_FULL_CONNECTION_USE_KERBEROS; } @@ -664,11 +665,11 @@ SMBC_attr_server(TALLOC_CTX *ctx, /* now add it to the cache (internal or external) */ errno = 0; /* let cache function set errno if it likes */ - if ((context->cache.add_cached_server_fn)(context, ipc_srv, - server, - "*IPC$", - *pp_workgroup, - *pp_username)) { + if (smbc_getFunctionAddCachedServer(context)(context, ipc_srv, + server, + "*IPC$", + *pp_workgroup, + *pp_username)) { DEBUG(3, (" Failed to add server to cache\n")); if (errno == 0) { errno = ENOMEM; diff --git a/source3/libsmb/libsmb_setget.c b/source3/libsmb/libsmb_setget.c new file mode 100644 index 0000000000..d0823bd77e --- /dev/null +++ b/source3/libsmb/libsmb_setget.c @@ -0,0 +1,905 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 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 + 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 "includes.h" +#define __LIBSMBCLIENT_INTERNAL__ +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/** Get the netbios name used for making connections */ +char * +smbc_getNetbiosName(SMBCCTX *c) +{ + return c->netbios_name; +} + +/** Set the netbios name used for making connections */ +void +smbc_setNetbiosName(SMBCCTX *c, char * netbios_name) +{ + c->netbios_name = netbios_name; +} + +/** Get the workgroup used for making connections */ +char * +smbc_getWorkgroup(SMBCCTX *c) +{ + return c->workgroup; +} + +/** Set the workgroup used for making connections */ +void +smbc_setWorkgroup(SMBCCTX *c, char * workgroup) +{ + c->workgroup = workgroup; +} + +/** Get the username used for making connections */ +char * +smbc_getUser(SMBCCTX *c) +{ + return c->user; +} + +/** Set the username used for making connections */ +void +smbc_setUser(SMBCCTX *c, char * user) +{ + c->user = user; +} + +/** Get the debug level */ +int +smbc_getDebug(SMBCCTX *c) +{ + return c->debug; +} + +/** Set the debug level */ +void +smbc_setDebug(SMBCCTX *c, int debug) +{ + c->debug = debug; + DEBUGLEVEL = debug; +} + +/** + * Get the timeout used for waiting on connections and response data + * (in milliseconds) + */ +int +smbc_getTimeout(SMBCCTX *c) +{ + return c->timeout; +} + +/** + * Set the timeout used for waiting on connections and response data + * (in milliseconds) + */ +void +smbc_setTimeout(SMBCCTX *c, int timeout) +{ + c->timeout = timeout; +} + +/** Get whether to log to standard error instead of standard output */ +smbc_bool +smbc_getOptionDebugToStderr(SMBCCTX *c) +{ + return c->internal->debug_stderr; +} + +/** Set whether to log to standard error instead of standard output */ +void +smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b) +{ + c->internal->debug_stderr = b; +} + +/** + * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +smbc_bool +smbc_getOptionFullTimeNames(SMBCCTX *c) +{ + return c->internal->full_time_names; +} + +/** + * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +void +smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b) +{ + c->internal->full_time_names = b; +} + +/** + * Get the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +smbc_share_mode +smbc_getOptionOpenShareMode(SMBCCTX *c) +{ + return c->internal->share_mode; +} + +/** + * Set the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +void +smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode) +{ + c->internal->share_mode = share_mode; +} + +/** Retrieve a previously set user data handle */ +void * +smbc_getOptionUserData(SMBCCTX *c) +{ + return c->internal->user_data; +} + +/** Save a user data handle */ +void +smbc_setOptionUserData(SMBCCTX *c, void *user_data) +{ + c->internal->user_data = user_data; +} + +/** Get the encoded value for encryption level. */ +smbc_smb_encrypt_level +smbc_getOptionSmbEncryptionLevel(SMBCCTX *c) +{ + return c->internal->smb_encryption_level; +} + +/** Set the encoded value for encryption level. */ +void +smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level) +{ + c->internal->smb_encryption_level = level; +} + +/** + * Get from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +int +smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c) +{ + return c->options.browse_max_lmb_count; +} + +/** + * Set from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +void +smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count) +{ + c->options.browse_max_lmb_count = count; +} + +/** + * Get whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +smbc_bool +smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c) +{ + return c->options.urlencode_readdir_entries; +} + +/** + * Set whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +void +smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b) +{ + c->options.urlencode_readdir_entries = b; +} + +/** + * Get whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +smbc_bool +smbc_getOptionOneSharePerServer(SMBCCTX *c) +{ + return c->options.one_share_per_server; +} + +/** + * Set whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +void +smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b) +{ + c->options.one_share_per_server = b; +} + +/** Get whether to enable use of kerberos */ +smbc_bool +smbc_getOptionUseKerberos(SMBCCTX *c) +{ + return c->flags & SMB_CTX_FLAG_USE_KERBEROS ? True : False; +} + +/** Set whether to enable use of kerberos */ +void +smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags |= SMB_CTX_FLAG_USE_KERBEROS; + } else { + c->flags &= ~SMB_CTX_FLAG_USE_KERBEROS; + } +} + +/** Get whether to fallback after kerberos */ +smbc_bool +smbc_getOptionFallbackAfterKerberos(SMBCCTX *c) +{ + return c->flags & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS ? True : False; +} + +/** Set whether to fallback after kerberos */ +void +smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + } else { + c->flags &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + } +} + +/** Get whether to automatically select anonymous login */ +smbc_bool +smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c) +{ + return c->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON ? True : False; +} + +/** Set whether to automatically select anonymous login */ +void +smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; + } else { + c->flags &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; + } +} + +/** Get the function for obtaining authentication data */ +smbc_get_auth_data_fn +smbc_getFunctionAuthData(SMBCCTX *c) +{ + return c->callbacks.auth_fn; +} + +/** Set the function for obtaining authentication data */ +void +smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn) +{ + c->internal->auth_fn_with_context = NULL; + c->callbacks.auth_fn = fn; +} + +/** Get the new-style authentication function which includes the context. */ +smbc_get_auth_data_with_context_fn +smbc_getFunctionAuthDataWithContext(SMBCCTX *c) +{ + return c->internal->auth_fn_with_context; +} + +/** Set the new-style authentication function which includes the context. */ +void +smbc_setFunctionAuthDataWithContext(SMBCCTX *c, + smbc_get_auth_data_with_context_fn fn) +{ + c->callbacks.auth_fn = NULL; + c->internal->auth_fn_with_context = fn; +} + +/** Get the function for checking if a server is still good */ +smbc_check_server_fn +smbc_getFunctionCheckServer(SMBCCTX *c) +{ + return c->callbacks.check_server_fn; +} + +/** Set the function for checking if a server is still good */ +void +smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn) +{ + c->callbacks.check_server_fn = fn; +} + +/** Get the function for removing a server if unused */ +smbc_remove_unused_server_fn +smbc_getFunctionRemoveUnusedServer(SMBCCTX *c) +{ + return c->callbacks.remove_unused_server_fn; +} + +/** Set the function for removing a server if unused */ +void +smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, + smbc_remove_unused_server_fn fn) +{ + c->callbacks.remove_unused_server_fn = fn; +} + +/** Get the function for adding a cached server */ +smbc_add_cached_srv_fn +smbc_getFunctionAddCachedServer(SMBCCTX *c) +{ + return c->callbacks.add_cached_srv_fn; +} + +/** Set the function for adding a cached server */ +void +smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn) +{ + c->callbacks.add_cached_srv_fn = fn; +} + +/** Get the function for server cache lookup */ +smbc_get_cached_srv_fn +smbc_getFunctionGetCachedServer(SMBCCTX *c) +{ + return c->callbacks.get_cached_srv_fn; +} + +/** Set the function for server cache lookup */ +void +smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn) +{ + c->callbacks.get_cached_srv_fn = fn; +} + +/** Get the function for server cache removal */ +smbc_remove_cached_srv_fn +smbc_getFunctionRemoveCachedServer(SMBCCTX *c) +{ + return c->callbacks.remove_cached_srv_fn; +} + +/** Set the function for server cache removal */ +void +smbc_setFunctionRemoveCachedServer(SMBCCTX *c, + smbc_remove_cached_srv_fn fn) +{ + c->callbacks.remove_cached_srv_fn = fn; +} + +/** + * Get the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +smbc_purge_cached_fn +smbc_getFunctionPurgeCachedServers(SMBCCTX *c) +{ + return c->callbacks.purge_cached_fn; +} + +/** Set the function to store private data of the server cache */ +void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache) +{ + c->internal->server_cache = cache; +} + +/** Get the function to store private data of the server cache */ +struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c) +{ + return c->internal->server_cache; +} + + +/** + * Set the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +void +smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_fn fn) +{ + c->callbacks.purge_cached_fn = fn; +} + +/** + * Callable functions for files. + */ + +smbc_open_fn +smbc_getFunctionOpen(SMBCCTX *c) +{ + return c->open; +} + +void +smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn) +{ + c->open = fn; +} + +smbc_creat_fn +smbc_getFunctionCreat(SMBCCTX *c) +{ + return c->creat; +} + +void +smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn fn) +{ + c->creat = fn; +} + +smbc_read_fn +smbc_getFunctionRead(SMBCCTX *c) +{ + return c->read; +} + +void +smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn) +{ + c->read = fn; +} + +smbc_write_fn +smbc_getFunctionWrite(SMBCCTX *c) +{ + return c->write; +} + +void +smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn) +{ + c->write = fn; +} + +smbc_unlink_fn +smbc_getFunctionUnlink(SMBCCTX *c) +{ + return c->unlink; +} + +void +smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn) +{ + c->unlink = fn; +} + +smbc_rename_fn +smbc_getFunctionRename(SMBCCTX *c) +{ + return c->rename; +} + +void +smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn) +{ + c->rename = fn; +} + +smbc_lseek_fn +smbc_getFunctionLseek(SMBCCTX *c) +{ + return c->lseek; +} + +void +smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn) +{ + c->lseek = fn; +} + +smbc_stat_fn +smbc_getFunctionStat(SMBCCTX *c) +{ + return c->stat; +} + +void +smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn) +{ + c->stat = fn; +} + +smbc_fstat_fn +smbc_getFunctionFstat(SMBCCTX *c) +{ + return c->fstat; +} + +void +smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn) +{ + c->fstat = fn; +} + +smbc_ftruncate_fn +smbc_getFunctionFtruncate(SMBCCTX *c) +{ + return c->internal->posix_emu.ftruncate_fn; +} + +void +smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn) +{ + c->internal->posix_emu.ftruncate_fn = fn; +} + +smbc_close_fn +smbc_getFunctionClose(SMBCCTX *c) +{ + return c->close_fn; +} + +void +smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn) +{ + c->close_fn = fn; +} + + +/** + * Callable functions for directories. + */ + +smbc_opendir_fn +smbc_getFunctionOpendir(SMBCCTX *c) +{ + return c->opendir; +} + +void +smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn) +{ + c->opendir = fn; +} + +smbc_closedir_fn +smbc_getFunctionClosedir(SMBCCTX *c) +{ + return c->closedir; +} + +void +smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn) +{ + c->closedir = fn; +} + +smbc_readdir_fn +smbc_getFunctionReaddir(SMBCCTX *c) +{ + return c->readdir; +} + +void +smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn) +{ + c->readdir = fn; +} + +smbc_getdents_fn +smbc_getFunctionGetdents(SMBCCTX *c) +{ + return c->getdents; +} + +void +smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn) +{ + c->getdents = fn; +} + +smbc_mkdir_fn +smbc_getFunctionMkdir(SMBCCTX *c) +{ + return c->mkdir; +} + +void +smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn) +{ + c->mkdir = fn; +} + +smbc_rmdir_fn +smbc_getFunctionRmdir(SMBCCTX *c) +{ + return c->rmdir; +} + +void +smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn) +{ + c->rmdir = fn; +} + +smbc_telldir_fn +smbc_getFunctionTelldir(SMBCCTX *c) +{ + return c->telldir; +} + +void +smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn) +{ + c->telldir = fn; +} + +smbc_lseekdir_fn +smbc_getFunctionLseekdir(SMBCCTX *c) +{ + return c->lseekdir; +} + +void +smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn) +{ + c->lseekdir = fn; +} + +smbc_fstatdir_fn +smbc_getFunctionFstatdir(SMBCCTX *c) +{ + return c->fstatdir; +} + +void +smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn) +{ + c->fstatdir = fn; +} + + +/** + * Callable functions applicable to both files and directories. + */ + +smbc_chmod_fn +smbc_getFunctionChmod(SMBCCTX *c) +{ + return c->chmod; +} + +void +smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn) +{ + c->chmod = fn; +} + +smbc_utimes_fn +smbc_getFunctionUtimes(SMBCCTX *c) +{ + return c->utimes; +} + +void +smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn) +{ + c->utimes = fn; +} + +smbc_setxattr_fn +smbc_getFunctionSetxattr(SMBCCTX *c) +{ + return c->setxattr; +} + +void +smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn) +{ + c->setxattr = fn; +} + +smbc_getxattr_fn +smbc_getFunctionGetxattr(SMBCCTX *c) +{ + return c->getxattr; +} + +void +smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn) +{ + c->getxattr = fn; +} + +smbc_removexattr_fn +smbc_getFunctionRemovexattr(SMBCCTX *c) +{ + return c->removexattr; +} + +void +smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn) +{ + c->removexattr = fn; +} + +smbc_listxattr_fn +smbc_getFunctionListxattr(SMBCCTX *c) +{ + return c->listxattr; +} + +void +smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn) +{ + c->listxattr = fn; +} + + +/** + * Callable functions related to printing + */ + +smbc_print_file_fn +smbc_getFunctionPrintFile(SMBCCTX *c) +{ + return c->print_file; +} + +void +smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn) +{ + c->print_file = fn; +} + +smbc_open_print_job_fn +smbc_getFunctionOpenPrintJob(SMBCCTX *c) +{ + return c->open_print_job; +} + +void +smbc_setFunctionOpenPrintJob(SMBCCTX *c, + smbc_open_print_job_fn fn) +{ + c->open_print_job = fn; +} + +smbc_list_print_jobs_fn +smbc_getFunctionListPrintJobs(SMBCCTX *c) +{ + return c->list_print_jobs; +} + +void +smbc_setFunctionListPrintJobs(SMBCCTX *c, + smbc_list_print_jobs_fn fn) +{ + c->list_print_jobs = fn; +} + +smbc_unlink_print_job_fn +smbc_getFunctionUnlinkPrintJob(SMBCCTX *c) +{ + return c->unlink_print_job; +} + +void +smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, + smbc_unlink_print_job_fn fn) +{ + c->unlink_print_job = fn; +} + diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index b733eab74f..27546f687e 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -157,7 +157,7 @@ SMBC_stat_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame,context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -237,7 +237,7 @@ SMBC_fstat_ctx(SMBCCTX *context, if (!file->file) { TALLOC_FREE(frame); - return (context->posix_emu.fstatdir_fn)(context, file, st); + return smbc_getFunctionFstatdir(context)(context, file, st); } /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index 3c08412d59..e17146e611 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -1729,7 +1729,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -2023,7 +2023,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -2157,7 +2157,7 @@ SMBC_removexattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); -- cgit From ee45d0d6630624b735a7ea07639ffa0d774a337c Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 3 Mar 2008 18:25:49 -0500 Subject: Missed a few 'deprecated' markers (This used to be commit 76ba37ac46b4a77fe228ca90635fa19140541ccd) --- source3/include/libsmbclient.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index a60c05fa7f..e1a4b74567 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -2767,7 +2767,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getServerCacheData(), smbc_setServerCacheData() */ - void * reserved; /* space where server_cache_data used to be */ + void * reserved _DEPRECATED_; /* * Very old configuration options. @@ -2796,7 +2796,7 @@ struct _SMBCCTX int browse_max_lmb_count _DEPRECATED_; int urlencode_readdir_entries _DEPRECATED_; int one_share_per_server _DEPRECATED_; - } options; + } options _DEPRECATED_; /** INTERNAL DATA * do _NOT_ touch this from your program ! -- cgit From 8a228000289b331bbe78d0a9c9b44a2ad4a298f8 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 3 Mar 2008 22:56:32 -0500 Subject: use constant name less likely to cause conflict (This used to be commit fd18b01016d1dc4b08983975353e62084fdc323c) --- source3/include/libsmbclient.h | 100 ++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'source3') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index e1a4b74567..2e38944d65 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -25,11 +25,11 @@ #ifndef SMBCLIENT_H_INCLUDED #define SMBCLIENT_H_INCLUDED -#undef _DEPRECATED_ +#undef DEPRECATED_SMBC_INTERFACE #if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__) -# define _DEPRECATED_ __attribute__ ((deprecated)) +# define DEPRECATED_SMBC_INTERFACE __attribute__ ((deprecated)) #else -# define _DEPRECATED_ +# define DEPRECATED_SMBC_INTERFACE #endif #ifdef __cplusplus @@ -2600,7 +2600,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getDebug() and smbc_setDebug() */ - int debug _DEPRECATED_; + int debug DEPRECATED_SMBC_INTERFACE; /** * netbios name used for making connections @@ -2608,7 +2608,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getNetbiosName() and smbc_setNetbiosName() */ - char * netbios_name _DEPRECATED_; + char * netbios_name DEPRECATED_SMBC_INTERFACE; /** * workgroup name used for making connections @@ -2616,7 +2616,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getWorkgroup() and smbc_setWorkgroup() */ - char * workgroup _DEPRECATED_; + char * workgroup DEPRECATED_SMBC_INTERFACE; /** * username used for making connections @@ -2624,7 +2624,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getUser() and smbc_setUser() */ - char * user _DEPRECATED_; + char * user DEPRECATED_SMBC_INTERFACE; /** * timeout used for waiting on connections / response data (in @@ -2633,7 +2633,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getTimeout() and smbc_setTimeout() */ - int timeout _DEPRECATED_; + int timeout DEPRECATED_SMBC_INTERFACE; /** * callable functions for files: @@ -2644,40 +2644,40 @@ struct _SMBCCTX * Use smbc_getFunction*() and smbc_setFunction*(), e.g. * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. */ - smbc_open_fn open _DEPRECATED_; - smbc_creat_fn creat _DEPRECATED_; - smbc_read_fn read _DEPRECATED_; - smbc_write_fn write _DEPRECATED_; - smbc_unlink_fn unlink _DEPRECATED_; - smbc_rename_fn rename _DEPRECATED_; - smbc_lseek_fn lseek _DEPRECATED_; - smbc_stat_fn stat _DEPRECATED_; - smbc_fstat_fn fstat _DEPRECATED_; + smbc_open_fn open DEPRECATED_SMBC_INTERFACE; + smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE; + smbc_read_fn read DEPRECATED_SMBC_INTERFACE; + smbc_write_fn write DEPRECATED_SMBC_INTERFACE; + smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE; + smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE; + smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE; + smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE; + smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE; #if 0 /* internal */ smbc_ftruncate_fn ftruncate_fn; #endif - smbc_close_fn close_fn _DEPRECATED_; - smbc_opendir_fn opendir _DEPRECATED_; - smbc_closedir_fn closedir _DEPRECATED_; - smbc_readdir_fn readdir _DEPRECATED_; - smbc_getdents_fn getdents _DEPRECATED_; - smbc_mkdir_fn mkdir _DEPRECATED_; - smbc_rmdir_fn rmdir _DEPRECATED_; - smbc_telldir_fn telldir _DEPRECATED_; - smbc_lseekdir_fn lseekdir _DEPRECATED_; - smbc_fstatdir_fn fstatdir _DEPRECATED_; - smbc_chmod_fn chmod _DEPRECATED_; - smbc_utimes_fn utimes _DEPRECATED_; - smbc_setxattr_fn setxattr _DEPRECATED_; - smbc_getxattr_fn getxattr _DEPRECATED_; - smbc_removexattr_fn removexattr _DEPRECATED_; - smbc_listxattr_fn listxattr _DEPRECATED_; + smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE; + smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE; + smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE; + smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE; + smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE; + smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE; + smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE; + smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE; + smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE; + smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE; + smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE; + smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE; + smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE; + smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE; + smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE; + smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE; /* Printing-related functions */ - smbc_print_file_fn print_file _DEPRECATED_; - smbc_open_print_job_fn open_print_job _DEPRECATED_; - smbc_list_print_jobs_fn list_print_jobs _DEPRECATED_; - smbc_unlink_print_job_fn unlink_print_job _DEPRECATED_; + smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE; + smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE; + smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE; + smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE; /* ** Callbacks @@ -2695,7 +2695,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() */ - smbc_get_auth_data_fn auth_fn _DEPRECATED_; + smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE; /** * check if a server is still good @@ -2704,7 +2704,7 @@ struct _SMBCCTX * Use smbc_getFunctionCheckServer(), * smbc_setFunctionCheckServer() */ - smbc_check_server_fn check_server_fn _DEPRECATED_; + smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE; /** * remove a server if unused @@ -2713,7 +2713,7 @@ struct _SMBCCTX * Use smbc_getFunctionRemoveUnusedServer(), * smbc_setFunctionCheckServer() */ - smbc_remove_unused_server_fn remove_unused_server_fn _DEPRECATED_; + smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE; /** Cache subsystem * @@ -2730,7 +2730,7 @@ struct _SMBCCTX * Use smbc_getFunctionAddCachedServer(), * smbc_setFunctionAddCachedServer() */ - smbc_add_cached_srv_fn add_cached_srv_fn _DEPRECATED_; + smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE; /** * server cache lookup @@ -2739,7 +2739,7 @@ struct _SMBCCTX * Use smbc_getFunctionGetCachedServer(), * smbc_setFunctionGetCachedServer() */ - smbc_get_cached_srv_fn get_cached_srv_fn _DEPRECATED_; + smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE; /** * server cache removal @@ -2748,7 +2748,7 @@ struct _SMBCCTX * Use smbc_getFunctionRemoveCachedServer(), * smbc_setFunctionRemoveCachedServer() */ - smbc_remove_cached_srv_fn remove_cached_srv_fn _DEPRECATED_; + smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE; /** * server cache purging, try to remove all cached servers @@ -2758,7 +2758,7 @@ struct _SMBCCTX * Use smbc_getFunctionPurgeCachedServers(), * smbc_setFunctionPurgeCachedServers() */ - smbc_purge_cached_fn purge_cached_fn _DEPRECATED_; + smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE; } callbacks; /** @@ -2767,7 +2767,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getServerCacheData(), smbc_setServerCacheData() */ - void * reserved _DEPRECATED_; + void * reserved DEPRECATED_SMBC_INTERFACE; /* * Very old configuration options. @@ -2781,7 +2781,7 @@ struct _SMBCCTX * smbc_setOptionNoAutoAnonymousLogin() * smbc_getOptionNoAutoAnonymousLogin() */ - int flags _DEPRECATED_; + int flags DEPRECATED_SMBC_INTERFACE; /** * user options selections that apply to this session @@ -2793,10 +2793,10 @@ struct _SMBCCTX * smbc_getOption*() functions. */ struct _smbc_options { - int browse_max_lmb_count _DEPRECATED_; - int urlencode_readdir_entries _DEPRECATED_; - int one_share_per_server _DEPRECATED_; - } options _DEPRECATED_; + int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE; + int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE; + int one_share_per_server DEPRECATED_SMBC_INTERFACE; + } options DEPRECATED_SMBC_INTERFACE; /** INTERNAL DATA * do _NOT_ touch this from your program ! -- cgit From 2c5e04b1f72c567898537110be3acbf3936e8584 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 11:02:26 +0100 Subject: Fix crash bug in pdb_init_ldapsam(). Karolin, this needs to be in 3-2-stable. Guenther (This used to be commit 0d73bde6de4391e7aec862424762473441fa0905) --- source3/passdb/pdb_ldap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index ce79dce668..87a648a5b4 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -6264,7 +6264,7 @@ NTSTATUS pdb_init_ldapsam(struct pdb_methods **pdb_method, const char *location) entry, get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_USER_SID), - NULL); + talloc_tos()); if (domain_sid_string) { bool found_sid; @@ -6300,7 +6300,7 @@ NTSTATUS pdb_init_ldapsam(struct pdb_methods **pdb_method, const char *location) entry, get_attr_key2string( dominfo_attr_list, LDAP_ATTR_ALGORITHMIC_RID_BASE ), - NULL); + talloc_tos()); if (alg_rid_base_string) { alg_rid_base = (uint32)atol(alg_rid_base_string); if (alg_rid_base != algorithmic_rid_base()) { -- cgit From f7b4485fbeabe40b73dd066f6b643a7a5ffee5cd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 11:04:36 +0100 Subject: Move talloc_init to the right place in "net ads join". Guenther (This used to be commit 8cd07c1fa8f435f7ff3dc79c195da9324fb2452f) --- source3/utils/net_ads.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 9358a4f184..46e0a2591b 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1121,6 +1121,12 @@ int net_ads_join(int argc, const char **argv) goto fail; } + if (!(ctx = talloc_init("net_ads_join"))) { + d_fprintf(stderr, "Could not initialise talloc context.\n"); + werr = WERR_NOMEM; + goto fail; + } + use_in_memory_ccache(); werr = libnet_init_JoinCtx(ctx, &r); @@ -1128,12 +1134,6 @@ int net_ads_join(int argc, const char **argv) goto fail; } - if (!(ctx = talloc_init("net_ads_join"))) { - d_fprintf(stderr, "Could not initialise talloc context.\n"); - werr = WERR_NOMEM; - goto fail; - } - /* process additional command line args */ for ( i=0; i Date: Tue, 4 Mar 2008 11:06:02 +0100 Subject: Zero more structs initially in LSA rpc server. Guenther (This used to be commit d7ce643285276790a65faff76666498595a508d7) --- source3/rpc_server/srv_lsa_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ce3fd1a44f..c2502141e5 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -82,6 +82,8 @@ static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx, return -1; } + ZERO_STRUCT(ref->domains[num]); + init_lsa_StringLarge(&ref->domains[num].name, dom_name); ref->domains[num].sid = sid_dup_talloc(mem_ctx, dom_sid); if (!ref->domains[num].sid) { @@ -228,6 +230,8 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, const char *domain; enum lsa_SidType type = SID_NAME_UNKNOWN; + ZERO_STRUCT(sid); + /* Split name into domain and user component */ full_name = name[i].string; -- cgit From 5a4182012de914116798455793fd1963c2e65d28 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 11:07:13 +0100 Subject: Use TALLOC_FREE in libnetjoin debugging dump code. Guenther (This used to be commit b753087ff79c1d35a409eddc1f61e115e887c1e1) --- source3/libnet/libnet_join.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 866d1c06e1..4f9e4c1c86 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -29,7 +29,7 @@ char *str = NULL; \ str = NDR_PRINT_FUNCTION_STRING(ctx, libnet_JoinCtx, f, r); \ DEBUG(1,("libnet_Join:\n%s", str)); \ - talloc_free(str); \ + TALLOC_FREE(str); \ } while (0) #define LIBNET_JOIN_IN_DUMP_CTX(ctx, r) \ @@ -42,7 +42,7 @@ char *str = NULL; \ str = NDR_PRINT_FUNCTION_STRING(ctx, libnet_UnjoinCtx, f, r); \ DEBUG(1,("libnet_Unjoin:\n%s", str)); \ - talloc_free(str); \ + TALLOC_FREE(str); \ } while (0) #define LIBNET_UNJOIN_IN_DUMP_CTX(ctx, r) \ -- cgit From 33322a7ced16e4b4325a813b4143833954882745 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 12:46:15 +0100 Subject: Fix lsa_QueryInfoPolicy: make proper talloc copies of the sids. Guenther (This used to be commit b9441232d66d78e66464be6c9748a023681ce6ca) --- source3/rpc_server/srv_lsa_nt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c2502141e5..c03630d6f9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -603,15 +603,22 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: name = get_global_sam_name(); - sid = get_global_sam_sid(); + sid = sid_dup_talloc(p->mem_ctx, get_global_sam_sid()); + if (!sid) { + return NT_STATUS_NO_MEMORY; + } break; case ROLE_DOMAIN_MEMBER: name = lp_workgroup(); /* We need to return the Domain SID here. */ - if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) - sid = &domain_sid; - else + if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) { + sid = sid_dup_talloc(p->mem_ctx, &domain_sid); + if (!sid) { + return NT_STATUS_NO_MEMORY; + } + } else { return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + } break; case ROLE_STANDALONE: name = lp_workgroup(); -- cgit From 253dc4d728cb27dc53bf072dcd4e0efa896ab7d2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 13:16:02 +0100 Subject: Fix counter mismatch in lsa_LookupNames server. Guenther (This used to be commit 80fd085c34befd38d33cf6e59080a2a36016a92d) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c03630d6f9..b3275f27a3 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1036,10 +1036,10 @@ done: } } - *r->out.count = num_entries; + *r->out.count = mapped_count; *r->out.domains = domains; r->out.sids->sids = rids; - r->out.sids->count = mapped_count; + r->out.sids->count = num_entries; return status; } -- cgit From 7c95f53b686e5a3eb291534ae9cdc5939ef2ac66 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 13:19:38 +0100 Subject: Fix counter mismatch in lsa_LookupNames3 server. Guenther (This used to be commit e052d6f2c82a644986e5d99f640310d71cd5c396) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b3275f27a3..20c910e46d 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1176,10 +1176,10 @@ done: } } - *r->out.count = num_entries; + *r->out.count = mapped_count; *r->out.domains = domains; r->out.sids->sids = trans_sids; - r->out.sids->count = mapped_count; + r->out.sids->count = num_entries; return status; } -- cgit From 9a05f49ca65039170500d5bcd9b685dd4c54587c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 12:26:05 +0100 Subject: Add new Windows 2008 Kerberos PAC Type 12 (apparently again undocumented). We need at least to parse this in order to correctly support kerberized session setup from w2k8 as well as local pam_winbind logons using kerberos. Guenther (This used to be commit 4ba62d49d740c43cf17ceef1534cf1c8a7e4a130) --- source3/librpc/idl/krb5pac.idl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/krb5pac.idl b/source3/librpc/idl/krb5pac.idl index 601e3e1a27..11f08e11aa 100644 --- a/source3/librpc/idl/krb5pac.idl +++ b/source3/librpc/idl/krb5pac.idl @@ -31,6 +31,19 @@ interface krb5pac samr_RidWithAttributeArray res_groups; } PAC_LOGON_INFO; + typedef struct { + [value(2*strlen_m(upn_name))] uint16 upn_size; + uint16 unknown1; /* 0x10 */ + [value(2*strlen_m(domain_name))] uint16 domain_size; + uint16 unknown2; /* 0x50 */ + uint16 unknown3; /* 0x01 */ + uint16 unknown4; + uint32 unknown5; + [charset(UTF16)] uint8 upn_name[upn_size+2]; + [charset(UTF16)] uint8 domain_name[domain_size+2]; + uint32 unknown6; + } PAC_UNKNOWN_12; + typedef [public] struct { [value(0x00081001)] uint32 unknown1; [value(0xCCCCCCCC)] uint32 unknown2; @@ -44,7 +57,8 @@ interface krb5pac PAC_TYPE_SRV_CHECKSUM = 6, PAC_TYPE_KDC_CHECKSUM = 7, PAC_TYPE_LOGON_NAME = 10, - PAC_TYPE_CONSTRAINED_DELEGATION = 11 + PAC_TYPE_CONSTRAINED_DELEGATION = 11, + PAC_TYPE_UNKNOWN_12 = 12 } PAC_TYPE; typedef [public,nodiscriminant,gensize] union { @@ -52,6 +66,7 @@ interface krb5pac [case(PAC_TYPE_SRV_CHECKSUM)] PAC_SIGNATURE_DATA srv_cksum; [case(PAC_TYPE_KDC_CHECKSUM)] PAC_SIGNATURE_DATA kdc_cksum; [case(PAC_TYPE_LOGON_NAME)] PAC_LOGON_NAME logon_name; + [case(PAC_TYPE_UNKNOWN_12)] PAC_UNKNOWN_12 unknown; } PAC_INFO; typedef [public,nopush,nopull,noprint] struct { -- cgit From 29eb63439992bf7d9c7fa99de6a317388aa1a661 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 12:28:36 +0100 Subject: Re-run make idl. Guenther (This used to be commit 8e601e2365f50e582de442daa1559f828bda3e89) --- source3/librpc/gen_ndr/krb5pac.h | 18 ++++++++- source3/librpc/gen_ndr/ndr_krb5pac.c | 76 ++++++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/ndr_krb5pac.h | 1 + 3 files changed, 94 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/krb5pac.h b/source3/librpc/gen_ndr/krb5pac.h index b8b9054bb6..8a148253ae 100644 --- a/source3/librpc/gen_ndr/krb5pac.h +++ b/source3/librpc/gen_ndr/krb5pac.h @@ -25,6 +25,19 @@ struct PAC_LOGON_INFO { struct samr_RidWithAttributeArray res_groups; }/* [gensize] */; +struct PAC_UNKNOWN_12 { + uint16_t upn_size;/* [value(2*strlen_m(upn_name))] */ + uint16_t unknown1; + uint16_t domain_size;/* [value(2*strlen_m(domain_name))] */ + uint16_t unknown2; + uint16_t unknown3; + uint16_t unknown4; + uint32_t unknown5; + const char *upn_name;/* [charset(UTF16)] */ + const char *domain_name;/* [charset(UTF16)] */ + uint32_t unknown6; +}; + struct PAC_LOGON_INFO_CTR { uint32_t unknown1;/* [value(0x00081001)] */ uint32_t unknown2;/* [value(0xCCCCCCCC)] */ @@ -40,7 +53,8 @@ enum PAC_TYPE PAC_TYPE_SRV_CHECKSUM=6, PAC_TYPE_KDC_CHECKSUM=7, PAC_TYPE_LOGON_NAME=10, - PAC_TYPE_CONSTRAINED_DELEGATION=11 + PAC_TYPE_CONSTRAINED_DELEGATION=11, + PAC_TYPE_UNKNOWN_12=12 } #else { __donnot_use_enum_PAC_TYPE=0x7FFFFFFF} @@ -49,6 +63,7 @@ enum PAC_TYPE #define PAC_TYPE_KDC_CHECKSUM ( 7 ) #define PAC_TYPE_LOGON_NAME ( 10 ) #define PAC_TYPE_CONSTRAINED_DELEGATION ( 11 ) +#define PAC_TYPE_UNKNOWN_12 ( 12 ) #endif ; @@ -57,6 +72,7 @@ union PAC_INFO { struct PAC_SIGNATURE_DATA srv_cksum;/* [case(PAC_TYPE_SRV_CHECKSUM)] */ struct PAC_SIGNATURE_DATA kdc_cksum;/* [case(PAC_TYPE_KDC_CHECKSUM)] */ struct PAC_LOGON_NAME logon_name;/* [case(PAC_TYPE_LOGON_NAME)] */ + struct PAC_UNKNOWN_12 unknown;/* [case(PAC_TYPE_UNKNOWN_12)] */ }/* [gensize,nodiscriminant,public] */; struct PAC_BUFFER { diff --git a/source3/librpc/gen_ndr/ndr_krb5pac.c b/source3/librpc/gen_ndr/ndr_krb5pac.c index 7c4dba0b0a..be9e2e1e4e 100644 --- a/source3/librpc/gen_ndr/ndr_krb5pac.c +++ b/source3/librpc/gen_ndr/ndr_krb5pac.c @@ -166,6 +166,63 @@ static size_t ndr_size_PAC_LOGON_INFO(const struct PAC_LOGON_INFO *r, int flags) return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_PAC_LOGON_INFO); } +static enum ndr_err_code ndr_push_PAC_UNKNOWN_12(struct ndr_push *ndr, int ndr_flags, const struct PAC_UNKNOWN_12 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 2 * strlen_m(r->upn_name))); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown1)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 2 * strlen_m(r->domain_name))); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown2)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown3)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown5)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->upn_name, 2 * strlen_m(r->upn_name) + 2, sizeof(uint8_t), CH_UTF16)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->domain_name, 2 * strlen_m(r->domain_name) + 2, sizeof(uint8_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown6)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_PAC_UNKNOWN_12(struct ndr_pull *ndr, int ndr_flags, struct PAC_UNKNOWN_12 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->upn_size)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown1)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->domain_size)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown2)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown3)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown5)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->upn_name, r->upn_size + 2, sizeof(uint8_t), CH_UTF16)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->domain_name, r->domain_size + 2, sizeof(uint8_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown6)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_UNKNOWN_12(struct ndr_print *ndr, const char *name, const struct PAC_UNKNOWN_12 *r) +{ + ndr_print_struct(ndr, name, "PAC_UNKNOWN_12"); + ndr->depth++; + ndr_print_uint16(ndr, "upn_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * strlen_m(r->upn_name):r->upn_size); + ndr_print_uint16(ndr, "unknown1", r->unknown1); + ndr_print_uint16(ndr, "domain_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * strlen_m(r->domain_name):r->domain_size); + ndr_print_uint16(ndr, "unknown2", r->unknown2); + ndr_print_uint16(ndr, "unknown3", r->unknown3); + ndr_print_uint16(ndr, "unknown4", r->unknown4); + ndr_print_uint32(ndr, "unknown5", r->unknown5); + ndr_print_string(ndr, "upn_name", r->upn_name); + ndr_print_string(ndr, "domain_name", r->domain_name); + ndr_print_uint32(ndr, "unknown6", r->unknown6); + ndr->depth--; +} + _PUBLIC_ enum ndr_err_code ndr_push_PAC_LOGON_INFO_CTR(struct ndr_push *ndr, int ndr_flags, const struct PAC_LOGON_INFO_CTR *r) { if (ndr_flags & NDR_SCALARS) { @@ -253,6 +310,7 @@ _PUBLIC_ void ndr_print_PAC_TYPE(struct ndr_print *ndr, const char *name, enum P case PAC_TYPE_KDC_CHECKSUM: val = "PAC_TYPE_KDC_CHECKSUM"; break; case PAC_TYPE_LOGON_NAME: val = "PAC_TYPE_LOGON_NAME"; break; case PAC_TYPE_CONSTRAINED_DELEGATION: val = "PAC_TYPE_CONSTRAINED_DELEGATION"; break; + case PAC_TYPE_UNKNOWN_12: val = "PAC_TYPE_UNKNOWN_12"; break; } ndr_print_enum(ndr, name, "ENUM", val, r); } @@ -278,6 +336,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_PAC_INFO(struct ndr_push *ndr, int ndr_flags NDR_CHECK(ndr_push_PAC_LOGON_NAME(ndr, NDR_SCALARS, &r->logon_name)); break; } + case PAC_TYPE_UNKNOWN_12: { + NDR_CHECK(ndr_push_PAC_UNKNOWN_12(ndr, NDR_SCALARS, &r->unknown)); + break; } + default: return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -298,6 +360,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_PAC_INFO(struct ndr_push *ndr, int ndr_flags case PAC_TYPE_LOGON_NAME: break; + case PAC_TYPE_UNKNOWN_12: + break; + default: return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -327,6 +392,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_PAC_INFO(struct ndr_pull *ndr, int ndr_flags NDR_CHECK(ndr_pull_PAC_LOGON_NAME(ndr, NDR_SCALARS, &r->logon_name)); break; } + case PAC_TYPE_UNKNOWN_12: { + NDR_CHECK(ndr_pull_PAC_UNKNOWN_12(ndr, NDR_SCALARS, &r->unknown)); + break; } + default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -346,6 +415,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull_PAC_INFO(struct ndr_pull *ndr, int ndr_flags case PAC_TYPE_LOGON_NAME: break; + case PAC_TYPE_UNKNOWN_12: + break; + default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -375,6 +447,10 @@ _PUBLIC_ void ndr_print_PAC_INFO(struct ndr_print *ndr, const char *name, const ndr_print_PAC_LOGON_NAME(ndr, "logon_name", &r->logon_name); break; + case PAC_TYPE_UNKNOWN_12: + ndr_print_PAC_UNKNOWN_12(ndr, "unknown", &r->unknown); + break; + default: ndr_print_bad_level(ndr, name, level); } diff --git a/source3/librpc/gen_ndr/ndr_krb5pac.h b/source3/librpc/gen_ndr/ndr_krb5pac.h index f23505d4f0..1d60382dc3 100644 --- a/source3/librpc/gen_ndr/ndr_krb5pac.h +++ b/source3/librpc/gen_ndr/ndr_krb5pac.h @@ -23,6 +23,7 @@ enum ndr_err_code ndr_push_PAC_SIGNATURE_DATA(struct ndr_push *ndr, int ndr_flag enum ndr_err_code ndr_pull_PAC_SIGNATURE_DATA(struct ndr_pull *ndr, int ndr_flags, struct PAC_SIGNATURE_DATA *r); void ndr_print_PAC_SIGNATURE_DATA(struct ndr_print *ndr, const char *name, const struct PAC_SIGNATURE_DATA *r); void ndr_print_PAC_LOGON_INFO(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_INFO *r); +void ndr_print_PAC_UNKNOWN_12(struct ndr_print *ndr, const char *name, const struct PAC_UNKNOWN_12 *r); enum ndr_err_code ndr_push_PAC_LOGON_INFO_CTR(struct ndr_push *ndr, int ndr_flags, const struct PAC_LOGON_INFO_CTR *r); enum ndr_err_code ndr_pull_PAC_LOGON_INFO_CTR(struct ndr_pull *ndr, int ndr_flags, struct PAC_LOGON_INFO_CTR *r); void ndr_print_PAC_LOGON_INFO_CTR(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_INFO_CTR *r); -- cgit From d06274b541ac4c4f021ff2fa90690431d2bb87c9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 19:04:54 +0100 Subject: Add secure_channel_type to libnetjoin. Guenther (This used to be commit f88910c1e5186737da4eda5a7a396c3238fc6775) --- source3/libnet/libnet_join.c | 4 +++- source3/librpc/gen_ndr/libnet_join.h | 3 +++ source3/librpc/gen_ndr/ndr_libnet_join.c | 1 + source3/librpc/idl/libnet_join.idl | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 4f9e4c1c86..9bed346b5e 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -630,7 +630,7 @@ static bool libnet_join_joindomain_store_secrets(TALLOC_CTX *mem_ctx, if (!secrets_store_machine_password(r->in.machine_password, r->out.netbios_domain_name, - SEC_CHAN_WKSTA)) + r->in.secure_channel_type)) { DEBUG(1,("Failed to save machine password\n")); return false; @@ -1412,6 +1412,8 @@ WERROR libnet_init_JoinCtx(TALLOC_CTX *mem_ctx, ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname()); W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name); + ctx->in.secure_channel_type = SEC_CHAN_WKSTA; + *r = ctx; return WERR_OK; diff --git a/source3/librpc/gen_ndr/libnet_join.h b/source3/librpc/gen_ndr/libnet_join.h index 8dbadcf0a2..0415f030b4 100644 --- a/source3/librpc/gen_ndr/libnet_join.h +++ b/source3/librpc/gen_ndr/libnet_join.h @@ -7,6 +7,8 @@ #ifndef _HEADER_libnetjoin #define _HEADER_libnetjoin +enum netr_SchannelType; + struct libnet_JoinCtx { struct { @@ -25,6 +27,7 @@ struct libnet_JoinCtx { uint8_t modify_config; struct ads_struct *ads;/* [ref] */ uint8_t debug; + enum netr_SchannelType secure_channel_type; } in; struct { diff --git a/source3/librpc/gen_ndr/ndr_libnet_join.c b/source3/librpc/gen_ndr/ndr_libnet_join.c index 6e65d03977..ac8f7ee71d 100644 --- a/source3/librpc/gen_ndr/ndr_libnet_join.c +++ b/source3/librpc/gen_ndr/ndr_libnet_join.c @@ -36,6 +36,7 @@ _PUBLIC_ void ndr_print_libnet_JoinCtx(struct ndr_print *ndr, const char *name, ndr_print_ads_struct(ndr, "ads", r->in.ads); ndr->depth--; ndr_print_uint8(ndr, "debug", r->in.debug); + ndr_print_netr_SchannelType(ndr, "secure_channel_type", r->in.secure_channel_type); ndr->depth--; } if (flags & NDR_OUT) { diff --git a/source3/librpc/idl/libnet_join.idl b/source3/librpc/idl/libnet_join.idl index 65d17c9203..3975d83a80 100644 --- a/source3/librpc/idl/libnet_join.idl +++ b/source3/librpc/idl/libnet_join.idl @@ -12,6 +12,7 @@ import "wkssvc.idl", "security.idl"; interface libnetjoin { typedef bitmap wkssvc_joinflags wkssvc_joinflags; + typedef enum netr_SchannelType netr_SchannelType; [nopush,nopull,noopnum] WERROR libnet_JoinCtx( [in] string dc_name, @@ -29,6 +30,7 @@ interface libnetjoin [in] boolean8 modify_config, [in] ads_struct *ads, [in] boolean8 debug, + [in] netr_SchannelType secure_channel_type, [out] string account_name, [out] string netbios_domain_name, [out] string dns_domain_name, -- cgit From ae45a74ddc3053405cf515ea276f82c674672de2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 22:54:14 +0100 Subject: Fix proxy_srvsvc_call(). Wow, this must have been broken a long time already. Guenther (This used to be commit 821762e5ab32a2fbea7c41f1d2c2ea8589daa1d3) --- source3/rpc_server/srv_srvsvc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 25e652c1fd..22fcaffb4e 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -34,13 +34,13 @@ static bool proxy_srvsvc_call(pipes_struct *p, uint8 opnum) struct api_struct *fns; int n_fns; - lsarpc_get_pipe_fns(&fns, &n_fns); + srvsvc_get_pipe_fns(&fns, &n_fns); if (opnum >= n_fns) return False; if (fns[opnum].opnum != opnum) { - smb_panic("LSA function table not sorted\n"); + smb_panic("SRVSVC function table not sorted\n"); } return fns[opnum].fn(p); -- cgit From d89877070e9ae3e3cc2690fd4ffb683d6e44f982 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 21:46:09 +0100 Subject: Whitespace cleanup in srvsvc server. Guenther (This used to be commit 3c0a3f8de742678b56f6b998a014105c05400666) --- source3/rpc_server/srv_srvsvc_nt.c | 100 ++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 8a25b6cfd5..880c808bd5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1,21 +1,21 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Jeremy Allison 2001. * Copyright (C) Nigel Williams 2001. * Copyright (C) Gerald (Jerry) Carter 2006. - * + * * 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 . */ @@ -101,11 +101,11 @@ static int pipe_enum_fn( struct db_record *rec, void *p) ********************************************************************/ static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username, - FILE_INFO_3 **info, + FILE_INFO_3 **info, uint32 *count, uint32 resume ) { struct file_enum_count fenum; - + fenum.ctx = ctx; fenum.username = username; fenum.count = *count; @@ -202,7 +202,7 @@ static void enum_file_fn( const struct share_mode_entry *e, ********************************************************************/ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, - FILE_INFO_3 **info, + FILE_INFO_3 **info, uint32 *count, uint32 resume ) { struct file_enum_count f_enum_cnt; @@ -211,12 +211,12 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, f_enum_cnt.username = username; f_enum_cnt.count = *count; f_enum_cnt.info = *info; - + share_mode_forall( enum_file_fn, (void *)&f_enum_cnt ); - + *info = f_enum_cnt.info; *count = f_enum_cnt.count; - + return WERR_OK; } @@ -602,7 +602,7 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, { SRV_SHARE_INFO_501 *info501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_501, num_entries); int i = 0; - + if (!info501) { return False; } @@ -612,7 +612,7 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, init_srv_share_info_501(p, &info501[i++], snum); } } - + ctr->share.info501 = info501; break; } @@ -637,7 +637,7 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, } /* here for completeness but not currently used with enum (1004 - 1501)*/ - + case 1004: { SRV_SHARE_INFO_1004 *info1004 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1004, num_entries); @@ -745,7 +745,7 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, ********************************************************************/ static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *r_n, - uint32 info_level, uint32 resume_hnd, bool all) + uint32 info_level, uint32 resume_hnd, bool all) { DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); @@ -852,7 +852,7 @@ static void init_srv_sess_info_0(pipes_struct *p, SRV_SESS_INFO_0 *ss0, uint32 * ss0->num_entries_read = num_entries; ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; ss0->num_entries_read2 = num_entries; - + if ((*snum) >= (*stot)) { (*snum) = 0; } @@ -867,16 +867,16 @@ static void init_srv_sess_info_0(pipes_struct *p, SRV_SESS_INFO_0 *ss0, uint32 * /******************************************************************* ********************************************************************/ -static void sess_file_fn( const struct share_mode_entry *e, +static void sess_file_fn( const struct share_mode_entry *e, const char *sharepath, const char *fname, void *data ) { struct sess_file_count *sess = (struct sess_file_count *)data; - + if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) { sess->count++; } - + return; } @@ -890,9 +890,9 @@ static int net_count_files( uid_t uid, struct server_id pid ) s_file_cnt.count = 0; s_file_cnt.uid = uid; s_file_cnt.pid = pid; - + share_mode_forall( sess_file_fn, &s_file_cnt ); - + return s_file_cnt.count; } @@ -910,42 +910,42 @@ static void init_srv_sess_info_1(pipes_struct *p, SRV_SESS_INFO_1 *ss1, uint32 * ss1->num_entries_read = 0; ss1->ptr_sess_info = 0; ss1->num_entries_read2 = 0; - + (*stot) = 0; return; } - + if (ss1 == NULL) { (*snum) = 0; return; } (*stot) = list_sessions(p->mem_ctx, &session_list); - + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[*snum].username); bool guest; - + if ( !pw ) { DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n", session_list[*snum].username)); continue; } - + connect_time = (uint32)(now - session_list[*snum].connect_start); num_files = net_count_files(pw->pw_uid, session_list[*snum].pid); guest = strequal( session_list[*snum].username, lp_guestaccount() ); - - init_srv_sess_info1( &ss1->info_1[num_entries], + + init_srv_sess_info1( &ss1->info_1[num_entries], session_list[*snum].remote_machine, - session_list[*snum].username, + session_list[*snum].username, num_files, connect_time, - 0, + 0, guest); num_entries++; } @@ -953,7 +953,7 @@ static void init_srv_sess_info_1(pipes_struct *p, SRV_SESS_INFO_1 *ss1, uint32 * ss1->num_entries_read = num_entries; ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; ss1->num_entries_read2 = num_entries; - + if ((*snum) >= (*stot)) { (*snum) = 0; } @@ -998,7 +998,7 @@ static WERROR init_srv_sess_info_ctr(pipes_struct *p, SRV_SESS_INFO_CTR *ctr, ********************************************************************/ static void init_srv_r_net_sess_enum(pipes_struct *p, SRV_R_NET_SESS_ENUM *r_n, - uint32 resume_hnd, int sess_level, int switch_value) + uint32 resume_hnd, int sess_level, int switch_value) { DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); @@ -1044,7 +1044,7 @@ static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto ss0->num_entries_read = num_entries; ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; ss0->num_entries_read2 = num_entries; - + if ((*snum) >= (*stot)) { (*snum) = 0; } @@ -1101,7 +1101,7 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto ss1->num_entries_read = num_entries; ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; ss1->num_entries_read2 = num_entries; - + if ((*snum) >= (*stot)) { (*snum) = 0; @@ -1111,7 +1111,7 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto ss1->num_entries_read = 0; ss1->ptr_conn_info = 0; ss1->num_entries_read2 = 0; - + (*stot) = 0; } } @@ -1154,7 +1154,7 @@ static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, ********************************************************************/ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, - uint32 resume_hnd, int conn_level, int switch_value) + uint32 resume_hnd, int conn_level, int switch_value) { DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); @@ -1180,7 +1180,7 @@ static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r, TALLOC_CTX *ctx = talloc_tos(); SRV_FILE_INFO_CTR *ctr = &r->ctr; - /* TODO -- Windows enumerates + /* TODO -- Windows enumerates (b) active pipes (c) open directories and files */ @@ -1188,12 +1188,12 @@ static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r, &ctr->num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(r->status)) goto done; - + r->status = net_enum_pipes( ctx, username, &ctr->file.info3, &ctr->num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(r->status)) goto done; - + r->level = ctr->level = 3; r->total_entries = ctr->num_entries; /* ctr->num_entries = r->total_entries - resume_hnd; */ @@ -1203,7 +1203,7 @@ static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r, r->status = WERR_OK; done: - if ( ctr->num_entries > 0 ) + if ( ctr->num_entries > 0 ) ctr->ptr_entries = 1; init_enum_hnd(&r->enum_hnd, 0); @@ -1233,7 +1233,7 @@ WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_F default: return WERR_UNKNOWN_LEVEL; } - + return WERR_OK; } @@ -1266,7 +1266,7 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R case 102: init_srv_info_102(&ctr->srv.sv102, - 500, global_myname(), + 500, global_myname(), string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), @@ -1401,7 +1401,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES /* fail out now if you are not root or not a domain admin */ - if ((user.ut.uid != sec_initial_uid()) && + if ((user.ut.uid != sec_initial_uid()) && ( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) { goto done; @@ -1413,7 +1413,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES strequal(session_list[snum].remote_machine, machine)) { NTSTATUS ntstat; - + if (user.ut.uid != sec_initial_uid()) { not_root = True; become_root(); @@ -1422,11 +1422,11 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES ntstat = messaging_send(smbd_messaging_context(), session_list[snum].pid, MSG_SHUTDOWN, &data_blob_null); - + if (NT_STATUS_IS_OK(ntstat)) r_u->status = WERR_OK; - if (not_root) + if (not_root) unbecome_root(); } } @@ -1720,7 +1720,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /********* END SeDiskOperatorPrivilege BLOCK *********/ - DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); + DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); TALLOC_FREE(command); @@ -1819,7 +1819,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S map_generic_share_sd_bits(psd); break; - /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */ + /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */ case 1004: case 1005: @@ -2070,7 +2070,7 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET t->tm_mon + 1, 1900+t->tm_year, t->tm_wday); - + DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); return r_u->status; @@ -2362,7 +2362,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D r_u->total_entries = init_server_disk_enum(&resume); - r_u->disk_enum_ctr.unknown = 0; + r_u->disk_enum_ctr.unknown = 0; if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) { return WERR_NOMEM; @@ -2378,7 +2378,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D /*copy disk name into a unicode string*/ - init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); + init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); } /* add a terminating null string. Is this there if there is more data to come? */ -- cgit From 2c3dc9baa57d32c48cc58f16abae20fe763fd06f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:07:45 +0100 Subject: Use pidl for _srvsvc_NetSrvGetInfo(). Guenther (This used to be commit 34caa41fa6d44165b470508261c2bde124fc4955) --- source3/Makefile.in | 3 +- source3/rpc_client/init_srvsvc.c | 86 ++++++++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc.c | 20 +------ source3/rpc_server/srv_srvsvc_nt.c | 106 ++++++++++++++++++++++--------------- 4 files changed, 152 insertions(+), 63 deletions(-) create mode 100644 source3/rpc_client/init_srvsvc.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index f4b0344ad2..04df5cf840 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -304,7 +304,8 @@ RPC_PARSE_OBJ1 = $(RPC_PARSE_OBJ0) rpc_parse/parse_sec.o RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_srv.o RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_srv.o \ rpc_client/init_netlogon.o \ - rpc_client/init_lsa.o + rpc_client/init_lsa.o \ + rpc_client/init_srvsvc.o LIBREPLACE_OBJ = @LIBREPLACE_OBJS@ diff --git a/source3/rpc_client/init_srvsvc.c b/source3/rpc_client/init_srvsvc.c new file mode 100644 index 0000000000..a4ee54cb48 --- /dev/null +++ b/source3/rpc_client/init_srvsvc.c @@ -0,0 +1,86 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * 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 "includes.h" + +/******************************************************************* + inits a srvsvc_NetSrvInfo102 structure +********************************************************************/ + +void init_srvsvc_NetSrvInfo102(struct srvsvc_NetSrvInfo102 *r, + enum srvsvc_PlatformId platform_id, + const char *server_name, + uint32_t version_major, + uint32_t version_minor, + uint32_t server_type, + const char *comment, + uint32_t users, + uint32_t disc, + uint32_t hidden, + uint32_t announce, + uint32_t anndelta, + uint32_t licenses, + const char *userpath) +{ + r->platform_id = platform_id; + r->server_name = server_name; + r->version_major = version_major; + r->version_minor = version_minor; + r->server_type = server_type; + r->comment = comment; + r->users = users; + r->disc = disc; + r->hidden = hidden; + r->announce = announce; + r->anndelta = anndelta; + r->licenses = licenses; + r->userpath = userpath; +} + +/******************************************************************* + inits a srvsvc_NetSrvInfo101 structure +********************************************************************/ + +void init_srvsvc_NetSrvInfo101(struct srvsvc_NetSrvInfo101 *r, + enum srvsvc_PlatformId platform_id, + const char *server_name, + uint32_t version_major, + uint32_t version_minor, + uint32_t server_type, + const char *comment) +{ + r->platform_id = platform_id; + r->server_name = server_name; + r->version_major = version_major; + r->version_minor = version_minor; + r->server_type = server_type; + r->comment = comment; +} + +/******************************************************************* + inits a srvsvc_NetSrvInfo100 structure +********************************************************************/ + +void init_srvsvc_NetSrvInfo100(struct srvsvc_NetSrvInfo100 *r, + enum srvsvc_PlatformId platform_id, + const char *server_name) +{ + r->platform_id = platform_id; + r->server_name = server_name; +} diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 22fcaffb4e..0e97ee3460 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -52,25 +52,7 @@ static bool proxy_srvsvc_call(pipes_struct *p, uint8 opnum) static bool api_srv_net_srv_get_info(pipes_struct *p) { - SRV_Q_NET_SRV_GET_INFO q_u; - SRV_R_NET_SRV_GET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get info */ - if (!srv_io_q_net_srv_get_info("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_srv_get_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_srv_get_info("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSRVGETINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 880c808bd5..ddb7e120d9 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1238,67 +1238,93 @@ WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_F } /******************************************************************* -net server get info + _srvsvc_NetSrvGetInfo ********************************************************************/ -WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u) +WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, + struct srvsvc_NetSrvGetInfo *r) { WERROR status = WERR_OK; - SRV_INFO_CTR *ctr = TALLOC_P(p->mem_ctx, SRV_INFO_CTR); - if (!ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(ctr); - - DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__)); if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to srv_net_srv_get_info\n")); + DEBUG(3, ("access denied to _srvsvc_NetSrvGetInfo\n")); return WERR_ACCESS_DENIED; } - switch (q_u->switch_value) { + switch (r->in.level) { /* Technically level 102 should only be available to Administrators but there isn't anything super-secret here, as most of it is made up. */ - case 102: - init_srv_info_102(&ctr->srv.sv102, - 500, global_myname(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - 0xffffffff, /* users */ - 0xf, /* disc */ - 0, /* hidden */ - 240, /* announce */ - 3000, /* announce delta */ - 100000, /* licenses */ - "c:\\"); /* user path */ + case 102: { + struct srvsvc_NetSrvInfo102 *info102; + + info102 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo102); + if (!info102) { + return WERR_NOMEM; + } + + init_srvsvc_NetSrvInfo102(info102, + PLATFORM_ID_NT, + global_myname(), + lp_major_announce_version(), + lp_minor_announce_version(), + lp_default_server_announce(), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), + 0xffffffff, /* users */ + 0xf, /* disc */ + 0, /* hidden */ + 240, /* announce */ + 3000, /* announce delta */ + 100000, /* licenses */ + "c:\\"); /* user path */ + r->out.info->info102 = info102; break; - case 101: - init_srv_info_101(&ctr->srv.sv101, - 500, global_myname(), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); + } + case 101: { + struct srvsvc_NetSrvInfo101 *info101; + + info101 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo101); + if (!info101) { + return WERR_NOMEM; + } + + init_srvsvc_NetSrvInfo101(info101, + PLATFORM_ID_NT, + global_myname(), + lp_major_announce_version(), + lp_minor_announce_version(), + lp_default_server_announce(), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); + r->out.info->info101 = info101; break; - case 100: - init_srv_info_100(&ctr->srv.sv100, 500, global_myname()); + } + case 100: { + struct srvsvc_NetSrvInfo100 *info100; + + info100 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo100); + if (!info100) { + return WERR_NOMEM; + } + + init_srvsvc_NetSrvInfo100(info100, + PLATFORM_ID_NT, + global_myname()); + r->out.info->info100 = info100; + break; + } default: status = WERR_UNKNOWN_LEVEL; break; } - /* set up the net server get info structure */ - init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status); - - DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__)); - return r_u->status; + return status; } /******************************************************************* @@ -2548,12 +2574,6 @@ WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r) { p->rng_fault_state = True; -- cgit From 640f53fe5bd989c57365e6ca85be29d2441c4b99 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:11:53 +0100 Subject: Use rpccli_srvsvc_NetSrvGetInfo() in rpcclient. Guenther (This used to be commit 4a74f1e8d2c45574973fc4c0ce4fbc9a843afaa0) --- source3/rpcclient/cmd_srvsvc.c | 78 ++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 572609981d..4b3601a5ff 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -130,51 +130,37 @@ static char *get_server_type_str(uint32 type) return typestr; } -static void display_server(char *sname, uint32 type, const char *comment) +static void display_server(const char *sname, uint32 type, const char *comment) { printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type), comment); } -static void display_srv_info_101(SRV_INFO_101 *sv101) +static void display_srv_info_101(struct srvsvc_NetSrvInfo101 *r) { - fstring name; - fstring comment; + display_server(r->server_name, r->server_type, r->comment); - unistr2_to_ascii(name, &sv101->uni_name, sizeof(name)); - unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment)); - - display_server(name, sv101->srv_type, comment); - - printf("\tplatform_id :\t%d\n", sv101->platform_id); - printf("\tos version :\t%d.%d\n", sv101->ver_major, - sv101->ver_minor); - - printf("\tserver type :\t0x%x\n", sv101->srv_type); + printf("\tplatform_id :\t%d\n", r->platform_id); + printf("\tos version :\t%d.%d\n", + r->version_major, r->version_minor); + printf("\tserver type :\t0x%x\n", r->server_type); } -static void display_srv_info_102(SRV_INFO_102 *sv102) +static void display_srv_info_102(struct srvsvc_NetSrvInfo102 *r) { - fstring name; - fstring comment; - fstring usr_path; - - unistr2_to_ascii(name, &sv102->uni_name, sizeof(name)); - unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment)); - unistr2_to_ascii(usr_path, &sv102->uni_usr_path, sizeof(usr_path)); - - display_server(name, sv102->srv_type, comment); - - printf("\tplatform_id :\t%d\n", sv102->platform_id); - printf("\tos version :\t%d.%d\n", sv102->ver_major, - sv102->ver_minor); - - printf("\tusers :\t%x\n", sv102->users); - printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden); - printf("\tannounce, delta :\t%d, %d\n", sv102->announce, - sv102->ann_delta); - printf("\tlicenses :\t%d\n", sv102->licenses); - printf("\tuser path :\t%s\n", usr_path); + display_server(r->server_name, r->server_type, r->comment); + + printf("\tplatform_id :\t%d\n", r->platform_id); + printf("\tos version :\t%d.%d\n", + r->version_major, r->version_minor); + printf("\tserver type :\t0x%x\n", r->server_type); + + printf("\tusers :\t%x\n", r->users); + printf("\tdisc, hidden :\t%x, %x\n", r->disc, r->hidden); + printf("\tannounce, delta :\t%d, %d\n", r->announce, + r->anndelta); + printf("\tlicenses :\t%d\n", r->licenses); + printf("\tuser path :\t%s\n", r->userpath); } /* Server query info */ @@ -183,8 +169,10 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, int argc, const char **argv) { uint32 info_level = 101; - SRV_INFO_CTR ctr; + union srvsvc_NetSrvInfo info; WERROR result; + NTSTATUS status; + const char *server_name; if (argc > 2) { printf("Usage: %s [infolevel]\n", argv[0]); @@ -194,8 +182,18 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, if (argc == 2) info_level = atoi(argv[1]); - result = rpccli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level, - &ctr); + server_name = talloc_asprintf_strupper_m(mem_ctx, "\\\\%s", + cli->cli->desthost); + W_ERROR_HAVE_NO_MEMORY(server_name); + + status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx, + server_name, + info_level, + &info, + &result); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } if (!W_ERROR_IS_OK(result)) { goto done; @@ -205,10 +203,10 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, switch (info_level) { case 101: - display_srv_info_101(&ctr.srv.sv101); + display_srv_info_101(info.info101); break; case 102: - display_srv_info_102(&ctr.srv.sv102); + display_srv_info_102(info.info102); break; default: printf("unsupported info level %d\n", info_level); -- cgit From 986005db133c6f0449b28251b7a765e22d667933 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:26:27 +0100 Subject: Remove unused marshalling for SRV_NET_SRV_GET_INFO. Guenther (This used to be commit 53a7e9b07d07d3e9d21360dee35fee27b46929b3) --- source3/include/rpc_srvsvc.h | 18 ----- source3/rpc_client/cli_srvsvc.c | 34 --------- source3/rpc_parse/parse_srv.c | 155 ---------------------------------------- 3 files changed, 207 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_srvsvc.h b/source3/include/rpc_srvsvc.h index 097c0d4348..ad9b547d41 100644 --- a/source3/include/rpc_srvsvc.h +++ b/source3/include/rpc_srvsvc.h @@ -747,24 +747,6 @@ typedef struct srv_info_ctr_info } SRV_INFO_CTR; -/* SRV_Q_NET_SRV_GET_INFO */ -typedef struct q_net_srv_get_info -{ - uint32 ptr_srv_name; - UNISTR2 uni_srv_name; /* "\\server" */ - uint32 switch_value; - -} SRV_Q_NET_SRV_GET_INFO; - -/* SRV_R_NET_SRV_GET_INFO */ -typedef struct r_net_srv_get_info -{ - SRV_INFO_CTR *ctr; - - WERROR status; /* return status */ - -} SRV_R_NET_SRV_GET_INFO; - /* SRV_Q_NET_SRV_SET_INFO */ typedef struct q_net_srv_set_info { diff --git a/source3/rpc_client/cli_srvsvc.c b/source3/rpc_client/cli_srvsvc.c index e5d9b4cdad..02e52b3a5a 100644 --- a/source3/rpc_client/cli_srvsvc.c +++ b/source3/rpc_client/cli_srvsvc.c @@ -24,40 +24,6 @@ #include "includes.h" -WERROR rpccli_srvsvc_net_srv_get_info(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - uint32 switch_value, SRV_INFO_CTR *ctr) -{ - prs_struct qbuf, rbuf; - SRV_Q_NET_SRV_GET_INFO q; - SRV_R_NET_SRV_GET_INFO r; - WERROR result = W_ERROR(ERRgeneral); - fstring server; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialise input parameters */ - - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); - strupper_m(server); - - init_srv_q_net_srv_get_info(&q, server, switch_value); - r.ctr = ctr; - - /* Marshall data and send request */ - - CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SRV_GET_INFO, - q, r, - qbuf, rbuf, - srv_io_q_net_srv_get_info, - srv_io_r_net_srv_get_info, - WERR_GENERAL_FAILURE); - - result = r.status; - return result; -} - WERROR rpccli_srvsvc_net_share_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 info_level, SRV_SHARE_INFO_CTR *ctr, int preferred_len, ENUM_HND *hnd) diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c index 954aa80600..8561e16428 100644 --- a/source3/rpc_parse/parse_srv.c +++ b/source3/rpc_parse/parse_srv.c @@ -2618,18 +2618,6 @@ bool srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_stru return True; } -/******************************************************************* - Inits a SRV_INFO_100 structure. - ********************************************************************/ - -void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name) -{ - DEBUG(5,("init_srv_info_100\n")); - - sv100->platform_id = platform_id; - init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name); -} - /******************************************************************* Reads or writes a SRV_INFO_101 structure. ********************************************************************/ @@ -2656,25 +2644,6 @@ static bool srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *p return True; } - -/******************************************************************* - Inits a SRV_INFO_101 structure. - ********************************************************************/ - -void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name, - uint32 ver_major, uint32 ver_minor, - uint32 srv_type, const char *comment) -{ - DEBUG(5,("init_srv_info_101\n")); - - sv101->platform_id = platform_id; - init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name); - sv101->ver_major = ver_major; - sv101->ver_minor = ver_minor; - sv101->srv_type = srv_type; - init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment); -} - /******************************************************************* Reads or writes a SRV_INFO_101 structure. ********************************************************************/ @@ -2714,41 +2683,6 @@ static bool srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *p return True; } -/******************************************************************* - Inits a SRV_INFO_102 structure. - ********************************************************************/ - -void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name, - const char *comment, uint32 ver_major, uint32 ver_minor, - uint32 srv_type, uint32 users, uint32 disc, uint32 hidden, - uint32 announce, uint32 ann_delta, uint32 licenses, - const char *usr_path) -{ - DEBUG(5,("init_srv_info_102\n")); - - sv102->platform_id = platform_id; - init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name); - sv102->ver_major = ver_major; - sv102->ver_minor = ver_minor; - sv102->srv_type = srv_type; - init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment); - - /* same as 101 up to here */ - - sv102->users = users; - sv102->disc = disc; - sv102->hidden = hidden; - sv102->announce = announce; - sv102->ann_delta = ann_delta; - sv102->licenses = licenses; - init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path); -} - - -/******************************************************************* - Reads or writes a SRV_INFO_102 structure. - ********************************************************************/ - static bool srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth) { if (sv102 == NULL) @@ -2850,71 +2784,6 @@ static bool srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, return True; } -/******************************************************************* - Inits a SRV_Q_NET_SRV_GET_INFO structure. - ********************************************************************/ - -void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv, - const char *server_name, uint32 switch_value) -{ - DEBUG(5,("init_srv_q_net_srv_get_info\n")); - - init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name); - - srv->switch_value = switch_value; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value)) - return False; - - return True; -} - -/******************************************************************* - Inits a SRV_R_NET_SRV_GET_INFO structure. - ********************************************************************/ - -void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv, - uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status) -{ - DEBUG(5,("init_srv_r_net_srv_get_info\n")); - - srv->ctr = ctr; - - if (W_ERROR_IS_OK(status)) { - srv->ctr->switch_value = switch_value; - srv->ctr->ptr_srv_ctr = 1; - } else { - srv->ctr->switch_value = 0; - srv->ctr->ptr_srv_ctr = 0; - } - - srv->status = status; -} - /******************************************************************* Inits a SRV_R_NET_SRV_SET_INFO structure. ********************************************************************/ @@ -2965,30 +2834,6 @@ bool srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, return True; } -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -bool srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - /******************************************************************* Reads or writes a structure. ********************************************************************/ -- cgit From 93cb719837bc7247f2705c408cdde5a4d578081b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:47:01 +0100 Subject: Fix IDL for srvsvc_NetSrvSetInfo(). Guenther (This used to be commit 024021daabe825bc7a033951aa1073ab76bd34aa) --- source3/librpc/idl/srvsvc.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/srvsvc.idl b/source3/librpc/idl/srvsvc.idl index 2f23fd1e70..885de1881c 100644 --- a/source3/librpc/idl/srvsvc.idl +++ b/source3/librpc/idl/srvsvc.idl @@ -1120,7 +1120,7 @@ import "security.idl", "svcctl.idl"; WERROR srvsvc_NetSrvSetInfo( [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] uint32 level, - [in,switch_is(level)] srvsvc_NetSrvInfo info, + [in,ref,switch_is(level)] srvsvc_NetSrvInfo *info, [in,out,unique] uint32 *parm_error ); -- cgit From 05ea7555c169220850f723f3cfa5cfacca5e556f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:47:28 +0100 Subject: Re-run make idl. Guenther (This used to be commit ea03cb92c481b9bb47d2a4e133cf830acb0f22a3) --- source3/librpc/gen_ndr/cli_srvsvc.c | 2 +- source3/librpc/gen_ndr/cli_srvsvc.h | 2 +- source3/librpc/gen_ndr/ndr_srvsvc.c | 25 +++++++++++++++++++------ source3/librpc/gen_ndr/srvsvc.h | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_srvsvc.c b/source3/librpc/gen_ndr/cli_srvsvc.c index 2b1d050a14..d6bfbb4e66 100644 --- a/source3/librpc/gen_ndr/cli_srvsvc.c +++ b/source3/librpc/gen_ndr/cli_srvsvc.c @@ -1169,7 +1169,7 @@ NTSTATUS rpccli_srvsvc_NetSrvSetInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_unc, uint32_t level, - union srvsvc_NetSrvInfo info, + union srvsvc_NetSrvInfo *info, uint32_t *parm_error, WERROR *werror) { diff --git a/source3/librpc/gen_ndr/cli_srvsvc.h b/source3/librpc/gen_ndr/cli_srvsvc.h index eb19db37bd..4df214f8e0 100644 --- a/source3/librpc/gen_ndr/cli_srvsvc.h +++ b/source3/librpc/gen_ndr/cli_srvsvc.h @@ -169,7 +169,7 @@ NTSTATUS rpccli_srvsvc_NetSrvSetInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_unc, uint32_t level, - union srvsvc_NetSrvInfo info, + union srvsvc_NetSrvInfo *info, uint32_t *parm_error, WERROR *werror); NTSTATUS rpccli_srvsvc_NetDiskEnum(struct rpc_pipe_client *cli, diff --git a/source3/librpc/gen_ndr/ndr_srvsvc.c b/source3/librpc/gen_ndr/ndr_srvsvc.c index 9b08ade4af..f447665fb8 100644 --- a/source3/librpc/gen_ndr/ndr_srvsvc.c +++ b/source3/librpc/gen_ndr/ndr_srvsvc.c @@ -16179,8 +16179,11 @@ static enum ndr_err_code ndr_push_srvsvc_NetSrvSetInfo(struct ndr_push *ndr, int NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server_unc, ndr_charset_length(r->in.server_unc, CH_UTF16), sizeof(uint16_t), CH_UTF16)); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.info, r->in.level)); - NDR_CHECK(ndr_push_srvsvc_NetSrvInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + if (r->in.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_push_srvsvc_NetSrvInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.parm_error)); if (r->in.parm_error) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.parm_error)); @@ -16201,6 +16204,7 @@ static enum ndr_err_code ndr_pull_srvsvc_NetSrvSetInfo(struct ndr_pull *ndr, int uint32_t _ptr_server_unc; uint32_t _ptr_parm_error; TALLOC_CTX *_mem_save_server_unc_0; + TALLOC_CTX *_mem_save_info_0; TALLOC_CTX *_mem_save_parm_error_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -16224,8 +16228,14 @@ static enum ndr_err_code ndr_pull_srvsvc_NetSrvSetInfo(struct ndr_pull *ndr, int NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_unc_0, 0); } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.info, r->in.level)); - NDR_CHECK(ndr_pull_srvsvc_NetSrvInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_srvsvc_NetSrvInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_parm_error)); if (_ptr_parm_error) { NDR_PULL_ALLOC(ndr, r->in.parm_error); @@ -16274,8 +16284,11 @@ _PUBLIC_ void ndr_print_srvsvc_NetSrvSetInfo(struct ndr_print *ndr, const char * } ndr->depth--; ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_set_switch_value(ndr, &r->in.info, r->in.level); - ndr_print_srvsvc_NetSrvInfo(ndr, "info", &r->in.info); + ndr_print_ptr(ndr, "info", r->in.info); + ndr->depth++; + ndr_print_set_switch_value(ndr, r->in.info, r->in.level); + ndr_print_srvsvc_NetSrvInfo(ndr, "info", r->in.info); + ndr->depth--; ndr_print_ptr(ndr, "parm_error", r->in.parm_error); ndr->depth++; if (r->in.parm_error) { diff --git a/source3/librpc/gen_ndr/srvsvc.h b/source3/librpc/gen_ndr/srvsvc.h index 6e6c7829a0..0b3e405ee6 100644 --- a/source3/librpc/gen_ndr/srvsvc.h +++ b/source3/librpc/gen_ndr/srvsvc.h @@ -1371,7 +1371,7 @@ struct srvsvc_NetSrvSetInfo { struct { const char *server_unc;/* [unique,charset(UTF16)] */ uint32_t level; - union srvsvc_NetSrvInfo info;/* [switch_is(level)] */ + union srvsvc_NetSrvInfo *info;/* [ref,switch_is(level)] */ uint32_t *parm_error;/* [unique] */ } in; -- cgit From eb44792a22f6889edcaa0760ab4ca86e9313122f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:40:25 +0100 Subject: Use pidl for _srvsvc_NetSrvSetInfo(). Guenther (This used to be commit 75b0bbf790da44c45c679c374dbe09f288f3fb8c) --- source3/rpc_server/srv_srvsvc.c | 20 +------------------- source3/rpc_server/srv_srvsvc_nt.c | 19 ++++++------------- 2 files changed, 7 insertions(+), 32 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 0e97ee3460..a7e7be4a04 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -61,25 +61,7 @@ static bool api_srv_net_srv_get_info(pipes_struct *p) static bool api_srv_net_srv_set_info(pipes_struct *p) { - SRV_Q_NET_SRV_SET_INFO q_u; - SRV_R_NET_SRV_SET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server set info */ - if (!srv_io_q_net_srv_set_info("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_srv_set_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_srv_set_info("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSRVSETINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ddb7e120d9..a3c9248ad2 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1328,22 +1328,21 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, } /******************************************************************* -net server set info + _srvsvc_NetSrvSetInfo ********************************************************************/ -WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) +WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, + struct srvsvc_NetSrvSetInfo *r) { WERROR status = WERR_OK; - DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__)); /* Set up the net server set info structure. */ - init_srv_r_net_srv_set_info(r_u, 0x0, status); + DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__)); - DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); - - return r_u->status; + return status; } /******************************************************************* @@ -2574,12 +2573,6 @@ WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetDiskEnum(pipes_struct *p, struct srvsvc_NetDiskEnum *r) { p->rng_fault_state = True; -- cgit From 2b5d47a093f0329159fe3f16316fd55e3b49e1a5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:40:53 +0100 Subject: Remove unused marshalling for SRV_NET_SRV_SET_INFO. Guenther (This used to be commit a7aef18797407b1f451191647d4b0225ac838817) --- source3/include/rpc_srvsvc.h | 85 --------------- source3/rpc_parse/parse_srv.c | 238 ------------------------------------------ 2 files changed, 323 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_srvsvc.h b/source3/include/rpc_srvsvc.h index ad9b547d41..e6c538a041 100644 --- a/source3/include/rpc_srvsvc.h +++ b/source3/include/rpc_srvsvc.h @@ -683,91 +683,6 @@ typedef struct { WERROR status; } SRV_R_NET_FILE_ENUM; -/* SRV_INFO_100 */ -typedef struct srv_info_100_info -{ - uint32 platform_id; /* 0x500 */ - uint32 ptr_name; /* pointer to server name */ - - UNISTR2 uni_name; /* server name "server" */ - -} SRV_INFO_100; - -/* SRV_INFO_101 */ -typedef struct srv_info_101_info -{ - uint32 platform_id; /* 0x500 */ - uint32 ptr_name; /* pointer to server name */ - uint32 ver_major; /* 0x4 */ - uint32 ver_minor; /* 0x2 */ - uint32 srv_type; /* browse etc type */ - uint32 ptr_comment; /* pointer to server comment */ - - UNISTR2 uni_name; /* server name "server" */ - UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */ - -} SRV_INFO_101; - -/* SRV_INFO_102 */ -typedef struct srv_info_102_info -{ - uint32 platform_id; /* 0x500 */ - uint32 ptr_name; /* pointer to server name */ - uint32 ver_major; /* 0x4 */ - uint32 ver_minor; /* 0x2 */ - uint32 srv_type; /* browse etc type */ - uint32 ptr_comment; /* pointer to server comment */ - uint32 users; /* 0xffff ffff*/ - uint32 disc; /* 0xf */ - uint32 hidden; /* 0x0 */ - uint32 announce; /* 240 */ - uint32 ann_delta; /* 3000 */ - uint32 licenses; /* 0 */ - uint32 ptr_usr_path; /* pointer to user path */ - - UNISTR2 uni_name; /* server name "server" */ - UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */ - UNISTR2 uni_usr_path; /* "c:\" (eh?) */ - -} SRV_INFO_102; - - -/* SRV_INFO_CTR */ -typedef struct srv_info_ctr_info -{ - uint32 switch_value; /* switch value */ - uint32 ptr_srv_ctr; /* pointer to server info */ - union - { - SRV_INFO_102 sv102; /* server info level 102 */ - SRV_INFO_101 sv101; /* server info level 101 */ - SRV_INFO_100 sv100; /* server info level 100 */ - - } srv; - -} SRV_INFO_CTR; - -/* SRV_Q_NET_SRV_SET_INFO */ -typedef struct q_net_srv_set_info -{ - uint32 ptr_srv_name; - UNISTR2 uni_srv_name; /* "\\server" */ - uint32 switch_value; - - SRV_INFO_CTR *ctr; - -} SRV_Q_NET_SRV_SET_INFO; - - -/* SRV_R_NET_SRV_SET_INFO */ -typedef struct r_net_srv_set_info -{ - uint32 switch_value; /* switch value */ - - WERROR status; /* return status */ - -} SRV_R_NET_SRV_SET_INFO; - /* SRV_Q_NET_REMOTE_TOD */ typedef struct q_net_remote_tod { diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c index 8561e16428..136aed5f16 100644 --- a/source3/rpc_parse/parse_srv.c +++ b/source3/rpc_parse/parse_srv.c @@ -2618,244 +2618,6 @@ bool srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_stru return True; } -/******************************************************************* - Reads or writes a SRV_INFO_101 structure. - ********************************************************************/ - -static bool srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth) -{ - if (sv100 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_100"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv100->ptr_name)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv100->uni_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a SRV_INFO_101 structure. - ********************************************************************/ - -static bool srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth) -{ - if (sv101 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_101"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv101->ptr_name)) - return False; - if(!prs_uint32("ver_major ", ps, depth, &sv101->ver_major)) - return False; - if(!prs_uint32("ver_minor ", ps, depth, &sv101->ver_minor)) - return False; - if(!prs_uint32("srv_type ", ps, depth, &sv101->srv_type)) - return False; - if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv101->uni_name, True, ps, depth)) - return False; - if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth)) - return False; - - return True; -} - -static bool srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth) -{ - if (sv102 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info102"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv102->ptr_name)) - return False; - if(!prs_uint32("ver_major ", ps, depth, &sv102->ver_major)) - return False; - if(!prs_uint32("ver_minor ", ps, depth, &sv102->ver_minor)) - return False; - if(!prs_uint32("srv_type ", ps, depth, &sv102->srv_type)) - return False; - if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment)) - return False; - - /* same as 101 up to here */ - - if(!prs_uint32("users ", ps, depth, &sv102->users)) - return False; - if(!prs_uint32("disc ", ps, depth, &sv102->disc)) - return False; - if(!prs_uint32("hidden ", ps, depth, &sv102->hidden)) - return False; - if(!prs_uint32("announce ", ps, depth, &sv102->announce)) - return False; - if(!prs_uint32("ann_delta ", ps, depth, &sv102->ann_delta)) - return False; - if(!prs_uint32("licenses ", ps, depth, &sv102->licenses)) - return False; - if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv102->uni_name, True, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a SRV_INFO_102 structure. - ********************************************************************/ - -static bool srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth) -{ - if (ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_ctr"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr)) - return False; - - if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) { - switch (ctr->switch_value) { - case 100: - if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth)) - return False; - break; - case 101: - if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth)) - return False; - break; - case 102: - if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth)) - return False; - break; - default: - DEBUG(5,("%s no server info at switch_value %d\n", - tab_depth(5,depth), ctr->switch_value)); - break; - } - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a SRV_R_NET_SRV_SET_INFO structure. - ********************************************************************/ - -void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv, - uint32 switch_value, WERROR status) -{ - DEBUG(5,("init_srv_r_net_srv_set_info\n")); - - srv->switch_value = switch_value; - srv->status = status; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -bool srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value)) - return False; - - if (UNMARSHALLING(ps)) { - q_n->ctr = PRS_ALLOC_MEM(ps, SRV_INFO_CTR, 1); - - if (!q_n->ctr) - return False; - } - - if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -bool srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - /******************************************************************* Reads or writes a structure. ********************************************************************/ -- cgit From d1ef6699c0f9648dd76ac5230694e03a574cd48d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 09:53:33 +0100 Subject: Fix rpccli_srvsvc_NetSrvSetInfo call in libnetapi. Guenther (This used to be commit 5911529205ca69c438e0782c07ee4fe5aa95de62) --- source3/lib/netapi/serverinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index 7fa166e411..54512950bf 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -268,7 +268,7 @@ static WERROR NetServerSetInfoRemote(struct libnetapi_ctx *ctx, status = rpccli_srvsvc_NetSrvSetInfo(pipe_cli, ctx, server_name, level, - info, + &info, parm_error, &werr); if (!NT_STATUS_IS_OK(status)) { -- cgit From 9e10620f85bdbe6a01af3ab18e3ee4215a574522 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:50:23 +0100 Subject: Fix IDL for srvsvc_NetShareSetInfo(). Guenther (This used to be commit 40d780f2e75c3a62853568a149a1229828ac9da4) --- source3/librpc/idl/srvsvc.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/srvsvc.idl b/source3/librpc/idl/srvsvc.idl index 885de1881c..1682fde5d6 100644 --- a/source3/librpc/idl/srvsvc.idl +++ b/source3/librpc/idl/srvsvc.idl @@ -577,7 +577,7 @@ import "security.idl", "svcctl.idl"; [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 share_name[], [in] uint32 level, - [in,switch_is(level)] srvsvc_NetShareInfo info, + [in,ref,switch_is(level)] srvsvc_NetShareInfo *info, [in,out,unique] uint32 *parm_error ); -- cgit From cc4cd73dc5f2db93ec9e1a87a31e0ce4fcca38ed Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:50:51 +0100 Subject: Re-run make idl. Guenther (This used to be commit 4ace93c3df280558ef75b6619297e367ac9713c9) --- source3/librpc/gen_ndr/cli_srvsvc.c | 2 +- source3/librpc/gen_ndr/cli_srvsvc.h | 2 +- source3/librpc/gen_ndr/ndr_srvsvc.c | 25 +++++++++++++++++++------ source3/librpc/gen_ndr/srvsvc.h | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_srvsvc.c b/source3/librpc/gen_ndr/cli_srvsvc.c index d6bfbb4e66..768855743c 100644 --- a/source3/librpc/gen_ndr/cli_srvsvc.c +++ b/source3/librpc/gen_ndr/cli_srvsvc.c @@ -923,7 +923,7 @@ NTSTATUS rpccli_srvsvc_NetShareSetInfo(struct rpc_pipe_client *cli, const char *server_unc, const char *share_name, uint32_t level, - union srvsvc_NetShareInfo info, + union srvsvc_NetShareInfo *info, uint32_t *parm_error, WERROR *werror) { diff --git a/source3/librpc/gen_ndr/cli_srvsvc.h b/source3/librpc/gen_ndr/cli_srvsvc.h index 4df214f8e0..c383b897e6 100644 --- a/source3/librpc/gen_ndr/cli_srvsvc.h +++ b/source3/librpc/gen_ndr/cli_srvsvc.h @@ -138,7 +138,7 @@ NTSTATUS rpccli_srvsvc_NetShareSetInfo(struct rpc_pipe_client *cli, const char *server_unc, const char *share_name, uint32_t level, - union srvsvc_NetShareInfo info, + union srvsvc_NetShareInfo *info, uint32_t *parm_error, WERROR *werror); NTSTATUS rpccli_srvsvc_NetShareDel(struct rpc_pipe_client *cli, diff --git a/source3/librpc/gen_ndr/ndr_srvsvc.c b/source3/librpc/gen_ndr/ndr_srvsvc.c index f447665fb8..c3f74cc11f 100644 --- a/source3/librpc/gen_ndr/ndr_srvsvc.c +++ b/source3/librpc/gen_ndr/ndr_srvsvc.c @@ -15656,8 +15656,11 @@ static enum ndr_err_code ndr_push_srvsvc_NetShareSetInfo(struct ndr_push *ndr, i NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.share_name, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.share_name, ndr_charset_length(r->in.share_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.info, r->in.level)); - NDR_CHECK(ndr_push_srvsvc_NetShareInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + if (r->in.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_push_srvsvc_NetShareInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.parm_error)); if (r->in.parm_error) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.parm_error)); @@ -15678,6 +15681,7 @@ static enum ndr_err_code ndr_pull_srvsvc_NetShareSetInfo(struct ndr_pull *ndr, i uint32_t _ptr_server_unc; uint32_t _ptr_parm_error; TALLOC_CTX *_mem_save_server_unc_0; + TALLOC_CTX *_mem_save_info_0; TALLOC_CTX *_mem_save_parm_error_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -15708,8 +15712,14 @@ static enum ndr_err_code ndr_pull_srvsvc_NetShareSetInfo(struct ndr_pull *ndr, i NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.share_name), sizeof(uint16_t))); NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.share_name, ndr_get_array_length(ndr, &r->in.share_name), sizeof(uint16_t), CH_UTF16)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.info, r->in.level)); - NDR_CHECK(ndr_pull_srvsvc_NetShareInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_srvsvc_NetShareInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_parm_error)); if (_ptr_parm_error) { NDR_PULL_ALLOC(ndr, r->in.parm_error); @@ -15759,8 +15769,11 @@ _PUBLIC_ void ndr_print_srvsvc_NetShareSetInfo(struct ndr_print *ndr, const char ndr->depth--; ndr_print_string(ndr, "share_name", r->in.share_name); ndr_print_uint32(ndr, "level", r->in.level); - ndr_print_set_switch_value(ndr, &r->in.info, r->in.level); - ndr_print_srvsvc_NetShareInfo(ndr, "info", &r->in.info); + ndr_print_ptr(ndr, "info", r->in.info); + ndr->depth++; + ndr_print_set_switch_value(ndr, r->in.info, r->in.level); + ndr_print_srvsvc_NetShareInfo(ndr, "info", r->in.info); + ndr->depth--; ndr_print_ptr(ndr, "parm_error", r->in.parm_error); ndr->depth++; if (r->in.parm_error) { diff --git a/source3/librpc/gen_ndr/srvsvc.h b/source3/librpc/gen_ndr/srvsvc.h index 0b3e405ee6..988d21adc4 100644 --- a/source3/librpc/gen_ndr/srvsvc.h +++ b/source3/librpc/gen_ndr/srvsvc.h @@ -1299,7 +1299,7 @@ struct srvsvc_NetShareSetInfo { const char *server_unc;/* [unique,charset(UTF16)] */ const char *share_name;/* [charset(UTF16)] */ uint32_t level; - union srvsvc_NetShareInfo info;/* [switch_is(level)] */ + union srvsvc_NetShareInfo *info;/* [ref,switch_is(level)] */ uint32_t *parm_error;/* [unique] */ } in; -- cgit From c6c67005a820fd20afd0674d9b8f529450f0e1ae Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 01:26:39 +0100 Subject: Use pidl for _srvsvc_NetShareSetInfo(). Guenther (This used to be commit 9bfa77edc68a887972b609bfb0aee8bbbc89ce04) --- source3/rpc_server/srv_srvsvc.c | 23 +---------- source3/rpc_server/srv_srvsvc_nt.c | 82 ++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 66 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index a7e7be4a04..0d50bccef0 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -270,28 +270,7 @@ static bool api_srv_net_share_get_info(pipes_struct *p) static bool api_srv_net_share_set_info(pipes_struct *p) { - SRV_Q_NET_SHARE_SET_INFO q_u; - SRV_R_NET_SHARE_SET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server set info. */ - if(!srv_io_q_net_share_set_info("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_set_info: Failed to unmarshall SRV_Q_NET_SHARE_SET_INFO.\n")); - return False; - } - - r_u.status = _srv_net_share_set_info(p, &q_u, &r_u); - - if(!srv_io_r_net_share_set_info("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_set_info: Failed to marshall SRV_R_NET_SHARE_SET_INFO.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHARESETINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a3c9248ad2..75c262a7a6 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1564,16 +1564,17 @@ char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) } /******************************************************************* - Net share set info. Modify share details. + _srvsvc_NetShareSetInfo. Modify share details. ********************************************************************/ -WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) +WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, + struct srvsvc_NetShareSetInfo *r) { struct current_user user; char *command = NULL; char *share_name = NULL; char *comment = NULL; - char *pathname = NULL; + const char *pathname = NULL; int type; int snum; int ret; @@ -1583,15 +1584,16 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S bool is_disk_op = False; int max_connections = 0; TALLOC_CTX *ctx = p->mem_ctx; + union srvsvc_NetShareInfo *info = r->in.info; - DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__)); - share_name = unistr2_to_ascii_talloc(ctx, &q_u->uni_share_name); + share_name = talloc_strdup(p->mem_ctx, r->in.share_name); if (!share_name) { - return WERR_NET_NAME_NOT_FOUND; + return WERR_NOMEM; } - r_u->parm_error = 0; + *r->out.parm_error = 0; if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) @@ -1619,44 +1621,39 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if ( user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - switch (q_u->info_level) { + switch (r->in.level) { case 1: pathname = talloc_strdup(ctx, lp_pathname(snum)); - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_remark); - type = q_u->info.share.info2.info_2.type; + comment = talloc_strdup(ctx, info->info2->comment); + type = info->info2->type; psd = NULL; break; case 2: - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_remark); - pathname = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_path); - type = q_u->info.share.info2.info_2.type; - max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; + comment = talloc_strdup(ctx, info->info2->comment); + pathname = info->info2->path; + type = info->info2->type; + max_connections = (info->info2->max_users == 0xffffffff) ? + 0 : info->info2->max_users; psd = NULL; break; #if 0 /* not supported on set but here for completeness */ case 501: - unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment)); - type = q_u->info.share.info501.info_501.type; + comment = talloc_strdup(ctx, info->info501->comment); + type = info->info501->type; psd = NULL; break; #endif case 502: - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info502.info_502_str.uni_remark); - pathname = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info502.info_502_str.uni_path); - type = q_u->info.share.info502.info_502.type; - psd = q_u->info.share.info502.info_502_str.sd; + comment = talloc_strdup(ctx, info->info502->comment); + pathname = info->info502->path; + type = info->info502->type; + psd = info->info502->sd; map_generic_share_sd_bits(psd); break; case 1004: pathname = talloc_strdup(ctx, lp_pathname(snum)); - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info1004.info_1004_str.uni_remark); + comment = talloc_strdup(ctx, info->info1004->comment); type = STYPE_DISKTREE; break; case 1005: @@ -1664,12 +1661,12 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S user, so we must compare it to see if it's what is set in smb.conf, so that we can contine other ops like setting ACLs on a share */ - if (((q_u->info.share.info1005.share_info_flags & + if (((info->info1005->dfs_flags & SHARE_1005_CSC_POLICY_MASK) >> SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum)) return WERR_OK; else { - DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n")); + DEBUG(3, ("_srvsvc_NetShareSetInfo: client is trying to change csc policy from the network; must be done with smb.conf\n")); return WERR_ACCESS_DENIED; } case 1006: @@ -1678,12 +1675,13 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S case 1501: pathname = talloc_strdup(ctx, lp_pathname(snum)); comment = talloc_strdup(ctx, lp_comment(snum)); - psd = q_u->info.share.info1501.sdb->sd; + psd = info->info1501->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; break; default: - DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); + DEBUG(5,("_srvsvc_NetShareSetInfo: unsupported switch value %d\n", + r->in.level)); return WERR_UNKNOWN_LEVEL; } @@ -1702,7 +1700,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S string_replace(comment, '"', ' '); } - DEBUG(10,("_srv_net_share_set_info: change share command = %s\n", + DEBUG(10,("_srvsvc_NetShareSetInfo: change share command = %s\n", lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); /* Only call modify function if something changed. */ @@ -1710,7 +1708,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) || (lp_max_connections(snum) != max_connections)) { if (!lp_change_share_cmd() || !*lp_change_share_cmd()) { - DEBUG(10,("_srv_net_share_set_info: No change share command\n")); + DEBUG(10,("_srvsvc_NetShareSetInfo: No change share command\n")); return WERR_ACCESS_DENIED; } @@ -1726,7 +1724,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_NOMEM; } - DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); + DEBUG(10,("_srvsvc_NetShareSetInfo: Running [%s]\n", command )); /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ @@ -1745,14 +1743,16 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /********* END SeDiskOperatorPrivilege BLOCK *********/ - DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); + DEBUG(3,("_srvsvc_NetShareSetInfo: Running [%s] returned (%d)\n", + command, ret )); TALLOC_FREE(command); if ( ret != 0 ) return WERR_ACCESS_DENIED; } else { - DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); + DEBUG(10,("_srvsvc_NetShareSetInfo: No change to share name (%s)\n", + share_name )); } /* Replace SD if changed. */ @@ -1764,12 +1764,12 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (old_sd && !sec_desc_equal(old_sd, psd)) { if (!set_share_security(share_name, psd)) - DEBUG(0,("_srv_net_share_set_info: Failed to change security info in share %s.\n", + DEBUG(0,("_srvsvc_NetShareSetInfo: Failed to change security info in share %s.\n", share_name )); } } - DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__)); return WERR_OK; } @@ -2549,12 +2549,6 @@ WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) { p->rng_fault_state = True; -- cgit From a7b00be7666d5423cc4b41dbe8ecd5667f41d5bb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 10:32:04 +0100 Subject: Fix IDL for srvsvc_NetRemoteTOD(). Guenther (This used to be commit cc3ec6ac65eab8c955cd17f3d4bdf58d6fcc22be) --- source3/librpc/idl/srvsvc.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/librpc/idl/srvsvc.idl b/source3/librpc/idl/srvsvc.idl index 1682fde5d6..4ad7bebdbd 100644 --- a/source3/librpc/idl/srvsvc.idl +++ b/source3/librpc/idl/srvsvc.idl @@ -1299,7 +1299,7 @@ import "security.idl", "svcctl.idl"; /* Function: 0x1c */ WERROR srvsvc_NetRemoteTOD( [in,unique] [string,charset(UTF16)] uint16 *server_unc, - [out,unique] srvsvc_NetRemoteTODInfo *info + [out,ref] srvsvc_NetRemoteTODInfo **info ); /**************************/ -- cgit From 91714e0429a667ca19aec8ba4cdd5e7722452979 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 10:32:55 +0100 Subject: Re-run make idl. Guenther (This used to be commit b9abb783200f6c14543c3b884b9393797cfa8dbd) --- source3/librpc/gen_ndr/cli_srvsvc.c | 6 ++---- source3/librpc/gen_ndr/cli_srvsvc.h | 2 +- source3/librpc/gen_ndr/ndr_srvsvc.c | 39 +++++++++++++++++++++++++------------ source3/librpc/gen_ndr/srv_srvsvc.c | 2 +- source3/librpc/gen_ndr/srvsvc.h | 2 +- 5 files changed, 32 insertions(+), 19 deletions(-) (limited to 'source3') diff --git a/source3/librpc/gen_ndr/cli_srvsvc.c b/source3/librpc/gen_ndr/cli_srvsvc.c index 768855743c..3624fb0dd4 100644 --- a/source3/librpc/gen_ndr/cli_srvsvc.c +++ b/source3/librpc/gen_ndr/cli_srvsvc.c @@ -1486,7 +1486,7 @@ NTSTATUS rpccli_srvsvc_NetTransportDel(struct rpc_pipe_client *cli, NTSTATUS rpccli_srvsvc_NetRemoteTOD(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_unc, - struct srvsvc_NetRemoteTODInfo *info, + struct srvsvc_NetRemoteTODInfo **info, WERROR *werror) { struct srvsvc_NetRemoteTOD r; @@ -1519,9 +1519,7 @@ NTSTATUS rpccli_srvsvc_NetRemoteTOD(struct rpc_pipe_client *cli, } /* Return variables */ - if (info && r.out.info) { - *info = *r.out.info; - } + *info = *r.out.info; /* Return result */ if (werror) { diff --git a/source3/librpc/gen_ndr/cli_srvsvc.h b/source3/librpc/gen_ndr/cli_srvsvc.h index c383b897e6..4f52600a99 100644 --- a/source3/librpc/gen_ndr/cli_srvsvc.h +++ b/source3/librpc/gen_ndr/cli_srvsvc.h @@ -213,7 +213,7 @@ NTSTATUS rpccli_srvsvc_NetTransportDel(struct rpc_pipe_client *cli, NTSTATUS rpccli_srvsvc_NetRemoteTOD(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_unc, - struct srvsvc_NetRemoteTODInfo *info, + struct srvsvc_NetRemoteTODInfo **info, WERROR *werror); NTSTATUS rpccli_srvsvc_NetSetServiceBits(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_srvsvc.c b/source3/librpc/gen_ndr/ndr_srvsvc.c index c3f74cc11f..22a04f86f8 100644 --- a/source3/librpc/gen_ndr/ndr_srvsvc.c +++ b/source3/librpc/gen_ndr/ndr_srvsvc.c @@ -17027,9 +17027,12 @@ static enum ndr_err_code ndr_push_srvsvc_NetRemoteTOD(struct ndr_push *ndr, int } } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); - if (r->out.info) { - NDR_CHECK(ndr_push_srvsvc_NetRemoteTODInfo(ndr, NDR_SCALARS, r->out.info)); + if (r->out.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.info)); + if (*r->out.info) { + NDR_CHECK(ndr_push_srvsvc_NetRemoteTODInfo(ndr, NDR_SCALARS, *r->out.info)); } NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } @@ -17042,6 +17045,7 @@ static enum ndr_err_code ndr_pull_srvsvc_NetRemoteTOD(struct ndr_pull *ndr, int uint32_t _ptr_info; TALLOC_CTX *_mem_save_server_unc_0; TALLOC_CTX *_mem_save_info_0; + TALLOC_CTX *_mem_save_info_1; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -17063,20 +17067,28 @@ static enum ndr_err_code ndr_pull_srvsvc_NetRemoteTOD(struct ndr_pull *ndr, int NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server_unc, ndr_get_array_length(ndr, &r->in.server_unc), sizeof(uint16_t), CH_UTF16)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_unc_0, 0); } + NDR_PULL_ALLOC(ndr, r->out.info); + ZERO_STRUCTP(r->out.info); } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); if (_ptr_info) { - NDR_PULL_ALLOC(ndr, r->out.info); + NDR_PULL_ALLOC(ndr, *r->out.info); } else { - r->out.info = NULL; + *r->out.info = NULL; } - if (r->out.info) { - _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); - NDR_CHECK(ndr_pull_srvsvc_NetRemoteTODInfo(ndr, NDR_SCALARS, r->out.info)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + if (*r->out.info) { + _mem_save_info_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.info, 0); + NDR_CHECK(ndr_pull_srvsvc_NetRemoteTODInfo(ndr, NDR_SCALARS, *r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_1, 0); } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -17105,10 +17117,13 @@ _PUBLIC_ void ndr_print_srvsvc_NetRemoteTOD(struct ndr_print *ndr, const char *n ndr->depth++; ndr_print_ptr(ndr, "info", r->out.info); ndr->depth++; - if (r->out.info) { - ndr_print_srvsvc_NetRemoteTODInfo(ndr, "info", r->out.info); + ndr_print_ptr(ndr, "info", *r->out.info); + ndr->depth++; + if (*r->out.info) { + ndr_print_srvsvc_NetRemoteTODInfo(ndr, "info", *r->out.info); } ndr->depth--; + ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/srv_srvsvc.c b/source3/librpc/gen_ndr/srv_srvsvc.c index afd458765e..75e586c716 100644 --- a/source3/librpc/gen_ndr/srv_srvsvc.c +++ b/source3/librpc/gen_ndr/srv_srvsvc.c @@ -2225,7 +2225,7 @@ static bool api_srvsvc_NetRemoteTOD(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.info = talloc_zero(r, struct srvsvc_NetRemoteTODInfo); + r->out.info = talloc_zero(r, struct srvsvc_NetRemoteTODInfo *); if (r->out.info == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srvsvc.h b/source3/librpc/gen_ndr/srvsvc.h index 988d21adc4..cede81e837 100644 --- a/source3/librpc/gen_ndr/srvsvc.h +++ b/source3/librpc/gen_ndr/srvsvc.h @@ -1472,7 +1472,7 @@ struct srvsvc_NetRemoteTOD { } in; struct { - struct srvsvc_NetRemoteTODInfo *info;/* [unique] */ + struct srvsvc_NetRemoteTODInfo **info;/* [ref] */ WERROR result; } out; -- cgit From 78b20443c587d303aa33f594c746c38e2689004d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 10:34:45 +0100 Subject: Use pidl for _srvsvc_NetRemoteTOD(). Guenther (This used to be commit 2b4e0f0593c6378cdac4811ded830ca694afac9e) --- source3/rpc_client/init_srvsvc.c | 33 +++++++++++++++++++++++ source3/rpc_server/srv_srvsvc.c | 20 +------------- source3/rpc_server/srv_srvsvc_nt.c | 55 +++++++++++++++++--------------------- 3 files changed, 58 insertions(+), 50 deletions(-) (limited to 'source3') diff --git a/source3/rpc_client/init_srvsvc.c b/source3/rpc_client/init_srvsvc.c index a4ee54cb48..5e868ffd2b 100644 --- a/source3/rpc_client/init_srvsvc.c +++ b/source3/rpc_client/init_srvsvc.c @@ -84,3 +84,36 @@ void init_srvsvc_NetSrvInfo100(struct srvsvc_NetSrvInfo100 *r, r->platform_id = platform_id; r->server_name = server_name; } + +/******************************************************************* + inits a srvsvc_NetRemoteTODInfo structure + ********************************************************************/ + +void init_srvsvc_NetRemoteTODInfo(struct srvsvc_NetRemoteTODInfo *r, + uint32_t elapsed, + uint32_t msecs, + uint32_t hours, + uint32_t mins, + uint32_t secs, + uint32_t hunds, + int32_t ttimezone, + uint32_t tinterval, + uint32_t day, + uint32_t month, + uint32_t year, + uint32_t weekday) +{ + r->elapsed = elapsed; + r->msecs = msecs; + r->hours = hours; + r->mins = mins; + r->secs = secs; + r->hunds = hunds; + r->timezone = ttimezone; + r->tinterval = tinterval; + r->day = day; + r->month = month; + r->year = year; + r->weekday = weekday; +} + diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 0d50bccef0..41fc39baf7 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -369,25 +369,7 @@ static bool api_srv_net_share_del_sticky(pipes_struct *p) static bool api_srv_net_remote_tod(pipes_struct *p) { - SRV_Q_NET_REMOTE_TOD q_u; - SRV_R_NET_REMOTE_TOD r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if(!srv_io_q_net_remote_tod("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_remote_tod(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!srv_io_r_net_remote_tod("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETREMOTETOD); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 75c262a7a6..4efea33738 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2054,12 +2054,13 @@ WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_ } /******************************************************************* -time of day + _srvsvc_NetRemoteTOD ********************************************************************/ -WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) +WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, + struct srvsvc_NetRemoteTOD *r) { - TIME_OF_DAY_INFO *tod; + struct srvsvc_NetRemoteTODInfo *tod; struct tm *t; time_t unixdate = time(NULL); @@ -2068,37 +2069,35 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET uint32 zone = get_time_zone(unixdate)/60; - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__)); - if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) + if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetRemoteTODInfo)) ) return WERR_NOMEM; - r_u->tod = tod; - r_u->ptr_srv_tod = 0x1; - r_u->status = WERR_OK; + *r->out.info = tod; - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__)); t = gmtime(&unixdate); /* set up the */ - init_time_of_day_info(tod, - unixdate, - 0, - t->tm_hour, - t->tm_min, - t->tm_sec, - 0, - zone, - 10000, - t->tm_mday, - t->tm_mon + 1, - 1900+t->tm_year, - t->tm_wday); - - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + init_srvsvc_NetRemoteTODInfo(tod, + unixdate, + 0, + t->tm_hour, + t->tm_min, + t->tm_sec, + 0, + zone, + 10000, + t->tm_mday, + t->tm_mon + 1, + 1900+t->tm_year, + t->tm_wday); - return r_u->status; + DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__)); + + return WERR_OK; } /*********************************************************************************** @@ -2597,12 +2596,6 @@ WERROR _srvsvc_NetTransportDel(pipes_struct *p, struct srvsvc_NetTransportDel *r return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, struct srvsvc_NetSetServiceBits *r) { p->rng_fault_state = True; -- cgit From b0dad261add75789cbbbfed12ed1d3f25c3e2182 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 10:38:13 +0100 Subject: Use rpccli_srvsvc_NetRemoteTOD() in rpcclient. Guenther (This used to be commit 5e9d8cdc948b678e5aa6e04ee13635376b7306f5) --- source3/rpcclient/cmd_srvsvc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 4b3601a5ff..2e84f0498f 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -402,9 +402,10 @@ static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - TIME_OF_DAY_INFO tod; + struct srvsvc_NetRemoteTODInfo *tod = NULL; fstring srv_name_slash; WERROR result; + NTSTATUS status; if (argc > 1) { printf("Usage: %s\n", argv[0]); @@ -412,8 +413,14 @@ static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, } fstr_sprintf(srv_name_slash, "\\\\%s", cli->cli->desthost); - result = rpccli_srvsvc_net_remote_tod( - cli, mem_ctx, srv_name_slash, &tod); + status = rpccli_srvsvc_NetRemoteTOD(cli, mem_ctx, + srv_name_slash, + &tod, + &result); + if (!NT_STATUS_IS_OK(status)) { + result = ntstatus_to_werror(status); + goto done; + } if (!W_ERROR_IS_OK(result)) goto done; -- cgit From 1bdce8e5b5bffaa05f3741f22ab4dec3a7038094 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 10:40:52 +0100 Subject: Remove unused marshalling for SRV_NET_REMOTE_TOD. Guenther (This used to be commit 9f0ea1d727046fef4c23bcf1e71d10f33c93b00f) --- source3/include/rpc_srvsvc.h | 36 ----------- source3/rpc_client/cli_srvsvc.c | 33 ---------- source3/rpc_parse/parse_srv.c | 130 ---------------------------------------- 3 files changed, 199 deletions(-) (limited to 'source3') diff --git a/source3/include/rpc_srvsvc.h b/source3/include/rpc_srvsvc.h index e6c538a041..d0b25e4fad 100644 --- a/source3/include/rpc_srvsvc.h +++ b/source3/include/rpc_srvsvc.h @@ -683,42 +683,6 @@ typedef struct { WERROR status; } SRV_R_NET_FILE_ENUM; -/* SRV_Q_NET_REMOTE_TOD */ -typedef struct q_net_remote_tod -{ - uint32 ptr_srv_name; - UNISTR2 uni_srv_name; /* "\\server" */ - -} SRV_Q_NET_REMOTE_TOD; - -/* TIME_OF_DAY_INFO */ -typedef struct time_of_day_info -{ - uint32 elapsedt; - uint32 msecs; - uint32 hours; - uint32 mins; - uint32 secs; - uint32 hunds; - uint32 zone; - uint32 tintervals; - uint32 day; - uint32 month; - uint32 year; - uint32 weekday; - -} TIME_OF_DAY_INFO; - -/* SRV_R_NET_REMOTE_TOD */ -typedef struct r_net_remote_tod -{ - uint32 ptr_srv_tod; /* pointer to TOD */ - TIME_OF_DAY_INFO *tod; - - WERROR status; /* return status */ - -} SRV_R_NET_REMOTE_TOD; - /* SRV_Q_NET_FILE_QUERY_SECDESC */ typedef struct q_net_file_query_secdesc { diff --git a/source3/rpc_client/cli_srvsvc.c b/source3/rpc_client/cli_srvsvc.c index 02e52b3a5a..524678c122 100644 --- a/source3/rpc_client/cli_srvsvc.c +++ b/source3/rpc_client/cli_srvsvc.c @@ -430,39 +430,6 @@ WERROR rpccli_srvsvc_net_share_add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ return result; } -WERROR rpccli_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - char *server, TIME_OF_DAY_INFO *tod) -{ - prs_struct qbuf, rbuf; - SRV_Q_NET_REMOTE_TOD q; - SRV_R_NET_REMOTE_TOD r; - WERROR result = W_ERROR(ERRgeneral); - fstring server_slash; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialise input parameters */ - - slprintf(server_slash, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); - strupper_m(server_slash); - - init_srv_q_net_remote_tod(&q, server_slash); - r.tod = tod; - - /* Marshall data and send request */ - - CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_REMOTE_TOD, - q, r, - qbuf, rbuf, - srv_io_q_net_remote_tod, - srv_io_r_net_remote_tod, - WERR_GENERAL_FAILURE); - - result = r.status; - return result; -} - WERROR rpccli_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 file_level, const char *user_name, SRV_FILE_INFO_CTR *ctr, int preferred_len, diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c index 136aed5f16..a09e704bed 100644 --- a/source3/rpc_parse/parse_srv.c +++ b/source3/rpc_parse/parse_srv.c @@ -2618,125 +2618,6 @@ bool srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_stru return True; } -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -bool srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a TIME_OF_DAY_INFO structure. - ********************************************************************/ - -static bool srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth) -{ - if (tod == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_time_of_day_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("elapsedt ", ps, depth, &tod->elapsedt)) - return False; - if(!prs_uint32("msecs ", ps, depth, &tod->msecs)) - return False; - if(!prs_uint32("hours ", ps, depth, &tod->hours)) - return False; - if(!prs_uint32("mins ", ps, depth, &tod->mins)) - return False; - if(!prs_uint32("secs ", ps, depth, &tod->secs)) - return False; - if(!prs_uint32("hunds ", ps, depth, &tod->hunds)) - return False; - if(!prs_uint32("timezone ", ps, depth, &tod->zone)) - return False; - if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals)) - return False; - if(!prs_uint32("day ", ps, depth, &tod->day)) - return False; - if(!prs_uint32("month ", ps, depth, &tod->month)) - return False; - if(!prs_uint32("year ", ps, depth, &tod->year)) - return False; - if(!prs_uint32("weekday ", ps, depth, &tod->weekday)) - return False; - - return True; -} - -/******************************************************************* - Inits a TIME_OF_DAY_INFO structure. - ********************************************************************/ - -void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs, - uint32 hours, uint32 mins, uint32 secs, uint32 hunds, - uint32 zone, uint32 tintervals, uint32 day, - uint32 month, uint32 year, uint32 weekday) -{ - DEBUG(5,("init_time_of_day_info\n")); - - tod->elapsedt = elapsedt; - tod->msecs = msecs; - tod->hours = hours; - tod->mins = mins; - tod->secs = secs; - tod->hunds = hunds; - tod->zone = zone; - tod->tintervals = tintervals; - tod->day = day; - tod->month = month; - tod->year = year; - tod->weekday = weekday; -} - - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -bool srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod)) - return False; - - if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - /******************************************************************* initialises a structure. ********************************************************************/ @@ -3098,14 +2979,3 @@ bool srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC return True; } - -/******************************************************************* - Inits a structure -********************************************************************/ - -void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server) -{ - q_u->ptr_srv_name = 1; - init_unistr2(&q_u->uni_srv_name, server, UNI_STR_TERMINATE); -} - -- cgit From 3bda36d6375391214dc920e4f602594047b1ad58 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 11:31:26 +0100 Subject: Fix build of pam_smbpass. Guenther (This used to be commit cd582b7705dca40b3c688c9e23d8375dab43b4d0) --- source3/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 04df5cf840..d61de377fc 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1905,7 +1905,8 @@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \ bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) @echo "Linking shared library $@" - @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) + @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ + @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTDB_SHARED@ @echo Linking $@ -- cgit From 6543c5928c7c46c3fe7f7cf845dd6173c692fbe4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 5 Mar 2008 11:39:47 +0100 Subject: Makefile: Add explicit dependecies to libtalloc.so. So as to fix building of isolated targets. Michael (This used to be commit 7dbc251e1cd28abf28342529607fa4b5f579a9c4) --- source3/Makefile.in | 118 ++++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index d61de377fc..cdb7cee4f6 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1264,48 +1264,48 @@ bin/.dummy: dir=bin $(MAKEDIR); fi @: >> $@ || : > $@ # what a fancy emoticon! -bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @BUILD_POPT@ +bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) \ $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) \ @POPTLIBS@ @SMBD_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/nmbd@EXEEXT@: $(BINARY_PREREQS) $(NMBD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/nmbd@EXEEXT@: $(BINARY_PREREQS) $(NMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ @LIBTDB_LIBS@ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) -bin/swat@EXEEXT@: $(BINARY_PREREQS) $(SWAT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/swat@EXEEXT@: $(BINARY_PREREQS) $(SWAT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINT_LIBS) \ $(AUTH_LIBS) $(LIBS) $(PASSDB_LIBS) @POPTLIBS@ $(KRB5LIBS) \ $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/rpcclient@EXEEXT@: $(BINARY_PREREQS) $(RPCCLIENT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/rpcclient@EXEEXT@: $(BINARY_PREREQS) $(RPCCLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(PASSDB_LIBS) $(RPCCLIENT_OBJ) \ $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) \ $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) $(DNSSD_LIBS) \ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @INIPARSERLIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ @LIBNETAPI_LIBS@ -bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ @@ -1317,160 +1317,160 @@ bin/umount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UMOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CIFS_UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) @POPTLIBS@ -bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ0) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ0) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CIFS_SPNEGO_OBJ) $(DYNEXP) $(LDFLAGS) -lkeyutils $(LIBS) \ $(LIBSMBCLIENT_OBJ0) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBWBCLIENT_SHARED@ @LIBTDB_LIBS@ -bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbstatus@EXEEXT@: $(BINARY_PREREQS) $(STATUS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/smbstatus@EXEEXT@: $(BINARY_PREREQS) $(STATUS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) \ @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbcontrol@EXEEXT@: $(BINARY_PREREQS) $(SMBCONTROL_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/smbcontrol@EXEEXT@: $(BINARY_PREREQS) $(SMBCONTROL_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ \ $(SMBCONTROL_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(LDAP_LIBS) @LIBUNWIND_PTRACE@ @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbtree@EXEEXT@: $(BINARY_PREREQS) $(SMBTREE_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/smbtree@EXEEXT@: $(BINARY_PREREQS) $(SMBTREE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(PASSDB_LIBS) \ $(DYNEXP) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) \ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ @POPTLIBS@ $(PASSDB_LIBS) $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBGET_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ @POPTLIBS@ $(LDAP_LIBS) @LIBTDB_LIBS@ -bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(TALLOCTORT_OBJ) $(LDFLAGS) \ $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/replacetort@EXEEXT@: $(REPLACETORT_OBJ) @BUILD_POPT@ +bin/replacetort@EXEEXT@: $(REPLACETORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(REPLACETORT_OBJ) $(LDFLAGS) \ $(DYNEXP) $(LIBS) @POPTLIBS@ -bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/msgtest@EXEEXT@: $(BINARY_PREREQS) $(MSGTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/msgtest@EXEEXT@: $(BINARY_PREREQS) $(MSGTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/smbcacls@EXEEXT@: $(BINARY_PREREQS) $(SMBCACLS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/smbcacls@EXEEXT@: $(BINARY_PREREQS) $(SMBCACLS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/smbcquotas@EXEEXT@: $(BINARY_PREREQS) $(SMBCQUOTAS_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/smbcquotas@EXEEXT@: $(BINARY_PREREQS) $(SMBCQUOTAS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBCQUOTAS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/eventlogadm@EXEEXT@: $(BINARY_PREREQS) $(EVTLOGADM_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/eventlogadm@EXEEXT@: $(BINARY_PREREQS) $(EVTLOGADM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/sharesec@EXEEXT@: $(BINARY_PREREQS) $(SHARESEC_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/sharesec@EXEEXT@: $(BINARY_PREREQS) $(SHARESEC_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(LIBS) @POPTLIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ -bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) $(ACL_LIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) @SMBD_LIBS@ $(NSCD_LIBS) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ -bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/log2pcap@EXEEXT@: $(BINARY_PREREQS) $(LOG2PCAP_OBJ) @BUILD_POPT@ +bin/log2pcap@EXEEXT@: $(BINARY_PREREQS) $(LOG2PCAP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LOG2PCAP_OBJ) $(LDFLAGS) $(DYNEXP) @POPTLIBS@ $(LIBS) -bin/locktest2@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST2_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/locktest2@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST2_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/ndrdump@EXEEXT@: $(BINARY_PREREQS) $(NDRDUMP_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/ndrdump@EXEEXT@: $(BINARY_PREREQS) $(NDRDUMP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NDRDUMP_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ @LDAP_LIBS@ @LIBTDB_LIBS@ -bin/debug2html@EXEEXT@: $(BINARY_PREREQS) $(DEBUG2HTML_OBJ) @BUILD_POPT@ +bin/debug2html@EXEEXT@: $(BINARY_PREREQS) $(DEBUG2HTML_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) -bin/smbfilter@EXEEXT@: $(BINARY_PREREQS) $(SMBFILTER_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ +bin/smbfilter@EXEEXT@: $(BINARY_PREREQS) $(SMBFILTER_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ -bin/ldbedit: $(BINARY_PREREQS) $(LDBEDIT_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/ldbedit: $(BINARY_PREREQS) $(LDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBEDIT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/ldbsearch: $(BINARY_PREREQS) $(LDBSEARCH_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/ldbsearch: $(BINARY_PREREQS) $(LDBSEARCH_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBSEARCH_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/ldbadd: $(BINARY_PREREQS) $(LDBADD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/ldbadd: $(BINARY_PREREQS) $(LDBADD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBADD_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/ldbmodify: $(BINARY_PREREQS) $(LDBMODIFY_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/ldbmodify: $(BINARY_PREREQS) $(LDBMODIFY_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBMODIFY_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/ldbdel: $(BINARY_PREREQS) $(LDBDEL_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/ldbdel: $(BINARY_PREREQS) $(LDBDEL_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBDEL_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ @@ -1511,7 +1511,7 @@ bin/libwbclient.a: $(BINARY_PREREQS) $(LIBWBCLIENT_OBJ0) $(WBCOMMON_OBJ) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBWBCLIENT_OBJ0) $(WBCOMMON_OBJ) -bin/libaddns.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBADDNS_OBJ) +bin/libaddns.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBADDNS_OBJ) @LIBTALLOC_SHARED@ @echo Linking shared library $@ @$(SHLD_DSO) $(LIBADDNS_OBJ) $(LIBS) \ $(KRB5LIBS) $(UUID_LIBS)\ @@ -1521,7 +1521,7 @@ bin/libaddns.a: $(BINARY_PREREQS) $(LIBADDNS_OBJ) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBADDNS_OBJ) -$(LIBNETAPI_SHARED_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +$(LIBNETAPI_SHARED_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ @$(SHLD_DSO) $(LIBNETAPI_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ @@ -1532,7 +1532,7 @@ $(LIBNETAPI_STATIC_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ1) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBNETAPI_OBJ1) -bin/libsmbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/libsmbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @@ -1542,7 +1542,7 @@ bin/libsmbclient.a: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ0) @echo Linking non-shared library $@ @-$(AR) -rc $@ $(LIBSMBCLIENT_OBJ0) -bin/libsmbsharemodes.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) @LIBTDB_SHARED@ +bin/libsmbsharemodes.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking shared library $@ @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LIBS) @LIBTDB_LIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) \ @@ -1553,7 +1553,7 @@ bin/libsmbsharemodes.a: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) @-$(AR) -rc $@ $(LIBSMBSHAREMODES_OBJ) # This is probably wrong for anything other than the GNU linker. -bin/libbigballofmud.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBBIGBALLOFMUD_OBJ) +bin/libbigballofmud.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBBIGBALLOFMUD_OBJ) @LIBTALLOC_SHARED@ @echo Linking shared library $@ @$(SHLD) $(LDSHFLAGS) -o $@ $(LIBBIGBALLOFMUD_OBJ) $(LIBS) \ $(PASSDB_LIBS) $(IDMAP_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ @@ -1633,13 +1633,13 @@ bin/librpc_echo.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_ECHO_OBJ) @echo "Linking $@" @$(SHLD_MODULE) $(RPC_ECHO_OBJ) -bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" @$(CC) $(FLAGS) -o $@ $(WINBINDD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) \ $(PASSDB_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" @$(CC) $(FLAGS) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ @@ -1649,7 +1649,7 @@ bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARE @$(SHLD) $(WINBIND_NSS_LDSHFLAGS) -o $@ $(WINBIND_NSS_OBJ) \ @WINBIND_NSS_EXTRA_LIBS@ @WINBIND_NSS_PTHREAD@ @SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@ -@WINBIND_WINS_NSS@: $(BINARY_PREREQS) $(WINBIND_WINS_NSS_OBJ) @LIBTDB_SHARED@ +@WINBIND_WINS_NSS@: $(BINARY_PREREQS) $(WINBIND_WINS_NSS_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo "Linking $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_WINS_NSS_OBJ) \ $(LDAP_LIBS) $(KRB5LIBS) $(LIBS) @LIBTDB_LIBS@ \ @@ -1890,47 +1890,47 @@ bin/registry.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/registry.o ## None here right now ######################################################### -bin/wbinfo@EXEEXT@: $(BINARY_PREREQS) $(WBINFO_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ +bin/wbinfo@EXEEXT@: $(BINARY_PREREQS) $(WBINFO_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(WBINFO_OBJ) $(DYNEXP) $(LIBS) \ $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \ - $(LIB_NONSMBD_OBJ) @BUILD_POPT@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ + $(LIB_NONSMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(NTLM_AUTH_OBJ) \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) +bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) @LIBTALLOC_SHARED@ @echo "Linking shared library $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ @LIBTDB_LIBS@ @WINBIND_LIBS@ -bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTDB_SHARED@ +bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBBACKUP_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ -bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) @LIBTDB_SHARED@ +bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ -bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) @LIBTDB_SHARED@ +bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBDUMP_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ -bin/tdbtorture@EXEEXT@: $(BINARY_PREREQS) $(TDBTORTURE_OBJ) @LIBTDB_SHARED@ +bin/tdbtorture@EXEEXT@: $(BINARY_PREREQS) $(TDBTORTURE_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTORTURE_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ -bin/t_strcmp@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_strcmp.o +bin/t_strcmp@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strcmp.o $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_strcmp.o -L ./bin -lbigballofmud -bin/t_strstr@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_strstr.o +bin/t_strstr@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strstr.o $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_strstr.o -L ./bin -lbigballofmud -bin/t_strappend@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_strappend.o +bin/t_strappend@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strappend.o $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_strappend.o -L ./bin -lbigballofmud bin/t_stringoverflow@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_stringoverflow.o -- cgit From 2223292338111e0c97419cc643aa45e05d3c7aa8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 13:20:32 +0100 Subject: Add PICFLAG to libnetapi Makefile. Guenther (This used to be commit 29fca3c0353f2be4577613d7e38fbc51d2a370fa) --- source3/lib/netapi/examples/Makefile.in | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/lib/netapi/examples/Makefile.in b/source3/lib/netapi/examples/Makefile.in index 6de3e65546..000eef118b 100644 --- a/source3/lib/netapi/examples/Makefile.in +++ b/source3/lib/netapi/examples/Makefile.in @@ -7,6 +7,7 @@ LIBS=@LIBS@ -lnetapi -ltdb -ltalloc DEVELOPER_CFLAGS=@DEVELOPER_CFLAGS@ FLAGS=-I../ -L../../../bin @CFLAGS@ $(GTK_FLAGS) CC=@CC@ +PICFLAG=@PICFLAG@ LDFLAGS=@PIE_LDFLAGS@ @LDFLAGS@ DYNEXP=@DYNEXP@ -- cgit From b428ccdf26d1a9537d2ef59aa1a09309d34666f2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 5 Mar 2008 14:16:46 +0100 Subject: Makefile: untangle -ltalloc from LIBS, making use of libtalloc explicit. Michael (This used to be commit 237ea62a49fbf47634b55795c1065250d5148600) --- source3/Makefile.in | 120 ++++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index cdb7cee4f6..8dbd1d58e4 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -18,7 +18,7 @@ datarootdir=@datarootdir@ selftest_prefix=@selftest_prefix@ smbtorture4_path=@smbtorture4_path@ -LIBS=@LIBS@ @LIBTALLOC_LIBS@ +LIBS=@LIBS@ CC=@CC@ SHLD=@SHLD@ LIB_PATH_VAR=@LIB_PATH_VAR@ @@ -1269,45 +1269,45 @@ bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARE @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) \ $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) \ - @POPTLIBS@ @SMBD_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @POPTLIBS@ @SMBD_LIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/nmbd@EXEEXT@: $(BINARY_PREREQS) $(NMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ - @LIBTDB_LIBS@ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) bin/swat@EXEEXT@: $(BINARY_PREREQS) $(SWAT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINT_LIBS) \ $(AUTH_LIBS) $(LIBS) $(PASSDB_LIBS) @POPTLIBS@ $(KRB5LIBS) \ - $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(LDAP_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/rpcclient@EXEEXT@: $(BINARY_PREREQS) $(RPCCLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(PASSDB_LIBS) $(RPCCLIENT_OBJ) \ $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(KRB5LIBS) $(LDAP_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) \ $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) $(DNSSD_LIBS) \ - @LIBTDB_LIBS@ @WINBIND_LIBS@ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ - $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @INIPARSERLIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ @LIBNETAPI_LIBS@ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @INIPARSERLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ @LIBNETAPI_LIBS@ bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/mount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_MOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ @@ -1320,161 +1320,161 @@ bin/umount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UMOUNT_OBJ) @BUILD_POPT@ bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ0) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CIFS_SPNEGO_OBJ) $(DYNEXP) $(LDFLAGS) -lkeyutils $(LIBS) \ - $(LIBSMBCLIENT_OBJ0) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBWBCLIENT_SHARED@ @LIBTDB_LIBS@ + $(LIBSMBCLIENT_OBJ0) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBWBCLIENT_SHARED@ @LIBTDB_LIBS@ bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbstatus@EXEEXT@: $(BINARY_PREREQS) $(STATUS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) \ - @POPTLIBS@ @LIBTDB_LIBS@ + @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbcontrol@EXEEXT@: $(BINARY_PREREQS) $(SMBCONTROL_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ \ $(SMBCONTROL_OBJ) $(DYNEXP) $(LDFLAGS) \ - $(LIBS) $(LDAP_LIBS) @LIBUNWIND_PTRACE@ @POPTLIBS@ @LIBTDB_LIBS@ + $(LIBS) $(LDAP_LIBS) @LIBUNWIND_PTRACE@ @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbtree@EXEEXT@: $(BINARY_PREREQS) $(SMBTREE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ - @LIBTDB_LIBS@ @WINBIND_LIBS@ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(PASSDB_LIBS) \ $(DYNEXP) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) \ - @LIBTDB_LIBS@ @WINBIND_LIBS@ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ - @POPTLIBS@ $(PASSDB_LIBS) $(LDAP_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + @POPTLIBS@ $(PASSDB_LIBS) $(LDAP_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBGET_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ - @LIBTDB_LIBS@ @WINBIND_LIBS@ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ - @POPTLIBS@ $(LDAP_LIBS) @LIBTDB_LIBS@ + @POPTLIBS@ $(LDAP_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(TALLOCTORT_OBJ) $(LDFLAGS) \ - $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/replacetort@EXEEXT@: $(REPLACETORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(REPLACETORT_OBJ) $(LDFLAGS) \ - $(DYNEXP) $(LIBS) @POPTLIBS@ + $(DYNEXP) $(LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/msgtest@EXEEXT@: $(BINARY_PREREQS) $(MSGTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbcacls@EXEEXT@: $(BINARY_PREREQS) $(SMBCACLS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/smbcquotas@EXEEXT@: $(BINARY_PREREQS) $(SMBCQUOTAS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBCQUOTAS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/eventlogadm@EXEEXT@: $(BINARY_PREREQS) $(EVTLOGADM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/sharesec@EXEEXT@: $(BINARY_PREREQS) $(SHARESEC_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(LIBS) @POPTLIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ + @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) $(ACL_LIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) @SMBD_LIBS@ $(NSCD_LIBS) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ + @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) $(ACL_LIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) @SMBD_LIBS@ $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/log2pcap@EXEEXT@: $(BINARY_PREREQS) $(LOG2PCAP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOG2PCAP_OBJ) $(LDFLAGS) $(DYNEXP) @POPTLIBS@ $(LIBS) + @$(CC) $(FLAGS) -o $@ $(LOG2PCAP_OBJ) $(LDFLAGS) $(DYNEXP) @POPTLIBS@ $(LIBS) @LIBTALLOC_LIBS@ bin/locktest2@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST2_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/ndrdump@EXEEXT@: $(BINARY_PREREQS) $(NDRDUMP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NDRDUMP_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - @POPTLIBS@ @LDAP_LIBS@ @LIBTDB_LIBS@ + @POPTLIBS@ @LDAP_LIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/debug2html@EXEEXT@: $(BINARY_PREREQS) $(DEBUG2HTML_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ bin/smbfilter@EXEEXT@: $(BINARY_PREREQS) $(SMBFILTER_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/ldbedit: $(BINARY_PREREQS) $(LDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBEDIT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ldbsearch: $(BINARY_PREREQS) $(LDBSEARCH_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBSEARCH_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ldbadd: $(BINARY_PREREQS) $(LDBADD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBADD_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ldbmodify: $(BINARY_PREREQS) $(LDBMODIFY_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBMODIFY_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ldbdel: $(BINARY_PREREQS) $(LDBDEL_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBDEL_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ $(LIBTALLOC_SHARED_TARGET): $(BINARY_PREREQS) $(LIBTALLOC_OBJ) @echo Linking shared library $@ @@ -1514,7 +1514,7 @@ bin/libwbclient.a: $(BINARY_PREREQS) $(LIBWBCLIENT_OBJ0) $(WBCOMMON_OBJ) bin/libaddns.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBADDNS_OBJ) @LIBTALLOC_SHARED@ @echo Linking shared library $@ @$(SHLD_DSO) $(LIBADDNS_OBJ) $(LIBS) \ - $(KRB5LIBS) $(UUID_LIBS)\ + $(KRB5LIBS) $(UUID_LIBS) @LIBTALLOC_LIBS@ \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) bin/libaddns.a: $(BINARY_PREREQS) $(LIBADDNS_OBJ) @@ -1523,7 +1523,7 @@ bin/libaddns.a: $(BINARY_PREREQS) $(LIBADDNS_OBJ) $(LIBNETAPI_SHARED_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBNETAPI_OBJ) @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ $(LIBS) \ + @$(SHLD_DSO) $(LIBNETAPI_OBJ) @LIBTALLOC_LIBS@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @ln -s -f `basename $@` $@.$(SONAME_VER) @@ -1534,7 +1534,7 @@ $(LIBNETAPI_STATIC_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ1) bin/libsmbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ $(LIBS) \ + @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @@ -1544,7 +1544,7 @@ bin/libsmbclient.a: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ0) bin/libsmbsharemodes.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LIBS) @LIBTDB_LIBS@ \ + @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @@ -1555,7 +1555,7 @@ bin/libsmbsharemodes.a: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) # This is probably wrong for anything other than the GNU linker. bin/libbigballofmud.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBBIGBALLOFMUD_OBJ) @LIBTALLOC_SHARED@ @echo Linking shared library $@ - @$(SHLD) $(LDSHFLAGS) -o $@ $(LIBBIGBALLOFMUD_OBJ) $(LIBS) \ + @$(SHLD) $(LDSHFLAGS) -o $@ $(LIBBIGBALLOFMUD_OBJ) $(LIBS) @LIBTALLOC_LIBS@ \ $(PASSDB_LIBS) $(IDMAP_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ @SONAMEFLAG@`basename $@`.$(LIBBIGBALLOFMUD_MAJOR) ln -snf libbigballofmud.so bin/libbigballofmud.so.0 @@ -1637,12 +1637,12 @@ bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBTALLOC_ @echo "Linking $@" @$(CC) $(FLAGS) -o $@ $(WINBINDD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) \ - $(PASSDB_LIBS) @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(PASSDB_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" @$(CC) $(FLAGS) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ + $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ @WINBIND_NSS@: $(BINARY_PREREQS) $(WINBIND_NSS_OBJ) @echo "Linking $@" @@ -1652,7 +1652,7 @@ bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @WINBIND_WINS_NSS@: $(BINARY_PREREQS) $(WINBIND_WINS_NSS_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo "Linking $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_WINS_NSS_OBJ) \ - $(LDAP_LIBS) $(KRB5LIBS) $(LIBS) @LIBTDB_LIBS@ \ + $(LDAP_LIBS) $(KRB5LIBS) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ \ @SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@ bin/winbind_krb5_locator.@SHLIBEXT@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OBJ) @@ -1893,7 +1893,7 @@ bin/registry.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/registry.o bin/wbinfo@EXEEXT@: $(BINARY_PREREQS) $(WBINFO_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(WBINFO_OBJ) $(DYNEXP) $(LIBS) \ - $(LDAP_LIBS) @POPTLIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \ $(LIB_NONSMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @@ -1901,37 +1901,37 @@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(NTLM_AUTH_OBJ) \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ - @LIBTDB_LIBS@ @WINBIND_LIBS@ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) @LIBTALLOC_SHARED@ @echo "Linking shared library $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ - @LIBTDB_LIBS@ @WINBIND_LIBS@ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBBACKUP_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBBACKUP_OBJ) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBDUMP_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBDUMP_OBJ) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/tdbtorture@EXEEXT@: $(BINARY_PREREQS) $(TDBTORTURE_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTORTURE_OBJ) $(DYNEXP) $(LIBS) @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTORTURE_OBJ) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/t_strcmp@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strcmp.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_strcmp.o -L ./bin -lbigballofmud + $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ torture/t_strcmp.o -L ./bin -lbigballofmud bin/t_strstr@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strstr.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_strstr.o -L ./bin -lbigballofmud + $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ torture/t_strstr.o -L ./bin -lbigballofmud bin/t_strappend@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strappend.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) torture/t_strappend.o -L ./bin -lbigballofmud + $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ torture/t_strappend.o -L ./bin -lbigballofmud bin/t_stringoverflow@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_stringoverflow.o $(CC) $(FLAGS) -o $@ $(DYNEXP) torture/t_stringoverflow.o -L./bin -lbigballofmud -- cgit From 0a15d8a3bd9092d0b08e376fcebcc4c593d046fc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 5 Mar 2008 15:04:28 +0100 Subject: Makefile: reformat - break long target lines. Michael (This used to be commit e26133808469cb7e9acc41cb15219d7b736d228a) --- source3/Makefile.in | 193 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 129 insertions(+), 64 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 8dbd1d58e4..cfe0095612 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -378,7 +378,9 @@ LIBWBCLIENT_OBJ0 = nsswitch/libwbclient/wbclient.o \ nsswitch/libwbclient/wbc_idmap.o \ nsswitch/libwbclient/wbc_sid.o \ nsswitch/libwbclient/wbc_pam.o -LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) $(WBCOMMON_OBJ) @LIBTALLOC_STATIC@ $(LIBREPLACE_OBJ) +LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) \ + $(WBCOMMON_OBJ) \ + @LIBTALLOC_STATIC@ $(LIBREPLACE_OBJ) GPEXT_OBJ = libgpo/gpext/gpext.o @GPEXT_STATIC@ @@ -1269,12 +1271,14 @@ bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARE @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) \ $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) \ - @POPTLIBS@ @SMBD_LIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @POPTLIBS@ @SMBD_LIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ \ + @WINBIND_LIBS@ bin/nmbd@EXEEXT@: $(BINARY_PREREQS) $(NMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ - @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @POPTLIBS@ \ + $(KRB5LIBS) $(LDAP_LIBS) bin/swat@EXEEXT@: $(BINARY_PREREQS) $(SWAT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @@ -1286,7 +1290,8 @@ bin/rpcclient@EXEEXT@: $(BINARY_PREREQS) $(RPCCLIENT_OBJ) @BUILD_POPT@ @LIBTALLO @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(PASSDB_LIBS) $(RPCCLIENT_OBJ) \ $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(KRB5LIBS) $(LDAP_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ \ + @WINBIND_LIBS@ bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @@ -1299,15 +1304,19 @@ bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @L @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ - $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @INIPARSERLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ @LIBNETAPI_LIBS@ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \ + @INIPARSERLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ \ + @LIBNETAPI_LIBS@ bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ + $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ + $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/mount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_MOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ @@ -1319,23 +1328,27 @@ bin/umount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UMOUNT_OBJ) @BUILD_POPT@ bin/cifs.spnego@EXEEXT@: $(BINARY_PREREQS) $(CIFS_SPNEGO_OBJ) $(LIBSMBCLIENT_OBJ0) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CIFS_SPNEGO_OBJ) $(DYNEXP) $(LDFLAGS) -lkeyutils $(LIBS) \ - $(LIBSMBCLIENT_OBJ0) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBWBCLIENT_SHARED@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(CIFS_SPNEGO_OBJ) $(DYNEXP) $(LDFLAGS) \ + -lkeyutils $(LIBS) $(LIBSMBCLIENT_OBJ0) $(KRB5LIBS) \ + $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBWBCLIENT_SHARED@ \ + @LIBTDB_LIBS@ bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbstatus@EXEEXT@: $(BINARY_PREREQS) $(STATUS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) \ - @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbcontrol@EXEEXT@: $(BINARY_PREREQS) $(SMBCONTROL_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ \ - $(SMBCONTROL_OBJ) $(DYNEXP) $(LDFLAGS) \ - $(LIBS) $(LDAP_LIBS) @LIBUNWIND_PTRACE@ @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + $(SMBCONTROL_OBJ) $(DYNEXP) $(LDFLAGS) \ + $(LIBS) $(LDAP_LIBS) @LIBUNWIND_PTRACE@ @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbtree@EXEEXT@: $(BINARY_PREREQS) $(SMBTREE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @@ -1352,7 +1365,8 @@ bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ @LIBTALLO bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ - @POPTLIBS@ $(PASSDB_LIBS) $(LDAP_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @POPTLIBS@ $(PASSDB_LIBS) $(LDAP_LIBS) @LIBTALLOC_LIBS@ \ + @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @@ -1367,12 +1381,15 @@ bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTALLO bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ \ + @LIBTDB_LIBS@ bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(TALLOCTORT_OBJ) $(LDFLAGS) \ - $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/replacetort@EXEEXT@: $(REPLACETORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ @@ -1381,57 +1398,80 @@ bin/replacetort@EXEEXT@: $(REPLACETORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/msgtest@EXEEXT@: $(BINARY_PREREQS) $(MSGTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/smbcacls@EXEEXT@: $(BINARY_PREREQS) $(SMBCACLS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) \ + $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/smbcquotas@EXEEXT@: $(BINARY_PREREQS) $(SMBCQUOTAS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBCQUOTAS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBCQUOTAS_OBJ) $(DYNEXP) $(LDFLAGS) \ + $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/eventlogadm@EXEEXT@: $(BINARY_PREREQS) $(EVTLOGADM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) \ + $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/sharesec@EXEEXT@: $(BINARY_PREREQS) $(SHARESEC_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) \ + $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ + @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ + @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) $(ACL_LIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) @SMBD_LIBS@ $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ + @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) \ + $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ + $(ACL_LIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) \ + @SMBD_LIBS@ $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ \ + @LIBWBCLIENT_SHARED@ bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) \ + $(TERMLIBS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/log2pcap@EXEEXT@: $(BINARY_PREREQS) $(LOG2PCAP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOG2PCAP_OBJ) $(LDFLAGS) $(DYNEXP) @POPTLIBS@ $(LIBS) @LIBTALLOC_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LOG2PCAP_OBJ) $(LDFLAGS) $(DYNEXP) \ + @POPTLIBS@ $(LIBS) @LIBTALLOC_LIBS@ bin/locktest2@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST2_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/ndrdump@EXEEXT@: $(BINARY_PREREQS) $(NDRDUMP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @@ -1440,41 +1480,49 @@ bin/ndrdump@EXEEXT@: $(BINARY_PREREQS) $(NDRDUMP_OBJ) @BUILD_POPT@ @LIBTALLOC_SH bin/debug2html@EXEEXT@: $(BINARY_PREREQS) $(DEBUG2HTML_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ + @$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(LIBS) @LIBTALLOC_LIBS@ bin/smbfilter@EXEEXT@: $(BINARY_PREREQS) $(SMBFILTER_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) \ + $(KRB5LIBS) $(LDAP_LIBS) @POPTLIBS@ \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/ldbedit: $(BINARY_PREREQS) $(LDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDBEDIT_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDBEDIT_OBJ) $(DYNEXP) $(LDFLAGS) \ + $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ldbsearch: $(BINARY_PREREQS) $(LDBSEARCH_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDBSEARCH_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDBSEARCH_OBJ) $(DYNEXP) $(LDFLAGS) \ + $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ldbadd: $(BINARY_PREREQS) $(LDBADD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBADD_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ldbmodify: $(BINARY_PREREQS) $(LDBMODIFY_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBMODIFY_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/ldbdel: $(BINARY_PREREQS) $(LDBDEL_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDBDEL_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ + $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ $(LIBTALLOC_SHARED_TARGET): $(BINARY_PREREQS) $(LIBTALLOC_OBJ) @echo Linking shared library $@ @@ -1523,7 +1571,8 @@ bin/libaddns.a: $(BINARY_PREREQS) $(LIBADDNS_OBJ) $(LIBNETAPI_SHARED_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBNETAPI_OBJ) @LIBTALLOC_LIBS@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ $(LIBS) \ + @$(SHLD_DSO) $(LIBNETAPI_OBJ) \ + @LIBTALLOC_LIBS@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @ln -s -f `basename $@` $@.$(SONAME_VER) @@ -1534,7 +1583,8 @@ $(LIBNETAPI_STATIC_TARGET): $(BINARY_PREREQS) $(LIBNETAPI_OBJ1) bin/libsmbclient.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ $(LIBS) \ + @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ $(LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @@ -1544,7 +1594,8 @@ bin/libsmbclient.a: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ0) bin/libsmbsharemodes.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking shared library $@ - @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ \ + @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) \ + $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ \ $(KRB5LIBS) $(LDAP_LIBS) \ @SONAMEFLAG@`basename $@`.$(SONAME_VER) @@ -1555,7 +1606,8 @@ bin/libsmbsharemodes.a: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ) # This is probably wrong for anything other than the GNU linker. bin/libbigballofmud.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBBIGBALLOFMUD_OBJ) @LIBTALLOC_SHARED@ @echo Linking shared library $@ - @$(SHLD) $(LDSHFLAGS) -o $@ $(LIBBIGBALLOFMUD_OBJ) $(LIBS) @LIBTALLOC_LIBS@ \ + @$(SHLD) $(LDSHFLAGS) -o $@ $(LIBBIGBALLOFMUD_OBJ) \ + $(LIBS) @LIBTALLOC_LIBS@ \ $(PASSDB_LIBS) $(IDMAP_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ @SONAMEFLAG@`basename $@`.$(LIBBIGBALLOFMUD_MAJOR) ln -snf libbigballofmud.so bin/libbigballofmud.so.0 @@ -1641,13 +1693,16 @@ bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBTALLOC_ bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" - @$(CC) $(FLAGS) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ - $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ + @$(CC) $(FLAGS) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) \ + $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \ + $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @LIBWBCLIENT_SHARED@ @WINBIND_NSS@: $(BINARY_PREREQS) $(WINBIND_NSS_OBJ) @echo "Linking $@" @$(SHLD) $(WINBIND_NSS_LDSHFLAGS) -o $@ $(WINBIND_NSS_OBJ) \ - @WINBIND_NSS_EXTRA_LIBS@ @WINBIND_NSS_PTHREAD@ @SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@ + @WINBIND_NSS_EXTRA_LIBS@ @WINBIND_NSS_PTHREAD@ \ + @SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@ @WINBIND_WINS_NSS@: $(BINARY_PREREQS) $(WINBIND_WINS_NSS_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo "Linking $@" @@ -1893,7 +1948,8 @@ bin/registry.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/registry.o bin/wbinfo@EXEEXT@: $(BINARY_PREREQS) $(WBINFO_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(WBINFO_OBJ) $(DYNEXP) $(LIBS) \ - $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + $(LDAP_LIBS) @POPTLIBS@ @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ \ + @WINBIND_LIBS@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \ $(LIB_NONSMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @@ -1905,36 +1961,45 @@ bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \ bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) @LIBTALLOC_SHARED@ @echo "Linking shared library $@" - @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ - @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ + @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_OBJ) -lpam $(DYNEXP) \ + $(LIBS) $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) \ + @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ @WINBIND_LIBS@ bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBBACKUP_OBJ) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBBACKUP_OBJ) $(DYNEXP) \ + $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) \ + $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBDUMP_OBJ) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBDUMP_OBJ) $(DYNEXP) \ + $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/tdbtorture@EXEEXT@: $(BINARY_PREREQS) $(TDBTORTURE_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTORTURE_OBJ) $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ + @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTORTURE_OBJ) $(DYNEXP) \ + $(LIBS) @LIBTALLOC_LIBS@ @LIBTDB_LIBS@ bin/t_strcmp@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strcmp.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ torture/t_strcmp.o -L ./bin -lbigballofmud + $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ \ + torture/t_strcmp.o -L ./bin -lbigballofmud bin/t_strstr@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strstr.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ torture/t_strstr.o -L ./bin -lbigballofmud + $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ \ + torture/t_strstr.o -L ./bin -lbigballofmud bin/t_strappend@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strappend.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ torture/t_strappend.o -L ./bin -lbigballofmud + $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) @LIBTALLOC_LIBS@ \ + torture/t_strappend.o -L ./bin -lbigballofmud bin/t_stringoverflow@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_stringoverflow.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) torture/t_stringoverflow.o -L./bin -lbigballofmud + $(CC) $(FLAGS) -o $@ $(DYNEXP) torture/t_stringoverflow.o \ + -L./bin -lbigballofmud bin/timelimit@EXEEXT@: script/tests/timelimit.o @echo Linking $@ -- cgit From 65b0235ee394f90e7a4938cfa5bc5d2d951e9d82 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 15:21:43 +0100 Subject: Give a better error message why NetServerSetInfo() may fail in the gui. Guenther (This used to be commit 1bbbebb7767b8a25532e8be3dbd274c211e34bbd) --- source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c | 2 +- source3/lib/netapi/serverinfo.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c index 73b14d4d87..a3719c7442 100644 --- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c +++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c @@ -154,7 +154,7 @@ static void callback_apply_description_change(GtkWidget *widget, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Failed to change computer description: %s.", - libnetapi_errstr(status)); + libnetapi_get_error_string(state->ctx, status)); g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog); diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index 54512950bf..d30e7d97f7 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -185,6 +185,9 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, } if (!lp_config_backend_is_registry()) { + libnetapi_set_error_string(ctx, + "Configuration manipulation requested but not " + "supported by backend"); return WERR_NOT_SUPPORTED; } -- cgit From cb94b313ba77a1460af021d1b1ee68f86c4490cb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 15:40:23 +0100 Subject: Make sure to generate pkgconfig files for libtdb and libtalloc. Guenther (This used to be commit df97fb019b89a147a0a2c560003d74c354fcc4b6) --- source3/configure.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 056c0f8049..1ebd84e9a8 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -6229,6 +6229,8 @@ AC_OUTPUT(Makefile library-versions pkgconfig/wbclient.pc pkgconfig/netapi.pc pkgconfig/smbsharemodes.pc + lib/talloc/talloc.pc + lib/tdb/tdb.pc ) ################################################# -- cgit From d42e415b4069f293c28fd0cae7fe6fbaa587b171 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 16:31:04 +0100 Subject: Revert "Make sure to generate pkgconfig files for libtdb and libtalloc." This uses incorrect version numbers for tdb and talloc. Guenther This reverts commit df97fb019b89a147a0a2c560003d74c354fcc4b6. (This used to be commit ead849949b1b879e2bc4a6b1f7c3d2df1962170a) --- source3/configure.in | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 1ebd84e9a8..056c0f8049 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -6229,8 +6229,6 @@ AC_OUTPUT(Makefile library-versions pkgconfig/wbclient.pc pkgconfig/netapi.pc pkgconfig/smbsharemodes.pc - lib/talloc/talloc.pc - lib/tdb/tdb.pc ) ################################################# -- cgit From 9d7cad7e8246b11c28096c2e62f6ef4e18f79722 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 5 Mar 2008 16:28:43 +0100 Subject: Fix a memleak -- Coverity ID 222 (cherry picked from commit a40781bafa3a8f0c7737164bca6cf74b0a452e72) (This used to be commit 86cabcad74ac06d888f2a352a2bef3abea1ed85c) --- source3/passdb/pdb_ldap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 87a648a5b4..dec9b5bafb 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -349,6 +349,7 @@ int ldapsam_search_suffix_by_name(struct ldapsam_privates *ldap_state, filter = talloc_asprintf(talloc_tos(), "(&%s%s)", "(uid=%u)", get_objclass_filter(ldap_state->schema_ver)); if (!filter) { + SAFE_FREE(escape_user); return LDAP_NO_MEMORY; } /* @@ -358,10 +359,10 @@ int ldapsam_search_suffix_by_name(struct ldapsam_privates *ldap_state, filter = talloc_all_string_sub(talloc_tos(), filter, "%u", escape_user); + SAFE_FREE(escape_user); if (!filter) { return LDAP_NO_MEMORY; } - SAFE_FREE(escape_user); ret = smbldap_search_suffix(ldap_state->smbldap_state, filter, attr, result); -- cgit From 932c287a406048759fa1ac4bf86e29d96991ded1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 5 Mar 2008 17:20:01 +0100 Subject: Fix Coverity ID 565 This would crash safely (This used to be commit 0f14357c86aee9a76ffbb45ea6419f4cc4106d62) --- source3/rpc_server/srv_winreg_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 7ff93e0b07..c76bc19d9c 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -508,8 +508,6 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateS /* pull the message string and perform necessary sanity checks on it */ - chkmsg[0] = '\0'; - if ( r->in.message && r->in.message->name && r->in.message->name->name ) { if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->name->name )) == NULL ) { return WERR_NOMEM; -- cgit