projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace getrandom() with getentropy()
[tinc]
/
src
/
tincd.c
diff --git
a/src/tincd.c
b/src/tincd.c
index
5bfeeab
..
edb03f5
100644
(file)
--- a/
src/tincd.c
+++ b/
src/tincd.c
@@
-130,7
+130,7
@@
static void usage(bool status) {
fprintf(stderr, "Try `%s --help\' for more information.\n",
program_name);
else {
fprintf(stderr, "Try `%s --help\' for more information.\n",
program_name);
else {
- static const char *message =
+ fprintf(stdout,
"Usage: %s [option]...\n"
"\n"
" -c, --config=DIR Read configuration options from DIR.\n"
"Usage: %s [option]...\n"
"\n"
" -c, --config=DIR Read configuration options from DIR.\n"
@@
-152,10
+152,20
@@
static void usage(bool status) {
" --help Display this help and exit.\n"
" --version Output version information and exit.\n"
"\n"
" --help Display this help and exit.\n"
" --version Output version information and exit.\n"
"\n"
- "Report bugs to tinc@tinc-vpn.org.\n";
+ "Report bugs to tinc@tinc-vpn.org.\n",
+ program_name);
+ }
+}
+
+// Try to resolve path to absolute, return a copy of the argument if this fails.
+static char *get_path_arg(char *arg) {
+ char *result = absolute_path(arg);
- printf(message, program_name);
+ if(!result) {
+ result = xstrdup(arg);
}
}
+
+ return result;
}
static bool parse_options(int argc, char **argv) {
}
static bool parse_options(int argc, char **argv) {
@@
-175,7
+185,7
@@
static bool parse_options(int argc, char **argv) {
case OPT_CONFIG_FILE:
free(confbase);
case OPT_CONFIG_FILE:
free(confbase);
- confbase =
xstrdup
(optarg);
+ confbase =
get_path_arg
(optarg);
break;
case OPT_NO_DETACH:
break;
case OPT_NO_DETACH:
@@
-263,14
+273,14
@@
static bool parse_options(int argc, char **argv) {
if(optarg) {
free(logfilename);
if(optarg) {
free(logfilename);
- logfilename =
xstrdup
(optarg);
+ logfilename =
get_path_arg
(optarg);
}
break;
case OPT_PIDFILE:
free(pidfilename);
}
break;
case OPT_PIDFILE:
free(pidfilename);
- pidfilename =
xstrdup
(optarg);
+ pidfilename =
get_path_arg
(optarg);
break;
default:
break;
default:
@@
-408,7
+418,7
@@
int main(int argc, char **argv) {
}
if(show_version) {
}
if(show_version) {
- static const char *message =
+ fprintf(stdout,
"%s version %s (built %s %s, protocol %d.%d)\n"
"Features:"
#ifdef HAVE_OPENSSL
"%s version %s (built %s %s, protocol %d.%d)\n"
"Features:"
#ifdef HAVE_OPENSSL
@@
-450,9
+460,8
@@
int main(int argc, char **argv) {
"\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n"
"\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n"
- "see the file COPYING for details.\n";
-
- printf(message, PACKAGE, BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR);
+ "see the file COPYING for details.\n",
+ PACKAGE, BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR);
return 0;
}
return 0;
}