1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

59433 Commits

Author SHA1 Message Date
Michael Adam
a752bbd10d s3:registry: eliminate race condition in creating/scanning sorted subkeys
Called, from key_exists, scan_sorted_subkeys re-creates the sorted
subkeys record of the given key and then searches through it.
The race is that between creation and parsing of the sorted subkey
record, another process that stores some other subkey of the same
parent key will delete the sorted subkey record, resulting in an
WERR_BADFILE of an operation that should actually succeed.

This patch fixes the issue by wrapping the creation and parsing
into a transaction.

Michael
2010-02-12 23:12:12 +01:00
Michael Adam
09f3ed1024 s3:make "net conf addshare" atomic by wrapping all writes in one transaction
Michael
2010-02-12 23:12:12 +01:00
Michael Adam
83fffbeb44 s3:g_lock: remove a nested event loop, replacing the inner loop by select
This made smbd crash in g_lock_lock() when trying to start a
transaction on a db with an already started transaction,
e.g. in a tcon_and_X where the share_info.tdb was not yet
initialized but share_info.tdb was already locked by another
process or writing acces to the winreg rpc pipe where the
registry tdb was already locked by another process.

What we really _want_ to do here by design is to react to
MSG_DBWRAP_G_LOCK_RETRY messages that are either sent
by a client doing g_lock_unlock or by ourselves when
we receive a CTDB_SRVID_SAMBA_NOTIFY or
CTDB_SRVID_RECONFIGURE message from ctdbd, i.e. when
either a client holding a lock or a complete node
has died.

Doing this properly involves calling tevent_loop_once(),
but doing this here with the main ctdbd messaging context
creates a nested event loop when g_lock_lock() is called
from the main event loop.

So as a quick fix, we act a little corasely here: we do
a select on the ctdb connection fd and when it is readable
or we get EINTR, then we retry without actually parsing
any ctdb packages or dispatching messages. This means that
we retry more often than necessary and intended by design,
but this does not harm and it is unobtrusive. When we have
finished, the main loop will pick up all the messages and
ctdb packets. The only extra twist is that we cannot use
timed events here but have to handcode a timeout for select.

Michael
2010-02-12 23:12:12 +01:00
Michael Adam
e4af0bc5af s3:ctdb_conn: add ctdbd_conn_get_fd() to get the fd out of the ctdb connection
Michael
2010-02-12 23:12:12 +01:00
Michael Adam
8e306b51b7 s3:g_lock: remove an unreached code path.
Michael
2010-02-12 23:12:12 +01:00
Michael Adam
1933214108 s3:dbwrap_ctdb: fix reading/storing of special key __db_sequence_number__
The key for reading and writing was inconsistent due to a
off by one data length.

Michael
2010-02-12 23:12:12 +01:00
Michael Adam
c311697ade s3:dbwrap_ctdb: exit early when nothing has been written in transaction_commit.
This skips update of the __db_sequence_number__ record when nothing else has
been written. There are transactions that are just openend and then nothing
is written until transaction_commit is called. This is for instance the case
with registry initialization routines: They start a transaction and only
write somthing when the registry has not been initialized yet.
So this change will skip many db_seqnum bumps and TRANS3_COMMIT roundtrips.

Michael
2010-02-12 23:12:12 +01:00
Michael Adam
1d594bd734 s3:dbwrap_ctdb: fix brown paperbag bug in ctdb_transaction_commit.
I carefully prepared the return value only to "return 0;" at the bottom. :-(
This may well have hit us for instance in the nested cancel case
and produced random errors.

Michael
2010-02-12 23:12:11 +01:00
Michael Adam
524072b56b s3:dbwrap_ctdb: fix logic error in pull_newest_from_marshall_buffer().
The logic bug was that if a record was found in the marshall buffer,
then always the ctdb header of tha last record in the marshall buffer
was returned, and not the ctdb header of the last occurrence of the
requested record.

This is fixed by introducing an additional temporary variable.

Michael
2010-02-12 23:12:11 +01:00
Michael Adam
1505b69dea s3:dbwrap_ctdb: fix an uninitialized variable.
Michael
2010-02-12 23:12:11 +01:00
Michael Adam
fb981cdb82 s3:dbwrap_ctdb: fix two "may be used uninitialized" warnings
Michael
2010-02-12 23:12:11 +01:00
Michael Adam
10a44ee693 s3:dbwrap_ctdb: fix db_ctdb_fetch_db_seqnum_from_db() when NT_STATUS_NOT_FOUND.
Don't treat this as an error but return seqnum 0 instead.

Michael
2010-02-12 23:12:11 +01:00
Volker Lendecke
a66c40ff38 s3:dbwrap: If "-n" is given to dbwrap_torture, open db with CLEAR_IF_FIRST 2010-02-12 23:12:10 +01:00
Michael Adam
9113ce82b5 s3:build: remove checks for deprecated ctdb controls.
Michael
2010-02-12 23:12:10 +01:00
Michael Adam
3fe7ce141d s3:dbwrap_ctdb: maintain a database sequence number that bumps in transactions
For persistent databases, 64bit integer is kept in a special record
__db_sequence_number__. This record is incremented with each completed
transaction.

The retry mechanism for failing TRANS3_COMMIT controls inside the
db_ctdb_transaction_commit() function now relies one a modified
behaviour of ctdbd's treatment of persistent databases in recoveries.
Recently, a special treatment for persistent databases had been
introduced in ctdb (1.0.108) to work around the problems with the
orinal design of persistent transactions.
Now with the rewrite we need to revert to the old behaviour that
ctdb always takes the newest copies of all records.

This change also paves the way for a next step, which will make
recovery use the db seqnum to tell which node has the newest copy
of a persistent db and use that node's copy. This will greatly
reduce the amount of data transferred with each recovery.

Michael
2010-02-12 23:12:10 +01:00
Michael Adam
26225d3e79 s3:dbwrap_ctdb: change db_ctdb_transaction_store() to return NTSTATUS.
The return values calculated by the callers were wrong anyways since
the new marshalling code does not set the local tdbs tdb error code.

Michael
2010-02-12 23:12:10 +01:00
Michael Adam
5a0c42770b s3:dbwrap_ctdb: update (C)
Michael
2010-02-12 23:12:10 +01:00
Michael Adam
d4c0afa841 build: Add a configure check for CTDB_CONTROL_TRANS3_COMMIT.
This is the new implementation of ctdb transactions using the
global lock feature. It is needed by the current dbwrap_ctdb code.

Michael
2010-02-12 23:12:10 +01:00
Volker Lendecke
ebc08b9938 s3: Add tdb_data_equal 2010-02-12 23:12:10 +01:00
Volker Lendecke
a035062f11 s3:torture: add a test LOCAL-DBTRANS to torture dbwrap with transactions. 2010-02-12 23:12:09 +01:00
Michael Adam
16bc6ba226 s3:dbwrap_ctdb: start rewrite of transactions using the global lock (g_lock)
This simplifies the transaction code a lot:

* transaction_start essentially consists of acquiring a global lock.

* No write operations at all are performed on the local database
  until the transaction is committed: Every store operation is just
  going into the marshall buffer.

* The commit operation calls a new simplified TRANS3_COMMIT control
  in ctdb which rolls out thae changes to all nodes including the
  node that is performing the transaction.

Michael
2010-02-12 23:12:09 +01:00
Volker Lendecke
b13dd17840 s3: setup debug for smbtorture 2010-02-12 23:12:09 +01:00
Volker Lendecke
12abab711b s3: Add ctdb_conn_msg_ctx() 2010-02-12 23:12:09 +01:00
Volker Lendecke
4c1c3f2549 s3: Implement global locks in a g_lock tdb
This is the basis to implement global locks in ctdb without depending on a
shared file system. The initial goal is to make ctdb persistent transactions
deterministic without too many timeouts.
2010-02-12 23:12:09 +01:00
Simo Sorce
30797cec7d s4:kdc Fill in created_by principal field 2010-02-12 16:39:33 -05:00
Simo Sorce
2e2b7e8259 s4:kdc Fix double free and uninitialized memory.
In samba_kdc_trust_message2entry() on error, hdb_free_entry()
may end up trying to access uninitialized memory or double
free the hdb_entry.
2010-02-12 16:39:26 -05:00
Günther Deschner
89621d8d19 testprogs: print all printerinfo levels in spoolss test.
Guenther
2010-02-12 20:46:44 +01:00
Matthias Dieter Wallnöfer
d5af819b1a s4:auth/credentials/credentials.c - Initialise the "lm_response" and "nt_response" structures
In some cases those structures are not initialised and the whole authentication
system crashes with a SIGSEGV. Bug discovered by Matthieu Patou in bug #6755.
2010-02-12 15:04:07 +01:00
Matthias Dieter Wallnöfer
de555895e5 s4:getopt.py - set the password callback only when no password has been provided
Previously the "no_pass" and "no_pass2" variables weren't handled correctly.
Since at the initialisation of the "CredentialsOptions" we don't have any
password at all. Only afterwards we could get one through "set_password".

If a password is specified, use it. If no password is specified, consider the
use fo an input mask on STDOUT. But if the loadparm context contains one prefer
it over the input.
2010-02-12 15:04:07 +01:00
Stefan Metzmacher
e82ac8655e s4:net_drs_bind: make some more stuff static
metze
2010-02-12 12:58:47 +01:00
Stefan Metzmacher
eee98110b3 s4:net/drs: use the full path to "utils/net/drs/net_drs*.h"
This fixes the build with automatic dependecies.

metze
2010-02-12 12:58:34 +01:00
Volker Lendecke
44f75eded1 s3: notify_onelevel does not use seqnums, so don't open asking for it 2010-02-12 12:08:22 +01:00
Günther Deschner
7e328e1e1c spoolss: regenerate hand-marshalled ndr_pull_spoolss_DriverInfo101 after ndr64 changes.
Guenther
2010-02-12 11:34:56 +01:00
Günther Deschner
95846bfee6 spoolss: make sure hand-marshalled spoolss_DriverInfo101 handles relative_highest_offset.
Guenther
2010-02-12 11:34:48 +01:00
Günther Deschner
8f07339b6d spoolss: regenerate hand-marshalled ndr_push_spoolss_DriverInfo101 after ndr64 changes.
Guenther
2010-02-12 11:34:39 +01:00
Jeremy Allison
9fc76f86fa Remove the code replaced by widelinks warning.
Jeremy.
2010-02-11 15:59:41 -08:00
Jeremy Allison
a6f402ad87 Remove lp_safe_widelinks() -> convert to just lp_widelinks. Suggestion from Volker.
Create widelinks_warning(int snum) to cover the message needed in make_connection.

Jeremy.
2010-02-11 15:16:23 -08:00
Kai Blin
4ff7f6ed36 s3 test: Make the netbios name test pass again 2010-02-11 23:56:36 +01:00
Kai Blin
ea055e8c79 s4: Switch to S3-style id mapping data types. 2010-02-11 23:56:35 +01:00
Kai Blin
86d70ae944 s4 idmap: Make the sid_to_xid and xid_to_sid calls static.
Looking at the winbind interface, we should only be using the bulk conversion calls.
2010-02-11 23:56:35 +01:00
Kai Blin
5d848053a7 libwbclient: Test wbcLookupName async functions 2010-02-11 23:56:35 +01:00
Kai Blin
cf968371ef libwbclient: Implement wbcLookupName_send/recv 2010-02-11 23:56:35 +01:00
Kai Blin
145f2c751b libwbclient: Implement wbcAuthenticateUserEx_send/recv 2010-02-11 23:56:35 +01:00
Kai Blin
749fb03971 libwbclient: Implement wbcLookupSid_send/recv 2010-02-11 23:56:34 +01:00
Kai Blin
57886720bb libwbclient: Implement wbcGidToSid_send/recv 2010-02-11 23:56:34 +01:00
Kai Blin
ada6e26d5e libwbclient: Implement wbcSidToGid_send/recv 2010-02-11 23:56:34 +01:00
Kai Blin
446b4aa17c libwbclient: Implement wbcUidToSid_send/recv 2010-02-11 23:56:34 +01:00
Kai Blin
4ff1906357 libwbclient: Implement wbcSidToUid_send/recv 2010-02-11 23:56:34 +01:00
Kai Blin
33bbe1cafd libwbclient: Add wbcInterfaceDetails_send/recv 2010-02-11 23:56:33 +01:00
Kai Blin
861ef367c8 libwbclient: Add wbcDomainInfo_send/recv calls 2010-02-11 23:56:33 +01:00