r22819: Fix Bug 4613. We just dumped the must change & friends. With the
[sfrench/samba-autobuild/.git] / source / auth / auth_util.c
index 336daa906d0e81cad662487b0ded50a23fe09b8a..1795322b55af06162221e86b4ca59d0853a566b2 100644 (file)
@@ -430,51 +430,6 @@ BOOL make_user_info_guest(auth_usersupplied_info **user_info)
        return NT_STATUS_IS_OK(nt_status) ? True : False;
 }
 
-/****************************************************************************
- prints a NT_USER_TOKEN to debug output.
-****************************************************************************/
-
-void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token)
-{
-       size_t     i;
-       
-       if (!token) {
-               DEBUGC(dbg_class, dbg_lev, ("NT user token: (NULL)\n"));
-               return;
-       }
-       
-       DEBUGC(dbg_class, dbg_lev,
-              ("NT user token of user %s\n",
-               sid_string_static(&token->user_sids[0]) ));
-       DEBUGADDC(dbg_class, dbg_lev,
-                 ("contains %lu SIDs\n", (unsigned long)token->num_sids));
-       for (i = 0; i < token->num_sids; i++)
-               DEBUGADDC(dbg_class, dbg_lev,
-                         ("SID[%3lu]: %s\n", (unsigned long)i, 
-                          sid_string_static(&token->user_sids[i])));
-
-       dump_se_priv( dbg_class, dbg_lev, &token->privileges );
-}
-
-/****************************************************************************
- prints a UNIX 'token' to debug output.
-****************************************************************************/
-
-void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
-                          int n_groups, gid_t *groups)
-{
-       int     i;
-       DEBUGC(dbg_class, dbg_lev,
-              ("UNIX token of user %ld\n", (long int)uid));
-
-       DEBUGADDC(dbg_class, dbg_lev,
-                 ("Primary group is %ld and contains %i supplementary "
-                  "groups\n", (long int)gid, n_groups));
-       for (i = 0; i < n_groups; i++)
-               DEBUGADDC(dbg_class, dbg_lev, ("Group[%3i]: %ld\n", i, 
-                       (long int)groups[i]));
-}
-
 static int server_info_dtor(auth_serversupplied_info *server_info)
 {
        TALLOC_FREE(server_info->sam_account);
@@ -834,11 +789,15 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
                        goto done;
                }
 
-               group_sids = talloc_array(tmp_ctx, DOM_SID, num_group_sids);
-               if (group_sids == NULL) {
-                       DEBUG(1, ("talloc_array failed\n"));
-                       result = NT_STATUS_NO_MEMORY;
-                       goto done;
+               if (num_group_sids) {
+                       group_sids = TALLOC_ARRAY(tmp_ctx, DOM_SID, num_group_sids);
+                       if (group_sids == NULL) {
+                               DEBUG(1, ("TALLOC_ARRAY failed\n"));
+                               result = NT_STATUS_NO_MEMORY;
+                               goto done;
+                       }
+               } else {
+                       group_sids = NULL;
                }
 
                for (i=0; i<num_group_sids; i++) {
@@ -864,9 +823,9 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
                uint32 dummy;
 
                num_group_sids = 1;
-               group_sids = talloc_array(tmp_ctx, DOM_SID, num_group_sids);
+               group_sids = TALLOC_ARRAY(tmp_ctx, DOM_SID, num_group_sids);
                if (group_sids == NULL) {
-                       DEBUG(1, ("talloc_array failed\n"));
+                       DEBUG(1, ("TALLOC_ARRAY failed\n"));
                        result = NT_STATUS_NO_MEMORY;
                        goto done;
                }
@@ -1117,7 +1076,7 @@ static auth_serversupplied_info *copy_serverinfo(auth_serversupplied_info *src)
        dst->gid = src->gid;
        dst->n_groups = src->n_groups;
        if (src->n_groups != 0) {
-               dst->groups = (gid_t *)talloc_memdup(
+               dst->groups = (gid_t *)TALLOC_MEMDUP(
                        dst, src->groups, sizeof(gid_t)*dst->n_groups);
        } else {
                dst->groups = NULL;
@@ -1525,6 +1484,30 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
+       if (!pdb_set_pass_last_set_time(
+                   sam_account,
+                   nt_time_to_unix(info3->pass_last_set_time),
+                   PDB_CHANGED)) {
+               TALLOC_FREE(sam_account);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       if (!pdb_set_pass_can_change_time(
+                   sam_account,
+                   nt_time_to_unix(info3->pass_can_change_time),
+                   PDB_CHANGED)) {
+               TALLOC_FREE(sam_account);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       if (!pdb_set_pass_must_change_time(
+                   sam_account,
+                   nt_time_to_unix(info3->pass_must_change_time),
+                   PDB_CHANGED)) {
+               TALLOC_FREE(sam_account);
+               return NT_STATUS_NO_MEMORY;
+       }
+
        result = make_server_info(NULL);
        if (result == NULL) {
                DEBUG(4, ("make_server_info failed!\n"));