Skip to content

Commit

Permalink
Allow option '-f' also for non-root (since setuid privileges are drop…
Browse files Browse the repository at this point in the history
…ped)
  • Loading branch information
schweikert committed Apr 28, 2014
1 parent d4e0a6c commit 86f0b1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
UNRELEASED
* More tests added
* Fix confusing error message with -g and IPv6 addresses (#58, reported by Axel Beckert)
* Allow option '-f' also for non-root (since setuid privileges are dropped)

2014-03-08 David Schweikert <david@schweikert.ch>
* Version 3.9
Expand Down
22 changes: 2 additions & 20 deletions src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ int main( int argc, char **argv )
s = open_ping_socket();

if((uid = getuid())) {
seteuid( getuid() );
/* drop privileges */
setuid( getuid() );
}

prog = argv[0];
Expand Down Expand Up @@ -509,27 +510,8 @@ int main( int argc, char **argv )
exit( 0 );

case 'f':
#ifdef ENABLE_F_OPTION
filename = optarg;
generate_flag = 0;
break;
#else
if( getuid() )
{
printf( "%s: this option can only be used by root.\n", argv[0] );
printf( "%s: fping will read from stdin by default.\n", argv[0] );
exit( 3 );

}/* IF */
else
{
filename = optarg;
generate_flag = 0;

}/* ELSE */

break;
#endif /* ENABLE_F_OPTION */

case 'g':
/* use IP list generation */
Expand Down

0 comments on commit 86f0b1e

Please sign in to comment.