[SCM] Samba Shared Repository - branch v3-3-test updated -
release-3-2-0pre2-3564-gd52b9be
Michael Adam
obnox at samba.org
Fri Aug 8 23:19:58 GMT 2008
The branch, v3-3-test has been updated
via d52b9beede1fb14e1d7e3acd9765d6cd14dfcc3d (commit)
via 363eb90ce8380ce1bbc74673936ba1e6d7eee23b (commit)
via f7c1f85438f7e0da2a96e3fc8f774f8c6936370e (commit)
via 742bedce417c666b5e91d8d0a7dc7682dc62eba2 (commit)
via 1b2dec93b635dfd23af78a370c223ea2dd486aa7 (commit)
from 7686752c5b015b15a6729631ba4aeedd25ebc659 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test
- Log -----------------------------------------------------------------
commit d52b9beede1fb14e1d7e3acd9765d6cd14dfcc3d
Author: Michael Adam <obnox at samba.org>
Date: Sat Aug 9 01:04:55 2008 +0200
nmbd: add support for delayed initial samlogon packages.
The hosts or networks configured with "init logon delayed hosts"
have their initial samlogon packages (empty username) delayed
by the value configured with "init logon delay" (defaulting
to 100 milliseconds).
This gives the administrator some control over what clients would
consider the preferred logon server: they choose the server that
repsonds most quickly.
Michael
commit 363eb90ce8380ce1bbc74673936ba1e6d7eee23b
Author: Michael Adam <obnox at samba.org>
Date: Sat Aug 9 01:03:06 2008 +0200
nmbd_packets: make queue_packet() public.
Michael
commit f7c1f85438f7e0da2a96e3fc8f774f8c6936370e
Author: Michael Adam <obnox at samba.org>
Date: Sat Aug 9 00:31:48 2008 +0200
loadparm: add two parameters "init logon delay hosts" and "init logon delay"
"init logon delays hosts" takes a list of hosts names or addresses
or networks for which the initial SAMLOGON reply should be delayed
(so other DCs get preferred by XP workstations if there are any).
This option takes the same type of list as "hosts allow" does.
"init logon delay" allows one to configure the delay for the hosts
configured for delayed initial samlogon with "init logon delayed hosts".
The value is interpreted as milliseconds. The default value is 100.
This commit only introduces the parameters.
They will be activated in a subsequent commit.
Michael
commit 742bedce417c666b5e91d8d0a7dc7682dc62eba2
Author: Michael Adam <obnox at samba.org>
Date: Sat Aug 9 00:05:38 2008 +0200
lib/access: make list_match() public.
Michael
commit 1b2dec93b635dfd23af78a370c223ea2dd486aa7
Author: Michael Adam <obnox at samba.org>
Date: Sat Aug 9 00:03:23 2008 +0200
lib/access: make client_match() public.
Michael
-----------------------------------------------------------------------
Summary of changes:
source/include/proto.h | 6 +++
source/lib/access.c | 4 +-
source/nmbd/nmbd_packets.c | 4 +-
source/nmbd/nmbd_processlogon.c | 92 ++++++++++++++++++++++++++++++++++++---
source/param/loadparm.c | 24 ++++++++++
5 files changed, 119 insertions(+), 11 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/include/proto.h b/source/include/proto.h
index 01b7a35..b5a1bfa 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -293,6 +293,9 @@ char *lang_tdb_current(void);
/* The following definitions come from lib/access.c */
+bool client_match(const char *tok, const void *item);
+bool list_match(const char **list,const void *item,
+ bool (*match_fn)(const char *, const void *));
bool allow_access(const char **deny_list,
const char **allow_list,
const char *cname,
@@ -5634,6 +5637,7 @@ struct response_record *queue_node_status( struct subnet_record *subrec,
void reply_netbios_packet(struct packet_struct *orig_packet,
int rcode, enum netbios_reply_type_code rcv_code, int opcode,
int ttl, char *data,int len);
+void queue_packet(struct packet_struct *packet);
void run_packet_queue(void);
void retransmit_or_expire_response_records(time_t t);
bool listen_for_packets(bool run_election);
@@ -5872,6 +5876,8 @@ bool lp_we_are_a_wins_server(void);
bool lp_wins_proxy(void);
bool lp_local_master(void);
bool lp_domain_logons(void);
+const char **lp_init_logon_delayed_hosts(void);
+int lp_init_logon_delay(void);
bool lp_load_printers(void);
bool lp_readraw(void);
bool lp_large_readwrite(void);
diff --git a/source/lib/access.c b/source/lib/access.c
index db5d007..6a445f8 100644
--- a/source/lib/access.c
+++ b/source/lib/access.c
@@ -175,7 +175,7 @@ static bool string_match(const char *tok,const char *s)
}
/* client_match - match host name and address against token */
-static bool client_match(const char *tok, const void *item)
+bool client_match(const char *tok, const void *item)
{
const char **client = (const char **)item;
@@ -211,7 +211,7 @@ static bool client_match(const char *tok, const void *item)
}
/* list_match - match an item against a list of tokens with exceptions */
-static bool list_match(const char **list,const void *item,
+bool list_match(const char **list,const void *item,
bool (*match_fn)(const char *, const void *))
{
bool match = false;
diff --git a/source/nmbd/nmbd_packets.c b/source/nmbd/nmbd_packets.c
index c1d373a..4b97819 100644
--- a/source/nmbd/nmbd_packets.c
+++ b/source/nmbd/nmbd_packets.c
@@ -28,8 +28,6 @@ extern int global_nmb_port;
extern int num_response_packets;
-static void queue_packet(struct packet_struct *packet);
-
bool rescan_listen_set = False;
@@ -1004,7 +1002,7 @@ for id %hu\n", packet_type, nmb_namestr(&orig_nmb->question.question_name),
Queue a packet into a packet queue
******************************************************************/
-static void queue_packet(struct packet_struct *packet)
+void queue_packet(struct packet_struct *packet)
{
struct packet_struct *p;
diff --git a/source/nmbd/nmbd_processlogon.c b/source/nmbd/nmbd_processlogon.c
index 6e110dd..f7990de 100644
--- a/source/nmbd/nmbd_processlogon.c
+++ b/source/nmbd/nmbd_processlogon.c
@@ -31,6 +31,40 @@ struct sam_database_info {
uint32 date_lo, date_hi;
};
+/**
+ * check whether the client belongs to the hosts
+ * for which initial logon should be delayed...
+ */
+static bool delay_logon(const char *peer_name, const char *peer_addr)
+{
+ const char **delay_list = lp_init_logon_delayed_hosts();
+ const char *peer[2];
+
+ if (delay_list == NULL) {
+ return False;
+ }
+
+ peer[0] = peer_name;
+ peer[1] = peer_addr;
+
+ return list_match(delay_list, (const char *)peer, client_match);
+}
+
+static void delayed_init_logon_handler(struct event_context *event_ctx,
+ struct timed_event *te,
+ const struct timeval *now,
+ void *private_data)
+{
+ struct packet_struct *p = (struct packet_struct *)private_data;
+
+ DEBUG(10, ("delayed_init_logon_handler (%lx): re-queuing packet.\n",
+ (unsigned long)te));
+
+ queue_packet(p);
+
+ TALLOC_FREE(te);
+}
+
/****************************************************************************
Process a domain logon packet
**************************************************************************/
@@ -280,6 +314,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
{
fstring getdc_str;
fstring source_name;
+ char *source_addr;
char *q = buf + 2;
fstring asccomp;
@@ -591,13 +626,58 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
pull_ascii_fstring(getdc_str, getdc);
pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
+ source_addr = SMB_STRDUP(inet_ntoa(dgram->header.source_ip));
+ if (source_addr == NULL) {
+ DEBUG(3, ("out of memory copying client"
+ " address string\n"));
+ return;
+ }
+
+ /*
+ * handle delay.
+ * packets requeued after delay are marked as
+ * locked.
+ */
+ if ((p->locked == False) &&
+ (strlen(ascuser) == 0) &&
+ delay_logon(source_name, source_addr))
+ {
+ struct timeval when;
+
+ DEBUG(3, ("process_logon_packet: "
+ "delaying initial logon "
+ "reply for client %s(%s) for "
+ "%u milliseconds\n",
+ source_name, source_addr,
+ lp_init_logon_delay()));
+
+ when = timeval_current_ofs(0,
+ lp_init_logon_delay() * 1000);
+ p->locked = true;
+ event_add_timed(nmbd_event_context(),
+ NULL,
+ when,
+ "delayed_init_logon",
+ delayed_init_logon_handler,
+ p);
+ } else {
+ DEBUG(3, ("process_logon_packet: "
+ "processing delayed initial "
+ "logon reply for client "
+ "%s(%s)\n",
+ source_name, source_addr));
+
+ p->locked = false;
+ send_mailslot(true, getdc,
+ outbuf,PTR_DIFF(q,outbuf),
+ global_myname(), 0x0,
+ source_name,
+ dgram->source_name.name_type,
+ p->ip, ip, p->port);
+ }
+
+ SAFE_FREE(source_addr);
- send_mailslot(True, getdc,
- outbuf,PTR_DIFF(q,outbuf),
- global_myname(), 0x0,
- source_name,
- dgram->source_name.name_type,
- p->ip, ip, p->port);
break;
}
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 6902bb0..7882b37 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -273,6 +273,8 @@ struct global {
int iPreferredMaster;
int iDomainMaster;
bool bDomainLogons;
+ char **szInitLogonDelayedHosts;
+ int InitLogonDelay;
bool bEncryptPasswords;
bool bUpdateEncrypt;
int clientSchannel;
@@ -3190,6 +3192,23 @@ static struct parm_struct parm_table[] = {
.flags = FLAG_ADVANCED,
},
+ {
+ .label = "init logon delayed hosts",
+ .type = P_LIST,
+ .p_class = P_GLOBAL,
+ .ptr = &Globals.szInitLogonDelayedHosts,
+ .flags = FLAG_ADVANCED,
+ },
+
+ {
+ .label = "init logon delay",
+ .type = P_INTEGER,
+ .p_class = P_GLOBAL,
+ .ptr = &Globals.InitLogonDelay,
+ .flags = FLAG_ADVANCED,
+
+ },
+
{N_("Browse Options"), P_SEP, P_SEPARATOR},
{
@@ -4797,6 +4816,9 @@ static void init_globals(bool first_time_only)
Globals.bWINSsupport = False;
Globals.bWINSproxy = False;
+ TALLOC_FREE(Globals.szInitLogonDelayedHosts);
+ Globals.InitLogonDelay = 100; /* 100 ms default delay */
+
Globals.bDNSproxy = True;
/* this just means to use them if they exist */
@@ -5109,6 +5131,8 @@ FN_GLOBAL_BOOL(lp_we_are_a_wins_server, &Globals.bWINSsupport)
FN_GLOBAL_BOOL(lp_wins_proxy, &Globals.bWINSproxy)
FN_GLOBAL_BOOL(lp_local_master, &Globals.bLocalMaster)
FN_GLOBAL_BOOL(lp_domain_logons, &Globals.bDomainLogons)
+FN_GLOBAL_LIST(lp_init_logon_delayed_hosts, &Globals.szInitLogonDelayedHosts)
+FN_GLOBAL_INTEGER(lp_init_logon_delay, &Globals.InitLogonDelay)
FN_GLOBAL_BOOL(lp_load_printers, &Globals.bLoadPrinters)
FN_GLOBAL_BOOL(lp_readraw, &Globals.bReadRaw)
FN_GLOBAL_BOOL(lp_large_readwrite, &Globals.bLargeReadwrite)
--
Samba Shared Repository
More information about the samba-cvs
mailing list