commit a664e2a655f0998182fae411ede0d8af6be1fb18
parent 2d9940e197632729551c12926d2f86104e02fbed
Author: Joris Vink <joris@coders.se>
Date: Thu, 31 Jul 2014 13:59:42 +0200
Make some configuration options fallback to defaults.
* If no runas_user is given, use current user.
* If no chroot path is given, don't complain if -n
* If no workers is set, use the default 1.
Diffstat:
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/config.c b/src/config.c
@@ -126,6 +126,8 @@ static struct kore_module_handle *current_handler = NULL;
void
kore_parse_config(void)
{
+ char *p;
+
if (config_file == NULL)
fatal("specify a configuration file with -c");
@@ -135,12 +137,21 @@ kore_parse_config(void)
fatal("no site module was loaded");
if (kore_cb_name != NULL && kore_cb == NULL)
fatal("no '%s' symbol found for kore_cb", kore_cb_name);
+
if (LIST_EMPTY(&listeners))
fatal("no listeners defined");
- if (skip_chroot != 0 && chroot_path == NULL)
+
+ if (skip_chroot != 1 && chroot_path == NULL)
fatal("missing a chroot path");
- if (runas_user == NULL)
- fatal("missing a username to run as");
+
+ if (runas_user == NULL) {
+ if ((p = getlogin()) == NULL)
+ fatal("missing a username to run as");
+
+ /* runas_user is free'd later down the line. */
+ runas_user = kore_strdup(p);
+ }
+
if ((pw = getpwnam(runas_user)) == NULL)
fatal("user '%s' does not exist", runas_user);
diff --git a/src/worker.c b/src/worker.c
@@ -76,7 +76,7 @@ kore_worker_init(void)
u_int16_t i, cpu;
if (worker_count == 0)
- fatal("no workers specified");
+ worker_count = 1;
len = sizeof(*accept_lock) +
(sizeof(struct kore_worker) * worker_count);