diff options
Diffstat (limited to 'source3/librpc/ndr')
-rw-r--r-- | source3/librpc/ndr/libndr.h | 4 | ||||
-rw-r--r-- | source3/librpc/ndr/misc.h | 42 | ||||
-rw-r--r-- | source3/librpc/ndr/ndr.c | 22 | ||||
-rw-r--r-- | source3/librpc/ndr/ndr_basic.c | 3 | ||||
-rw-r--r-- | source3/librpc/ndr/ndr_krb5pac.c | 141 | ||||
-rw-r--r-- | source3/librpc/ndr/ndr_misc.c | 149 | ||||
-rw-r--r-- | source3/librpc/ndr/ndr_sec_helper.c | 815 | ||||
-rw-r--r-- | source3/librpc/ndr/ndr_string.c | 3 | ||||
-rw-r--r-- | source3/librpc/ndr/security.h | 257 | ||||
-rw-r--r-- | source3/librpc/ndr/sid.c | 67 |
10 files changed, 163 insertions, 1340 deletions
diff --git a/source3/librpc/ndr/libndr.h b/source3/librpc/ndr/libndr.h index d0c2c74db9..a277a626c7 100644 --- a/source3/librpc/ndr/libndr.h +++ b/source3/librpc/ndr/libndr.h @@ -22,8 +22,8 @@ #define _PRINTF_ATTRIBUTE(a,b) -#include "librpc/ndr/misc.h" -#include "librpc/ndr/security.h" +#include "librpc/gen_ndr/misc.h" +#include "librpc/gen_ndr/security.h" /* this provides definitions for the libcli/rpc/ MSRPC library diff --git a/source3/librpc/ndr/misc.h b/source3/librpc/ndr/misc.h deleted file mode 100644 index 71975d7858..0000000000 --- a/source3/librpc/ndr/misc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* header auto-generated by pidl */ - -#ifndef _HEADER_misc -#define _HEADER_misc - -struct GUID { - uint32_t time_low; - uint16_t time_mid; - uint16_t time_hi_and_version; - uint8_t clock_seq[2]; - uint8_t node[6]; -}/* [noprint,gensize,public,noejs] */; - -struct ndr_syntax_id { - struct GUID uuid; - uint32_t if_version; -}/* [public] */; - -struct policy_handle { - uint32_t handle_type; - struct GUID uuid; -}/* [public] */; - -enum netr_SchannelType { - SEC_CHAN_WKSTA=2, - SEC_CHAN_DOMAIN=4, - SEC_CHAN_BDC=6 -}; - -enum netr_SamDatabaseID { - SAM_DATABASE_DOMAIN=0, - SAM_DATABASE_BUILTIN=1, - SAM_DATABASE_PRIVS=2 -}; - -enum samr_RejectReason { - SAMR_REJECT_OTHER=0, - SAMR_REJECT_TOO_SHORT=1, - SAMR_REJECT_COMPLEXITY=2 -}; - -#endif /* _HEADER_misc */ 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;i<ndr->depth;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;i<count;i++) { char *idx=NULL; - asprintf(&idx, "[%d]", i); - if (idx) { + if (asprintf(&idx, "[%d]", i) != -1) { ndr_print_uint8(ndr, idx, data[i]); free(idx); } 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 <http://www.gnu.org/licenses/>. +*/ + + +#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--; +} diff --git a/source3/librpc/ndr/ndr_misc.c b/source3/librpc/ndr/ndr_misc.c index 245ba45215..79761b9251 100644 --- a/source3/librpc/ndr/ndr_misc.c +++ b/source3/librpc/ndr/ndr_misc.c @@ -24,41 +24,6 @@ #include "includes.h" -enum ndr_err_code ndr_push_GUID(struct ndr_push *ndr, int ndr_flags, const struct GUID *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->time_low)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->time_mid)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->time_hi_and_version)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->clock_seq, 2)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->node, 6)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_GUID(struct ndr_pull *ndr, int ndr_flags, struct GUID *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->time_low)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->time_mid)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->time_hi_and_version)); - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->clock_seq, 2)); - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->node, 6)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -size_t ndr_size_GUID(const struct GUID *r, int flags) -{ - return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_GUID); -} - /** * see if a range of memory is all zero. A NULL pointer is considered * to be all zero @@ -78,39 +43,6 @@ void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID * ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); } -enum ndr_err_code ndr_push_policy_handle(struct ndr_push *ndr, int ndr_flags, const struct policy_handle *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->handle_type)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->uuid)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_policy_handle(struct ndr_pull *ndr, int ndr_flags, struct policy_handle *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->handle_type)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->uuid)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, const struct policy_handle *r) -{ - ndr_print_struct(ndr, name, "policy_handle"); - ndr->depth++; - ndr_print_uint32(ndr, "handle_type", r->handle_type); - ndr_print_GUID(ndr, "uuid", &r->uuid); - ndr->depth--; -} - enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r) { if (ndr_flags & NDR_SCALARS) { @@ -153,84 +85,3 @@ void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct s #endif ndr->depth--; } - -void ndr_print_ads_struct(struct ndr_print *ndr, const char *name, const struct ads_struct *r) -{ - if (!r) { return; } - - ndr_print_struct(ndr, name, "ads_struct"); - ndr->depth++; - ndr_print_bool(ndr, "is_mine", r->is_mine); - ndr_print_struct(ndr, name, "server"); - ndr->depth++; - ndr_print_string(ndr, "realm", r->server.realm); - ndr_print_string(ndr, "workgroup", r->server.workgroup); - ndr_print_string(ndr, "ldap_server", r->server.ldap_server); - ndr_print_bool(ndr, "foreign", r->server.foreign); - ndr->depth--; - ndr_print_struct(ndr, name, "auth"); - ndr->depth++; - ndr_print_string(ndr, "realm", r->auth.realm); -#ifdef DEBUG_PASSWORD - ndr_print_string(ndr, "password", r->auth.password); -#else - ndr_print_string(ndr, "password", "(PASSWORD ommited)"); -#endif - ndr_print_string(ndr, "user_name", r->auth.user_name); - ndr_print_string(ndr, "kdc_server", r->auth.kdc_server); - ndr_print_uint32(ndr, "flags", r->auth.flags); - ndr_print_uint32(ndr, "time_offset", r->auth.time_offset); - ndr_print_time_t(ndr, "tgt_expire", r->auth.tgt_expire); - ndr_print_time_t(ndr, "tgs_expire", r->auth.tgs_expire); - ndr_print_time_t(ndr, "renewable", r->auth.renewable); - ndr->depth--; - ndr_print_struct(ndr, name, "config"); - ndr->depth++; - ndr_print_uint32(ndr, "flags", r->config.flags); - ndr_print_string(ndr, "realm", r->config.realm); - ndr_print_string(ndr, "bind_path", r->config.bind_path); - ndr_print_string(ndr, "ldap_server_name", r->config.ldap_server_name); - ndr_print_string(ndr, "server_site_name", r->config.server_site_name); - ndr_print_string(ndr, "client_site_name", r->config.client_site_name); - ndr_print_time_t(ndr, "current_time", r->config.current_time); - ndr_print_bool(ndr, "tried_closest_dc", r->config.tried_closest_dc); - ndr_print_string(ndr, "schema_path", r->config.schema_path); - ndr_print_string(ndr, "config_path", r->config.config_path); - ndr->depth--; -#ifdef HAVE_LDAP - ndr_print_struct(ndr, name, "ldap"); - ndr->depth++; - ndr_print_ptr(ndr, "ld", r->ldap.ld); - ndr_print_sockaddr_storage(ndr, "ss", &r->ldap.ss); - ndr_print_time_t(ndr, "last_attempt", r->ldap.last_attempt); - ndr_print_uint32(ndr, "port", r->ldap.port); - ndr_print_uint16(ndr, "wrap_type", r->ldap.wrap_type); -#ifdef HAVE_LDAP_SASL_WRAPPING - ndr_print_ptr(ndr, "sbiod", r->ldap.sbiod); -#endif /* HAVE_LDAP_SASL_WRAPPING */ - ndr_print_ptr(ndr, "mem_ctx", r->ldap.mem_ctx); - ndr_print_ptr(ndr, "wrap_ops", r->ldap.wrap_ops); - ndr_print_ptr(ndr, "wrap_private_data", r->ldap.wrap_private_data); - ndr_print_struct(ndr, name, "in"); - ndr->depth++; - ndr_print_uint32(ndr, "ofs", r->ldap.in.ofs); - ndr_print_uint32(ndr, "needed", r->ldap.in.needed); - ndr_print_uint32(ndr, "left", r->ldap.in.left); - ndr_print_uint32(ndr, "max_wrapped", r->ldap.in.max_wrapped); - ndr_print_uint32(ndr, "min_wrapped", r->ldap.in.min_wrapped); - ndr_print_uint32(ndr, "size", r->ldap.in.size); - ndr_print_array_uint8(ndr, "buf", r->ldap.in.buf, r->ldap.in.size); - ndr->depth--; - ndr_print_struct(ndr, name, "out"); - ndr->depth++; - ndr_print_uint32(ndr, "ofs", r->ldap.out.ofs); - ndr_print_uint32(ndr, "left", r->ldap.out.left); - ndr_print_uint32(ndr, "max_unwrapped", r->ldap.out.max_unwrapped); - ndr_print_uint32(ndr, "sig_size", r->ldap.out.sig_size); - ndr_print_uint32(ndr, "size", r->ldap.out.size); - ndr_print_array_uint8(ndr, "buf", r->ldap.out.buf, r->ldap.out.size); - ndr->depth--; - ndr->depth--; -#endif /* HAVE_LDAP */ - ndr->depth--; -} diff --git a/source3/librpc/ndr/ndr_sec_helper.c b/source3/librpc/ndr/ndr_sec_helper.c index d1938b9588..f8bad6ca61 100644 --- a/source3/librpc/ndr/ndr_sec_helper.c +++ b/source3/librpc/ndr/ndr_sec_helper.c @@ -89,818 +89,3 @@ void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct d { ndr_print_dom_sid(ndr, name, sid); } - -static enum ndr_err_code ndr_push_security_ace_flags(struct ndr_push *ndr, int ndr_flags, uint8_t r) -{ - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_ace_flags(struct ndr_pull *ndr, int ndr_flags, uint8_t *r) -{ - uint8_t v; - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v)); - *r = v; - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_ace_flags(struct ndr_print *ndr, const char *name, uint8_t r) -{ - ndr_print_uint8(ndr, name, r); - ndr->depth++; - ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_OBJECT_INHERIT", SEC_ACE_FLAG_OBJECT_INHERIT, r); - ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_CONTAINER_INHERIT", SEC_ACE_FLAG_CONTAINER_INHERIT, r); - ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_NO_PROPAGATE_INHERIT", SEC_ACE_FLAG_NO_PROPAGATE_INHERIT, r); - ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_INHERIT_ONLY", SEC_ACE_FLAG_INHERIT_ONLY, r); - ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_INHERITED_ACE", SEC_ACE_FLAG_INHERITED_ACE, r); - ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_VALID_INHERIT", SEC_ACE_FLAG_VALID_INHERIT, r); - ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_SUCCESSFUL_ACCESS", SEC_ACE_FLAG_SUCCESSFUL_ACCESS, r); - ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_FAILED_ACCESS", SEC_ACE_FLAG_FAILED_ACCESS, r); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_security_ace_type(struct ndr_push *ndr, int ndr_flags, enum security_ace_type r) -{ - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_ace_type(struct ndr_pull *ndr, int ndr_flags, enum security_ace_type *r) -{ - uint8_t v; - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v)); - *r = (enum security_ace_type)v; - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_ace_type(struct ndr_print *ndr, const char *name, enum security_ace_type r) -{ - const char *val = NULL; - - switch (r) { - case SEC_ACE_TYPE_ACCESS_ALLOWED: val = "SEC_ACE_TYPE_ACCESS_ALLOWED"; break; - case SEC_ACE_TYPE_ACCESS_DENIED: val = "SEC_ACE_TYPE_ACCESS_DENIED"; break; - case SEC_ACE_TYPE_SYSTEM_AUDIT: val = "SEC_ACE_TYPE_SYSTEM_AUDIT"; break; - case SEC_ACE_TYPE_SYSTEM_ALARM: val = "SEC_ACE_TYPE_SYSTEM_ALARM"; break; - case SEC_ACE_TYPE_ALLOWED_COMPOUND: val = "SEC_ACE_TYPE_ALLOWED_COMPOUND"; break; - case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: val = "SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT"; break; - case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: val = "SEC_ACE_TYPE_ACCESS_DENIED_OBJECT"; break; - case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: val = "SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT"; break; - case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: val = "SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT"; break; - } - ndr_print_enum(ndr, name, "ENUM", val, r); -} - -static enum ndr_err_code ndr_push_security_ace_object_flags(struct ndr_push *ndr, int ndr_flags, uint32_t r) -{ - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_ace_object_flags(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; -} - -void ndr_print_security_ace_object_flags(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), "SEC_ACE_OBJECT_TYPE_PRESENT", SEC_ACE_OBJECT_TYPE_PRESENT, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT", SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT, r); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_security_ace_object_type(struct ndr_push *ndr, int ndr_flags, const union security_ace_object_type *r) -{ - int level; - level = ndr_push_get_switch_value(ndr, r); - if (ndr_flags & NDR_SCALARS) { - switch (level) { - case SEC_ACE_OBJECT_TYPE_PRESENT: - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->type)); - break; - - default: - break; - - } - } - if (ndr_flags & NDR_BUFFERS) { - switch (level) { - case SEC_ACE_OBJECT_TYPE_PRESENT: - break; - - default: - break; - - } - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_ace_object_type(struct ndr_pull *ndr, int ndr_flags, union security_ace_object_type *r) -{ - int level; - level = ndr_pull_get_switch_value(ndr, r); - if (ndr_flags & NDR_SCALARS) { - switch (level) { - case SEC_ACE_OBJECT_TYPE_PRESENT: { - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->type)); - break; } - - default: { - break; } - - } - } - if (ndr_flags & NDR_BUFFERS) { - switch (level) { - case SEC_ACE_OBJECT_TYPE_PRESENT: - break; - - default: - break; - - } - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_ace_object_type(struct ndr_print *ndr, const char *name, const union security_ace_object_type *r) -{ - int level; - level = ndr_print_get_switch_value(ndr, r); - ndr_print_union(ndr, name, level, "security_ace_object_type"); - switch (level) { - case SEC_ACE_OBJECT_TYPE_PRESENT: - ndr_print_GUID(ndr, "type", &r->type); - break; - - default: - break; - - } -} - -static enum ndr_err_code ndr_push_security_ace_object_inherited_type(struct ndr_push *ndr, int ndr_flags, const union security_ace_object_inherited_type *r) -{ - int level; - level = ndr_push_get_switch_value(ndr, r); - if (ndr_flags & NDR_SCALARS) { - switch (level) { - case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT: - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->inherited_type)); - break; - - default: - break; - - } - } - if (ndr_flags & NDR_BUFFERS) { - switch (level) { - case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT: - break; - - default: - break; - - } - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_ace_object_inherited_type(struct ndr_pull *ndr, int ndr_flags, union security_ace_object_inherited_type *r) -{ - int level; - level = ndr_pull_get_switch_value(ndr, r); - if (ndr_flags & NDR_SCALARS) { - switch (level) { - case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT: { - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->inherited_type)); - break; } - - default: { - break; } - - } - } - if (ndr_flags & NDR_BUFFERS) { - switch (level) { - case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT: - break; - - default: - break; - - } - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_ace_object_inherited_type(struct ndr_print *ndr, const char *name, const union security_ace_object_inherited_type *r) -{ - int level; - level = ndr_print_get_switch_value(ndr, r); - ndr_print_union(ndr, name, level, "security_ace_object_inherited_type"); - switch (level) { - case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT: - ndr_print_GUID(ndr, "inherited_type", &r->inherited_type); - break; - - default: - break; - - } -} - -static enum ndr_err_code ndr_push_security_ace_object(struct ndr_push *ndr, int ndr_flags, const struct security_ace_object *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_security_ace_object_flags(ndr, NDR_SCALARS, r->flags)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->type, r->flags&SEC_ACE_OBJECT_TYPE_PRESENT)); - NDR_CHECK(ndr_push_security_ace_object_type(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->inherited_type, r->flags&SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT)); - NDR_CHECK(ndr_push_security_ace_object_inherited_type(ndr, NDR_SCALARS, &r->inherited_type)); - } - if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_security_ace_object_type(ndr, NDR_BUFFERS, &r->type)); - NDR_CHECK(ndr_push_security_ace_object_inherited_type(ndr, NDR_BUFFERS, &r->inherited_type)); - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_ace_object(struct ndr_pull *ndr, int ndr_flags, struct security_ace_object *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_security_ace_object_flags(ndr, NDR_SCALARS, &r->flags)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->type, r->flags&SEC_ACE_OBJECT_TYPE_PRESENT)); - NDR_CHECK(ndr_pull_security_ace_object_type(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->inherited_type, r->flags&SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT)); - NDR_CHECK(ndr_pull_security_ace_object_inherited_type(ndr, NDR_SCALARS, &r->inherited_type)); - } - if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_security_ace_object_type(ndr, NDR_BUFFERS, &r->type)); - NDR_CHECK(ndr_pull_security_ace_object_inherited_type(ndr, NDR_BUFFERS, &r->inherited_type)); - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_ace_object(struct ndr_print *ndr, const char *name, const struct security_ace_object *r) -{ - ndr_print_struct(ndr, name, "security_ace_object"); - ndr->depth++; - ndr_print_security_ace_object_flags(ndr, "flags", r->flags); - ndr_print_set_switch_value(ndr, &r->type, r->flags&SEC_ACE_OBJECT_TYPE_PRESENT); - ndr_print_security_ace_object_type(ndr, "type", &r->type); - ndr_print_set_switch_value(ndr, &r->inherited_type, r->flags&SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT); - ndr_print_security_ace_object_inherited_type(ndr, "inherited_type", &r->inherited_type); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_security_ace_object_ctr(struct ndr_push *ndr, int ndr_flags, const union security_ace_object_ctr *r) -{ - int level; - level = ndr_push_get_switch_value(ndr, r); - if (ndr_flags & NDR_SCALARS) { - switch (level) { - case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: - NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_SCALARS, &r->object)); - break; - - case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: - NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_SCALARS, &r->object)); - break; - - case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: - NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_SCALARS, &r->object)); - break; - - case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: - NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_SCALARS, &r->object)); - break; - - default: - break; - - } - } - if (ndr_flags & NDR_BUFFERS) { - switch (level) { - case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: - NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_BUFFERS, &r->object)); - break; - - case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: - NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_BUFFERS, &r->object)); - break; - - case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: - NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_BUFFERS, &r->object)); - break; - - case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: - NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_BUFFERS, &r->object)); - break; - - default: - break; - - } - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_ace_object_ctr(struct ndr_pull *ndr, int ndr_flags, union security_ace_object_ctr *r) -{ - int level; - level = ndr_pull_get_switch_value(ndr, r); - if (ndr_flags & NDR_SCALARS) { - switch (level) { - case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: { - NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_SCALARS, &r->object)); - break; } - - case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: { - NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_SCALARS, &r->object)); - break; } - - case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: { - NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_SCALARS, &r->object)); - break; } - - case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: { - NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_SCALARS, &r->object)); - break; } - - default: { - break; } - - } - } - if (ndr_flags & NDR_BUFFERS) { - switch (level) { - case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: - NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_BUFFERS, &r->object)); - break; - - case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: - NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_BUFFERS, &r->object)); - break; - - case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: - NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_BUFFERS, &r->object)); - break; - - case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: - NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_BUFFERS, &r->object)); - break; - - default: - break; - - } - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_ace_object_ctr(struct ndr_print *ndr, const char *name, const union security_ace_object_ctr *r) -{ - int level; - level = ndr_print_get_switch_value(ndr, r); - ndr_print_union(ndr, name, level, "security_ace_object_ctr"); - switch (level) { - case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: - ndr_print_security_ace_object(ndr, "object", &r->object); - break; - - case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: - ndr_print_security_ace_object(ndr, "object", &r->object); - break; - - case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: - ndr_print_security_ace_object(ndr, "object", &r->object); - break; - - case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: - ndr_print_security_ace_object(ndr, "object", &r->object); - break; - - default: - break; - - } -} - -enum ndr_err_code ndr_push_security_ace(struct ndr_push *ndr, int ndr_flags, const struct security_ace *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_security_ace_type(ndr, NDR_SCALARS, r->type)); - NDR_CHECK(ndr_push_security_ace_flags(ndr, NDR_SCALARS, r->flags)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, ndr_size_security_ace(r,ndr->flags))); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->access_mask)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->object, r->type)); - NDR_CHECK(ndr_push_security_ace_object_ctr(ndr, NDR_SCALARS, &r->object)); - NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, &r->trustee)); - } - if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_security_ace_object_ctr(ndr, NDR_BUFFERS, &r->object)); - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_security_ace(struct ndr_pull *ndr, int ndr_flags, struct security_ace *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_security_ace_type(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_security_ace_flags(ndr, NDR_SCALARS, &r->flags)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->access_mask)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->object, r->type)); - NDR_CHECK(ndr_pull_security_ace_object_ctr(ndr, NDR_SCALARS, &r->object)); - NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, &r->trustee)); - } - if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_security_ace_object_ctr(ndr, NDR_BUFFERS, &r->object)); - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_ace(struct ndr_print *ndr, const char *name, const struct security_ace *r) -{ - ndr_print_struct(ndr, name, "security_ace"); - ndr->depth++; - ndr_print_security_ace_type(ndr, "type", r->type); - ndr_print_security_ace_flags(ndr, "flags", r->flags); - ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_security_ace(r,ndr->flags):r->size); - ndr_print_uint32(ndr, "access_mask", r->access_mask); - ndr_print_set_switch_value(ndr, &r->object, r->type); - ndr_print_security_ace_object_ctr(ndr, "object", &r->object); - ndr_print_dom_sid(ndr, "trustee", &r->trustee); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_security_acl_revision(struct ndr_push *ndr, int ndr_flags, enum security_acl_revision r) -{ - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_acl_revision(struct ndr_pull *ndr, int ndr_flags, enum security_acl_revision *r) -{ - uint16_t v; - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); - *r = (enum security_acl_revision)v; - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_acl_revision(struct ndr_print *ndr, const char *name, enum security_acl_revision r) -{ - const char *val = NULL; - - switch (r) { - case SECURITY_ACL_REVISION_NT4: val = "SECURITY_ACL_REVISION_NT4"; break; - case SECURITY_ACL_REVISION_ADS: val = "SECURITY_ACL_REVISION_ADS"; break; - } - ndr_print_enum(ndr, name, "ENUM", val, r); -} - -enum ndr_err_code ndr_push_security_acl(struct ndr_push *ndr, int ndr_flags, const struct security_acl *r) -{ - uint32_t cntr_aces_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_security_acl_revision(ndr, NDR_SCALARS, r->revision)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, ndr_size_security_acl(r,ndr->flags))); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_aces)); - for (cntr_aces_0 = 0; cntr_aces_0 < r->num_aces; cntr_aces_0++) { - NDR_CHECK(ndr_push_security_ace(ndr, NDR_SCALARS, &r->aces[cntr_aces_0])); - } - } - if (ndr_flags & NDR_BUFFERS) { - for (cntr_aces_0 = 0; cntr_aces_0 < r->num_aces; cntr_aces_0++) { - NDR_CHECK(ndr_push_security_ace(ndr, NDR_BUFFERS, &r->aces[cntr_aces_0])); - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_security_acl(struct ndr_pull *ndr, int ndr_flags, struct security_acl *r) -{ - uint32_t cntr_aces_0; - TALLOC_CTX *_mem_save_aces_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_security_acl_revision(ndr, NDR_SCALARS, &r->revision)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_aces)); - if (r->num_aces > 1000) { /* num_aces is unsigned */ - return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); - } - NDR_PULL_ALLOC_N(ndr, r->aces, r->num_aces); - _mem_save_aces_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->aces, 0); - for (cntr_aces_0 = 0; cntr_aces_0 < r->num_aces; cntr_aces_0++) { - NDR_CHECK(ndr_pull_security_ace(ndr, NDR_SCALARS, &r->aces[cntr_aces_0])); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_aces_0, 0); - } - if (ndr_flags & NDR_BUFFERS) { - _mem_save_aces_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->aces, 0); - for (cntr_aces_0 = 0; cntr_aces_0 < r->num_aces; cntr_aces_0++) { - NDR_CHECK(ndr_pull_security_ace(ndr, NDR_BUFFERS, &r->aces[cntr_aces_0])); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_aces_0, 0); - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_acl(struct ndr_print *ndr, const char *name, const struct security_acl *r) -{ - uint32_t cntr_aces_0; - ndr_print_struct(ndr, name, "security_acl"); - ndr->depth++; - ndr_print_security_acl_revision(ndr, "revision", r->revision); - ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_security_acl(r,ndr->flags):r->size); - ndr_print_uint32(ndr, "num_aces", r->num_aces); - ndr->print(ndr, "%s: ARRAY(%d)", "aces", r->num_aces); - ndr->depth++; - for (cntr_aces_0=0;cntr_aces_0<r->num_aces;cntr_aces_0++) { - char *idx_0=NULL; - asprintf(&idx_0, "[%d]", cntr_aces_0); - if (idx_0) { - ndr_print_security_ace(ndr, "aces", &r->aces[cntr_aces_0]); - free(idx_0); - } - } - ndr->depth--; - ndr->depth--; -} - -static enum ndr_err_code ndr_push_security_descriptor_revision(struct ndr_push *ndr, int ndr_flags, enum security_descriptor_revision r) -{ - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_descriptor_revision(struct ndr_pull *ndr, int ndr_flags, enum security_descriptor_revision *r) -{ - uint8_t v; - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v)); - *r = (enum security_descriptor_revision)v; - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_descriptor_revision(struct ndr_print *ndr, const char *name, enum security_descriptor_revision r) -{ - const char *val = NULL; - - switch (r) { - case SECURITY_DESCRIPTOR_REVISION_1: val = "SECURITY_DESCRIPTOR_REVISION_1"; break; - } - ndr_print_enum(ndr, name, "ENUM", val, r); -} - -static enum ndr_err_code ndr_push_security_descriptor_type(struct ndr_push *ndr, int ndr_flags, uint16_t r) -{ - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_security_descriptor_type(struct ndr_pull *ndr, int ndr_flags, uint16_t *r) -{ - uint16_t v; - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); - *r = v; - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_descriptor_type(struct ndr_print *ndr, const char *name, uint16_t r) -{ - ndr_print_uint16(ndr, name, r); - ndr->depth++; - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_OWNER_DEFAULTED", SEC_DESC_OWNER_DEFAULTED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_GROUP_DEFAULTED", SEC_DESC_GROUP_DEFAULTED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_PRESENT", SEC_DESC_DACL_PRESENT, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_DEFAULTED", SEC_DESC_DACL_DEFAULTED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_PRESENT", SEC_DESC_SACL_PRESENT, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_DEFAULTED", SEC_DESC_SACL_DEFAULTED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_TRUSTED", SEC_DESC_DACL_TRUSTED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SERVER_SECURITY", SEC_DESC_SERVER_SECURITY, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_AUTO_INHERIT_REQ", SEC_DESC_DACL_AUTO_INHERIT_REQ, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_AUTO_INHERIT_REQ", SEC_DESC_SACL_AUTO_INHERIT_REQ, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_AUTO_INHERITED", SEC_DESC_DACL_AUTO_INHERITED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_AUTO_INHERITED", SEC_DESC_SACL_AUTO_INHERITED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_PROTECTED", SEC_DESC_DACL_PROTECTED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_PROTECTED", SEC_DESC_SACL_PROTECTED, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_RM_CONTROL_VALID", SEC_DESC_RM_CONTROL_VALID, r); - ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SELF_RELATIVE", SEC_DESC_SELF_RELATIVE, r); - ndr->depth--; -} - -enum ndr_err_code ndr_push_security_descriptor(struct ndr_push *ndr, int ndr_flags, const struct security_descriptor *r) -{ - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN); - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_security_descriptor_revision(ndr, NDR_SCALARS, r->revision)); - NDR_CHECK(ndr_push_security_descriptor_type(ndr, NDR_SCALARS, r->type)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->owner_sid)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->group_sid)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->sacl)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->dacl)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->owner_sid) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->owner_sid)); - NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->owner_sid)); - } - if (r->group_sid) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->group_sid)); - NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->group_sid)); - } - if (r->sacl) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->sacl)); - NDR_CHECK(ndr_push_security_acl(ndr, NDR_SCALARS|NDR_BUFFERS, r->sacl)); - } - if (r->dacl) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->dacl)); - NDR_CHECK(ndr_push_security_acl(ndr, NDR_SCALARS|NDR_BUFFERS, r->dacl)); - } - } - ndr->flags = _flags_save_STRUCT; - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_security_descriptor(struct ndr_pull *ndr, int ndr_flags, struct security_descriptor *r) -{ - uint32_t _ptr_owner_sid; - TALLOC_CTX *_mem_save_owner_sid_0; - uint32_t _ptr_group_sid; - TALLOC_CTX *_mem_save_group_sid_0; - uint32_t _ptr_sacl; - TALLOC_CTX *_mem_save_sacl_0; - uint32_t _ptr_dacl; - TALLOC_CTX *_mem_save_dacl_0; - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN); - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_security_descriptor_revision(ndr, NDR_SCALARS, &r->revision)); - NDR_CHECK(ndr_pull_security_descriptor_type(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_owner_sid)); - if (_ptr_owner_sid) { - NDR_PULL_ALLOC(ndr, r->owner_sid); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->owner_sid, _ptr_owner_sid)); - } else { - r->owner_sid = NULL; - } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_group_sid)); - if (_ptr_group_sid) { - NDR_PULL_ALLOC(ndr, r->group_sid); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->group_sid, _ptr_group_sid)); - } else { - r->group_sid = NULL; - } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sacl)); - if (_ptr_sacl) { - NDR_PULL_ALLOC(ndr, r->sacl); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->sacl, _ptr_sacl)); - } else { - r->sacl = NULL; - } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dacl)); - if (_ptr_dacl) { - NDR_PULL_ALLOC(ndr, r->dacl); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->dacl, _ptr_dacl)); - } else { - r->dacl = NULL; - } - } - if (ndr_flags & NDR_BUFFERS) { - if (r->owner_sid) { - struct ndr_pull_save _relative_save; - ndr_pull_save(ndr, &_relative_save); - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->owner_sid)); - _mem_save_owner_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->owner_sid, 0); - NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->owner_sid)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_owner_sid_0, 0); - ndr_pull_restore(ndr, &_relative_save); - } - if (r->group_sid) { - struct ndr_pull_save _relative_save; - ndr_pull_save(ndr, &_relative_save); - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->group_sid)); - _mem_save_group_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->group_sid, 0); - NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->group_sid)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_group_sid_0, 0); - ndr_pull_restore(ndr, &_relative_save); - } - if (r->sacl) { - struct ndr_pull_save _relative_save; - ndr_pull_save(ndr, &_relative_save); - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->sacl)); - _mem_save_sacl_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->sacl, 0); - NDR_CHECK(ndr_pull_security_acl(ndr, NDR_SCALARS|NDR_BUFFERS, r->sacl)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sacl_0, 0); - ndr_pull_restore(ndr, &_relative_save); - } - if (r->dacl) { - struct ndr_pull_save _relative_save; - ndr_pull_save(ndr, &_relative_save); - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->dacl)); - _mem_save_dacl_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->dacl, 0); - NDR_CHECK(ndr_pull_security_acl(ndr, NDR_SCALARS|NDR_BUFFERS, r->dacl)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dacl_0, 0); - ndr_pull_restore(ndr, &_relative_save); - } - } - ndr->flags = _flags_save_STRUCT; - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_security_descriptor(struct ndr_print *ndr, const char *name, const struct security_descriptor *r) -{ - ndr_print_struct(ndr, name, "security_descriptor"); - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN); - ndr->depth++; - ndr_print_security_descriptor_revision(ndr, "revision", r->revision); - ndr_print_security_descriptor_type(ndr, "type", r->type); - ndr_print_ptr(ndr, "owner_sid", r->owner_sid); - ndr->depth++; - if (r->owner_sid) { - ndr_print_dom_sid(ndr, "owner_sid", r->owner_sid); - } - ndr->depth--; - ndr_print_ptr(ndr, "group_sid", r->group_sid); - ndr->depth++; - if (r->group_sid) { - ndr_print_dom_sid(ndr, "group_sid", r->group_sid); - } - ndr->depth--; - ndr_print_ptr(ndr, "sacl", r->sacl); - ndr->depth++; - if (r->sacl) { - ndr_print_security_acl(ndr, "sacl", r->sacl); - } - ndr->depth--; - ndr_print_ptr(ndr, "dacl", r->dacl); - ndr->depth++; - if (r->dacl) { - ndr_print_security_acl(ndr, "dacl", r->dacl); - } - ndr->depth--; - ndr->depth--; - ndr->flags = _flags_save_STRUCT; - } -} - -enum ndr_err_code ndr_push_security_secinfo(struct ndr_push *ndr, int ndr_flags, uint32_t r) -{ - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_security_secinfo(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; -} - -void ndr_print_security_secinfo(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), "SECINFO_OWNER", SECINFO_OWNER, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_GROUP", SECINFO_GROUP, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_DACL", SECINFO_DACL, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_SACL", SECINFO_SACL, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_UNPROTECTED_SACL", SECINFO_UNPROTECTED_SACL, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_UNPROTECTED_DACL", SECINFO_UNPROTECTED_DACL, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_PROTECTED_SACL", SECINFO_PROTECTED_SACL, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_PROTECTED_DACL", SECINFO_PROTECTED_DACL, r); - ndr->depth--; -} - diff --git a/source3/librpc/ndr/ndr_string.c b/source3/librpc/ndr/ndr_string.c index 711dbce538..e553443bd8 100644 --- a/source3/librpc/ndr/ndr_string.c +++ b/source3/librpc/ndr/ndr_string.c @@ -633,8 +633,7 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co ndr->depth++; for (i=0;i<count;i++) { char *idx=NULL; - asprintf(&idx, "[%d]", i); - if (idx) { + if (asprintf(&idx, "[%d]", i) != -1) { ndr_print_string(ndr, idx, a[i]); free(idx); } diff --git a/source3/librpc/ndr/security.h b/source3/librpc/ndr/security.h deleted file mode 100644 index 99f7daf2bd..0000000000 --- a/source3/librpc/ndr/security.h +++ /dev/null @@ -1,257 +0,0 @@ -/* header auto-generated by pidl */ - -#ifndef _HEADER_security -#define _HEADER_security - -#define SEC_MASK_GENERIC ( 0xF0000000 ) -#define SEC_MASK_FLAGS ( 0x0F000000 ) -#define SEC_MASK_STANDARD ( 0x00FF0000 ) -#define SEC_MASK_SPECIFIC ( 0x0000FFFF ) -#define SEC_GENERIC_ALL ( 0x10000000 ) -#define SEC_GENERIC_EXECUTE ( 0x20000000 ) -#define SEC_GENERIC_WRITE ( 0x40000000 ) -#define SEC_GENERIC_READ ( 0x80000000 ) -#define SEC_FLAG_SYSTEM_SECURITY ( 0x01000000 ) -#define SEC_FLAG_MAXIMUM_ALLOWED ( 0x02000000 ) -#define SEC_STD_DELETE ( 0x00010000 ) -#define SEC_STD_READ_CONTROL ( 0x00020000 ) -#define SEC_STD_WRITE_DAC ( 0x00040000 ) -#define SEC_STD_WRITE_OWNER ( 0x00080000 ) -#define SEC_STD_SYNCHRONIZE ( 0x00100000 ) -#define SEC_STD_REQUIRED ( 0x000F0000 ) -#define SEC_STD_ALL ( 0x001F0000 ) -#define SEC_FILE_READ_DATA ( 0x00000001 ) -#define SEC_FILE_WRITE_DATA ( 0x00000002 ) -#define SEC_FILE_APPEND_DATA ( 0x00000004 ) -#define SEC_FILE_READ_EA ( 0x00000008 ) -#define SEC_FILE_WRITE_EA ( 0x00000010 ) -#define SEC_FILE_EXECUTE ( 0x00000020 ) -#define SEC_FILE_READ_ATTRIBUTE ( 0x00000080 ) -#define SEC_FILE_WRITE_ATTRIBUTE ( 0x00000100 ) -#define SEC_FILE_ALL ( 0x000001ff ) -#define SEC_DIR_LIST ( 0x00000001 ) -#define SEC_DIR_ADD_FILE ( 0x00000002 ) -#define SEC_DIR_ADD_SUBDIR ( 0x00000004 ) -#define SEC_DIR_READ_EA ( 0x00000008 ) -#define SEC_DIR_WRITE_EA ( 0x00000010 ) -#define SEC_DIR_TRAVERSE ( 0x00000020 ) -#define SEC_DIR_DELETE_CHILD ( 0x00000040 ) -#define SEC_DIR_READ_ATTRIBUTE ( 0x00000080 ) -#define SEC_DIR_WRITE_ATTRIBUTE ( 0x00000100 ) -#define SEC_REG_QUERY_VALUE ( 0x00000001 ) -#define SEC_REG_SET_VALUE ( 0x00000002 ) -#define SEC_REG_CREATE_SUBKEY ( 0x00000004 ) -#define SEC_REG_ENUM_SUBKEYS ( 0x00000008 ) -#define SEC_REG_NOTIFY ( 0x00000010 ) -#define SEC_REG_CREATE_LINK ( 0x00000020 ) -#define SEC_ADS_CREATE_CHILD ( 0x00000001 ) -#define SEC_ADS_DELETE_CHILD ( 0x00000002 ) -#define SEC_ADS_LIST ( 0x00000004 ) -#define SEC_ADS_SELF_WRITE ( 0x00000008 ) -#define SEC_ADS_READ_PROP ( 0x00000010 ) -#define SEC_ADS_WRITE_PROP ( 0x00000020 ) -#define SEC_ADS_DELETE_TREE ( 0x00000040 ) -#define SEC_ADS_LIST_OBJECT ( 0x00000080 ) -#define SEC_ADS_CONTROL_ACCESS ( 0x00000100 ) -#define SEC_RIGHTS_FILE_READ ( SEC_STD_READ_CONTROL|SEC_STD_SYNCHRONIZE|SEC_FILE_READ_DATA|SEC_FILE_READ_ATTRIBUTE|SEC_FILE_READ_EA ) -#define SEC_RIGHTS_FILE_WRITE ( SEC_STD_READ_CONTROL|SEC_STD_SYNCHRONIZE|SEC_FILE_WRITE_DATA|SEC_FILE_WRITE_ATTRIBUTE|SEC_FILE_WRITE_EA|SEC_FILE_APPEND_DATA ) -#define SEC_RIGHTS_FILE_EXECUTE ( SEC_STD_SYNCHRONIZE|SEC_STD_READ_CONTROL|SEC_FILE_READ_ATTRIBUTE|SEC_FILE_EXECUTE ) -#define SEC_RIGHTS_FILE_ALL ( SEC_STD_ALL|SEC_FILE_ALL ) -#define SEC_RIGHTS_DIR_READ ( SEC_RIGHTS_FILE_READ ) -#define SEC_RIGHTS_DIR_WRITE ( SEC_RIGHTS_FILE_WRITE ) -#define SEC_RIGHTS_DIR_EXECUTE ( SEC_RIGHTS_FILE_EXECUTE ) -#define SEC_RIGHTS_DIR_ALL ( SEC_RIGHTS_FILE_ALL ) -#define SID_NULL ( "S-1-0-0" ) -#define SID_WORLD_DOMAIN ( "S-1-1" ) -#define SID_WORLD ( "S-1-1-0" ) -#define SID_CREATOR_OWNER_DOMAIN ( "S-1-3" ) -#define SID_CREATOR_OWNER ( "S-1-3-0" ) -#define SID_CREATOR_GROUP ( "S-1-3-1" ) -#define SID_NT_AUTHORITY ( "S-1-5" ) -#define SID_NT_DIALUP ( "S-1-5-1" ) -#define SID_NT_NETWORK ( "S-1-5-2" ) -#define SID_NT_BATCH ( "S-1-5-3" ) -#define SID_NT_INTERACTIVE ( "S-1-5-4" ) -#define SID_NT_SERVICE ( "S-1-5-6" ) -#define SID_NT_ANONYMOUS ( "S-1-5-7" ) -#define SID_NT_PROXY ( "S-1-5-8" ) -#define SID_NT_ENTERPRISE_DCS ( "S-1-5-9" ) -#define SID_NT_SELF ( "S-1-5-10" ) -#define SID_NT_AUTHENTICATED_USERS ( "S-1-5-11" ) -#define SID_NT_RESTRICTED ( "S-1-5-12" ) -#define SID_NT_TERMINAL_SERVER_USERS ( "S-1-5-13" ) -#define SID_NT_REMOTE_INTERACTIVE ( "S-1-5-14" ) -#define SID_NT_THIS_ORGANISATION ( "S-1-5-15" ) -#define SID_NT_SYSTEM ( "S-1-5-18" ) -#define SID_NT_LOCAL_SERVICE ( "S-1-5-19" ) -#define SID_NT_NETWORK_SERVICE ( "S-1-5-20" ) -#define SID_BUILTIN ( "S-1-5-32" ) -#define SID_BUILTIN_ADMINISTRATORS ( "S-1-5-32-544" ) -#define SID_BUILTIN_USERS ( "S-1-5-32-545" ) -#define SID_BUILTIN_GUESTS ( "S-1-5-32-546" ) -#define SID_BUILTIN_POWER_USERS ( "S-1-5-32-547" ) -#define SID_BUILTIN_ACCOUNT_OPERATORS ( "S-1-5-32-548" ) -#define SID_BUILTIN_SERVER_OPERATORS ( "S-1-5-32-549" ) -#define SID_BUILTIN_PRINT_OPERATORS ( "S-1-5-32-550" ) -#define SID_BUILTIN_BACKUP_OPERATORS ( "S-1-5-32-551" ) -#define SID_BUILTIN_REPLICATOR ( "S-1-5-32-552" ) -#define SID_BUILTIN_RAS_SERVERS ( "S-1-5-32-553" ) -#define SID_BUILTIN_PREW2K ( "S-1-5-32-554" ) -#define DOMAIN_RID_LOGON ( 9 ) -#define DOMAIN_RID_ADMINISTRATOR ( 500 ) -#define DOMAIN_RID_GUEST ( 501 ) -#define DOMAIN_RID_ADMINS ( 512 ) -#define DOMAIN_RID_USERS ( 513 ) -#define DOMAIN_RID_DCS ( 516 ) -#define DOMAIN_RID_CERT_ADMINS ( 517 ) -#define DOMAIN_RID_SCHEMA_ADMINS ( 518 ) -#define DOMAIN_RID_ENTERPRISE_ADMINS ( 519 ) -#define NT4_ACL_REVISION ( SECURITY_ACL_REVISION_NT4 ) -#define SD_REVISION ( SECURITY_DESCRIPTOR_REVISION_1 ) -enum sec_privilege { - SEC_PRIV_SECURITY=1, - SEC_PRIV_BACKUP=2, - SEC_PRIV_RESTORE=3, - SEC_PRIV_SYSTEMTIME=4, - SEC_PRIV_SHUTDOWN=5, - SEC_PRIV_REMOTE_SHUTDOWN=6, - SEC_PRIV_TAKE_OWNERSHIP=7, - SEC_PRIV_DEBUG=8, - SEC_PRIV_SYSTEM_ENVIRONMENT=9, - SEC_PRIV_SYSTEM_PROFILE=10, - SEC_PRIV_PROFILE_SINGLE_PROCESS=11, - SEC_PRIV_INCREASE_BASE_PRIORITY=12, - SEC_PRIV_LOAD_DRIVER=13, - SEC_PRIV_CREATE_PAGEFILE=14, - SEC_PRIV_INCREASE_QUOTA=15, - SEC_PRIV_CHANGE_NOTIFY=16, - SEC_PRIV_UNDOCK=17, - SEC_PRIV_MANAGE_VOLUME=18, - SEC_PRIV_IMPERSONATE=19, - SEC_PRIV_CREATE_GLOBAL=20, - SEC_PRIV_ENABLE_DELEGATION=21, - SEC_PRIV_INTERACTIVE_LOGON=22, - SEC_PRIV_NETWORK_LOGON=23, - SEC_PRIV_REMOTE_INTERACTIVE_LOGON=24 -}; - -/* bitmap security_ace_flags */ -#define SEC_ACE_FLAG_OBJECT_INHERIT ( 0x01 ) -#define SEC_ACE_FLAG_CONTAINER_INHERIT ( 0x02 ) -#define SEC_ACE_FLAG_NO_PROPAGATE_INHERIT ( 0x04 ) -#define SEC_ACE_FLAG_INHERIT_ONLY ( 0x08 ) -#define SEC_ACE_FLAG_INHERITED_ACE ( 0x10 ) -#define SEC_ACE_FLAG_VALID_INHERIT ( 0x0f ) -#define SEC_ACE_FLAG_SUCCESSFUL_ACCESS ( 0x40 ) -#define SEC_ACE_FLAG_FAILED_ACCESS ( 0x80 ) - -enum security_ace_type { - SEC_ACE_TYPE_ACCESS_ALLOWED=0, - SEC_ACE_TYPE_ACCESS_DENIED=1, - SEC_ACE_TYPE_SYSTEM_AUDIT=2, - SEC_ACE_TYPE_SYSTEM_ALARM=3, - SEC_ACE_TYPE_ALLOWED_COMPOUND=4, - SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT=5, - SEC_ACE_TYPE_ACCESS_DENIED_OBJECT=6, - SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT=7, - SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT=8 -}; - -/* bitmap security_ace_object_flags */ -#define SEC_ACE_OBJECT_TYPE_PRESENT ( 0x00000001 ) -#define SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT ( 0x00000002 ) - -union security_ace_object_type { - struct GUID type;/* [case(SEC_ACE_OBJECT_TYPE_PRESENT)] */ -}/* [nodiscriminant] */; - -union security_ace_object_inherited_type { - struct GUID inherited_type;/* [case(SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT)] */ -}/* [nodiscriminant] */; - -struct security_ace_object { - uint32_t flags; - union security_ace_object_type type;/* [switch_is(flags&SEC_ACE_OBJECT_TYPE_PRESENT)] */ - union security_ace_object_inherited_type inherited_type;/* [switch_is(flags&SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT)] */ -}; - -union security_ace_object_ctr { - struct security_ace_object object;/* [case(SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT)] */ -}/* [nodiscriminant] */; - -struct security_ace { - enum security_ace_type type; - uint8_t flags; - uint16_t size;/* [value(ndr_size_security_ace(r,ndr->flags))] */ - uint32_t access_mask; - union security_ace_object_ctr object;/* [switch_is(type)] */ - struct dom_sid trustee; -}/* [gensize,public,nosize] */; - -enum security_acl_revision { - SECURITY_ACL_REVISION_NT4=2, - SECURITY_ACL_REVISION_ADS=4 -}; - -struct security_acl { - enum security_acl_revision revision; - uint16_t size;/* [value(ndr_size_security_acl(r,ndr->flags))] */ - uint32_t num_aces;/* [range(0 1000)] */ - struct security_ace *aces; -}/* [gensize,public,nosize] */; - -enum security_descriptor_revision { - SECURITY_DESCRIPTOR_REVISION_1=1 -}; - -/* bitmap security_descriptor_type */ -#define SEC_DESC_OWNER_DEFAULTED ( 0x0001 ) -#define SEC_DESC_GROUP_DEFAULTED ( 0x0002 ) -#define SEC_DESC_DACL_PRESENT ( 0x0004 ) -#define SEC_DESC_DACL_DEFAULTED ( 0x0008 ) -#define SEC_DESC_SACL_PRESENT ( 0x0010 ) -#define SEC_DESC_SACL_DEFAULTED ( 0x0020 ) -#define SEC_DESC_DACL_TRUSTED ( 0x0040 ) -#define SEC_DESC_SERVER_SECURITY ( 0x0080 ) -#define SEC_DESC_DACL_AUTO_INHERIT_REQ ( 0x0100 ) -#define SEC_DESC_SACL_AUTO_INHERIT_REQ ( 0x0200 ) -#define SEC_DESC_DACL_AUTO_INHERITED ( 0x0400 ) -#define SEC_DESC_SACL_AUTO_INHERITED ( 0x0800 ) -#define SEC_DESC_DACL_PROTECTED ( 0x1000 ) -#define SEC_DESC_SACL_PROTECTED ( 0x2000 ) -#define SEC_DESC_RM_CONTROL_VALID ( 0x4000 ) -#define SEC_DESC_SELF_RELATIVE ( 0x8000 ) - -struct security_descriptor { - enum security_descriptor_revision revision; - uint16_t type; - struct dom_sid *owner_sid;/* [relative] */ - struct dom_sid *group_sid;/* [relative] */ - struct security_acl *sacl;/* [relative] */ - struct security_acl *dacl;/* [relative] */ -}/* [gensize,public,flag(LIBNDR_FLAG_LITTLE_ENDIAN),nosize] */; - -struct sec_desc_buf { - uint32_t sd_size;/* [value(ndr_size_security_descriptor(sd,ndr->flags)),range(0 0x40000)] */ - struct security_descriptor *sd;/* [unique,subcontext(4)] */ -}/* [public] */; - -struct security_token { - struct dom_sid *user_sid;/* [unique] */ - struct dom_sid *group_sid;/* [unique] */ - uint32_t num_sids; - struct dom_sid **sids;/* [unique,size_is(num_sids)] */ - uint64_t privilege_mask; -}/* [public] */; - -/* bitmap security_secinfo */ -#define SECINFO_OWNER ( 0x00000001 ) -#define SECINFO_GROUP ( 0x00000002 ) -#define SECINFO_DACL ( 0x00000004 ) -#define SECINFO_SACL ( 0x00000008 ) -#define SECINFO_UNPROTECTED_SACL ( 0x10000000 ) -#define SECINFO_UNPROTECTED_DACL ( 0x20000000 ) -#define SECINFO_PROTECTED_SACL ( 0x40000000 ) -#define SECINFO_PROTECTED_DACL ( 0x80000000 ) - -#endif /* _HEADER_security */ diff --git a/source3/librpc/ndr/sid.c b/source3/librpc/ndr/sid.c index 89ab2b8ea5..b6ec045806 100644 --- a/source3/librpc/ndr/sid.c +++ b/source3/librpc/ndr/sid.c @@ -187,70 +187,3 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const return NDR_ERR_SUCCESS; } - -enum ndr_err_code ndr_push_sec_desc_buf(struct ndr_push *ndr, int ndr_flags, const struct sec_desc_buf *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_security_descriptor(r->sd,ndr->flags))); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->sd)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->sd) { - { - struct ndr_push *_ndr_sd; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sd, 4, -1)); - NDR_CHECK(ndr_push_security_descriptor(_ndr_sd, NDR_SCALARS|NDR_BUFFERS, r->sd)); - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sd, 4, -1)); - } - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_sec_desc_buf(struct ndr_pull *ndr, int ndr_flags, struct sec_desc_buf *r) -{ - uint32_t _ptr_sd; - TALLOC_CTX *_mem_save_sd_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sd_size)); - if (r->sd_size > 0x40000) { /* sd_size is unsigned */ - return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); - } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sd)); - if (_ptr_sd) { - NDR_PULL_ALLOC(ndr, r->sd); - } else { - r->sd = NULL; - } - } - if (ndr_flags & NDR_BUFFERS) { - if (r->sd) { - _mem_save_sd_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->sd, 0); - { - struct ndr_pull *_ndr_sd; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sd, 4, -1)); - NDR_CHECK(ndr_pull_security_descriptor(_ndr_sd, NDR_SCALARS|NDR_BUFFERS, r->sd)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sd, 4, -1)); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sd_0, 0); - } - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_sec_desc_buf(struct ndr_print *ndr, const char *name, const struct sec_desc_buf *r) -{ - ndr_print_struct(ndr, name, "sec_desc_buf"); - ndr->depth++; - ndr_print_uint32(ndr, "sd_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_security_descriptor(r->sd,ndr->flags):r->sd_size); - ndr_print_ptr(ndr, "sd", r->sd); - ndr->depth++; - if (r->sd) { - ndr_print_security_descriptor(ndr, "sd", r->sd); - } - ndr->depth--; - ndr->depth--; -} |