Browse Source

Try to figure out nobodys uid und gid using getpwnam

dynamic-accesslists
erdgeist 18 years ago
parent
commit
bd4617a911
  1. 9
      opentracker.c

9
opentracker.c

@ -24,6 +24,7 @@
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <pwd.h>
#include "trackerlogic.h" #include "trackerlogic.h"
#include "scan_urlencoded_query.h" #include "scan_urlencoded_query.h"
@ -736,6 +737,7 @@ static void ot_try_bind( char ip[4], uint16 port, int is_tcp ) {
} }
int main( int argc, char **argv ) { int main( int argc, char **argv ) {
struct passwd *pws = NULL;
char serverip[4] = {0,0,0,0}; char serverip[4] = {0,0,0,0};
char *serverdir = "."; char *serverdir = ".";
int scanon = 1; int scanon = 1;
@ -759,8 +761,15 @@ int main( int argc, char **argv ) {
ot_try_bind( serverip, 6969, 1 ); ot_try_bind( serverip, 6969, 1 );
ot_try_bind( serverip, 6969, 0 ); ot_try_bind( serverip, 6969, 0 );
} }
pws = getpwnam( "nobody ");
if( !pws ) {
setegid( (gid_t)-2 ); setuid( (uid_t)-2 ); setegid( (gid_t)-2 ); setuid( (uid_t)-2 );
setgid( (gid_t)-2 ); seteuid( (uid_t)-2 ); setgid( (gid_t)-2 ); seteuid( (uid_t)-2 );
} else {
setegid( pws->pw_gid ); setuid( pws->pw_uid );
setgid( pws->pw_gid ); seteuid( pws->pw_uid );
}
signal( SIGPIPE, SIG_IGN ); signal( SIGPIPE, SIG_IGN );
signal( SIGINT, graceful ); signal( SIGINT, graceful );

Loading…
Cancel
Save