Skip to content

Commit

Permalink
Updated PR as discussion in issue 468 , currently ony for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ftasnetamot committed Aug 26, 2024
1 parent e5fb5a3 commit d4c4b0c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
11 changes: 9 additions & 2 deletions doc/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ After each run of ./configure, those changes are gone and the Makefile is recrea
There are a couple of configuration options at the beginning of the Makefile:

* `# override undefine HAVE_LANDLOCK` if you uncomment this line, sslh will be compiled
without landlock. As an alternative ./configure creates a config.h file,
which gives also the possibility, to comment that out.
without landlock. This works with gcc versions < 12. Otherwise, if your system has
linux/landlock.h in the include path, the configure script creates a _**config.h**_ file,
which defines HAVE_LANDLOCK. It is not enough, to set this to 0, you must delete it,
when you don't wish to have landlock in your binary.

* `USELIBWRAP` compiles support for host access control (see `hosts_access(3)`),
you will need `libwrap` headers and library to compile (`libwrap0-dev` in Debian).
Expand All @@ -82,6 +84,11 @@ There are a couple of configuration options at the beginning of the Makefile:

* `USELIBBSD` compiles support for updating the process name (as shown by `ps`).

* `USELIBCAP` compiles support for libcap, which allows to inherit capabilities to
daughter-processes, which run as restricted users. You need this, when you wish to
make sure, that the --user= parameter can be used, without setting capabilities etc.
to your binaries, to make this work.

Now you can do either a plain `make` to create the binaries, or you can do an
`make install` to create the binaries and install them.

Expand Down
3 changes: 3 additions & 0 deletions landlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ static int add_path_ro(int ruleset_fd, ll_obj_type otype, const char* path)
return -1;
}

// close helper handle
close(fd);

return 0;
}

Expand Down
12 changes: 9 additions & 3 deletions sslh-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,20 @@ int main(int argc, char *argv[], char* envp[])
if (!cfg.foreground) {
if (fork() > 0) exit(0); /* Detach */
// close stdin, stderr, stdout
// closing stdin frees a filehandle, and 0 will not be reused, so no problem
// with control-jobs, trying to catch fd/0
close(fileno(stdin));
int newfd;
if (newfd = open("/dev/null", O_RDWR)) {
dup2 (newfd, STDIN_FILENO);
// duplicating a handle connected to /dev/null to stdout and stderr
// so we don't run in any problems, when a control-job wor whats-o-ever will
// grab stdout and stderr
if ((newfd = open("/dev/null", O_RDWR))) {
dup2 (newfd, STDOUT_FILENO);
dup2 (newfd, STDERR_FILENO);
// close the helper handle, as this is now unnecessary
close(newfd);
} else {
print_message(msg_config, "Error closing standard filehandles for background daemon\n");
print_message(msg_system_error, "Error closing standard filehandles for background daemon\n");
}

/* New session -- become group leader */
Expand Down
2 changes: 1 addition & 1 deletion sslh-select.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void start_shoveler(int listen_socket) {
}


/* The actual main is in common.c: it's the same for both version of
/* The actual main is in sslh-main.c: it's the same for all versions of
* the server
*/

Expand Down

0 comments on commit d4c4b0c

Please sign in to comment.