Compare commits
No commits in common. "b61f5c4caefec7801418659865835f4673c159ac" and "7b5d3e82d63651965aaba7fba62bd1d3474338bf" have entirely different histories.
b61f5c4cae
...
7b5d3e82d6
3 changed files with 16 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
|||
# feuille version
|
||||
VERSION = 1.18.2
|
||||
VERSION = 1.6.20
|
||||
|
||||
# paths (customize them to fit your system)
|
||||
PREFIX = /usr/local
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
. ftr VB CB
|
||||
. ftr VBI CBI
|
||||
.\}
|
||||
.TH "feuille" "1" "November 2022" "feuille 1.18.2" ""
|
||||
.TH "feuille" "1" "November 2022" "feuille 1.6.20" ""
|
||||
.hy
|
||||
.SH NAME
|
||||
.PP
|
||||
|
|
36
feuille.c
36
feuille.c
|
@ -16,7 +16,6 @@
|
|||
#include "feuille.h"
|
||||
|
||||
#include <errno.h> /* for errno, ERANGE, EAGAIN, EFBIG, ENOENT */
|
||||
#include <grp.h> /* for initgroups */
|
||||
#include <limits.h> /* for USHRT_MAX, ULONG_MAX, CHAR_MAX, PATH_MAX, UCHA... */
|
||||
#include <locale.h> /* for NULL, setlocale, LC_ALL */
|
||||
#include <pwd.h> /* for getpwnam, passwd */
|
||||
|
@ -316,10 +315,10 @@ int main(int argc, char *argv[])
|
|||
verbose(2, "creating folder `%s'...", settings.output);
|
||||
|
||||
if (realpath(settings.output, path) == NULL)
|
||||
die(errno, "could not get real path of directory `%s': %s.\n", settings.output, strerror(errno));
|
||||
die(errno, "Could not get real path of directory `%s': %s\n", settings.output, strerror(errno));
|
||||
|
||||
if (access(path, W_OK) != 0)
|
||||
die(errno, "cannot write to directory `%s': %s.\n", path, strerror(errno));
|
||||
die(errno, "Cannot write to directory `%s': %s\n", path, strerror(errno));
|
||||
|
||||
chdir(path);
|
||||
|
||||
|
@ -333,7 +332,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
struct passwd *user;
|
||||
if ((user = getpwnam(settings.user)) == NULL)
|
||||
die(1, "user `%s' doesn't exist.\n", settings.user);
|
||||
die(1, "User `%s' doesn't exist\n", settings.user);
|
||||
|
||||
uid = user->pw_uid;
|
||||
gid = user->pw_gid;
|
||||
|
@ -350,7 +349,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
int server;
|
||||
if ((server = initialize_server()) == -1)
|
||||
die(errno, "failed to initialize server socket: %f.\n", strerror(errno));
|
||||
die(errno, "Failed to initialize server socket: %s\n", strerror(errno));
|
||||
|
||||
|
||||
/* make feuille run in the background */
|
||||
|
@ -373,17 +372,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* privileges drop */
|
||||
verbose(2, "dropping root privileges...");
|
||||
setgid(gid);
|
||||
setuid(uid);
|
||||
|
||||
/* switching groups */
|
||||
if (setgid(gid) != 0 || getgid() != gid)
|
||||
die(1, "could not switch to group for user `%s'.\n", settings.user);
|
||||
|
||||
if (initgroups(settings.user, gid) != 0)
|
||||
die(1, "could not initialize other groups for user `%s'.\n", settings.user);
|
||||
|
||||
/* switching user */
|
||||
if (setuid(uid) != 0 || getuid() != uid)
|
||||
die(1, "could not switch to user `%s'.\n", settings.user);
|
||||
}
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
|
@ -392,11 +383,7 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
/* do not create a thread pool if in DEBUG mode */
|
||||
verbose(1, "running in DEBUG mode, won't create a worker pool.");
|
||||
accept_loop(server);
|
||||
#else
|
||||
#ifndef DEBUG
|
||||
/* create a thread pool for incoming connections */
|
||||
verbose(1, "initializing worker pool...");
|
||||
|
||||
|
@ -407,8 +394,14 @@ int main(int argc, char *argv[])
|
|||
accept_loop(server);
|
||||
|
||||
} else if (pid < 0)
|
||||
die(errno, "could not initialize worker n. %d: %s.\n", i, strerror(errno));
|
||||
die(errno, "Could not initialize worker n. %d: %s\n", i, strerror(errno));
|
||||
}
|
||||
#else
|
||||
/* do not create a thread pool if in DEBUG mode */
|
||||
verbose(1, "running in DEBUG mode, won't create a worker pool.");
|
||||
accept_loop(server);
|
||||
#endif
|
||||
|
||||
|
||||
sleep(1);
|
||||
|
||||
|
@ -432,7 +425,6 @@ int main(int argc, char *argv[])
|
|||
} else if (pid < 0)
|
||||
error("could not fork killed child again: ", strerror(errno));
|
||||
}
|
||||
#endif
|
||||
|
||||
close(server);
|
||||
return 0;
|
||||
|
|
Reference in a new issue