svn commit: samba r21870 - in branches/SAMBA_3_0/source: auth
include smbd
vlendec at samba.org
vlendec at samba.org
Sun Mar 18 11:24:13 GMT 2007
Author: vlendec
Date: 2007-03-18 11:24:10 +0000 (Sun, 18 Mar 2007)
New Revision: 21870
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21870
Log:
Move sending auth_server keepalives out of the main loop into an idle event.
Volker
Modified:
branches/SAMBA_3_0/source/auth/auth.c
branches/SAMBA_3_0/source/auth/auth_server.c
branches/SAMBA_3_0/source/include/auth.h
branches/SAMBA_3_0/source/smbd/process.c
Changeset:
Modified: branches/SAMBA_3_0/source/auth/auth.c
===================================================================
--- branches/SAMBA_3_0/source/auth/auth.c 2007-03-18 10:57:46 UTC (rev 21869)
+++ branches/SAMBA_3_0/source/auth/auth.c 2007-03-18 11:24:10 UTC (rev 21870)
@@ -333,10 +333,7 @@
if (*auth_context) {
/* Free private data of context's authentication methods */
for (auth_method = (*auth_context)->auth_method_list; auth_method; auth_method = auth_method->next) {
- if (auth_method->free_private_data) {
- auth_method->free_private_data (&auth_method->private_data);
- auth_method->private_data = NULL;
- }
+ TALLOC_FREE(auth_method->private_data);
}
talloc_destroy((*auth_context)->mem_ctx);
Modified: branches/SAMBA_3_0/source/auth/auth_server.c
===================================================================
--- branches/SAMBA_3_0/source/auth/auth_server.c 2007-03-18 10:57:46 UTC (rev 21869)
+++ branches/SAMBA_3_0/source/auth/auth_server.c 2007-03-18 11:24:10 UTC (rev 21870)
@@ -136,38 +136,72 @@
return cli;
}
+struct server_security_state {
+ struct cli_state *cli;
+};
+
/****************************************************************************
- Clean up our allocated cli.
+ Send a 'keepalive' packet down the cli pipe.
****************************************************************************/
-static void free_server_private_data(void **private_data_pointer)
+static BOOL send_server_keepalive(const struct timeval *now,
+ void *private_data)
{
- struct cli_state **cli = (struct cli_state **)private_data_pointer;
- if (*cli && (*cli)->initialised) {
- DEBUG(10, ("Shutting down smbserver connection\n"));
- cli_shutdown(*cli);
+ struct server_security_state *state = talloc_get_type_abort(
+ private_data, struct server_security_state);
+
+ if (!state->cli || !state->cli->initialised) {
+ return False;
}
- *private_data_pointer = NULL;
+
+ if (send_keepalive(state->cli->fd)) {
+ return True;
+ }
+
+ DEBUG( 2, ( "send_server_keepalive: password server keepalive "
+ "failed.\n"));
+ cli_shutdown(state->cli);
+ state->cli = NULL;
+ return False;
}
-/****************************************************************************
- Send a 'keepalive' packet down the cli pipe.
-****************************************************************************/
+static int destroy_server_security(struct server_security_state *state)
+{
+ if (state->cli) {
+ cli_shutdown(state->cli);
+ }
+ return 0;
+}
-static void send_server_keepalive(void **private_data_pointer)
+static struct server_security_state *make_server_security_state(struct cli_state *cli)
{
- /* also send a keepalive to the password server if its still
- connected */
- if (private_data_pointer) {
- struct cli_state *cli = (struct cli_state *)(*private_data_pointer);
- if (cli && cli->initialised) {
- if (!send_keepalive(cli->fd)) {
- DEBUG( 2, ( "send_server_keepalive: password server keepalive failed.\n"));
- cli_shutdown(cli);
- *private_data_pointer = NULL;
- }
+ struct server_security_state *result;
+
+ if (!(result = talloc(NULL, struct server_security_state))) {
+ DEBUG(0, ("talloc failed\n"));
+ cli_shutdown(cli);
+ return NULL;
+ }
+
+ result->cli = cli;
+ talloc_set_destructor(result, destroy_server_security);
+
+ if (lp_keepalive() != 0) {
+ struct timeval interval;
+ interval.tv_sec = lp_keepalive();
+ interval.tv_usec = 0;
+
+ if (event_add_idle(smbd_event_context(), result, interval,
+ "server_security_keepalive",
+ send_server_keepalive,
+ result) == NULL) {
+ DEBUG(0, ("event_add_idle failed\n"));
+ TALLOC_FREE(result);
+ return NULL;
}
}
+
+ return result;
}
/****************************************************************************
@@ -190,7 +224,8 @@
/* However, it is still a perfectly fine connection
to pass that unencrypted password over */
- *my_private_data = (void *)cli;
+ *my_private_data =
+ (void *)make_server_security_state(cli);
return data_blob(NULL, 0);
} else if (cli->secblob.length < 8) {
@@ -200,7 +235,9 @@
return data_blob(NULL, 0);
}
- *my_private_data = (void *)cli;
+ if (!(*my_private_data = (void *)make_server_security_state(cli))) {
+ return data_blob(NULL,0);
+ }
/* The return must be allocated on the caller's mem_ctx, as our own will be
destoyed just after the call. */
@@ -415,8 +452,6 @@
(*auth_method)->name = "smbserver";
(*auth_method)->auth = check_smbserver_security;
(*auth_method)->get_chal = auth_get_challenge_server;
- (*auth_method)->send_keepalive = send_server_keepalive;
- (*auth_method)->free_private_data = free_server_private_data;
return NT_STATUS_OK;
}
Modified: branches/SAMBA_3_0/source/include/auth.h
===================================================================
--- branches/SAMBA_3_0/source/include/auth.h 2007-03-18 10:57:46 UTC (rev 21869)
+++ branches/SAMBA_3_0/source/include/auth.h 2007-03-18 11:24:10 UTC (rev 21870)
@@ -115,13 +115,7 @@
/* Used to keep tabs on things like the cli for SMB server authentication */
void *private_data;
-
- /* Function to clean up the above arbitary structure */
- void (*free_private_data)(void **private_data);
- /* Function to send a keepalive message on the above structure */
- void (*send_keepalive)(void **private_data);
-
} auth_methods;
typedef NTSTATUS (*auth_init_function)(struct auth_context *, const char *, struct auth_methods **);
Modified: branches/SAMBA_3_0/source/smbd/process.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/process.c 2007-03-18 10:57:46 UTC (rev 21869)
+++ branches/SAMBA_3_0/source/smbd/process.c 2007-03-18 11:24:10 UTC (rev 21870)
@@ -1328,7 +1328,6 @@
static BOOL timeout_processing(int *select_timeout,
time_t *last_timeout_processing_time)
{
- static time_t last_keepalive_sent_time = 0;
static time_t last_idle_closed_check = 0;
time_t t;
BOOL allidle = True;
@@ -1351,9 +1350,6 @@
*last_timeout_processing_time = t = time(NULL);
- if(last_keepalive_sent_time == 0)
- last_keepalive_sent_time = t;
-
if(last_idle_closed_check == 0)
last_idle_closed_check = t;
@@ -1371,20 +1367,6 @@
last_idle_closed_check = t;
}
- if (lp_keepalive() && (t - last_keepalive_sent_time)> lp_keepalive()) {
- /* send a keepalive for a password server or the like.
- This is attached to the auth_info created in the
- negprot */
- if (negprot_global_auth_context && negprot_global_auth_context->challenge_set_method
- && negprot_global_auth_context->challenge_set_method->send_keepalive) {
-
- negprot_global_auth_context->challenge_set_method->send_keepalive
- (&negprot_global_auth_context->challenge_set_method->private_data);
- }
-
- last_keepalive_sent_time = t;
- }
-
/* check for connection timeouts */
allidle = conn_idle_all(t);
More information about the samba-cvs
mailing list