diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-23 01:53:54 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-23 01:53:54 +0000 |
commit | d47d14f2ffc7a6d2cc306530b777f364767998b3 (patch) | |
tree | 5ff4972c9bea1a5104a2aac2986f2331db96d101 | |
parent | 7ab05c2ffa87c962a38a9ac90fa5705d93516a57 (diff) | |
download | samba-d47d14f2ffc7a6d2cc306530b777f364767998b3.tar.gz samba-d47d14f2ffc7a6d2cc306530b777f364767998b3.tar.bz2 samba-d47d14f2ffc7a6d2cc306530b777f364767998b3.zip |
reduced the number of magic types we need in mkproto.pl
In general I prefer "struct foo" to just "foo" for most
structures. There are exceptions.
(This used to be commit 04eb12b56c653f98801ab29411f47564ab32fa58)
-rw-r--r-- | source4/auth/auth_util.c | 4 | ||||
-rw-r--r-- | source4/include/includes.h | 4 | ||||
-rw-r--r-- | source4/include/smb.h | 2 | ||||
-rw-r--r-- | source4/lib/system.c | 2 | ||||
-rw-r--r-- | source4/lib/util_unistr.c | 39 | ||||
-rw-r--r-- | source4/libcli/util/cliutil.c | 4 | ||||
-rw-r--r-- | source4/passdb/passdb.c | 183 | ||||
-rw-r--r-- | source4/script/mkproto.pl | 100 | ||||
-rw-r--r-- | source4/smbd/password.c | 2 | ||||
-rw-r--r-- | source4/smbd/rewrite.c | 6 | ||||
-rw-r--r-- | source4/torture/rpc/winreg.c | 2 |
11 files changed, 66 insertions, 282 deletions
diff --git a/source4/auth/auth_util.c b/source4/auth/auth_util.c index 7096361913..580b96142e 100644 --- a/source4/auth/auth_util.c +++ b/source4/auth/auth_util.c @@ -618,7 +618,7 @@ static NTSTATUS create_nt_user_token(const DOM_SID *user_sid, const DOM_SID *gro Create the SID list for this user. ****************************************************************************/ -NT_USER_TOKEN *create_nt_token(uid_t uid, gid_t gid, int ngroups, gid_t *groups, BOOL is_guest) +struct nt_user_token *create_nt_token(uid_t uid, gid_t gid, int ngroups, gid_t *groups, BOOL is_guest) { DOM_SID user_sid; DOM_SID group_sid; @@ -1169,7 +1169,7 @@ void delete_nt_token(NT_USER_TOKEN **pptoken) Duplicate a SID token. ****************************************************************************/ -NT_USER_TOKEN *dup_nt_token(NT_USER_TOKEN *ptoken) +struct nt_user_token *dup_nt_token(NT_USER_TOKEN *ptoken) { NT_USER_TOKEN *token; diff --git a/source4/include/includes.h b/source4/include/includes.h index e6a25a9b24..0f5e73cf56 100644 --- a/source4/include/includes.h +++ b/source4/include/includes.h @@ -631,9 +631,9 @@ typedef int socklen_t; #ifndef SMB_STRUCT_DIRENT # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64) -# define SMB_STRUCT_DIRENT struct dirent64 +# define smb_dirent dirent64 # else -# define SMB_STRUCT_DIRENT struct dirent +# define smb_dirent dirent # endif #endif diff --git a/source4/include/smb.h b/source4/include/smb.h index b791182aa6..f6a4281e01 100644 --- a/source4/include/smb.h +++ b/source4/include/smb.h @@ -346,7 +346,7 @@ typedef struct sid_info #define PRIMARY_USER_SID_INDEX 0 #define PRIMARY_GROUP_SID_INDEX 1 -typedef struct _nt_user_token { +typedef struct nt_user_token { size_t num_sids; DOM_SID *user_sids; } NT_USER_TOKEN; diff --git a/source4/lib/system.c b/source4/lib/system.c index bafe689a30..f79386eed1 100644 --- a/source4/lib/system.c +++ b/source4/lib/system.c @@ -324,7 +324,7 @@ FILE *sys_fopen(const char *path, const char *type) A readdir wrapper that will deal with 64 bit filesizes. ********************************************************************/ -SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp) +struct smb_dirent *sys_readdir(DIR *dirp) { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_READDIR64) return readdir64(dirp); diff --git a/source4/lib/util_unistr.c b/source4/lib/util_unistr.c index 71a67eb159..3ab04eda1f 100644 --- a/source4/lib/util_unistr.c +++ b/source4/lib/util_unistr.c @@ -794,43 +794,4 @@ int unistrcpy(uint16 *dst, uint16 *src) return num_wchars; } -/** - * Samba ucs2 type to UNISTR2 conversion - * - * @param ctx Talloc context to create the dst strcture (if null) and the - * contents of the unicode string. - * @param dst UNISTR2 destination. If equals null, then it's allocated. - * @param src smb_ucs2_t source. - * @param max_len maximum number of unicode characters to copy. If equals - * null, then null-termination of src is taken - * - * @return copied UNISTR2 destination - **/ -UNISTR2* ucs2_to_unistr2(TALLOC_CTX *ctx, UNISTR2* dst, smb_ucs2_t* src) -{ - size_t len; - - if (!src) return NULL; - len = strlen_w(src); - - /* allocate UNISTR2 destination if not given */ - if (!dst) { - dst = (UNISTR2*) talloc(ctx, sizeof(UNISTR2)); - if (!dst) return NULL; - } - if (!dst->buffer) { - dst->buffer = (uint16*) talloc(ctx, sizeof(uint16) * (len + 1)); - if (!dst->buffer) return NULL; - } - - /* set UNISTR2 parameters */ - dst->uni_max_len = len + 1; - dst->undoc = 0; - dst->uni_str_len = len; - - /* copy the actual unicode string */ - strncpy_w(dst->buffer, src, dst->uni_max_len); - - return dst; -}; diff --git a/source4/libcli/util/cliutil.c b/source4/libcli/util/cliutil.c index 47f94992a4..13b3dad0bf 100644 --- a/source4/libcli/util/cliutil.c +++ b/source4/libcli/util/cliutil.c @@ -76,13 +76,13 @@ BOOL yesno(char *p) const char *readdirname(DIR *p) { - SMB_STRUCT_DIRENT *ptr; + struct smb_dirent *ptr; char *dname; if (!p) return(NULL); - ptr = (SMB_STRUCT_DIRENT *)sys_readdir(p); + ptr = (struct smb_dirent *)sys_readdir(p); if (!ptr) return(NULL); diff --git a/source4/passdb/passdb.c b/source4/passdb/passdb.c index 39e2d4cb22..437a02a3f8 100644 --- a/source4/passdb/passdb.c +++ b/source4/passdb/passdb.c @@ -810,189 +810,6 @@ BOOL local_lookup_name(const char *c_user, DOM_SID *psid, enum SID_NAME_USE *psi return True; } -/**************************************************************************** - Convert a uid to SID - locally. -****************************************************************************/ - -DOM_SID *local_uid_to_sid(DOM_SID *psid, uid_t uid) -{ - struct passwd *pass; - SAM_ACCOUNT *sam_user = NULL; - fstring str; /* sid string buffer */ - - sid_copy(psid, get_global_sam_sid()); - - if((pass = getpwuid_alloc(uid))) { - - if (NT_STATUS_IS_ERR(pdb_init_sam(&sam_user))) { - passwd_free(&pass); - return NULL; - } - - if (pdb_getsampwnam(sam_user, pass->pw_name)) { - sid_copy(psid, pdb_get_user_sid(sam_user)); - } else { - sid_append_rid(psid, fallback_pdb_uid_to_user_rid(uid)); - } - - DEBUG(10,("local_uid_to_sid: uid %u -> SID (%s) (%s).\n", - (unsigned)uid, sid_to_string( str, psid), - pass->pw_name )); - - passwd_free(&pass); - pdb_free_sam(&sam_user); - - } else { - sid_append_rid(psid, fallback_pdb_uid_to_user_rid(uid)); - - DEBUG(10,("local_uid_to_sid: uid %u -> SID (%s) (unknown user).\n", - (unsigned)uid, sid_to_string( str, psid))); - } - - return psid; -} - -/**************************************************************************** - Convert a SID to uid - locally. -****************************************************************************/ - -BOOL local_sid_to_uid(uid_t *puid, const DOM_SID *psid, enum SID_NAME_USE *name_type) -{ - fstring str; - SAM_ACCOUNT *sam_user = NULL; - - *name_type = SID_NAME_UNKNOWN; - - if (NT_STATUS_IS_ERR(pdb_init_sam(&sam_user))) - return False; - - if (pdb_getsampwsid(sam_user, psid)) { - - if (!IS_SAM_SET(sam_user,PDB_UID)&&!IS_SAM_CHANGED(sam_user,PDB_UID)) { - pdb_free_sam(&sam_user); - return False; - } - - *puid = pdb_get_uid(sam_user); - - DEBUG(10,("local_sid_to_uid: SID %s -> uid (%u) (%s).\n", sid_to_string( str, psid), - (unsigned int)*puid, pdb_get_username(sam_user))); - pdb_free_sam(&sam_user); - } else { - - DOM_SID dom_sid; - uint32 rid; - GROUP_MAP map; - - pdb_free_sam(&sam_user); - - if (pdb_getgrsid(&map, *psid, MAPPING_WITHOUT_PRIV)) { - DEBUG(3, ("local_sid_to_uid: SID '%s' is a group, not a user... \n", sid_to_string(str, psid))); - /* It's a group, not a user... */ - return False; - } - - sid_copy(&dom_sid, psid); - if (!sid_peek_check_rid(get_global_sam_sid(), psid, &rid)) { - DEBUG(3, ("sid_peek_rid failed - sid '%s' is not in our domain\n", sid_to_string(str, psid))); - return False; - } - - if (!pdb_rid_is_user(rid)) { - DEBUG(3, ("local_sid_to_uid: sid '%s' cannot be mapped to a uid algorithmicly becouse it is a group\n", sid_to_string(str, psid))); - return False; - } - - *puid = fallback_pdb_user_rid_to_uid(rid); - - DEBUG(5,("local_sid_to_uid: SID %s algorithmicly mapped to %ld mapped becouse SID was not found in passdb.\n", - sid_to_string(str, psid), (signed long int)(*puid))); - } - - *name_type = SID_NAME_USER; - - return True; -} - -/**************************************************************************** - Convert a gid to SID - locally. -****************************************************************************/ - -DOM_SID *local_gid_to_sid(DOM_SID *psid, gid_t gid) -{ - GROUP_MAP map; - - sid_copy(psid, get_global_sam_sid()); - - if (pdb_getgrgid(&map, gid, MAPPING_WITHOUT_PRIV)) { - sid_copy(psid, &map.sid); - } - else { - sid_append_rid(psid, pdb_gid_to_group_rid(gid)); - } - - return psid; -} - -/**************************************************************************** - Convert a SID to gid - locally. -****************************************************************************/ - -BOOL local_sid_to_gid(gid_t *pgid, const DOM_SID *psid, enum SID_NAME_USE *name_type) -{ - fstring str; - GROUP_MAP map; - - *name_type = SID_NAME_UNKNOWN; - - /* - * We can only convert to a gid if this is our local - * Domain SID (ie. we are the controling authority). - * - * Or in the Builtin SID too. JFM, 11/30/2001 - */ - - if (pdb_getgrsid(&map, *psid, MAPPING_WITHOUT_PRIV)) { - - /* the SID is in the mapping table but not mapped */ - if (map.gid==(gid_t)-1) - return False; - - *pgid = map.gid; - *name_type = map.sid_name_use; - DEBUG(10,("local_sid_to_gid: mapped SID %s (%s) -> gid (%u).\n", - sid_to_string( str, psid), - map.nt_name, (unsigned int)*pgid)); - - } else { - uint32 rid; - SAM_ACCOUNT *sam_user = NULL; - if (NT_STATUS_IS_ERR(pdb_init_sam(&sam_user))) - return False; - - if (pdb_getsampwsid(sam_user, psid)) { - return False; - pdb_free_sam(&sam_user); - } - - pdb_free_sam(&sam_user); - - if (!sid_peek_check_rid(get_global_sam_sid(), psid, &rid)) { - DEBUG(3, ("sid_peek_rid failed - sid '%s' is not in our domain\n", sid_to_string(str, psid))); - return False; - } - - if (pdb_rid_is_user(rid)) - return False; - - *pgid = pdb_group_rid_to_gid(rid); - *name_type = SID_NAME_ALIAS; - DEBUG(10,("local_sid_to_gid: SID %s -> gid (%u).\n", sid_to_string( str, psid), - (unsigned int)*pgid)); - } - - return True; -} /************************************************************* Change a password entry in the local smbpasswd file. diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl index 93a908165c..b13c4b1fbb 100644 --- a/source4/script/mkproto.pl +++ b/source4/script/mkproto.pl @@ -21,6 +21,55 @@ sub print_footer { printf "\n#endif /* %s */\n", $header_name; } + +sub handle_loadparm { + my $line = shift; + + if ($line =~ /^FN_GLOBAL_STRING/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "char *$fnName(void);\n"; + } elsif ($line =~ /^FN_LOCAL_STRING/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "char *$fnName(int );\n"; + } elsif ($line =~ /^FN_GLOBAL_BOOL/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "BOOL $fnName(void);\n"; + } + elsif ($line =~ /^FN_LOCAL_BOOL/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "BOOL $fnName(int );\n"; + } + elsif ($line =~ /^FN_GLOBAL_INTEGER/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "int $fnName(void);\n"; + } + elsif ($line =~ /^FN_LOCAL_INTEGER/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "int $fnName(int );\n"; + } + elsif ($line =~ /^FN_GLOBAL_LIST/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "const char **$fnName(void);\n"; + } + elsif ($line =~ /^FN_LOCAL_LIST/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "const char **$fnName(int );\n"; + } + elsif ($line =~ /^FN_GLOBAL_CONST_STRING/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "const char *$fnName(void);\n"; + } + elsif ($line =~ /^FN_LOCAL_CONST_STRING/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "const char *$fnName(int );\n"; + } + elsif ($line =~ /^FN_LOCAL_CHAR/o) { + my $fnName = (split(/[\(,]/, $line))[1]; + print "char $fnName(int );\n"; + } +} + + sub process_files { my $line; my $inheader; @@ -57,60 +106,19 @@ sub process_files { } - if ($line =~ /^FN_GLOBAL_STRING/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "char *$fnName(void);\n"; - } - elsif ($line =~ /^FN_LOCAL_STRING/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "char *$fnName(int );\n"; - } - elsif ($line =~ /^FN_GLOBAL_BOOL/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "BOOL $fnName(void);\n"; - } - elsif ($line =~ /^FN_LOCAL_BOOL/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "BOOL $fnName(int );\n"; - } - elsif ($line =~ /^FN_GLOBAL_INTEGER/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "int $fnName(void);\n"; - } - elsif ($line =~ /^FN_LOCAL_INTEGER/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "int $fnName(int );\n"; - } - elsif ($line =~ /^FN_GLOBAL_LIST/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "const char **$fnName(void);\n"; - } - elsif ($line =~ /^FN_LOCAL_LIST/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "const char **$fnName(int );\n"; - } - elsif ($line =~ /^FN_GLOBAL_CONST_STRING/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "const char *$fnName(void);\n"; - } - elsif ($line =~ /^FN_LOCAL_CONST_STRING/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "const char *$fnName(int );\n"; - } - elsif ($line =~ /^FN_LOCAL_CHAR/o) { - my $fnName = (split(/[\(,]/, $line))[1]; - print "char $fnName(int );\n"; + if ($line =~ /^FN_/) { + handle_loadparm($line); } # I'm going to leave these as is for now - perl can probably handle larger regex, though -- vance # I've also sort of put these in approximate order of most commonly called - elsif ( $line =~ /^NTSTATUS|^void|^BOOL|^int|^struct|^char|^const|^PyObject|^ssize_t|^size_t|^uint|^ADS_STATUS|^ADS_STRUCT|^enum.*\(|^SMB_ACL_T|^time|^smb_ucs2_t|^DATA_BLOB|^WERROR/o ) { + elsif ( $line =~ /^NTSTATUS|^void|^BOOL|^int|^struct|^char|^const|^\w+_[tT]\s|^uint|^ADS_STATUS|^enum\s.*\(|^DATA_BLOB|^WERROR/o ) { $gotstart = 1; - } elsif ( $line =~ /^smb_iconv_t|^long|^CLI_POLICY_HND|^FILE|^XFILE|^SMB_OFF_T|^pipes_struct|^smb_np_struct|^file_fd_struct|^files_struct|^connection_struct|^uid_t|^gid_t|^unsigned|^DIR|^user/o) { + } elsif ( $line =~ /^long|^XFILE|^FILE|^unsigned|^DIR/o) { $gotstart = 1; - } elsif ( $line =~ /^pid_t|^ino_t|^off_t|^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NT_DEVICEMODE|^NT_USER_TOKEN|^ADS_MODLIST|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_VALUE|^NTTIME|^UNISTR2|^SMB_STRUCT_DIRENT|^SEC_DESC|^DOM_SID/o ) { + } elsif ( $line =~ /^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NTTIME/o ) { $gotstart = 1; } diff --git a/source4/smbd/password.c b/source4/smbd/password.c index d2559ac41e..53530abf7a 100644 --- a/source4/smbd/password.c +++ b/source4/smbd/password.c @@ -26,7 +26,7 @@ check if a uid has been validated, and return an pointer to the user_struct if it has. NULL if not. vuid is biased by an offset. This allows us to tell random client vuid's (normally zero) from valid vuids. ****************************************************************************/ -user_struct *get_valid_user_struct(struct server_context *smb, uint16 vuid) +struct user_struct *get_valid_user_struct(struct server_context *smb, uint16 vuid) { user_struct *usp; int count=0; diff --git a/source4/smbd/rewrite.c b/source4/smbd/rewrite.c index 4421d0c960..18ff62e9dc 100644 --- a/source4/smbd/rewrite.c +++ b/source4/smbd/rewrite.c @@ -64,15 +64,13 @@ BOOL init_names(void) BOOL uid_to_sid(DOM_SID *sid, uid_t uid) { - *sid = *get_global_sam_sid(); - sid_append_rid(sid, uid*2); + ZERO_STRUCTP(sid); return True; } BOOL gid_to_sid(DOM_SID *sid, gid_t gid) { - *sid = *get_global_sam_sid(); - sid_append_rid(sid, gid*2 + 1); + ZERO_STRUCTP(sid); return True; } diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index 3b88b032b7..65db147e21 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -173,7 +173,7 @@ static BOOL test_EnumKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, keyname.unknown = 0x0000020a; init_winreg_String(&keyname.key_name, NULL); init_winreg_String(&classname, NULL); - r.in.name = &keyname; + r.in.in_name = &keyname; r.in.class = &classname; tm.low = tm.high = 0x7fffffff; r.in.last_changed_time = &tm; |