Compare commits

..
8 Commits
7 changed files with 54 additions and 19 deletions

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ sslh-ev
systemd-sslh-generator
sslh.8.gz
tags
version.h
/config.status
/config.log
/config.h
+9
View File
@@ -1,3 +1,12 @@
v2.2.3:
Reverse older commit: version.h cannot be included
without breaking the build (everything recompiles
every time) and the release archive creation (which
relies on git tags).
v2.2.2:
Fix potential vulnerability similar to CVE-2020-28935
v2.2.1:
Added a boolean setting "is_unix" for listen and
protocol entries. This will use the 'host' setting
+1 -3
View File
@@ -70,9 +70,8 @@ all: sslh-fork sslh-select $(MAN) echosrv $(CONDITIONAL_TARGETS)
$(OBJS_A): $(OBJS)
$(AR) rcs $(OBJS_A) $(OBJS)
version.h: .FORCE
version.h:
./genver.sh >version.h
.FORCE:
$(OBJS) $(FORK_OBJS) $(SELECT_OBJS) $(EV_OBJS): argtable3.h collection.h common.h gap.h hash.h log.h probe.h processes.h sslh-conf.h tcp-listener.h tcp-probe.h tls.h udp-listener.h version.h
@@ -145,7 +144,6 @@ distclean: clean
clean:
rm -f sslh-fork sslh-select $(CONDITIONAL_TARGETS) echosrv version.h $(MAN) systemd-sslh-generator *.o *.gcov *.gcno *.gcda *.png *.html *.css *.info
echo "// this is a placeholder for version.h, to make code-checking editors happy" > version.h
tags:
ctags --globals -T *.[ch]
+33 -11
View File
@@ -986,26 +986,48 @@ void drop_privileges(const char* user_name, const char* chroot_path)
}
}
#ifndef O_NOFOLLOW
#define O_NOFOLLOW 0
#endif
/* Writes my PID */
void write_pid_file(const char* pidfile)
{
FILE *f;
int res;
int fd;
char pidbuf[32];
size_t len, written = 0;
ssize_t res;
f = fopen(pidfile, "w");
if (!f) {
/* Format PID as string */
len = snprintf(pidbuf, sizeof(pidbuf), "%d\n", getpid());
if (len >= sizeof(pidbuf)) {
print_message(msg_system_error, "write_pid_file: PID string too long\n");
return;
}
/* Open file with O_NOFOLLOW to prevent symlink attacks (Similar to CVE-2020-28935) */
fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW ,0644);
if (fd == -1) {
print_message(msg_system_error, "write_pid_file: %s: %s\n", pidfile, strerror(errno));
return;
}
res = fprintf(f, "%d\n", getpid());
if (res < 0) {
print_message(msg_system_error, "write_pid_file: fprintf: %s\n", strerror(errno));
/* Write PID to file with proper error handling */
while (written < len) {
res = write(fd, pidbuf + written, len - written);
if (res == -1) {
if (errno == EINTR || errno == EAGAIN)
continue;
print_message(msg_system_error, "write_pid_file: write: %s\n", strerror(errno));
break;
}
written += res;
}
res = fclose(f);
if (res == EOF) {
print_message(msg_system_error, "write_pid_file: fclose: %s\n", strerror(errno));
return;
/* Close file */
if (close(fd) == -1) {
print_message(msg_system_error, "write_pid_file: close: %s\n", strerror(errno));
}
}
+8
View File
@@ -34,6 +34,10 @@
#include <sys/capability.h>
#endif
#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif
#include "config.h"
#include "version.h"
@@ -182,6 +186,10 @@ extern struct sslhcfg_item cfg;
extern struct addrinfo *addr_listen;
extern const char* server_type;
#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED < 1080)
extern int hosts_ctl();
#endif
/* sslh-fork.c */
void start_shoveler(int);
+2
View File
@@ -20,6 +20,8 @@
*/
#include "config.h"
#ifdef HAVE_PROXYPROTOCOL
#include <proxy_protocol.h>
-5
View File
@@ -1,5 +0,0 @@
#ifndef VERSION_H
#define VERSION_H
#define VERSION "v2.2.0-dirty"
#endif