Changes from APPLIANCE_HEAD:
[ira/wip.git] / source3 / passdb / smbpassgroup.c
index 13963b8c0faed01f81998cdcbaa0fc71c92d21c1..4636c08c9492c0a4282e2ebab287823c624da005 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "includes.h"
 
-#ifdef USE_SMBGROUP_DB
+#ifdef USE_SMBPASS_DB
 
 static int grp_file_lock_depth = 0;
 extern int DEBUGLEVEL;
@@ -77,8 +77,9 @@ static struct smb_passwd *getsmbfilegrpent(void *vp,
        static pstring  user_name;
        struct passwd *pwfile;
        pstring         linebuf;
-       char  *p;
+       unsigned char  *p;
        int            uidval;
+       size_t            linebuf_len;
 
        if (vp == NULL)
        {
@@ -91,12 +92,12 @@ static struct smb_passwd *getsmbfilegrpent(void *vp,
        /*
         * Scan the file, a line at a time.
         */
-       while (getfileline(vp, linebuf, sizeof(linebuf)) > 0)
+       while ((linebuf_len = getfileline(vp, linebuf, sizeof(linebuf))) > 0)
        {
                /*
                 * The line we have should be of the form :-
                 * 
-                * username:uid:aliasrid1,aliasrid2..:domainrid1,domainrid2..:
+                * username:uid:domainrid1,domainrid2..:aliasrid1,aliasrid2..:
                 */
 
                /*
@@ -113,42 +114,48 @@ static struct smb_passwd *getsmbfilegrpent(void *vp,
                p = Atoic((char *) p, &uidval, ":");
 
                pw_buf.smb_name = user_name;
-               pw_buf.unix_uid = uidval;
+               pw_buf.smb_userid = uidval;
 
                /*
-                * Now get a list of alias RIDs
+                * Now get the password value - this should be 32 hex digits
+                * which are the ascii representations of a 16 byte string.
+                * Get two at a time and put them into the password.
                 */
 
                /* Skip the ':' */
                p++;
 
-               if (als_rids != NULL && num_alss != NULL)
+               if (grp_rids != NULL && num_grps != NULL)
                {
                        int i;
-                       p = get_numlist(p, als_rids, num_alss);
+                       p = get_numlist(p, grp_rids, num_grps);
                        if (p == NULL)
                        {
                                DEBUG(0,("getsmbfilegrpent: invalid line\n"));
                                return NULL;
                        }
+                       for (i = 0; i < (*num_grps); i++)
+                       {
+                               (*grp_rids)[i] = pwdb_gid_to_group_rid((*grp_rids)[i]);
+                       }
                }
 
-               /*
-                * Now get a list of group RIDs
-                */
-
                /* Skip the ':' */
                p++;
 
-               if (grp_rids != NULL && num_grps != NULL)
+               if (als_rids != NULL && num_alss != NULL)
                {
                        int i;
-                       p = get_numlist(p, grp_rids, num_grps);
+                       p = get_numlist(p, als_rids, num_alss);
                        if (p == NULL)
                        {
                                DEBUG(0,("getsmbfilegrpent: invalid line\n"));
                                return NULL;
                        }
+                       for (i = 0; i < (*num_alss); i++)
+                       {
+                               (*als_rids)[i] = pwdb_gid_to_alias_rid((*als_rids)[i]);
+                       }
                }
 
                pwfile = Get_Pwnam(pw_buf.smb_name, False);