mirror of
https://github.com/bol-van/zapret.git
synced 2025-04-19 05:22:58 +03:00
tpws : dropcaps
This commit is contained in:
parent
352f93ced2
commit
8b9d7f56d3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -12,7 +12,7 @@ define Package/tpws
|
||||
CATEGORY:=Network
|
||||
TITLE:=tpws
|
||||
SUBMENU:=Zapret
|
||||
DEPENDS:=+zlib
|
||||
DEPENDS:=+zlib +libcap
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
|
24
tpws/tpws.c
24
tpws/tpws.c
@ -23,6 +23,7 @@
|
||||
#include <getopt.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/capability.h>
|
||||
|
||||
#include "tpws.h"
|
||||
#include "tpws_conn.h"
|
||||
@ -789,6 +790,26 @@ void daemonize()
|
||||
/* stderror */
|
||||
}
|
||||
|
||||
bool dropcaps()
|
||||
{
|
||||
cap_t capabilities;
|
||||
|
||||
capabilities = cap_init();
|
||||
if (cap_clear(capabilities))
|
||||
{
|
||||
perror("cap_init");
|
||||
return false;
|
||||
}
|
||||
if (cap_set_proc(capabilities))
|
||||
{
|
||||
perror("cap_set_proc");
|
||||
cap_free(capabilities);
|
||||
return false;
|
||||
}
|
||||
cap_free(capabilities);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool droproot()
|
||||
{
|
||||
if (params.uid || params.gid)
|
||||
@ -804,9 +825,10 @@ bool droproot()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return dropcaps();
|
||||
}
|
||||
|
||||
|
||||
bool writepid(const char *filename)
|
||||
{
|
||||
FILE *F;
|
||||
|
Loading…
x
Reference in New Issue
Block a user