[PATCH] Build: Set the default ctdb socket path at configure time

Jim McDonough jmcd at samba.org
Thu Oct 18 09:23:03 MDT 2012


On Thu, Oct 18, 2012 at 5:09 PM, David Disseldorp <ddiss at suse.de> wrote:
> From: David Disseldorp <ddiss at samba.org>
>
> The ctdb socket path currently defaults to /tmp/ctdb.socket and can be
> modified at runtime using the --socket=filename option, common to both
> ctdb and ctdbd binaries.
>
> This change allows the default path to be set at configure time using
> the --with-socketpath=FILE argument. When not specified, the default
> path remains /tmp/ctdb.socket, documentation remains unchanged as a
> result.
> ---
Looks good to me, but note that if it's compiled outside of autotools,
there's no guarantee that SOCKPATH will be defined, and then it will
compile but fail.


>  Makefile.in             |    2 ++
>  configure.ac            |   11 +++++++++++
>  include/ctdb_protocol.h |    4 ++--
>  3 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile.in b/Makefile.in
> index 48cb57c..706d7f8 100755
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -16,6 +16,7 @@ sbindir = @sbindir@
>  mandir = @mandir@
>  localstatedir = @localstatedir@
>  logdir = @LOGDIR@
> +sockpath = @SOCKPATH@
>  VPATH = @srcdir@:@tdbdir@:@tallocdir@:@libreplacedir@:@poptdir@:@teventdir@:
>  srcdir = @srcdir@
>  etcdir = @sysconfdir@
> @@ -51,6 +52,7 @@ CFLAGS=@CPPFLAGS@ -g -I$(srcdir)/include -Iinclude -Ilib -Ilib/util -I$(srcdir)
>         $(TALLOC_CFLAGS) $(TEVENT_CFLAGS) $(TDB_CFLAGS) -I at libreplacedir@ \
>         -DVARDIR=\"$(localstatedir)\" -DETCDIR=\"$(etcdir)\" \
>         -DLOGDIR=\"$(logdir)\" \
> +       -DSOCKPATH=\"$(sockpath)\" \
>         -DUSE_MMAP=1 -DTEVENT_DEPRECATED_QUIET=1 @CFLAGS@ -Wno-format-zero-length $(POPT_CFLAGS) \
>         -fPIC
>
> diff --git a/configure.ac b/configure.ac
> index 50d20a0..85934a7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -71,6 +71,17 @@ if test ! -z "$LOGDIR"; then
>  fi
>  AC_SUBST(LOGDIR)
>
> +SOCKPATH='/tmp/ctdb.socket'
> +AC_ARG_WITH([socketpath],
> +       [  --with-socketpath=FILE       path to CTDB daemon socket [[/tmp/ctdb.socket]]],
> +       SOCKPATH=$withval)
> +if test ! -z "$SOCKPATH"; then
> +  if test "$SOCKPATH" = "yes" -o "$SOCKPATH" = "no"; then
> +         AC_MSG_ERROR([--with-socketpath must specify a file path])
> +  fi
> +fi
> +AC_SUBST(SOCKPATH)
> +
>  AC_CONFIG_HEADER(config.h)
>
>  EXTRA_OBJ=""
> diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
> index 9682756..c3d1556 100644
> --- a/include/ctdb_protocol.h
> +++ b/include/ctdb_protocol.h
> @@ -20,8 +20,8 @@
>  #ifndef _CTDB_PROTOCOL_H
>  #define _CTDB_PROTOCOL_H
>
> -/* location of daemon socket */
> -#define CTDB_PATH      "/tmp/ctdb.socket"
> +/* location of daemon socket, set at configure time */
> +#define CTDB_PATH SOCKPATH
>
>  /* default ctdb port number */
>  #define CTDB_PORT 4379
> --
> 1.7.1
>



-- 
Jim McDonough
Samba Team
SUSE labs
jmcd at samba dot org
jmcd at themcdonoughs dot org


More information about the samba-technical mailing list