[PATCH 1/1] Extended share names
Stefan (metze) Metzmacher
metze at samba.org
Thu Jan 10 18:58:10 GMT 2008
Hi,
> if "extended share names" is enabled, then When make_connection()
> tries to load the share section from the config it will check in
> this order for:
> \\name.domain\share
> \\name\share
> \\name.domain
> \\name
why this two without share?
> /* local prototypes */
> static int map_parameter(const char *pszParmName);
> @@ -2407,6 +2413,8 @@ bool loadparm_init(struct loadparm_context *lp_ctx)
> lp_do_global_parameter_var(lp_ctx, "setup directory", "%s",
> dyn_SETUPDIR);
>
> + lp_do_global_parameter(lp_ctx, "extended share names", "0");
This should be "no" instead of "0".
> for (i = 0; parm_table[i].label; i++) {
> if (!(parm_table[i].flags & FLAG_CMDLINE)) {
> parm_table[i].flags |= FLAG_DEFAULT;
> diff --git a/source/smb_server/smb/service.c b/source/smb_server/smb/service.c
> index 558f303..8fb00b2 100644
> --- a/source/smb_server/smb/service.c
> +++ b/source/smb_server/smb/service.c
> @@ -120,17 +120,70 @@ static NTSTATUS make_connection(struct smbsrv_request *req,
> const char *type_str;
> struct share_config *scfg;
> const char *sharetype;
> -
> + const char *server_name=NULL;
> + const char *full_server_name=NULL;
> + const char *full_service=service;
> + const char* short_service=NULL;
> + bool extended_share_names=lp_extended_share_names(global_loadparm);
> +
> /* the service might be of the form \\SERVER\SHARE. Should we put
> the server name we get from this somewhere? */
> if (strncmp(service, "\\\\", 2) == 0) {
> char *p = strchr(service+2, '\\');
> + /* Get the server name (including \\ ) up to a . or \ */
> + server_name=talloc_strndup(req, service, 2+strcspn(2+service, "\\."));
> + full_server_name=talloc_strndup(req, service, 2+strcspn(2+service, "\\"));
This looks a bit complex for oneliners, please split this up a bit more.
Split the logic from the allocation and check for allocation errors.
> if (p) {
> service = p + 1;
> }
> + short_service=talloc_asprintf(req, "%s\\%s", server_name, service);
> + }
> +
> + if (extended_share_names) {
> + /* Try the full \\blah.domain\blah service - useful for proxy backends */
> + if (!NT_STATUS_IS_OK(status) && full_service) {
> + DEBUG(3,("Looking for service %s\n",full_service));
> + status = share_get_config(req, req->smb_conn->share_context, full_service, &scfg);
> + }
> +
> + /* Try the short \\blah\blah service - useful for proxy backends */
> + if (!NT_STATUS_IS_OK(status) && short_service) {
> + DEBUG(3,("Looking for service %s\n",short_service));
> + status = share_get_config(req, req->smb_conn->share_context, short_service, &scfg);
> + }
> +
> + /* Try the full \\blah.domain server name - useful for proxy backends */
> + if (!NT_STATUS_IS_OK(status) && service > full_server_name) {
> + DEBUG(3,("Looking for service %s\n", full_server_name));
> + status = share_get_config(req, req->smb_conn->share_context, full_server_name, &scfg);
> + }
here's one tab too much:-)
> + /* Try the short \\blah server name - useful for proxy backends */
> + if (!NT_STATUS_IS_OK(status) && service > server_name) {
'>' doesn't work on strings...
metze
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : http://lists.samba.org/archive/samba-technical/attachments/20080110/05ee22f1/signature.bin
More information about the samba-technical
mailing list