Skip to content

Commit

Permalink
endlessh: Error-out when specifying a port and listening on stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
nbraud committed Jan 31, 2020
1 parent f787d66 commit 4ba224f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions endlessh.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ struct config {
.bind_family = DEFAULT_BIND_FAMILY, \
}

static bool port_set = false;
static void
config_set_port(struct config *c, const char *s, int hardfail)
{
Expand All @@ -302,6 +303,7 @@ config_set_port(struct config *c, const char *s, int hardfail)
} else {
c->port = tmp;
}
port_set = true;
}

static void
Expand Down Expand Up @@ -676,6 +678,12 @@ main(int argc, char **argv)
exit(EXIT_FAILURE);
}

if (listen_on_stdin && port_set) {
fprintf(stderr,
"endlessh: Cannot specify a port when listening on stdin (-i)");
exit(EXIT_FAILURE);
}

/* Set output (log) to line buffered */
setvbuf(stdout, 0, _IOLBF, 0);

Expand Down

0 comments on commit 4ba224f

Please sign in to comment.