From 44c763c72870337843ec6a96264ccb8373f4b44b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 29 Mar 2011 15:20:32 -0400 Subject: [PATCH] If there is an existing sudoers file, only install if it passes a syntax check. --- Makefile.in | 7 +++++-- common/Makefile.in | 2 ++ compat/Makefile.in | 2 ++ doc/Makefile.in | 2 ++ include/Makefile.in | 2 ++ plugins/sample/Makefile.in | 2 ++ plugins/sample_group/Makefile.in | 2 ++ plugins/sudoers/Makefile.in | 8 +++++++- src/Makefile.in | 2 ++ zlib/Makefile.in | 2 ++ 10 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index b384425fc..132d56cfc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -57,10 +57,13 @@ all: config.status check: config.status for d in $(SUBDIRS) $(SAMPLES); do (cd $$d && $(MAKE) $@) || break; done -install-dirs install-binaries install-includes install-plugin uninstall: config.status +pre-install: for d in $(SUBDIRS); do (cd $$d && $(MAKE) $@) || break; done -install install-doc: config.status ChangeLog +install-dirs install-binaries install-includes install-plugin uninstall: config.status pre-install + for d in $(SUBDIRS); do (cd $$d && $(MAKE) $@) || break; done + +install install-doc: config.status ChangeLog pre-install for d in $(SUBDIRS); do (cd $$d && $(MAKE) $@) || break; done autoconf: diff --git a/common/Makefile.in b/common/Makefile.in index 2a83c4b1a..a0fd01da4 100644 --- a/common/Makefile.in +++ b/common/Makefile.in @@ -78,6 +78,8 @@ term.lo: $(srcdir)/term.c $(incdir)/missing.h $(top_builddir)/config.h zero_bytes.lo: $(srcdir)/zero_bytes.c $(incdir)/missing.h $(top_builddir)/config.h $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/zero_bytes.c +pre-install: + install: install-dirs: diff --git a/compat/Makefile.in b/compat/Makefile.in index 36ecba571..150e65982 100644 --- a/compat/Makefile.in +++ b/compat/Makefile.in @@ -114,6 +114,8 @@ strsignal.lo: $(srcdir)/strsignal.c $(incdir)/missing.h $(top_builddir)/config.h utimes.lo: $(srcdir)/utimes.c $(incdir)/missing.h $(srcdir)/utime.h $(top_builddir)/config.h $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/utimes.c +pre-install: + install: install-dirs: diff --git a/doc/Makefile.in b/doc/Makefile.in index 4468a3f16..414d8c070 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -142,6 +142,8 @@ HISTORY: $(srcdir)/history.pod LICENSE: $(srcdir)/license.pod pod2text -l -i0 $(srcdir)/license.pod | sed '1,2d' > $@ +pre-install: + install: install-dirs install-doc install-dirs: diff --git a/include/Makefile.in b/include/Makefile.in index d7be382a3..150ca621d 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -47,6 +47,8 @@ Makefile: $(srcdir)/Makefile.in .SUFFIXES: .h +pre-install: + install: install-dirs install-includes install-dirs: diff --git a/plugins/sample/Makefile.in b/plugins/sample/Makefile.in index a7da2c1c6..0cdc880dc 100644 --- a/plugins/sample/Makefile.in +++ b/plugins/sample/Makefile.in @@ -85,6 +85,8 @@ sample_plugin.lo: $(srcdir)/sample_plugin.c sample_plugin.la: $(OBJS) $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) -module -export-symbols $(srcdir)/sample_plugin.sym -avoid-version -rpath $(plugindir) +pre-install: + install: install-dirs install-plugin install-dirs: diff --git a/plugins/sample_group/Makefile.in b/plugins/sample_group/Makefile.in index 3a2237056..ac35a2faf 100644 --- a/plugins/sample_group/Makefile.in +++ b/plugins/sample_group/Makefile.in @@ -88,6 +88,8 @@ sample_group.lo: $(srcdir)/sample_group.c sample_group.la: $(OBJS) $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) -module -export-symbols $(srcdir)/sample_group.sym -avoid-version -rpath $(plugindir) +pre-install: + install: install-dirs install-plugin install-dirs: diff --git a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in index e99288a6c..18d464823 100644 --- a/plugins/sudoers/Makefile.in +++ b/plugins/sudoers/Makefile.in @@ -328,6 +328,12 @@ tsgetgrpw.o: $(srcdir)/tsgetgrpw.c $(SUDODEP) visudo.o: $(srcdir)/visudo.c $(SUDODEP) $(devdir)/gram.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/visudo.c +pre-install: + @if test -r $(DESTDIR)$(sudoersdir)/sudoers; then \ + echo "Checking existing sudoers file for syntax errors."; \ + ./visudo -c -f $(DESTDIR)$(sudoersdir)/sudoers; \ + fi + install: install-dirs install-plugin install-binaries install-sudoers install-doc install-dirs: @@ -351,7 +357,7 @@ install-plugin: sudoers.la install-dirs install-sudoers: install-dirs $(INSTALL) -d -O $(sudoers_uid) -G $(sudoers_gid) -M 0750 \ $(DESTDIR)$(sudoersdir)/sudoers.d - test -f $(DESTDIR)$(sudoersdir)/sudoers || \ + test -r $(DESTDIR)$(sudoersdir)/sudoers || \ $(INSTALL) -O $(sudoers_uid) -G $(sudoers_gid) -M $(sudoers_mode) \ sudoers $(DESTDIR)$(sudoersdir)/sudoers diff --git a/src/Makefile.in b/src/Makefile.in index 9b4a3b49d..c1b15bc43 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -141,6 +141,8 @@ ttysize.o: $(srcdir)/ttysize.c $(incdir)/missing.h $(top_builddir)/config.h utmp.o: $(srcdir)/utmp.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/utmp.c +pre-install: + install: install-dirs install-binaries @INSTALL_NOEXEC@ install-dirs: diff --git a/zlib/Makefile.in b/zlib/Makefile.in index e74f518ec..469db6633 100644 --- a/zlib/Makefile.in +++ b/zlib/Makefile.in @@ -89,6 +89,8 @@ uncompr.lo: $(srcdir)/zlib.h ./zconf.h zutil.lo: $(srcdir)/zutil.h $(srcdir)/zlib.h ./zconf.h $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/zutil.c +pre-install: + install: install-dirs: -- 2.40.0