From 797cf76bc51a342ab680c9426a480bd544edf334 Mon Sep 17 00:00:00 2001 Message-Id: <797cf76bc51a342ab680c9426a480bd544edf334.1714953214.git.mdw@distorted.org.uk> From: Mark Wooding Date: Thu, 4 Jan 2007 11:27:03 +0000 Subject: [PATCH] New environment variable TRIPESOCK. Organization: Straylight/Edgeware From: Mark Wooding Provides a handy default for the `--admin-socket' option. Added documentation. Also fixed paths in documentation to reflect the configuration choices; in particular, they were wrong in the Debian build. --- client/tripectl.c | 2 ++ configure.in | 2 +- doc/tripe-admin.5.in | 3 --- doc/{tripe.8 => tripe.8.in} | 21 ++++++++++++++------- doc/{tripectl.1 => tripectl.1.in} | 10 ++++++++-- init/tripe-init.in | 8 ++++---- server/tripe.c | 2 ++ 7 files changed, 31 insertions(+), 17 deletions(-) rename doc/{tripe.8 => tripe.8.in} (97%) rename doc/{tripectl.1 => tripectl.1.in} (95%) diff --git a/client/tripectl.c b/client/tripectl.c index 50678df9..5bdc5025 100644 --- a/client/tripectl.c +++ b/client/tripectl.c @@ -343,6 +343,8 @@ int main(int argc, char *argv[]) if ((p = getenv("TRIPEDIR")) != 0) dir = p; + if ((p = getenv("TRIPESOCK")) != 0) + sock = p; /* --- Parse the arguments --- */ diff --git a/configure.in b/configure.in index 972fcf60..cb6efb2c 100644 --- a/configure.in +++ b/configure.in @@ -256,7 +256,7 @@ AC_OUTPUT( \ Makefile \ common/Makefile client/Makefile server/Makefile \ proxy/Makefile pkstream/Makefile \ - doc/Makefile \ + doc/Makefile doc/tripe.8 doc/tripectl.1 \ wireshark/Makefile \ init/Makefile init/tripe-init \ keys/Makefile keys/tripe-keys \ diff --git a/doc/tripe-admin.5.in b/doc/tripe-admin.5.in index 822bbf50..1f52a6db 100644 --- a/doc/tripe-admin.5.in +++ b/doc/tripe-admin.5.in @@ -25,9 +25,6 @@ clients can be written in scripting languages such as Perl, Python or Tcl, or more advanced clients such as GUI monitors can be written in C with little difficulty. .PP -By default, the server listens for admin connections on the Unix-domain -socket -.BR /var/lib/tripe/tripesock . Administration commands use a textual protocol. Each client command or server response consists of a line of ASCII text terminated by a single linefeed character. No command may be longer than 255 characters. diff --git a/doc/tripe.8 b/doc/tripe.8.in similarity index 97% rename from doc/tripe.8 rename to doc/tripe.8.in index f5fe5bf6..e58c28cf 100644 --- a/doc/tripe.8 +++ b/doc/tripe.8.in @@ -99,7 +99,7 @@ will initialize by following these steps: It sets the directory named by the .B TRIPEDIR environment variable (or -.B /var/lib/tripe +.B "@configdir@" if the variable is unset) as the current directory. .hP 2. It acquires a UDP socket with an arbitrary kernel-selected port number. @@ -169,9 +169,12 @@ in the background is with .BI "\-d, \-\-directory=" dir Makes .I dir -the current directory, instead of -.BR /var/lib/tripe . -Give a current directory of +the current directory. The default directory to change to is given by +the environment variable +.BR TRIPEDIR ; +if that's not specified, a default default of +.B "@configdir@" +is used. Give a current directory of .B . if you don't want it to change directory at all. .TP @@ -226,9 +229,13 @@ rather than the default .TP .BI "\-a, \-\-admin\-socket=" socket Accept admin connections to a Unix-domain socket named -.I socket -rather than the default -.BR tripesock . +.IR socket . +The default socket, if this option isn't specified, is given by the +environment variable +.BR TRIPESOCK ; +if that's not set either, then a default default of +.B "@socketdir@/tripesock" +is used instead. .TP .BI "\-T, \-\-trace=" trace-opts Allows the enabling or disabling of various internal diagnostics. See diff --git a/doc/tripectl.1 b/doc/tripectl.1.in similarity index 95% rename from doc/tripectl.1 rename to doc/tripectl.1.in index 379fcda1..d46dd33d 100644 --- a/doc/tripectl.1 +++ b/doc/tripectl.1.in @@ -86,15 +86,21 @@ directory. The default directory, if this option is not specified, is taken from the environment variable .BR TRIPEDIR ; if that's not defined either, a default default of -.BR /var/lib/tripe +.B "@configdir@" is used. .TP -.BI "\-a, \-\-admin=" socket +.BI "\-a, \-\-admin-socket=" socket If connecting to a running server, connect to the socket named .IR socket ; if running a new server, instruct it to listen for admin connections on .IR socket . +The default socket, if this option is not specified, is taken from the +environment variable +.BR TRIPESOCK ; +if that's not defined either, a default default of +.B "@socketdir@/tripesock" +is used. .TP .BI "\-P, \-\-pidfile=" pidfile Write diff --git a/init/tripe-init.in b/init/tripe-init.in index e609a653..ddede105 100755 --- a/init/tripe-init.in +++ b/init/tripe-init.in @@ -10,11 +10,11 @@ set -e [ -f @initconfig@ ] && . @initconfig@ : ${prefix=@prefix@} ${exec_prefix=@exec_prefix@} : ${bindir=@bindir@} ${sbindir=@sbindir@} -: ${TRIPEDIR=@configdir@} ${tripesock=@socketdir@/tripesock} +: ${TRIPEDIR=@configdir@} ${TRIPESOCK=@socketdir@/tripesock} : ${pidfile=@pidfile@} : ${tripe=$sbindir/tripe} ${tripectl=$bindir/tripectl} PATH=/usr/bin:/usr/sbin:/bin:/sbin:$bindir -export PATH TRIPEDIR +export PATH TRIPEDIR TRIPESOCK # --- Give up if there's no key --- @@ -150,13 +150,13 @@ case "$1" in ;; stop) echo -n "Stopping TrIPE VPN daemon:" - if test ! -S $tripesock; then + if test ! -S $TRIPESOCK; then echo " not running" elif $tripectl quit >/dev/null 2>&1; then echo " done" elif test ! -f $pidfile; then echo " stale socket found: removing" - rm -f $tripesock + rm -f $TRIPESOCK elif kill `cat $pidfile`; then echo " done (killed violently)" else diff --git a/server/tripe.c b/server/tripe.c index b5bd21c4..d98a2af4 100644 --- a/server/tripe.c +++ b/server/tripe.c @@ -152,6 +152,8 @@ int main(int argc, char *argv[]) if ((p = getenv("TRIPEDIR")) != 0) dir = p; + if ((p = getenv("TRIPESOCK")) != 0) + csock = p; tun_default = tunnels[0]; for (;;) { -- [mdw]