Mercurial > hg > early-roguelike
comparison srogue/mdport.c @ 175:10c273a62228
srogue: remove md_droppriv() and md_resetpriv().
These partial privilege-dropping functions are no longer needed.
| author | John "Elwin" Edwards |
|---|---|
| date | Sat, 01 Aug 2015 16:31:03 -0400 |
| parents | 600873555ec0 |
| children | f4f6734771e0 |
comparison
equal
deleted
inserted
replaced
| 174:1863409c44cf | 175:10c273a62228 |
|---|---|
| 1531 #else | 1531 #else |
| 1532 return( (long)sbrk(0) ); | 1532 return( (long)sbrk(0) ); |
| 1533 #endif | 1533 #endif |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 void | |
| 1537 md_droppriv(void) | |
| 1538 { | |
| 1539 #if defined(HAVE_GETUID) | |
| 1540 uid_t realuid = getuid(); | |
| 1541 | |
| 1542 #if defined(HAVE_SETRESUID) | |
| 1543 if (setresuid(-1, realuid, realuid) != 0) { | |
| 1544 #elif defined (HAVE_SETREUID) | |
| 1545 if (setreuid(realuid, realuid) != 0) { | |
| 1546 #elif defined (HAVE_SETUID) | |
| 1547 if (setuid(realuid) != 0) { | |
| 1548 #else | |
| 1549 if (0) { | |
| 1550 #endif | |
| 1551 printf("Cannot change to effective uid: %d\n", realuid); | |
| 1552 exit(1); | |
| 1553 } | |
| 1554 #endif | |
| 1555 } | |
| 1556 | |
| 1557 extern uid_t playuid; | |
| 1558 extern gid_t playgid; | |
| 1559 | |
| 1560 void | |
| 1561 md_resetpriv(void) | |
| 1562 { | |
| 1563 #if defined (HAVE_SETUID) | |
| 1564 setuid(playuid); | |
| 1565 #endif | |
| 1566 #if defined (HAVE_SETGID) | |
| 1567 setgid(playgid); | |
| 1568 #endif | |
| 1569 } | |
| 1570 | |
| 1571 int | 1536 int |
| 1572 md_random(void) | 1537 md_random(void) |
| 1573 { | 1538 { |
| 1574 #if defined (HAVE_LRAND48) | 1539 #if defined (HAVE_LRAND48) |
| 1575 return lrand48(); | 1540 return lrand48(); |
