Luke, I am moving the code back into passdb/passdb.c, this the correct
authorJeremy Allison <jra@samba.org>
Fri, 9 Jun 2000 18:45:31 +0000 (18:45 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 9 Jun 2000 18:45:31 +0000 (18:45 +0000)
place to do this, not in smbd/passwd.c

Please don't change this without asking first, I have run this past
Andrew so talk to him (I'm on vacation next week).

I also removed the g_newXXX macros. There are essentially a private C extension,
not used anywhere else in the code, and add no functionality over malloc(XX)
and make the code harder to understand (everyone knows what malloc does).

Jeremy.
(This used to be commit e1b1b6fb6794ba02e1fea510a981fa0ce0d12b58)

source3/include/proto.h
source3/include/smb.h
source3/include/smb_macros.h
source3/passdb/passdb.c
source3/rpc_parse/parse_net.c
source3/smbd/password.c
source3/smbd/reply.c

index 3887d965894b6d6811b00f4e2270e5e9307bcae1..a5da95cd7dd1e94d32e9b83435f523c064f83924 100644 (file)
@@ -3304,8 +3304,7 @@ char *validated_domain(uint16 vuid);
 int setup_groups(char *user, char *domain, 
                 uid_t uid, gid_t gid, int *p_ngroups, gid_t **p_groups);
 uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, 
-                    char *domain,BOOL guest,
-                    NET_USER_INFO_3 *usr);
+                    char *domain,BOOL guest);
 void add_session_user(char *user);
 BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned char *c8);
 BOOL smb_password_ok(struct smb_passwd *smb_pass, uchar chal[8],
index 0efced2e381ff4f68b430f32460cc6acedaddf22..91f0e04b48f2c30b9a64493df5797f6c8b697f05 100644 (file)
@@ -1696,7 +1696,12 @@ typedef struct
        int n_groups;
        gid_t *groups;
 
-       NET_USER_INFO_3 usr;
+#if 0
+       NET_USER_INFO_3 usr; /* This should not be here. */
+#else
+       DOM_SID user_sid;
+       DOM_SID *group_sids;
+#endif
 
        /* per-user authentication information on NT RPCs */
        /* lkclXXXX - THIS SHOULD NOT BE HERE! */
index 267b061f656dff101c2e038b081c61351ae0f20a..51c7c1c6380e7b532331b4d181df8068254f0f96 100644 (file)
 #define IS_DOS_SYSTEM(test_mode)   (((test_mode) & aSYSTEM) != 0)
 #define IS_DOS_HIDDEN(test_mode)   (((test_mode) & aHIDDEN) != 0)
 
-/* memory-allocation-helpers (idea and names from glib) */
-#define g_new(type, count) \
-       ((type *) malloc(sizeof(type) * (count)))
-#define g_new0(type, count) \
-       ((type *) calloc((count), sizeof(type)))
-#define g_renew(type, mem, count) \
-       ((type *) Realloc(mem, sizeof(type) * (count)))
-
 /* zero a structure */
 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
 
index 957ba0687461f95e1d228e036df242ceabcfb697..6556503dca3c2a3c35b40c474744041368c8c63f 100644 (file)
@@ -1214,7 +1214,6 @@ BOOL lookup_local_name(char *domain, char *user, DOM_SID *psid, uint8 *psid_name
        return True;
 }
 
-#if 0
 /****************************************************************************
  Create a list of SIDS for a user - primary and group.
  This is really the wrong way to do this and needs to go via winbind. JRA.
@@ -1242,5 +1241,45 @@ BOOL setup_user_sids(user_struct *vuser)
        }
 
        return True;
-}
+#if 0
+       /* Luke's code. */
+   if (usr == NULL)
+   {
+    int i;
+    extern DOM_SID global_sam_sid;
+    DEBUG(0,("vuser struct usr being filled in with trash, today\n"));
+    DEBUG(0,("this needs to be replaced with a proper surs impl.\n"));
+    DEBUG(0,("e.g. the one used in winbindd.  in fact, all\n"));
+    DEBUG(0,("occurrences of pdb_xxx_to_xxx should be replaced\n"));
+    DEBUG(0,("as soon as possible.\n"));
+    vuser->usr.user_id = pdb_uid_to_user_rid(uid);
+    vuser->usr.group_id = pdb_gid_to_group_rid(gid);
+    vuser->usr.num_groups = vuser->n_groups;
+    if (vuser->n_groups != 0)
+    {
+        vuser->usr.gids = g_new(DOM_GID, vuser->usr.num_groups);
+        if (vuser->usr.gids == NULL)
+            return UID_FIELD_INVALID;
+    }
+
+    for (i = 0; i < vuser->usr.num_groups; i++)
+    {
+        DOM_GID *ntgid = &vuser->usr.gids[i];
+        ntgid->attr = 0x7;
+        ntgid->g_rid = pdb_gid_to_group_rid(vuser->groups[i]);
+    }
+    /* this is possibly the worst thing to do, ever.  it assumes */
+    /* that all users of this system are in the local SAM database */
+    /* however, because there is no code to do anything otherwise, */
+    /* we have no choice */
+    init_dom_sid2(&vuser->usr.dom_sid, &global_sam_sid);
+   }
+   else
+   {
+      vuser->usr = *usr;
+   }                                           
 #endif
+}
index c1b16b8864f0ad357bfb9d4c72907d48c83e6e92..bcc8e876b54ea79ff7e2d3e127bd35f4c196e795 100644 (file)
@@ -1072,7 +1072,7 @@ void init_net_user_info3(NET_USER_INFO_3 *usr,
 
        if (num_groups > 0)
        {
-               usr->gids = g_new(DOM_GID, num_groups);
+               usr->gids = (DOM_GID *)malloc(sizeof(DOM_GID) * num_groups);
                if (usr->gids == NULL)
                        return;
                for (i = 0; i < num_groups; i++)
@@ -1190,7 +1190,7 @@ static BOOL net_io_user_info3(char *desc, NET_USER_INFO_3 *usr, prs_struct *ps,
 
        if (UNMARSHALLING(ps) && usr->num_groups2 > 0)
        {
-               usr->gids = g_new(DOM_GID, usr->num_groups2);
+               usr->gids = (DOM_GID *)malloc(sizeof(DOM_GID)*usr->num_groups2);
                if (usr->gids == NULL)
                        return False;
        }
index 4110530c0b6b55a0865eb959698e8cd4263dc9cd..c38a6a0f2b76a6bbec9979b795d459f6f5480957 100644 (file)
@@ -117,24 +117,24 @@ invalidate a uid
 ****************************************************************************/
 void invalidate_vuid(uint16 vuid)
 {
-  user_struct *vuser = get_valid_user_struct(vuid);
+       user_struct *vuser = get_valid_user_struct(vuid);
 
-  if (vuser == NULL) return;
+       if (vuser == NULL)
+               return;
 
-  vuser->uid = (uid_t)-1;
-  vuser->gid = (gid_t)-1;
+       vuser->uid = (uid_t)-1;
+       vuser->gid = (gid_t)-1;
 
-  /* same number of igroups as groups */
-  vuser->n_groups = 0;
+       /* same number of igroups as groups */
+       vuser->n_groups = 0;
 
-  if (vuser->groups)
-    free((char *)vuser->groups);
+       if (vuser->groups)
+               free((char *)vuser->groups);
 
-  vuser->groups  = NULL;
+       vuser->groups  = NULL;
 
-    if (vuser->usr.gids != NULL)
-           free (vuser->usr.gids);
-  vuser->usr.gids  = NULL;
+       if (vuser->group_sids != NULL)
+               free (vuser->group_sids);
 }
 
 
@@ -218,8 +218,7 @@ has been given. vuid is biased by an offset. This allows us to
 tell random client vuid's (normally zero) from valid vuids.
 ****************************************************************************/
 uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, 
-                    char *domain,BOOL guest,
-                    NET_USER_INFO_3 *usr)
+                    char *domain,BOOL guest)
 {
   user_struct *vuser;
   struct passwd *pwfile; /* for getting real name from passwd file */
@@ -279,44 +278,7 @@ uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name,
               &vuser->n_groups,
               &vuser->groups);
 
-  if (usr == NULL)
-  {
-       int i;
-       extern DOM_SID global_sam_sid;
-
-       DEBUG(0,("vuser struct usr being filled in with trash, today\n"));
-       DEBUG(0,("this needs to be replaced with a proper surs impl.\n"));
-       DEBUG(0,("e.g. the one used in winbindd.  in fact, all\n"));
-       DEBUG(0,("occurrences of pdb_xxx_to_xxx should be replaced\n"));
-       DEBUG(0,("as soon as possible.\n"));
-       vuser->usr.user_id = pdb_uid_to_user_rid(uid);
-       vuser->usr.group_id = pdb_gid_to_group_rid(gid);
-       vuser->usr.num_groups = vuser->n_groups;
-       if (vuser->n_groups != 0)
-       {
-               vuser->usr.gids = g_new(DOM_GID, vuser->usr.num_groups);
-               if (vuser->usr.gids == NULL)
-                       return UID_FIELD_INVALID;
-       }
-
-       for (i = 0; i < vuser->usr.num_groups; i++)
-       {
-               DOM_GID *ntgid = &vuser->usr.gids[i];
-               ntgid->attr = 0x7;
-               ntgid->g_rid = pdb_gid_to_group_rid(vuser->groups[i]);
-       }
-
-       /* this is possibly the worst thing to do, ever.  it assumes */
-       /* that all users of this system are in the local SAM database */
-       /* however, because there is no code to do anything otherwise, */
-       /* we have no choice */
-
-       init_dom_sid2(&vuser->usr.dom_sid, &global_sam_sid);
-  }
-  else
-  {
-         vuser->usr = *usr;
-  }
+  setup_user_sids(vuser);
 
   DEBUG(3,("uid %d registered to name %s\n",(int)uid,unix_name));
 
index f9c0695a390b1eda799b7c5419ad94b218822021..00a0ce3c4a0fa0212416263184e3f5b96064379b 100644 (file)
@@ -1001,9 +1001,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
   /* register the name and uid as being validated, so further connections
      to a uid can get through without a password, on the same VC */
 
-  DEBUG(0,("must call domain_client_validate() which returns a "));
-  DEBUG(0,("NET_USER_INFO_3 structure to pass to register_vuid()"));
-  sess_vuid = register_vuid(uid,gid,user,sesssetup_user,domain,guest, NULL);
+  sess_vuid = register_vuid(uid,gid,user,sesssetup_user,domain,guest);
  
   SSVAL(outbuf,smb_uid,sess_vuid);
   SSVAL(inbuf,smb_uid,sess_vuid);