diff options
author | Jeremy Allison <jra@samba.org> | 2002-01-09 04:13:30 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-01-09 04:13:30 +0000 |
commit | 91536cc901088232074ad8dd7ae16e0f6026f25e (patch) | |
tree | f0d2539b3503ed58ea6830d2b85c424849b98bf5 /source3/rpc_server | |
parent | 0a3f6b9b489fda547650083252906a881740af2b (diff) | |
download | samba-91536cc901088232074ad8dd7ae16e0f6026f25e.tar.gz samba-91536cc901088232074ad8dd7ae16e0f6026f25e.tar.bz2 samba-91536cc901088232074ad8dd7ae16e0f6026f25e.zip |
Fixed all uses of tdb_fetch/store/_int to use explicit int32 little endian
in tdb's. All except winbindd_idmap.... Hmmmmmm.
Jeremy.
(This used to be commit ec71f1732b6b27bd2d65b250a6f3720a235dc38d)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_srvsvc_nt.c | 47 |
1 files changed, 29 insertions, 18 deletions
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; } /******************************************************************* |