reduced the number of magic types we need in mkproto.pl
authorAndrew Tridgell <tridge@samba.org>
Sun, 23 Nov 2003 01:53:54 +0000 (01:53 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sun, 23 Nov 2003 01:53:54 +0000 (01:53 +0000)
In general I prefer "struct foo" to just "foo" for most
structures. There are exceptions.
(This used to be commit 04eb12b56c653f98801ab29411f47564ab32fa58)

source4/auth/auth_util.c
source4/include/includes.h
source4/include/smb.h
source4/lib/system.c
source4/lib/util_unistr.c
source4/libcli/util/cliutil.c
source4/passdb/passdb.c
source4/script/mkproto.pl
source4/smbd/password.c
source4/smbd/rewrite.c
source4/torture/rpc/winreg.c

index 7096361913b481680dc048cd74d90579fb6d00eb..580b96142e1d1697214c130f7d3348e0953e4a4f 100644 (file)
@@ -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;
 
index e6a25a9b24523feacc888f0fa751d79dbe0173f6..0f5e73cf563cdf93548dcf001379484ff57b6f64 100644 (file)
@@ -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
 
index b791182aa6c2e67c0de04b963c9f8d98ed5a9131..f6a4281e012a95c9da85e1f3f109bde5d026ad0d 100644 (file)
@@ -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;
index bafe689a30a898c1d5a1d4abe21460f3ea98d247..f79386eed13cde9601a9e1e4259d3dd7d111c4be 100644 (file)
@@ -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);
index 71a67eb1599ca13248894fee37c16c40f36104f7..3ab04eda1ff8f88611ef0194b67917bc1ccbe6de 100644 (file)
@@ -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;
-};
 
index 47f94992a43979eabe47fdc3ec22791727afc6d5..13b3dad0bf70e9048877deb460746ac10714c7d6 100644 (file)
@@ -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);
 
index 39e2d4cb22e803ed045c792380fa12b331c2a58c..437a02a3f80b9423722903b14c0b9c47a216fe5b 100644 (file)
@@ -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.
index 93a908165c602dcc6ece53c08f190da26c825eb3..b13c4b1fbb609958a5776c1a7c54f2085b58a1e3 100644 (file)
@@ -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;
                        }
 
index d2559ac41e62c96f1e5dd578b03f0057b75c9956..53530abf7a47eebb6904c5f0b47faee8b6156970 100644 (file)
@@ -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;
index 4421d0c96008c0ed082de3609c5b02057174e480..18ff62e9dc3889ae33b3bc76194f903b39681157 100644 (file)
@@ -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;
 }
 
index 3b88b032b7c51ef700c30d8f165be1ad483fbb45..65db147e218181ffe955aff491b2e07ca7e782cd 100644 (file)
@@ -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;