From: Arvin Schnell Date: Fri, 3 May 2013 07:51:20 +0000 (+0200) Subject: - make pam module optional X-Git-Tag: v0.1.4~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4145ab75e19bd934b717dbaefc3fe2b29893afe8;p=thirdparty%2Fsnapper.git - make pam module optional - set better cflags - avoid some compiler warnings --- diff --git a/configure.ac b/configure.ac index c1be4b4c..21671ee1 100644 --- a/configure.ac +++ b/configure.ac @@ -48,7 +48,7 @@ dnl Automake 1.11 enables silent compilation dnl Disable it by "configure --disable-silent-rules" or "make V=1" m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -CFLAGS="${CFLAGS} -Wall -Wformat=2 -Wmissing-prototypes" +CFLAGS="${CFLAGS} -std=c99 -Wall -Wextra -Wformat=2 -Wmissing-prototypes -Wno-unused-parameter" CXXFLAGS="${CXXFLAGS} -std=c++0x -Wall -Wextra -Wformat=2 -Wnon-virtual-dtor -Wno-unused-parameter" fillupdir=/var/adm/fillup-templates @@ -105,6 +105,10 @@ if test "x$with_xattrs" != "xno"; then AC_DEFINE(ENABLE_XATTRS, 1, [Enable extended attributes support]) fi +AC_ARG_ENABLE([pam], AC_HELP_STRING([--disable-pam],[Disable pam plugin support]), + [with_pam=$enableval],[with_pam=yes]) +AM_CONDITIONAL(HAVE_PAM, [test "$with_pam" != "no"]) + PKG_CHECK_MODULES(DBUS, dbus-1) AC_SUBST(VERSION) diff --git a/doc/Makefile.am b/doc/Makefile.am index 980ff55b..d0098870 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -2,7 +2,11 @@ # Makefile.am for snapper/doc # -man_MANS = snapper.8 snapperd.8 pam_snapper.8 +man_MANS = snapper.8 snapperd.8 + +if HAVE_PAM +man_MANS += pam_snapper.8 +endif TXTS = dbus-protocol.txt diff --git a/examples/C/snapper_dbus_cli.c b/examples/C/snapper_dbus_cli.c index 1c6822ce..03b52c2b 100644 --- a/examples/C/snapper_dbus_cli.c +++ b/examples/C/snapper_dbus_cli.c @@ -18,6 +18,8 @@ * To contact Novell about this file by physical or electronic mail, you may * find current contact information at www.novell.com. */ + + #include #include #include @@ -206,7 +208,7 @@ static int dict_unpack(DBusMessageIter *iter, static void dict_array_print(uint32_t num_dicts, struct dict *dicts) { - int i; + uint32_t i; for (i = 0; i < num_dicts; i++) { printf("dict (\n" diff --git a/pam/Makefile.am b/pam/Makefile.am index c4cb9746..896618fe 100644 --- a/pam/Makefile.am +++ b/pam/Makefile.am @@ -2,6 +2,8 @@ # Makefile.am for snapper/pam # +if HAVE_PAM + AM_CFLAGS = -D_GNU_SOURCE INCLUDES = -I$(top_srcdir) $(DBUS_CFLAGS) @@ -13,3 +15,5 @@ securelib_LTLIBRARIES = pam_snapper.la pam_snapper_la_LDFLAGS = -no-undefined -avoid-version -module pam_snapper_la_LIBADD = -lpam $(DBUS_LIBS) +endif + diff --git a/pam/pam_snapper.c b/pam/pam_snapper.c index 8a39e282..bb17bce2 100644 --- a/pam/pam_snapper.c +++ b/pam/pam_snapper.c @@ -289,7 +289,6 @@ static int cdbus_create_snap_pack( pam_handle_t * pamh, const char *snapper_conf DBusMessageIter array_iter; DBusMessageIter struct_iter; const char *desc = MODULE_NAME; - uint32_t i; uint32_t *snap_id = NULL; bool ret; const char *modestrings[3] = { "CreateSingleSnapshot", "CreatePreSnapshot", "CreatePostSnapshot" }; @@ -328,7 +327,7 @@ static int cdbus_create_snap_pack( pam_handle_t * pamh, const char *snapper_conf pam_syslog( pamh, LOG_ERR, "failed to open array container" ); return -ENOMEM; } - for ( i = 0; i < num_user_data; i++ ) { + for ( uint32_t i = 0; i < num_user_data; ++i ) { ret = dbus_message_iter_open_container( &array_iter, DBUS_TYPE_DICT_ENTRY, NULL, &struct_iter ); if ( !ret ) { pam_syslog( pamh, LOG_ERR, "failed to open struct container" ); @@ -410,8 +409,7 @@ static void cdbus_fill_user_data( pam_handle_t * pamh, struct dict ( *user_data { int fields[4] = { PAM_RUSER, PAM_RHOST, PAM_TTY, PAM_SERVICE }; const char *names[4] = { "ruser", "rhost", "tty", "service" }; - int i; - for ( i = 0; i < 4; ++i ) { + for ( int i = 0; i < 4; ++i ) { const char *readval = NULL; int ret = pam_get_item( pamh, fields[i], ( const void ** )&readval ); if ( ret == PAM_SUCCESS && readval ) { @@ -533,7 +531,7 @@ static int csv_contains( pam_handle_t * pamh, const char *haystack, const char * const char *e; while ( ( e = strchr( s, ',' ) ) ) { - if ( e - s == l && strncmp( s, needle, l ) == 0 ) + if ( e == s + l && strncmp( s, needle, l ) == 0 ) return 1; s = e + 1; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 9794df03..efb53729 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -2,6 +2,8 @@ # Makefile.am for snapper/scripts # +if HAVE_PAM + pam_snapperdir = /usr/lib/pam_snapper pam_snapper_SCRIPTS = \ @@ -10,6 +12,8 @@ pam_snapper_SCRIPTS = \ pam_snapper_useradd.sh \ pam_snapper_userdel.sh +endif + EXTRA_DIST = snapper-hourly snapper-daily zypp-plugin.py $(pam_snapper_SCRIPTS) install-data-local: diff --git a/snapper/Makefile.am b/snapper/Makefile.am index 75bfedd4..c9c74df8 100644 --- a/snapper/Makefile.am +++ b/snapper/Makefile.am @@ -10,7 +10,7 @@ lib_LTLIBRARIES = libsnapper.la if HAVE_XATTRS TMP_XA = XAttributes.cc XAttributes.h -endif HAVE_XATTRS +endif libsnapper_la_SOURCES = \ Factory.cc Factory.h \ @@ -36,7 +36,6 @@ libsnapper_la_SOURCES = \ $(TMP_XA) - if ENABLE_BTRFS libsnapper_la_SOURCES += \ Btrfs.cc Btrfs.h