htparser: Allow PID-file, chuser and chroot arguments to be treated as NULL if empty.
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 14 May 2021 14:06:07 +0000 (16:06 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 14 May 2021 14:06:07 +0000 (16:06 +0200)
src/htparser.c

index 348a940..b7435b9 100644 (file)
@@ -621,16 +621,16 @@ int main(int argc, char **argv)
            usesyslog = 1;
            break;
        case 'u':
-           if((pwent = getpwnam(optarg)) == NULL) {
+           if(optarg[0] && ((pwent = getpwnam(optarg)) == NULL)) {
                flog(LOG_ERR, "could not find user %s", optarg);
                exit(1);
            }
            break;
        case 'r':
-           root = optarg;
+           root = optarg[0] ? optarg : NULL;
            break;
        case 'p':
-           pidfile = optarg;
+           pidfile = optarg[0] ? optarg : NULL;
            break;
        default:
            usage(stderr);