diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-09-14 14:51:16 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:51:46 -0500 |
commit | 71453ab90dbda7f335a3c7119eb8d404e85a0131 (patch) | |
tree | 98389567efb132cd9bdec96e7ae1ce77800ee03c /source3 | |
parent | 1e811453620ea35bcc1f2b481d1ebdc0778b282f (diff) | |
download | samba-71453ab90dbda7f335a3c7119eb8d404e85a0131.tar.gz samba-71453ab90dbda7f335a3c7119eb8d404e85a0131.tar.bz2 samba-71453ab90dbda7f335a3c7119eb8d404e85a0131.zip |
r18526: Use generated server for unixinfo RPC interface.
(This used to be commit a5c0606d7667506fdc64776e32d4b3508195a199)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 2 | ||||
-rw-r--r-- | source3/include/includes.h | 1 | ||||
-rw-r--r-- | source3/include/rpc_unixinfo.h | 172 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_unixinfo.c | 43 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_dfs.c | 12 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_lsa.c | 200 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_lsa.h | 2 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_unixinfo.c | 32 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_unixinfo.h | 2 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/unixinfo.h | 2 | ||||
-rw-r--r-- | source3/rpc_parse/parse_unixinfo.c | 266 | ||||
-rw-r--r-- | source3/rpc_server/srv_unixinfo.c | 163 | ||||
-rw-r--r-- | source3/rpc_server/srv_unixinfo_nt.c | 116 |
13 files changed, 307 insertions, 706 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 778e520ca1..9d3c023154 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -314,7 +314,7 @@ RPC_NETLOG_OBJ = rpc_server/srv_netlog.o rpc_server/srv_netlog_nt.o RPC_SAMR_OBJ = rpc_server/srv_samr.o rpc_server/srv_samr_nt.o \ rpc_server/srv_samr_util.o -RPC_UNIXINFO_OBJ = rpc_server/srv_unixinfo.o rpc_server/srv_unixinfo_nt.o rpc_parse/parse_unixinfo.o +RPC_UNIXINFO_OBJ = librpc/gen_ndr/srv_unixinfo.o rpc_server/srv_unixinfo_nt.o REGFIO_OBJ = registry/regfio.o RPC_REG_OBJ = rpc_server/srv_reg.o rpc_server/srv_reg_nt.o $(REGFIO_OBJ) diff --git a/source3/include/includes.h b/source3/include/includes.h index 319a475bcf..f56faa7551 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -1008,7 +1008,6 @@ extern int errno; #include "rpc_ds.h" #include "rpc_echo.h" #include "rpc_shutdown.h" -#include "rpc_unixinfo.h" #include "rpc_perfcount.h" #include "rpc_perfcount_defs.h" #include "nt_printing.h" diff --git a/source3/include/rpc_unixinfo.h b/source3/include/rpc_unixinfo.h deleted file mode 100644 index 913196b7c9..0000000000 --- a/source3/include/rpc_unixinfo.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Unixinfo definitions. - - Copyright (C) Volker Lendecke 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 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. -*/ - -#ifndef _RPC_UNIXINFO_H -#define _RPC_UNIXINFO_H - -#define UNIXINFO_SID_TO_UID 0x00 -#define UNIXINFO_UID_TO_SID 0x01 -#define UNIXINFO_SID_TO_GID 0x02 -#define UNIXINFO_GID_TO_SID 0x03 -#define UNIXINFO_GETPWUID 0x04 - -typedef struct unixinfo_q_sid_to_uid { - DOM_SID sid; -} UNIXINFO_Q_SID_TO_UID; - -typedef struct unixinfo_r_sid_to_uid { - uint64 uid; - NTSTATUS status; -} UNIXINFO_R_SID_TO_UID; - -typedef struct unixinfo_q_uid_to_sid { - uint64 uid; -} UNIXINFO_Q_UID_TO_SID; - -typedef struct unixinfo_r_uid_to_sid { - uint32 sidptr; - DOM_SID sid; - NTSTATUS status; -} UNIXINFO_R_UID_TO_SID; - -typedef struct unixinfo_q_sid_to_gid { - DOM_SID sid; -} UNIXINFO_Q_SID_TO_GID; - -typedef struct unixinfo_r_sid_to_gid { - uint64 gid; - NTSTATUS status; -} UNIXINFO_R_SID_TO_GID; - -typedef struct unixinfo_q_gid_to_sid { - uint64 gid; -} UNIXINFO_Q_GID_TO_SID; - -typedef struct unixinfo_r_gid_to_sid { - uint32 sidptr; - DOM_SID sid; - NTSTATUS status; -} UNIXINFO_R_GID_TO_SID; - -typedef struct unixinfo_q_getpwuid { - uint32 count; - uint64 *uid; -} UNIXINFO_Q_GETPWUID; - -struct unixinfo_getpwuid { - /* name, gid and gecos explicitly excluded, these values can be - retrieved via other means */ - NTSTATUS status; - const char *homedir; - const char *shell; -}; - -typedef struct unixinfo_r_getpwuid { - uint32 count; - struct unixinfo_getpwuid *info; - NTSTATUS status; -} UNIXINFO_R_GETPWUID; - -#endif -/* - Unix SMB/CIFS implementation. - - Unixinfo definitions. - - Copyright (C) Volker Lendecke 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 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. -*/ - -#ifndef _RPC_UNIXINFO_H -#define _RPC_UNIXINFO_H - -#define UNIXINFO_SID_TO_UID 0x00 -#define UNIXINFO_UID_TO_SID 0x01 -#define UNIXINFO_SID_TO_GID 0x02 -#define UNIXINFO_GID_TO_SID 0x03 -#define UNIXINFO_GETPWUID 0x04 - -typedef struct unixinfo_q_sid_to_uid { - DOM_SID sid; -} UNIXINFO_Q_SID_TO_UID; - -typedef struct unixinfo_r_sid_to_uid { - uint64 uid; - NTSTATUS status; -} UNIXINFO_R_SID_TO_UID; - -typedef struct unixinfo_q_uid_to_sid { - uint64 uid; -} UNIXINFO_Q_UID_TO_SID; - -typedef struct unixinfo_r_uid_to_sid { - uint32 sidptr; - DOM_SID sid; - NTSTATUS status; -} UNIXINFO_R_UID_TO_SID; - -typedef struct unixinfo_q_sid_to_gid { - DOM_SID sid; -} UNIXINFO_Q_SID_TO_GID; - -typedef struct unixinfo_r_sid_to_gid { - uint64 gid; - NTSTATUS status; -} UNIXINFO_R_SID_TO_GID; - -typedef struct unixinfo_q_gid_to_sid { - uint64 gid; -} UNIXINFO_Q_GID_TO_SID; - -typedef struct unixinfo_r_gid_to_sid { - uint32 sidptr; - DOM_SID sid; - NTSTATUS status; -} UNIXINFO_R_GID_TO_SID; - -typedef struct unixinfo_q_getpwuid { - uint64 uid; -} UNIXINFO_Q_GETPWUID; - -typedef struct unixinfo_r_getpwuid { - /* name and gid explicitly excluded, these values can be retrieved via - other means */ - const char *gecos; - const char *homedir; - const char *shell; - NTSTATUS status; -} UNIXINFO_R_GETPWUID; - -#endif diff --git a/source3/librpc/gen_ndr/ndr_unixinfo.c b/source3/librpc/gen_ndr/ndr_unixinfo.c index 4a5a2c70d6..bbf76a368b 100644 --- a/source3/librpc/gen_ndr/ndr_unixinfo.c +++ b/source3/librpc/gen_ndr/ndr_unixinfo.c @@ -327,7 +327,7 @@ _PUBLIC_ void ndr_print_unixinfo_GidToSid(struct ndr_print *ndr, const char *nam NTSTATUS ndr_push_unixinfo_GetPWUid(struct ndr_push *ndr, int flags, const struct unixinfo_GetPWUid *r) { uint32_t cntr_uids_0; - uint32_t cntr_infos_1; + uint32_t cntr_infos_0; if (flags & NDR_IN) { if (r->in.count == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.count)); @@ -339,10 +339,9 @@ NTSTATUS ndr_push_unixinfo_GetPWUid(struct ndr_push *ndr, int flags, const struc if (flags & NDR_OUT) { if (r->out.count == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.count)); - if (r->out.infos == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.count)); - for (cntr_infos_1 = 0; cntr_infos_1 < *r->out.count; cntr_infos_1++) { - NDR_CHECK(ndr_push_unixinfo_GetPWUidInfo(ndr, NDR_SCALARS, &r->out.infos[cntr_infos_1])); + 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)); } @@ -352,10 +351,10 @@ NTSTATUS ndr_push_unixinfo_GetPWUid(struct ndr_push *ndr, int flags, const struc NTSTATUS ndr_pull_unixinfo_GetPWUid(struct ndr_pull *ndr, int flags, struct unixinfo_GetPWUid *r) { uint32_t cntr_uids_0; - uint32_t cntr_infos_1; + uint32_t cntr_infos_0; TALLOC_CTX *_mem_save_count_0; TALLOC_CTX *_mem_save_uids_0; - TALLOC_CTX *_mem_save_infos_1; + TALLOC_CTX *_mem_save_infos_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -379,9 +378,6 @@ NTSTATUS ndr_pull_unixinfo_GetPWUid(struct ndr_pull *ndr, int flags, struct unix 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.count == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_PULL_ALLOC_N(ndr, r->out.infos, *r->in.count); - memset(r->out.infos, 0, *r->in.count * sizeof(*r->out.infos)); if (r->in.uids) { if (r->in.count == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.uids, *r->in.count)); @@ -399,15 +395,13 @@ NTSTATUS ndr_pull_unixinfo_GetPWUid(struct ndr_pull *ndr, int flags, struct unix } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_array_size(ndr, &r->out.infos)); - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC_N(ndr, r->out.infos, ndr_get_array_size(ndr, &r->out.infos)); - } - _mem_save_infos_1 = NDR_PULL_GET_MEM_CTX(ndr); + 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_1 = 0; cntr_infos_1 < *r->out.count; cntr_infos_1++) { - NDR_CHECK(ndr_pull_unixinfo_GetPWUidInfo(ndr, NDR_SCALARS, &r->out.infos[cntr_infos_1])); + 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_1, 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) { if (r->out.count == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; @@ -420,7 +414,7 @@ NTSTATUS ndr_pull_unixinfo_GetPWUid(struct ndr_pull *ndr, int flags, struct unix _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_1; + uint32_t cntr_infos_0; ndr_print_struct(ndr, name, "unixinfo_GetPWUid"); ndr->depth++; if (flags & NDR_SET_VALUES) { @@ -453,20 +447,17 @@ _PUBLIC_ void ndr_print_unixinfo_GetPWUid(struct ndr_print *ndr, const char *nam ndr->depth++; ndr_print_uint32(ndr, "count", *r->out.count); ndr->depth--; - ndr_print_ptr(ndr, "infos", r->out.infos); - ndr->depth++; ndr->print(ndr, "%s: ARRAY(%d)", "infos", *r->out.count); ndr->depth++; - for (cntr_infos_1=0;cntr_infos_1<*r->out.count;cntr_infos_1++) { - char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_infos_1); - if (idx_1) { - ndr_print_unixinfo_GetPWUidInfo(ndr, "infos", &r->out.infos[cntr_infos_1]); - free(idx_1); + 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) { + ndr_print_unixinfo_GetPWUidInfo(ndr, "infos", &r->out.infos[cntr_infos_0]); + free(idx_0); } } ndr->depth--; - ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/srv_dfs.c b/source3/librpc/gen_ndr/srv_dfs.c index 75f3cd3949..bd4503248d 100644 --- a/source3/librpc/gen_ndr/srv_dfs.c +++ b/source3/librpc/gen_ndr/srv_dfs.c @@ -31,6 +31,12 @@ static BOOL api_dfs_GetManagerVersion(pipes_struct *p) return False; } + r.out.exist_flag = talloc_size(mem_ctx, sizeof(*r.out.exist_flag)); + if (r.out.exist_flag == NULL) { + talloc_free(mem_ctx); + return False; + } + _dfs_GetManagerVersion(p, r.out.exist_flag); push = ndr_push_init_ctx(mem_ctx); @@ -231,6 +237,12 @@ static BOOL api_dfs_GetInfo(pipes_struct *p) return False; } + r.out.info = talloc_size(mem_ctx, sizeof(*r.out.info)); + if (r.out.info == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _dfs_GetInfo(p, r.in.path, r.in.server, r.in.share, r.in.level, r.out.info); push = ndr_push_init_ctx(mem_ctx); diff --git a/source3/librpc/gen_ndr/srv_lsa.c b/source3/librpc/gen_ndr/srv_lsa.c index 20d564b65f..c9780580d6 100644 --- a/source3/librpc/gen_ndr/srv_lsa.c +++ b/source3/librpc/gen_ndr/srv_lsa.c @@ -133,6 +133,12 @@ static BOOL api_lsa_EnumPrivs(pipes_struct *p) } r.out.resume_handle = r.in.resume_handle; + r.out.privs = talloc_size(mem_ctx, sizeof(*r.out.privs)); + if (r.out.privs == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_EnumPrivs(p, r.in.handle, r.in.resume_handle, r.in.max_count, r.out.privs); push = ndr_push_init_ctx(mem_ctx); @@ -183,6 +189,12 @@ static BOOL api_lsa_QuerySecurity(pipes_struct *p) return False; } + r.out.sdbuf = talloc_size(mem_ctx, sizeof(*r.out.sdbuf)); + if (r.out.sdbuf == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_QuerySecurity(p, r.in.handle, r.in.sec_info, r.out.sdbuf); push = ndr_push_init_ctx(mem_ctx); @@ -333,6 +345,12 @@ static BOOL api_lsa_OpenPolicy(pipes_struct *p) return False; } + r.out.handle = talloc_size(mem_ctx, sizeof(*r.out.handle)); + if (r.out.handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_OpenPolicy(p, r.in.system_name, r.in.attr, r.in.access_mask, r.out.handle); push = ndr_push_init_ctx(mem_ctx); @@ -383,6 +401,12 @@ static BOOL api_lsa_QueryInfoPolicy(pipes_struct *p) return False; } + r.out.info = talloc_size(mem_ctx, sizeof(*r.out.info)); + if (r.out.info == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_QueryInfoPolicy(p, r.in.handle, r.in.level, r.out.info); push = ndr_push_init_ctx(mem_ctx); @@ -533,6 +557,12 @@ static BOOL api_lsa_CreateAccount(pipes_struct *p) return False; } + r.out.acct_handle = talloc_size(mem_ctx, sizeof(*r.out.acct_handle)); + if (r.out.acct_handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_CreateAccount(p, r.in.handle, r.in.sid, r.in.access_mask, r.out.acct_handle); push = ndr_push_init_ctx(mem_ctx); @@ -584,6 +614,12 @@ static BOOL api_lsa_EnumAccounts(pipes_struct *p) } r.out.resume_handle = r.in.resume_handle; + r.out.sids = talloc_size(mem_ctx, sizeof(*r.out.sids)); + if (r.out.sids == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_EnumAccounts(p, r.in.handle, r.in.resume_handle, r.in.num_entries, r.out.sids); push = ndr_push_init_ctx(mem_ctx); @@ -634,6 +670,12 @@ static BOOL api_lsa_CreateTrustedDomain(pipes_struct *p) return False; } + r.out.trustdom_handle = talloc_size(mem_ctx, sizeof(*r.out.trustdom_handle)); + if (r.out.trustdom_handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_CreateTrustedDomain(p, r.in.handle, r.in.info, r.in.access_mask, r.out.trustdom_handle); push = ndr_push_init_ctx(mem_ctx); @@ -685,6 +727,12 @@ static BOOL api_lsa_EnumTrustDom(pipes_struct *p) } r.out.resume_handle = r.in.resume_handle; + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_EnumTrustDom(p, r.in.handle, r.in.resume_handle, r.in.max_size, r.out.domains); push = ndr_push_init_ctx(mem_ctx); @@ -735,6 +783,12 @@ static BOOL api_lsa_LookupNames(pipes_struct *p) return False; } + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.sids = r.in.sids; r.out.count = r.in.count; r.out.result = _lsa_LookupNames(p, r.in.handle, r.in.num_names, r.in.names, r.out.domains, r.in.sids, r.in.level, r.in.count); @@ -787,6 +841,12 @@ static BOOL api_lsa_LookupSids(pipes_struct *p) return False; } + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.names = r.in.names; r.out.count = r.in.count; r.out.result = _lsa_LookupSids(p, r.in.handle, r.in.sids, r.out.domains, r.in.names, r.in.level, r.in.count); @@ -839,6 +899,12 @@ static BOOL api_lsa_CreateSecret(pipes_struct *p) return False; } + r.out.sec_handle = talloc_size(mem_ctx, sizeof(*r.out.sec_handle)); + if (r.out.sec_handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_CreateSecret(p, r.in.handle, r.in.name, r.in.access_mask, r.out.sec_handle); push = ndr_push_init_ctx(mem_ctx); @@ -889,6 +955,12 @@ static BOOL api_lsa_OpenAccount(pipes_struct *p) return False; } + r.out.acct_handle = talloc_size(mem_ctx, sizeof(*r.out.acct_handle)); + if (r.out.acct_handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_OpenAccount(p, r.in.handle, r.in.sid, r.in.access_mask, r.out.acct_handle); push = ndr_push_init_ctx(mem_ctx); @@ -939,6 +1011,12 @@ static BOOL api_lsa_EnumPrivsAccount(pipes_struct *p) return False; } + r.out.privs = talloc_size(mem_ctx, sizeof(*r.out.privs)); + if (r.out.privs == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_EnumPrivsAccount(p, r.in.handle, r.out.privs); push = ndr_push_init_ctx(mem_ctx); @@ -1289,6 +1367,12 @@ static BOOL api_lsa_OpenTrustedDomain(pipes_struct *p) return False; } + r.out.trustdom_handle = talloc_size(mem_ctx, sizeof(*r.out.trustdom_handle)); + if (r.out.trustdom_handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_OpenTrustedDomain(p, r.in.handle, r.in.sid, r.in.access_mask, r.out.trustdom_handle); push = ndr_push_init_ctx(mem_ctx); @@ -1339,6 +1423,12 @@ static BOOL api_lsa_QueryTrustedDomainInfo(pipes_struct *p) return False; } + r.out.info = talloc_size(mem_ctx, sizeof(*r.out.info)); + if (r.out.info == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_QueryTrustedDomainInfo(p, r.in.trustdom_handle, r.in.level, r.out.info); push = ndr_push_init_ctx(mem_ctx); @@ -1439,6 +1529,12 @@ static BOOL api_lsa_OpenSecret(pipes_struct *p) return False; } + r.out.sec_handle = talloc_size(mem_ctx, sizeof(*r.out.sec_handle)); + if (r.out.sec_handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_OpenSecret(p, r.in.handle, r.in.name, r.in.access_mask, r.out.sec_handle); push = ndr_push_init_ctx(mem_ctx); @@ -1593,6 +1689,12 @@ static BOOL api_lsa_LookupPrivValue(pipes_struct *p) return False; } + r.out.luid = talloc_size(mem_ctx, sizeof(*r.out.luid)); + if (r.out.luid == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_LookupPrivValue(p, r.in.handle, r.in.name, r.out.luid); push = ndr_push_init_ctx(mem_ctx); @@ -1643,6 +1745,12 @@ static BOOL api_lsa_LookupPrivName(pipes_struct *p) return False; } + r.out.name = talloc_size(mem_ctx, sizeof(*r.out.name)); + if (r.out.name == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_LookupPrivName(p, r.in.handle, r.in.luid, r.out.name); push = ndr_push_init_ctx(mem_ctx); @@ -1693,6 +1801,12 @@ static BOOL api_lsa_LookupPrivDisplayName(pipes_struct *p) return False; } + r.out.disp_name = talloc_size(mem_ctx, sizeof(*r.out.disp_name)); + if (r.out.disp_name == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.language_id = r.in.language_id; r.out.result = _lsa_LookupPrivDisplayName(p, r.in.handle, r.in.name, r.out.disp_name, r.in.language_id, r.in.unknown); @@ -1794,6 +1908,12 @@ static BOOL api_lsa_EnumAccountsWithUserRight(pipes_struct *p) return False; } + r.out.sids = talloc_size(mem_ctx, sizeof(*r.out.sids)); + if (r.out.sids == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_EnumAccountsWithUserRight(p, r.in.handle, r.in.name, r.out.sids); push = ndr_push_init_ctx(mem_ctx); @@ -1844,6 +1964,12 @@ static BOOL api_lsa_EnumAccountRights(pipes_struct *p) return False; } + r.out.rights = talloc_size(mem_ctx, sizeof(*r.out.rights)); + if (r.out.rights == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_EnumAccountRights(p, r.in.handle, r.in.sid, r.out.rights); push = ndr_push_init_ctx(mem_ctx); @@ -1994,6 +2120,12 @@ static BOOL api_lsa_QueryTrustedDomainInfoBySid(pipes_struct *p) return False; } + r.out.info = talloc_size(mem_ctx, sizeof(*r.out.info)); + if (r.out.info == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_QueryTrustedDomainInfoBySid(p, r.in.handle, r.in.dom_sid, r.in.level, r.out.info); push = ndr_push_init_ctx(mem_ctx); @@ -2244,6 +2376,12 @@ static BOOL api_lsa_OpenPolicy2(pipes_struct *p) return False; } + r.out.handle = talloc_size(mem_ctx, sizeof(*r.out.handle)); + if (r.out.handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_OpenPolicy2(p, r.in.system_name, r.in.attr, r.in.access_mask, r.out.handle); push = ndr_push_init_ctx(mem_ctx); @@ -2346,6 +2484,12 @@ static BOOL api_lsa_QueryInfoPolicy2(pipes_struct *p) return False; } + r.out.info = talloc_size(mem_ctx, sizeof(*r.out.info)); + if (r.out.info == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_QueryInfoPolicy2(p, r.in.handle, r.in.level, r.out.info); push = ndr_push_init_ctx(mem_ctx); @@ -2446,6 +2590,12 @@ static BOOL api_lsa_QueryTrustedDomainInfoByName(pipes_struct *p) return False; } + r.out.info = talloc_size(mem_ctx, sizeof(*r.out.info)); + if (r.out.info == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_QueryTrustedDomainInfoByName(p, r.in.handle, r.in.trusted_domain, r.in.level, r.out.info); push = ndr_push_init_ctx(mem_ctx); @@ -2547,6 +2697,12 @@ static BOOL api_lsa_EnumTrustedDomainsEx(pipes_struct *p) } r.out.resume_handle = r.in.resume_handle; + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_EnumTrustedDomainsEx(p, r.in.handle, r.in.resume_handle, r.out.domains, r.in.max_size); push = ndr_push_init_ctx(mem_ctx); @@ -2698,6 +2854,12 @@ static BOOL api_lsa_QueryDomainInformationPolicy(pipes_struct *p) return False; } + r.out.info = talloc_size(mem_ctx, sizeof(*r.out.info)); + if (r.out.info == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_QueryDomainInformationPolicy(p, r.in.handle, r.in.level, r.out.info); push = ndr_push_init_ctx(mem_ctx); @@ -2798,6 +2960,12 @@ static BOOL api_lsa_OpenTrustedDomainByName(pipes_struct *p) return False; } + r.out.trustdom_handle = talloc_size(mem_ctx, sizeof(*r.out.trustdom_handle)); + if (r.out.trustdom_handle == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _lsa_OpenTrustedDomainByName(p, r.in.handle, r.in.name, r.in.access_mask, r.out.trustdom_handle); push = ndr_push_init_ctx(mem_ctx); @@ -2898,6 +3066,12 @@ static BOOL api_lsa_LookupSids2(pipes_struct *p) return False; } + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.names = r.in.names; r.out.count = r.in.count; r.out.result = _lsa_LookupSids2(p, r.in.handle, r.in.sids, r.out.domains, r.in.names, r.in.level, r.in.count, r.in.unknown1, r.in.unknown2); @@ -2950,6 +3124,12 @@ static BOOL api_lsa_LookupNames2(pipes_struct *p) return False; } + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.sids = r.in.sids; r.out.count = r.in.count; r.out.result = _lsa_LookupNames2(p, r.in.handle, r.in.num_names, r.in.names, r.out.domains, r.in.sids, r.in.level, r.in.count, r.in.unknown1, r.in.unknown2); @@ -3452,6 +3632,12 @@ static BOOL api_lsa_LookupNames3(pipes_struct *p) return False; } + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.sids = r.in.sids; r.out.count = r.in.count; r.out.result = _lsa_LookupNames3(p, r.in.handle, r.in.num_names, r.in.names, r.out.domains, r.in.sids, r.in.level, r.in.count, r.in.unknown1, r.in.unknown2); @@ -3854,6 +4040,12 @@ static BOOL api_lsa_LookupSids3(pipes_struct *p) return False; } + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.names = r.in.names; r.out.count = r.in.count; r.out.result = _lsa_LookupSids3(p, r.in.sids, r.out.domains, r.in.names, r.in.level, r.in.count, r.in.unknown1, r.in.unknown2); @@ -3906,6 +4098,12 @@ static BOOL api_lsa_LookupNames4(pipes_struct *p) return False; } + r.out.domains = talloc_size(mem_ctx, sizeof(*r.out.domains)); + if (r.out.domains == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.sids = r.in.sids; r.out.count = r.in.count; r.out.result = _lsa_LookupNames4(p, r.in.num_names, r.in.names, r.out.domains, r.in.sids, r.in.level, r.in.count, r.in.unknown1, r.in.unknown2); @@ -4227,7 +4425,7 @@ void lsarpc_get_pipe_fns(struct api_struct **fns, int *n_fns) *n_fns = sizeof(api_lsarpc_cmds) / sizeof(struct api_struct); } -NTSTATUS rpc_netdfs_init(void) +NTSTATUS rpc_lsarpc_init(void) { return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsarpc", api_lsarpc_cmds, sizeof(api_lsarpc_cmds) / sizeof(struct api_struct)); } diff --git a/source3/librpc/gen_ndr/srv_lsa.h b/source3/librpc/gen_ndr/srv_lsa.h index b6fdf5f1d3..4dd3c75415 100644 --- a/source3/librpc/gen_ndr/srv_lsa.h +++ b/source3/librpc/gen_ndr/srv_lsa.h @@ -84,5 +84,5 @@ NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p); NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p); NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p); void lsarpc_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_netdfs_init(void); +NTSTATUS rpc_lsarpc_init(void); #endif /* __SRV_LSARPC__ */ diff --git a/source3/librpc/gen_ndr/srv_unixinfo.c b/source3/librpc/gen_ndr/srv_unixinfo.c index 1c58e94405..e992330866 100644 --- a/source3/librpc/gen_ndr/srv_unixinfo.c +++ b/source3/librpc/gen_ndr/srv_unixinfo.c @@ -31,6 +31,12 @@ static BOOL api_unixinfo_SidToUid(pipes_struct *p) return False; } + r.out.uid = talloc_size(mem_ctx, sizeof(*r.out.uid)); + if (r.out.uid == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _unixinfo_SidToUid(p, r.in.sid, r.out.uid); push = ndr_push_init_ctx(mem_ctx); @@ -81,6 +87,12 @@ static BOOL api_unixinfo_UidToSid(pipes_struct *p) return False; } + r.out.sid = talloc_size(mem_ctx, sizeof(*r.out.sid)); + if (r.out.sid == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _unixinfo_UidToSid(p, r.in.uid, r.out.sid); push = ndr_push_init_ctx(mem_ctx); @@ -131,6 +143,12 @@ static BOOL api_unixinfo_SidToGid(pipes_struct *p) return False; } + r.out.gid = talloc_size(mem_ctx, sizeof(*r.out.gid)); + if (r.out.gid == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _unixinfo_SidToGid(p, r.in.sid, r.out.gid); push = ndr_push_init_ctx(mem_ctx); @@ -181,6 +199,12 @@ static BOOL api_unixinfo_GidToSid(pipes_struct *p) return False; } + r.out.sid = talloc_size(mem_ctx, sizeof(*r.out.sid)); + if (r.out.sid == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _unixinfo_GidToSid(p, r.in.gid, r.out.sid); push = ndr_push_init_ctx(mem_ctx); @@ -232,6 +256,12 @@ static BOOL api_unixinfo_GetPWUid(pipes_struct *p) } r.out.count = r.in.count; + r.out.infos = talloc_array_size(mem_ctx, sizeof(*r.out.infos), *r.in.count); + if (r.out.infos == NULL) { + talloc_free(mem_ctx); + return False; + } + r.out.result = _unixinfo_GetPWUid(p, r.in.count, r.in.uids, r.out.infos); push = ndr_push_init_ctx(mem_ctx); @@ -274,7 +304,7 @@ void unixinfo_get_pipe_fns(struct api_struct **fns, int *n_fns) *n_fns = sizeof(api_unixinfo_cmds) / sizeof(struct api_struct); } -NTSTATUS rpc_netdfs_init(void) +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 index 751b85162d..d21fb839ad 100644 --- a/source3/librpc/gen_ndr/srv_unixinfo.h +++ b/source3/librpc/gen_ndr/srv_unixinfo.h @@ -7,5 +7,5 @@ NTSTATUS _unixinfo_SidToGid(pipes_struct *p, struct dom_sid sid, uint64_t *gid); NTSTATUS _unixinfo_GidToSid(pipes_struct *p, uint64_t gid, struct dom_sid *sid); NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, uint32_t *count, uint64_t *uids, struct unixinfo_GetPWUidInfo *infos); void unixinfo_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_netdfs_init(void); +NTSTATUS rpc_unixinfo_init(void); #endif /* __SRV_UNIXINFO__ */ diff --git a/source3/librpc/gen_ndr/unixinfo.h b/source3/librpc/gen_ndr/unixinfo.h index 78914daebe..8f8984963f 100644 --- a/source3/librpc/gen_ndr/unixinfo.h +++ b/source3/librpc/gen_ndr/unixinfo.h @@ -71,7 +71,7 @@ struct unixinfo_GetPWUid { struct { uint32_t *count;/* [keepref,ref,range(0 1023)] */ - struct unixinfo_GetPWUidInfo *infos;/* [keepref,ref,size_is(*count)] */ + struct unixinfo_GetPWUidInfo *infos;/* [keepref,size_is(*count)] */ NTSTATUS result; } out; diff --git a/source3/rpc_parse/parse_unixinfo.c b/source3/rpc_parse/parse_unixinfo.c deleted file mode 100644 index 72e0d392ec..0000000000 --- a/source3/rpc_parse/parse_unixinfo.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * - * RPC Pipe client / server routines - * - * Copyright (C) Volker Lendecke 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 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" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE - -void init_q_unixinfo_sid_to_uid(UNIXINFO_Q_SID_TO_UID *q_d, const DOM_SID *sid) -{ - sid_copy(&q_d->sid, sid); -} - -BOOL unixinfo_io_q_unixinfo_sid_to_uid(const char *desc, UNIXINFO_Q_SID_TO_UID *q_d, - prs_struct *ps, int depth) -{ - return smb_io_dom_sid(desc, &q_d->sid, ps, depth); -} - -BOOL unixinfo_io_r_unixinfo_sid_to_uid(const char *desc, UNIXINFO_R_SID_TO_UID *r_d, - prs_struct *ps, int depth) -{ - if (!prs_uint64(desc, ps, depth, &r_d->uid)) - return False; - - if (!prs_ntstatus(desc, ps, depth, &r_d->status)) - return False; - - return True; -} - -void init_q_unixinfo_uid_to_sid(UNIXINFO_Q_UID_TO_SID *q_d, uint64 uid) -{ - q_d->uid = uid; -} - -BOOL unixinfo_io_q_unixinfo_uid_to_sid(const char *desc, UNIXINFO_Q_UID_TO_SID *q_d, - prs_struct *ps, int depth) -{ - return prs_uint64(desc, ps, depth, &q_d->uid); -} - -void init_r_unixinfo_uid_to_sid(UNIXINFO_R_UID_TO_SID *r_d, DOM_SID *sid) -{ - if (sid == NULL) { - r_d->sidptr = 0; - return; - } - r_d->sidptr = 1; - sid_copy(&r_d->sid, sid); -} - -BOOL unixinfo_io_r_unixinfo_uid_to_sid(const char *desc, UNIXINFO_R_UID_TO_SID *r_d, - prs_struct *ps, int depth) -{ - if (!prs_uint32("sidptr", ps, depth, &r_d->sidptr)) - return False; - - if (r_d->sidptr != 0) { - if (!smb_io_dom_sid(desc, &r_d->sid, ps, depth)) - return False; - } - - if (!prs_ntstatus(desc, ps, depth, &r_d->status)) - return False; - - return True; -} - -void init_q_unixinfo_sid_to_gid(UNIXINFO_Q_SID_TO_GID *q_d, const DOM_SID *sid) -{ - sid_copy(&q_d->sid, sid); -} - -BOOL unixinfo_io_q_unixinfo_sid_to_gid(const char *desc, UNIXINFO_Q_SID_TO_GID *q_d, - prs_struct *ps, int depth) -{ - return smb_io_dom_sid(desc, &q_d->sid, ps, depth); -} - -void init_r_unixinfo_sid_to_gid(UNIXINFO_R_SID_TO_GID *r_d, uint64 gid) -{ - r_d->gid = gid; - r_d->status = NT_STATUS_OK; -} - -BOOL unixinfo_io_r_unixinfo_sid_to_gid(const char *desc, UNIXINFO_R_SID_TO_GID *r_d, - prs_struct *ps, int depth) -{ - if (!prs_uint64(desc, ps, depth, &r_d->gid)) - return False; - - if (!prs_ntstatus(desc, ps, depth, &r_d->status)) - return False; - - return True; -} - -void init_q_unixinfo_gid_to_sid(UNIXINFO_Q_GID_TO_SID *q_d, uint64 gid) -{ - q_d->gid = gid; -} - -BOOL unixinfo_io_q_unixinfo_gid_to_sid(const char *desc, UNIXINFO_Q_GID_TO_SID *q_d, - prs_struct *ps, int depth) -{ - return prs_uint64(desc, ps, depth, &q_d->gid); -} - -void init_r_unixinfo_gid_to_sid(UNIXINFO_R_GID_TO_SID *r_d, DOM_SID *sid) -{ - if (sid == NULL) { - r_d->sidptr = 0; - return; - } - r_d->sidptr = 1; - sid_copy(&r_d->sid, sid); -} - -BOOL unixinfo_io_r_unixinfo_gid_to_sid(const char *desc, UNIXINFO_R_GID_TO_SID *r_d, - prs_struct *ps, int depth) -{ - if (!prs_uint32("sidptr", ps, depth, &r_d->sidptr)) - return False; - - if (r_d->sidptr != 0) { - if (!smb_io_dom_sid(desc, &r_d->sid, ps, depth)) - return False; - } - - if (!prs_ntstatus(desc, ps, depth, &r_d->status)) - return False; - - return True; -} - -void init_q_unixinfo_getpwuid(UNIXINFO_Q_GETPWUID *r_d, int count, - uint64 *uids) -{ - r_d->count = count; - r_d->uid = uids; -} - -BOOL unixinfo_io_q_unixinfo_getpwuid(const char *desc, - UNIXINFO_Q_GETPWUID *q_d, - prs_struct *ps, int depth) -{ - uint32 arraysize; - int i; - - if (!prs_uint32("count", ps, depth, &q_d->count)) - return False; - - arraysize = q_d->count; - - if (!prs_uint32("arraysize", ps, depth, &arraysize)) - return False; - - if (arraysize != q_d->count) { - DEBUG(10, ("count!=arraysize\n")); - return False; - } - - if (q_d->count > 1023) { - DEBUG(10, ("Range exceeded\n")); - return False; - } - - if (UNMARSHALLING(ps)) { - q_d->uid = PRS_ALLOC_MEM(ps, uint64, q_d->count); - if (q_d->uid == NULL) { - return False; - } - } - - for (i=0; i<q_d->count; i++) { - if (!prs_uint64(desc, ps, depth+1, &q_d->uid[i])) - return False; - } - - return True; -} - -void init_r_unixinfo_getpwuid(UNIXINFO_R_GETPWUID *r_d, uint32 count, - struct unixinfo_getpwuid *info) -{ - r_d->count = count; - r_d->info = info; -} - -BOOL unixinfo_io_r_unixinfo_getpwuid(const char *desc, - UNIXINFO_R_GETPWUID *r_d, - prs_struct *ps, int depth) -{ - uint32 arraysize; - int i; - - if (!prs_uint32("count", ps, depth, &r_d->count)) - return False; - - arraysize = r_d->count; - - if (!prs_uint32("arraysize", ps, depth, &arraysize)) - return False; - - if (arraysize != r_d->count) { - DEBUG(10, ("count!=arraysize\n")); - return False; - } - - if (r_d->count > 1023) { - DEBUG(10, ("Range exceeded\n")); - return False; - } - - if (UNMARSHALLING(ps)) { - r_d->info = PRS_ALLOC_MEM(ps, struct unixinfo_getpwuid, - r_d->count); - if (r_d->info == NULL) { - return False; - } - } - - for (i=0; i<r_d->count; i++) { - if (!prs_align(ps)) - return False; - - if (!prs_ntstatus("status", ps, depth+1, &r_d->info[i].status)) - return False; - - if (!prs_string_alloc("homedir", ps, depth+1, - &r_d->info[i].homedir)) - return False; - - if (!prs_string_alloc("shell", ps, depth+1, - &r_d->info[i].shell)) - return False; - } - - if (!prs_align(ps)) - return False; - - if (!prs_ntstatus(desc, ps, depth, &r_d->status)) - return False; - - return True; -} diff --git a/source3/rpc_server/srv_unixinfo.c b/source3/rpc_server/srv_unixinfo.c deleted file mode 100644 index f21416dfab..0000000000 --- a/source3/rpc_server/srv_unixinfo.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines for unixinfo-pipe - * Copyright (C) Volker Lendecke 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 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. - */ - -/* This is the interface to the rpcunixinfo pipe. */ - -#include "includes.h" -#include "nterr.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -static BOOL api_sid_to_uid(pipes_struct *p) -{ - UNIXINFO_Q_SID_TO_UID q_u; - UNIXINFO_R_SID_TO_UID 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 (!unixinfo_io_q_unixinfo_sid_to_uid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_sid_to_uid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_sid_to_uid("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_uid_to_sid(pipes_struct *p) -{ - UNIXINFO_Q_UID_TO_SID q_u; - UNIXINFO_R_UID_TO_SID 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 (!unixinfo_io_q_unixinfo_uid_to_sid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_uid_to_sid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_uid_to_sid("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_sid_to_gid(pipes_struct *p) -{ - UNIXINFO_Q_SID_TO_GID q_u; - UNIXINFO_R_SID_TO_GID 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 (!unixinfo_io_q_unixinfo_sid_to_gid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_sid_to_gid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_sid_to_gid("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_gid_to_sid(pipes_struct *p) -{ - UNIXINFO_Q_GID_TO_SID q_u; - UNIXINFO_R_GID_TO_SID 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 (!unixinfo_io_q_unixinfo_gid_to_sid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_gid_to_sid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_gid_to_sid("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_getpwuid(pipes_struct *p) -{ - UNIXINFO_Q_GETPWUID q_u; - UNIXINFO_R_GETPWUID 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 (!unixinfo_io_q_unixinfo_getpwuid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_getpwuid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_getpwuid("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* -\pipe\unixinfo commands -********************************************************************/ - -struct api_struct api_unixinfo_cmds[] = { - {"SID_TO_UID", UNIXINFO_SID_TO_UID, api_sid_to_uid }, - {"UID_TO_SID", UNIXINFO_UID_TO_SID, api_uid_to_sid }, - {"SID_TO_GID", UNIXINFO_SID_TO_GID, api_sid_to_gid }, - {"GID_TO_SID", UNIXINFO_GID_TO_SID, api_gid_to_sid }, - {"GETPWUID", UNIXINFO_GETPWUID, api_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/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c index 5afbb7bed0..321c6a6a5e 100644 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -23,120 +23,92 @@ #include "includes.h" #include "nterr.h" + + #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV /* Map a sid to a uid */ -NTSTATUS _unixinfo_sid_to_uid(pipes_struct *p, - UNIXINFO_Q_SID_TO_UID *q_u, - UNIXINFO_R_SID_TO_UID *r_u) +NTSTATUS _unixinfo_SidToUid(pipes_struct *p, struct dom_sid sid, uint64_t *uid) { - uid_t uid; + uid_t real_uid; + NTSTATUS status; + *uid = 0; - r_u->uid = 0; + status = sid_to_uid(&sid, &real_uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; + if (NT_STATUS_IS_OK(status)) + *uid = real_uid; - r_u->status = sid_to_uid(&q_u->sid, &uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; - if (NT_STATUS_IS_OK(r_u->status)) - r_u->uid = uid; - - return r_u->status; + return status; } /* Map a uid to a sid */ -NTSTATUS _unixinfo_uid_to_sid(pipes_struct *p, - UNIXINFO_Q_UID_TO_SID *q_u, - UNIXINFO_R_UID_TO_SID *r_u) +NTSTATUS _unixinfo_UidToSid(pipes_struct *p, uint64_t uid, struct dom_sid *sid) { - DOM_SID sid; + NTSTATUS status = NT_STATUS_NO_SUCH_USER; - r_u->status = NT_STATUS_NO_SUCH_USER; + uid_to_sid(sid, (uid_t)uid); + status = NT_STATUS_OK; - if (q_u->uid == 0) { - uid_to_sid(&sid, q_u->uid); - r_u->status = NT_STATUS_OK; - } - - init_r_unixinfo_uid_to_sid(r_u, - NT_STATUS_IS_OK(r_u->status) ? &sid : NULL); - - return r_u->status; + return status; } /* Map a sid to a gid */ -NTSTATUS _unixinfo_sid_to_gid(pipes_struct *p, - UNIXINFO_Q_SID_TO_GID *q_u, - UNIXINFO_R_SID_TO_GID *r_u) +NTSTATUS _unixinfo_SidToGid(pipes_struct *p, struct dom_sid sid, uint64_t *gid) { - gid_t gid; + gid_t real_gid; + NTSTATUS status; - r_u->gid = 0; + *gid = 0; - r_u->status = sid_to_gid(&q_u->sid, &gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; - if (NT_STATUS_IS_OK(r_u->status)) - r_u->gid = gid; + status = sid_to_gid(&sid, &real_gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; + if (NT_STATUS_IS_OK(status)) + *gid = real_gid; - return r_u->status; + return status; } /* Map a gid to a sid */ -NTSTATUS _unixinfo_gid_to_sid(pipes_struct *p, - UNIXINFO_Q_GID_TO_SID *q_u, - UNIXINFO_R_GID_TO_SID *r_u) +NTSTATUS _unixinfo_GidToSid(pipes_struct *p, uint64_t gid, struct dom_sid *sid) { - DOM_SID sid; + NTSTATUS status = NT_STATUS_NO_SUCH_GROUP; - r_u->status = NT_STATUS_NO_SUCH_GROUP; + gid_to_sid(sid, (gid_t)gid); + status = NT_STATUS_OK; - if (q_u->gid == 0) { - gid_to_sid(&sid, q_u->gid); - r_u->status = NT_STATUS_OK; - } - - init_r_unixinfo_gid_to_sid(r_u, - NT_STATUS_IS_OK(r_u->status) ? &sid : NULL); - - return r_u->status; + return status; } /* Get unix struct passwd information */ -NTSTATUS _unixinfo_getpwuid(pipes_struct *p, - UNIXINFO_Q_GETPWUID *q_u, - UNIXINFO_R_GETPWUID *r_u) +NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, uint32_t *count, uint64_t *uids, + struct unixinfo_GetPWUidInfo *infos) { int i; + NTSTATUS status; - if (r_u->count > 1023) { + if (*count > 1023) return NT_STATUS_INVALID_PARAMETER; - } - - r_u->info = TALLOC_ARRAY(p->mem_ctx, struct unixinfo_getpwuid, - q_u->count); - - if ((r_u->count > 0) && (r_u->info == NULL)) { - return NT_STATUS_NO_MEMORY; - } - r_u->status = NT_STATUS_OK; - r_u->count = q_u->count; + status = NT_STATUS_OK; - for (i=0; i<r_u->count; i++) { + for (i=0; i<*count; i++) { struct passwd *pw; char *homedir, *shell; ssize_t len1, len2; - r_u->info[i].status = NT_STATUS_NO_SUCH_USER; - r_u->info[i].homedir = ""; - r_u->info[i].shell = ""; + infos[i].status = NT_STATUS_NO_SUCH_USER; + infos[i].homedir = ""; + infos[i].shell = ""; - pw = getpwuid(q_u->uid[i]); + pw = getpwuid(uids[i]); if (pw == NULL) { - DEBUG(10, ("Did not find uid %lld\n", q_u->uid[i])); + DEBUG(10, ("Did not find uid %lld\n", uids[i])); continue; } @@ -146,14 +118,14 @@ NTSTATUS _unixinfo_getpwuid(pipes_struct *p, if ((len1 < 0) || (len2 < 0) || (homedir == NULL) || (shell == NULL)) { DEBUG(3, ("push_utf8_talloc failed\n")); - r_u->info[i].status = NT_STATUS_NO_MEMORY; + infos[i].status = NT_STATUS_NO_MEMORY; continue; } - r_u->info[i].status = NT_STATUS_OK; - r_u->info[i].homedir = homedir; - r_u->info[i].shell = shell; + infos[i].status = NT_STATUS_OK; + infos[i].homedir = homedir; + infos[i].shell = shell; } - return r_u->status; + return status; } |