Support OpenBSD 6.0 pledge() syscall for sandboxing.
This commit is contained in:
@@ -249,6 +249,7 @@ AC_CHECK_FUNCS(m4_normalize([
|
|||||||
pselect
|
pselect
|
||||||
getaddrinfo
|
getaddrinfo
|
||||||
getnameinfo
|
getnameinfo
|
||||||
|
pledge
|
||||||
]))
|
]))
|
||||||
|
|
||||||
AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if clock_gettime is available.])])
|
AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if clock_gettime is available.])])
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -563,6 +564,15 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
} else {
|
} else {
|
||||||
/* parent */
|
/* parent */
|
||||||
|
|
||||||
|
/* Drop unnecessary privileges */
|
||||||
|
#ifdef HAVE_PLEDGE
|
||||||
|
/* OpenBSD pledge() syscall */
|
||||||
|
if ( pledge( "stdio inet ioctl tty", NULL )) {
|
||||||
|
perror( "pledge() failed" );
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UTEMPTER
|
#ifdef HAVE_UTEMPTER
|
||||||
/* make utmp entry */
|
/* make utmp entry */
|
||||||
utempter_add_record( master, utmp_entry );
|
utempter_add_record( master, utmp_entry );
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -407,6 +408,15 @@ bool STMClient::main( void )
|
|||||||
/* initialize signal handling and structures */
|
/* initialize signal handling and structures */
|
||||||
main_init();
|
main_init();
|
||||||
|
|
||||||
|
/* Drop unnecessary privileges */
|
||||||
|
#ifdef HAVE_PLEDGE
|
||||||
|
/* OpenBSD pledge() syscall */
|
||||||
|
if ( pledge( "stdio inet ioctl tty", NULL )) {
|
||||||
|
perror( "pledge() failed" );
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* prepare to poll for events */
|
/* prepare to poll for events */
|
||||||
Select &sel = Select::get_instance();
|
Select &sel = Select::get_instance();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user