summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/groupdb/mapping.c23
-rw-r--r--source3/intl/lang_tdb.c4
-rw-r--r--source3/lib/account_pol.c15
-rw-r--r--source3/printing/nt_printing.c28
-rw-r--r--source3/printing/printing.c25
-rw-r--r--source3/rpc_server/srv_srvsvc_nt.c47
6 files changed, 90 insertions, 52 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 7b44596256..7093f14eca 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -142,14 +142,17 @@ char *decode_sid_name_use(fstring group, enum SID_NAME_USE name_use)
}
/****************************************************************************
-open the group mapping tdb
+ Open the group mapping tdb.
****************************************************************************/
+
BOOL init_group_mapping(void)
{
static pid_t local_pid;
char *vstring = "INFO/version";
-
- if (tdb && local_pid == sys_getpid()) return True;
+ int32 vers_id;
+
+ if (tdb && local_pid == sys_getpid())
+ return True;
tdb = tdb_open_log(lock_path("group_mapping.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
if (!tdb) {
DEBUG(0,("Failed to open group mapping database\n"));
@@ -160,10 +163,20 @@ BOOL init_group_mapping(void)
/* handle a Samba upgrade */
tdb_lock_bystring(tdb, vstring);
- if (tdb_fetch_int(tdb, vstring) != DATABASE_VERSION) {
+
+ /* Cope with byte-reversed older versions of the db. */
+ vers_id = tdb_fetch_int32(tdb, vstring);
+ if ((vers_id != DATABASE_VERSION) && (IREV(vers_id) == DATABASE_VERSION)) {
+ /* Written on a bigendian machine with old fetch_int code. Save as le. */
+ tdb_store_int32(tdb, vstring, DATABASE_VERSION);
+ vers_id = DATABASE_VERSION;
+ }
+
+ if (vers_id != DATABASE_VERSION) {
tdb_traverse(tdb, tdb_traverse_delete_fn, NULL);
- tdb_store_int(tdb, vstring, DATABASE_VERSION);
+ tdb_store_int32(tdb, vstring, DATABASE_VERSION);
}
+
tdb_unlock_bystring(tdb, vstring);
/* write a list of default groups */
diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c
index 6f9ff9dd65..7ebcc9e85e 100644
--- a/source3/intl/lang_tdb.c
+++ b/source3/intl/lang_tdb.c
@@ -144,11 +144,11 @@ BOOL lang_tdb_init(const char *lang)
free(path);
- loadtime = tdb_fetch_int(tdb, "/LOADTIME/");
+ loadtime = tdb_fetch_int32(tdb, "/LOADTIME/");
if (loadtime == -1 || loadtime < st.st_mtime) {
load_msg(msg_path);
- tdb_store_int(tdb, "/LOADTIME/", (int)time(NULL));
+ tdb_store_int32(tdb, "/LOADTIME/", (int)time(NULL));
}
free(msg_path);
diff --git a/source3/lib/account_pol.c b/source3/lib/account_pol.c
index 111bf5bb91..126ee291d8 100644
--- a/source3/lib/account_pol.c
+++ b/source3/lib/account_pol.c
@@ -25,14 +25,16 @@ static TDB_CONTEXT *tdb; /* used for driver files */
#define DATABASE_VERSION 1
/****************************************************************************
-open the account policy tdb
+ Open the account policy tdb.
****************************************************************************/
+
BOOL init_account_policy(void)
{
static pid_t local_pid;
char *vstring = "INFO/version";
- if (tdb && local_pid == sys_getpid()) return True;
+ if (tdb && local_pid == sys_getpid())
+ return True;
tdb = tdb_open_log(lock_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
if (!tdb) {
DEBUG(0,("Failed to open account policy database\n"));
@@ -43,9 +45,9 @@ BOOL init_account_policy(void)
/* handle a Samba upgrade */
tdb_lock_bystring(tdb, vstring);
- if (tdb_fetch_int(tdb, vstring) != DATABASE_VERSION) {
+ if (tdb_fetch_int32(tdb, vstring) != DATABASE_VERSION) {
tdb_traverse(tdb, tdb_traverse_delete_fn, NULL);
- tdb_store_int(tdb, vstring, DATABASE_VERSION);
+ tdb_store_int32(tdb, vstring, DATABASE_VERSION);
account_policy_set(AP_MIN_PASSWORD_LEN, MINPASSWDLENGTH); /* 5 chars minimum */
account_policy_set(AP_PASSWORD_HISTORY, 0); /* don't keep any old password */
@@ -59,7 +61,6 @@ BOOL init_account_policy(void)
}
tdb_unlock_bystring(tdb, vstring);
-
return True;
}
@@ -102,7 +103,7 @@ BOOL account_policy_get(int field, uint32 *value)
init_account_policy();
fstrcpy(name, decode_account_policy_name(field));
- *value=tdb_fetch_int(tdb, name);
+ *value=tdb_fetch_int32(tdb, name);
DEBUG(10,("account_policy_get: %s:%d\n", name, *value));
return True;
}
@@ -117,7 +118,7 @@ BOOL account_policy_set(int field, uint32 value)
init_account_policy();
fstrcpy(name, decode_account_policy_name(field));
- if ( tdb_store_int(tdb, name, value)== -1)
+ if ( tdb_store_int32(tdb, name, value)== -1)
return False;
DEBUG(10,("account_policy_set: %s:%d\n", name, value));
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index b49767eac7..6c0e4c83e7 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -262,15 +262,27 @@ BOOL nt_printing_init(void)
/* handle a Samba upgrade */
tdb_lock_bystring(tdb_drivers, vstring);
- if (tdb_fetch_int(tdb_drivers, vstring) != NTDRIVERS_DATABASE_VERSION) {
-
- if (tdb_fetch_int(tdb_drivers, vstring) == NTDRIVERS_DATABASE_VERSION_1) {
- if (!upgrade_to_version_2())
- return False;
- } else
- tdb_traverse(tdb_drivers, tdb_traverse_delete_fn, NULL);
+ {
+ int32 vers_id;
+
+ /* Cope with byte-reversed older versions of the db. */
+ vers_id = tdb_fetch_int32(tdb_drivers, vstring);
+ if ((vers_id != NTDRIVERS_DATABASE_VERSION) && (IREV(vers_id) == NTDRIVERS_DATABASE_VERSION)) {
+ /* Written on a bigendian machine with old fetch_int code. Save as le. */
+ tdb_store_int32(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION);
+ vers_id = NTDRIVERS_DATABASE_VERSION;
+ }
+
+ if (vers_id != NTDRIVERS_DATABASE_VERSION) {
- tdb_store_int(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION);
+ if ((vers_id == NTDRIVERS_DATABASE_VERSION_1) || (IREV(vers_id) == NTDRIVERS_DATABASE_VERSION_1)) {
+ if (!upgrade_to_version_2())
+ return False;
+ } else
+ tdb_traverse(tdb_drivers, tdb_traverse_delete_fn, NULL);
+
+ tdb_store_int32(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION);
+ }
}
tdb_unlock_bystring(tdb_drivers, vstring);
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index ab966bd9f2..08115cdb79 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -45,9 +45,10 @@ static pid_t local_pid;
static int get_queue_status(int, print_status_struct *);
/****************************************************************************
-initialise the printing backend. Called once at startup.
-Does not survive a fork
+ Initialise the printing backend. Called once at startup.
+ Does not survive a fork
****************************************************************************/
+
BOOL print_backend_init(void)
{
char *sversion = "INFO/version";
@@ -63,9 +64,9 @@ BOOL print_backend_init(void)
/* handle a Samba upgrade */
tdb_lock_bystring(tdb, sversion);
- if (tdb_fetch_int(tdb, sversion) != PRINT_DATABASE_VERSION) {
+ if (tdb_fetch_int32(tdb, sversion) != PRINT_DATABASE_VERSION) {
tdb_traverse(tdb, tdb_traverse_delete_fn, NULL);
- tdb_store_int(tdb, sversion, PRINT_DATABASE_VERSION);
+ tdb_store_int32(tdb, sversion, PRINT_DATABASE_VERSION);
}
tdb_unlock_bystring(tdb, sversion);
@@ -263,7 +264,7 @@ static void print_cache_flush(int snum)
{
fstring key;
slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum));
- tdb_store_int(tdb, key, -1);
+ tdb_store_int32(tdb, key, -1);
}
/****************************************************************************
@@ -385,7 +386,7 @@ static void print_queue_update_background(int snum)
*/
slprintf(cachestr, sizeof(cachestr)-1, "CACHE/%s", printer_name);
- tdb_store_int(tdb, cachestr, (int)time(NULL));
+ tdb_store_int32(tdb, cachestr, (int)time(NULL));
/* get the current queue using the appropriate interface */
ZERO_STRUCT(status);
@@ -441,7 +442,7 @@ static void print_queue_update_background(int snum)
safe_free(tstruct.queue);
- tdb_store_int(tdb, "INFO/total_jobs", tstruct.total_jobs);
+ tdb_store_int32(tdb, "INFO/total_jobs", tstruct.total_jobs);
/*
* Get the old print status. We will use this to compare the
@@ -471,7 +472,7 @@ static void print_queue_update_background(int snum)
*/
slprintf(keystr, sizeof(keystr)-1, "CACHE/%s", printer_name);
- tdb_store_int(tdb, keystr, (int)time(NULL));
+ tdb_store_int32(tdb, keystr, (int)time(NULL));
/* Delete our pid from the db. */
set_updating_pid(printer_name, True);
@@ -812,7 +813,7 @@ static BOOL print_cache_expired(int snum)
time_t t2, t = time(NULL);
slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum));
- t2 = tdb_fetch_int(tdb, key);
+ t2 = tdb_fetch_int32(tdb, key);
if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
DEBUG(3, ("print cache expired for queue %s \
(last_cache = %d, time now = %d, qcachetime = %d)\n", lp_servicename(snum),
@@ -875,7 +876,7 @@ static int get_total_jobs(int snum)
/* make sure the database is up to date */
if (print_cache_expired(snum)) print_queue_update(snum);
- total_jobs = tdb_fetch_int(tdb, "INFO/total_jobs");
+ total_jobs = tdb_fetch_int32(tdb, "INFO/total_jobs");
if (total_jobs >0)
return total_jobs;
else
@@ -966,7 +967,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
/* lock the database */
tdb_lock_bystring(tdb, "INFO/nextjob");
- next_jobid = tdb_fetch_int(tdb, "INFO/nextjob");
+ next_jobid = tdb_fetch_int32(tdb, "INFO/nextjob");
if (next_jobid == -1)
next_jobid = 1;
@@ -981,7 +982,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
goto fail;
}
- tdb_store_int(tdb, "INFO/nextjob", jobid);
+ tdb_store_int32(tdb, "INFO/nextjob", jobid);
/* we have a job entry - now create the spool file */
slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%.6d.XXXXXX",
diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c
index f37096fec3..57013829c5 100644
--- a/source3/rpc_server/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srv_srvsvc_nt.c
@@ -120,30 +120,41 @@ static TDB_CONTEXT *share_tdb; /* used for share security descriptors */
BOOL share_info_db_init(void)
{
- static pid_t local_pid;
- char *vstring = "INFO/version";
+ static pid_t local_pid;
+ char *vstring = "INFO/version";
+ int32 vers_id;
- if (share_tdb && local_pid == sys_getpid()) return True;
- share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
- if (!share_tdb) {
- DEBUG(0,("Failed to open share info database %s (%s)\n",
- lock_path("share_info.tdb"), strerror(errno) ));
- return False;
- }
+ if (share_tdb && local_pid == sys_getpid())
+ return True;
+ share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+ if (!share_tdb) {
+ DEBUG(0,("Failed to open share info database %s (%s)\n",
+ lock_path("share_info.tdb"), strerror(errno) ));
+ return False;
+ }
- local_pid = sys_getpid();
+ local_pid = sys_getpid();
- /* handle a Samba upgrade */
- tdb_lock_bystring(share_tdb, vstring);
- if (tdb_fetch_int(share_tdb, vstring) != SHARE_DATABASE_VERSION) {
- tdb_traverse(share_tdb, tdb_traverse_delete_fn, NULL);
- tdb_store_int(share_tdb, vstring, SHARE_DATABASE_VERSION);
- }
- tdb_unlock_bystring(share_tdb, vstring);
+ /* handle a Samba upgrade */
+ tdb_lock_bystring(share_tdb, vstring);
+
+ /* Cope with byte-reversed older versions of the db. */
+ vers_id = tdb_fetch_int32(share_tdb, vstring);
+ if ((vers_id != SHARE_DATABASE_VERSION) && (IREV(vers_id) == SHARE_DATABASE_VERSION)) {
+ /* Written on a bigendian machine with old fetch_int code. Save as le. */
+ tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION);
+ vers_id = SHARE_DATABASE_VERSION;
+ }
+
+ if (vers_id != SHARE_DATABASE_VERSION) {
+ tdb_traverse(share_tdb, tdb_traverse_delete_fn, NULL);
+ tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION);
+ }
+ tdb_unlock_bystring(share_tdb, vstring);
message_register(MSG_SMB_CONF_UPDATED, smb_conf_updated);
- return True;
+ return True;
}
/*******************************************************************