ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/tools.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/tools.c (file contents):
Revision 1.55 by tdb, Fri Jul 16 15:28:02 2004 UTC vs.
Revision 1.58 by ats, Mon Nov 1 20:34:58 2004 UTC

# Line 481 | Line 481 | struct uvmexp *sg_get_uvmexp() {
481          mib[1] = VM_UVMEXP;
482  
483          if (sysctl(mib, 2, &uvm, &size, NULL, 0) < 0) {
484 <                sg_set_error(SG_ERROR_SYSCTL, "CTL_VM.VM_UVMEXP");
484 >                sg_set_error_with_errno(SG_ERROR_SYSCTL, "CTL_VM.VM_UVMEXP");
485                  return NULL;
486          }
487  
# Line 513 | Line 513 | int sg_init(){
513   }
514  
515   int sg_drop_privileges() {
516 + #ifdef HAVE_SETEGID
517          if (setegid(getgid()) != 0) {
518 <                sg_set_error(SG_ERROR_SETEGID, NULL);
518 > #elif defined(HAVE_SETRESGID)
519 >        if (setresgid(getgid(), getgid(), getgid()) != 0) {
520 > #else
521 >        {
522 > #endif
523 >                sg_set_error_with_errno(SG_ERROR_SETEGID, NULL);
524                  return -1;
525          }
526 + #ifdef HAVE_SETEUID
527          if (seteuid(getuid()) != 0) {
528 <                sg_set_error(SG_ERROR_SETEUID, NULL);
528 > #elif defined(HAVE_SETRESUID)
529 >        if (setresuid(getuid(), getuid(), getuid()) != 0) {
530 > #else
531 >        {
532 > #endif
533 >                sg_set_error_with_errno(SG_ERROR_SETEUID, NULL);
534                  return -1;
535          }
536          return 0;
# Line 528 | Line 540 | void *sg_realloc(void *ptr, size_t size) {
540          void *tmp = NULL;
541          tmp = realloc(ptr, size);
542          if(tmp == NULL) {
543 <                sg_set_error(SG_ERROR_MALLOC, NULL);
543 >                sg_set_error_with_errno(SG_ERROR_MALLOC, NULL);
544          }
545          return tmp;
546   }
535

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines