109 Commits

Author SHA1 Message Date
Michael Santos
c179d9a57b start_listen_sockets: exit if no addresses
Do not allocate a 0 byte buffer if no addresses are available:

    common.c:122:14: warning: Call to 'malloc' has an allocation size of 0 bytes
       *sockfd = malloc(num_addr * sizeof(*sockfd[0]));
		 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-06-18 10:35:28 -04:00
Yves Rutschle
7acf9627ee fix memory leak when using transparent proxying 2018-05-29 12:38:57 +02:00
Yves Rutschle
1a6ba5edc0 fix IPv6 parse error introduced in 7bf3e12c30d0585743792982ed8bcfc44aecae34 2018-01-27 22:59:52 +01:00
Yves Rutschlé
7bf3e12c30 Don't clobber data in libconfig space, copy it before
changing it. So far it worked, but really that's not
respecting the contract.
2018-01-07 16:43:50 +00:00
Mike Frysinger
0fb4c6b2ad add chroot support
This allows people to chroot sslh into a path to further harden it.

We have to rework the user logic a bit because we need to look up
the user details *before* we chroot (as we need to read /etc/passwd
files), but do the actual priv dropping *after* we chroot (so we
have permission to make the actual chroot call).

Similarly, we need to open the syslog before we drop privs because
/dev/log won't be available inside the chroot.
2018-01-03 10:19:59 -05:00
yrutschle
24cd3d0974
Merge pull request #161 from pali/master
Ensure that IPv6 socket would listen only for IPv6 connections
2018-01-02 23:19:00 +01:00
Pali Rohár
3db5e127fd Ensure that IPv6 socket would listen only for IPv6 connections
When transparent mode is enabled and sslh listening on :: IPv6 address then
source origin address is propagated to target application independently if
connection is IPv4 or IPv6.

On Linux by default IPv6 socket can accept also IPv4 connections. More
applications, including OpenSSH server do not accept IPv4 connections on
IPv6 socket and therefore such transparent configuration does not work.
On BSD systems it is turned off by default due to security reasons.

This patch disables IPv4 connections on IPv6 listening sockets. If somebody
needs to have sslh listening on both IPv4 and IPv6 addresses, then still it
is possible by specifying multiple --listen arguments.

I think it is more misleading if option --listen :::443 cause listening on
both IPv4 and IPv6 addresses even IPv4 address was not specified. This can
also cause security related problems for people who do not know about this
fact as documentation does not mentioned this behavior.
2017-12-28 21:31:15 +01:00
Robert de Bath
981091e39d Translate systemd C99 and C++ code to old C 2017-12-17 16:37:00 +00:00
yrutschle
7808a3a766
Merge pull request #142 from astiob/select-bugs
Fix several bugs in sslh-select
2017-12-16 19:51:23 +01:00
Yves Rutschle
6ca1ee7bfd remove leftover debug messages 2017-11-26 20:10:05 +01:00
Robert de Bath
9fcbe8c7ea Fixup compile using -std=c90 2017-11-23 20:50:49 +00:00
Oleg Oshmyan
60b11e4964 Fix defer_write when deferred_data != begin_deferred_data
I think this currently never happens, but let's
not wait until it starts happening and blows up.
2017-10-28 23:13:29 +03:00
Yves Rutschle
f4d2a8d2ad fix logging to specified facility 2017-07-22 17:20:45 +02:00
Yves Rutschle
aa06261d70 added syslog_facility option 2017-07-21 22:46:24 +02:00
Yves Rutschle
00d5872aa1 ignore brackets in hostname in config files 2017-04-21 22:33:02 +02:00
Yves Rutschle
b0f4e24ce0 IP_FREEBIND: real fix, ignore catastrophic previous checkin 2017-04-06 17:13:11 +02:00
Yves Rutschle
078827ad3f Some systems define IP_FREEBIND but don't implement it which result in setsockopt() failing. No need to die in that case, just ignore the error. 2017-04-06 16:26:27 +02:00
Yves Rutschle
067f5d7646 Revert "clarify no space after -F (issue 108)"
This reverts commit f02ce3821c018719536971dbb1bc1ed1517530a2.

That commit accidently imported code that broke transparent
proxying.
2017-01-08 12:54:34 +01:00
Yves Rutschlé
f02ce3821c clarify no space after -F (issue 108) 2016-11-06 19:44:47 +00:00
Yves Rutschlé
245fd26459 fix compiler warnings 2016-05-03 08:37:23 +00:00
yrutschle
9cc47a157d Merge pull request #69 from ViKingIX/fix_local_conn
Fix the connection problem in transparent mode.
2016-04-28 11:55:56 +02:00
yrutschle
8f39c106e1 Merge pull request #56 from hogarthj/master
Initial addition of systemd socket based activiation
2016-02-05 16:46:47 +01:00
Yves Rutschle
414ed7de11 Support keepalive for connections on the connecting side 2016-02-04 09:19:54 +01:00
Yves Rutschle
1b9937b293 Support keepalive for connections on the listening side 2016-02-02 21:07:47 +01:00
James Hogarth
b3f48d9876 Add systemd capabilities to sslh, rebased on current master 2016-01-29 16:20:54 +00:00
Yves Rutschle
8758a298ba Changed connection log to include the name of the probe that triggered. 2015-12-15 16:06:14 +01:00
Yves Rutschle
2cb424c646 Added log_level option to configuration file, which switches off log at each connection 2015-12-15 15:51:18 +01:00
ViKing
b108809a78 Fix the connection problem in transparent mode.
When the source and destination are the same, the bind_peer() will
fail, thus end the connection. Therefore a check of all the interface
IPs are checked to skip bind() if they are the same.
2015-10-07 00:10:03 +08:00
Eero Häkkinen
717c285b31 Fix access rights checking to work with IPv6. 2015-09-27 22:14:00 +03:00
Yves Rutschle
56fdc6b4af Transparant proxy support for FreeBSD 2014-12-25 20:08:24 +01:00
Yves Rutschle
b9ddfb4c7a Support RFC5952-style IPv6 addresses 2014-12-22 18:19:02 +01:00
Ruben van Staveren
ece6e28e45 #ifdef IP_BINDANY/IPV6_BINDANY cases 2014-07-24 17:29:53 +02:00
Ruben van Staveren
e2fc091482 When transparent, make sure both connections use the same address family 2014-07-22 20:05:25 +02:00
Ruben van Staveren
e246536be2 FreeBSD way of doing transparent proxy: work in progress 2014-07-22 20:05:25 +02:00
Yves Rutschle
426797f9c0 call setgroups before setgid 2014-03-30 17:28:00 +02:00
Belobrov Andrey
ff070a6b46 Fixed possible file descriptor leak. 2014-02-14 08:32:38 +04:00
Yves Rutschle
6bcb5c83f2 libcap support: print out process capabilities at startup if verbose 2014-02-09 21:39:27 +01:00
Yves Rutschle
4dfa694e8a Merged libcap patch 2014-02-09 20:34:26 +01:00
Yves Rutschle
67c34a7460 set IP_FREEBIND if available to bind to non-existent interfaces 2014-02-09 13:29:49 +01:00
Sebastian Schmidt
009faa64b7 Implement libcap support
Use libcap for saving CAP_NET_ADMIN (if --transparent is given) over a
setuid(). We don’t need CAP_NET_BIND_SERVICE as the listening sockets
are established before dropping root.
2013-10-20 21:16:56 +02:00
Yves Rutschle
96f5d6387e new test for PROBE_AGAIN; changed deferred_data to begin_deferred_data where appropriate 2013-09-28 21:33:25 +02:00
Ondrej Kuznk
025545aee3 Fix typos and type warnings 2013-09-28 20:49:46 +02:00
Ondřej Kuzník
e4fb8b8496 defered -> deferred 2013-09-28 20:42:04 +02:00
Ondřej Kuzník
d7bbec0dc7 Simplify function signatures 2013-09-28 20:21:48 +02:00
Ondřej Kuzník
dbafd6510d Allow probes to say they cannot decide yet 2013-09-28 20:21:47 +02:00
Ondřej Kuzník
c5cd91d92c Let defer_write accumulate data 2013-09-28 20:21:47 +02:00
Mike Frysinger
2d23cdc9f4 check asprintf return value
The current asprintf usage triggers many warnings like:

sslh-main.c: In function 'print_usage':
sslh-main.c:86:17: warning: ignoring return value of 'asprintf',
	declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-09-17 00:26:44 -04:00
Mike Frysinger
b8ea0699c4 drop_privileges: fix setuid check
The code attempts to check the return of setuid, but forgets to assign
the result variable.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-09-17 00:23:26 -04:00
Jason Cooper
c6adb6a1e1 remove unneeded executable permissions on source files
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-09-16 21:56:38 +02:00
Yves Rutschle
f3c5f098ca fixed getpeername causing sslh to quit 2013-08-29 12:15:50 +02:00