Moved seteuid
This commit is contained in:
22
src/runner.c
22
src/runner.c
@@ -21,6 +21,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <poll.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
@@ -54,6 +55,27 @@ void runServer(int connfd, Sitefile *site, Listener *listener,
|
||||
createLog("Socket type is somehow invalid");
|
||||
return;
|
||||
}
|
||||
if (context == NULL) {
|
||||
createErrorLog("Failed to create context", errno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
{
|
||||
struct passwd *swebs, *root;
|
||||
swebs = getpwnam("swebs");
|
||||
if (swebs == NULL)
|
||||
createLog("Couldn't find swebs user");
|
||||
else
|
||||
if (seteuid(swebs->pw_uid))
|
||||
createErrorLog("seteuid() failed", errno);
|
||||
root = getpwnam("root");
|
||||
if (root != NULL) {
|
||||
/* I don't know why this if statement could be false but we have it
|
||||
* just in case. */
|
||||
if (geteuid() == root->pw_uid)
|
||||
createLog("swebs probably should not be run as root");
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
int i;
|
||||
|
||||
Reference in New Issue
Block a user