-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
some small bug fixes and add the possibility to build without using t… #44
base: master
Are you sure you want to change the base?
Conversation
Please list the new options in wsdd2.c's help() output and in wsdd2.8. |
There are no new options. |
Command line options |
Please take a closer look at the code, they are not new. |
Right, but they were not implemented before. 1.8.7:
(the wsdd2.8 needs update still. |
What is currently preventing the merge? |
It would be better command line options override the Is not this enough? diff --git a/wsdd2.c b/wsdd2.c
index 8f81936..52141a3 100644
--- a/wsdd2.c
+++ b/wsdd2.c
@@ -691,9 +691,7 @@ int main(int argc, char **argv)
const char *prog = basename(argv[0]);
unsigned int ipv46 = 0, tcpudp = 0, llmnrwsdd = 0;
- 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 +738,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 +760,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:
@@ -765,6 +771,8 @@ int main(int argc, char **argv)
if (argc > optind)
help(prog, EXIT_FAILURE, "Unknown argument '%s'", argv[optind]);
+ init_sysinfo();
+
if (!ipv46)
ipv46 = _4 | _6;
if (!llmnrwsdd) |
Sorry, diff --git a/wsdd2.c b/wsdd2.c
index 8f81936..1e716a8 100644
--- a/wsdd2.c
+++ b/wsdd2.c
@@ -656,24 +656,35 @@ static void init_sysinfo()
{
char hostn[HOST_NAME_MAX + 1];
- if (!hostname && gethostname(hostn, sizeof(hostn) - 1) != 0)
- err(EXIT_FAILURE, "gethostname");
-
- char *p = strchr(hostn, '.');
- if (p) *p = '\0';
- hostname = strdup(hostn);
+ /* command line options have preference */
+ if (!hostname) {
+ if (gethostname(hostn, sizeof(hostn) - 1) != 0)
+ err(EXIT_FAILURE, "gethostname");
+
+ char *p = strchr(hostn, '.');
+ if (p) *p = '\0';
+ hostname = strdup(hostn);
+ }
- if (!hostaliases && !(hostaliases = get_smbparm("additional dns hostnames", "")))
- err(EXIT_FAILURE, "get_smbparm");
+ if (!hostaliases) {
+ if (!(hostaliases = get_smbparm("additional dns hostnames", "")))
+ err(EXIT_FAILURE, "get_smbparm");
+ }
- if (!netbiosname && !(netbiosname = get_smbparm("netbios name", hostname)))
- err(EXIT_FAILURE, "get_smbparm");
+ if (!netbiosname) {
+ if (!(netbiosname = get_smbparm("netbios name", hostname)))
+ err(EXIT_FAILURE, "get_smbparm");
+ }
- if (!netbiosaliases && !(netbiosaliases = get_smbparm("netbios aliases", "")))
- err(EXIT_FAILURE, "get_smbparm");
+ if (!netbiosaliases) {
+ if (!(netbiosaliases = get_smbparm("netbios aliases", "")))
+ err(EXIT_FAILURE, "get_smbparm");
+ }
- if (!workgroup && !(workgroup = get_smbparm("workgroup", "WORKGROUP")))
- err(EXIT_FAILURE, "get_smbparm");
+ if (!workgroup) {
+ if (!(workgroup = get_smbparm("workgroup", "WORKGROUP")))
+ err(EXIT_FAILURE, "get_smbparm");
+ }
init_getresp();
}
@@ -691,9 +702,7 @@ int main(int argc, char **argv)
const char *prog = basename(argv[0]);
unsigned int ipv46 = 0, tcpudp = 0, llmnrwsdd = 0;
- 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 +749,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 +771,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:
@@ -765,6 +782,8 @@ int main(int argc, char **argv)
if (argc > optind)
help(prog, EXIT_FAILURE, "Unknown argument '%s'", argv[optind]);
+ init_sysinfo();
+
if (!ipv46)
ipv46 = _4 | _6;
if (!llmnrwsdd) |
|
However, on systems without testparm I am forced to specify a hostalias. Furthermore, I do not understand the meaning of the following amendment. - if (!hostaliases && !(hostaliases = get_smbparm("additional dns hostnames", "")))
- err(EXIT_FAILURE, "get_smbparm");
+ if (!hostaliases) {
+ if (!(hostaliases = get_smbparm("additional dns hostnames", "")))
+ err(EXIT_FAILURE, "get_smbparm");
+ } With double amperesand, the second condition is no longer evaluated if the first one already fails. |
Is it not enough? Sure, you can keep the short-circuit evaluation. It is my personal preference only. |
What does "not enough" mean? If I don't need an alias, I don't want to have to make one up. |
Sorry, I misread. Right, need the #define. Scratch my suggestions, you patch is minimal and works. |
I just faced the issue with missing Regarding the |
I will no longer make any changes to the pull request. I have been waiting for the commit for a year and three months now and have made all the "required" changes and extensions during this time. Either it will now be committed or not. |
I will do it, no problem. Anyway, I plan to enhance the logic to accept |
I chose the build-switch for testparm because I want to build it for an embedded system. If a command line switch is used, I always have to set this switch on a system on which there is definitely no testparm. This is exactly what I wanted to avoid. What functionality is missing from -A and -B? I have already done a lot in this regard in my PR. |
So just fix usage of
Just what you did in this PR - add them to getopt. I expect that when I am finished with my changes, this PR will not be necessary. |
Please find here result of 3-hours programming session, it should have everything I wanted (including handling of missing |
I'll do a build test in my cross-compiler environment in the next few days. |
I gave it a quick test and deployed a fix. I will not have time till next week to test it more I wonder. |
I made a draft Pull Request #51 with all the changes |
…estparm
wsd.c:
With the change Dolphin shows the hostname and not only the IP. Content-Type can additionally contain one or more parameters separated by semicolon. Dolphin also sends the charset among other things.
wsdd.h:
I had to remove the include because otherwise the following build error comes.
error: redefinition of 'struct sockaddr_in'
netinet/in.h and linux/in.h should never be used together. linux/in.h is for kernel builds and netinet/in.h is for userland builds. Also, in wsdd2.c _GNU_SOURCE is defined and thus struct ip_mreqn is available via bits/in.h.
wsdd2.c:
Here my changes should be self-explanatory.