From 9bccceaea13d02725acde4e7a1418bb566b1bce5 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 26 Apr 2017 13:52:49 -0600 Subject: [PATCH] In "make install", install sample sudoers file as /etc/sudoers.dist and copy it to /etc/sudoers if there is no existing /etc/sudoers. Packages either contain /etc/sudoers (RPM and Debian) or /etc/sudoers.dist (everything else). --- plugins/sudoers/Makefile.in | 6 ++++-- sudo.pp | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in index b0aef8abb..3c091734a 100644 --- a/plugins/sudoers/Makefile.in +++ b/plugins/sudoers/Makefile.in @@ -349,8 +349,9 @@ install-plugin: sudoers.la install-dirs install-sudoers: install-dirs $(INSTALL) -d $(INSTALL_OWNER) -m 0750 $(DESTDIR)$(sudoersdir)/sudoers.d + $(INSTALL) $(INSTALL_OWNER) -m $(sudoers_mode) sudoers $(DESTDIR)$(sudoersdir)/sudoers.dist test -r $(DESTDIR)$(sudoersdir)/sudoers || \ - $(INSTALL) $(INSTALL_OWNER) -m $(sudoers_mode) sudoers $(DESTDIR)$(sudoersdir)/sudoers + cp -p $(DESTDIR)$(sudoersdir)/sudoers.dist $(DESTDIR)$(sudoersdir)/sudoers uninstall: -$(LIBTOOL) $(LTFLAGS) --mode=uninstall rm -f $(DESTDIR)$(plugindir)/sudoers.la @@ -360,8 +361,9 @@ uninstall: $(DESTDIR)$(replaydir)/sudoreplay$(INSTALL_BACKUP) \ $(DESTDIR)$(visudodir)/visudo$(INSTALL_BACKUP) \ $(DESTDIR)$(plugindir)/sudoers.so$(INSTALL_BACKUP) - -cmp $(DESTDIR)$(sudoersdir)/sudoers $(srcdir)/sudoers >/dev/null && \ + -cmp $(DESTDIR)$(sudoersdir)/sudoers $(DESTDIR)$(sudoersdir)/sudoers.dist >/dev/null && \ rm -f $(DESTDIR)$(sudoersdir)/sudoers + -rm -f $(DESTDIR)$(sudoersdir)/sudoers.dist splint: splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(devdir) -I$(srcdir) -I$(top_srcdir) $(srcdir)/*.c $(srcdir)/auth/*.c diff --git a/sudo.pp b/sudo.pp index d39742508..6ed628011 100644 --- a/sudo.pp +++ b/sudo.pp @@ -85,10 +85,11 @@ still allow people to get their work done." if test -n "$linux_audit"; then pp_rpm_requires="audit-libs >= $linux_audit" fi + # The package manager will handle an existing sudoers file + rm -f ${pp_destdir}$sudoersdir/sudoers.dist %else - # For all but RPM and Debian we need to install sudoers with a different - # name and make a copy of it if there is no existing file. - mv ${pp_destdir}$sudoersdir/sudoers ${pp_destdir}$sudoersdir/sudoers.dist + # For all but RPM and Debian we copy sudoers in a post-install script. + rm -f ${pp_destdir}$sudoersdir/sudoers %endif %if [deb] -- 2.40.0