From 85a89c337f54bf5411bfc7cb46d60985f2072e76 Mon Sep 17 00:00:00 2001
From: Carsten Schlote <c.schlote@konzeptpark.de>
Date: Mon, 1 Oct 2007 17:38:39 +0200
Subject: [PATCH] This patch updates sudo to version 1.6.9p2.

It patches some compile breakage, when trying to cross compile.

It also allows to install a user sudoers file from projectroot.

Signed-off-by: Carsten Schlote <c.schlote@konzeptpark.de>
---
 .../generic/0001-FixCrossCompile.patch             |   11 ++++++
 rules/Kconfig                                      |    2 +-
 rules/sudo.in                                      |   39 ++++++++++++++++++++
 rules/sudo.make                                    |   36 +++++++++++++++++-
 4 files changed, 85 insertions(+), 3 deletions(-)
 create mode 100644 patches/sudo-1.6.9p2/generic/0001-FixCrossCompile.patch

diff --git a/patches/sudo-1.6.9p2/generic/0001-FixCrossCompile.patch b/patches/sudo-1.6.9p2/generic/0001-FixCrossCompile.patch
new file mode 100644
index 0000000..d3b3762
--- /dev/null
+++ b/patches/sudo-1.6.9p2/generic/0001-FixCrossCompile.patch
@@ -0,0 +1,11 @@
+--- sudo-1.6.8p12/configure.orig	2007-07-06 16:42:44.000000000 +0200
++++ sudo-1.6.8p12/configure	2007-07-06 16:43:33.000000000 +0200
+@@ -24397,7 +24397,7 @@ if test "$cross_compiling" = yes; then
+ See \`config.log' for more details." >&5
+ echo "$as_me: error: cannot run test program while cross compiling
+ See \`config.log' for more details." >&2;}
+-   { (exit 1); exit 1; }; }
++    }
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
diff --git a/rules/Kconfig b/rules/Kconfig
index 80c437a..008ea31 100644
--- a/rules/Kconfig
+++ b/rules/Kconfig
@@ -70,6 +70,7 @@ source "rules/pdksh.in"
 source "rules/procps.in"
 source "rules/screen.in"
 source "rules/setserial.in"
+source "rules/sudo.in"
 source "rules/sysfsutils.in"
 source "rules/sysutils.in"
 source "rules/util-linux.in"
@@ -260,7 +261,6 @@ source "rules/libIDL-2.in"
 source "rules/liboop.in"
 source "rules/paranoia.in"
 source "rules/qte.in"
-source "rules/sudo.in"
 source "rules/tinylogin.in"
 source "rules/xvkbd.in"
 endmenu
diff --git a/rules/sudo.in b/rules/sudo.in
index 33df390..0026aae 100644
--- a/rules/sudo.in
+++ b/rules/sudo.in
@@ -9,3 +9,42 @@ config SUDO
  	  as few privileges as possible but still allow
 	  people to get their work done.
 
+if SUDO
+
+config SUDO_NO_SENDMAIL
+	bool "Send no mails"
+	default y
+
+config SUDO_NO_PAM
+	bool "Don't use libpam"
+	default y
+
+config SUDO_ETC_SUDOERS
+	bool "Install sudoers file into /etc"
+	default y
+	help
+	  Installs /etc/sudoers from a selectable source
+
+	choice
+		prompt "Kind of sudoers"
+		default SUDO_ETC_SUDOERS_DEFAULT
+		depends on SUDO_ETC_SUDOERS
+
+		config SUDO_ETC_SUDOERS_DEFAULT
+			bool
+			prompt "Use generic"
+			help
+			  Installs a generic /etc/sudoers file from the
+			  sources.
+
+		config SUDO_ETC_SUDOERS_USER
+			bool
+			prompt "User defined"
+			help
+			  This uses a user defined /etc/sudoers file. PTXdist
+			  uses file projectroot/etc/sudoers in your local project.
+
+	endchoice
+
+
+endif
diff --git a/rules/sudo.make b/rules/sudo.make
index d9a70ae..f30f4b7 100644
--- a/rules/sudo.make
+++ b/rules/sudo.make
@@ -19,7 +19,7 @@ PACKAGES-$(PTXCONF_SUDO) += sudo
 #
 # Paths and names
 #
-SUDO_VERSION	= 1.6.8
+SUDO_VERSION	= 1.6.9p2
 SUDO		= sudo-$(SUDO_VERSION)
 SUDO_SUFFIX	= tar.gz
 SUDO_URL	= http://www.courtesan.com/sudo/dist/$(SUDO).$(SUDO_SUFFIX)
@@ -68,6 +68,13 @@ SUDO_ENV 	=  $(CROSS_ENV)
 #
 SUDO_AUTOCONF =  $(CROSS_AUTOCONF_USR)
 
+  ifdef PTXCONF_SUDO_NO_SENDMAIL
+SUDO_AUTOCONF += --without-sendmail
+  endif
+  ifdef PTXCONF_SUDO_NO_PAM
+SUDO_AUTOCONF += --without-pam
+  endif
+
 $(STATEDIR)/sudo.prepare: $(sudo_prepare_deps_default)
 	@$(call targetinfo, $@)
 	@$(call clean, $(SUDO_DIR)/config.cache)
@@ -95,7 +102,7 @@ sudo_install: $(STATEDIR)/sudo.install
 
 $(STATEDIR)/sudo.install: $(sudo_install_deps_default)
 	@$(call targetinfo, $@)
-	@$(call install, SUDO)
+	# FIXME: @$(call install, SUDO)
 	@$(call touch, $@)
 
 # ----------------------------------------------------------------------------
@@ -106,6 +113,31 @@ sudo_targetinstall: $(STATEDIR)/sudo.targetinstall
 
 $(STATEDIR)/sudo.targetinstall: $(sudo_targetinstall_deps_default)
 	@$(call targetinfo, $@)
+
+	@$(call install_init, sudo)
+	@$(call install_fixup, sudo,PACKAGE,sudo)
+	@$(call install_fixup, sudo,PRIORITY,optional)
+	@$(call install_fixup, sudo,VERSION,$(SUDO_VERSION))
+	@$(call install_fixup, sudo,SECTION,base)
+	@$(call install_fixup, sudo,AUTHOR,"Carsten Schlote <c.schlote\@konzeptpark.de>")
+	@$(call install_fixup, sudo,DEPENDS,)
+	@$(call install_fixup, sudo,DESCRIPTION,missing)
+
+	@$(call install_copy, sudo, 0, 0, 7755, $(SUDO_DIR)/sudo, /usr/bin/sudo)
+	@$(call install_link, sudo, sudo, /usr/bin/sudoedit)
+
+	@$(call install_copy, sudo, 0, 0, 0755, $(SUDO_DIR)/.libs/sudo_noexec.so, /usr/libexec/sudo_noexec.so)
+
+ ifdef PTXCONF_SUDO_ETC_SUDOERS
+  ifdef PTXCONF_SUDO_ETC_SUDOERS_DEFAULT
+	@$(call install_copy, sudo, 0, 0, 0440, $(SUDO_DIR)/sudoers, /etc/sudoers,n)
+  endif
+  ifdef PTXCONF_SUDO_ETC_SUDOERS_USER
+	@$(call install_copy, sudo, 0, 0, 0440, ${PTXDIST_WORKSPACE}/projectroot/etc/sudoers, /etc/sudoers,n)
+  endif
+ endif
+	@$(call install_finish, sudo)
+
 	@$(call touch, $@)
 
 # ----------------------------------------------------------------------------
-- 
1.5.3.1

