From b5c5bc739d82c3a9685f1dbffa21dd01ad4752e6 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 23 Oct 2008 10:12:36 +0000 Subject: [PATCH] kes Apply patch from Marco van Wieringen that implements the new Solaris libsec interface for ACLs so that Bacula can save and restore both the new ACLs and old ACLs. kes Marco's patch also corrects the file dependency generation code so that it works properly both with shared libraries and static libraries. kes Marco's patch also includes a small cleanup of the cats Makefile to remove some references to non-existent files. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7879 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/config.h.in | 3 ++ bacula/autoconf/config.h.in.save | 3 ++ bacula/autoconf/configure.in | 11 ++++ bacula/src/cats/Makefile.in | 33 +++++------- bacula/src/filed/acl.c | 90 +++++++++++++++++++++++++++++++- bacula/src/findlib/Makefile.in | 8 +-- bacula/src/lib/Makefile.in | 10 ++-- bacula/src/version.h | 4 +- bacula/technotes-2.5 | 9 ++++ 9 files changed, 142 insertions(+), 29 deletions(-) diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index abf5ebad5b..d015a65f05 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -155,6 +155,9 @@ /* Define if you have libacl */ #undef HAVE_ACL +/* Define if you have extended acls */ +#undef HAVE_EXTENDED_ACL + /* General libs */ #undef LIBS diff --git a/bacula/autoconf/config.h.in.save b/bacula/autoconf/config.h.in.save index abf5ebad5b..d015a65f05 100644 --- a/bacula/autoconf/config.h.in.save +++ b/bacula/autoconf/config.h.in.save @@ -155,6 +155,9 @@ /* Define if you have libacl */ #undef HAVE_ACL +/* Define if you have extended acls */ +#undef HAVE_EXTENDED_ACL + /* General libs */ #undef LIBS diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 9510443bd3..02ce81690a 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -2207,6 +2207,7 @@ dnl dnl Check for ACL libraries dnl have_acl=no +have_extended_acl=no AC_CHECK_HEADER(sys/acl.h) AC_CHECK_FUNC(acl_get_file, [have_acl=yes], [ @@ -2219,6 +2220,12 @@ AC_CHECK_FUNC(acl_get_file, [have_acl=yes], [ have_acl=yes; FDLIBS="-lsec $FDLIBS" + + AC_CHECK_LIB(sec, acl_totext, + [ + have_extended_acl=yes + ] + ) ] ) ] @@ -2229,6 +2236,10 @@ if test $have_acl = yes; then AC_DEFINE(HAVE_ACL) fi +if test $have_extended_acl = yes; then + AC_DEFINE(HAVE_EXTENDED_ACL) +fi + dnl Check for pthread libraries PTHREAD_LIB="" AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread", diff --git a/bacula/src/cats/Makefile.in b/bacula/src/cats/Makefile.in index 87455d4dc5..204b2e3d90 100644 --- a/bacula/src/cats/Makefile.in +++ b/bacula/src/cats/Makefile.in @@ -26,10 +26,6 @@ dummy: # INCLUDE_FILES = bdb.h cats.h protos.h sql_cmds.h -# -SVRSRCS = cats.c sql.c -SVROBJS = cats.o sql.o - LIBSRCS = mysql.c bdb.c dbi.c \ sql.c sql_cmds.c sql_create.c sql_delete.c sql_find.c \ sql_get.c sql_list.c sql_update.c sqlite.c \ @@ -54,7 +50,7 @@ LIBBACSQL_LT_AGE = 0 $(NO_ECHO)$(LIBTOOL_COMPILE) $(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(SQL_INC) $(DINCLUDE) $(CFLAGS) $< #------------------------------------------------------------------------- all: Makefile libbacsql$(DEFAULT_ARCHIVE_TYPE) - @echo "==== Make of cats is good ====" + @echo "==== Make of sqllib is good ====" @echo " " libbacsql.a: $(LIBOBJS) @@ -66,9 +62,6 @@ libbacsql.la: Makefile $(LIBOBJS) @echo "Making $@ ..." $(LIBTOOL_LINK) $(CXX) $(DEFS) $(DEBUG) $(LDFLAGS) -o $@ $(LIBOBJS) -export-dynamic -rpath $(libdir) -version-info $(LIBBACSQL_LT_CURRENT):$(LIBBACSQL_LT_REVISION):$(LIBBACSQL_LT_AGE) $(DB_LIBS) -cats: Makefile $(SVROBJS) ../findlib/libfind$(DEFAULT_ARCHIVE_TYPE) - $(LIBTOOL_LINK) $(CC) $(WLDFLAGS) $(LDFLAGS) -L../findlib -L../lib -o $@ $(SVROBJS) $(LIBS) $(DB_LIBS) -lfind -lbac - Makefile: $(srcdir)/Makefile.in $(topdir)/config.status cd $(topdir) \ && CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -79,7 +72,7 @@ libtool-clean: $(RMF) -r .libs _libs clean: @LIBTOOL_CLEAN_TARGET@ - $(RMF) cats core a.out *.o *.bak *~ *.intpro *.extpro 1 2 3 + $(RMF) core a.out *.o *.bak *~ *.intpro *.extpro 1 2 3 realclean: clean $(RMF) tags @@ -115,12 +108,12 @@ devclean: realclean install-includes: $(MKDIR) $(DESTDIR)/$(includedir)/bacula/sql - for I in ${INCLUDE_FILES}; do \ + for I in $(INCLUDE_FILES); do \ $(INSTALL_DATA) $$I $(DESTDIR)$(includedir)/bacula/sql/`basename $$I`; \ done uninstall-includes: - for I in ${INCLUDE_FILES}; do \ + for I in $(INCLUDE_FILES); do \ $(RMF) $(DESTDIR)$(includedir)/bacula/sql/`basename $$I`; \ done @@ -147,23 +140,23 @@ install: @LIBTOOL_INSTALL_TARGET@ @INCLUDE_INSTALL_TARGET@ $(INSTALL_SCRIPT) drop_bacula_database $(DESTDIR)$(scriptdir)/drop_bacula_database @filename=make_catalog_backup; \ - if test -f ${DESTDIR}${scriptdir}/$$filename; then \ + if test -f $(DESTDIR)$(scriptdir)/$$filename; then \ destname=$$filename.new; \ echo " ==> Found existing $$filename, installing new file as $$destname"; \ else \ destname=$$filename; \ fi; \ - echo "${INSTALL_SCRIPT} $$filename ${DESTDIR}${scriptdir}/$$destname"; \ - ${INSTALL_SCRIPT} $$filename ${DESTDIR}${scriptdir}/$$destname + echo "$(INSTALL_SCRIPT) $$filename $(DESTDIR)$(scriptdir)/$$destname"; \ + $(INSTALL_SCRIPT) $$filename $(DESTDIR)$(scriptdir)/$$destname @filename=delete_catalog_backup; \ - if test -f ${DESTDIR}${scriptdir}/$$filename; then \ + if test -f $(DESTDIR)$(scriptdir)/$$filename; then \ destname=$$filename.new; \ echo " ==> Found existing $$filename, installing new file as $$destname"; \ else \ destname=$$filename; \ fi; \ - echo "${INSTALL_SCRIPT} $$filename ${DESTDIR}${scriptdir}/$$destname"; \ - ${INSTALL_SCRIPT} $$filename ${DESTDIR}${scriptdir}/$$destname + echo "$(INSTALL_SCRIPT) $$filename $(DESTDIR)$(scriptdir)/$$destname"; \ + $(INSTALL_SCRIPT) $$filename $(DESTDIR)$(scriptdir)/$$destname uninstall: @LIBTOOL_UNINSTALL_TARGET@ @INCLUDE_UNINSTALL_TARGET@ (cd $(DESTDIR)$(scriptdir); $(RMF) create_@DB_TYPE@_database) @@ -184,7 +177,7 @@ uninstall: @LIBTOOL_UNINSTALL_TARGET@ @INCLUDE_UNINSTALL_TARGET@ (cd $(DESTDIR)$(scriptdir); $(RMF) delete_catalog_backup) # Semi-automatic generation of dependencies: -# Use gcc -MM because X11 `makedepend' doesn't work on all systems +# Use gcc -M because X11 `makedepend' doesn't work on all systems # and it also includes system headers. # `semi'-automatic since dependencies are generated at distribution time. @@ -192,7 +185,9 @@ depend: @$(MV) Makefile Makefile.bak @$(SED) "/^# DO NOT DELETE:/,$$ d" Makefile.bak > Makefile @$(ECHO) "# DO NOT DELETE: nice dependency list follows" >> Makefile - @$(CXX) -S -M $(CPPFLAGS) $(XINC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile + @for src in $(LIBSRCS); do \ + $(CXX) -S -M -MT `basename $$src .c`$(DEFAULT_OBJECT_TYPE) $(CPPFLAGS) $(XINC) -I$(srcdir) -I$(basedir) $(SQL_INC) $$src >> Makefile; \ + done @if test -f Makefile ; then \ $(RMF) Makefile.bak; \ else \ diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index 458020152f..a9a61449d1 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -350,6 +350,93 @@ int bacl_set(JCR *jcr, int acltype) #elif defined(HAVE_SUN_OS) #include +/* + * As the new libsec interface with acl_totext and acl_fromtext also handles + * the old format from acltotext we can use the new functions even + * for acls retrieved and stored in the database with older fd versions. If the + * new interface is not defined (Solaris 9 and older we fall back to the old code) + */ +#if defined(HAVE_EXTENDED_ACL) +int bacl_get(JCR *jcr, int acltype) +{ + int len, flags; + acl_t *aclp; + char *acl_text; + + /* + * Get ACL info: don't bother allocating space if there is only a trivial ACL. + */ + if (acl_get(jcr->last_fname, ACL_NO_TRIVIAL, &aclp) != 0) + return -1; + + if (aclp == NULL) { + /* The ACLs simply reflect the (already known) standard permissions */ + return pm_strcpy(jcr->acl_text, ""); + } + +#if defined(ACL_SID_FMT) + /* + * New format flag added in newer Solaris versions. + */ + flags = ACL_APPEND_ID | ACL_COMPACT_FMT | ACL_SID_FMT; +#else + flags = ACL_APPEND_ID | ACL_COMPACT_FMT; +#endif /* ACL_SID_FMT */ + + if ((acl_text = acl_totext(aclp, flags)) != NULL) { + len = pm_strcpy(jcr->acl_text, acl_text); + actuallyfree(acl_text); + + acl_free(aclp); + + return len; + } + + acl_free(aclp); + + return -1; +} + +/* + * As the header acl.h doesn't seem to define this one we need to. + */ +extern "C" { +char *acl_strerror(int); +} + +int bacl_set(JCR *jcr, int acltype) +{ + acl_t *aclp; + int error; + + if ((error = acl_fromtext(jcr->acl_text, &aclp)) != 0) { + Jmsg2(jcr, M_ERROR, 0, _("acl_fromtext error on file \"%s\": ERR=%s\n"), + jcr->last_fname, acl_strerror(error)); + Dmsg3(100, "acl_fromtext error acl=%s file=%s ERR=%s\n", + jcr->acl_text, jcr->last_fname, acl_strerror(error)); + return -1; + } + + /* + * Restore the ACLs, but don't complain about links which really should + * not have attributes, and the file it is linked to may not yet be restored. + */ + if ((error = acl_set(jcr->last_fname, aclp)) == -1 && jcr->last_type != FT_LNK) { + Jmsg2(jcr, M_ERROR, 0, _("acl_set error on file \"%s\": ERR=%s\n"), + jcr->last_fname, acl_strerror(error)); + Dmsg3(100, "acl_set error acl=%s file=%s ERR=%s\n", + jcr->acl_text, jcr->last_fname, acl_strerror(error)); + + acl_free(aclp); + return -1; + } + + acl_free(aclp); + return 0; +} + +#else /* HAVE_EXTENDED_ACL */ + int bacl_get(JCR *jcr, int acltype) { int n, len; @@ -414,7 +501,8 @@ int bacl_set(JCR *jcr, int acltype) return 0; } -#endif +#endif /* HAVE_EXTENDED_ACL */ +#endif /* HAVE_SUN_OS */ #ifdef TEST_PROGRAM diff --git a/bacula/src/findlib/Makefile.in b/bacula/src/findlib/Makefile.in index 6a61bda309..bd6e23a9b1 100644 --- a/bacula/src/findlib/Makefile.in +++ b/bacula/src/findlib/Makefile.in @@ -66,12 +66,12 @@ Makefile: $(srcdir)/Makefile.in $(topdir)/config.status install-includes: $(MKDIR) $(DESTDIR)/$(includedir)/bacula/findlib - for I in ${INCLUDE_FILES}; do \ + for I in $(INCLUDE_FILES); do \ $(INSTALL_DATA) $$I $(DESTDIR)$(includedir)/bacula/findlib/`basename $$I`; \ done uninstall-includes: - for I in ${INCLUDE_FILES}; do \ + for I in $(INCLUDE_FILES); do \ $(RMF) $(DESTDIR)$(includedir)/bacula/findlib/`basename $$I`; \ done @@ -114,7 +114,9 @@ depend: @$(MV) Makefile Makefile.bak @$(SED) "/^# DO NOT DELETE:/,$$ d" Makefile.bak > Makefile @$(ECHO) "# DO NOT DELETE: nice dependency list follows" >> Makefile - @$(CXX) -S -M $(CPPFLAGS) $(XINC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile + @for src in $(LIBSRCS); do \ + $(CXX) -S -M -MT `basename $$src .c`$(DEFAULT_OBJECT_TYPE) $(CPPFLAGS) $(XINC) -I$(srcdir) -I$(basedir) $(SQL_INC) $$src >> Makefile; \ + done @if test -f Makefile ; then \ $(RMF) Makefile.bak; \ else \ diff --git a/bacula/src/lib/Makefile.in b/bacula/src/lib/Makefile.in index 923154fa77..240156391a 100644 --- a/bacula/src/lib/Makefile.in +++ b/bacula/src/lib/Makefile.in @@ -170,12 +170,12 @@ bsnprintf: Makefile bsnprintf.o install-includes: $(MKDIR) $(DESTDIR)/$(includedir)/bacula - for I in ${INCLUDE_FILES}; do \ + for I in $(INCLUDE_FILES); do \ $(INSTALL_DATA) $$I $(DESTDIR)$(includedir)/bacula/`basename $$I`; \ done uninstall-includes: - for I in ${INCLUDE_FILES}; do \ + for I in $(INCLUDE_FILES); do \ $(RMF) $(DESTDIR)$(includedir)/bacula/`basename $$I`; \ done @@ -211,7 +211,7 @@ distclean: realclean (cd $(srcdir); $(RMF) Makefile) # Semi-automatic generation of dependencies: -# Use gcc -MM because X11 `makedepend' doesn't work on all systems +# Use gcc -M because X11 `makedepend' doesn't work on all systems # and it also includes system headers. # `semi'-automatic since dependencies are generated at distribution time. @@ -219,7 +219,9 @@ depend: @$(MV) Makefile Makefile.bak @$(SED) "/^# DO NOT DELETE:/,$$ d" Makefile.bak > Makefile @$(ECHO) "# DO NOT DELETE: nice dependency list follows" >> Makefile - @$(CXX) -S -M $(CPPFLAGS) $(XINC) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >>Makefile + @for src in $(LIBBAC_SRCS) $(LIBBACCFG_SRCS) $(LIBBACPY_SRCS); do \ + $(CXX) -S -M -MT `basename $$src .c`$(DEFAULT_OBJECT_TYPE) $(CPPFLAGS) $(XINC) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(SQL_INC) $$src >> Makefile; \ + done @if test -f Makefile ; then \ $(RMF) Makefile.bak; \ else \ diff --git a/bacula/src/version.h b/bacula/src/version.h index 1c80647d48..a3ff69825b 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.17" -#define BDATE "21 October 2008" -#define LSMDATE "21Oct08" +#define BDATE "23 October 2008" +#define LSMDATE "23Oct08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 0a14ce1faa..f1c6ebe5d0 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -50,6 +50,15 @@ libtool on the configure command line with: General: +23Oct08 +kes Apply patch from Marco van Wieringen that implements the new + Solaris libsec interface for ACLs so that Bacula can save and + restore both the new ACLs and old ACLs. +kes Marco's patch also corrects the file dependency generation code + so that it works properly both with shared libraries and static + libraries. +kes Marco's patch also includes a small cleanup of the cats Makefile + to remove some references to non-existent files. 22Oct08 kes Modify win32 Makefiles to use full paths in most cases. In particular add MAINDIR environment variable that points -- 2.39.5