Discussion:
[SCM] Samba Shared Repository - branch master updated
(too old to reply)
Amitay Isaacs
2015-11-16 10:48:03 UTC
Permalink
The branch, master has been updated
via 44bf7c2 ctdb-recoverd: Factor out recovery master validation
via e44957f ctdb-recmaster: Update capabilities before calling first election
via c5e50a4 ctdb-recoverd: Move VNN map retrieval to where it is needed
via d1f996a ctdb-recoverd: Drop explicit check for recovery lock
via 1499f3e ctdb-recoverd: Simplify using TALLOC_FREE()
via 050e64b ctdb-recoverd: Clarify that recmaster is being set on the current node
via 0833e47 ctdb-recoverd: Do not sanity check recovery master with local daemon
via d8decd0 ctdb-recoverd: Don't retrieve recovery master from local daemon
via e90cab7 ctdb-recoverd: Explicitly set initial recovery master to unknown
via 018077f ctdb-recoverd: Do not set recovery master during recovery
via 4b37cc7 ctdb-recoverd: Have recovery daemon remember election result
via 6f88375 ctdb-recoverd: Clarify recovery master validation logic
via 74fa62c WHATSNEW: Document CTDB tunable change
via 9166c30 ctdb-daemon: Rename EventScriptTimeoutCount to MonitorTimeoutCount
via 55ad4d8 ctdb-daemon: Move script timeout count into monitor state
via 0d5db1c ctdb-daemon: Reset script timeout count in monitor code
via a33b50d ctdb-daemon: Do not bother printing script timeout count
via 134ede8 ctdb-doc: Correct documentation for tunables for script timeout
via bda2d9d ctdb-ipalloc: Don't consider runstates in the IP takeover code
via 9ea3188 ctdb-ipalloc: Check for available IPs, not runstate, in takeover run
via 66574c9 ctdb-ipalloc: A VNN can only host IPs if node is in RUNNING runstate
from 6b4a961 ctdb-build: Remove ctdb-common-util subsystem

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


- Log -----------------------------------------------------------------
commit 44bf7c2a12e0bd806552f8cbe0b013a5d07e0218
Author: Martin Schwenke <***@meltin.net>
Date: Tue Oct 27 16:43:07 2015 +1100

ctdb-recoverd: Factor out recovery master validation

Starting to untangle cluster management, database recovery and public
IP allocation. This is a non-trivial subset of the cluster management
code that runs in the recovery daemon on all nodes.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

Autobuild-User(master): Amitay Isaacs <***@samba.org>
Autobuild-Date(master): Mon Nov 16 11:47:45 CET 2015 on sn-devel-104

commit e44957fc8ba67e90f5ded77c6e9ae59ad59b42a0
Author: Martin Schwenke <***@meltin.net>
Date: Tue Oct 27 15:09:33 2015 +1100

ctdb-recmaster: Update capabilities before calling first election

Capabilities are used when computing an election result so having them
up-to-date seems like a good idea.

Also update several instances of an ambiguous comment.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit c5e50a474b6ddac05cab0116da42c62a615c6c79
Author: Martin Schwenke <***@meltin.net>
Date: Tue Oct 27 14:35:09 2015 +1100

ctdb-recoverd: Move VNN map retrieval to where it is needed

The VNN map is only needed on the recovery master, so no need for all
recovery daemons to retrieve it.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit d1f996a50f1da36e7046fe28cdb97285e7cf00a5
Author: Martin Schwenke <***@meltin.net>
Date: Tue Oct 27 14:32:48 2015 +1100

ctdb-recoverd: Drop explicit check for recovery lock

This is already handled in update_recovery_lock(), which is called
immediately before.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 1499f3e301db856d10e481adf5be9b01999a08e4
Author: Martin Schwenke <***@meltin.net>
Date: Fri Oct 23 16:00:55 2015 +1100

ctdb-recoverd: Simplify using TALLOC_FREE()

The only non-obvious part here is dropping the setting of the nodemap
local variable to NULL. If the following control succeeds then it is
set, otherwise return and it doesn't matter.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 050e64b6478fb17e3c69ba24cf68f630da9f691a
Author: Martin Schwenke <***@meltin.net>
Date: Fri Oct 23 15:27:12 2015 +1100

ctdb-recoverd: Clarify that recmaster is being set on the current node

That is, using CTDB_CURRENT_NODE makes this more obvious.

Also fix incorrect error messages.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 0833e478c36761b546be5f9ceadac81573825b22
Author: Martin Schwenke <***@meltin.net>
Date: Fri Oct 23 15:05:08 2015 +1100

ctdb-recoverd: Do not sanity check recovery master with local daemon

Each recovery daemon knows who the recmaster is and is in sync with
its local daemon. The recovery master is running this check so do not
bother checking with its local daemon - both agree that it is the
recovery master.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit d8decd0b1d6446ab079b41e4b8d99e88b34c6e6d
Author: Martin Schwenke <***@meltin.net>
Date: Fri Oct 23 15:33:01 2015 +1100

ctdb-recoverd: Don't retrieve recovery master from local daemon

The recovery daemon already knows which node is the master. This
relies on rec->recmaster being correctly initialised and correctly set
during elections.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit e90cab70739cc7c39600c065389f7bdad6038031
Author: Martin Schwenke <***@meltin.net>
Date: Tue Nov 10 13:54:47 2015 +1100

ctdb-recoverd: Explicitly set initial recovery master to unknown

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 018077f3b024b4d2862a8c1ae6758b88b7889b3e
Author: Martin Schwenke <***@meltin.net>
Date: Thu Oct 22 21:54:58 2015 +1100

ctdb-recoverd: Do not set recovery master during recovery

Recovery should not do cluster management functions. Setting the
recovery master should only be done via an election.

Main loop will determine if recovery master is inconsistent across the
cluster and force an election if necessary.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 4b37cc7cf659bec33c8a4c1bb9d5b3eaccc7c9e5
Author: Martin Schwenke <***@meltin.net>
Date: Fri Oct 23 14:32:41 2015 +1100

ctdb-recoverd: Have recovery daemon remember election result

The recovery daemon pushes knowledge of recovery master election
progress/result to local daemon. It then retrieves that information
again.

Instead, have the recovery daemon reliably track election
progress/result in rec->recmaster so it doesn't need to be retrieved.
Be careful to maintain consistency by only doing this when the local
daemon has been updated.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 6f8837528f43519a98d82aa85424c1e145dc98ee
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 21 16:19:00 2015 +1100

ctdb-recoverd: Clarify recovery master validation logic

There can be no holes in the nodemap. Even if a node has been deleted
it will take a slot in the nodemap. The only exception is that the
nodemap shrinks if nodes are deleted from the end. That should never
include the master because a node should be shutdown before being
deleted, and an election should already have take place.

To avoid walking off the end of the nodemap nodes array just confirm
that the master node's PNN is a valid index into the array. No need
to walk through the nodemap.

After this, in this section of the code j is now invalid. So use the
master's PNN to index into the nodemap. This is safe.

In the process, clean up some log messages to avoid saying "Force
reelection". It's just an "election".

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 74fa62c685069425e6e15783a0eb290e0778ce65
Author: Martin Schwenke <***@meltin.net>
Date: Fri Nov 13 15:23:14 2015 +1100

WHATSNEW: Document CTDB tunable change

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 9166c30a41997b8d94222abe551053dacd2ca0fa
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 17:03:01 2015 +1100

ctdb-daemon: Rename EventScriptTimeoutCount to MonitorTimeoutCount

This only applies to monitor events so renaming clarifies this.

Note that this change is not backward compatible. Users with

CTDB_SET_EventScriptTimeoutCount=<n>

in their configuration will get failures when starting CTDB but the
cause will be clearly logged.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 55ad4d80d491af5964429c5a6ac65ac515309060
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 16:51:59 2015 +1100

ctdb-daemon: Move script timeout count into monitor state

It is only used by the monitoring code.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 0d5db1c0072cf56904ab34aded73a13dc78a4153
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 16:42:41 2015 +1100

ctdb-daemon: Reset script timeout count in monitor code

This is the only place it is used.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit a33b50d07f10b3541dc6f6c8148416bb95871f8c
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 16:39:18 2015 +1100

ctdb-daemon: Do not bother printing script timeout count

It is only updated for monitor events, so it is meaningless here.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 134ede80e8165c4a1fe8a660c56bbd0e751d7565
Author: Martin Schwenke <***@meltin.net>
Date: Tue Oct 27 15:18:25 2015 +1100

ctdb-doc: Correct documentation for tunables for script timeout

* The defaults for EventScriptTimeout and EventScriptTimeoutCount are
wrong.

* EventScriptTimeout is the total time for all enabled scripts that
are run for an event, not a single event script.

* EventScriptTimeoutCount only applies to monitor events.

* EventScriptUnhealthyOnTimeout is obsolete, so remove it.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit bda2d9de2b188a3f3804ed198e9b59ffec5ef066
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 22:15:00 2015 +1100

ctdb-ipalloc: Don't consider runstates in the IP takeover code

Checking runstates is unnecessary now that nodes that are not RUNNING
will return no available IP addresses. I have no idea why I didn't do
it this way originally.

Tweak the test code to cope with this.

Note that this is a backward-incompatible change. If new and old
versions of CTDB are running together in a cluster and a new node
takes over as recovery master then old nodes will be able to host
public IP addresses before they are in RUNNING runstate. This is
mitigated by the bias towards recovery master stability in elections.
If it is important that nodes do not host IPs until they are RUNNING
then do not restart nodes running the old version.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 9ea318847a3ec2a18ce897833b8a5fcf6d8c4205
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 22:11:33 2015 +1100

ctdb-ipalloc: Check for available IPs, not runstate, in takeover run

The available IPs list is now only non-empty for nodes that are in
RUNNING runstate. So, to avoid running the IP allocation algorithm
when there are no available available IPs, explicitly check for
available IPs rather than checking runstates.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 66574c9fda26ee72f04426b2f7c96fe617332620
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 20:41:08 2015 +1100

ctdb-ipalloc: A VNN can only host IPs if node is in RUNNING runstate

This will allow wonderful simplification (i.e. removal) of some of the
runstate checking in the takeover run code.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

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

Summary of changes:
WHATSNEW.txt | 11 ++
ctdb/doc/ctdb-tunables.7.xml | 28 ++--
ctdb/doc/ctdb.1.xml | 2 +-
ctdb/include/ctdb_private.h | 1 -
ctdb/protocol/protocol.h | 2 +-
ctdb/server/ctdb_monitor.c | 13 +-
ctdb/server/ctdb_recoverd.c | 297 +++++++++++++++--------------------
ctdb/server/ctdb_takeover.c | 131 ++-------------
ctdb/server/ctdb_tunables.c | 2 +-
ctdb/server/eventscript.c | 5 +-
ctdb/tests/src/ctdb_takeover_tests.c | 54 ++++---
11 files changed, 212 insertions(+), 334 deletions(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index f1a1c07..53f7860 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -41,6 +41,17 @@ smb.conf changes
-------------- ----------- -------
aio max threads New 100

+CTDB changes
+------------
+
+* The CTDB tunable parameter EventScriptTimeoutCount has been renamed
+ to MonitorTimeoutCount
+
+ It has only ever been used to limit timed-out monitor events.
+
+ Configurations containing CTDB_SET_EventScriptTimeoutCount=<n> will
+ cause CTDB to fail at startup. Useful messages will be logged.
+
KNOWN ISSUES
============

diff --git a/ctdb/doc/ctdb-tunables.7.xml b/ctdb/doc/ctdb-tunables.7.xml
index b029fdb..6c164f3 100644
--- a/ctdb/doc/ctdb-tunables.7.xml
+++ b/ctdb/doc/ctdb-tunables.7.xml
@@ -166,29 +166,29 @@

<refsect2>
<title>EventScriptTimeout</title>
- <para>Default: 20</para>
+ <para>Default: 30</para>
<para>
- How long should ctdb let an event script run before aborting it and
- marking the node unhealthy.
+ Maximum time in seconds to allow an event to run before timing
+ out. This is the total time for all enabled scripts that are
+ run for an event, not just a single event script.
</para>
- </refsect2>

- <refsect2>
- <title>EventScriptTimeoutCount</title>
- <para>Default: 1</para>
<para>
- How many events in a row needs to timeout before we flag the node UNHEALTHY.
- This setting is useful if your scripts can not be written so that they
- do not hang for benign reasons.
+ Note that timeouts are ignored for some events ("takeip",
+ "releaseip", "startrecovery", "recovered") and converted to
+ success. The logic here is that the callers of these events
+ implement their own additional timeout.
</para>
</refsect2>

<refsect2>
- <title>EventScriptUnhealthyOnTimeout</title>
- <para>Default: 0</para>
+ <title>MonitorTimeoutCount</title>
+ <para>Default: 20</para>
<para>
- This setting can be be used to make ctdb never become UNHEALTHY if your
- eventscripts keep hanging/timing out.
+ How many monitor events in a row need to timeout before a node
+ is flagged as UNHEALTHY. This setting is useful if scripts
+ can not be written so that they do not hang for benign
+ reasons.
</para>
</refsect2>

diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml
index 0ff848c..3658c89 100644
--- a/ctdb/doc/ctdb.1.xml
+++ b/ctdb/doc/ctdb.1.xml
@@ -650,7 +650,7 @@ TakeoverTimeout = 9
MonitorInterval = 15
TickleUpdateInterval = 20
EventScriptTimeout = 30
-EventScriptTimeoutCount = 1
+MonitorTimeoutCount = 1
RecoveryGracePeriod = 120
RecoveryBanPeriod = 300
DatabaseHashSize = 100001
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 2542c4a..57a13d9 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -356,7 +356,6 @@ struct ctdb_context {
int start_as_disabled;
int start_as_stopped;
bool valgrinding;
- uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
uint32_t *recd_ping_count;
TALLOC_CTX *recd_ctx; /* a context used to track recoverd monitoring events */
TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h
index 27bc828..672b5ed 100644
--- a/ctdb/protocol/protocol.h
+++ b/ctdb/protocol/protocol.h
@@ -572,7 +572,7 @@ struct ctdb_tunable_list {
uint32_t monitor_interval;
uint32_t tickle_update_interval;
uint32_t script_timeout;
- uint32_t script_timeout_count; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
+ uint32_t monitor_timeout_count; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
uint32_t script_unhealthy_on_timeout; /* obsolete */
uint32_t recovery_grace_period;
uint32_t recovery_ban_period;
diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c
index 44cc547..4f998d3 100644
--- a/ctdb/server/ctdb_monitor.c
+++ b/ctdb/server/ctdb_monitor.c
@@ -39,6 +39,7 @@ struct ctdb_monitor_state {
uint32_t monitoring_mode;
TALLOC_CTX *monitor_context;
uint32_t next_interval;
+ uint32_t event_script_timeouts;
};

static void ctdb_check_health(struct tevent_context *ev,
@@ -144,14 +145,20 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
}

if (status == -ETIME) {
- ctdb->event_script_timeouts++;
+ ctdb->monitor->event_script_timeouts++;

- if (ctdb->event_script_timeouts >= ctdb->tunable.script_timeout_count) {
- DEBUG(DEBUG_ERR, ("Maximum timeout count %u reached for eventscript. Making node unhealthy\n", ctdb->tunable.script_timeout_count));
+ if (ctdb->monitor->event_script_timeouts >=
+ ctdb->tunable.monitor_timeout_count) {
+ DEBUG(DEBUG_ERR,
+ ("Maximum monitor timeout count %u reached."
+ " Making node unhealthy\n",
+ ctdb->tunable.monitor_timeout_count));
} else {
/* We pretend this is OK. */
goto after_change_status;
}
+ } else {
+ ctdb->monitor->event_script_timeouts = 0;
}

if (status != 0 && !(node->flags & NODE_FLAGS_UNHEALTHY)) {
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 13f833f..3f0cffc 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -418,7 +418,7 @@ static int run_startrecovery_eventscript(struct ctdb_recoverd *rec, struct ctdb_
}

/*
- update the node capabilities for all connected nodes
+ Retrieve capabilities from all connected nodes
*/
static int update_capabilities(struct ctdb_recoverd *rec,
struct ctdb_node_map_old *nodemap)
@@ -528,36 +528,6 @@ static int set_recovery_mode(struct ctdb_context *ctdb,
return 0;
}

-/*
- change recovery master on all node
- */
-static int set_recovery_master(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap, uint32_t pnn)
-{
- TDB_DATA data;
- TALLOC_CTX *tmp_ctx;
- uint32_t *nodes;
-
- tmp_ctx = talloc_new(ctdb);
- CTDB_NO_MEMORY(ctdb, tmp_ctx);
-
- data.dsize = sizeof(uint32_t);
- data.dptr = (unsigned char *)&pnn;
-
- nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
- if (ctdb_client_async_control(ctdb, CTDB_CONTROL_SET_RECMASTER,
- nodes, 0,
- CONTROL_TIMEOUT(), false, data,
- NULL, NULL,
- NULL) != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to set recmaster. Recovery failed.\n"));
- talloc_free(tmp_ctx);
- return -1;
- }
-
- talloc_free(tmp_ctx);
- return 0;
-}
-
/* update all remote nodes to use the same db priority that we have
this can fail if the remove node has not yet been upgraded to
support this function, so we always return success and never fail
@@ -2000,15 +1970,6 @@ static int db_recovery_serial(struct ctdb_recoverd *rec, TALLOC_CTX *mem_ctx,

DEBUG(DEBUG_NOTICE, (__location__ " Recovery - updated vnnmap\n"));

- /* update recmaster to point to us for all nodes */
- ret = set_recovery_master(ctdb, nodemap, pnn);
- if (ret!=0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to set recovery master\n"));
- return -1;
- }
-
- DEBUG(DEBUG_NOTICE, (__location__ " Recovery - updated recmaster\n"));
-
/* disable recovery mode */
ret = set_recovery_mode(ctdb, rec, nodemap, CTDB_RECOVERY_NORMAL, false);
if (ret != 0) {
@@ -2038,20 +1999,12 @@ static int do_recovery(struct ctdb_recoverd *rec,
DEBUG(DEBUG_NOTICE, (__location__ " Starting do_recovery\n"));

/* Check if the current node is still the recmaster. It's possible that
- * re-election has changed the recmaster, but we have not yet updated
- * that information.
+ * re-election has changed the recmaster.
*/
- ret = ctdb_ctrl_getrecmaster(ctdb, mem_ctx, CONTROL_TIMEOUT(),
- pnn, &ctdb->recovery_master);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster\n"));
- return -1;
- }
-
- if (pnn != ctdb->recovery_master) {
+ if (pnn != rec->recmaster) {
DEBUG(DEBUG_NOTICE,
("Recovery master changed to %u, aborting recovery\n",
- ctdb->recovery_master));
+ rec->recmaster));
return -1;
}

@@ -2146,7 +2099,7 @@ static int do_recovery(struct ctdb_recoverd *rec,
*/
sync_recovery_lock_file_across_cluster(rec);

- /* update the capabilities for all nodes */
+ /* Retrieve capabilities from all connected nodes */
ret = update_capabilities(rec, nodemap);
if (ret!=0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to update node capabilities.\n"));
@@ -2377,12 +2330,13 @@ static int send_election_request(struct ctdb_recoverd *rec, uint32_t pnn)
/* first we assume we will win the election and set
recoverymaster to be ourself on the current node
*/
- ret = ctdb_ctrl_setrecmaster(ctdb, CONTROL_TIMEOUT(), pnn, pnn);
+ ret = ctdb_ctrl_setrecmaster(ctdb, CONTROL_TIMEOUT(),
+ CTDB_CURRENT_NODE, pnn);
if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " failed to send recmaster election request\n"));
+ DEBUG(DEBUG_ERR, (__location__ " failed to set recmaster\n"));
return -1;
}
-
+ rec->recmaster = pnn;

/* send an election message to all active nodes */
DEBUG(DEBUG_INFO,(__location__ " Send election request to all active nodes\n"));
@@ -2786,11 +2740,13 @@ static void election_handler(uint64_t srvid, TDB_DATA data, void *private_data)
clear_ip_assignment_tree(ctdb);

/* ok, let that guy become recmaster then */
- ret = ctdb_ctrl_setrecmaster(ctdb, CONTROL_TIMEOUT(), ctdb_get_pnn(ctdb), em->pnn);
+ ret = ctdb_ctrl_setrecmaster(ctdb, CONTROL_TIMEOUT(),
+ CTDB_CURRENT_NODE, em->pnn);
if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " failed to send recmaster election request"));
+ DEBUG(DEBUG_ERR, (__location__ " failed to set recmaster"));
return;
}
+ rec->recmaster = em->pnn;

return;
}
@@ -2883,16 +2839,11 @@ static void monitor_handler(uint64_t srvid, TDB_DATA data, void *private_data)

nodemap->nodes[i].flags = c->new_flags;

- ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, CONTROL_TIMEOUT(),
- CTDB_CURRENT_NODE, &ctdb->recovery_master);
+ ret = ctdb_ctrl_getrecmode(ctdb, tmp_ctx, CONTROL_TIMEOUT(),
+ CTDB_CURRENT_NODE, &ctdb->recovery_mode);

- if (ret == 0) {
- ret = ctdb_ctrl_getrecmode(ctdb, tmp_ctx, CONTROL_TIMEOUT(),
- CTDB_CURRENT_NODE, &ctdb->recovery_mode);
- }
-
if (ret == 0 &&
- ctdb->recovery_master == ctdb->pnn &&
+ rec->recmaster == ctdb->pnn &&
ctdb->recovery_mode == CTDB_RECOVERY_NORMAL) {
/* Only do the takeover run if the perm disabled or unhealthy
flags changed since these will cause an ip failover but not
@@ -2922,19 +2873,11 @@ static void push_flags_handler(uint64_t srvid, TDB_DATA data,
struct ctdb_node_flag_change *c = (struct ctdb_node_flag_change *)data.dptr;
struct ctdb_node_map_old *nodemap=NULL;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- uint32_t recmaster;
uint32_t *nodes;

- /* find the recovery master */
- ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, &recmaster);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster from local node\n"));
- talloc_free(tmp_ctx);
- return;
- }
-
/* read the node flags from the recmaster */
- ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), recmaster, tmp_ctx, &nodemap);
+ ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), rec->recmaster,
+ tmp_ctx, &nodemap);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to get nodemap from node %u\n", c->pnn));
talloc_free(tmp_ctx);
@@ -3108,9 +3051,12 @@ static enum monitor_result verify_recmaster(struct ctdb_recoverd *rec, struct ct
rmdata->pnn = pnn;
rmdata->status = MONITOR_OK;

- /* loop over all active nodes and send an async getrecmaster call to
+ /* loop over all active nodes and send an async getrecmaster call to
them*/
for (j=0; j<nodemap->num; j++) {
+ if (nodemap->nodes[j].pnn == rec->recmaster) {
+ continue;
+ }
if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
continue;
}
@@ -3384,12 +3330,98 @@ static int update_recovery_lock_file(struct ctdb_context *ctdb)
return 0;
}

+static enum monitor_result validate_recovery_master(struct ctdb_recoverd *rec,
+ TALLOC_CTX *mem_ctx)
+{
+ struct ctdb_context *ctdb = rec->ctdb;
+ uint32_t pnn = ctdb_get_pnn(ctdb);
+ struct ctdb_node_map_old *nodemap = rec->nodemap;
+ struct ctdb_node_map_old *recmaster_nodemap = NULL;
+ int ret;
+
+ /* When recovery daemon is started, recmaster is set to
+ * "unknown" so it knows to start an election.
+ */
+ if (rec->recmaster == CTDB_UNKNOWN_PNN) {
+ DEBUG(DEBUG_NOTICE,
+ ("Initial recovery master set - forcing election\n"));
+ return MONITOR_ELECTION_NEEDED;
+ }
+
+ /*
+ * If the current recmaster does not have CTDB_CAP_RECMASTER,
+ * but we have, then force an election and try to become the new
+ * recmaster.
+ */
+ if (!ctdb_node_has_capabilities(rec->caps,
+ rec->recmaster,
+ CTDB_CAP_RECMASTER) &&
+ (rec->ctdb->capabilities & CTDB_CAP_RECMASTER) &&
+ !(nodemap->nodes[pnn].flags & NODE_FLAGS_INACTIVE)) {
+ DEBUG(DEBUG_ERR,
+ (" Current recmaster node %u does not have CAP_RECMASTER,"
+ " but we (node %u) have - force an election\n",
+ rec->recmaster, pnn));
+ return MONITOR_ELECTION_NEEDED;
+ }
+
+ /* Verify that the master node has not been deleted. This
+ * should not happen because a node should always be shutdown
+ * before being deleted, causing a new master to be elected
+ * before now. However, if something strange has happened
+ * then checking here will ensure we don't index beyond the
+ * end of the nodemap array. */
+ if (rec->recmaster >= nodemap->num) {
+ DEBUG(DEBUG_ERR,
+ ("Recmaster node %u has been deleted. Force election\n",
+ rec->recmaster));
+ return MONITOR_ELECTION_NEEDED;
+ }
+
+ /* if recovery master is disconnected/deleted we must elect a new recmaster */
+ if (nodemap->nodes[rec->recmaster].flags &
+ (NODE_FLAGS_DISCONNECTED|NODE_FLAGS_DELETED)) {
+ DEBUG(DEBUG_NOTICE,
+ ("Recmaster node %u is disconnected/deleted. Force election\n",
+ rec->recmaster));
+ return MONITOR_ELECTION_NEEDED;
+ }
+
+ /* get nodemap from the recovery master to check if it is inactive */
+ ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), rec->recmaster,
+ mem_ctx, &recmaster_nodemap);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,
+ (__location__
+ " Unable to get nodemap from recovery master %u\n",
+ rec->recmaster));
+ return MONITOR_FAILED;
+ }
+
+
+ if ((recmaster_nodemap->nodes[rec->recmaster].flags & NODE_FLAGS_INACTIVE) &&
+ (rec->node_flags & NODE_FLAGS_INACTIVE) == 0) {
+ DEBUG(DEBUG_NOTICE,
+ ("Recmaster node %u is inactive. Force election\n",
+ rec->recmaster));
+ /*
+ * update our nodemap to carry the recmaster's notion of
+ * its own flags, so that we don't keep freezing the
+ * inactive recmaster node...
+ */
+ nodemap->nodes[rec->recmaster].flags =
+ recmaster_nodemap->nodes[rec->recmaster].flags;
+ return MONITOR_ELECTION_NEEDED;
+ }
+
+ return MONITOR_OK;
+}
+
static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
TALLOC_CTX *mem_ctx)
{
uint32_t pnn;
struct ctdb_node_map_old *nodemap=NULL;
- struct ctdb_node_map_old *recmaster_nodemap=NULL;
struct ctdb_node_map_old **remote_nodemaps=NULL;
struct ctdb_vnn_map *vnnmap=NULL;
struct ctdb_vnn_map *remote_vnnmap=NULL;
@@ -3442,29 +3474,10 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
return;
}

- /* Make sure that if recovery lock verification becomes disabled when
- we close the file
- */
- if (ctdb->recovery_lock_file == NULL) {
- ctdb_recovery_unlock(ctdb);
- }
-
pnn = ctdb_get_pnn(ctdb);

- /* get the vnnmap */
- ret = ctdb_ctrl_getvnnmap(ctdb, CONTROL_TIMEOUT(), pnn, mem_ctx, &vnnmap);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to get vnnmap from node %u\n", pnn));
- return;
- }
-
-
- /* get number of nodes */
- if (rec->nodemap) {
- talloc_free(rec->nodemap);
- rec->nodemap = NULL;
- nodemap=NULL;
- }
+ /* get nodemap */
+ TALLOC_FREE(rec->nodemap);
ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), pnn, rec, &rec->nodemap);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to get nodemap from node %u\n", pnn));
@@ -3520,13 +3533,6 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
return;
}

- /* check which node is the recovery master */
- ret = ctdb_ctrl_getrecmaster(ctdb, mem_ctx, CONTROL_TIMEOUT(), pnn, &rec->recmaster);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster from node %u\n", pnn));
- return;
- }
-
/* If we are not the recmaster then do some housekeeping */
if (rec->recmaster != pnn) {
/* Ignore any IP reallocate requests - only recmaster
@@ -3541,80 +3547,23 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
TALLOC_FREE(rec->force_rebalance_nodes);
}

- /* This is a special case. When recovery daemon is started, recmaster
- * is set to -1. If a node is not started in stopped state, then
- * start election to decide recovery master
- */
- if (rec->recmaster == (uint32_t)-1) {
- DEBUG(DEBUG_NOTICE,(__location__ " Initial recovery master set - forcing election\n"));
- force_election(rec, pnn, nodemap);
- return;
- }
-
- /* update the capabilities for all nodes */
+ /* Retrieve capabilities from all connected nodes */
ret = update_capabilities(rec, nodemap);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to update node capabilities.\n"));
return;
}
--
Samba Shared Repository
Andrew Bartlett
2015-11-16 13:51:04 UTC
Permalink
The branch, master has been updated
via db99742 build:wafsamba: Waf 1.8 compatible declaration of 'mandatory' configuration tests
via 7c0575d build:wafsamba: Install named.conf only once
via cfe8bec build:wafsamba: Replace Options.is_install by bld.is_install
from 44bf7c2 ctdb-recoverd: Factor out recovery master validation

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


- Log -----------------------------------------------------------------
commit db99742d8b15cc1c48421a4720a43dff72c6ba1b
Author: Thomas Nagy <***@waf.io>
Date: Thu Nov 12 00:27:31 2015 +0100

build:wafsamba: Waf 1.8 compatible declaration of 'mandatory' configuration tests

The configuration tests raise exceptions by default in later Waf versions,
but the samba tests do not specify whether the errors should be raised or
not. This changes lifts the ambiguity.

Signed-off-by: Thomas Nagy <***@waf.io>
Reviewed-by: Andrew Bartlett <***@samba.org>
Reviewed-by: Michael Adam <***@samba.org>

Autobuild-User(master): Andrew Bartlett <***@samba.org>
Autobuild-Date(master): Mon Nov 16 14:50:39 CET 2015 on sn-devel-104

commit 7c0575d7ba29d79d8d287a862d6c88a4c5e65631
Author: Thomas Nagy <***@waf.io>
Date: Sun Nov 8 18:50:55 2015 +0100

build:wafsamba: Install named.conf only once

The wildcard *.conf already lists named.conf. Adding files
more than once will cause unnecessary rebuilds and raise
errors in later Waf versions.

Signed-off-by: Thomas Nagy <***@waf.io>
Reviewed-by: Andrew Bartlett <***@samba.org>
Reviewed-by: Michael Adam <***@samba.org>

commit cfe8becb9e62b9e15119107d186628c784a3d38c
Author: Thomas Nagy <***@waf.io>
Date: Sat Nov 7 00:57:36 2015 +0100

build:wafsamba: Replace Options.is_install by bld.is_install

Options.is_install is a deprecated module variable that is more
verbose than bld.is_install and complicates the Waf 1.8 upgrade.

Signed-off-by: Thomas Nagy <***@waf.io>
Reviewed-by: Andrew Bartlett <***@samba.org>
Reviewed-by: Michael Adam <***@samba.org>

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

Summary of changes:
buildtools/wafsamba/samba_autoconf.py | 7 +++++--
buildtools/wafsamba/samba_conftests.py | 4 ++--
buildtools/wafsamba/samba_install.py | 6 +++---
buildtools/wafsamba/samba_patterns.py | 3 +--
buildtools/wafsamba/samba_python.py | 9 +++++++--
buildtools/wafsamba/samba_wildcard.py | 1 -
buildtools/wafsamba/wafsamba.py | 2 +-
dynconfig/wscript | 4 ++--
lib/ldb/wscript | 4 ++--
source4/setup/wscript_build | 2 +-
10 files changed, 24 insertions(+), 18 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 99ceb77..09ce218 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -100,6 +100,7 @@ def CHECK_HEADER(conf, h, add_headers=False, lib=None):
type='nolink',
execute=0,
ccflags=ccflags,
+ mandatory=False,
includes=cpppath,
uselib=lib.upper(),
msg="Checking for header %s" % h)
@@ -485,6 +486,7 @@ def CHECK_LDFLAGS(conf, ldflags):
return conf.check(fragment='int main(void) { return 0; }\n',
execute=0,
ldflags=ldflags,
+ mandatory=False,
msg="Checking linker accepts %s" % ldflags)


@@ -568,9 +570,9 @@ int foo()

(ccflags, ldflags, cpppath) = library_flags(conf, lib)
if shlib:
- res = conf.check(features='c cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
+ res = conf.check(features='c cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False)
else:
- res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
+ res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False)

if not res:
if mandatory:
@@ -670,6 +672,7 @@ def SAMBA_CONFIG_H(conf, path=None):
execute=0,
ccflags='-fstack-protector',
ldflags='-fstack-protector',
+ mandatory=False,
msg='Checking if toolchain accepts -fstack-protector'):
conf.ADD_CFLAGS('-fstack-protector')
conf.ADD_LDFLAGS('-fstack-protector')
diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py
index b4e44c5..045f858 100644
--- a/buildtools/wafsamba/samba_conftests.py
+++ b/buildtools/wafsamba/samba_conftests.py
@@ -196,7 +196,7 @@ int foo(int v) {
return v * 2;
}
'''
- return conf.check(features='c cshlib',vnum="1",fragment=snip,msg=msg)
+ return conf.check(features='c cshlib',vnum="1",fragment=snip,msg=msg, mandatory=False)

@conf
def CHECK_NEED_LC(conf, msg):
@@ -258,7 +258,7 @@ int foo(int v) {
ldb_module = PyImport_ImportModule("ldb");
return v * 2;
}'''
- return conf.check(features='c cshlib',uselib='PYEMBED',fragment=snip,msg=msg)
+ return conf.check(features='c cshlib',uselib='PYEMBED',fragment=snip,msg=msg, mandatory=False)

# this one is quite complex, and should probably be broken up
# into several parts. I'd quite like to create a set of CHECK_COMPOUND()
diff --git a/buildtools/wafsamba/samba_install.py b/buildtools/wafsamba/samba_install.py
index 5f399f9..8297ce4 100644
--- a/buildtools/wafsamba/samba_install.py
+++ b/buildtools/wafsamba/samba_install.py
@@ -4,7 +4,7 @@
# library use

import os
-import Options, Utils
+import Utils
from TaskGen import feature, before, after
from samba_utils import LIB_PATH, MODE_755, install_rpath, build_rpath

@@ -19,7 +19,7 @@ def install_binary(self):
install_ldflags = install_rpath(self)
build_ldflags = build_rpath(bld)

- if not Options.is_install:
+ if not self.bld.is_install:
# just need to set rpath if we are not installing
self.env.RPATH = build_ldflags
return
@@ -68,7 +68,7 @@ def install_library(self):
install_ldflags = install_rpath(self)
build_ldflags = build_rpath(bld)

- if not Options.is_install or not getattr(self, 'samba_install', True):
+ if not self.bld.is_install or not getattr(self, 'samba_install', True):
# just need to set the build rpath if we are not installing
self.env.RPATH = build_ldflags
return
diff --git a/buildtools/wafsamba/samba_patterns.py b/buildtools/wafsamba/samba_patterns.py
index 9c6d499..ceca2cc 100644
--- a/buildtools/wafsamba/samba_patterns.py
+++ b/buildtools/wafsamba/samba_patterns.py
@@ -7,7 +7,7 @@ def write_version_header(task):
'''print version.h contents'''
src = task.inputs[0].srcpath(task.env)

- version = samba_version_file(src, task.env.srcdir, env=task.env, is_install=task.env.is_install)
+ version = samba_version_file(src, task.env.srcdir, env=task.env, is_install=task.generator.bld.is_install)
string = str(version)

task.outputs[0].write(string)
@@ -25,7 +25,6 @@ def SAMBA_MKVERSION(bld, target):
source= 'VERSION',
target=target,
always=bld.is_install)
- t.env.is_install = bld.is_install
Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION


diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index 6f94350..8075381 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -1,7 +1,7 @@
# waf build tool for building IDL files with pidl

import os
-import Build, Logs, Utils
+import Build, Logs, Utils, Configure
from Configure import conf

@conf
@@ -63,7 +63,12 @@ def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
del(conf.env.defines['PYTHONARCHDIR'])

def _check_python_headers(conf, mandatory):
- conf.check_python_headers(mandatory=mandatory)
+ try:
+ Configure.ConfigurationError
+ conf.check_python_headers(mandatory=mandatory)
+ except Configure.ConfigurationError:
+ if mandatory:
+ raise

if conf.env['PYTHON_VERSION'] > '3':
abi_pattern = os.path.splitext(conf.env['pyext_PATTERN'])[0]
diff --git a/buildtools/wafsamba/samba_wildcard.py b/buildtools/wafsamba/samba_wildcard.py
index 3d87481..ed3e0c2 100644
--- a/buildtools/wafsamba/samba_wildcard.py
+++ b/buildtools/wafsamba/samba_wildcard.py
@@ -130,7 +130,6 @@ def fake_build_environment(info=True, flush=False):

Options.commands['install'] = False
Options.commands['uninstall'] = False
- Options.is_install = False

bld.is_install = 0 # False

diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index a8e122c..a17b609 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -282,7 +282,7 @@ def SAMBA_LIBRARY(bld, libname, source,
if not vscriptpath:
raise Utils.WafError("unable to find vscript path for %s" % vscript)
bld.add_manual_dependency(fullpath, vscriptpath)
- if Options.is_install:
+ if bld.is_install:
# also make the .inst file depend on the vscript
instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
diff --git a/dynconfig/wscript b/dynconfig/wscript
index d76b6de..dba74f6 100755
--- a/dynconfig/wscript
+++ b/dynconfig/wscript
@@ -374,7 +374,7 @@ def dynconfig_cflags(bld, list=None):
if list and not varname in list:
continue
value = bld.env[varname]
- if not Options.is_install:
+ if not bld.is_install:
override = get_override(bld)
if varname in override:
value = os.path.join(bld.env.srcdir, override[varname])
@@ -399,7 +399,7 @@ def pathconfig_entities(bld, list=None):
if list and not varname in list:
continue
value = bld.env[varname]
- if not Options.is_install:
+ if not bld.is_install:
override = get_override(bld)
if varname in override:
value = os.path.join(bld.env.srcdir, override[varname])
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 662bec9..41eca8a 100755
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -13,7 +13,7 @@ while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
srcdir = srcdir + '/..'
sys.path.insert(0, srcdir + '/buildtools/wafsamba')

-import wafsamba, samba_dist, Options, Utils
+import wafsamba, samba_dist, Utils

samba_dist.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
lib/tdb:lib/tdb lib/tdb:lib/tdb lib/tevent:lib/tevent
@@ -150,7 +150,7 @@ def build(bld):
bld.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')

if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
- if Options.is_install:
+ if bld.is_install:
modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
else:
# when we run from the source directory, we want to use
diff --git a/source4/setup/wscript_build b/source4/setup/wscript_build
index cb83e3e..2717986 100644
--- a/source4/setup/wscript_build
+++ b/source4/setup/wscript_build
@@ -7,6 +7,6 @@ bld.INSTALL_FILES('${SETUPDIR}', 'dns_update_list')
bld.INSTALL_FILES('${SETUPDIR}', 'spn_update_list')

for p in '''schema-map-* DB_CONFIG *.inf *.ldif *.reg *.zone *.conf *.php *.txt
- named.conf named.conf.update named.conf.dlz'''.split():
+ named.conf.update named.conf.dlz'''.split():
bld.INSTALL_WILDCARD('${SETUPDIR}', p)
--
Samba Shared Repository
Volker Lendecke
2015-11-16 16:56:02 UTC
Permalink
The branch, master has been updated
via b486398 smbd: Move a message_send_all to the cleanupd
via de6fe2a smbd: Move cleanupd revalidate to a separate fn
via bbeabd3 smbd: Move brl_validate to the cleanupd
via 14fc901 smbd: Move serverid_deregister() to the cleanupd
via 99833c9 smbd: Move messaging_cleanup() to the cleanupd
via 1dddba5 smbd: Move smbprofile_cleanup() to the cleanupd
via b4b4fd0 smbprofile: Add dst pid to smbprofile_cleanup
via e3e0a29 smbd: Implement a cleanup daemon
from db99742 build:wafsamba: Waf 1.8 compatible declaration of 'mandatory' configuration tests

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


- Log -----------------------------------------------------------------
commit b486398d06b1c5d82a1e9728d757c79ccc401875
Author: Volker Lendecke <***@samba.org>
Date: Mon Nov 16 08:11:20 2015 +0100

smbd: Move a message_send_all to the cleanupd

message_send_all traverses serverid.tdb, which can be expensive

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

Autobuild-User(master): Volker Lendecke <***@samba.org>
Autobuild-Date(master): Mon Nov 16 17:55:36 CET 2015 on sn-devel-104

commit de6fe2a1dd6ab03b1c369b61da17fded72305b2d
Author: Volker Lendecke <***@samba.org>
Date: Mon Nov 16 08:08:46 2015 +0100

smbd: Move cleanupd revalidate to a separate fn

Simple preparation for the next patch...

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit bbeabd346de1e339b1cafbad03d892ac48b3cb25
Author: Volker Lendecke <***@samba.org>
Date: Sat Nov 7 20:18:52 2015 +0100

smbd: Move brl_validate to the cleanupd

This walks brlock.tdb, which can be time-consuming.

This adds a new includes.h include. It's too much of a pain for me now to
make locking/proto.h clean to include on its own.

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit 14fc9018aa8abfd3255f0f3a1b2b5541e8a9dc61
Author: Volker Lendecke <***@samba.org>
Date: Fri Nov 6 17:01:02 2015 +0100

smbd: Move serverid_deregister() to the cleanupd

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit 99833c94288a99d9f106252227842fe991763d56
Author: Volker Lendecke <***@samba.org>
Date: Fri Nov 6 15:32:46 2015 +0100

smbd: Move messaging_cleanup() to the cleanupd

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit 1dddba5f173c5db288957ceb448b19c56163b240
Author: Volker Lendecke <***@samba.org>
Date: Fri Nov 6 15:21:59 2015 +0100

smbd: Move smbprofile_cleanup() to the cleanupd

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit b4b4fd0ba0f838cc30d7c331dae33335015096f7
Author: Volker Lendecke <***@samba.org>
Date: Fri Nov 6 14:55:35 2015 +0100

smbprofile: Add dst pid to smbprofile_cleanup

The consolidation will soon be done by a separate process. We need to
avoid the getpid() call in smbprofile_cleanup().

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit e3e0a295c3fc25391260a8bb7d7d29137f7129fa
Author: Volker Lendecke <***@samba.org>
Date: Mon Nov 2 12:47:13 2015 +0100

smbd: Implement a cleanup daemon

We do way too much stuff in the parent smbd in remove_child_pid(). In
particular accessing ctdbd is not a good idea when ctdbd is stuck in something.
We've had a case where smbd exited itself with "ctdb timeout" being set to 60
seconds. ctdb was just stuck doing recoveries, and the parent smbd was sitting
in serverid_exists trying to retrieve a record for a child that had exited. Not
good.

This daemon sits there as parent->cleanupd and receives MSG_SMB_NOTIFY_CLEANUP
messages that hold the serverid and exit status of a former child. The next
commits will step by step empty remove_child_pid in the parent and move the
tasks to the helper.

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

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

Summary of changes:
source3/include/smbprofile.h | 4 +-
source3/profile/profile.c | 4 +-
source3/smbd/server.c | 161 +++++++++++++++++----
source3/smbd/smbd_cleanupd.c | 156 ++++++++++++++++++++
lib/util/iov_buf.h => source3/smbd/smbd_cleanupd.h | 21 +--
source3/wscript_build | 2 +-
6 files changed, 308 insertions(+), 40 deletions(-)
create mode 100644 source3/smbd/smbd_cleanupd.c
copy lib/util/iov_buf.h => source3/smbd/smbd_cleanupd.h (68%)


Changeset truncated at 500 lines:

diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h
index 76d9d2b..c771fd4 100644
--- a/source3/include/smbprofile.h
+++ b/source3/include/smbprofile.h
@@ -533,7 +533,7 @@ static inline bool smbprofile_dump_pending(void)

void smbprofile_dump(void);

-void smbprofile_cleanup(pid_t pid);
+void smbprofile_cleanup(pid_t pid, pid_t dst);
void smbprofile_stats_accumulate(struct profile_stats *acc,
const struct profile_stats *add);
void smbprofile_collect(struct profile_stats *stats);
@@ -610,7 +610,7 @@ static inline void smbprofile_dump(void)
return;
}

-static inline void smbprofile_cleanup(pid_t pid)
+static inline void smbprofile_cleanup(pid_t pid, pid_t dst)
{
return;
}
diff --git a/source3/profile/profile.c b/source3/profile/profile.c
index 00cb3e5..1464a42 100644
--- a/source3/profile/profile.c
+++ b/source3/profile/profile.c
@@ -312,7 +312,7 @@ void smbprofile_dump(void)
return;
}

-void smbprofile_cleanup(pid_t pid)
+void smbprofile_cleanup(pid_t pid, pid_t dst)
{
TDB_DATA key = { .dptr = (uint8_t *)&pid, .dsize = sizeof(pid) };
struct profile_stats s = {};
@@ -336,7 +336,7 @@ void smbprofile_cleanup(pid_t pid)
tdb_delete(smbprofile_state.internal.db->tdb, key);
tdb_chainunlock(smbprofile_state.internal.db->tdb, key);

- pid = getpid();
+ pid = dst;
ret = tdb_chainlock(smbprofile_state.internal.db->tdb, key);
if (ret != 0) {
return;
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 72c4642..1dd4f89 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -49,6 +49,8 @@
#include "scavenger.h"
#include "locking/leases_db.h"
#include "smbd/notifyd/notifyd.h"
+#include "smbd/smbd_cleanupd.h"
+#include "lib/util/sys_rw.h"

#ifdef CLUSTER_SUPPORT
#include "ctdb_protocol.h"
@@ -70,6 +72,8 @@ struct smbd_parent_context {
struct smbd_child_pid *children;
size_t num_children;

+ struct server_id cleanupd;
+
struct tevent_timer *cleanup_te;
};

@@ -279,8 +283,10 @@ static int smbd_parent_ctdb_reconfigured(
* Someone from the family died, validate our locks
*/

- messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
- MSG_SMB_BRL_VALIDATE, NULL, 0);
+ if (am_parent) {
+ messaging_send_buf(msg_ctx, am_parent->cleanupd,
+ MSG_SMB_BRL_VALIDATE, NULL, 0);
+ }

return 0;
}
@@ -405,6 +411,118 @@ static bool smbd_notifyd_init(struct messaging_context *msg, bool interactive)
return tevent_req_poll(req, ev);
}

+static void cleanupd_stopped(struct tevent_req *req);
+
+static bool cleanupd_init(struct messaging_context *msg, bool interactive,
+ struct server_id *ppid)
+{
+ struct tevent_context *ev = messaging_tevent_context(msg);
+ struct server_id parent_id = messaging_server_id(msg);
+ struct tevent_req *req;
+ pid_t pid;
+ NTSTATUS status;
+ ssize_t rwret;
+ int ret;
+ bool ok;
+ char c;
+ int up_pipe[2];
+
+ if (interactive) {
+ req = smbd_cleanupd_send(msg, ev, msg, parent_id.pid);
+ *ppid = messaging_server_id(msg);
+ return (req != NULL);
+ }
+
+ ret = pipe(up_pipe);
+ if (ret == -1) {
+ DBG_WARNING("pipe failed: %s\n", strerror(errno));
+ return false;
+ }
+
+ pid = fork();
+ if (pid == -1) {
+ DBG_WARNING("fork failed: %s\n", strerror(errno));
+ close(up_pipe[0]);
+ close(up_pipe[1]);
+ return false;
+ }
+
+ if (pid != 0) {
+
+ close(up_pipe[1]);
+ rwret = sys_read(up_pipe[0], &c, 1);
+ close(up_pipe[0]);
+
+ if (rwret == -1) {
+ DBG_WARNING("sys_read failed: %s\n", strerror(errno));
+ return false;
+ }
+ if (rwret == 0) {
+ DBG_WARNING("cleanupd could not start\n");
+ return false;
+ }
+ if (c != 0) {
+ DBG_WARNING("cleanupd returned %d\n", (int)c);
+ return false;
+ }
+
+ DBG_DEBUG("Started cleanupd pid=%d\n", (int)pid);
+
+ *ppid = pid_to_procid(pid);
+ return true;
+ }
+
+ close(up_pipe[0]);
+
+ status = reinit_after_fork(msg, ev, true, "cleanupd");
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_WARNING("reinit_after_fork failed: %s\n",
+ nt_errstr(status));
+ c = 1;
+ sys_write(up_pipe[1], &c, 1);
+
+ exit(1);
+ }
+
+ req = smbd_cleanupd_send(msg, ev, msg, parent_id.pid);
+ if (req == NULL) {
+ DBG_WARNING("smbd_cleanupd_send failed\n");
+ c = 2;
+ sys_write(up_pipe[1], &c, 1);
+
+ exit(1);
+ }
+
+ tevent_req_set_callback(req, cleanupd_stopped, msg);
+
+ c = 0;
+ rwret = sys_write(up_pipe[1], &c, 1);
+ close(up_pipe[1]);
+
+ if (rwret == -1) {
+ DBG_WARNING("sys_write failed: %s\n", strerror(errno));
+ exit(1);
+ }
+ if (rwret != 1) {
+ DBG_WARNING("sys_write could not write result\n");
+ exit(1);
+ }
+
+ ok = tevent_req_poll(req, ev);
+ if (!ok) {
+ DBG_WARNING("tevent_req_poll returned %s\n", strerror(errno));
+ }
+ exit(0);
+}
+
+static void cleanupd_stopped(struct tevent_req *req)
+{
+ NTSTATUS status;
+
+ status = smbd_cleanupd_recv(req);
+ DBG_WARNING("cleanupd stopped: %s\n", nt_errstr(status));
+}
+
/*
at most every smbd:cleanuptime seconds (default 20), we scan the BRL
and locking database for entries to cleanup. As a side effect this
@@ -427,11 +545,8 @@ static void cleanup_timeout_fn(struct tevent_context *event_ctx,

parent->cleanup_te = NULL;

- DEBUG(1,("Cleaning up brl and lock database after unclean shutdown\n"));
- message_send_all(parent->msg_ctx, MSG_SMB_UNLOCK, NULL, 0, NULL);
- messaging_send_buf(parent->msg_ctx,
- messaging_server_id(parent->msg_ctx),
- MSG_SMB_BRL_VALIDATE, NULL, 0);
+ messaging_send_buf(parent->msg_ctx, parent->cleanupd,
+ MSG_SMB_UNLOCK, NULL, 0);
}

static void remove_child_pid(struct smbd_parent_context *parent,
@@ -439,19 +554,18 @@ static void remove_child_pid(struct smbd_parent_context *parent,
bool unclean_shutdown)
{
struct smbd_child_pid *child;
- struct server_id child_id;
- int ret;
-
- child_id = pid_to_procid(pid);
-
- ret = messaging_cleanup(parent->msg_ctx, pid);
+ struct iovec iov[2];
+ NTSTATUS status;

- if ((ret != 0) && (ret != ENOENT)) {
- DEBUG(10, ("%s: messaging_cleanup returned %s\n",
- __func__, strerror(ret)));
- }
+ iov[0] = (struct iovec) { .iov_base = (uint8_t *)&pid,
+ .iov_len = sizeof(pid) };
+ iov[1] = (struct iovec) { .iov_base = (uint8_t *)&unclean_shutdown,
+ .iov_len = sizeof(bool) };

- smbprofile_cleanup(pid);
+ status = messaging_send_iov(parent->msg_ctx, parent->cleanupd,
+ MSG_SMB_NOTIFY_CLEANUP,
+ iov, ARRAY_SIZE(iov), NULL, 0);
+ DEBUG(10, ("messaging_send_iov returned %s\n", nt_errstr(status)));

for (child = parent->children; child != NULL; child = child->next) {
if (child->pid == pid) {
@@ -487,11 +601,6 @@ static void remove_child_pid(struct smbd_parent_context *parent,
DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n"));
}
}
-
- if (!serverid_deregister(child_id)) {
- DEBUG(1, ("Could not remove pid %d from serverid.tdb\n",
- (int)pid));
- }
}

/****************************************************************************
@@ -893,8 +1002,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
messaging_register(msg_ctx, NULL, MSG_SMB_STAT_CACHE_DELETE,
smb_stat_cache_delete);
messaging_register(msg_ctx, NULL, MSG_DEBUG, smbd_msg_debug);
- messaging_register(msg_ctx, NULL, MSG_SMB_BRL_VALIDATE,
- brl_revalidate);
messaging_register(msg_ctx, NULL, MSG_SMB_FORCE_TDIS,
smb_parent_send_to_children);
messaging_register(msg_ctx, NULL, MSG_SMB_KILL_CLIENT_IP,
@@ -1476,6 +1583,10 @@ extern void build_options(bool screen);
exit_daemon("Samba cannot init notification", EACCES);
}

+ if (!cleanupd_init(msg_ctx, interactive, &parent->cleanupd)) {
+ exit_daemon("Samba cannot init the cleanupd", EACCES);
+ }
+
if (!messaging_parent_dgm_cleanup_init(msg_ctx)) {
exit(1);
}
diff --git a/source3/smbd/smbd_cleanupd.c b/source3/smbd/smbd_cleanupd.c
new file mode 100644
index 0000000..c940ef1
--- /dev/null
+++ b/source3/smbd/smbd_cleanupd.c
@@ -0,0 +1,156 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * Copyright (C) Volker Lendecke 2015
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "smbd_cleanupd.h"
+#include "lib/util_procid.h"
+#include "lib/util/tevent_ntstatus.h"
+#include "lib/util/debug.h"
+#include "smbprofile.h"
+#include "serverid.h"
+#include "locking/proto.h"
+
+struct smbd_cleanupd_state {
+ pid_t parent_pid;
+};
+
+static void smbd_cleanupd_shutdown(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data);
+static void smbd_cleanupd_process_exited(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data);
+static void smbd_cleanupd_unlock(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data);
+
+struct tevent_req *smbd_cleanupd_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct messaging_context *msg,
+ pid_t parent_pid)
+{
+ struct tevent_req *req;
+ struct smbd_cleanupd_state *state;
+ NTSTATUS status;
+
+ req = tevent_req_create(mem_ctx, &state, struct smbd_cleanupd_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->parent_pid = parent_pid;
+
+ status = messaging_register(msg, req, MSG_SHUTDOWN,
+ smbd_cleanupd_shutdown);
+ if (tevent_req_nterror(req, status)) {
+ return tevent_req_post(req, ev);
+ }
+
+ status = messaging_register(msg, req, MSG_SMB_NOTIFY_CLEANUP,
+ smbd_cleanupd_process_exited);
+ if (tevent_req_nterror(req, status)) {
+ return tevent_req_post(req, ev);
+ }
+
+ status = messaging_register(msg, NULL, MSG_SMB_UNLOCK,
+ smbd_cleanupd_unlock);
+ if (tevent_req_nterror(req, status)) {
+ return tevent_req_post(req, ev);
+ }
+
+ return req;
+}
+
+static void smbd_cleanupd_shutdown(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data)
+{
+ struct tevent_req *req = talloc_get_type_abort(
+ private_data, struct tevent_req);
+ tevent_req_done(req);
+}
+
+static void smbd_cleanupd_unlock(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data)
+{
+ DBG_WARNING("Cleaning up brl and lock database after unclean "
+ "shutdown\n");
+
+ message_send_all(msg, MSG_SMB_UNLOCK, NULL, 0, NULL);
+
+ brl_revalidate(msg, private_data, msg_type, server_id, data);
+}
+
+static void smbd_cleanupd_process_exited(struct messaging_context *msg,
+ void *private_data, uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data)
+{
+ struct tevent_req *req = talloc_get_type_abort(
+ private_data, struct tevent_req);
+ struct smbd_cleanupd_state *state = tevent_req_data(
+ req, struct smbd_cleanupd_state);
+ pid_t pid;
+ struct server_id child_id;
+ bool unclean_shutdown;
+ int ret;
+
+ if (data->length != (sizeof(pid) + sizeof(unclean_shutdown))) {
+ DBG_WARNING("Got invalid length: %zu\n", data->length);
+ return;
+ }
+
+ memcpy(&pid, data->data, sizeof(pid));
+ memcpy(&unclean_shutdown, data->data + sizeof(pid),
+ sizeof(unclean_shutdown));
+
+ DBG_DEBUG("%d exited %sclean\n", (int)pid,
+ unclean_shutdown ? "un" : "");
+
+ /*
+ * Get child_id before messaging_cleanup which wipes the
+ * unique_id. Not that it really matters here for functionality (the
+ * child should have properly cleaned up :-)) though, but it looks
+ * nicer.
+ */
+ child_id = pid_to_procid(pid);
+
+ smbprofile_cleanup(pid, state->parent_pid);
+
+ ret = messaging_cleanup(msg, pid);
+
+ if ((ret != 0) && (ret != ENOENT)) {
+ DBG_DEBUG("messaging_cleanup returned %s\n", strerror(ret));
+ }
+
+ if (!serverid_deregister(child_id)) {
+ DEBUG(1, ("Could not remove pid %d from serverid.tdb\n",
+ (int)pid));
+ }
+}
+
+NTSTATUS smbd_cleanupd_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
diff --git a/lib/util/iov_buf.h b/source3/smbd/smbd_cleanupd.h
similarity index 68%
copy from lib/util/iov_buf.h
copy to source3/smbd/smbd_cleanupd.h
index 8f0ca26..6e5d87f 100644
--- a/lib/util/iov_buf.h
+++ b/source3/smbd/smbd_cleanupd.h
@@ -1,6 +1,6 @@
/*
* Unix SMB/CIFS implementation.
- * Samba system utilities
+ *
* Copyright (C) Volker Lendecke 2014
*
* This program is free software; you can redistribute it and/or modify
@@ -17,16 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

-#ifndef __LIB_IOV_BUF_H__
-#define __LIB_IOV_BUF_H__
+#ifndef __SMBD_CLEANUPD_H__
+#define __SMBD_CLEANUPD_H__

-#include <unistd.h>
-#include <stdint.h>
-#include <stdbool.h>
+#include "replace.h"
+#include <tevent.h>
+#include "messages.h"

-ssize_t iov_buflen(const struct iovec *iov, int iovlen);
-ssize_t iov_buf(const struct iovec *iov, int iovcnt,
- uint8_t *buf, size_t buflen);
-bool iov_advance(struct iovec **iov, int *iovcnt, size_t n);
+struct tevent_req *smbd_cleanupd_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct messaging_context *msg,
+ pid_t parent_pid);
+NTSTATUS smbd_cleanupd_recv(struct tevent_req *req);

#endif
diff --git a/source3/wscript_build b/source3/wscript_build
index 4c6390e..b5b5ea0 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -858,7 +858,7 @@ bld.SAMBA3_SUBSYSTEM('LIBLSA',
########################## BINARIES #################################

bld.SAMBA3_BINARY('smbd/smbd',
- source='smbd/server.c',
+ source='smbd/server.c smbd/smbd_cleanupd.c',
deps='smbd_base EPMD LSASD FSSD MDSSD',
install_path='${SBINDIR}')
--
Samba Shared Repository
Andreas Schneider
2015-11-17 18:53:02 UTC
Permalink
The branch, master has been updated
via 5943f92 s4-backupkey: Don't use deprecated data structures
via f4da068 s4-torture: Rename issuer unique id in backupkey test
via 3de5943 s3-vfs_snapper: Fix a possible use without init warning
via f7e2399 s4-param: Make sure newname is not used uninitialized
from b486398 smbd: Move a message_send_all to the cleanupd

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


- Log -----------------------------------------------------------------
commit 5943f92d2a58473f0526bd564dead78e1528b5be
Author: Andreas Schneider <***@samba.org>
Date: Wed Nov 11 11:49:12 2015 +0100

s4-backupkey: Don't use deprecated data structures

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Michael Adam <***@samba.org>

Autobuild-User(master): Andreas Schneider <***@cryptomilk.org>
Autobuild-Date(master): Tue Nov 17 19:52:33 CET 2015 on sn-devel-104

commit f4da06803b07de76ed26355b17f81dbdfd1dc926
Author: Andreas Schneider <***@samba.org>
Date: Thu Nov 12 11:35:39 2015 +0100

s4-torture: Rename issuer unique id in backupkey test

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Michael Adam <***@samba.org>

commit 3de59437c3195f61281fb765b3c944258a259d1d
Author: Andreas Schneider <***@samba.org>
Date: Fri Nov 13 14:14:10 2015 +0100

s3-vfs_snapper: Fix a possible use without init warning

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Michael Adam <***@samba.org>

commit f7e2399926a0c6531acaa8f4567b6fa67f69c6de
Author: Andreas Schneider <***@samba.org>
Date: Fri Nov 13 13:40:25 2015 +0100

s4-param: Make sure newname is not used uninitialized

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Michael Adam <***@samba.org>

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

Summary of changes:
source3/modules/vfs_snapper.c | 2 +-
source4/param/share_ldb.c | 2 +-
source4/rpc_server/backupkey/dcesrv_backupkey.c | 2 +-
source4/torture/rpc/backupkey.c | 12 ++++++------
4 files changed, 9 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c
index a25ae95..ef8951d 100644
--- a/source3/modules/vfs_snapper.c
+++ b/source3/modules/vfs_snapper.c
@@ -1404,7 +1404,7 @@ static NTSTATUS snapper_create_snap_call(TALLOC_CTX *mem_ctx,
NTSTATUS status;
DBusMessage *req_msg;
DBusMessage *rsp_msg;
- uint32_t snap_id;
+ uint32_t snap_id = 0;
char *snap_path;

status = snapper_create_snap_pack(mem_ctx,
diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c
index 0257cd1..cf8c5bb 100644
--- a/source4/param/share_ldb.c
+++ b/source4/param/share_ldb.c
@@ -445,7 +445,7 @@ static NTSTATUS sldb_set(struct share_context *ctx, const char *name, struct sha
TALLOC_CTX *tmp_ctx;
NTSTATUS ret;
bool do_rename = false;
- char *newname;
+ char *newname = NULL;
int err, i;

if (!name) {
diff --git a/source4/rpc_server/backupkey/dcesrv_backupkey.c b/source4/rpc_server/backupkey/dcesrv_backupkey.c
index ccd95d2..8636e0f 100644
--- a/source4/rpc_server/backupkey/dcesrv_backupkey.c
+++ b/source4/rpc_server/backupkey/dcesrv_backupkey.c
@@ -816,7 +816,7 @@ static WERROR create_heimdal_rsa_key(TALLOC_CTX *ctx, hx509_context *hctx,
size_t len;
int bits = 2048;
int RSA_returned_bits;
- gnutls_x509_privkey gtls_key;
+ gnutls_x509_privkey_t gtls_key;
WERROR werr;

*rsa = NULL;
diff --git a/source4/torture/rpc/backupkey.c b/source4/torture/rpc/backupkey.c
index b86fccd..557aaae 100644
--- a/source4/torture/rpc/backupkey.c
+++ b/source4/torture/rpc/backupkey.c
@@ -415,7 +415,7 @@ static struct GUID *get_cert_guid(struct torture_context *tctx,
{
hx509_context hctx;
hx509_cert cert;
- heim_bit_string subjectuniqid;
+ heim_bit_string issuer_unique_id;
DATA_BLOB data;
int hret;
uint32_t size;
@@ -430,7 +430,7 @@ static struct GUID *get_cert_guid(struct torture_context *tctx,
hx509_context_free(&hctx);
return NULL;
}
- hret = hx509_cert_get_issuer_unique_id(hctx, cert, &subjectuniqid);
+ hret = hx509_cert_get_issuer_unique_id(hctx, cert, &issuer_unique_id);
if (hret) {
torture_comment(tctx, "error while getting the issuer_uniq_id\n");
hx509_cert_free(cert);
@@ -438,17 +438,17 @@ static struct GUID *get_cert_guid(struct torture_context *tctx,
return NULL;
}

- /* The subjectuniqid is a bit string,
+ /* The issuer_unique_id is a bit string,
* which means that the real size has to be divided by 8
* to have the number of bytes
*/
hx509_cert_free(cert);
hx509_context_free(&hctx);
- size = subjectuniqid.length / 8;
- data = data_blob_const(subjectuniqid.data, size);
+ size = issuer_unique_id.length / 8;
+ data = data_blob_const(issuer_unique_id.data, size);

status = GUID_from_data_blob(&data, guid);
- der_free_bit_string(&subjectuniqid);
+ der_free_bit_string(&issuer_unique_id);
if (!NT_STATUS_IS_OK(status)) {
return NULL;
}
--
Samba Shared Repository
Jeremy Allison
2015-11-17 21:59:04 UTC
Permalink
The branch, master has been updated
via 8f9bf74 smbd: Simplify check_access()
via c2d5fdb smbd: Use check_access_fsp where appropriate
via c056daf smbd: Factor out check_access_fsp() from check_access()
via c8485dd smbd: Refactor check_access()
via b8467dc smbd: Early return from dos_mode_debug_print
via b367dbc smbd: Add hex value to dos_mode_debug_print
via 0f5c98f smbd: Use dos_mode_debug_print in get_ea_dos_attribute
via 313986b smbd: Use dos_mode_debug_print in dos_mode_from_sbuf
via 053cf16 smbd: Use dos_mode_debug_print in dos_mode_msdfs
via 89deffb smbd: Streamline dos_mode_debug_print
from 5943f92 s4-backupkey: Don't use deprecated data structures

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


- Log -----------------------------------------------------------------
commit 8f9bf74fbfc15cae10d4cf1249280f82e7410fab
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 15:19:31 2015 +0100

smbd: Simplify check_access()

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

Autobuild-User(master): Jeremy Allison <***@samba.org>
Autobuild-Date(master): Tue Nov 17 22:58:10 CET 2015 on sn-devel-104

commit c2d5fdb629ecdeaaa284fdbe69e9d061b7f835a2
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 15:13:41 2015 +0100

smbd: Use check_access_fsp where appropriate

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit c056daf7abc63569fad90b47e02e38acfebfe985
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 15:10:42 2015 +0100

smbd: Factor out check_access_fsp() from check_access()

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit c8485ddbac397f50c68f6d76468d5c7679da9082
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 14:57:50 2015 +0100

smbd: Refactor check_access()

This is a micro-patch to make the next ones just obvious

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit b8467dc4923a9efb905fc1e8db3c3029766cdc59
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 13:49:30 2015 +0100

smbd: Early return from dos_mode_debug_print

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit b367dbc7bda1d0c33b2b8aba9a6e07c01c0a84d8
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 13:44:30 2015 +0100

smbd: Add hex value to dos_mode_debug_print

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit 0f5c98fac90c6aca0d082687b12657e4acf58e87
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 13:43:10 2015 +0100

smbd: Use dos_mode_debug_print in get_ea_dos_attribute

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit 313986bb7521da354bd3beb32bfc289e37c06550
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 13:41:29 2015 +0100

smbd: Use dos_mode_debug_print in dos_mode_from_sbuf

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit 053cf16a3bd7c9c167a2cff9b56576fb94a50cc6
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 13:37:14 2015 +0100

smbd: Use dos_mode_debug_print in dos_mode_msdfs

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit 89deffb65a251e612e615074525009957123172d
Author: Volker Lendecke <***@samba.org>
Date: Tue Nov 17 13:21:13 2015 +0100

smbd: Streamline dos_mode_debug_print

One line per flag is a bit overkill

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

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

Summary of changes:
source3/smbd/dosmode.c | 61 ++++++++++++++-------------------------
source3/smbd/proto.h | 2 ++
source3/smbd/smb2_ioctl_filesys.c | 7 ++---
source3/smbd/trans2.c | 27 ++++++++++-------
4 files changed, 43 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 72acd4e..0f3eef0 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -31,36 +31,43 @@ static NTSTATUS get_file_handle_for_metadata(connection_struct *conn,
files_struct **ret_fsp,
bool *need_close);

-static void dos_mode_debug_print(uint32_t mode)
+static void dos_mode_debug_print(const char *func, uint32_t mode)
{
- DEBUG(8,("dos_mode returning "));
+ fstring modestr;
+
+ if (DEBUGLEVEL < DBGLVL_INFO) {
+ return;
+ }
+
+ modestr[0] = '\0';

if (mode & FILE_ATTRIBUTE_HIDDEN) {
- DEBUG(8, ("h"));
+ fstrcat(modestr, "h");
}
if (mode & FILE_ATTRIBUTE_READONLY) {
- DEBUG(8, ("r"));
+ fstrcat(modestr, "r");
}
if (mode & FILE_ATTRIBUTE_SYSTEM) {
- DEBUG(8, ("s"));
+ fstrcat(modestr, "s");
}
if (mode & FILE_ATTRIBUTE_DIRECTORY) {
- DEBUG(8, ("d"));
+ fstrcat(modestr, "d");
}
if (mode & FILE_ATTRIBUTE_ARCHIVE) {
- DEBUG(8, ("a"));
+ fstrcat(modestr, "a");
}
if (mode & FILE_ATTRIBUTE_SPARSE) {
- DEBUG(8, ("[sparse]"));
+ fstrcat(modestr, "[sparse]");
}
if (mode & FILE_ATTRIBUTE_OFFLINE) {
- DEBUG(8, ("[offline]"));
+ fstrcat(modestr, "[offline]");
}
if (mode & FILE_ATTRIBUTE_COMPRESSED) {
- DEBUG(8, ("[compressed]"));
+ fstrcat(modestr, "[compressed]");
}

- DEBUG(8,("\n"));
+ DBG_INFO("%s returning (0x%x): \"%s\"\n", func, (unsigned)mode,
+ modestr);
}

static uint32_t filter_mode_by_protocol(uint32_t mode)
@@ -240,15 +247,8 @@ static uint32_t dos_mode_from_sbuf(connection_struct *conn,

result |= set_link_read_only_flag(&smb_fname->st);

- DEBUG(8,("dos_mode_from_sbuf returning "));
-
- if (result & FILE_ATTRIBUTE_HIDDEN) DEBUG(8, ("h"));
- if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
- if (result & FILE_ATTRIBUTE_SYSTEM) DEBUG(8, ("s"));
- if (result & FILE_ATTRIBUTE_DIRECTORY ) DEBUG(8, ("d"));
- if (result & FILE_ATTRIBUTE_ARCHIVE ) DEBUG(8, ("a"));
+ dos_mode_debug_print(__func__, result);

- DEBUG(8,("\n"));
return result;
}

@@ -367,15 +367,7 @@ static bool get_ea_dos_attribute(connection_struct *conn,
/* FILE_ATTRIBUTE_SPARSE is valid on get but not on set. */
*pattr = (uint32_t)(dosattr & (SAMBA_ATTRIBUTES_MASK|FILE_ATTRIBUTE_SPARSE));

- DEBUG(8,("get_ea_dos_attribute returning (0x%x)", dosattr));
-
- if (dosattr & FILE_ATTRIBUTE_HIDDEN) DEBUG(8, ("h"));
- if (dosattr & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
- if (dosattr & FILE_ATTRIBUTE_SYSTEM) DEBUG(8, ("s"));
- if (dosattr & FILE_ATTRIBUTE_DIRECTORY ) DEBUG(8, ("d"));
- if (dosattr & FILE_ATTRIBUTE_ARCHIVE ) DEBUG(8, ("a"));
-
- DEBUG(8,("\n"));
+ dos_mode_debug_print(__func__, *pattr);

return True;
}
@@ -539,16 +531,7 @@ uint32_t dos_mode_msdfs(connection_struct *conn,
*/
result |= FILE_ATTRIBUTE_REPARSE_POINT;

- DEBUG(8,("dos_mode_msdfs returning "));
-
- if (result & FILE_ATTRIBUTE_HIDDEN) DEBUG(8, ("h"));
- if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
- if (result & FILE_ATTRIBUTE_SYSTEM) DEBUG(8, ("s"));
- if (result & FILE_ATTRIBUTE_DIRECTORY ) DEBUG(8, ("d"));
- if (result & FILE_ATTRIBUTE_ARCHIVE ) DEBUG(8, ("a"));
- if (result & FILE_ATTRIBUTE_SPARSE ) DEBUG(8, ("[sparse]"));
-
- DEBUG(8,("\n"));
+ dos_mode_debug_print(__func__, result);

return(result);
}
@@ -653,7 +636,7 @@ uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)

result = filter_mode_by_protocol(result);

- dos_mode_debug_print(result);
+ dos_mode_debug_print(__func__, result);

return result;
}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 7926dd6..be51182 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -1079,6 +1079,8 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf);

/* The following definitions come from smbd/trans2.c */

+NTSTATUS check_access_fsp(const struct files_struct *fsp,
+ uint32_t access_mask);
NTSTATUS check_access(connection_struct *conn,
files_struct *fsp,
const struct smb_filename *smb_fname,
diff --git a/source3/smbd/smb2_ioctl_filesys.c b/source3/smbd/smb2_ioctl_filesys.c
index 187deaf..6e4a785 100644
--- a/source3/smbd/smb2_ioctl_filesys.c
+++ b/source3/smbd/smb2_ioctl_filesys.c
@@ -94,8 +94,7 @@ static NTSTATUS fsctl_set_cmprn(TALLOC_CTX *mem_ctx,
}

/* WRITE_DATA permission is required, WRITE_ATTRIBUTES is not */
- status = check_access(fsp->conn, fsp, NULL,
- FILE_WRITE_DATA);
+ status = check_access_fsp(fsp, FILE_WRITE_DATA);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -141,7 +140,7 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
}

/* WRITE_DATA permission is required */
- status = check_access(fsp->conn, fsp, NULL, FILE_WRITE_DATA);
+ status = check_access_fsp(fsp, FILE_WRITE_DATA);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -333,7 +332,7 @@ static NTSTATUS fsctl_qar(TALLOC_CTX *mem_ctx,
}

/* READ_DATA permission is required */
- status = check_access(fsp->conn, fsp, NULL, FILE_READ_DATA);
+ status = check_access_fsp(fsp, FILE_READ_DATA);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index e2e4c80..11c97e8 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -54,6 +54,15 @@ static char *store_file_unix_basic_info2(connection_struct *conn,
files_struct *fsp,
const SMB_STRUCT_STAT *psbuf);

+NTSTATUS check_access_fsp(const struct files_struct *fsp,
+ uint32_t access_mask)
+{
+ if (!(fsp->access_mask & access_mask)) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+ return NT_STATUS_OK;
+}
+
/********************************************************************
The canonical "check access" based on object handle or path function.
********************************************************************/
@@ -63,20 +72,16 @@ NTSTATUS check_access(connection_struct *conn,
const struct smb_filename *smb_fname,
uint32_t access_mask)
{
+ NTSTATUS status;
+
if (fsp) {
- if (!(fsp->access_mask & access_mask)) {
- return NT_STATUS_ACCESS_DENIED;
- }
+ status = check_access_fsp(fsp, access_mask);
} else {
- NTSTATUS status = smbd_check_access_rights(conn,
- smb_fname,
- false,
- access_mask);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
+ status = smbd_check_access_rights(conn, smb_fname,
+ false, access_mask);
}
- return NT_STATUS_OK;
+
+ return status;
}

/********************************************************************
--
Samba Shared Repository
Jeremy Allison
2015-11-18 03:05:06 UTC
Permalink
The branch, master has been updated
via fd05d61 libcli/smb: Use helper function for finding session
from 8f9bf74 smbd: Simplify check_access()

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


- Log -----------------------------------------------------------------
commit fd05d617a8860e6ed2db90c0396fdca9c15ef4a3
Author: Christof Schmitt <***@samba.org>
Date: Wed Oct 21 12:04:47 2015 -0700

libcli/smb: Use helper function for finding session

This removes some duplicated code.

Signed-off-by: Christof Schmitt <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

Autobuild-User(master): Jeremy Allison <***@samba.org>
Autobuild-Date(master): Wed Nov 18 04:04:17 CET 2015 on sn-devel-104

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

Summary of changes:
libcli/smb/smbXcli_base.c | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 6fe4816..1f1b6cd 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -3295,6 +3295,21 @@ static void smb2cli_req_writev_done(struct tevent_req *subreq)
}
}

+static struct smbXcli_session* smbXcli_session_by_uid(struct smbXcli_conn *conn,
+ uint64_t uid)
+{
+ struct smbXcli_session *s = conn->sessions;
+
+ for (; s; s = s->next) {
+ if (s->smb2->session_id != uid) {
+ continue;
+ }
+ break;
+ }
+
+ return s;
+}
+
static NTSTATUS smb2cli_inbuf_parse_compound(struct smbXcli_conn *conn,
uint8_t *buf,
size_t buflen,
@@ -3362,14 +3377,7 @@ static NTSTATUS smb2cli_inbuf_parse_compound(struct smbXcli_conn *conn,
goto inval;
}

- s = conn->sessions;
- for (; s; s = s->next) {
- if (s->smb2->session_id != uid) {
- continue;
- }
- break;
- }
-
+ s = smbXcli_session_by_uid(conn, uid);
if (s == NULL) {
DEBUG(10, ("unknown session_id %llu\n",
(unsigned long long)uid));
@@ -3588,17 +3596,8 @@ static NTSTATUS smb2cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
uint64_t uid = BVAL(inhdr, SMB2_HDR_SESSION_ID);

if (session == NULL) {
- struct smbXcli_session *s;
-
- s = state->conn->sessions;
- for (; s; s = s->next) {
- if (s->smb2->session_id != uid) {
- continue;
- }
-
- session = s;
- break;
- }
+ session = smbXcli_session_by_uid(state->conn,
+ uid);
}

if (session == NULL) {
--
Samba Shared Repository
Amitay Isaacs
2015-11-18 06:13:04 UTC
Permalink
The branch, master has been updated
via 3968e33 ctdb: Remove unused ctdb_set_process_name
via 03b27bd ctdb: Use prctl_set_comment from lib/util
via 9ec0938 lib/util: Move util_process from util to util-core
from fd05d61 libcli/smb: Use helper function for finding session

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


- Log -----------------------------------------------------------------
commit 3968e33acf6695558da93b368fc45fe7ac0a4bb0
Author: Christof Schmitt <***@samba.org>
Date: Wed Sep 23 16:11:51 2015 -0700

ctdb: Remove unused ctdb_set_process_name

Signed-off-by: Christof Schmitt <***@samba.org>
Reviewed-by: Amitay Isaacs <***@gmail.com>

Autobuild-User(master): Amitay Isaacs <***@samba.org>
Autobuild-Date(master): Wed Nov 18 07:12:50 CET 2015 on sn-devel-104

commit 03b27bd13915b3ed4befe39216f62c15eb82dcf9
Author: Christof Schmitt <***@samba.org>
Date: Wed Sep 23 16:10:59 2015 -0700

ctdb: Use prctl_set_comment from lib/util

Signed-off-by: Christof Schmitt <***@samba.org>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 9ec09385902d70e4f3d54b14781b2de858f83c97
Author: Christof Schmitt <***@samba.org>
Date: Wed Sep 23 16:02:27 2015 -0700

lib/util: Move util_process from util to util-core

Make the common prctl_set_comment function available to both ctdb
builds.

Signed-off-by: Christof Schmitt <***@samba.org>
Reviewed-by: Amitay Isaacs <***@gmail.com>

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

Summary of changes:
ctdb/common/system.h | 1 -
ctdb/common/system_aix.c | 6 ------
ctdb/common/system_freebsd.c | 6 ------
ctdb/common/system_gnu.c | 6 ------
ctdb/common/system_kfreebsd.c | 6 ------
ctdb/common/system_linux.c | 12 ------------
ctdb/server/ctdb_call.c | 3 ++-
ctdb/server/ctdb_monitor.c | 3 ++-
ctdb/server/ctdb_recover.c | 3 ++-
ctdb/server/ctdb_recoverd.c | 3 ++-
ctdb/server/ctdb_takeover.c | 3 ++-
ctdb/server/ctdb_traverse.c | 3 ++-
ctdb/server/ctdb_update_record.c | 3 ++-
ctdb/server/ctdb_vacuum.c | 3 ++-
lib/util/wscript_build | 4 ++--
15 files changed, 18 insertions(+), 47 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/system.h b/ctdb/common/system.h
index 8df87cd..ba11d20 100644
--- a/ctdb/common/system.h
+++ b/ctdb/common/system.h
@@ -39,7 +39,6 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
uint32_t *ack_seq, uint32_t *seq);
bool ctdb_sys_check_iface_exists(const char *iface);
int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
-int ctdb_set_process_name(const char *name);

/* From system_util.c */

diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
index 4c13106..a380f1c 100644
--- a/ctdb/common/system_aix.c
+++ b/ctdb/common/system_aix.c
@@ -379,9 +379,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
}
return ret;
}
-
-int ctdb_set_process_name(const char *name)
-{
- /* FIXME AIX: set_process_name not implemented */
- return -ENOSYS;
-}
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
index 97ac06c..21a300b 100644
--- a/ctdb/common/system_freebsd.c
+++ b/ctdb/common/system_freebsd.c
@@ -375,9 +375,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
/* FIXME FreeBSD: get_peer_pid not implemented */
return 1;
}
-
-int ctdb_set_process_name(const char *name)
-{
- /* FIXME FreeBSD: set_process_name not implemented */
- return -ENOSYS;
-}
diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c
index 84c5dd6..aeed56c 100644
--- a/ctdb/common/system_gnu.c
+++ b/ctdb/common/system_gnu.c
@@ -368,9 +368,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
/* FIXME GNU/Hurd: get_peer_pid not implemented */
return 1;
}
-
-int ctdb_set_process_name(const char *name)
-{
- /* FIXME GNU/Hurd: set_process_name not implemented */
- return -ENOSYS;
-}
diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c
index bd01410..b241aa8 100644
--- a/ctdb/common/system_kfreebsd.c
+++ b/ctdb/common/system_kfreebsd.c
@@ -368,9 +368,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
/* FIXME kFreeBSD: get_peer_pid not implemented */
return 1;
}
-
-int ctdb_set_process_name(const char *name)
-{
- /* FIXME kFreeBSD: set_process_name not implemented */
- return -ENOSYS;
-}
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
index e7d9329..23c83d4 100644
--- a/ctdb/common/system_linux.c
+++ b/ctdb/common/system_linux.c
@@ -603,15 +603,3 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
}
return ret;
}
-
-/*
- * Set process name
- */
-int ctdb_set_process_name(const char *name)
-{
- char procname[16];
-
- strncpy(procname, name, 15);
- procname[15] = '\0';
- return prctl(PR_SET_NAME, (unsigned long)procname, 0, 0, 0);
-}
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 6d05af8..db9fb6a 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -30,6 +30,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"

#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -1887,7 +1888,7 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
close(rc->fd[0]);
debug_extra = talloc_asprintf(NULL, "revokechild-%s:", ctdb_db->db_name);

- ctdb_set_process_name("ctdb_revokechild");
+ prctl_set_comment("ctdb_revokechild");
if (switch_from_server_to_client(ctdb, "revokechild-%s", ctdb_db->db_name) != 0) {
DEBUG(DEBUG_ERR,("Failed to switch from server to client for revokechild process\n"));
c = 1;
diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c
index 4f998d3..d8eda2a 100644
--- a/ctdb/server/ctdb_monitor.c
+++ b/ctdb/server/ctdb_monitor.c
@@ -28,6 +28,7 @@

#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"

#include "ctdb_private.h"

@@ -104,7 +105,7 @@ void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event)
if (child == 0) {
int ret;

- ctdb_set_process_name("ctdb_notification");
+ prctl_set_comment("ctdb_notification");
debug_extra = talloc_asprintf(NULL, "notification-%s:", event);
ret = ctdb_run_notification_script_child(ctdb, event);
if (ret != 0) {
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index bf045c1..7b34d7e 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -31,6 +31,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"

#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -633,7 +634,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
char cc = 0;
close(state->fd[0]);

- ctdb_set_process_name("ctdb_recmode");
+ prctl_set_comment("ctdb_recmode");
debug_extra = talloc_asprintf(NULL, "set_recmode:");
/* Daemon should not be able to get the recover lock,
* as it should be held by the recovery master */
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 3f0cffc..c9f19fa 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -32,6 +32,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"

#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -4074,7 +4075,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)

srandom(getpid() ^ time(NULL));

- ctdb_set_process_name("ctdb_recovered");
+ prctl_set_comment("ctdb_recovered");
if (switch_from_server_to_client(ctdb, "recoverd") != 0) {
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch recovery daemon into client mode. shutting down.\n"));
exit(1);
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index 6844246..c9179d3 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -30,6 +30,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"

#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -4518,7 +4519,7 @@ int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb, struct ctdb_re
close(h->fd[0]);
debug_extra = talloc_asprintf(NULL, "reloadips:");

- ctdb_set_process_name("ctdb_reloadips");
+ prctl_set_comment("ctdb_reloadips");
if (switch_from_server_to_client(ctdb, "reloadips-child") != 0) {
DEBUG(DEBUG_CRIT,("ERROR: Failed to switch reloadips child into client mode\n"));
res = -1;
diff --git a/ctdb/server/ctdb_traverse.c b/ctdb/server/ctdb_traverse.c
index 3dea3fa..73c3a06 100644
--- a/ctdb/server/ctdb_traverse.c
+++ b/ctdb/server/ctdb_traverse.c
@@ -30,6 +30,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"

#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -217,7 +218,7 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con

close(h->fd[0]);

- ctdb_set_process_name("ctdb_traverse");
+ prctl_set_comment("ctdb_traverse");
if (switch_from_server_to_client(ctdb, "traverse_local-%s:",
ctdb_db->db_name) != 0) {
DEBUG(DEBUG_CRIT, ("Failed to switch traverse child into client mode\n"));
diff --git a/ctdb/server/ctdb_update_record.c b/ctdb/server/ctdb_update_record.c
index 143520a..bc9c6fe 100644
--- a/ctdb/server/ctdb_update_record.c
+++ b/ctdb/server/ctdb_update_record.c
@@ -28,6 +28,7 @@
#include "lib/tdb_wrap/tdb_wrap.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"

#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -265,7 +266,7 @@ static struct childwrite_handle *ctdb_childwrite(
char c = 0;

close(result->fd[0]);
- ctdb_set_process_name("ctdb_write_persistent");
+ prctl_set_comment("ctdb_write_persistent");
debug_extra = talloc_asprintf(NULL, "childwrite-%s:", ctdb_db->db_name);
ret = ctdb_persistent_store(state);
if (ret != 0) {
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index a81bd54..54dfe99 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -31,6 +31,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
+#include "lib/util/util_process.h"

#include "ctdb_private.h"
#include "ctdb_client.h"
@@ -1507,7 +1508,7 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
close(child_ctx->fd[0]);

DEBUG(DEBUG_INFO,("Vacuuming child process %d for db %s started\n", getpid(), ctdb_db->db_name));
- ctdb_set_process_name("ctdb_vacuum");
+ prctl_set_comment("ctdb_vacuum");
if (switch_from_server_to_client(ctdb, "vacuum-%s", ctdb_db->db_name) != 0) {
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch vacuum daemon into client mode. Shutting down.\n"));
_exit(1);
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 81578a9..226b15e 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -64,7 +64,7 @@ bld.SAMBA_LIBRARY('talloc_report',
bld.SAMBA_SUBSYSTEM('samba-util-core',
source='''xfile.c data_blob.c util_file.c time.c
signal.c util.c idtree.c fault.c
- substitute.c''',
+ substitute.c util_process.c''',
deps='''time-basic samba-debug socket-blocking talloc
tevent execinfo pthread''',
local_include=False)
@@ -102,7 +102,7 @@ if not bld.env.SAMBA_UTIL_CORE_ONLY:
util_strlist.c util_paths.c idtree_random.c base64.c
util_str.c util_str_common.c ms_fnmatch.c
server_id.c dprintf.c bitmap.c pidfile.c
- tevent_debug.c util_process.c memcache.c''',
+ tevent_debug.c memcache.c''',
deps='samba-util-core DYNCONFIG close-low-fd tini tiniparser genrand',

public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd systemd-daemon',
--
Samba Shared Repository
Amitay Isaacs
2015-11-18 10:52:03 UTC
Permalink
The branch, master has been updated
via d967789 ctdb-scripts: Fix CTDB_DBDIR=tmpfs support
from 3968e33 ctdb: Remove unused ctdb_set_process_name

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


- Log -----------------------------------------------------------------
commit d9677894b7aa2248e1884ab9e21667879bf1e3c4
Author: Martin Schwenke <***@meltin.net>
Date: Tue Nov 17 14:57:44 2015 +1100

ctdb-scripts: Fix CTDB_DBDIR=tmpfs support

Various scripts (including debug_locks.sh, 00.ctdb, 05.system) need
CTDB_DBDIR to point to the right place... but it doesn't.

Move the rewriting of CTDB_DBDIR to loadconfig() so that it happens
for all scripts. Have this code set internal variable
CTDB_DBDIR_TMPFS_OPTIONS so that ctdbd_wrapper can do the mount.

This loses the generality that was present in dbdir_tmpfs_start() but
it wasn't being used anyway. If it is needed in the future then it
will be in the git history.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

Autobuild-User(master): Amitay Isaacs <***@samba.org>
Autobuild-Date(master): Wed Nov 18 11:51:54 CET 2015 on sn-devel-104

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

Summary of changes:
ctdb/config/ctdbd_wrapper | 79 ++++++++++++++++-------------------------------
ctdb/config/functions | 25 +++++++++++++++
2 files changed, 52 insertions(+), 52 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index 71c7b25..be251e6 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -25,7 +25,6 @@ loadconfig "ctdb"
[ -n "$CTDB_SOCKET" ] && export CTDB_SOCKET

ctdbd="${CTDBD:-/usr/local/sbin/ctdbd}"
-ctdb_rundir="/usr/local/var/run/ctdb"

############################################################

@@ -80,61 +79,37 @@ ctdbd_is_running ()

############################################################

-# Mount given database directories on tmpfs
+# If necessary, mount volatile database directory on tmpfs
dbdir_tmpfs_start ()
{
- for _var ; do
- # $_var is the name of the configuration varable, so get the
- # value
- eval _val="\$${_var}"
-
- case "$_val" in
- tmpfs|tmpfs:*)
- _opts_defaults="mode=700"
- # Get any extra options specified after colon
- if [ "$_val" = "tmpfs" ] ; then
- _opts=""
- else
- _opts="${_val#tmpfs:}"
- fi
- # It is OK to repeat options - last value wins
- _opts_all="${_opts_defaults}${_opts:+,}${_opts}"
-
- # Last component of mountpoint is variable name
- _mnt="${ctdb_rundir}/${_var}"
- mkdir -p "$_mnt" || exit $?
-
- # If already mounted then remount, otherwise mount
- if findmnt -t tmpfs "$_mnt" >/dev/null ; then
- mount -t tmpfs -o "remount,$_opts_all" none "$_mnt" || \
- exit $?
- else
- mount -t tmpfs -o "$_opts_all" none "$_mnt" || exit $?
- fi
-
- # Replace specified value with mountpoint, to be
- # passed to ctdbd
- eval "${_var}=${_mnt}"
- ;;
- esac
- done
+ if [ -z "$CTDB_DBDIR_TMPFS_OPTIONS" ] ; then
+ return
+ fi
+
+ # Shortcut for readability
+ _opts="$CTDB_DBDIR_TMPFS_OPTIONS"
+
+ mkdir -p "$CTDB_DBDIR" || exit $?
+
+ # If already mounted then remount, otherwise mount
+ if findmnt -t tmpfs "$CTDB_DBDIR" >/dev/null ; then
+ mount -t tmpfs -o "remount,$_opts" none "$CTDB_DBDIR" || \
+ exit $?
+ else
+ mount -t tmpfs -o "$_opts" none "$CTDB_DBDIR" || exit $?
+ fi
}

-# Unmount database tmpfs directories on exit
+# If necessary, unmount volatile database tmpfs directory on exit
dbdir_tmpfs_stop ()
{
- for _var ; do
- eval _val="\$${_var}"
-
- case "$_val" in
- tmpfs|tmpfs:*)
- _mnt="${ctdb_rundir}/${_var}"
- if [ -d "$_mnt" ] && findmnt -t tmpfs "$_mnt" >/dev/null ; then
- umount "$_mnt"
- fi
- ;;
- esac
- done
+ if [ -z "$CTDB_DBDIR_TMPFS_OPTIONS" ] ; then
+ return
+ fi
+
+ if [ -d "$CTDB_DBDIR" ] && findmnt -t tmpfs "$CTDB_DBDIR" >/dev/null ; then
+ umount "$CTDB_DBDIR"
+ fi
}

build_ctdb_options ()
@@ -223,7 +198,7 @@ start()
# there may still be other processes around, so do some cleanup.
kill_ctdbd "$_session"

- dbdir_tmpfs_start CTDB_DBDIR
+ dbdir_tmpfs_start

build_ctdb_options

@@ -334,7 +309,7 @@ stop()
fi
fi

- dbdir_tmpfs_stop CTDB_DBDIR
+ dbdir_tmpfs_stop

return 0
}
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 49bed98..eef8f7e 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -8,6 +8,7 @@ if [ -z "$CTDB_BASE" ] ; then
fi

CTDB_VARDIR="/usr/local/var/lib/ctdb"
+ctdb_rundir="/usr/local/var/run/ctdb"

# Only (and always) override these variables in test code

@@ -21,6 +22,29 @@ fi

#######################################
# pull in a system config file, if any
+
+rewrite_ctdb_options ()
+{
+ case "$CTDB_DBDIR" in
+ tmpfs|tmpfs:*)
+ _opts_defaults="mode=700"
+ # Get any extra options specified after colon
+ if [ "$CTDB_DBDIR" = "tmpfs" ] ; then
+ _opts=""
+ else
+ _opts="${CTDB_DBDIR#tmpfs:}"
+ fi
+ # This is an internal variable, only used by ctdbd_wrapper.
+ # It is OK to repeat mount options - last value wins
+ CTDB_DBDIR_TMPFS_OPTIONS="${_opts_defaults}${_opts:+,}${_opts}"
+
+ CTDB_DBDIR="${ctdb_rundir}/CTDB_DBDIR"
+ ;;
+ *)
+ CTDB_DBDIR_TMPFS_OPTIONS=""
+ esac
+}
+
_loadconfig() {

if [ -z "$1" ] ; then
@@ -52,6 +76,7 @@ _loadconfig() {
if [ -r "$_config" ] ; then
. "$_config"
fi
+ rewrite_ctdb_options
fi
}
--
Samba Shared Repository
Volker Lendecke
2015-11-18 14:55:04 UTC
Permalink
The branch, master has been updated
via 39d0a81 lib: tevent: Whitespace cleanup.
via 2be3dd1 lib: tevent: Fix bug in poll backend - poll_event_loop_poll()
from d967789 ctdb-scripts: Fix CTDB_DBDIR=tmpfs support

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


- Log -----------------------------------------------------------------
commit 39d0a81ed87c58836335ec10af22b36c9961f91e
Author: Jeremy Allison <***@samba.org>
Date: Tue Nov 17 09:13:41 2015 -0800

lib: tevent: Whitespace cleanup.

Signed-off-by: Jeremy Allison <***@samba.org>
Reviewed-by: Volker Lendecke <***@samba.org>

Autobuild-User(master): Volker Lendecke <***@samba.org>
Autobuild-Date(master): Wed Nov 18 15:54:03 CET 2015 on sn-devel-104

commit 2be3dd1407eabe3df360ede2eab178848e34733c
Author: Jeremy Allison <***@samba.org>
Date: Tue Nov 17 10:28:50 2015 -0800

lib: tevent: Fix bug in poll backend - poll_event_loop_poll()

If the (pfd->revents & POLLNVAL) case is triggered,
we do DLIST_REMOVE(ev->fd_events, fde); and then
use fde->next in the loop above.

Save off fde->next for loop interation before
this so we can't use a deleted ->next value.

Signed-off-by: Jeremy Allison <***@samba.org>
Reviewed-by: Volker Lendecke <***@samba.org>

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

Summary of changes:
lib/tevent/tevent_epoll.c | 6 +++---
lib/tevent/tevent_poll.c | 5 ++++-
2 files changed, 7 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index 01fcde6..507ea5c 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -216,7 +216,7 @@ static void epoll_update_event(struct epoll_event_context *epoll_ev, struct teve

/*
reopen the epoll handle when our pid changes
- see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an
+ see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an
demonstration of why this is needed
*/
static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
@@ -661,7 +661,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
}

for (i=0;i<ret;i++) {
- struct tevent_fd *fde = talloc_get_type(events[i].data.ptr,
+ struct tevent_fd *fde = talloc_get_type(events[i].data.ptr,
struct tevent_fd);
uint16_t flags = 0;
struct tevent_fd *mpx_fde = NULL;
@@ -888,7 +888,7 @@ static void epoll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
}

/*
- do a single event loop using the events defined in ev
+ do a single event loop using the events defined in ev
*/
static int epoll_event_loop_once(struct tevent_context *ev, const char *location)
{
diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c
index 573ba93..9b1781f 100644
--- a/lib/tevent/tevent_poll.c
+++ b/lib/tevent/tevent_poll.c
@@ -498,6 +498,7 @@ static int poll_event_loop_poll(struct tevent_context *ev,
int timeout = -1;
int poll_errno;
struct tevent_fd *fde = NULL;
+ struct tevent_fd *next = NULL;
unsigned i;

if (ev->signal_events && tevent_common_check_signal(ev)) {
@@ -542,11 +543,13 @@ static int poll_event_loop_poll(struct tevent_context *ev,
which ones and call the handler, being careful to allow
the handler to remove itself when called */

- for (fde = ev->fd_events; fde; fde = fde->next) {
+ for (fde = ev->fd_events; fde; fde = next) {
uint64_t idx = fde->additional_flags;
struct pollfd *pfd;
uint16_t flags = 0;

+ next = fde->next;
+
if (idx == UINT64_MAX) {
continue;
}
--
Samba Shared Repository
Jeremy Allison
2015-11-18 20:41:05 UTC
Permalink
The branch, master has been updated
via bf06a51 Set LD_LIBRARY_PATH during tests.
from 39d0a81 lib: tevent: Whitespace cleanup.

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


- Log -----------------------------------------------------------------
commit bf06a5166ed29e82c4efdb86cf2634f424c29931
Author: Jelmer Vernooij <***@jelmer.uk>
Date: Wed Nov 18 02:59:37 2015 +0000

Set LD_LIBRARY_PATH during tests.

Without this, tests fail ir libtevent is not installed on the system.

Signed-Off-By: Jelmer Vernooij <***@jelmer.uk>
Reviewed-by: Jeremy Allison <***@samba.org>

Autobuild-User(master): Jeremy Allison <***@samba.org>
Autobuild-Date(master): Wed Nov 18 21:40:26 CET 2015 on sn-devel-104

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

Summary of changes:
lib/tevent/wscript | 3 +++
1 file changed, 3 insertions(+)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/wscript b/lib/tevent/wscript
index 4c5fe0c..73871d8 100755
--- a/lib/tevent/wscript
+++ b/lib/tevent/wscript
@@ -133,6 +133,9 @@ def test(ctx):
'''test tevent'''
print("The tevent testsuite is part of smbtorture in samba4")

+ samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
+ samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
+
pyret = samba_utils.RUN_PYTHON_TESTS(['bindings.py'])
sys.exit(pyret)
--
Samba Shared Repository
Volker Lendecke
2015-11-19 09:06:03 UTC
Permalink
The branch, master has been updated
via 155eeac lib: Fix memalign_array overflow protection
via 69e427e idl: Some CC can't find indented #defines
via 12b9b77 idl: Avoid // style comments
via 5f6c4fa libreplace: Only check for malloc.h if needed
via b64f249 libreplace: Put the malloc.h check on a line of its own
via 4dfa4ed libreplace: Only check malloc.h once
from bf06a51 Set LD_LIBRARY_PATH during tests.

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


- Log -----------------------------------------------------------------
commit 155eeac5ac9db6742b51ba9da57ef6eb0a796aed
Author: Volker Lendecke <***@samba.org>
Date: Wed Nov 18 13:13:57 2015 +0100

lib: Fix memalign_array overflow protection

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

Autobuild-User(master): Volker Lendecke <***@samba.org>
Autobuild-Date(master): Thu Nov 19 10:05:08 CET 2015 on sn-devel-104

commit 69e427ecee84777906b46ddbf63a7d0bb3b8ed39
Author: Volker Lendecke <***@samba.org>
Date: Mon Nov 16 16:23:10 2015 +0100

idl: Some CC can't find indented #defines

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit 12b9b770283c47f307e4ea7a8683762a25b35de5
Author: Volker Lendecke <***@samba.org>
Date: Mon Nov 16 16:11:48 2015 +0100

idl: Avoid // style comments

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit 5f6c4fa4860f794d25f1fcc2e557ca81cbe90183
Author: Volker Lendecke <***@samba.org>
Date: Mon Jun 30 15:46:21 2014 +0200

libreplace: Only check for malloc.h if needed

OpenBSD complains that malloc.h is deprecated on every gcc invocation.
That hides a lot of real warnings. malloc and friends nowadays are
typically defined in stdlib.h, only check there.

We need memalign. On OpenBSD this does not exist, so libreplace replaces
it. The wscript test in libreplace only checks whether memalign can
link. Unfortunately in glibc memalign comes from malloc.h.

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit b64f24971c5930ff382af6f69ab1fd84b4024fbf
Author: Volker Lendecke <***@samba.org>
Date: Mon Jun 30 15:15:37 2014 +0200

libreplace: Put the malloc.h check on a line of its own

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

commit 4dfa4edd1bf3cca42deec514e30e6962c6794647
Author: Volker Lendecke <***@samba.org>
Date: Mon Jun 30 13:52:02 2014 +0200

libreplace: Only check malloc.h once

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

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

Summary of changes:
lib/replace/wscript | 13 +++++++++++--
lib/util/util.c | 2 +-
librpc/idl/clusapi.idl | 26 +++++++++++++-------------
3 files changed, 25 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/replace/wscript b/lib/replace/wscript
index 7bfe7ee..37cbbb7 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -43,7 +43,12 @@ def configure(conf):
conf.CHECK_HEADERS('sys/id.h sys/ioctl.h sys/ipc.h sys/mman.h sys/mode.h sys/ndir.h sys/priv.h')
conf.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
conf.CHECK_HEADERS('sys/vfs.h sys/xattr.h termio.h termios.h sys/file.h')
- conf.CHECK_HEADERS('sys/ucontext.h sys/wait.h sys/stat.h malloc.h grp.h')
+ conf.CHECK_HEADERS('sys/ucontext.h sys/wait.h sys/stat.h')
+
+ if not conf.CHECK_DECLS('malloc', headers='stdlib.h'):
+ conf.CHECK_HEADERS('malloc.h')
+
+ conf.CHECK_HEADERS('grp.h')
conf.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
conf.CHECK_HEADERS('stdarg.h vararg.h sys/mount.h mntent.h')
conf.CHECK_HEADERS('stropts.h unix.h string.h strings.h sys/param.h limits.h')
@@ -71,7 +76,7 @@ def configure(conf):
conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
conf.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h')
conf.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h')
- conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h malloc.h')
+ conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h')
conf.CHECK_HEADERS('syscall.h sys/syscall.h inttypes.h')
conf.CHECK_HEADERS('sys/atomic.h')
conf.CHECK_HEADERS('libgen.h')
@@ -245,6 +250,10 @@ def configure(conf):
conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf')
conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memalign posix_memalign')
+
+ if conf.CONFIG_SET('HAVE_MEMALIGN'):
+ conf.CHECK_DECLS('memalign', headers='malloc.h')
+
conf.CHECK_FUNCS('prctl dirname basename')

# libbsd on some platforms provides strlcpy and strlcat
diff --git a/lib/util/util.c b/lib/util/util.c
index d8a84da..03edd7f 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -773,7 +773,7 @@ void *malloc_array(size_t el_size, unsigned int count)

void *memalign_array(size_t el_size, size_t align, unsigned int count)
{
- if (count*el_size >= MAX_MALLOC_SIZE) {
+ if (el_size == 0 || count >= MAX_MALLOC_SIZE/el_size) {
return NULL;
}

diff --git a/librpc/idl/clusapi.idl b/librpc/idl/clusapi.idl
index 3440047..8c4a227 100644
--- a/librpc/idl/clusapi.idl
+++ b/librpc/idl/clusapi.idl
@@ -28,15 +28,15 @@ import "winreg.idl", "misc.idl";
typedef [context_handle] void *HNETINTERFACE_RPC;
typedef [context_handle] void *HBATCH_PORT_RPC;
#else
- #define HCLUSTER_RPC policy_handle
- #define HNODE_RPC policy_handle
- #define HGROUP_RPC policy_handle
- #define HRES_RPC policy_handle
- #define HKEY_RPC policy_handle
- #define HNOTIFY_RPC policy_handle
- #define HNETWORK_RPC policy_handle
- #define HNETINTERFACE_RPC policy_handle
- #define HBATCH_PORT_RPC policy_handle
+#define HCLUSTER_RPC policy_handle
+#define HNODE_RPC policy_handle
+#define HGROUP_RPC policy_handle
+#define HRES_RPC policy_handle
+#define HKEY_RPC policy_handle
+#define HNOTIFY_RPC policy_handle
+#define HNETWORK_RPC policy_handle
+#define HNETINTERFACE_RPC policy_handle
+#define HBATCH_PORT_RPC policy_handle
#endif

typedef struct {
@@ -2046,7 +2046,7 @@ import "winreg.idl", "misc.idl";
#endif

typedef struct {
- uint32 dwObjectType; // really of type CLUSTER_OBJECT_TYPE_RPC
+ uint32 dwObjectType; /* really of type CLUSTER_OBJECT_TYPE_RPC */
hyper FilterFlags;
} NOTIFY_FILTER_AND_TYPE_RPC;

@@ -2068,9 +2068,9 @@ import "winreg.idl", "misc.idl";
/*****************/
/* Function 0x89 */

- //
- // Notify interface V2 functions
- //
+ /*
+ * Notify interface V2 functions
+ */
#if 0
HNOTIFY_RPC
clusapi_CreateNotifyV2(
--
Samba Shared Repository
Michael Adam
2015-11-19 12:11:03 UTC
Permalink
The branch, master has been updated
via 5036c6e build:wafsamba: remove check_orphaned_targets
from 155eeac lib: Fix memalign_array overflow protection

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


- Log -----------------------------------------------------------------
commit 5036c6e7447b7ad53886c759a7a3f5c29ae57779
Author: Thomas Nagy <***@waf.io>
Date: Sat Nov 14 15:23:27 2015 +0100

build:wafsamba: remove check_orphaned_targets

The function check_orphaned_targets is not used and has
no specification, so it can be removed safely.

Signed-off-by: Thomas Nagy <***@waf.io>
Reviewed-by: Andrew Bartlett <***@samba.org>
Reviewed-by: Michael Adam <***@samba.org>

Autobuild-User(master): Michael Adam <***@samba.org>
Autobuild-Date(master): Thu Nov 19 13:10:53 CET 2015 on sn-devel-104

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

Summary of changes:
buildtools/wafsamba/samba_deps.py | 19 -------------------
1 file changed, 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py
index 9e5eab7..6976a9a 100644
--- a/buildtools/wafsamba/samba_deps.py
+++ b/buildtools/wafsamba/samba_deps.py
@@ -302,23 +302,6 @@ def check_duplicate_sources(bld, tgt_list):

return True

-
-def check_orphaned_targets(bld, tgt_list):
- '''check if any build targets are orphaned'''
-
- target_dict = LOCAL_CACHE(bld, 'TARGET_TYPE')
-
- debug('deps: checking for orphaned targets')
-
- for t in tgt_list:
- if getattr(t, 'samba_used', False):
- continue
- type = target_dict[t.sname]
- if not type in ['BINARY', 'LIBRARY', 'MODULE', 'ET', 'PYTHON']:
- if re.search('^PIDL_', t.sname) is None:
- Logs.warn("Target %s of type %s is unused by any other target" % (t.sname, type))
-
-
def check_group_ordering(bld, tgt_list):
'''see if we have any dependencies that violate the group ordering

@@ -1151,8 +1134,6 @@ def check_project_rules(bld):

debug('deps: project rules stage1 completed')

- #check_orphaned_targets(bld, tgt_list)
-
if not check_duplicate_sources(bld, tgt_list):
Logs.error("Duplicate sources present - aborting")
sys.exit(1)
--
Samba Shared Repository
Volker Lendecke
2015-11-19 19:17:04 UTC
Permalink
The branch, master has been updated
via 7e9aaec winbind: Don't crash on invalid idmap configs
from 5036c6e build:wafsamba: remove check_orphaned_targets

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


- Log -----------------------------------------------------------------
commit 7e9aaecec552ca53c50fc0c731419af467f76a00
Author: Volker Lendecke <***@samba.org>
Date: Thu Nov 19 17:00:49 2015 +0100

winbind: Don't crash on invalid idmap configs

We should not leave NULL in idmap_domains[]. This will lead to NULL
ptr deferences in idmap_find_domain().

Bug: https://bugzilla.samba.org/show_bug.cgi?id=11612
Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Andreas Schneider <***@samba.org>

Autobuild-User(master): Volker Lendecke <***@samba.org>
Autobuild-Date(master): Thu Nov 19 20:16:44 CET 2015 on sn-devel-104

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

Summary of changes:
source3/winbindd/idmap.c | 1 +
1 file changed, 1 insertion(+)


Changeset truncated at 500 lines:

diff --git a/source3/winbindd/idmap.c b/source3/winbindd/idmap.c
index 8de8990..4012e70 100644
--- a/source3/winbindd/idmap.c
+++ b/source3/winbindd/idmap.c
@@ -146,6 +146,7 @@ static bool idmap_found_domain_backend(
if (dom == NULL) {
DBG_NOTICE("Could not init idmap domain %s\n",
domname);
+ return false;
}

tmp = talloc_realloc(idmap_domains, idmap_domains,
--
Samba Shared Repository
Jeremy Allison
2015-11-19 22:21:04 UTC
Permalink
The branch, master has been updated
via d451bba selftest: add test for force user and well-known primary group
via d8717a0 auth: consistent handling of well-known alias as primary gid
via 42b7d48 auth: remove a line that has no effect
from 7e9aaec winbind: Don't crash on invalid idmap configs

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


- Log -----------------------------------------------------------------
commit d451bbaee2e025d4135f686c0f220d6337dbf38e
Author: Uri Simchoni <***@samba.org>
Date: Tue Nov 17 23:14:36 2015 +0200

selftest: add test for force user and well-known primary group

Add a test for connecting to a share with a "force user" whos
primary unix gid maps to a well-known alias.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11608

Signed-off-by: Uri Simchoni <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

Autobuild-User(master): Jeremy Allison <***@samba.org>
Autobuild-Date(master): Thu Nov 19 23:20:36 CET 2015 on sn-devel-104

commit d8717a038ef82caf05fff611c7cf92aecc436563
Author: Uri Simchoni <***@samba.org>
Date: Tue Nov 17 23:05:10 2015 +0200

auth: consistent handling of well-known alias as primary gid

When a local user has its primary group id mapped to a well-known
alias or a builtin group, smbd accepts logins of such a user, but
fails tree-connects to shares with a "force user" set to this user
with an error of NT_STATUS_INVALID_SID.

This fix causes the connect to succeed and the NT token to resemble
the token that would have been created in a login.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11608

Signed-off-by: Uri Simchoni <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

commit 42b7d48f76189b1e138f5cac6489a4d018598c87
Author: Uri Simchoni <***@samba.org>
Date: Tue Nov 17 21:43:44 2015 +0200

auth: remove a line that has no effect

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11608

Signed-off-by: Uri Simchoni <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

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

Summary of changes:
selftest/target/Samba3.pm | 19 +++++++++++++++++--
source3/auth/server_info.c | 25 +++++++++++++++++--------
source3/script/tests/test_smbclient_auth.sh | 1 +
3 files changed, 35 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 1c54dae..94612b2 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1228,8 +1228,9 @@ sub provision($$$$$$$$)

my ($max_uid, $max_gid);
my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
+ my ($uid_pdbtest_wkn);
my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
- my ($gid_userdup);
+ my ($gid_userdup, $gid_everyone);

if ($unix_uid < 0xffff - 5) {
$max_uid = 0xffff;
@@ -1242,8 +1243,9 @@ sub provision($$$$$$$$)
$uid_pdbtest = $max_uid - 3;
$uid_pdbtest2 = $max_uid - 4;
$uid_userdup = $max_uid - 5;
+ $uid_pdbtest_wkn = $max_uid - 6;

- if ($unix_gids[0] < 0xffff - 6) {
+ if ($unix_gids[0] < 0xffff - 7) {
$max_gid = 0xffff;
} else {
$max_gid = $unix_gids[0];
@@ -1255,6 +1257,7 @@ sub provision($$$$$$$$)
$gid_domusers = $max_gid - 4;
$gid_domadmins = $max_gid - 5;
$gid_userdup = $max_gid - 6;
+ $gid_everyone = $max_gid - 7;

##
## create conffile
@@ -1398,9 +1401,15 @@ sub provision($$$$$$$$)
force user = $unix_name
guest ok = yes
[forceuser_unixonly]
+ comment = force a user with unix user SID and group SID
path = $shrdir
force user = pdbtest
guest ok = yes
+[forceuser_wkngroup]
+ comment = force a user with well-known group SID
+ path = $shrdir
+ force user = pdbtest_wkn
+ guest ok = yes
[forcegroup]
path = $shrdir
force group = nogroup
@@ -1528,6 +1537,7 @@ $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
+pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
";
if ($unix_uid != 0) {
print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
@@ -1545,6 +1555,7 @@ $unix_name-group:x:$unix_gids[0]:
domusers:X:$gid_domusers:
domadmins:X:$gid_domadmins:
userdup:x:$gid_userdup:$unix_name
+everyone:x:$gid_everyone:
";
if ($unix_gids[0] != 0) {
print GROUP "root:x:$gid_root:
@@ -1737,6 +1748,10 @@ sub wait_for_start($$$$$)
if ($ret != 0) {
return 1;
}
+ $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin");
+ if ($ret != 0) {
+ return 1;
+ }

if ($winbindd eq "yes") {
# note: creating builtin groups requires winbindd for the
diff --git a/source3/auth/server_info.c b/source3/auth/server_info.c
index b537390..9194cbd 100644
--- a/source3/auth/server_info.c
+++ b/source3/auth/server_info.c
@@ -599,18 +599,27 @@ NTSTATUS passwd_to_SamInfo3(TALLOC_CTX *mem_ctx,
* will be rejected by other Samba code.
*/
gid_to_sid(&group_sid, pwd->pw_gid);
+ }

- ZERO_STRUCT(domain_sid);
-
- /*
- * If we are a unix group, set the group_sid to the
- * 'Domain Users' RID of 513 which will always resolve to a
- * name.
- */
- if (sid_check_is_in_unix_groups(&group_sid)) {
+ /*
+ * If we are a unix group, or a wellknown/builtin alias,
+ * set the group_sid to the
+ * 'Domain Users' RID of 513 which will always resolve to a
+ * name.
+ */
+ if (sid_check_is_in_unix_groups(&group_sid) ||
+ sid_check_is_in_builtin(&group_sid) ||
+ sid_check_is_in_wellknown_domain(&group_sid)) {
+ if (sid_check_is_in_unix_users(&user_sid)) {
sid_compose(&group_sid,
get_global_sam_sid(),
DOMAIN_RID_USERS);
+ } else {
+ sid_copy(&domain_sid, &user_sid);
+ sid_split_rid(&domain_sid, NULL);
+ sid_compose(&group_sid,
+ &domain_sid,
+ DOMAIN_RID_USERS);
}
}

diff --git a/source3/script/tests/test_smbclient_auth.sh b/source3/script/tests/test_smbclient_auth.sh
index 24e98b1..057414c 100755
--- a/source3/script/tests/test_smbclient_auth.sh
+++ b/source3/script/tests/test_smbclient_auth.sh
@@ -28,5 +28,6 @@ testit "smbclient //$SERVER/tmpguest as anon" $SMBCLIENT //$SERVER/tmpguest $CON
testit "smbclient //$SERVER/forceuser" $SMBCLIENT //$SERVER/forceuser $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 -c quit $ADDARGS
testit "smbclient //$SERVER/forceuser as anon" $SMBCLIENT //$SERVER/forceuser $CONFIGURATION -U% -I $SERVER_IP -p 139 -c quit $ADDARGS
testit "smbclient //$SERVER/forceuser_unixonly" $SMBCLIENT //$SERVER/forceuser_unixonly $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 -c quit $ADDARGS
+testit "smbclient //$SERVER/forceuser_wkngroup" $SMBCLIENT //$SERVER/forceuser_wkngroup $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 -c quit $ADDARGS
testit "smbclient //$SERVER/forcegroup" $SMBCLIENT //$SERVER/forcegroup $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 -c quit $ADDARGS
testit "smbclient //$SERVER/forcegroup as anon" $SMBCLIENT //$SERVER/forcegroup $CONFIGURATION -U% -I $SERVER_IP -p 139 -c quit $ADDARGS
--
Samba Shared Repository
Amitay Isaacs
2015-11-20 03:41:03 UTC
Permalink
The branch, master has been updated
via 8fdda6f ctdb-scripts: Drop creation of database directories
via 5b7bb60 ctdb-ipalloc: ctdb_takeover_run_core() takes ipalloc_state
via 5fba874 ctdb-ipalloc: Tidy up create_merged_ip_list()
via 837483c ctdb-ipalloc: Move IP list creation out to ctdb_takeover_run()
via cc1637b ctdb-ipalloc: Add no_ip_failback to ipalloc_state
via 47ddd62 ctdb-ipalloc: New enum ipalloc_algorithm in ipalloc_state
via cfa0ffe ctdb-ipalloc: Move IP allocation state into its own struct
via d7739d8 ctdb-ipalloc: node_ip_coverage() doesn't need CTDB context
from d451bba selftest: add test for force user and well-known primary group

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


- Log -----------------------------------------------------------------
commit 8fdda6fa96df35e02ac8ed1f7add46efc528683e
Author: Martin Schwenke <***@meltin.net>
Date: Thu Nov 19 08:35:17 2015 +1100

ctdb-scripts: Drop creation of database directories

These should be created elsewhere. If not then something is wrong, so
don't hide the problem.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

Autobuild-User(master): Amitay Isaacs <***@samba.org>
Autobuild-Date(master): Fri Nov 20 04:40:26 CET 2015 on sn-devel-104

commit 5b7bb6056b366a2bd834dfb09d2a37009ae38c29
Author: Martin Schwenke <***@meltin.net>
Date: Thu Oct 29 21:08:07 2015 +1100

ctdb-ipalloc: ctdb_takeover_run_core() takes ipalloc_state

As do the functions called below it. They no longer need a CTDB
context.

create_merged_ip_list() now takes both a CTDB context and an
ipalloc_state.

Drop ipalloc_state from CTDB context. So the substitution in the
code is:

ctdb->ipalloc_state -> ipalloc_state

Tweak the test code to match.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 5fba874a2edd3b892f3a3c5670971b9bbe8afa81
Author: Martin Schwenke <***@meltin.net>
Date: Thu Oct 29 20:46:54 2015 +1100

ctdb-ipalloc: Tidy up create_merged_ip_list()

Simplify with TALLOC_FREE() and fix some whitespace.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 837483c8d3f8c44f9709074932a9dd7ebfac90ce
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 21:17:47 2015 +1100

ctdb-ipalloc: Move IP list creation out to ctdb_takeover_run()

For various reasons create_merged_ip_list() needs a CTDB context.
This is difficult to resolve now for a few reasons, including:

* The ip_tree needs somewhere to live.

It isn't very useful in its current form. However, in the future
real remote IP monitoring will probably be added back, so leave it
around.

* It uses node flags from the ctdb_node structure.

This could be changed by putting a node map into ipalloc_state
and referencing that.

For now, it is easier to move it out to where there will be a CTDB
context available for the forseeable future. ctdb_takeover_run() will
need one as long as the current client interface is used.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit cc1637b17c9ae89bcc00d95f9cdfd00f67c88bc3
Author: Martin Schwenke <***@meltin.net>
Date: Thu Oct 29 19:53:25 2015 +1100

ctdb-ipalloc: Add no_ip_failback to ipalloc_state

The IP allocation algorithms need the value of this tunable, so copy
it to avoid needing the CTDB context.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 47ddd623581477bf0a40bd8330dfaf4d8f551752
Author: Martin Schwenke <***@meltin.net>
Date: Thu Oct 29 19:41:10 2015 +1100

ctdb-ipalloc: New enum ipalloc_algorithm in ipalloc_state

Algorithm-related tunables from the CTDB context no longer need to be
accessed in the allocation logic.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit cfa0ffe78073f9e3a014bb127fb9a4b7ad95fceb
Author: Martin Schwenke <***@meltin.net>
Date: Thu Oct 29 16:49:44 2015 +1100

ctdb-ipalloc: Move IP allocation state into its own struct

Most of the IP allocation code does not need a CTDB context. However,
temporarily hang this off the CTDB context and make only the changes
relating to known/available IP address. This makes those logic
changes obvious without burying them in function type changes.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit d7739d8a7f2d72c5cf6d77272d11f5dd859b6010
Author: Martin Schwenke <***@meltin.net>
Date: Wed Oct 28 22:59:18 2015 +1100

ctdb-ipalloc: node_ip_coverage() doesn't need CTDB context

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

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

Summary of changes:
ctdb/config/events.d/00.ctdb | 4 +-
ctdb/include/ctdb_private.h | 6 -
ctdb/server/ctdb_takeover.c | 260 ++++++++++++++++++++++-------------
ctdb/tests/src/ctdb_takeover_tests.c | 39 ++++--
4 files changed, 195 insertions(+), 114 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index 99a0c71..3bc20d7 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -65,7 +65,7 @@ check_tdb ()
check_persistent_databases ()
{
_dir="${CTDB_DBDIR_PERSISTENT:-${CTDB_DBDIR:-${CTDB_VARDIR}}/persistent}"
- mkdir -p "$_dir" 2>/dev/null
+ [ -d "$_dir" ] || return 0

[ "${CTDB_MAX_PERSISTENT_CHECK_ERRORS:-0}" = "0" ] || return 0

@@ -80,7 +80,7 @@ check_persistent_databases ()
check_non_persistent_databases ()
{
_dir="${CTDB_DBDIR:-${CTDB_VARDIR}}"
- mkdir -p "$_dir" 2>/dev/null
+ [ -d "$_dir" ] || return 0

for _db in $(ls "${_dir}/"*.tdb.*[0-9] 2>/dev/null) ; do
check_tdb $_db || {
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 57a13d9..b7c3e5d 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -126,12 +126,6 @@ struct ctdb_node {
if the node becomes disconnected */
struct daemon_control_state *pending_controls;

- /* used by the recovery daemon when distributing ip addresses
- across the nodes. it needs to know which public ip's can be handled
- by each node.
- */
- struct ctdb_public_ip_list_old *known_public_ips;
- struct ctdb_public_ip_list_old *available_public_ips;
/* used by the recovery dameon to track when a node should be banned */
struct ctdb_banning_state *ban_state;
};
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index c9179d3..d99f9aa 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -53,6 +53,23 @@ struct ctdb_ipflags {
bool noiphost;
};

+enum ipalloc_algorithm {
+ IPALLOC_DETERMINISTIC,
+ IPALLOC_NONDETERMINISTIC,
+ IPALLOC_LCP2,
+};
+
+struct ipalloc_state {
+ uint32_t num;
+
+ /* Arrays with data for each node */
+ struct ctdb_public_ip_list_old **known_public_ips;
+ struct ctdb_public_ip_list_old **available_public_ips;
+
+ enum ipalloc_algorithm algorithm;
+ uint32_t no_ip_failback;
+};
+
struct ctdb_interface {
struct ctdb_interface *prev, *next;
const char *name;
@@ -1242,8 +1259,7 @@ struct public_ip_list {
/* Given a physical node, return the number of
public addresses that is currently assigned to this node.
*/
-static int node_ip_coverage(struct ctdb_context *ctdb, int32_t pnn,
- struct public_ip_list *ips)
+static int node_ip_coverage(int32_t pnn, struct public_ip_list *ips)
{
int num=0;

@@ -1259,7 +1275,8 @@ static int node_ip_coverage(struct ctdb_context *ctdb, int32_t pnn,
/* Can the given node host the given IP: is the public IP known to the
* node and is NOIPHOST unset?
*/
-static bool can_node_host_ip(struct ctdb_context *ctdb, int32_t pnn,
+static bool can_node_host_ip(struct ipalloc_state *ipalloc_state,
+ int32_t pnn,
struct ctdb_ipflags ipflags,
struct public_ip_list *ip)
{
@@ -1270,7 +1287,7 @@ static bool can_node_host_ip(struct ctdb_context *ctdb, int32_t pnn,
return false;
}

- public_ips = ctdb->nodes[pnn]->available_public_ips;
+ public_ips = ipalloc_state->available_public_ips[pnn];

if (public_ips == NULL) {
return false;
@@ -1286,7 +1303,8 @@ static bool can_node_host_ip(struct ctdb_context *ctdb, int32_t pnn,
return false;
}

-static bool can_node_takeover_ip(struct ctdb_context *ctdb, int32_t pnn,
+static bool can_node_takeover_ip(struct ipalloc_state *ipalloc_state,
+ int32_t pnn,
struct ctdb_ipflags ipflags,
struct public_ip_list *ip)
{
@@ -1294,14 +1312,14 @@ static bool can_node_takeover_ip(struct ctdb_context *ctdb, int32_t pnn,
return false;
}

- return can_node_host_ip(ctdb, pnn, ipflags, ip);
+ return can_node_host_ip(ipalloc_state, pnn, ipflags, ip);
}

/* search the node lists list for a node to takeover this ip.
pick the node that currently are serving the least number of ips
so that the ips get spread out evenly.
*/
-static int find_takeover_node(struct ctdb_context *ctdb,
+static int find_takeover_node(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *ip,
struct public_ip_list *all_ips)
@@ -1313,12 +1331,12 @@ static int find_takeover_node(struct ctdb_context *ctdb,
pnn = -1;
for (i=0; i<numnodes; i++) {
/* verify that this node can serve this ip */
- if (!can_node_takeover_ip(ctdb, i, ipflags[i], ip)) {
+ if (!can_node_takeover_ip(ipalloc_state, i, ipflags[i], ip)) {
/* no it couldnt so skip to the next node */
continue;
}

- num = node_ip_coverage(ctdb, i, all_ips);
+ num = node_ip_coverage(i, all_ips);
/* was this the first node we checked ? */
if (pnn == -1) {
pnn = i;
@@ -1329,7 +1347,7 @@ static int find_takeover_node(struct ctdb_context *ctdb,
min = num;
}
}
- }
+ }
if (pnn == -1) {
DEBUG(DEBUG_WARNING,(__location__ " Could not find node to take over public address '%s'\n",
ctdb_addr_to_str(&ip->addr)));
@@ -1398,25 +1416,21 @@ static int verify_remote_ip_allocation(struct ctdb_context *ctdb,
uint32_t pnn);

static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
+ struct ipalloc_state *ipalloc_state,
struct ctdb_node_map_old *nodemap)
{
int j;
int ret;

- if (ctdb->num_nodes != nodemap->num) {
- DEBUG(DEBUG_ERR, (__location__ " ctdb->num_nodes (%d) != nodemap->num (%d) invalid param\n",
- ctdb->num_nodes, nodemap->num));
+ if (ipalloc_state->num != nodemap->num) {
+ DEBUG(DEBUG_ERR,
+ (__location__
+ " ipalloc_state->num (%d) != nodemap->num (%d) invalid param\n",
+ ipalloc_state->num, nodemap->num));
return -1;
}

for (j=0; j<nodemap->num; j++) {
- /* For readability */
- struct ctdb_node *node = ctdb->nodes[j];
-
- /* release any existing data */
- TALLOC_FREE(node->known_public_ips);
- TALLOC_FREE(node->available_public_ips);
-
if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
continue;
}
@@ -1424,34 +1438,34 @@ static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
/* Retrieve the list of known public IPs from the node */
ret = ctdb_ctrl_get_public_ips_flags(ctdb,
TAKEOVER_TIMEOUT(),
- node->pnn,
+ j,
ctdb->nodes,
0,
- &node->known_public_ips);
+ &ipalloc_state->known_public_ips[j]);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Failed to read known public IPs from node: %u\n",
- node->pnn));
+ j));
return -1;
}

if (ctdb->do_checkpublicip) {
verify_remote_ip_allocation(ctdb,
- node->known_public_ips,
- node->pnn);
+ ipalloc_state->known_public_ips[j],
+ j);
}

/* Retrieve the list of available public IPs from the node */
ret = ctdb_ctrl_get_public_ips_flags(ctdb,
TAKEOVER_TIMEOUT(),
- node->pnn,
+ j,
ctdb->nodes,
CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE,
- &node->available_public_ips);
+ &ipalloc_state->available_public_ips[j]);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Failed to read available public IPs from node: %u\n",
- node->pnn));
+ j));
return -1;
}
}
@@ -1460,20 +1474,17 @@ static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
}

static struct public_ip_list *
-create_merged_ip_list(struct ctdb_context *ctdb)
+create_merged_ip_list(struct ctdb_context *ctdb, struct ipalloc_state *ipalloc_state)
{
int i, j;
struct public_ip_list *ip_list;
struct ctdb_public_ip_list_old *public_ips;

- if (ctdb->ip_tree != NULL) {
- talloc_free(ctdb->ip_tree);
- ctdb->ip_tree = NULL;
- }
+ TALLOC_FREE(ctdb->ip_tree);
ctdb->ip_tree = trbt_create(ctdb, 0);

- for (i=0;i<ctdb->num_nodes;i++) {
- public_ips = ctdb->nodes[i]->known_public_ips;
+ for (i=0; i < ctdb->num_nodes; i++) {
+ public_ips = ipalloc_state->known_public_ips[i];

if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
continue;
@@ -1482,9 +1493,9 @@ create_merged_ip_list(struct ctdb_context *ctdb)
/* there were no public ips for this node */
if (public_ips == NULL) {
continue;
- }
+ }

- for (j=0;j<public_ips->num;j++) {
+ for (j=0; j < public_ips->num; j++) {
struct public_ip_list *tmp_ip;

tmp_ip = talloc_zero(ctdb->ip_tree, struct public_ip_list);
@@ -1614,20 +1625,22 @@ static uint32_t lcp2_imbalance(struct public_ip_list * all_ips, int pnn)
/* Allocate any unassigned IPs just by looping through the IPs and
* finding the best node for each.
*/
-static void basic_allocate_unassigned(struct ctdb_context *ctdb,
+static void basic_allocate_unassigned(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips)
{
struct public_ip_list *tmp_ip;

- /* loop over all ip's and find a physical node to cover for
+ /* loop over all ip's and find a physical node to cover for
each unassigned ip.
*/
for (tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next) {
if (tmp_ip->pnn == -1) {
- if (find_takeover_node(ctdb, ipflags, tmp_ip, all_ips)) {
- DEBUG(DEBUG_WARNING,("Failed to find node to cover ip %s\n",
- ctdb_addr_to_str(&tmp_ip->addr)));
+ if (find_takeover_node(ipalloc_state, ipflags,
+ tmp_ip, all_ips)) {
+ DEBUG(DEBUG_WARNING,
+ ("Failed to find node to cover ip %s\n",
+ ctdb_addr_to_str(&tmp_ip->addr)));
}
}
}
@@ -1635,7 +1648,7 @@ static void basic_allocate_unassigned(struct ctdb_context *ctdb,

/* Basic non-deterministic rebalancing algorithm.
*/
-static void basic_failback(struct ctdb_context *ctdb,
+static void basic_failback(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
int num_ips)
@@ -1668,12 +1681,13 @@ try_again:
minnode = -1;
for (i=0; i<numnodes; i++) {
/* only check nodes that can actually serve this ip */
- if (!can_node_takeover_ip(ctdb, i, ipflags[i], tmp_ip)) {
+ if (!can_node_takeover_ip(ipalloc_state, i,
+ ipflags[i], tmp_ip)) {
/* no it couldnt so skip to the next node */
continue;
}

- num = node_ip_coverage(ctdb, i, all_ips);
+ num = node_ip_coverage(i, all_ips);
if (maxnode == -1) {
maxnode = i;
maxnum = num;
@@ -1713,7 +1727,10 @@ try_again:
/* Reassign one of maxnode's VNNs */
for (tmp=all_ips;tmp;tmp=tmp->next) {
if (tmp->pnn == maxnode) {
- (void)find_takeover_node(ctdb, ipflags, tmp, all_ips);
+ (void)find_takeover_node(ipalloc_state,
+ ipflags,
+ tmp,
+ all_ips);
retries++;
goto try_again;;
}
@@ -1722,7 +1739,7 @@ try_again:
}
}

-static void lcp2_init(struct ctdb_context *tmp_ctx,
+static void lcp2_init(TALLOC_CTX *tmp_ctx,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
uint32_t *force_rebalance_nodes,
@@ -1780,7 +1797,7 @@ static void lcp2_init(struct ctdb_context *tmp_ctx,
/* Allocate any unassigned addresses using the LCP2 algorithm to find
* the IP/node combination that will cost the least.
*/
-static void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
+static void lcp2_allocate_unassigned(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
uint32_t *lcp2_imbalances)
@@ -1815,7 +1832,8 @@ static void lcp2_allocate_unassigned(struct ctdb_context *ctdb,

for (dstnode=0; dstnode<numnodes; dstnode++) {
/* only check nodes that can actually takeover this ip */
- if (!can_node_takeover_ip(ctdb, dstnode,
+ if (!can_node_takeover_ip(ipalloc_state,
+ dstnode,
ipflags[dstnode],
tmp_ip)) {
/* no it couldnt so skip to the next node */
@@ -1878,7 +1896,7 @@ static void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
* to move IPs from, determines the best IP/destination node
* combination to move from the source node.
*/
-static bool lcp2_failback_candidate(struct ctdb_context *ctdb,
+static bool lcp2_failback_candidate(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
int srcnode,
@@ -1926,7 +1944,7 @@ static bool lcp2_failback_candidate(struct ctdb_context *ctdb,
}

/* only check nodes that can actually takeover this ip */
- if (!can_node_takeover_ip(ctdb, dstnode,
+ if (!can_node_takeover_ip(ipalloc_state, dstnode,
ipflags[dstnode], tmp_ip)) {
/* no it couldnt so skip to the next node */
continue;
@@ -1995,7 +2013,7 @@ static int lcp2_cmp_imbalance_pnn(const void * a, const void * b)
* node with the highest LCP2 imbalance, and then determines the best
* IP/destination node combination to move from the source node.
*/
-static void lcp2_failback(struct ctdb_context *ctdb,
+static void lcp2_failback(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
uint32_t *lcp2_imbalances,
@@ -2014,7 +2032,7 @@ try_again:
*/
DEBUG(DEBUG_DEBUG,("+++++++++++++++++++++++++++++++++++++++++\n"));
DEBUG(DEBUG_DEBUG,("Selecting most imbalanced node from:\n"));
- lips = talloc_array(ctdb, struct lcp2_imbalance_pnn, numnodes);
+ lips = talloc_array(ipalloc_state, struct lcp2_imbalance_pnn, numnodes);
for (i=0; i<numnodes; i++) {
lips[i].imbalance = lcp2_imbalances[i];
lips[i].pnn = i;
@@ -2032,7 +2050,7 @@ try_again:
break;
}

- if (lcp2_failback_candidate(ctdb,
+ if (lcp2_failback_candidate(ipalloc_state,
ipflags,
all_ips,
lips[i].pnn,
@@ -2049,7 +2067,7 @@ try_again:
}
}

-static void unassign_unsuitable_ips(struct ctdb_context *ctdb,
+static void unassign_unsuitable_ips(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips)
{
@@ -2062,7 +2080,7 @@ static void unassign_unsuitable_ips(struct ctdb_context *ctdb,
if (tmp_ip->pnn == -1) {
continue;
}
- if (!can_node_host_ip(ctdb, tmp_ip->pnn,
+ if (!can_node_host_ip(ipalloc_state, tmp_ip->pnn,
ipflags[tmp_ip->pnn], tmp_ip) != 0) {
/* this node can not serve this ip. */
DEBUG(DEBUG_DEBUG,("Unassign IP: %s from %d\n",
@@ -2073,7 +2091,7 @@ static void unassign_unsuitable_ips(struct ctdb_context *ctdb,
}
}

-static void ip_alloc_deterministic_ips(struct ctdb_context *ctdb,
+static void ip_alloc_deterministic_ips(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips)
{
@@ -2096,18 +2114,18 @@ static void ip_alloc_deterministic_ips(struct ctdb_context *ctdb,
* IPs, since the modulo step above implicitly fails
* back IPs to their "home" node.
*/
- if (1 == ctdb->tunable.no_ip_failback) {
+ if (1 == ipalloc_state->no_ip_failback) {
DEBUG(DEBUG_WARNING, ("WARNING: 'NoIPFailback' set but ignored - incompatible with 'DeterministicIPs\n"));
}

- unassign_unsuitable_ips(ctdb, ipflags, all_ips);
+ unassign_unsuitable_ips(ipalloc_state, ipflags, all_ips);

- basic_allocate_unassigned(ctdb, ipflags, all_ips);
+ basic_allocate_unassigned(ipalloc_state, ipflags, all_ips);

/* No failback here! */
}

-static void ip_alloc_nondeterministic_ips(struct ctdb_context *ctdb,
+static void ip_alloc_nondeterministic_ips(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips)
{
@@ -2118,22 +2136,22 @@ static void ip_alloc_nondeterministic_ips(struct ctdb_context *ctdb,
num_ips++;
}

- unassign_unsuitable_ips(ctdb, ipflags, all_ips);
+ unassign_unsuitable_ips(ipalloc_state, ipflags, all_ips);

- basic_allocate_unassigned(ctdb, ipflags, all_ips);
+ basic_allocate_unassigned(ipalloc_state, ipflags, all_ips);

/* If we don't want IPs to fail back then don't rebalance IPs. */
- if (1 == ctdb->tunable.no_ip_failback) {
+ if (1 == ipalloc_state->no_ip_failback) {
return;
}

/* Now, try to make sure the ip adresses are evenly distributed
across the nodes.
*/
- basic_failback(ctdb, ipflags, all_ips, num_ips);
+ basic_failback(ipalloc_state, ipflags, all_ips, num_ips);
}

-static void ip_alloc_lcp2(struct ctdb_context *ctdb,
+static void ip_alloc_lcp2(struct ipalloc_state *ipalloc_state,
struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
uint32_t *force_rebalance_nodes)
@@ -2142,17 +2160,17 @@ static void ip_alloc_lcp2(struct ctdb_context *ctdb,
bool *rebalance_candidates;
int numnodes, num_rebalance_candidates, i;

- TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
+ TALLOC_CTX *tmp_ctx = talloc_new(ipalloc_state);

- unassign_unsuitable_ips(ctdb, ipflags, all_ips);
+ unassign_unsuitable_ips(ipalloc_state, ipflags, all_ips);

lcp2_init(tmp_ctx, ipflags, all_ips,force_rebalance_nodes,
&lcp2_imbalances, &rebalance_candidates);

- lcp2_allocate_unassigned(ctdb, ipflags, all_ips, lcp2_imbalances);
+ lcp2_allocate_unassigned(ipalloc_state, ipflags, all_ips, lcp2_imbalances);

/* If we don't want IPs to fail back then don't rebalance IPs. */
- if (1 == ctdb->tunable.no_ip_failback) {
+ if (1 == ipalloc_state->no_ip_failback) {
goto finished;
}

@@ -2174,7 +2192,7 @@ static void ip_alloc_lcp2(struct ctdb_context *ctdb,
/* Now, try to make sure the ip adresses are evenly distributed
across the nodes.
--
Samba Shared Repository
Michael Adam
2015-11-21 03:45:03 UTC
Permalink
The branch, master has been updated
via 0111773 samba-tool:provision: fix bug 11600
from 8fdda6f ctdb-scripts: Drop creation of database directories

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


- Log -----------------------------------------------------------------
commit 0111773310ea1ef63ab0d7b256f29aa7e27b545b
Author: Rowland Penny <***@gmail.com>
Date: Mon Nov 16 16:22:31 2015 +0000

samba-tool:provision: fix bug 11600

If you join a second DC after changing the name of
the 'Default Domain Policy' or 'Default Domain Controllers
Policy' the join will fail as the search is hardcoded to
these names, this fix changes the search to the objects name.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11600

Signed-off-by: Rowland Penny <***@gmail.com>
Reviewed-by: Michael Adam <***@samba.org>
Reviewed-by: Andreas Schneider <***@samba.org>

Autobuild-User(master): Michael Adam <***@samba.org>
Autobuild-Date(master): Sat Nov 21 04:44:58 CET 2015 on sn-devel-104

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

Summary of changes:
python/samba/provision/__init__.py | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py
index 953bd0f..b36a7d2 100644
--- a/python/samba/provision/__init__.py
+++ b/python/samba/provision/__init__.py
@@ -276,16 +276,15 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf,
names.domainlevel = int(res6[0]["msDS-Behavior-Version"][0])

# policy guid
- res7 = samdb.search(expression="(displayName=Default Domain Policy)",
+ res7 = samdb.search(expression="(name={%s})" % DEFAULT_POLICY_GUID,
base="CN=Policies,CN=System," + basedn,
scope=ldb.SCOPE_ONELEVEL, attrs=["cn","displayName"])
names.policyid = str(res7[0]["cn"]).replace("{","").replace("}","")
# dc policy guid
- res8 = samdb.search(expression="(displayName=Default Domain Controllers"
- " Policy)",
- base="CN=Policies,CN=System," + basedn,
- scope=ldb.SCOPE_ONELEVEL,
- attrs=["cn","displayName"])
+ res8 = samdb.search(expression="(name={%s})" % DEFAULT_DC_POLICY_GUID,
+ base="CN=Policies,CN=System," + basedn,
+ scope=ldb.SCOPE_ONELEVEL,
+ attrs=["cn","displayName"])
if len(res8) == 1:
names.policyid_dc = str(res8[0]["cn"]).replace("{","").replace("}","")
else:
--
Samba Shared Repository
Amitay Isaacs
2015-11-23 04:35:03 UTC
Permalink
The branch, master has been updated
via 33084a1 ctdb-ipalloc: Drop unnecessary struct ctdb_ipflags
via e73496d ctdb-ipalloc: Move memory allocation into ipalloc_state_init()
via 47c5e5a ctdb-ipalloc: Have set_ipflags_internal() set ipalloc_state->ipflags
via dd163e2 ctdb-ipalloc: Fold IP flags into IP allocation state
via 22a930a ctdb-ipalloc: Use number of nodes from IP allocation state
via 1316241 ctdb-ipalloc: Allocate memory off IP allocation state
via 921e17d ctdb-ipalloc: Add error handling to IP allocation
via 25c1093 ctdb-ipalloc: Drop CTDB context argument from set_ipflags_internal()
from 0111773 samba-tool:provision: fix bug 11600

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


- Log -----------------------------------------------------------------
commit 33084a1c2ce74464e9b6b3e8241a7265c1cfbb66
Author: Martin Schwenke <***@meltin.net>
Date: Tue Nov 3 16:41:55 2015 +1100

ctdb-ipalloc: Drop unnecessary struct ctdb_ipflags

This can be easily decomposed into 2 separate arrays.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

Autobuild-User(master): Amitay Isaacs <***@samba.org>
Autobuild-Date(master): Mon Nov 23 05:34:55 CET 2015 on sn-devel-104

commit e73496d0dc2b8485a808f57d149856baf8a93b72
Author: Martin Schwenke <***@meltin.net>
Date: Tue Nov 3 16:36:34 2015 +1100

ctdb-ipalloc: Move memory allocation into ipalloc_state_init()

This puts all of the memory allocation for ipalloc_state into its init
function. This also simplifies the code because
set_ipflags_internal() can no longer fail because it no longer
allocates memory.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 47c5e5aa14328a4cbe147dd1ef77f6fd9c69fd5c
Author: Martin Schwenke <***@meltin.net>
Date: Tue Nov 3 16:30:23 2015 +1100

ctdb-ipalloc: Have set_ipflags_internal() set ipalloc_state->ipflags

This is cleaner than returning ipflags and assigning them into
ipalloc_state afterwards.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit dd163e26d90ad8de064496cae6849c0fe83abffc
Author: Martin Schwenke <***@meltin.net>
Date: Mon Nov 2 16:50:05 2015 +1100

ctdb-ipalloc: Fold IP flags into IP allocation state

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 22a930a0454ef9b98d7d004f65fb15359910a3f6
Author: Martin Schwenke <***@meltin.net>
Date: Tue Nov 3 15:29:30 2015 +1100

ctdb-ipalloc: Use number of nodes from IP allocation state

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 13162419be0f01ea67749390b03466f97fa2df80
Author: Martin Schwenke <***@meltin.net>
Date: Tue Nov 3 15:26:34 2015 +1100

ctdb-ipalloc: Allocate memory off IP allocation state

Instead of local or passed temporary contexts.

This has the side effect of making ipalloc_state available inside the
modified functions, making future use of ipalloc_state simpler.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 921e17d81ebbcc5ec4531925f108cff37e562845
Author: Martin Schwenke <***@meltin.net>
Date: Fri Oct 30 11:47:22 2015 +1100

ctdb-ipalloc: Add error handling to IP allocation

The only likely failure is out of memory, so just return boolean
value.

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

commit 25c10936eb5a800e7f0a5874a4093581ac5da9af
Author: Martin Schwenke <***@meltin.net>
Date: Sat Oct 31 06:48:23 2015 +1100

ctdb-ipalloc: Drop CTDB context argument from set_ipflags_internal()

Signed-off-by: Martin Schwenke <***@meltin.net>
Reviewed-by: Amitay Isaacs <***@gmail.com>

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

Summary of changes:
ctdb/server/ctdb_takeover.c | 203 ++++++++++++++++++-----------------
ctdb/tests/src/ctdb_takeover_tests.c | 33 +++---
2 files changed, 116 insertions(+), 120 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index d99f9aa..00d35e1 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -48,11 +48,6 @@
#define CTDB_ARP_REPEAT 3

/* Flags used in IP allocation algorithms. */
-struct ctdb_ipflags {
- bool noiptakeover;
- bool noiphost;
-};
-
enum ipalloc_algorithm {
IPALLOC_DETERMINISTIC,
IPALLOC_NONDETERMINISTIC,
@@ -65,6 +60,8 @@ struct ipalloc_state {
/* Arrays with data for each node */
struct ctdb_public_ip_list_old **known_public_ips;
struct ctdb_public_ip_list_old **available_public_ips;
+ bool *noiptakeover;
+ bool *noiphost;

enum ipalloc_algorithm algorithm;
uint32_t no_ip_failback;
@@ -1277,13 +1274,12 @@ static int node_ip_coverage(int32_t pnn, struct public_ip_list *ips)
*/
static bool can_node_host_ip(struct ipalloc_state *ipalloc_state,
int32_t pnn,
- struct ctdb_ipflags ipflags,
struct public_ip_list *ip)
{
struct ctdb_public_ip_list_old *public_ips;
int i;

- if (ipflags.noiphost) {
+ if (ipalloc_state->noiphost[pnn]) {
return false;
}

@@ -1305,14 +1301,13 @@ static bool can_node_host_ip(struct ipalloc_state *ipalloc_state,

static bool can_node_takeover_ip(struct ipalloc_state *ipalloc_state,
int32_t pnn,
- struct ctdb_ipflags ipflags,
struct public_ip_list *ip)
{
- if (ipflags.noiptakeover) {
+ if (ipalloc_state->noiptakeover[pnn]) {
return false;
}

- return can_node_host_ip(ipalloc_state, pnn, ipflags, ip);
+ return can_node_host_ip(ipalloc_state, pnn, ip);
}

/* search the node lists list for a node to takeover this ip.
@@ -1320,18 +1315,17 @@ static bool can_node_takeover_ip(struct ipalloc_state *ipalloc_state,
so that the ips get spread out evenly.
*/
static int find_takeover_node(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
struct public_ip_list *ip,
struct public_ip_list *all_ips)
{
int pnn, min=0, num;
int i, numnodes;

- numnodes = talloc_array_length(ipflags);
+ numnodes = ipalloc_state->num;
pnn = -1;
for (i=0; i<numnodes; i++) {
/* verify that this node can serve this ip */
- if (!can_node_takeover_ip(ipalloc_state, i, ipflags[i], ip)) {
+ if (!can_node_takeover_ip(ipalloc_state, i, ip)) {
/* no it couldnt so skip to the next node */
continue;
}
@@ -1626,7 +1620,6 @@ static uint32_t lcp2_imbalance(struct public_ip_list * all_ips, int pnn)
* finding the best node for each.
*/
static void basic_allocate_unassigned(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips)
{
struct public_ip_list *tmp_ip;
@@ -1636,7 +1629,7 @@ static void basic_allocate_unassigned(struct ipalloc_state *ipalloc_state,
*/
for (tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next) {
if (tmp_ip->pnn == -1) {
- if (find_takeover_node(ipalloc_state, ipflags,
+ if (find_takeover_node(ipalloc_state,
tmp_ip, all_ips)) {
DEBUG(DEBUG_WARNING,
("Failed to find node to cover ip %s\n",
@@ -1649,7 +1642,6 @@ static void basic_allocate_unassigned(struct ipalloc_state *ipalloc_state,
/* Basic non-deterministic rebalancing algorithm.
*/
static void basic_failback(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
int num_ips)
{
@@ -1657,7 +1649,7 @@ static void basic_failback(struct ipalloc_state *ipalloc_state,
int maxnode, maxnum, minnode, minnum, num, retries;
struct public_ip_list *tmp_ip;

- numnodes = talloc_array_length(ipflags);
+ numnodes = ipalloc_state->num;
retries = 0;

try_again:
@@ -1682,7 +1674,7 @@ try_again:
for (i=0; i<numnodes; i++) {
/* only check nodes that can actually serve this ip */
if (!can_node_takeover_ip(ipalloc_state, i,
- ipflags[i], tmp_ip)) {
+ tmp_ip)) {
/* no it couldnt so skip to the next node */
continue;
}
@@ -1728,7 +1720,6 @@ try_again:
for (tmp=all_ips;tmp;tmp=tmp->next) {
if (tmp->pnn == maxnode) {
(void)find_takeover_node(ipalloc_state,
- ipflags,
tmp,
all_ips);
retries++;
@@ -1739,8 +1730,7 @@ try_again:
}
}

-static void lcp2_init(TALLOC_CTX *tmp_ctx,
- struct ctdb_ipflags *ipflags,
+static bool lcp2_init(struct ipalloc_state *ipalloc_state,
struct public_ip_list *all_ips,
uint32_t *force_rebalance_nodes,
uint32_t **lcp2_imbalances,
@@ -1749,12 +1739,18 @@ static void lcp2_init(TALLOC_CTX *tmp_ctx,
int i, numnodes;
struct public_ip_list *tmp_ip;

- numnodes = talloc_array_length(ipflags);
+ numnodes = ipalloc_state->num;

- *rebalance_candidates = talloc_array(tmp_ctx, bool, numnodes);
- CTDB_NO_MEMORY_FATAL(tmp_ctx, *rebalance_candidates);
- *lcp2_imbalances = talloc_array(tmp_ctx, uint32_t, numnodes);
- CTDB_NO_MEMORY_FATAL(tmp_ctx, *lcp2_imbalances);
+ *rebalance_candidates = talloc_array(ipalloc_state, bool, numnodes);
+ if (*rebalance_candidates == NULL) {
+ DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+ return false;
+ }
+ *lcp2_imbalances = talloc_array(ipalloc_state, uint32_t, numnodes);
+ if (*lcp2_imbalances == NULL) {
+ DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+ return false;
+ }

for (i=0; i<numnodes; i++) {
(*lcp2_imbalances)[i] = lcp2_imbalance(all_ips, i);
@@ -1778,7 +1774,7 @@ static void lcp2_init(TALLOC_CTX *tmp_ctx,
/* 3rd step: if a node is forced to re-balance then
we allow failback onto the node */
if (force_rebalance_nodes == NULL) {
- return;
+ return true;
}
for (i = 0; i < talloc_array_length(force_rebalance_nodes); i++) {
uint32_t pnn = force_rebalance_nodes[i];
@@ -1792,13 +1788,14 @@ static void lcp2_init(TALLOC_CTX *tmp_ctx,
("Forcing rebalancing of IPs to node %u\n", pnn));
(*rebalance_candidates)[pnn] = true;
}
+
+ return true;
}

/* Allocate any unassigned addresses using the LCP2 algorithm to find
* the IP/node combination that will cost the least.
*/
static void lcp2_allocate_unassigned(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
uint32_t *lcp2_imbalances)
{
@@ -1812,7 +1809,7 @@ static void lcp2_allocate_unassigned(struct ipalloc_state *ipalloc_state,
bool should_loop = true;
bool have_unassigned = true;

- numnodes = talloc_array_length(ipflags);
+ numnodes = ipalloc_state->num;

while (have_unassigned && should_loop) {
should_loop = false;
@@ -1834,7 +1831,6 @@ static void lcp2_allocate_unassigned(struct ipalloc_state *ipalloc_state,
/* only check nodes that can actually takeover this ip */
if (!can_node_takeover_ip(ipalloc_state,
dstnode,
- ipflags[dstnode],
tmp_ip)) {
/* no it couldnt so skip to the next node */
continue;
@@ -1897,7 +1893,6 @@ static void lcp2_allocate_unassigned(struct ipalloc_state *ipalloc_state,
* combination to move from the source node.
*/
static bool lcp2_failback_candidate(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
int srcnode,
uint32_t *lcp2_imbalances,
@@ -1916,7 +1911,7 @@ static bool lcp2_failback_candidate(struct ipalloc_state *ipalloc_state,
mindstnode = -1;
mindstimbl = 0;

- numnodes = talloc_array_length(ipflags);
+ numnodes = ipalloc_state->num;

DEBUG(DEBUG_DEBUG,(" ----------------------------------------\n"));
DEBUG(DEBUG_DEBUG,(" CONSIDERING MOVES FROM %d [%d]\n",
@@ -1945,7 +1940,7 @@ static bool lcp2_failback_candidate(struct ipalloc_state *ipalloc_state,

/* only check nodes that can actually takeover this ip */
if (!can_node_takeover_ip(ipalloc_state, dstnode,
- ipflags[dstnode], tmp_ip)) {
+ tmp_ip)) {
/* no it couldnt so skip to the next node */
continue;
}
@@ -2014,7 +2009,6 @@ static int lcp2_cmp_imbalance_pnn(const void * a, const void * b)
* IP/destination node combination to move from the source node.
*/
static void lcp2_failback(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips,
uint32_t *lcp2_imbalances,
bool *rebalance_candidates)
@@ -2023,7 +2017,7 @@ static void lcp2_failback(struct ipalloc_state *ipalloc_state,
struct lcp2_imbalance_pnn * lips;
bool again;

- numnodes = talloc_array_length(ipflags);
+ numnodes = ipalloc_state->num;

try_again:
/* Put the imbalances and nodes into an array, sort them and
@@ -2051,7 +2045,6 @@ try_again:
}

if (lcp2_failback_candidate(ipalloc_state,
- ipflags,
all_ips,
lips[i].pnn,
lcp2_imbalances,
@@ -2068,7 +2061,6 @@ try_again:
}

static void unassign_unsuitable_ips(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
struct public_ip_list *all_ips)
{
struct public_ip_list *tmp_ip;
@@ -2081,7 +2073,7 @@ static void unassign_unsuitable_ips(struct ipalloc_state *ipalloc_state,
continue;
}
if (!can_node_host_ip(ipalloc_state, tmp_ip->pnn,
- ipflags[tmp_ip->pnn], tmp_ip) != 0) {
+ tmp_ip) != 0) {
/* this node can not serve this ip. */
DEBUG(DEBUG_DEBUG,("Unassign IP: %s from %d\n",
ctdb_addr_to_str(&(tmp_ip->addr)),
@@ -2091,14 +2083,13 @@ static void unassign_unsuitable_ips(struct ipalloc_state *ipalloc_state,
}
}

-static void ip_alloc_deterministic_ips(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
+static bool ip_alloc_deterministic_ips(struct ipalloc_state *ipalloc_state,
struct public_ip_list *all_ips)
{
struct public_ip_list *tmp_ip;
int i, numnodes;

- numnodes = talloc_array_length(ipflags);
+ numnodes = ipalloc_state->num;

DEBUG(DEBUG_NOTICE,("Deterministic IPs enabled. Resetting all ip allocations\n"));
/* Allocate IPs to nodes in a modulo fashion so that IPs will
@@ -2118,15 +2109,16 @@ static void ip_alloc_deterministic_ips(struct ipalloc_state *ipalloc_state,
DEBUG(DEBUG_WARNING, ("WARNING: 'NoIPFailback' set but ignored - incompatible with 'DeterministicIPs\n"));
}

- unassign_unsuitable_ips(ipalloc_state, ipflags, all_ips);
+ unassign_unsuitable_ips(ipalloc_state, all_ips);

- basic_allocate_unassigned(ipalloc_state, ipflags, all_ips);
+ basic_allocate_unassigned(ipalloc_state, all_ips);

/* No failback here! */
+
+ return true;
}

-static void ip_alloc_nondeterministic_ips(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
+static bool ip_alloc_nondeterministic_ips(struct ipalloc_state *ipalloc_state,
struct public_ip_list *all_ips)
{
/* This should be pushed down into basic_failback. */
@@ -2136,38 +2128,41 @@ static void ip_alloc_nondeterministic_ips(struct ipalloc_state *ipalloc_state,
num_ips++;
}

- unassign_unsuitable_ips(ipalloc_state, ipflags, all_ips);
+ unassign_unsuitable_ips(ipalloc_state, all_ips);

- basic_allocate_unassigned(ipalloc_state, ipflags, all_ips);
+ basic_allocate_unassigned(ipalloc_state, all_ips);

/* If we don't want IPs to fail back then don't rebalance IPs. */
if (1 == ipalloc_state->no_ip_failback) {
- return;
+ return true;
}

/* Now, try to make sure the ip adresses are evenly distributed
across the nodes.
*/
- basic_failback(ipalloc_state, ipflags, all_ips, num_ips);
+ basic_failback(ipalloc_state, all_ips, num_ips);
+
+ return true;
}

-static void ip_alloc_lcp2(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
+static bool ip_alloc_lcp2(struct ipalloc_state *ipalloc_state,
struct public_ip_list *all_ips,
uint32_t *force_rebalance_nodes)
{
uint32_t *lcp2_imbalances;
bool *rebalance_candidates;
int numnodes, num_rebalance_candidates, i;
+ bool ret = true;

- TALLOC_CTX *tmp_ctx = talloc_new(ipalloc_state);
-
- unassign_unsuitable_ips(ipalloc_state, ipflags, all_ips);
+ unassign_unsuitable_ips(ipalloc_state, all_ips);

- lcp2_init(tmp_ctx, ipflags, all_ips,force_rebalance_nodes,
- &lcp2_imbalances, &rebalance_candidates);
+ if (!lcp2_init(ipalloc_state, all_ips,force_rebalance_nodes,
+ &lcp2_imbalances, &rebalance_candidates)) {
+ ret = false;
+ goto finished;
+ }

- lcp2_allocate_unassigned(ipalloc_state, ipflags, all_ips, lcp2_imbalances);
+ lcp2_allocate_unassigned(ipalloc_state, all_ips, lcp2_imbalances);

/* If we don't want IPs to fail back then don't rebalance IPs. */
if (1 == ipalloc_state->no_ip_failback) {
@@ -2178,7 +2173,7 @@ static void ip_alloc_lcp2(struct ipalloc_state *ipalloc_state,
* nodes to transfer IPs to. This check is much cheaper than
* continuing on...
*/
- numnodes = talloc_array_length(ipflags);
+ numnodes = ipalloc_state->num;
num_rebalance_candidates = 0;
for (i=0; i<numnodes; i++) {
if (rebalance_candidates[i]) {
@@ -2192,11 +2187,11 @@ static void ip_alloc_lcp2(struct ipalloc_state *ipalloc_state,
/* Now, try to make sure the ip adresses are evenly distributed
across the nodes.
*/
- lcp2_failback(ipalloc_state, ipflags, all_ips,
+ lcp2_failback(ipalloc_state, all_ips,
lcp2_imbalances, rebalance_candidates);

finished:
- talloc_free(tmp_ctx);
+ return ret;
}

static bool all_nodes_are_disabled(struct ctdb_node_map_old *nodemap)
@@ -2214,21 +2209,22 @@ static bool all_nodes_are_disabled(struct ctdb_node_map_old *nodemap)
}

/* The calculation part of the IP allocation algorithm. */
-static void ctdb_takeover_run_core(struct ipalloc_state *ipalloc_state,
- struct ctdb_ipflags *ipflags,
+static bool ctdb_takeover_run_core(struct ipalloc_state *ipalloc_state,
struct public_ip_list *all_ips,
uint32_t *force_rebalance_nodes)
{
+ bool ret;
+
switch (ipalloc_state->algorithm) {
case IPALLOC_LCP2:
- ip_alloc_lcp2(ipalloc_state, ipflags, all_ips,
- force_rebalance_nodes);
+ ret = ip_alloc_lcp2(ipalloc_state, all_ips,
+ force_rebalance_nodes);
break;
case IPALLOC_DETERMINISTIC:
- ip_alloc_deterministic_ips(ipalloc_state, ipflags, all_ips);
+ ret = ip_alloc_deterministic_ips(ipalloc_state, all_ips);
break;
case IPALLOC_NONDETERMINISTIC:
- ip_alloc_nondeterministic_ips(ipalloc_state, ipflags, all_ips);
+ ret = ip_alloc_nondeterministic_ips(ipalloc_state, all_ips);
break;
}

@@ -2236,7 +2232,7 @@ static void ctdb_takeover_run_core(struct ipalloc_state *ipalloc_state,
or -1 if there is no node that can cover this ip
*/

- return;
+ return ret;
}

struct get_tunable_callback_data {
@@ -2360,29 +2356,22 @@ static uint32_t *get_tunable_from_nodes(struct ctdb_context *ctdb,
* else
* Set NOIPHOST ip flags for disabled nodes
*/
-static struct ctdb_ipflags *
-set_ipflags_internal(struct ctdb_context *ctdb,
- TALLOC_CTX *tmp_ctx,
- struct ctdb_node_map_old *nodemap,
- uint32_t *tval_noiptakeover,
- uint32_t *tval_noiphostonalldisabled)
+static void set_ipflags_internal(struct ipalloc_state *ipalloc_state,
+ struct ctdb_node_map_old *nodemap,
+ uint32_t *tval_noiptakeover,
+ uint32_t *tval_noiphostonalldisabled)
{
int i;
- struct ctdb_ipflags *ipflags;
-
- /* Clear IP flags - implicit due to talloc_zero */
- ipflags = talloc_zero_array(tmp_ctx, struct ctdb_ipflags, nodemap->num);
- CTDB_NO_MEMORY_NULL(ctdb, ipflags);

for (i=0;i<nodemap->num;i++) {
/* Can not take IPs on node with NoIPTakeover set */
if (tval_noiptakeover[i] != 0) {
- ipflags[i].noiptakeover = true;
+ ipalloc_state->noiptakeover[i] = true;
}

/* Can not host IPs on INACTIVE node */
if (nodemap->nodes[i].flags & NODE_FLAGS_INACTIVE) {
- ipflags[i].noiphost = true;
+ ipalloc_state->noiphost[i] = true;
}
}

@@ -2392,7 +2381,7 @@ set_ipflags_internal(struct ctdb_context *ctdb,
*/
for (i=0;i<nodemap->num;i++) {
if (tval_noiphostonalldisabled[i] != 0) {
- ipflags[i].noiphost = true;
+ ipalloc_state->noiphost[i] = true;
}
}
} else {
@@ -2401,45 +2390,41 @@ set_ipflags_internal(struct ctdb_context *ctdb,
*/
for (i=0;i<nodemap->num;i++) {
if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) {
- ipflags[i].noiphost = true;
+ ipalloc_state->noiphost[i] = true;
}
}
}
-
- return ipflags;
}

-static struct ctdb_ipflags *set_ipflags(struct ctdb_context *ctdb,
- TALLOC_CTX *tmp_ctx,
- struct ctdb_node_map_old *nodemap)
+static bool set_ipflags(struct ctdb_context *ctdb,
+ struct ipalloc_state *ipalloc_state,
+ struct ctdb_node_map_old *nodemap)
{
uint32_t *tval_noiptakeover;
uint32_t *tval_noiphostonalldisabled;
- struct ctdb_ipflags *ipflags;
-

- tval_noiptakeover = get_tunable_from_nodes(ctdb, tmp_ctx, nodemap,
+ tval_noiptakeover = get_tunable_from_nodes(ctdb, ipalloc_state, nodemap,
"NoIPTakeover", 0);
if (tval_noiptakeover == NULL) {
--
Samba Shared Repository
Ralph Böhme
2015-11-23 14:17:04 UTC
Permalink
The branch, master has been updated
via 8aab442 dbwrap_tdb: Fix a typo
from 33084a1 ctdb-ipalloc: Drop unnecessary struct ctdb_ipflags

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


- Log -----------------------------------------------------------------
commit 8aab4426a5235c60d3febabad075985e1f9777f0
Author: Volker Lendecke <***@samba.org>
Date: Tue Oct 20 14:00:54 2015 +0200

dbwrap_tdb: Fix a typo

Signed-off-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

Autobuild-User(master): Ralph Böhme <***@samba.org>
Autobuild-Date(master): Mon Nov 23 15:16:19 CET 2015 on sn-devel-104

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

Summary of changes:
lib/dbwrap/dbwrap_tdb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/lib/dbwrap/dbwrap_tdb.c b/lib/dbwrap/dbwrap_tdb.c
index 0e54449..e12ec44 100644
--- a/lib/dbwrap/dbwrap_tdb.c
+++ b/lib/dbwrap/dbwrap_tdb.c
@@ -405,7 +405,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
int hash_size, int tdb_flags,
int open_flags, mode_t mode,
enum dbwrap_lock_order lock_order,
- uint64_t dbrwap_flags)
+ uint64_t dbwrap_flags)
{
struct db_context *result = NULL;
struct db_tdb_ctx *db_tdb;
--
Samba Shared Repository
GÃŒnther Deschner
2015-11-23 17:21:02 UTC
Permalink
The branch, master has been updated
via e6f88c1 libads: Fix picky const warning with krb5_set_password_using_ccache
via 0733ce3 gensec: Fix picky unused variable errors
via ab0cbf9 auth: Fix picky const warnings in gssapi_pac
via e0504a8 s4-auth: Fix picky unused variable warning
via e9e306b krb5_wrap: Fix picky const compiler warnings
via bf10446 selftest: Fix Samba::bindir_path() with a valid directory.
from 8aab442 dbwrap_tdb: Fix a typo

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


- Log -----------------------------------------------------------------
commit e6f88c1451f8843fca9ca361cd2dbdf3e77ff47c
Author: Andreas Schneider <***@samba.org>
Date: Tue Oct 6 14:05:15 2015 +0200

libads: Fix picky const warning with krb5_set_password_using_ccache

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Guenther Deschner <***@samba.org>

Autobuild-User(master): Günther Deschner <***@samba.org>
Autobuild-Date(master): Mon Nov 23 18:20:31 CET 2015 on sn-devel-104

commit 0733ce3c6ed1e8d97690c9ec80c2768a05690dfd
Author: Andreas Schneider <***@samba.org>
Date: Tue Oct 6 13:25:49 2015 +0200

gensec: Fix picky unused variable errors

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Guenther Deschner <***@samba.org>

commit ab0cbf9bbac6c7a9450f26e2eeb4f8e794db8d89
Author: Andreas Schneider <***@samba.org>
Date: Tue Oct 6 13:24:41 2015 +0200

auth: Fix picky const warnings in gssapi_pac

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Guenther Deschner <***@samba.org>

commit e0504a80dcf70ec9da0e8fa9f2d5bd7f042468f6
Author: Andreas Schneider <***@samba.org>
Date: Tue Oct 6 13:03:41 2015 +0200

s4-auth: Fix picky unused variable warning

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Guenther Deschner <***@samba.org>

commit e9e306b1d57e9d9c40cd37d3fbb981606ca87223
Author: Andreas Schneider <***@samba.org>
Date: Tue Oct 6 13:03:19 2015 +0200

krb5_wrap: Fix picky const compiler warnings

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Guenther Deschner <***@samba.org>

commit bf10446a69b0f328441ab334a8e35ad14c3d47e8
Author: Andreas Schneider <***@samba.org>
Date: Mon May 12 16:45:55 2014 +0200

selftest: Fix Samba::bindir_path() with a valid directory.

Signed-off-by: Andreas Schneider <***@samba.org>
Reviewed-by: Guenther Deschner <***@samba.org>

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

Summary of changes:
auth/kerberos/gssapi_pac.c | 12 ++++++++++--
lib/krb5_wrap/krb5_samba.c | 5 +++--
selftest/target/Samba.pm | 2 +-
source3/libads/krb5_setpw.c | 13 ++++++++++---
source4/auth/gensec/gensec_gssapi.c | 4 +++-
source4/auth/kerberos/kerberos_util.c | 4 ++++
6 files changed, 31 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/auth/kerberos/gssapi_pac.c b/auth/kerberos/gssapi_pac.c
index c6fa909..685d0ec 100644
--- a/auth/kerberos/gssapi_pac.c
+++ b/auth/kerberos/gssapi_pac.c
@@ -113,7 +113,11 @@ NTSTATUS gssapi_obtain_pac_blob(TALLOC_CTX *mem_ctx,

if (gss_maj != 0) {
DEBUG(0, ("obtaining PAC via GSSAPI gss_get_name_attribute failed: %s\n",
- gssapi_error_string(mem_ctx, gss_maj, gss_min, gss_mech_krb5)));
+ gssapi_error_string(mem_ctx,
+ gss_maj,
+ gss_min,
+ discard_const_p(struct gss_OID_desc_struct,
+ gss_mech_krb5))));
return NT_STATUS_ACCESS_DENIED;
} else if (authenticated && complete) {
/* The PAC blob is returned directly */
@@ -199,7 +203,11 @@ NTSTATUS gssapi_get_session_key(TALLOC_CTX *mem_ctx,
&gse_sesskey_inq_oid, &set);
if (gss_maj) {
DEBUG(0, ("gss_inquire_sec_context_by_oid failed [%s]\n",
- gssapi_error_string(mem_ctx, gss_maj, gss_min, gss_mech_krb5)));
+ gssapi_error_string(mem_ctx,
+ gss_maj,
+ gss_min,
+ discard_const_p(struct gss_OID_desc_struct,
+ gss_mech_krb5))));
return NT_STATUS_NO_USER_SESSION_KEY;
}

diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c
index 8c70273..13984e9 100644
--- a/lib/krb5_wrap/krb5_samba.c
+++ b/lib/krb5_wrap/krb5_samba.c
@@ -2143,7 +2143,7 @@ krb5_error_code smb_krb5_make_principal(krb5_context context,
va_list ap;

if (_realm) {
- realm = _realm;
+ realm = discard_const_p(char, _realm);
free_realm = false;
} else {
code = krb5_get_default_realm(context, &realm);
@@ -2324,7 +2324,8 @@ char *smb_krb5_principal_get_realm(krb5_context context,
return strdup(discard_const_p(char, krb5_principal_get_realm(context, principal)));
#elif defined(krb5_princ_realm) /* MIT */
krb5_data *realm;
- realm = krb5_princ_realm(context, principal);
+ realm = discard_const_p(krb5_data,
+ krb5_princ_realm(context, principal));
return strndup(realm->data, realm->length);
#else
#error UNKNOWN_GET_PRINC_REALM_FUNCTIONS
diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm
index 9f3e6ec..f1c4055 100644
--- a/selftest/target/Samba.pm
+++ b/selftest/target/Samba.pm
@@ -57,7 +57,7 @@ sub bindir_path($$) {

my $valpath = "$object->{bindir}/$path";

- return $valpath if (-f $valpath);
+ return $valpath if (-f $valpath or -d $valpath);
return $path;
}

diff --git a/source3/libads/krb5_setpw.c b/source3/libads/krb5_setpw.c
index 5b33e2e..c633495 100644
--- a/source3/libads/krb5_setpw.c
+++ b/source3/libads/krb5_setpw.c
@@ -98,7 +98,10 @@ ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *principal,
return ADS_ERROR_KRB5(ret);
}

- ret = krb5_set_password_using_ccache(context, ccache, newpw, princ,
+ ret = krb5_set_password_using_ccache(context,
+ ccache,
+ discard_const_p(char, newpw),
+ princ,
&result_code,
&result_code_string,
&result_string);
@@ -236,8 +239,12 @@ static ADS_STATUS ads_krb5_chg_password(const char *kdc_host,
return ADS_ERROR_KRB5(ret);
}

- ret = krb5_change_password(context, &creds, newpw, &result_code,
- &result_code_string, &result_string);
+ ret = krb5_change_password(context,
+ &creds,
+ discard_const_p(char, newpw),
+ &result_code,
+ &result_code_string,
+ &result_string);
if (ret) {
DEBUG(1, ("krb5_change_password failed (%s)\n", error_message(ret)));
aret = ADS_ERROR_KRB5(ret);
diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c
index ed6d08a..e0b2bf2 100644
--- a/source4/auth/gensec/gensec_gssapi.c
+++ b/source4/auth/gensec/gensec_gssapi.c
@@ -87,7 +87,9 @@ static NTSTATUS gensec_gssapi_start(struct gensec_security *gensec_security)
{
struct gensec_gssapi_state *gensec_gssapi_state;
krb5_error_code ret;
+#ifdef SAMBA4_USES_HEIMDAL
const char *realm;
+#endif

gensec_gssapi_state = talloc_zero(gensec_security, struct gensec_gssapi_state);
if (!gensec_gssapi_state) {
@@ -417,8 +419,8 @@ static NTSTATUS gensec_gssapi_update(struct gensec_security *gensec_security,
{
#ifdef SAMBA4_USES_HEIMDAL
struct gsskrb5_send_to_kdc send_to_kdc;
-#endif
krb5_error_code ret;
+#endif

nt_status = gensec_gssapi_client_creds(gensec_security, ev);
if (!NT_STATUS_IS_OK(nt_status)) {
diff --git a/source4/auth/kerberos/kerberos_util.c b/source4/auth/kerberos/kerberos_util.c
index 2026af3..653e3d2 100644
--- a/source4/auth/kerberos/kerberos_util.c
+++ b/source4/auth/kerberos/kerberos_util.c
@@ -235,7 +235,9 @@ done:
{
krb5_error_code ret;
const char *password;
+#ifdef SAMBA4_USES_HEIMDAL
const char *self_service;
+#endif
const char *target_service;
time_t kdc_time = 0;
krb5_principal princ;
@@ -267,7 +269,9 @@ done:
return ret;
}

+#ifdef SAMBA4_USES_HEIMDAL
self_service = cli_credentials_get_self_service(credentials);
+#endif
target_service = cli_credentials_get_target_service(credentials);

password = cli_credentials_get_password(credentials);
--
Samba Shared Repository
Uri Simchoni
2015-11-23 21:20:03 UTC
Permalink
The branch, master has been updated
via 22386dc samba-tool: replace use of os.popen
from e6f88c1 libads: Fix picky const warning with krb5_set_password_using_ccache

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


- Log -----------------------------------------------------------------
commit 22386dc39673f66de2dd57596447acf3c6c00ef7
Author: Uri Simchoni <***@samba.org>
Date: Sun Nov 15 13:34:03 2015 +0200

samba-tool: replace use of os.popen

The netcmd/domain.py module uses os.popen() on user-supplied
parameters. This opens up the way to code injection.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11601

Signed-off-by: Uri Simchoni <***@samba.org>
Reviewed-by: Alexander Bokovoy <***@samba.org>

Autobuild-User(master): Uri Simchoni <***@samba.org>
Autobuild-Date(master): Mon Nov 23 22:19:34 CET 2015 on sn-devel-104

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

Summary of changes:
python/samba/netcmd/domain.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index 6726538..62f8bfa 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -31,6 +31,7 @@ import ctypes
import random
import tempfile
import logging
+import subprocess
from getpass import getpass
from samba.net import Net, LIBNET_JOIN_AUTOMATIC
import samba.ntacls
@@ -87,9 +88,16 @@ from samba.provision.common import (
)

def get_testparm_var(testparm, smbconf, varname):
- cmd = "%s -s -l --parameter-name='%s' %s 2>/dev/null" % (testparm, varname, smbconf)
- output = os.popen(cmd, 'r').readline()
- return output.strip()
+ errfile = open(os.devnull, 'w')
+ p = subprocess.Popen([testparm, '-s', '-l',
+ '--parameter-name=%s' % varname, smbconf],
+ stdout=subprocess.PIPE, stderr=errfile)
+ (out,err) = p.communicate()
+ errfile.close()
+ lines = out.split('\n')
+ if lines:
+ return lines[0].strip()
+ return ""

try:
import samba.dckeytab
--
Samba Shared Repository
Continue reading on narkive:
Loading...