The branch, master has been updated
       via  c57b32c5ab754cdf99527e4dfc4bb6ff3ca93e25 (commit)
       via  1258ed8b1c52eff93aaa8fe132643e6c2ac31e56 (commit)
       via  aef0bdc6a1ffdf746ce9ce27c45b3ca4f6593ba9 (commit)
       via  eaddcfef1ba553744ae9293feaf7585ec9aaa0db (commit)
       via  1e742660bf3fed39b7efa2502d88ee6415522385 (commit)
      from  87fe4d732d18d18ed56c99cba6a395a0bf9e9d95 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c57b32c5ab754cdf99527e4dfc4bb6ff3ca93e25
Author: Jeremy Allison <[email protected]>
Date:   Wed Apr 1 20:20:19 2009 -0700

    Allow pdbedit to change a user rid/sid. Based on a fix from Alexander 
Zagrebin <[email protected]>.
    Jeremy.

commit 1258ed8b1c52eff93aaa8fe132643e6c2ac31e56
Merge: aef0bdc6a1ffdf746ce9ce27c45b3ca4f6593ba9 
87fe4d732d18d18ed56c99cba6a395a0bf9e9d95
Author: Jeremy Allison <[email protected]>
Date:   Wed Apr 1 20:20:44 2009 -0700

    Merge branch 'master' of ssh://[email protected]/data/git/samba

commit aef0bdc6a1ffdf746ce9ce27c45b3ca4f6593ba9
Merge: eaddcfef1ba553744ae9293feaf7585ec9aaa0db 
01a942d8ab5b5e430eb928dd58626fe16b9b04fe
Author: Jeremy Allison <[email protected]>
Date:   Wed Apr 1 14:03:17 2009 -0700

    Merge branch 'master' of ssh://[email protected]/data/git/samba

commit eaddcfef1ba553744ae9293feaf7585ec9aaa0db
Merge: 1e742660bf3fed39b7efa2502d88ee6415522385 
264b28ec0962c355ee90f9ac67fcf07cd84c5c7b
Author: Jeremy Allison <[email protected]>
Date:   Wed Apr 1 09:16:41 2009 -0700

    Merge branch 'master' of ssh://[email protected]/data/git/samba

commit 1e742660bf3fed39b7efa2502d88ee6415522385
Author: Jeremy Allison <[email protected]>
Date:   Tue Mar 31 18:28:49 2009 -0700

    Tidy up some convert_string_internal error cases, found by Andrew Bartlett.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/charcnv.c    |   25 ++++++++++++++----
 source3/passdb/pdb_tdb.c |   60 +++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 76 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index c3b3451..03b32c1 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -242,7 +242,7 @@ static size_t convert_string_internal(charset_t from, 
charset_t to,
                                        DEBUG(3,("convert_string_internal: 
Conversion error: %s(%s)\n",reason,inbuf));
                                if (allow_bad_conv)
                                        goto use_as_is;
-                               break;
+                               return (size_t)-1;
                        case E2BIG:
                                reason="No more room"; 
                                if (!conv_silent) {
@@ -263,11 +263,12 @@ static size_t convert_string_internal(charset_t from, 
charset_t to,
                                        DEBUG(3,("convert_string_internal: 
Conversion error: %s(%s)\n",reason,inbuf));
                                if (allow_bad_conv)
                                        goto use_as_is;
-                               break;
+                               
+                               return (size_t)-1;
                        default:
                                if (!conv_silent)
                                        DEBUG(0,("convert_string_internal: 
Conversion error: %s(%s)\n",reason,inbuf));
-                               break;
+                               return (size_t)-1;
                }
                /* smb_panic(reason); */
        }
@@ -412,7 +413,11 @@ size_t convert_string(charset_t from, charset_t to,
 #ifdef BROKEN_UNICODE_COMPOSE_CHARACTERS
                                goto general_case;
 #else
-                               return retval + convert_string_internal(from, 
to, p, slen, q, dlen, allow_bad_conv);
+                               size_t ret = convert_string_internal(from, to, 
p, slen, q, dlen, allow_bad_conv);
+                               if (ret == (size_t)-1) {
+                                       return ret;
+                               }
+                               return retval + ret;
 #endif
                        }
                }
@@ -448,7 +453,11 @@ size_t convert_string(charset_t from, charset_t to,
 #ifdef BROKEN_UNICODE_COMPOSE_CHARACTERS
                                goto general_case;
 #else
-                               return retval + convert_string_internal(from, 
to, p, slen, q, dlen, allow_bad_conv);
+                               size_t ret = convert_string_internal(from, to, 
p, slen, q, dlen, allow_bad_conv);
+                               if (ret == (size_t)-1) {
+                                       return ret;
+                               }
+                               return retval + ret;
 #endif
                        }
                }
@@ -484,7 +493,11 @@ size_t convert_string(charset_t from, charset_t to,
 #ifdef BROKEN_UNICODE_COMPOSE_CHARACTERS
                                goto general_case;
 #else
-                               return retval + convert_string_internal(from, 
to, p, slen, q, dlen, allow_bad_conv);
+                               size_t ret = convert_string_internal(from, to, 
p, slen, q, dlen, allow_bad_conv);
+                               if (ret == (size_t)-1) {
+                                       return ret;
+                               }
+                               return retval + ret;
 #endif
                        }
                }
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 6c49eb1..dd6e678 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -817,12 +817,17 @@ static bool tdb_update_ridrec_only( struct samu* newpwd, 
int flag )
 static bool tdb_update_sam(struct pdb_methods *my_methods, struct samu* newpwd,
                           int flag)
 {
-       if (!pdb_get_user_rid(newpwd)) {
+       uint32_t oldrid;
+       uint32_t newrid;
+
+       if (!(newrid = pdb_get_user_rid(newpwd))) {
                DEBUG(0,("tdb_update_sam: struct samu (%s) with no RID!\n",
                         pdb_get_username(newpwd)));
                return False;
        }
 
+       oldrid = newrid;
+
        /* open the database */
 
        if ( !tdbsam_open( tdbsam_filename ) ) {
@@ -835,11 +840,60 @@ static bool tdb_update_sam(struct pdb_methods 
*my_methods, struct samu* newpwd,
                return false;
        }
 
-       if (!tdb_update_samacct_only(newpwd, flag)
-           || !tdb_update_ridrec_only(newpwd, flag)) {
+       /* If we are updating, we may be changing this users RID. Retrieve the 
old RID
+          so we can check. */
+
+       if (flag == TDB_MODIFY) {
+               struct samu *account = samu_new(talloc_tos());
+               if (account == NULL) {
+                       DEBUG(0,("tdb_update_sam: samu_new() failed\n"));
+                       goto cancel;
+               }
+               if (!NT_STATUS_IS_OK(tdbsam_getsampwnam(my_methods, account, 
pdb_get_username(newpwd)))) {
+                       DEBUG(0,("tdb_update_sam: tdbsam_getsampwnam() for %s 
failed\n",
+                               pdb_get_username(newpwd)));
+                       TALLOC_FREE(account);
+                       goto cancel;
+               }
+               if (!(oldrid = pdb_get_user_rid(account))) {
+                       DEBUG(0,("tdb_update_sam: pdb_get_user_rid() 
failed\n"));
+                       TALLOC_FREE(account);
+                       goto cancel;
+               }
+               TALLOC_FREE(account);
+       }
+
+       /* Update the new samu entry. */
+       if (!tdb_update_samacct_only(newpwd, flag)) {
                goto cancel;
        }
 
+       /* Now take care of the case where the RID changed. We need
+        * to delete the old RID key and add the new. */
+
+       if (flag == TDB_MODIFY && newrid != oldrid) { 
+               fstring keystr;
+
+               /* Delete old RID key */
+               DEBUG(10, ("tdb_update_sam: Deleting key for RID %u\n", 
oldrid));
+               slprintf(keystr, sizeof(keystr) - 1, "%s%.8x", RIDPREFIX, 
oldrid);
+               if (!NT_STATUS_IS_OK(dbwrap_delete_bystring(db_sam, keystr))) {
+                       DEBUG(0, ("tdb_update_sam: Can't delete %s\n", keystr));
+                       goto cancel;
+               }
+               /* Insert new RID key */
+               DEBUG(10, ("tdb_update_sam: Inserting key for RID %u\n", 
newrid));
+               if (!tdb_update_ridrec_only(newpwd, TDB_INSERT)) {
+                       goto cancel;
+               }
+       } else {
+               DEBUG(10, ("tdb_update_sam: %s key for RID %u\n",
+                       flag == TDB_MODIFY ? "Updating" : "Inserting", newrid));
+               if (!tdb_update_ridrec_only(newpwd, flag)) {
+                       goto cancel;
+               }
+       }
+
        if (db_sam->transaction_commit(db_sam) != 0) {
                DEBUG(0, ("Could not commit transaction\n"));
                return false;


-- 
Samba Shared Repository

Reply via email to