From 20f39abc5680cd1b3d97359cfeb61a9b65f5b836 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Mon, 30 Nov 2015 10:59:32 +0100 Subject: [PATCH] bipdir improvements - more documentation - don't die if environment variable $HOME isn't defined but '-s' parameter is used - oidentd: change path, file is located in bipdir --- TODO | 18 ------------------ bip.1 | 6 ++++-- bip.conf.5 | 14 ++++++++++---- samples/bip.conf | 6 +++--- src/bip.c | 23 +++++++++++++---------- 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/TODO b/TODO index bf32eb5..88b626e 100644 --- a/TODO +++ b/TODO @@ -1,22 +1,4 @@ - home = getenv("HOME"); - if (!home) { - conf_die(&bip, "no $HOME !, do you live in a trailer ?"); - faudrait virer ca - pourquoi ? - bah mon bip a pas de HOME - ? - un user sans home ? - et je le definis juste pour pas qu'il conf_die - c'est possible ca ? :) - sarko - env - bip - le -s suffit - hum ok :) - c'est complètement élite "env -" :) faudrait ptet pouvoir specifier directement le oidentd_path - oui et documenter -s - rajoute le -s au --help aussi a l'occasion - voila - Allow to dump a config file, so that when the config is dynamically diff --git a/bip.1 b/bip.1 index c9597da..94388bb 100644 --- a/bip.1 +++ b/bip.1 @@ -24,8 +24,10 @@ Use config_file as the configuration file. If no config file is given, bip will try to open ~/.bip/bip.conf. .TP -\fB-s\fP homedir -Set bip home directory to homedir instead of $HOME/.bip. +\fB-s\fP bipdir +Set bip home directory to bipdir instead of $HOME/.bip. \fBbipdir\fP is +the default parent directory for client certificate, configuration, logs, pid, +oidentd. .TP \fB-h\fP diff --git a/bip.conf.5 b/bip.conf.5 index 5ee04cb..d153f07 100644 --- a/bip.conf.5 +++ b/bip.conf.5 @@ -59,13 +59,19 @@ If you use vim you will probably want to use vim with the provided \fBbip.vim\fP syntax file to avoid common syntax and lexical mistakes. You can also find an example configuration file along with BIP. +By default, \fBbipdir\fR is the \fB$HOME/.bip\fP directory and the parent +directory for client certificate, configuration, logs, pid, oidentd. If +environment variable \fB$HOME\fP doesn't exist, \fB-s\fP parameter must be +used. + .SH GLOBAL OPTIONS .TP \fBclient_side_ssl\fP (default: \fBfalse\fP) When true, clients will need to connect to BIP using SSL. -You'll also need to generate a SSL cert/key pair in /bip.pem (usually -~/.bip/bip.pem or /var/lib/bip/bip.pem) or if defined. +You'll also need to generate a SSL cert/key pair in \fBbipdir\fR/bip.pem +(usually ~/.bip/bip.pem or /var/lib/bip/bip.pem) or if +defined. .TP \fBclient_side_ssl_pem\fP (default: \fB/bip.pem\fP) @@ -106,7 +112,7 @@ Determines the log file name depending on : Specify the verbosity of BIP from 0 (fatal errors) to 6 (huge debug output) .TP -\fBlog_root\fP (default: \fBHOME/.bip/logs\fP) +\fBlog_root\fP (default: \fB/logs\fP) Main log directory. Sub-directories and files will be created from there depending on \fBlog_format\fP. @@ -122,7 +128,7 @@ The delay increases with the number of attempts: delay = reconn_timer * number of attempts .TP -\fBpid_file\fP (default: \fBHOME/.bip/bip.pid\fP) +\fBpid_file\fP (default: \fB/bip.pid\fP) Defines the file where BIP's pid will be stored. BIP checks if this file exists and if the pid is still alive upon startup. If true, BIP refuses to start. diff --git a/samples/bip.conf b/samples/bip.conf index 8dd51fd..c361441 100644 --- a/samples/bip.conf +++ b/samples/bip.conf @@ -17,10 +17,10 @@ port = 7778; client_side_ssl = false; # This is the file containing the SSL cert/key pair bip'll use to -# serve SSL clients. If unset, it defaults to /bip.pem +# serve SSL clients. If unset, it defaults to /bip.pem #client_side_ssl_pem = "/path/to/pemfile"; -# Define where the pidfile should be stored. Defaults to /bip.pid +# Define where the pidfile should be stored. Defaults to /bip.pid #pid_file="/var/run/bip/bip.pid"; # Uncomment this line to disable logging and backlogging. @@ -36,7 +36,7 @@ log_level = 3; # This is where logs go. Channel and private messages will use that # configuration value as a prefix, and then log_format to determine -# full log filename. +# full log filename. Defaults to /logs. #log_root = "/var/proxy/logs"; # Uncomment this line to disable bip's internal messages logging. diff --git a/src/bip.c b/src/bip.c index 73a401c..5da112f 100644 --- a/src/bip.c +++ b/src/bip.c @@ -269,6 +269,8 @@ static void usage(char *name) " -f config_file: Use config_file as the configuration file\n" " If no config file is given %s will try to open ~/.bip/" S_CONF "\n" " -n: Don't daemonize, log in stderr\n" +" -s: Bip HOME, default parent directory for client certificate,\n" +" configuration, logs, pid, oidentd\n" " -v: Print version and exit\n" " -h: This help\n", name, name); exit(1); @@ -1218,18 +1220,11 @@ int main(int argc, char **argv) char *home = NULL; /* oidentd path searching ignores conf_biphome */ home = getenv("HOME"); - if (!home) { - conf_die(&bip, "no $HOME !, do you live in a trailer ?"); + if (!home && !conf_biphome) { + conf_die(&bip, "no value for environment variable $HOME," + "use '-s' parameter"); return 0; } -#ifdef HAVE_OIDENTD - bip.oidentdpath = bip_malloc(strlen(home) + 1 + - strlen(OIDENTD_FILENAME) + 1); - strcpy(bip.oidentdpath, home); - strcat(bip.oidentdpath, "/"); - strcat(bip.oidentdpath, OIDENTD_FILENAME); -#endif - if (!conf_biphome) { conf_biphome = bip_malloc(strlen(home) + strlen("/.bip") + 1); @@ -1237,6 +1232,14 @@ int main(int argc, char **argv) strcat(conf_biphome, "/.bip"); } +#ifdef HAVE_OIDENTD + bip.oidentdpath = bip_malloc(strlen(conf_biphome) + 1 + + strlen(OIDENTD_FILENAME) + 1); + strcpy(bip.oidentdpath, conf_biphome); + strcat(bip.oidentdpath, "/"); + strcat(bip.oidentdpath, OIDENTD_FILENAME); +#endif + if (!confpath) { confpath = bip_malloc(strlen(conf_biphome) + 1 + strlen(S_CONF) + 1);