From 9d6decae2503446c08fa41c3908512d301e35719 Mon Sep 17 00:00:00 2001 From: Lars Herschke Date: Thu, 26 Jan 2023 20:41:38 +0100 Subject: [PATCH 1/3] some small bug fixes and add the possibility to build without using testparm --- wsd.c | 2 +- wsdd.h | 1 - wsdd2.c | 25 +++++++++++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/wsd.c b/wsd.c index 0b4b3d2..266d13d 100644 --- a/wsd.c +++ b/wsd.c @@ -928,7 +928,7 @@ static int wsd_parse_http_header(int fd, struct endpoint *ep, if ((val = HEADER_IS(p, "Content-Type:"))) { while (*val == ' ' || *val == '\t' || *val == '\r' || *val == '\n') val++; // skip LWS - if (strcmp(val, "application/soap+xml") != 0) { + if (strncmp(val, "application/soap+xml", 20) != 0) { ep->errstr = __FUNCTION__ ": Unsupported Content-Type"; return 400; } diff --git a/wsdd.h b/wsdd.h index bf19a2a..dc960f9 100644 --- a/wsdd.h +++ b/wsdd.h @@ -27,7 +27,6 @@ #include // IFNAMSIZ #include // ntohs() #include // struct sockaddr_in, struct ip_mreq -#include // struct ip_mreqn #include // struct sockaddr_nl #include // time_t, time() diff --git a/wsdd2.c b/wsdd2.c index 4f91f6e..c9c6131 100644 --- a/wsdd2.c +++ b/wsdd2.c @@ -663,6 +663,7 @@ static void init_sysinfo() if (p) *p = '\0'; hostname = strdup(hostn); +#ifndef WITHOUT_TESTPARM if (!hostaliases && !(hostaliases = get_smbparm("additional dns hostnames", ""))) err(EXIT_FAILURE, "get_smbparm"); @@ -674,6 +675,18 @@ static void init_sysinfo() if (!workgroup && !(workgroup = get_smbparm("workgroup", "WORKGROUP"))) err(EXIT_FAILURE, "get_smbparm"); +#else + if (!netbiosname) { + netbiosname = strdup(hostname); + unsigned char *s = (unsigned char*) netbiosname; + while (*s) { + *s = toupper(*s); + s++; + } + } + if (!workgroup) + workgroup = "WORKGROUP"; +#endif init_getresp(); } @@ -693,7 +706,7 @@ int main(int argc, char **argv) init_sysinfo(); - while ((opt = getopt(argc, argv, "hd46utlwLWi:H:N:G:b:")) != -1) { + while ((opt = getopt(argc, argv, "hd46utlwLWi:H:A:N:B:G:b:")) != -1) { switch (opt) { case 'h': help(prog, EXIT_SUCCESS, NULL); @@ -740,10 +753,18 @@ int main(int argc, char **argv) if (optarg != NULL && strlen(optarg) > 0) hostname = strdup(optarg); break; + case 'A': + if (optarg != NULL && strlen(optarg) > 0) + hostaliases = strdup(optarg); + break; case 'N': if (optarg != NULL && strlen(optarg) > 0) netbiosname = strdup(optarg); break; + case 'B': + if (optarg != NULL && strlen(optarg) > 0) + netbiosaliases = strdup(optarg); + break; case 'G': if (optarg != NULL && strlen(optarg) > 0) workgroup = strdup(optarg); @@ -754,7 +775,7 @@ int main(int argc, char **argv) help(prog, EXIT_FAILURE, "Bad key:val '%s'", optarg); break; case '?': - if (strchr("iHNGb", optopt)) + if (strchr("iHANBGb", optopt)) printf("Option -%c requires an argument.\n", optopt); /* ... fall through ... */ default: From ed6240ce2b3900890931c663acf3a4a33ecf487b Mon Sep 17 00:00:00 2001 From: Lars Herschke Date: Fri, 3 Mar 2023 17:07:46 +0100 Subject: [PATCH 2/3] add missing options to man page --- wsdd2.8 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/wsdd2.8 b/wsdd2.8 index f865df5..ce05cdd 100644 --- a/wsdd2.8 +++ b/wsdd2.8 @@ -18,8 +18,8 @@ wsdd2 \- server to provide WSDD/LLMNR services to clients .SH "SYNOPSIS" .HP \w'\ 'u wsddd2 [\-h] [\-d] [\-4] [\-6] [\-u] [\-t] [\-l] [\-w] [\-L] [\-W] -[\-i ] [\-H ] [\-N ] [\-G ] -[\-b ] +[\-i ] [\-H ] [\-A ] [\-N ] +[\-B ] [\-G ] [\-b ] .SH "DESCRIPTION" .PP @@ -123,6 +123,15 @@ system host name retrieved with \fBgethostname\fR(3) or \fBuname\fR(3) functions. .RE +.PP +\-A +.RS 4 +Use specified string as list of DNS machine names instead of value +returned by +.br +\fBtestparm -s --parameter-name="additional dns hostnames"\fR command. +.RE + .PP \-N .RS 4 @@ -132,6 +141,15 @@ Use specified string as NETBIOS machine name instead of value returned by name. .RE +.PP +\-B +.RS 4 +Use specified string as list of NETBIOS machine names instead of value +returned by +.br +\fBtestparm -s --parameter-name="netbios aliases"\fR command. +.RE + .PP \-G .RS 4 From b40aba85159b636b3d865e3ad8f5752e1422c440 Mon Sep 17 00:00:00 2001 From: Lars Herschke Date: Sat, 16 Dec 2023 22:36:42 +0100 Subject: [PATCH 3/3] document WITHOUT_TESTPARM macro --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a478ce8..eb217ef 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Microsoft is moving to support mDNS/DNS-SD, but not yet there. The primary purpose of this project is to enable WSD on Samba servers so that network shares hosted on a Unix box can appear in Windows File Explorer / Network. +If you predefine WITHOUT_TESTPARM as a macro when building, +wsdd2 can be used on lightweight Samba servers without testparm support. NOTE: Make sure there is no firewall rule blocking WSD multicast address 239.255.255.250 and ff02::c, protocol UDP port 3702. Unicast SOAP HTTP