From 209d47c100bf59f15519c4c82089285210041c2e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 12:41:45 +1000 Subject: s4-param Rename lock_path() -> lpcfg_lock_path() This avoids a conflict with the source3/ lock_path() --- source4/smb_server/smb/negprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/negprot.c b/source4/smb_server/smb/negprot.c index 656da4df20..2466a60705 100644 --- a/source4/smb_server/smb/negprot.c +++ b/source4/smb_server/smb/negprot.c @@ -278,7 +278,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice) capabilities |= CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS; } - large_test_path = lock_path(req, req->smb_conn->lp_ctx, "large_test.dat"); + large_test_path = lpcfg_lock_path(req, req->smb_conn->lp_ctx, "large_test.dat"); if (large_file_support(large_test_path)) { capabilities |= CAP_LARGE_FILES; } -- cgit From 85eb4377dbc9e2d25e0ee2e358e785347b09f0a7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 May 2011 10:05:46 +1000 Subject: s4:cluster Rename .id to .pid in server_id This also changes some DEBUG messages to use cluster_id_string() rather than .id, to isolate them from this and other changes. Andrew Bartlett --- source4/smb_server/smb/negprot.c | 7 ++++--- source4/smb_server/smb/receive.c | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/negprot.c b/source4/smb_server/smb/negprot.c index 2466a60705..0a07ab93e2 100644 --- a/source4/smb_server/smb/negprot.c +++ b/source4/smb_server/smb/negprot.c @@ -145,7 +145,7 @@ static void reply_lanman1(struct smbsrv_request *req, uint16_t choice) SSVAL(req->out.vwv, VWV(3), lpcfg_maxmux(req->smb_conn->lp_ctx)); SSVAL(req->out.vwv, VWV(4), 1); SSVAL(req->out.vwv, VWV(5), raw); - SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id); + SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.pid); srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t); SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60); SIVAL(req->out.vwv, VWV(11), 0); /* reserved */ @@ -199,7 +199,7 @@ static void reply_lanman2(struct smbsrv_request *req, uint16_t choice) SSVAL(req->out.vwv, VWV(3), lpcfg_maxmux(req->smb_conn->lp_ctx)); SSVAL(req->out.vwv, VWV(4), 1); SSVAL(req->out.vwv, VWV(5), raw); - SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id); + SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.pid); srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t); SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60); SIVAL(req->out.vwv, VWV(11), 0); @@ -332,7 +332,8 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice) SSVAL(req->out.vwv+1, VWV(2), 1); /* num vcs */ SIVAL(req->out.vwv+1, VWV(3), req->smb_conn->negotiate.max_recv); SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */ - SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->connection->server_id.id); /* session key */ + SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->connection->server_id.pid); /* session key */ + SIVAL(req->out.vwv+1, VWV(9), capabilities); push_nttime(req->out.vwv+1, VWV(11), nttime); SSVALS(req->out.vwv+1,VWV(15), req->smb_conn->negotiate.zone_offset/60); diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c index c2503efabc..1e5d5681f4 100644 --- a/source4/smb_server/smb/receive.c +++ b/source4/smb_server/smb/receive.c @@ -25,7 +25,7 @@ #include "smb_server/smb_server.h" #include "system/filesys.h" #include "param/param.h" - +#include "cluster/cluster.h" /* send an oplock break request to a client @@ -471,6 +471,7 @@ static void switch_message(int type, struct smbsrv_request *req) int flags; struct smbsrv_connection *smb_conn = req->smb_conn; NTSTATUS status; + char *task_id; type &= 0xff; @@ -501,8 +502,10 @@ static void switch_message(int type, struct smbsrv_request *req) } } - DEBUG(5,("switch message %s (task_id %u)\n", - smb_fn_name(type), (unsigned)req->smb_conn->connection->server_id.id)); + task_id = cluster_id_string(NULL, req->smb_conn->connection->server_id); + DEBUG(5,("switch message %s (task_id %s)\n", + smb_fn_name(type), task_id)); + talloc_free(task_id); /* this must be called before we do any reply */ if (flags & SIGNING_NO_REPLY) { -- cgit From ea0ac9cdfceae96b0e0be2531d9dea3b079bcd7f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 7 May 2011 08:14:06 +0200 Subject: s4-auth Rename auth -> auth4 to avoid conflict with s3 auth --- source4/smb_server/smb/sesssetup.c | 2 +- source4/smb_server/smb_server.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/sesssetup.c b/source4/smb_server/smb/sesssetup.c index c4efe3919c..116f2cd958 100644 --- a/source4/smb_server/smb/sesssetup.c +++ b/source4/smb_server/smb/sesssetup.c @@ -34,7 +34,7 @@ #include "lib/stream/packet.h" struct sesssetup_context { - struct auth_context *auth_context; + struct auth4_context *auth_context; struct smbsrv_request *req; }; diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index 6088853743..83612194ff 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -300,7 +300,7 @@ struct smbsrv_connection { enum protocol_types protocol; /* authentication context for multi-part negprot */ - struct auth_context *auth_context; + struct auth4_context *auth_context; /* reference to the kerberos keytab, or machine trust account */ struct cli_credentials *server_credentials; -- cgit From 8b2ba64d603dd1ef1afde621f594dc46f2133708 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 7 May 2011 13:32:20 +0200 Subject: libds: moved enum security_types to a common header Pair-Programmed-With: Andrew Bartlett --- source4/smb_server/smb_server.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index 83612194ff..6fcd9787bb 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -22,6 +22,7 @@ #include "libcli/raw/request.h" #include "libcli/raw/interfaces.h" #include "lib/socket/socket.h" +#include "libds/common/roles.h" #include "../lib/util/dlinklist.h" #include "../librpc/gen_ndr/nbt.h" @@ -265,8 +266,6 @@ struct smbsrv_request { struct smb_request_buffer out; }; -enum security_types {SEC_SHARE,SEC_USER}; - /* smb server context structure. This should contain all the state * information associated with a SMB server connection */ -- cgit From 22cb631b4fd0647b70fbaaafaffda8712a84a999 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 May 2011 15:57:19 +1000 Subject: s4-interfaces Rename interfaces code so not to conflict with source3/ The iface_count, iface_n_bcast, and load_interfaces functions conflicted with functions of the same name in source3, so the source4 functions were renamed. Hopefully we can actually wrap one around the other in future. Andrew Bartlett --- source4/smb_server/service_smb.c | 6 +++--- source4/smb_server/smb_samba3.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/service_smb.c b/source4/smb_server/service_smb.c index 583360bbe7..4866695865 100644 --- a/source4/smb_server/service_smb.c +++ b/source4/smb_server/service_smb.c @@ -48,16 +48,16 @@ static void smbsrv_task_init(struct task_server *task) int i; struct interface *ifaces; - load_interfaces(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); - num_interfaces = iface_count(ifaces); + num_interfaces = iface_list_count(ifaces); /* We have been given an interfaces line, and been told to only bind to those interfaces. Create a socket per interface and bind to only these. */ for(i = 0; i < num_interfaces; i++) { - const char *address = iface_n_ip(ifaces, i); + const char *address = iface_list_n_ip(ifaces, i); status = smbsrv_add_socket(task, task->event_ctx, task->lp_ctx, task->model_ops, address); if (!NT_STATUS_IS_OK(status)) goto failed; } diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c index b0ed38cf6a..86e67ec20d 100644 --- a/source4/smb_server/smb_samba3.c +++ b/source4/smb_server/smb_samba3.c @@ -135,16 +135,16 @@ static void samba3_smb_task_init(struct task_server *task) int i; struct interface *ifaces; - load_interfaces(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); - num_interfaces = iface_count(ifaces); + num_interfaces = iface_list_count(ifaces); /* We have been given an interfaces line, and been told to only bind to those interfaces. Create a socket per interface and bind to only these. */ for(i = 0; i < num_interfaces; i++) { - const char *address = iface_n_ip(ifaces, i); + const char *address = iface_list_n_ip(ifaces, i); status = samba3_add_socket(task, task->event_ctx, task->lp_ctx, -- cgit From 3478e3add376a291e4b4e3acfe92b2df22287142 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Sun, 15 May 2011 19:56:25 +0400 Subject: s4-dfs: fix bugs in idl and adapt code accordingly --- source4/smb_server/smb/trans2.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c index 0a6c014e88..fbddc177ed 100644 --- a/source4/smb_server/smb/trans2.c +++ b/source4/smb_server/smb/trans2.c @@ -872,15 +872,15 @@ static NTSTATUS fill_normal_dfs_referraltype(struct dfs_referral_type *ref, case 3: ZERO_STRUCTP(ref); ref->version = version; - ref->referral.v3.data.server_type = DFS_SERVER_NON_ROOT; + ref->referral.v3.server_type = DFS_SERVER_NON_ROOT; /* "normal" referral seems to always include the GUID */ ref->referral.v3.size = 34; - ref->referral.v3.data.entry_flags = 0; - ref->referral.v3.data.ttl = 600; /* As w2k3 */ - ref->referral.v3.data.referrals.r1.DFS_path = dfs_path; - ref->referral.v3.data.referrals.r1.DFS_alt_path = dfs_path; - ref->referral.v3.data.referrals.r1.netw_address = server_path; + ref->referral.v3.entry_flags = 0; + ref->referral.v3.ttl = 600; /* As w2k3 */ + ref->referral.v3.referrals.r1.DFS_path = dfs_path; + ref->referral.v3.referrals.r1.DFS_alt_path = dfs_path; + ref->referral.v3.referrals.r1.netw_address = server_path; return NT_STATUS_OK; case 4: ZERO_STRUCTP(ref); @@ -892,10 +892,10 @@ static NTSTATUS fill_normal_dfs_referraltype(struct dfs_referral_type *ref, if (isfirstoffset) { ref->referral.v4.entry_flags = DFS_HEADER_FLAG_TARGET_BCK; } - ref->referral.v4.ttl = 600; /* As w2k3 */ - ref->referral.v4.r1.DFS_path = dfs_path; - ref->referral.v4.r1.DFS_alt_path = dfs_path; - ref->referral.v4.r1.netw_address = server_path; + ref->referral.v4.ttl = 900; /* As w2k8r2 */ + ref->referral.v4.referrals.r1.DFS_path = dfs_path; + ref->referral.v4.referrals.r1.DFS_alt_path = dfs_path; + ref->referral.v4.referrals.r1.netw_address = server_path; return NT_STATUS_OK; } @@ -915,17 +915,23 @@ static NTSTATUS fill_domain_dfs_referraltype(struct dfs_referral_type *ref, case 3: ZERO_STRUCTP(ref); ref->version = version; - ref->referral.v3.data.server_type = DFS_SERVER_NON_ROOT; + ref->referral.v3.server_type = DFS_SERVER_NON_ROOT; /* It's hard coded ... don't think it's a good way but the sizeof return not the * correct values * * We have 18 if the GUID is not included 34 otherwise */ - ref->referral.v3.size = 18; - ref->referral.v3.data.entry_flags = DFS_FLAG_REFERRAL_DOMAIN_RESP; - ref->referral.v3.data.ttl = 600; /* As w2k3 */ - ref->referral.v3.data.referrals.r2.special_name = domain; - ref->referral.v3.data.referrals.r2.nb_expanded_names = numnames; + if (numnames == 0) { + /* Windows return without the guid when returning domain list + */ + ref->referral.v3.size = 18; + } else { + ref->referral.v3.size = 34; + } + ref->referral.v3.entry_flags = DFS_FLAG_REFERRAL_DOMAIN_RESP; + ref->referral.v3.ttl = 600; /* As w2k3 */ + ref->referral.v3.referrals.r2.special_name = domain; + ref->referral.v3.referrals.r2.nb_expanded_names = numnames; /* Put the final terminator */ if (names) { const char **names2 = talloc_array(ref, const char *, numnames+1); @@ -936,7 +942,7 @@ static NTSTATUS fill_domain_dfs_referraltype(struct dfs_referral_type *ref, NT_STATUS_HAVE_NO_MEMORY(names2[i]); } names2[numnames] = 0; - ref->referral.v3.data.referrals.r2.expanded_names = names2; + ref->referral.v3.referrals.r2.expanded_names = names2; } return NT_STATUS_OK; } -- cgit From c590c3a47c39aeb79a8bce502a5477b62e36bbd7 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Sun, 15 May 2011 22:18:19 +0400 Subject: s4-dfs: clean the code --- source4/smb_server/smb/trans2.c | 94 ++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 44 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c index fbddc177ed..0587779677 100644 --- a/source4/smb_server/smb/trans2.c +++ b/source4/smb_server/smb/trans2.c @@ -914,6 +914,7 @@ static NTSTATUS fill_domain_dfs_referraltype(struct dfs_referral_type *ref, switch (version) { case 3: ZERO_STRUCTP(ref); + DEBUG(8, ("Called fill_domain_dfs_referraltype\n")); ref->version = version; ref->referral.v3.server_type = DFS_SERVER_NON_ROOT; /* It's hard coded ... don't think it's a good way but the sizeof return not the @@ -941,7 +942,7 @@ static NTSTATUS fill_domain_dfs_referraltype(struct dfs_referral_type *ref, names2[i] = talloc_asprintf(names2, "\\%s", names[i]); NT_STATUS_HAVE_NO_MEMORY(names2[i]); } - names2[numnames] = 0; + names2[numnames] = NULL; ref->referral.v3.referrals.r2.expanded_names = names2; } return NT_STATUS_OK; @@ -1348,7 +1349,7 @@ static NTSTATUS dodomain_referral(TALLOC_CTX *ctx, } if (!ok && resp.nb_referrals == 2) { - DEBUG(0, (__location__ "; Not able to fit the domain and realm in DFS a " + DEBUG(8, (__location__ "; Not able to fit the domain and realm in DFS a " " 56K buffer, something must be broken")); talloc_free(context); return NT_STATUS_INTERNAL_ERROR; @@ -1369,6 +1370,8 @@ static NTSTATUS dodomain_referral(TALLOC_CTX *ctx, */ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, const struct dfs_GetDFSReferral_in dfsreq, + const char* requesteddomain, + const char* requestedshare, const char* requestedname, struct ldb_context *ldb, struct smb_trans2 *trans, @@ -1384,16 +1387,13 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, NTSTATUS status; unsigned int num_domain = 1; enum ndr_err_code ndr_err; - const char *requesteddomain; const char *realm = lpcfg_realm(lp_ctx); const char *domain = lpcfg_workgroup(lp_ctx); const char *site_name = NULL; /* Name of the site where the client is */ - char *share = NULL; bool found = false; bool need_fqdn = false; bool dc_referral = true; unsigned int i; - char *tmp; struct dc_set **set; char const **domain_list; struct tsocket_address *remote_address; @@ -1413,24 +1413,13 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, context = talloc_new(ctx); NT_STATUS_HAVE_NO_MEMORY(context); - if (requestedname[0] == '\\' && !strchr(requestedname+1,'\\')) { - requestedname++; - } - requesteddomain = requestedname; - - if (strchr(requestedname,'\\')) { - char *subpart; - /* we have a second part */ - requesteddomain = talloc_strdup(context, requestedname+1); - NT_STATUS_HAVE_NO_MEMORY_AND_FREE(requesteddomain, context); - subpart = strchr(requesteddomain,'\\'); - subpart[0] = '\0'; - } - tmp = strchr(requestedname + 1,'\\'); /* To get second \ if any */ + DEBUG(10, ("in this we have request for %s and share %s requested is %s\n", + requesteddomain, + requestedshare, + requestedname)); - if (tmp != NULL) { - /* There was a share */ - share = tmp+1; + if (requestedshare) { + DEBUG(10, ("Have a non DC domain referal\n")); dc_referral = false; } @@ -1514,8 +1503,13 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, referral = talloc(context, struct dfs_referral_type); NT_STATUS_HAVE_NO_MEMORY_AND_FREE(referral, context); - referral_str = talloc_asprintf(referral, "\\%s", - requestedname); + if (requestedname[0] == '\\') { + referral_str = talloc_asprintf(referral, "%s", + requestedname); + } else { + referral_str = talloc_asprintf(referral, "\\%s", + requestedname); + } NT_STATUS_HAVE_NO_MEMORY_AND_FREE(referral_str, context); status = fill_domain_dfs_referraltype(referral, 3, @@ -1570,12 +1564,14 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, NT_STATUS_HAVE_NO_MEMORY_AND_FREE(referral, context); referral_str = talloc_asprintf(referral, "\\%s\\%s", - set[i]->names[j], share); + set[i]->names[j], requestedshare); + DEBUG(8, ("Doing a dfs referral for %s with this value %s requested %s\n", set[i]->names[j], referral_str, requestedname)); NT_STATUS_HAVE_NO_MEMORY_AND_FREE(referral_str, context); status = fill_normal_dfs_referraltype(referral, dfsreq.max_referral_level, requestedname, referral_str, j==0); + if (!NT_STATUS_IS_OK(status)) { DEBUG(2, (__location__ ": Unable to fill a normal dfs referral object")); talloc_free(context); @@ -1622,7 +1618,7 @@ static NTSTATUS trans2_getdfsreferral(struct smbsrv_request *req, struct ldb_context *ldb; struct loadparm_context *lp_ctx; const char *realm, *nbname, *requestedname; - char *fqdn, *tmp; + char *fqdn, *share, *domain, *tmp; NTSTATUS status; lp_ctx = req->tcon->ntvfs->lp_ctx; @@ -1651,7 +1647,7 @@ static NTSTATUS trans2_getdfsreferral(struct smbsrv_request *req, return status; } - DEBUG(10, ("Requested DFS name: %s length: %u\n", + DEBUG(8, ("Requested DFS name: %s length: %u\n", dfsreq.servername, (unsigned int)strlen(dfsreq.servername))); /* @@ -1685,31 +1681,41 @@ static NTSTATUS trans2_getdfsreferral(struct smbsrv_request *req, } talloc_free(fqdn); - tmp = strchr(requestedname + 1,'\\'); /* To get second \ if any */ + domain = talloc_strdup(context, requestedname); + while(*domain && *domain == '\\') { + domain++; + } + tmp = strchr(domain,'\\'); /* To get second \ if any */ + share = NULL; + if (tmp) { + /* + * We are finishing properly the domain string + * and the share one will start after the \ + */ + tmp[0] = '\\'; + tmp++; + share = talloc_strdup(context, tmp); + } /* - * If we have no slash at the first position or (foo.bar.domain.net) - * a slash at the first position but no other slash (\foo.bar.domain.net) - * or a slash at the first position and another slash - * and netlogon or sysvol after the second slash - * (\foo.bar.domain.net\sysvol) then we will handle it because - * it's either a dc referral or a sysvol/netlogon referral + * Here we have filtered the thing the requested name don't contain our DNS name. + * So if the share == NULL or if share in ("sysvol", "netlogon") + * then we proceed. In the first case it will be a dc refereal in the second it will + * be just a sysvol/netlogon referral. */ - if (requestedname[0] != '\\' || - tmp == NULL || - strcasecmp(tmp+1, "sysvol") == 0 || - strcasecmp(tmp+1, "netlogon") == 0) { - status = dodc_or_sysvol_referral(op, dfsreq, requestedname, + if (share == NULL || + strcasecmp(share, "sysvol") == 0 || + strcasecmp(share, "netlogon") == 0) { + status = dodc_or_sysvol_referral(op, dfsreq, domain, share, requestedname, ldb, trans, req, lp_ctx); talloc_free(context); return status; } - if (requestedname[0] == '\\' && - tmp && - strchr(tmp+1, '\\') && - (strncasecmp(tmp+1, "sysvol", 6) == 0 || - strncasecmp(tmp+1, "netlogon", 8) == 0)) { + tmp = strchr(share, '\\'); + if (tmp && + (strncasecmp(share, "sysvol", 6) == 0 || + strncasecmp(share, "netlogon", 8) == 0)) { /* * We have more than two \ so it something like * \domain\sysvol\foobar -- cgit From 28598e79330f37abbb709e2b317dde9c8d6c90b5 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Mon, 16 May 2011 20:51:20 +0400 Subject: s4-dfs: Use a workaround for ndr relative pointer bug/limitation Autobuild-User: Matthieu Patou Autobuild-Date: Tue May 17 01:33:27 CEST 2011 on sn-devel-104 --- source4/smb_server/smb/trans2.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c index 0587779677..163712379a 100644 --- a/source4/smb_server/smb/trans2.c +++ b/source4/smb_server/smb/trans2.c @@ -867,24 +867,22 @@ static NTSTATUS fill_normal_dfs_referraltype(struct dfs_referral_type *ref, const char *dfs_path, const char *server_path, int isfirstoffset) { + ZERO_STRUCTP(ref); + ref->version = version; switch (version) { case 3: - ZERO_STRUCTP(ref); - ref->version = version; ref->referral.v3.server_type = DFS_SERVER_NON_ROOT; /* "normal" referral seems to always include the GUID */ ref->referral.v3.size = 34; ref->referral.v3.entry_flags = 0; ref->referral.v3.ttl = 600; /* As w2k3 */ - ref->referral.v3.referrals.r1.DFS_path = dfs_path; - ref->referral.v3.referrals.r1.DFS_alt_path = dfs_path; - ref->referral.v3.referrals.r1.netw_address = server_path; + ref->referral.v3.referrals.r1.DFS_path = talloc_strdup(ref, dfs_path); + ref->referral.v3.referrals.r1.DFS_alt_path = talloc_strdup(ref, dfs_path); + ref->referral.v3.referrals.r1.netw_address = talloc_strdup(ref, server_path); return NT_STATUS_OK; case 4: - ZERO_STRUCTP(ref); - ref->version = version; ref->referral.v4.server_type = DFS_SERVER_NON_ROOT; /* "normal" referral seems to always include the GUID */ ref->referral.v4.size = 34; @@ -893,10 +891,9 @@ static NTSTATUS fill_normal_dfs_referraltype(struct dfs_referral_type *ref, ref->referral.v4.entry_flags = DFS_HEADER_FLAG_TARGET_BCK; } ref->referral.v4.ttl = 900; /* As w2k8r2 */ - ref->referral.v4.referrals.r1.DFS_path = dfs_path; - ref->referral.v4.referrals.r1.DFS_alt_path = dfs_path; - ref->referral.v4.referrals.r1.netw_address = server_path; - + ref->referral.v4.referrals.r1.DFS_path = talloc_strdup(ref, dfs_path); + ref->referral.v4.referrals.r1.DFS_alt_path = talloc_strdup(ref, dfs_path); + ref->referral.v4.referrals.r1.netw_address = talloc_strdup(ref, server_path); return NT_STATUS_OK; } return NT_STATUS_INVALID_LEVEL; -- cgit From 29a03cdbc297460415b27a5acc8ecfb7240cd2b4 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Wed, 18 May 2011 01:14:24 +0400 Subject: s4-dfs: Add workaround so that XP really works well XP seems to have problems working at a correct speed (or even working at all if we return referral of level 4). --- source4/smb_server/smb/trans2.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c index 163712379a..b3aa690e85 100644 --- a/source4/smb_server/smb/trans2.c +++ b/source4/smb_server/smb/trans2.c @@ -868,21 +868,13 @@ static NTSTATUS fill_normal_dfs_referraltype(struct dfs_referral_type *ref, const char *server_path, int isfirstoffset) { ZERO_STRUCTP(ref); - ref->version = version; - switch (version) { - case 3: - ref->referral.v3.server_type = DFS_SERVER_NON_ROOT; - /* "normal" referral seems to always include the GUID */ - ref->referral.v3.size = 34; - - ref->referral.v3.entry_flags = 0; - ref->referral.v3.ttl = 600; /* As w2k3 */ - ref->referral.v3.referrals.r1.DFS_path = talloc_strdup(ref, dfs_path); - ref->referral.v3.referrals.r1.DFS_alt_path = talloc_strdup(ref, dfs_path); - ref->referral.v3.referrals.r1.netw_address = talloc_strdup(ref, server_path); - return NT_STATUS_OK; case 4: + version = 3; +# if 0 + /* For the moment there is a bug with XP that don't seems to appriciate much + * level4 so we return just level 3 for everyone + */ ref->referral.v4.server_type = DFS_SERVER_NON_ROOT; /* "normal" referral seems to always include the GUID */ ref->referral.v4.size = 34; @@ -895,6 +887,19 @@ static NTSTATUS fill_normal_dfs_referraltype(struct dfs_referral_type *ref, ref->referral.v4.referrals.r1.DFS_alt_path = talloc_strdup(ref, dfs_path); ref->referral.v4.referrals.r1.netw_address = talloc_strdup(ref, server_path); return NT_STATUS_OK; +#endif + case 3: + ref->version = version; + ref->referral.v3.server_type = DFS_SERVER_NON_ROOT; + /* "normal" referral seems to always include the GUID */ + ref->referral.v3.size = 34; + + ref->referral.v3.entry_flags = 0; + ref->referral.v3.ttl = 600; /* As w2k3 */ + ref->referral.v3.referrals.r1.DFS_path = talloc_strdup(ref, dfs_path); + ref->referral.v3.referrals.r1.DFS_alt_path = talloc_strdup(ref, dfs_path); + ref->referral.v3.referrals.r1.netw_address = talloc_strdup(ref, server_path); + return NT_STATUS_OK; } return NT_STATUS_INVALID_LEVEL; } -- cgit From dc8c8fd9e4f85974cd0665e613d4422ba8dd900e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 12 May 2011 12:35:02 +0200 Subject: s4-ipv6: use iface_list_wildcard() to listen on IPv6 when we need to listen on a wildcard address, we now listen on a list of sockets, usually 0.0.0.0 and :: --- source4/smb_server/service_smb.c | 15 ++++++++++++--- source4/smb_server/smb_samba3.c | 21 +++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/service_smb.c b/source4/smb_server/service_smb.c index 4866695865..d2833d9be6 100644 --- a/source4/smb_server/service_smb.c +++ b/source4/smb_server/service_smb.c @@ -63,9 +63,18 @@ static void smbsrv_task_init(struct task_server *task) } } else { /* Just bind to lpcfg_socket_address() (usually 0.0.0.0) */ - status = smbsrv_add_socket(task, task->event_ctx, task->lp_ctx, task->model_ops, - lpcfg_socket_address(task->lp_ctx)); - if (!NT_STATUS_IS_OK(status)) goto failed; + const char **wcard; + int i; + wcard = iface_list_wildcard(task, task->lp_ctx); + if (wcard == NULL) { + DEBUG(0,("No wildcard addresses available\n")); + goto failed; + } + for (i=0; wcard[i]; i++) { + status = smbsrv_add_socket(task, task->event_ctx, task->lp_ctx, task->model_ops, wcard[i]); + if (!NT_STATUS_IS_OK(status)) goto failed; + } + talloc_free(wcard); } return; diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c index 86e67ec20d..35630ade05 100644 --- a/source4/smb_server/smb_samba3.c +++ b/source4/smb_server/smb_samba3.c @@ -152,12 +152,21 @@ static void samba3_smb_task_init(struct task_server *task) if (!NT_STATUS_IS_OK(status)) goto failed; } } else { - /* Just bind to lpcfg_socket_address() (usually 0.0.0.0) */ - status = samba3_add_socket(task, - task->event_ctx, task->lp_ctx, - model_ops, - lpcfg_socket_address(task->lp_ctx)); - if (!NT_STATUS_IS_OK(status)) goto failed; + const char **wcard; + int i; + wcard = iface_list_wildcard(task, task->lp_ctx); + if (wcard == NULL) { + DEBUG(0,("No wildcard addresses available\n")); + goto failed; + } + for (i=0; wcard[i]; i++) { + status = samba3_add_socket(task, + task->event_ctx, task->lp_ctx, + model_ops, + wcard[i]); + if (!NT_STATUS_IS_OK(status)) goto failed; + } + talloc_free(wcard); } return; -- cgit From 8f3ce14ea744d721636d3e096ae1f021aae042bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 12 May 2011 12:36:33 +0200 Subject: s4-ipv6: use "ip" instead of "ipv4" for servers this allows stream_setup_socket() to work with both v4 and v6 addresses --- source4/smb_server/smb_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index d21e5fbdb0..d64a597d31 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -190,7 +190,7 @@ _PUBLIC_ NTSTATUS smbsrv_add_socket(TALLOC_CTX *mem_ctx, if (port == 0) continue; status = stream_setup_socket(mem_ctx, event_context, lp_ctx, model_ops, &smb_stream_ops, - "ipv4", address, &port, + "ip", address, &port, lpcfg_socket_options(lp_ctx), NULL); NT_STATUS_NOT_OK_RETURN(status); -- cgit From 40dc94a53f4f0f5dee285daf486912b0996d5f3e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Jun 2011 15:40:28 +1000 Subject: s4-ipv6: update callers to load_interface_list() --- source4/smb_server/service_smb.c | 2 +- source4/smb_server/smb_samba3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/service_smb.c b/source4/smb_server/service_smb.c index d2833d9be6..7e50318424 100644 --- a/source4/smb_server/service_smb.c +++ b/source4/smb_server/service_smb.c @@ -48,7 +48,7 @@ static void smbsrv_task_init(struct task_server *task) int i; struct interface *ifaces; - load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, task->lp_ctx, &ifaces); num_interfaces = iface_list_count(ifaces); diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c index 35630ade05..1a99be644a 100644 --- a/source4/smb_server/smb_samba3.c +++ b/source4/smb_server/smb_samba3.c @@ -135,7 +135,7 @@ static void samba3_smb_task_init(struct task_server *task) int i; struct interface *ifaces; - load_interface_list(task, lpcfg_interfaces(task->lp_ctx), &ifaces); + load_interface_list(task, task->lp_ctx, &ifaces); num_interfaces = iface_list_count(ifaces); -- cgit From be91effc20b6454f2b71aaadff3ff02378df164f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Jun 2011 11:43:38 +1000 Subject: s4-ipv6: removed an old comment the comment is not correct any more --- source4/smb_server/service_smb.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/service_smb.c b/source4/smb_server/service_smb.c index 7e50318424..cbbd2cd95e 100644 --- a/source4/smb_server/service_smb.c +++ b/source4/smb_server/service_smb.c @@ -62,7 +62,6 @@ static void smbsrv_task_init(struct task_server *task) if (!NT_STATUS_IS_OK(status)) goto failed; } } else { - /* Just bind to lpcfg_socket_address() (usually 0.0.0.0) */ const char **wcard; int i; wcard = iface_list_wildcard(task, task->lp_ctx); -- cgit From 16b1c77644217796f70a3a0bf1d95c245f9ee2d9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 8 Jun 2011 14:05:55 +1000 Subject: lib/util Bring procid_str() into lib/util as server_id_string() This is needed for OpenChange, which prints Samba struct server_id values in debug messages. Andrew Bartlett --- source4/smb_server/smb/receive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c index 1e5d5681f4..1379fe31cf 100644 --- a/source4/smb_server/smb/receive.c +++ b/source4/smb_server/smb/receive.c @@ -502,7 +502,7 @@ static void switch_message(int type, struct smbsrv_request *req) } } - task_id = cluster_id_string(NULL, req->smb_conn->connection->server_id); + task_id = server_id_str(NULL, &req->smb_conn->connection->server_id); DEBUG(5,("switch message %s (task_id %s)\n", smb_fn_name(type), task_id)); talloc_free(task_id); -- cgit From 4f7f1430268f0ab5447fe189da6435bdd8e0614e Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Thu, 23 Jun 2011 02:35:50 +0400 Subject: dfsreferral: search client's site and use it Autobuild-User: Matthieu Patou Autobuild-Date: Thu Jun 23 01:50:39 CEST 2011 on sn-devel-104 --- source4/smb_server/smb/trans2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/smb_server') diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c index b3aa690e85..72babd533b 100644 --- a/source4/smb_server/smb/trans2.c +++ b/source4/smb_server/smb/trans2.c @@ -1107,7 +1107,7 @@ static NTSTATUS get_dcs(TALLOC_CTX *ctx, struct ldb_context *ldb, } talloc_free(r); - if (searched_site != NULL) { + if (searched_site != NULL && searched_site[0] != '\0') { ret = ldb_search(ldb, subctx, &r, configdn, LDB_SCOPE_SUBTREE, attrs_none, "(&(name=%s)(objectClass=site))", searched_site); if (ret != LDB_SUCCESS) { @@ -1461,7 +1461,7 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, client_addr = tsocket_address_inet_addr_string(remote_address, context); NT_STATUS_HAVE_NO_MEMORY_AND_FREE(client_addr, context); } - + site_name = samdb_client_site_name(ldb, context, client_addr, NULL); status = get_dcs(context, ldb, site_name, need_fqdn, &set, 0); if (!NT_STATUS_IS_OK(status)) { DEBUG(3,("Unable to get list of DCs\n")); -- cgit