diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-07-18 11:51:00 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-07-19 08:02:32 +0200 |
commit | 0f57da57e3c250c0b00d1a369eeff0eb49bee4f8 (patch) | |
tree | 5145843382cc36b994ac8986fd425bee2c05be5a | |
parent | cf9bd1d9ed6db5d35d92816382edbadc217de792 (diff) | |
download | samba-0f57da57e3c250c0b00d1a369eeff0eb49bee4f8.tar.gz samba-0f57da57e3c250c0b00d1a369eeff0eb49bee4f8.tar.bz2 samba-0f57da57e3c250c0b00d1a369eeff0eb49bee4f8.zip |
lib/param: bring lp_smb_ports() into common by making it a list everywhere
-rw-r--r-- | lib/param/loadparm.c | 1 | ||||
-rw-r--r-- | lib/param/param_functions.c | 1 | ||||
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/param/loadparm.c | 5 | ||||
-rw-r--r-- | source3/smbd/server.c | 31 |
5 files changed, 14 insertions, 26 deletions
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index d5f370e80f..33aef249db 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -1526,7 +1526,6 @@ static struct loadparm_context *global_loadparm_context; FN_GLOBAL_BOOL(readraw, bReadRaw) FN_GLOBAL_BOOL(unicode, bUnicode) FN_GLOBAL_BOOL(writeraw, bWriteRaw) -FN_GLOBAL_LIST(smb_ports, smb_ports) FN_GLOBAL_STRING(cachedir, szCacheDir) FN_GLOBAL_STRING(socket_address, szSocketAddress) FN_GLOBAL_STRING(statedir, szStateDir) diff --git a/lib/param/param_functions.c b/lib/param/param_functions.c index c2bd63105a..eb701902dc 100644 --- a/lib/param/param_functions.c +++ b/lib/param/param_functions.c @@ -356,6 +356,7 @@ FN_GLOBAL_LIST(preload_modules, szPreloadModules) FN_GLOBAL_LIST(rndc_command, szRNDCCommand) FN_GLOBAL_LIST(samba_kcc_command, szSambaKCCCommand) FN_GLOBAL_LIST(server_services, server_services) +FN_GLOBAL_LIST(smb_ports, smb_ports) FN_GLOBAL_LIST(spn_update_command, szSPNUpdateCommand) FN_GLOBAL_LIST(svcctl_list, szServicesList) FN_GLOBAL_LIST(usershare_prefix_allow_list, szUsersharePrefixAllowList) diff --git a/source3/include/proto.h b/source3/include/proto.h index 769a300403..4d99a607e3 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1002,7 +1002,7 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m /* The following definitions come from param/loadparm.c */ -const char *lp_smb_ports(void); +const char **lp_smb_ports(void); const char *lp_dos_charset(void); const char *lp_unix_charset(void); char *lp_logfile(TALLOC_CTX *ctx); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 4c21d5032f..00edc3f3d7 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -1533,7 +1533,7 @@ static struct parm_struct parm_table[] = { }, { .label = "smb ports", - .type = P_STRING, + .type = P_LIST, .p_class = P_GLOBAL, .offset = GLOBAL_VAR(smb_ports), .special = NULL, @@ -4925,7 +4925,7 @@ static void init_globals(bool reinit_globals) Globals.server_signing = SMB_SIGNING_DEFAULT; Globals.bDeferSharingViolations = true; - string_set(&Globals.smb_ports, SMB_PORTS); + Globals.smb_ports = (const char **)str_list_make_v3(NULL, SMB_PORTS, NULL); Globals.bEnablePrivileges = true; Globals.bHostMSDfs = true; @@ -5109,7 +5109,6 @@ int lp_cups_encrypt(void) /* These functions remain in source3/param for now */ -FN_GLOBAL_CONST_STRING(smb_ports, smb_ports) FN_GLOBAL_INTEGER(security, security) FN_GLOBAL_INTEGER(usershare_max_shares, iUsershareMaxShares) FN_GLOBAL_STRING(configfile, szConfigFile) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 28374fa985..f7f1d8c715 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -733,8 +733,8 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, const char *smb_ports) { int num_interfaces = iface_count(); - int i; - const char *ports; + int i,j; + const char **ports; unsigned dns_port = 0; #ifdef HAVE_ATEXIT @@ -744,16 +744,11 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, /* Stop zombies */ smbd_setup_sig_chld_handler(parent); + ports = lp_smb_ports(); + /* use a reasonable default set of ports - listing on 445 and 139 */ - if (!smb_ports) { - ports = lp_smb_ports(); - if (!ports || !*ports) { - ports = talloc_strdup(talloc_tos(), SMB_PORTS); - } else { - ports = talloc_strdup(talloc_tos(), ports); - } - } else { - ports = talloc_strdup(talloc_tos(), smb_ports); + if (smb_ports) { + ports = (const char **)str_list_make_v3(talloc_tos(), smb_ports, NULL); } if (lp_interfaces() && lp_bind_interfaces_only()) { @@ -767,9 +762,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, for(i = 0; i < num_interfaces; i++) { const struct sockaddr_storage *ifss = iface_n_sockaddr_storage(i); - char *tok; - const char *ptr; - if (ifss == NULL) { DEBUG(0,("open_sockets_smbd: " "interface %d has NULL IP address !\n", @@ -777,9 +769,8 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, continue; } - for (ptr=ports; - next_token_talloc(talloc_tos(),&ptr, &tok, " \t,");) { - unsigned port = atoi(tok); + for (j = 0; ports && ports[j]; j++) { + unsigned port = atoi(ports[j]); if (port == 0 || port > 0xffff) { continue; } @@ -804,8 +795,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, /* Just bind to 0.0.0.0 - accept connections from anywhere. */ - char *tok; - const char *ptr; const char *sock_addr = lp_socket_address(); char *sock_tok; const char *sock_ptr; @@ -821,10 +810,10 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, for (sock_ptr=sock_addr; next_token_talloc(talloc_tos(), &sock_ptr, &sock_tok, " \t,"); ) { - for (ptr=ports; next_token_talloc(talloc_tos(), &ptr, &tok, " \t,"); ) { + for (j = 0; ports && ports[j]; j++) { struct sockaddr_storage ss; - unsigned port = atoi(tok); + unsigned port = atoi(ports[j]); if (port == 0 || port > 0xffff) { continue; } |