]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- make pam module optional
authorArvin Schnell <aschnell@suse.de>
Fri, 3 May 2013 07:51:20 +0000 (09:51 +0200)
committerArvin Schnell <aschnell@suse.de>
Fri, 3 May 2013 07:51:20 +0000 (09:51 +0200)
- set better cflags
- avoid some compiler warnings

configure.ac
doc/Makefile.am
examples/C/snapper_dbus_cli.c
pam/Makefile.am
pam/pam_snapper.c
scripts/Makefile.am
snapper/Makefile.am

index c1be4b4c44beea35e3b2f941fe854103c6e31153..21671ee15253db1015b7ac22500b9eb388856b55 100644 (file)
@@ -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)
index 980ff55b993778027584dac191afb8fd6eef036e..d00988705789c54b4152f9171857aef379e69e2f 100644 (file)
@@ -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
 
index 1c6822ce8a2202ec010596513ac11e28d634e6d3..03b52c2b5a7ed7cd39d41763c74e19710603e291 100644 (file)
@@ -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 <dbus/dbus.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -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"
index c4cb9746c916b6b682e854423043efcd44bfb89c..896618fe7712f258efc157fb4d86f6a35f263742 100644 (file)
@@ -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
+
index 8a39e28287f4c83127c5ebe358c630448a967ef3..bb17bce2ddf464adea44e61990a38bfc72fbdb29 100644 (file)
@@ -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;
index 9794df03e4279eb4515ce7a0ef28e2aae91b5f9a..efb53729bea801b3d071df7279ebc0fb009cc03c 100644 (file)
@@ -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:
index 75bfedd4abfe38ba9a6f4e5573effdc334519e8b..c9c74df8d7cd3fc9d1ced68a5c4c9df6d5944ae4 100644 (file)
@@ -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