Patchwork sudo: fix install

login
register
mail settings
Submitter Simon Dawson
Date June 21, 2012, 8:45 a.m.
Message ID <1340268304-26103-1-git-send-email-spdawson@gmail.com>
Download mbox | patch
Permalink /patch/166256/
State Accepted
Commit 463ffd9ee401d4fcff0883735db38c873be1d9a0
Headers show

Comments

Simon Dawson - June 21, 2012, 8:45 a.m.
From: Simon Dawson <spdawson@gmail.com>

Running sudo on the target fails with the following errors.

  sudo: /usr/libexec/sudoers.so: No such file or directory
  sudo: fatal error, unable to load plugins

The problem is that the installation of the sudo package is broken. This patch
replaces the hand-crafted install rule with the default AUTOTARGETS install.

Unfortunately, the default install fails because it includes a step that
invokes the cross-compiled visudo binary. A patch is provided here to disable
this visudo invocation, which is for sanity checking only. This local patch is
a backport of upstream commit 8209:0c4e3f68b2f5; the real fix will be in the
1.8.6 release of sudo.

Signed-off-by: Simon Dawson <spdawson@gmail.com>
---
 ...rt-commit-8209:0c4e3f68b2f5-from-upstream.patch |  263 ++++++++++++++++++++
 package/sudo/sudo.mk                               |    8 -
 2 files changed, 263 insertions(+), 8 deletions(-)
 create mode 100644 package/sudo/sudo-1.8.5p1-backport-commit-8209:0c4e3f68b2f5-from-upstream.patch
Arnout Vandecappelle - June 21, 2012, 8:11 p.m.
On 06/21/12 10:45, spdawson@gmail.com wrote:
> From: Simon Dawson<spdawson@gmail.com>
>
> Running sudo on the target fails with the following errors.
>
>    sudo: /usr/libexec/sudoers.so: No such file or directory
>    sudo: fatal error, unable to load plugins
>
> The problem is that the installation of the sudo package is broken. This patch
> replaces the hand-crafted install rule with the default AUTOTARGETS install.
>
> Unfortunately, the default install fails because it includes a step that
> invokes the cross-compiled visudo binary. A patch is provided here to disable
> this visudo invocation, which is for sanity checking only. This local patch is
> a backport of upstream commit 8209:0c4e3f68b2f5; the real fix will be in the
> 1.8.6 release of sudo.
>
> Signed-off-by: Simon Dawson<spdawson@gmail.com>

Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

  Nice work, Simon!  I especially like the very extensive comment in the
patch header.

  It's a pity that upstream decided to add the cross_compiling assignment to
all these Makefile.in where it isn't actually used, but that's their choice...


  Regards,
  Arnout
Thomas Petazzoni - June 21, 2012, 9:53 p.m.
Le Thu, 21 Jun 2012 22:11:44 +0200,
Arnout Vandecappelle <arnout@mind.be> a écrit :

>   Nice work, Simon!  I especially like the very extensive comment in the
> patch header.

Yes, thanks a lot for this work, and your persistence in getting this
done properly!

>   It's a pity that upstream decided to add the cross_compiling assignment to
> all these Makefile.in where it isn't actually used, but that's their choice...

Well, once it will be in a released version, we'll discard the patch
and we'll no longer notice this :)

Thomas
Simon Dawson - June 22, 2012, 6:48 a.m.
On 21 June 2012 22:53, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Le Thu, 21 Jun 2012 22:11:44 +0200,
> Arnout Vandecappelle <arnout@mind.be> a écrit :
>
>>   Nice work, Simon!  I especially like the very extensive comment in the
>> patch header.
>
> Yes, thanks a lot for this work, and your persistence in getting this done properly!

Thanks for your help with this.

Simon.
Peter Korsgaard - June 23, 2012, 7:36 a.m.
>>>>> "spdawson" == spdawson  <spdawson@gmail.com> writes:

 spdawson> From: Simon Dawson <spdawson@gmail.com>
 spdawson> Running sudo on the target fails with the following errors.

 spdawson>   sudo: /usr/libexec/sudoers.so: No such file or directory
 spdawson>   sudo: fatal error, unable to load plugins

Committed, thanks.

Patch

diff --git a/package/sudo/sudo-1.8.5p1-backport-commit-8209:0c4e3f68b2f5-from-upstream.patch b/package/sudo/sudo-1.8.5p1-backport-commit-8209:0c4e3f68b2f5-from-upstream.patch
new file mode 100644
index 0000000..69512b0
--- /dev/null
+++ b/package/sudo/sudo-1.8.5p1-backport-commit-8209:0c4e3f68b2f5-from-upstream.patch
@@ -0,0 +1,263 @@ 
+The installation of the sudoers plugin fails when cross compiling, because it
+tries to run the cross-compiled visudo, rather than that of the host.
+
+The visudo invocation is only required in order to sanity check any existing
+sudoers file in the target directory; this can safely be dispensed with.
+
+This is a backport of commit 8209:0c4e3f68b2f5 from upstream.
+
+N.B. The upstream fix will appear in sudo 1.8.6; when the Buildroot package
+is bumped to version 1.8.6 (or higher), then this patch will no longer be
+required.
+
+Signed-off-by: Simon Dawson <spdawson@gmail.com>
+diff -Nurp a/common/Makefile.in b/common/Makefile.in
+--- a/common/Makefile.in	2012-05-15 17:22:01.000000000 +0100
++++ b/common/Makefile.in	2012-06-21 08:55:57.345169676 +0100
+@@ -24,6 +24,7 @@ devdir = @devdir@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ incdir = $(top_srcdir)/include
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Where to install things...
+ prefix = @prefix@
+diff -Nurp a/compat/Makefile.in b/compat/Makefile.in
+--- a/compat/Makefile.in	2012-05-15 17:22:01.000000000 +0100
++++ b/compat/Makefile.in	2012-06-21 08:57:09.097166477 +0100
+@@ -24,6 +24,7 @@ devdir = @devdir@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ incdir = $(top_srcdir)/include
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Where to install things...
+ prefix = @prefix@
+@@ -111,19 +112,21 @@ install-plugin:
+ uninstall:
+ 
+ check: $(TEST_PROGS)
+-	@if [ -f fnm_test ]; then \
+-	    ./fnm_test $(srcdir)/regress/fnmatch/fnm_test.in; \
+-	fi
+-	@if [ -f globtest ]; then \
+-	    mkdir -p `sed 's@/[^/]*$$@@' $(srcdir)/regress/glob/files | sort -u`; \
+-	    touch `cat $(srcdir)/regress/glob/files`; \
+-	    chmod 0755 `grep '/r[^/]*$$' $(srcdir)/regress/glob/files`; \
+-	    chmod 0444 `grep '/s[^/]*$$' $(srcdir)/regress/glob/files`; \
+-	    chmod 0711 `grep '/t[^/]*$$' $(srcdir)/regress/glob/files`; \
+-	    ./globtest $(srcdir)/regress/glob/globtest.in; \
+-	    rval=$$?; \
+-	    rm -rf fake; \
+-	    exit $$rval; \
++	@if test X"$(cross_compiling)" != X"yes"; then \
++	    if test -f fnm_test; then \
++		./fnm_test $(srcdir)/regress/fnmatch/fnm_test.in; \
++	    fi; \
++	    if test -f globtest; then \
++		mkdir -p `sed 's@/[^/]*$$@@' $(srcdir)/regress/glob/files | sort -u`; \
++		touch `cat $(srcdir)/regress/glob/files`; \
++		chmod 0755 `grep '/r[^/]*$$' $(srcdir)/regress/glob/files`; \
++		chmod 0444 `grep '/s[^/]*$$' $(srcdir)/regress/glob/files`; \
++		chmod 0711 `grep '/t[^/]*$$' $(srcdir)/regress/glob/files`; \
++		./globtest $(srcdir)/regress/glob/globtest.in; \
++		rval=$$?; \
++		rm -rf fake; \
++		exit $$rval; \
++	    fi; \
+ 	fi
+ 
+ clean:
+diff -Nurp a/configure b/configure
+--- a/configure	2012-05-17 20:53:53.000000000 +0100
++++ b/configure	2012-06-21 08:58:08.769163817 +0100
+@@ -691,6 +691,7 @@ password_timeout
+ timeout
+ timedir
+ iolog_dir
++CROSS_COMPILING
+ COMPAT_TEST_PROGS
+ SUDO_NLS
+ LIBINTL
+@@ -2874,6 +2875,7 @@ $as_echo "$as_me: Configuring Sudo versi
+ 
+ 
+ 
++
+ #
+ # Begin initial values for man page substitution
+ #
+@@ -20094,6 +20096,8 @@ if test -n "$GCC"; then
+     fi
+ fi
+ 
++CROSS_COMPILING="$cross_compiling"
++
+ test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
+ 
+ if test X"$with_noexec" != X"no" -o X"$with_selinux" != X"no"; then
+diff -Nurp a/configure.in b/configure.in
+--- a/configure.in	2012-05-17 20:53:54.000000000 +0100
++++ b/configure.in	2012-06-21 08:58:51.017161934 +0100
+@@ -67,6 +67,7 @@ AC_SUBST([LT_STATIC])
+ AC_SUBST([LIBINTL])
+ AC_SUBST([SUDO_NLS])
+ AC_SUBST([COMPAT_TEST_PROGS])
++AC_SUBST([CROSS_COMPILING])
+ dnl
+ dnl Variables that get substituted in docs (not overridden by environment)
+ dnl
+@@ -3198,6 +3199,11 @@ if test -n "$GCC"; then
+ fi
+ 
+ dnl
++dnl Skip regress tests and sudoers sanity check if cross compiling.
++dnl
++CROSS_COMPILING="$cross_compiling"
++
++dnl
+ dnl Set exec_prefix
+ dnl
+ test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
+diff -Nurp a/doc/Makefile.in b/doc/Makefile.in
+--- a/doc/Makefile.in	2012-03-12 18:02:07.000000000 +0000
++++ b/doc/Makefile.in	2012-06-21 08:59:06.537161242 +0100
+@@ -23,6 +23,7 @@ srcdir = @srcdir@
+ docdir = @docdir@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Tools to use
+ NROFF = @NROFFPROG@
+diff -Nurp a/plugins/sample/Makefile.in b/plugins/sample/Makefile.in
+--- a/plugins/sample/Makefile.in	2012-03-12 18:02:09.000000000 +0000
++++ b/plugins/sample/Makefile.in	2012-06-21 08:59:24.397160445 +0100
+@@ -24,6 +24,7 @@ devdir = @devdir@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ incdir = $(top_srcdir)/include
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Compiler & tools to use
+ CC = @CC@
+diff -Nurp a/plugins/sample_group/Makefile.in b/plugins/sample_group/Makefile.in
+--- a/plugins/sample_group/Makefile.in	2012-05-15 17:22:02.000000000 +0100
++++ b/plugins/sample_group/Makefile.in	2012-06-21 08:59:38.641159810 +0100
+@@ -24,6 +24,7 @@ devdir = @devdir@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ incdir = $(top_srcdir)/include
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Compiler & tools to use
+ CC = @CC@
+diff -Nurp a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in
+--- a/plugins/sudoers/Makefile.in	2012-05-15 17:22:02.000000000 +0100
++++ b/plugins/sudoers/Makefile.in	2012-06-21 09:32:26.165072089 +0100
+@@ -32,6 +32,7 @@ top_srcdir = @top_srcdir@
+ incdir = $(top_srcdir)/include
+ docdir = @docdir@
+ timedir = @timedir@
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Compiler & tools to use
+ CC = @CC@
+@@ -237,7 +238,7 @@ sudoers: $(srcdir)/sudoers.in
+ 	(cd $(top_builddir) && $(SHELL) config.status --file=plugins/sudoers/$@)
+ 
+ pre-install:
+-	@if test -r $(DESTDIR)$(sudoersdir)/sudoers; then \
++	@if test X"$(cross_compiling)" != X"yes" -a -r $(DESTDIR)$(sudoersdir)/sudoers; then \
+ 	    echo "Checking existing sudoers file for syntax errors."; \
+ 	    ./visudo -c -f $(DESTDIR)$(sudoersdir)/sudoers; \
+ 	fi
+@@ -280,17 +281,23 @@ uninstall:
+ 	    rm -f $(DESTDIR)$(sudoersdir)/sudoers
+ 
+ check: $(TEST_PROGS) visudo testsudoers
+-	@-rval=0; \
+-	./check_addr $(srcdir)/regress/parser/check_addr.in; \
++	@-if test X"$(cross_compiling)" != X"yes"; then \
++	    rval=0; \
++	    PWD=`pwd`; \
++	    ./check_addr $(srcdir)/regress/parser/check_addr.in; \
+ 	rval=`expr $$rval + $$?`; \
+-	./check_fill; \
+-	rval=`expr $$rval + $$?`; \
+-	./check_iolog_path $(srcdir)/regress/iolog_path/data; \
+-	rval=`expr $$rval + $$?`; \
+-	./check_wrap $(srcdir)/regress/logging/check_wrap.in > check_wrap.out; \
+-	diff check_wrap.out $(srcdir)/regress/logging/check_wrap.out.ok; \
+-	rval=`expr $$rval + $$?`; \
+-	passed=0; failed=0; total=0; \
++	    ./check_fill; \
++	    rval=`expr $$rval + $$?`; \
++	    ./check_iolog_path $(srcdir)/regress/iolog_path/data; \
++	    rval=`expr $$rval + $$?`; \
++	    if [ X"$(soext)" != X"" ]; then \
++		./check_symbols .libs/sudoers$(soext) $(shlib_exp); \
++		rval=`expr $$rval + $$?`; \
++	    fi; \
++	    ./check_wrap $(srcdir)/regress/logging/check_wrap.in > check_wrap.out; \
++	    diff check_wrap.out $(srcdir)/regress/logging/check_wrap.out.ok; \
++	    rval=`expr $$rval + $$?`; \
++	    passed=0; failed=0; total=0; \
+ 	    for t in $(srcdir)/regress/sudoers/*.in; do \
+ 		dir=`dirname $$t`; \
+ 		dirbase=`basename $$dir`; \
+@@ -318,8 +325,8 @@ check: $(TEST_PROGS) visudo testsudoers
+ 		total=`expr $$total + 1`; \
+ 	    done; \
+ 	    echo "$$dirbase: $$passed/$$total tests passed; $$failed/$$total tests failed"; \
+-	rval=`expr $$rval + $$failed`; \
+-	passed=0; failed=0; total=0; \
++	    rval=`expr $$rval + $$failed`; \
++	    passed=0; failed=0; total=0; \
+ 	    for t in $(srcdir)/regress/*/*.sh; do \
+ 		dir=`dirname $$t`; \
+ 		dirbase=`basename $$dir`; \
+@@ -351,7 +358,9 @@ check: $(TEST_PROGS) visudo testsudoers
+ 		fi; \
+ 	    done; \
+ 	    echo "$$dirbase: $$passed/$$total tests passed; $$failed/$$total tests failed"; \
+-	    rval=`expr $$rval + $$failed`; exit $$rval
++	    rval=`expr $$rval + $$failed`; \
++	    exit $$rval; \
++	fi
+ 
+ clean:
+ 	-$(LIBTOOL) --mode=clean rm -f $(PROGS) $(TEST_PROGS) *.lo *.o *.la *.a stamp-* core *.core core.* *.out *.toke *.err
+diff -Nurp a/plugins/system_group/Makefile.in b/plugins/system_group/Makefile.in
+--- a/plugins/system_group/Makefile.in	2012-05-15 17:22:03.000000000 +0100
++++ b/plugins/system_group/Makefile.in	2012-06-21 09:32:38.361071545 +0100
+@@ -24,6 +24,7 @@ devdir = @devdir@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ incdir = $(top_srcdir)/include
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Compiler & tools to use
+ CC = @CC@
+diff -Nurp a/src/Makefile.in b/src/Makefile.in
+--- a/src/Makefile.in	2012-05-08 21:56:43.000000000 +0100
++++ b/src/Makefile.in	2012-06-21 09:32:53.233070882 +0100
+@@ -24,6 +24,7 @@ devdir = @devdir@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ incdir = $(top_srcdir)/include
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Compiler & tools to use
+ CC = @CC@
+diff -Nurp a/zlib/Makefile.in b/zlib/Makefile.in
+--- a/zlib/Makefile.in	2012-03-12 18:02:17.000000000 +0000
++++ b/zlib/Makefile.in	2012-06-21 09:33:03.417070428 +0100
+@@ -22,6 +22,7 @@
+ srcdir = @srcdir@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
++cross_compiling = @CROSS_COMPILING@
+ 
+ # Compiler & tools to use
+ CC = @CC@
diff --git a/package/sudo/sudo.mk b/package/sudo/sudo.mk
index 3629ad1..f1efc54 100644
--- a/package/sudo/sudo.mk
+++ b/package/sudo/sudo.mk
@@ -14,12 +14,4 @@  SUDO_CONF_OPT = \
 		--without-interfaces \
 		--without-pam
 
-define SUDO_INSTALL_TARGET_CMDS
-	install -m 4555 -D $(@D)/src/sudo $(TARGET_DIR)/usr/bin/sudo
-	install -m 0555 -D $(@D)/plugins/sudoers/visudo  \
-		$(TARGET_DIR)/usr/sbin/visudo
-	install -m 0440 -D $(@D)/plugins/sudoers/sudoers \
-		$(TARGET_DIR)/etc/sudoers
-endef
-
 $(eval $(call AUTOTARGETS))