minor fixes
authorSimo Sorce <idra@samba.org>
Thu, 27 Sep 2001 02:05:30 +0000 (02:05 +0000)
committerSimo Sorce <idra@samba.org>
Thu, 27 Sep 2001 02:05:30 +0000 (02:05 +0000)
(This used to be commit 57e639bbdd115b51362caf7e3db4ba34ccdeddc2)

source3/passdb/pdb_tdb.c
source3/smbd/mangle.c

index 6702926355f29b40b9013935fe77da5531f8de22..990d0077b2338f302fbac9d107c244218cf19091 100644 (file)
@@ -384,12 +384,10 @@ BOOL pdb_setsampwent(BOOL update)
        pstrcat (tdbfile, PASSDB_FILE_NAME);
        
        /* Open tdb passwd */
-       if (!(global_tdb_ent.passwd_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, update ? O_RDWR : O_RDONLY, 0600))) {
-               DEBUG(0, ("Unable to open TDB passwd, trying create new!\n"));
-               if (!(global_tdb_ent.passwd_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT | O_EXCL, 0600))) {
-                       DEBUG(0, ("Unable to create TDB passwd (passdb.tdb) !!!"));
-                       return False;
-               }
+       if (!(global_tdb_ent.passwd_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, update?(O_RDWR|O_CREAT):O_RDONLY, 0600)))
+       {
+               DEBUG(0, ("Unable to open/create TDB passwd\n"));
+               return False;
        }
        
        global_tdb_ent.key = tdb_firstkey(global_tdb_ent.passwd_tdb);
@@ -771,19 +769,11 @@ static BOOL tdb_update_sam(SAM_ACCOUNT* newpwd, BOOL override, int flag)
        }
 
        /* open the account TDB passwd*/
-       pwd_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, O_RDWR, 0600);
-       if (!pwd_tdb) {
+       pwd_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0600);
+       if (!pwd_tdb)
+       {
                DEBUG(0, ("tdb_update_sam: Unable to open TDB passwd!\n"));
-               if (flag == TDB_INSERT) {
-                       DEBUG(0, ("Unable to open TDB passwd, trying create new!\n"));
-                       pwd_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT | O_EXCL, 0600);
-                       if (!pwd_tdb) {
-                               DEBUG(0, ("Unable to create TDB passwd (passdb.tdb) !!!\n"));
-                               ret = False;
-                               goto reallydone;
-                       }
-                       newtdb = True;
-               }
+               return False;
        }
 
        /* add the account */
@@ -813,13 +803,11 @@ static BOOL tdb_update_sam(SAM_ACCOUNT* newpwd, BOOL override, int flag)
        }
 
 done:  
-
        /* cleanup */
        tdb_close (pwd_tdb);
-
-reallydone:
        SAFE_FREE(buf);
-       return (ret);
+       
+       return (ret);   
 }
 
 /***************************************************************************
index 0de2188bcfdebc8db7de455ab74d8afe919f2f09..c0a3dacf08e44506a61b97fc04700bea0c512b01 100644 (file)
@@ -1006,15 +1006,10 @@ static BOOL init_mangle_tdb(void)
                slprintf(tdbfile, sizeof(tdbfile)-1, "%s/%s", lp_private_dir(), MANGLE_TDB_FILE_NAME);
 
                /* Open tdb */
-               if (!(global_mt_ent.mangle_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, O_RDWR, 0600)))
+               if (!(global_mt_ent.mangle_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0600)))
                {
-                       DEBUG(0, ("Unable to open Mangle TDB, trying create new!\n"));
-                       /* create a new one if it does not exist */
-                       if (!(global_mt_ent.mangle_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT | O_EXCL, 0600)))
-                       {
-                               DEBUG(0, ("Unable to create Mangle TDB (%s) !!!", tdbfile));
-                               return False;
-                       }
+                       DEBUG(0, ("Unable to open Mangle TDB\n"));
+                       return False;
                }
        }
 
@@ -1153,7 +1148,7 @@ smb_ucs2_t *unmangle(const smb_ucs2_t *mangled)
        }
        strupper_w(temp);
        /* set search key */
-       pull_ucs2(NULL, mufname, temp, sizeof(mufname), 0, STR_TERMINATE);
+       ucs2_to_dos(NULL, mufname, temp, sizeof(mufname), 0, STR_TERMINATE);
        SAFE_FREE(temp);
        slprintf(keystr, sizeof(keystr)-1, "%s%s", MANGLED_PREFIX, mufname);
        key.dptr = keystr;
@@ -1254,7 +1249,7 @@ smb_ucs2_t *_mangle(const smb_ucs2_t *unmangled)
                        snprintf(num, 7, "%d", c);
                        strncat_wa(temp, num, n);
 
-                       pull_ucs2(NULL, mufname, temp, sizeof(mufname), 0, STR_TERMINATE);
+                       ucs2_to_dos(NULL, mufname, temp, sizeof(mufname), 0, STR_TERMINATE);
                        if (strlen(mufname) > 8)
                        {
                                n++;