add OpenBSD pledge support - thanks Gleydson Soares

This commit is contained in:
Nico Golde 2016-09-02 16:13:43 +02:00
parent f79e2f0953
commit 18580a159f
2 changed files with 11 additions and 0 deletions

View File

@ -25,3 +25,6 @@ LIBS = -L${LIBDIR} -L/usr/lib -lc
CC = cc
CFLAGS = -g -O0 -W -Wall ${INCLUDES} -DVERSION=\"${VERSION}\"
LDFLAGS = ${LIBS}
# OpenBSD pledge(2) support
# CFLAGS+= -DUSE_PLEDGE

8
ii.c
View File

@ -490,6 +490,14 @@ int main(int argc, char *argv[]) {
}
}
irc = tcpopen(port);
#ifdef USE_PLEDGE /* OpenBSD pledge(2) support */
if (pledge("stdio rpath wpath cpath dpath", NULL) == -1) {
fputs("ii: pledge\\n", stderr);
exit(EXIT_FAILURE);
}
#endif
if(!snprintf(path, sizeof(path), "%s/%s", prefix, host)) {
fputs("ii: path to irc directory too long\n", stderr);
exit(EXIT_FAILURE);