aboutsummaryrefslogtreecommitdiff
path: root/src/util/os_installation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-11 14:35:04 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-11 14:35:04 +0000
commitb381e2c60e3f5f9404fe070082d164bf99020869 (patch)
tree55dd9f51c3b86fe19cf53eb1cbbf64bada275cd2 /src/util/os_installation.c
parent6eee0ac04bfb98bc4adad02458fa4e3b4f899229 (diff)
downloadgnunet-b381e2c60e3f5f9404fe070082d164bf99020869.tar.gz
gnunet-b381e2c60e3f5f9404fe070082d164bf99020869.zip
bincheck
Diffstat (limited to 'src/util/os_installation.c')
-rw-r--r--src/util/os_installation.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 9bf260979..36627a8d8 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -438,14 +438,15 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
438 438
439 439
440/** 440/**
441 * Check whether the suid bit is set on a file. 441 * Check whether an executable exists and possibly
442 * if the suid bit is set on the file.
442 * Attempts to find the file using the current 443 * Attempts to find the file using the current
443 * PATH environment variable as a search path. 444 * PATH environment variable as a search path.
444 * 445 *
445 * @param binary the name of the file to check 446 * @param binary the name of the file to check
446 * @return GNUNET_YES if the file is SUID, 447 * @return GNUNET_YES if the file is SUID,
447 * GNUNET_NO if not, 448 * GNUNET_NO if not SUID (but binary exists)
448 * GNUNET_SYSERR on error 449 * GNUNET_SYSERR on error (no such binary or not executable)
449 */ 450 */
450int 451int
451GNUNET_OS_check_helper_binary (const char *binary) 452GNUNET_OS_check_helper_binary (const char *binary)
@@ -477,11 +478,10 @@ GNUNET_OS_check_helper_binary (const char *binary)
477#endif 478#endif
478 if (p == NULL) 479 if (p == NULL)
479 { 480 {
480 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 481 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
481 "tcp", 482 _("Could not find binary `%s' in PATH!\n"),
482 _("Could not find binary `%s' in PATH!\n"), 483 binary);
483 binary); 484 return GNUNET_SYSERR;
484 return GNUNET_NO;
485 } 485 }
486 if (0 != STAT (p, &statbuf)) 486 if (0 != STAT (p, &statbuf))
487 { 487 {
@@ -492,20 +492,28 @@ GNUNET_OS_check_helper_binary (const char *binary)
492 GNUNET_free (p); 492 GNUNET_free (p);
493 return GNUNET_SYSERR; 493 return GNUNET_SYSERR;
494 } 494 }
495 GNUNET_free (p);
496#ifndef MINGW 495#ifndef MINGW
497 if ( (0 != (statbuf.st_mode & S_ISUID)) && 496 if ( (0 != (statbuf.st_mode & S_ISUID)) &&
498 (statbuf.st_uid == 0) ) 497 (statbuf.st_uid == 0) )
499 return GNUNET_YES; 498 {
500 return GNUNET_NO; 499 GNUNET_free (p);
500 return GNUNET_YES;
501 }
502 if (0 == ACCESS (p, X_OK))
503 {
504 GNUNET_free (p);
505 return GNUNET_NO;
506 }
507 GNUNET_free (p);
508 return GNUNET_SYSERR;
501#else 509#else
510 GNUNET_free (p);
502 rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP); 511 rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
503 if (INVALID_SOCKET == rawsock) 512 if (INVALID_SOCKET == rawsock)
504 { 513 {
505 DWORD err = GetLastError (); 514 DWORD err = GetLastError ();
506 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, 515 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
507 "tcp", 516 "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) failed! GLE = %d\n", err);
508 "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) failed! GLE = %d\n", err);
509 return GNUNET_NO; /* not running as administrator */ 517 return GNUNET_NO; /* not running as administrator */
510 } 518 }
511 closesocket (rawsock); 519 closesocket (rawsock);