Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion wsdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <net/if.h> // IFNAMSIZ
#include <arpa/inet.h> // ntohs()
#include <netinet/in.h> // struct sockaddr_in, struct ip_mreq
#include <linux/in.h> // struct ip_mreqn
#include <linux/netlink.h> // struct sockaddr_nl
#include <time.h> // time_t, time()

Expand Down
22 changes: 20 additions & 2 deletions wsdd2.8
Original file line number Diff line number Diff line change
Expand Up @@ -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 <intrerface>] [\-H <hostname>] [\-N <netbiosname>] [\-G <workgroup>]
[\-b <kvlist>]
[\-i <intrerface>] [\-H <hostname>] [\-A <hostaliases>] [\-N <netbiosname>]
[\-B <netbiosaliases>] [\-G <workgroup>] [\-b <kvlist>]

.SH "DESCRIPTION"
.PP
Expand Down Expand Up @@ -123,6 +123,15 @@ system host name retrieved with \fBgethostname\fR(3) or \fBuname\fR(3)
functions.
.RE

.PP
\-A <hostaliases>
.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 <nebiosname>
.RS 4
Expand All @@ -132,6 +141,15 @@ Use specified string as NETBIOS machine name instead of value returned by
name.
.RE

.PP
\-B <nebiosaliases>
.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 <workgroup>
.RS 4
Expand Down
25 changes: 23 additions & 2 deletions wsdd2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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();
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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:
Expand Down