From 3a95956186fa4c7770c425d54328f60ea67b655f Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Wed, 10 Oct 2012 16:13:25 +0200 Subject: [PATCH] Implement feature request #1939 ACL and XATTR support for GNU/Hurd and autoconf support for detecting GNU Hurd and setting the correct DISTNAME etc. and proper platform support for GNU hurd. --- bacula/autoconf/acconfig.h | 1 + bacula/autoconf/bacula-macros/os.m4 | 11 ++++ bacula/autoconf/configure.in | 10 ++++ bacula/platforms/Makefile.in | 2 +- bacula/platforms/hurd/Makefile.in | 88 +++++++++++++++++++++++++++++ bacula/platforms/hurd/bacula-dir.in | 73 ++++++++++++++++++++++++ bacula/platforms/hurd/bacula-fd.in | 73 ++++++++++++++++++++++++ bacula/platforms/hurd/bacula-sd.in | 73 ++++++++++++++++++++++++ bacula/src/filed/acl.c | 20 +++++-- bacula/src/filed/xattr.c | 14 ++++- bacula/src/filed/xattr.h | 2 + bacula/src/lib/mntent_cache.c | 17 +++++- bacula/src/streams.h | 7 +++ 13 files changed, 383 insertions(+), 8 deletions(-) create mode 100644 bacula/platforms/hurd/Makefile.in create mode 100644 bacula/platforms/hurd/bacula-dir.in create mode 100644 bacula/platforms/hurd/bacula-fd.in create mode 100644 bacula/platforms/hurd/bacula-sd.in diff --git a/bacula/autoconf/acconfig.h b/bacula/autoconf/acconfig.h index 40a91d70e5..4c5f8dd3c4 100644 --- a/bacula/autoconf/acconfig.h +++ b/bacula/autoconf/acconfig.h @@ -143,6 +143,7 @@ #undef HAVE_CYGWIN #undef HAVE_OSF1_OS #undef HAVE_DARWIN_OS +#undef HAVE_HURD_OS /* Set to correct scanf value for long long int */ #undef lld diff --git a/bacula/autoconf/bacula-macros/os.m4 b/bacula/autoconf/bacula-macros/os.m4 index 2833e4da3a..1af4f903ae 100644 --- a/bacula/autoconf/bacula-macros/os.m4 +++ b/bacula/autoconf/bacula-macros/os.m4 @@ -62,6 +62,14 @@ else BA_CONDITIONAL(HAVE_SUN_OS, $FALSEPRG) fi +if test $HAVE_UNAME=yes -a x`uname -s` = xGNU +then + BA_CONDITIONAL(HAVE_HURD_OS, $TRUEPRG) + AC_DEFINE(HAVE_HURD_OS) +else + BA_CONDITIONAL(HAVE_HURD_OS, $FALSEPRG) +fi + if test $HAVE_UNAME=yes -a x`uname -s` = xOSF1 then BA_CONDITIONAL(HAVE_OSF1_OS, $TRUEPRG) @@ -168,6 +176,9 @@ then elif test $HAVE_UNAME=yes -a x`uname -s` = xSunOS then DISTNAME=solaris +elif test $HAVE_UNAME=yes -a x`uname -s` = xGNU +then + DISTNAME=hurd elif test $HAVE_UNAME=yes -a x`uname -s` = xFreeBSD then DISTNAME=freebsd diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 7931835fa5..de09194390 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -3152,6 +3152,16 @@ freebsd) platforms/freebsd/bacula-dir" largefile_support="yes" ;; +hurd) + DISTVER=`uname -r` + TAPEDRIVE="/dev/nst0" + PSCMD="ps -e -o pid,command" + PFILES="${PFILES} \ + platforms/hurd/Makefile \ + platforms/hurd/bacula-fd \ + platforms/hurd/bacula-sd \ + platforms/hurd/bacula-dir" + ;; hpux) PSCMD="UNIX95=1; ps -e -o pid,comm" CFLAGS="${CFLAGS} -D_XOPEN_SOURCE_EXTENDED=1" diff --git a/bacula/platforms/Makefile.in b/bacula/platforms/Makefile.in index bba619b773..fedcde3cf7 100644 --- a/bacula/platforms/Makefile.in +++ b/bacula/platforms/Makefile.in @@ -11,7 +11,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL = @INSTALL@ -SUBDIRS = freebsd redhat solaris unknown openbsd osx irix gentoo \ +SUBDIRS = hurd freebsd redhat solaris unknown openbsd osx irix gentoo \ debian darwin aix bsdi mandrake slackware alpha ubuntu systemd MAKE = make diff --git a/bacula/platforms/hurd/Makefile.in b/bacula/platforms/hurd/Makefile.in new file mode 100644 index 0000000000..c8f392eea1 --- /dev/null +++ b/bacula/platforms/hurd/Makefile.in @@ -0,0 +1,88 @@ +# +# This file is used as the template to create the +# Makefile for the Debian GNU Hurd specific installation. +# +# 21 March 2008 -- Kern Sibbald +# +# for Bacula release @VERSION@ (@DATE@) -- @DISTNAME@ +# + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ -m 754 + +nothing: + +install: install-autostart + +install-autostart: install-autostart-fd install-autostart-sd install-autostart-dir + +install_logrotate: + @$(INSTALL_PROGRAM) ../../scripts/logrotate $(DESTDIR)/etc/logrotate.d/bacula + +install-autostart-fd: uninstall-autostart-fd + @echo "Installing bacula-fd boot script ..." + @$(INSTALL_PROGRAM) bacula-fd $(DESTDIR)/etc/init.d/bacula-fd + @echo "Installing bacula-fd symlinks ..." + @if test x$(DESTDIR) = x ; then \ + /usr/sbin/update-rc.d bacula-fd start 91 2 3 4 5 . stop 9 0 1 6 .; \ + fi + + +install-autostart-sd: uninstall-autostart-sd + @echo "Installing bacula-sd boot script ..." + @$(INSTALL_PROGRAM) bacula-sd $(DESTDIR)/etc/init.d/bacula-sd + @echo "Installing bacula-sd symlinks ..." + @if test "x$(DESTDIR)" = "x" ; then \ + /usr/sbin/update-rc.d bacula-sd start 91 2 3 4 5 . stop 9 0 1 6 .; \ + fi + + +install-autostart-dir: uninstall-autostart-dir + @echo "Installing bacula-dir boot script ..." + @$(INSTALL_PROGRAM) bacula-dir $(DESTDIR)/etc/init.d/bacula-dir + @echo "Installing bacula-dir symlinks ..." + @if test "x$(DESTDIR)" = "x" ; then \ + /usr/sbin/update-rc.d bacula-dir start 90 2 3 4 5 . stop 9 0 1 6 .; \ + fi + + +uninstall: uninstall-autostart + +uninstall-autostart: uninstall-autostart-fd uninstall-autostart-sd uninstall-autostart-dir + +uninstall-logrotate: + @rm -f $(DESTDIR)/etc/logrotate.d/bacula + +uninstall-autostart-fd: + @if test "x$(DESTDIR)" = "x" -a -f /etc/init.d/bacula-fd; then \ + /etc/init.d/bacula-fd stop; \ + rm -f $(DESTDIR)/etc/init.d/bacula-fd; \ + /usr/sbin/update-rc.d bacula-fd remove; \ + fi + + +uninstall-autostart-sd: + @if test "x$(DESTDIR)" = "x" -a -f /etc/init.d/bacula-sd; then \ + /etc/init.d/bacula-sd stop; \ + rm -f $(DESTDIR)/etc/init.d/bacula-sd; \ + /usr/sbin/update-rc.d bacula-sd remove; \ + fi + +uninstall-autostart-dir: + @if test "x$(DESTDIR)" = "x" -a -f /etc/init.d/bacula-dir; then \ + /etc/init.d/bacula-dir stop; \ + rm -f $(DESTDIR)/etc/init.d/bacula-dir; \ + /usr/sbin/update-rc.d bacula-dir remove; \ + fi + @rm -f $(DESTDIR)/etc/init.d/bacula-dir + +clean: + @rm -f 1 2 3 + +distclean: clean + @rm -f Makefile + @rm -f bacula-sd bacula-fd bacula-dir + +devclean: clean + @rm -f Makefile + @rm -f bacula-sd bacula-fd bacula-dir diff --git a/bacula/platforms/hurd/bacula-dir.in b/bacula/platforms/hurd/bacula-dir.in new file mode 100644 index 0000000000..88c13a31a1 --- /dev/null +++ b/bacula/platforms/hurd/bacula-dir.in @@ -0,0 +1,73 @@ +#! /bin/sh +# +# bacula This shell script takes care of starting and stopping +# the bacula Director daemon on Debian GNU Hurd systems. +# +# Kern E. Sibbald - 21 March 2008 +# +# For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@ +# +### BEGIN INIT INFO +# Provides: bacula-dir +# Required-Start: $network +# Required-Stop: $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start @BACULA@ Director daemon at boot time +# Description: Enable @BACULA@ Director. +### END INIT INFO +# + +NAME="bacula-dir" +DESC="@BACULA@ Director" +DAEMON=@sbindir@/${NAME} +BUSER=@dir_user@ +BGROUP=@dir_group@ +BOPTIONS="-c @sysconfdir@/${NAME}.conf" +BPORT=@dir_port@ + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +test -f $DAEMON || exit 0 + +if [ -n "`getent services ${NAME}`" ]; then + BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'` +fi + +if [ -f /etc/default/$NAME ]; then + . /etc/default/$NAME +fi + +PIDFILE=@piddir@/${NAME}.${BPORT}.pid + +if [ "x${BUSER}" != "x" ]; then + USERGRP="--chuid ${BUSER}" + if [ "x${BGROUP}" != "x" ]; then + USERGRP="${USERGRP}:${BGROUP}" + fi +fi + +case "$1" in + start) + echo -n "Starting ${DESC}: " + start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS} + RETVAL=$? + echo "${NAME}" + ;; + stop) + echo -n "Stopping ${DESC}: " + start-stop-daemon --oknodo --stop --quiet ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS} + RETVAL=$? + echo "${NAME}" + ;; + restart|force-reload) + $0 stop + sleep 5 + $0 start + ;; + *) + echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac +exit $RETVAL diff --git a/bacula/platforms/hurd/bacula-fd.in b/bacula/platforms/hurd/bacula-fd.in new file mode 100644 index 0000000000..270950a7dd --- /dev/null +++ b/bacula/platforms/hurd/bacula-fd.in @@ -0,0 +1,73 @@ +#! /bin/sh +# +# bacula This shell script takes care of starting and stopping +# the bacula Director daemon on Debian GNU Hurd systems. +# +# Kern E. Sibbald - 21 March 2008 +# +# For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@ +# +### BEGIN INIT INFO +# Provides: bacula-fd +# Required-Start: $network +# Required-Stop: $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start @BACULA@ Client daemon at boot time +# Description: Enable @BACULA@ Client. +### END INIT INFO + + +NAME="bacula-fd" +DESC="@BACULA@ File Daemon" +DAEMON=@sbindir@/${NAME} +BUSER=@fd_user@ +BGROUP=@fd_group@ +BOPTIONS="-c @sysconfdir@/${NAME}.conf" +BPORT=@fd_port@ + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +test -f $DAEMON || exit 0 + +if [ -n "`getent services ${NAME}`" ]; then + BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'` +fi + +if [ -f /etc/default/$NAME ]; then + . /etc/default/$NAME +fi + +PIDFILE=@piddir@/${NAME}.${BPORT}.pid + +if [ "x${BUSER}" != "x" ]; then + USERGRP="--chuid ${BUSER}" + if [ "x${BGROUP}" != "x" ]; then + USERGRP="${USERGRP}:${BGROUP}" + fi +fi + +case "$1" in + start) + echo -n "Starting ${DESC}: " + start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS} + RETVAL=$? + echo "${NAME}" + ;; + stop) + echo -n "Stopping ${DESC}: " + start-stop-daemon --oknodo --stop --quiet ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS} + RETVAL=$? + echo "${NAME}" + ;; + restart|force-reload) + $0 stop + sleep 5 + $0 start + ;; + *) + echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac +exit $RETVAL diff --git a/bacula/platforms/hurd/bacula-sd.in b/bacula/platforms/hurd/bacula-sd.in new file mode 100644 index 0000000000..ff1ad29a8d --- /dev/null +++ b/bacula/platforms/hurd/bacula-sd.in @@ -0,0 +1,73 @@ +#! /bin/sh +# +# bacula This shell script takes care of starting and stopping +# the bacula Director daemon on Debian GNU Hurd systems. +# +# Kern E. Sibbald - 21 March 2008 +# +# For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@ +# +### BEGIN INIT INFO +# Provides: bacula-sd +# Required-Start: $network +# Required-Stop: $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start @BACULA@ Storage daemon at boot time +# Description: Enable @BACULA@ Storage daemon. +### END INIT INFO + + +NAME="bacula-sd" +DESC="@BACULA@ Storage Daemon" +DAEMON=@sbindir@/${NAME} +BUSER=@sd_user@ +BGROUP=@sd_group@ +BOPTIONS="-c @sysconfdir@/${NAME}.conf" +BPORT=@sd_port@ + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +test -f $DAEMON || exit 0 + +if [ -n "`getent services ${NAME}`" ]; then + BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'` +fi + +if [ -f /etc/default/$NAME ]; then + . /etc/default/$NAME +fi + +PIDFILE=@piddir@/${NAME}.${BPORT}.pid + +if [ "x${BUSER}" != "x" ]; then + USERGRP="--chuid ${BUSER}" + if [ "x${BGROUP}" != "x" ]; then + USERGRP="${USERGRP}:${BGROUP}" + fi +fi + +case "$1" in + start) + echo -n "Starting ${DESC}: " + start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS} + RETVAL=$? + echo "${NAME}" + ;; + stop) + echo -n "Stopping ${DESC}: " + start-stop-daemon --oknodo --stop --quiet ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS} + RETVAL=$? + echo "${NAME}" + ;; + restart|force-reload) + $0 stop + sleep 5 + $0 start + ;; + *) + echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac +exit $RETVAL diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index b83bd7a19e..59eac94e27 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -32,6 +32,7 @@ * - AIX (pre-5.3 and post 5.3 acls, acl_get and aclx_get interface) * - Darwin * - FreeBSD (POSIX and NFSv4/ZFS acls) + * - GNU Hurd * - HPUX * - IRIX * - Linux @@ -543,7 +544,8 @@ static bacl_exit_code (*os_parse_acl_streams) defined(HAVE_FREEBSD_OS) || \ defined(HAVE_IRIX_OS) || \ defined(HAVE_OSF1_OS) || \ - defined(HAVE_LINUX_OS) + defined(HAVE_LINUX_OS) || \ + defined(HAVE_HURD_OS) #include @@ -642,7 +644,8 @@ static int acl_count_entries(acl_t acl) { int count = 0; #if defined(HAVE_FREEBSD_OS) || \ - defined(HAVE_LINUX_OS) + defined(HAVE_LINUX_OS) || \ + defined(HAVE_HURD_OS) acl_entry_t ace; int entry_available; @@ -684,7 +687,8 @@ static bool acl_is_trivial(acl_t acl) acl_entry_t ace; acl_tag_t tag; #if defined(HAVE_FREEBSD_OS) || \ - defined(HAVE_LINUX_OS) + defined(HAVE_LINUX_OS) || \ + defined(HAVE_HURD_OS) int entry_available; entry_available = acl_get_entry(acl, ACL_FIRST_ENTRY, &ace); @@ -1275,7 +1279,8 @@ static bacl_exit_code (*os_parse_acl_streams) freebsd_parse_acl_streams; #elif defined(HAVE_IRIX_OS) || \ - defined(HAVE_LINUX_OS) + defined(HAVE_LINUX_OS) || \ + defined(HAVE_HURD_OS) /* * Define the supported ACL streams for these OSes */ @@ -1293,6 +1298,13 @@ static int os_access_acl_streams[1] = { static int os_default_acl_streams[1] = { STREAM_ACL_LINUX_DEFAULT_ACL }; +#elif defined(HAVE_HURD_OS) +static int os_access_acl_streams[1] = { + STREAM_ACL_HURD_ACCESS_ACL +}; +static int os_default_acl_streams[1] = { + STREAM_ACL_HURD_DEFAULT_ACL +}; #endif static bacl_exit_code generic_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index faf86d578c..21a63650d8 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -35,6 +35,7 @@ * - AIX (Extended Attributes) * - Darwin (Extended Attributes) * - FreeBSD (Extended Attributes) + * - GNU HURD (Extended Attributes) * - IRIX (Extended Attributes) * - Linux (Extended Attributes) * - NetBSD (Extended Attributes) @@ -1035,7 +1036,8 @@ static bxattr_exit_code (*os_parse_xattr_streams) irix_parse_xattr_streams; #elif defined(HAVE_DARWIN_OS) || \ - defined(HAVE_LINUX_OS) + defined(HAVE_LINUX_OS) || \ + defined(HAVE_HURD_OS) #if (!defined(HAVE_LISTXATTR) && !defined(HAVE_LLISTXATTR)) || \ (!defined(HAVE_GETXATTR) && !defined(HAVE_LGETXATTR)) || \ @@ -1077,6 +1079,16 @@ static const char *xattr_acl_skiplist[3] = { static const char *xattr_skiplist[1] = { NULL }; +#elif defined(HAVE_HURD_OS) +static int os_default_xattr_streams[1] = { + STREAM_XATTR_HURD +}; +static const char *xattr_acl_skiplist[1] = { + NULL +}; +static const char *xattr_skiplist[1] = { + NULL +}; #endif /* diff --git a/bacula/src/filed/xattr.h b/bacula/src/filed/xattr.h index cb1c68e451..b61ec11161 100644 --- a/bacula/src/filed/xattr.h +++ b/bacula/src/filed/xattr.h @@ -33,6 +33,8 @@ #define BXATTR_ENOTSUP EOPNOTSUPP #elif defined(HAVE_DARWIN_OS) #define BXATTR_ENOTSUP ENOTSUP +#elif defined(HAVE_HURD_OS) +#define BXATTR_ENOTSUP ENOTSUP #endif /* diff --git a/bacula/src/lib/mntent_cache.c b/bacula/src/lib/mntent_cache.c index c30cc912fe..ca2c8a8db4 100644 --- a/bacula/src/lib/mntent_cache.c +++ b/bacula/src/lib/mntent_cache.c @@ -68,10 +68,15 @@ #include #if defined(HAVE_GETMNTENT) -#if defined(HAVE_LINUX_OS) || defined(HAVE_HPUX_OS) || defined(HAVE_AIX_OS) +#if defined(HAVE_LINUX_OS) || \ + defined(HAVE_HPUX_OS) || \ + defined(HAVE_AIX_OS) #include #elif defined(HAVE_SUN_OS) #include +#elif defined(HAVE_HURD_OS) +#include +#include #endif /* HAVE_GETMNTENT */ #elif defined(HAVE_GETMNTINFO) #if defined(HAVE_OPENBSD_OS) @@ -181,7 +186,11 @@ static void refresh_mount_cache(void) #if defined(HAVE_GETMNTENT) FILE *fp; struct stat st; -#if defined(HAVE_LINUX_OS) || defined(HAVE_HPUX_OS) || defined(HAVE_IRIX_OS) || defined(HAVE_AIX_OS) +#if defined(HAVE_LINUX_OS) || \ + defined(HAVE_HPUX_OS) || \ + defined(HAVE_IRIX_OS) || \ + defined(HAVE_AIX_OS) || \ + defined(HAVE_HURD_OS) struct mntent *mnt; #if defined(HAVE_LINUX_OS) @@ -202,6 +211,10 @@ static void refresh_mount_cache(void) if ((fp = setmntent(MNTTAB, "r")) == (FILE *)NULL) { return; } +#elif defined(HAVE_HURD_OS) + if ((fp = setmntent(_PATH_MNTTAB, "r")) == (FILE *)NULL) { + return; + } #endif while ((mnt = getmntent(fp)) != (struct mntent *)NULL) { diff --git a/bacula/src/streams.h b/bacula/src/streams.h index 1fc8c829cb..78b1e6897e 100644 --- a/bacula/src/streams.h +++ b/bacula/src/streams.h @@ -169,6 +169,13 @@ #define STREAM_ACL_FREEBSD_NFS4_ACL 1017 /* FreeBSD specific acl_t string representation * from acl_to_text (NFSv4 or ZFS acl) */ +#define STREAM_ACL_HURD_DEFAULT_ACL 1018 /* GNU HURD specific acl_t string representation + * from acl_to_text (POSIX acl) for default acls. + */ +#define STREAM_ACL_HURD_ACCESS_ACL 1019 /* GNU HURD specific acl_t string representation + * from acl_to_text (POSIX acl) for access acls. + */ +#define STREAM_XATTR_HURD 1989 /* GNU HURD specific extended attributes */ #define STREAM_XATTR_IRIX 1990 /* IRIX specific extended attributes */ #define STREAM_XATTR_TRU64 1991 /* TRU64 specific extended attributes */ #define STREAM_XATTR_AIX 1992 /* AIX specific extended attributes */ -- 2.39.5