Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/mini-sendmail: new aport

From: Stuart Cardall <developer_at_it-offshore.co.uk>
Date: Sat, 30 Jan 2016 22:58:30 +0000

---
 testing/mini-sendmail/APKBUILD      | 59 +++++++++++++++++++++++++++++++++++++
 testing/mini-sendmail/README.alpine |  5 ++++
 testing/mini-sendmail/sh.c          | 33 +++++++++++++++++++++
 3 files changed, 97 insertions(+)
 create mode 100644 testing/mini-sendmail/APKBUILD
 create mode 100644 testing/mini-sendmail/README.alpine
 create mode 100644 testing/mini-sendmail/sh.c
diff --git a/testing/mini-sendmail/APKBUILD b/testing/mini-sendmail/APKBUILD
new file mode 100644
index 0000000..c7b51d2
--- /dev/null
+++ b/testing/mini-sendmail/APKBUILD
_at_@ -0,0 +1,59 @@
+# Contributor: Stuart Cardall <developer_at_it-offshore.co.uk>
+# Maintainer: Stuart Cardall <developer_at_it-offshore.co.uk>
+pkgname=mini-sendmail
+_realname=mini_sendmail
+pkgver=1.3.9
+pkgrel=0
+pkgdesc="Accept mail inside a chroot + wrapper for /bin/sh"
+url="http://acme.com/software/mini_sendmail/"
+arch="all"
+license="custom"
+depends=""
+depends_dev=""
+makedepends="$depends_dev"
+subpackages="$pkgname-doc"
+source="http://www.acme.com/software/$_realname/$_realname-$pkgver.tar.gz
+	README.alpine
+	sh.c
+	"
+
+_builddir="$srcdir"/$_realname-$pkgver
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+	cd "$_builddir"
+	sed -i "s|^BINDIR.*|BINDIR = $pkgdir/var/lib/mini-sendmail|" Makefile
+	sed -i "s|^MANDIR.*|MANDIR = $pkgdir/usr/share/man|" Makefile
+	sed -i 's|cp mini_sendmail.8.*|cp mini_sendmail.8 $(MANDIR)/man8/|' Makefile
+	make || return 1
+	cp "$srcdir"/sh.c ./
+	gcc sh.c -o sh -static || return 1
+}
+
+package() {
+	cd "$_builddir"
+	mkdir -p "$pkgdir"/var/lib/mini-sendmail
+	mkdir -p "$pkgdir"/usr/share/man/man8
+	mkdir -p "$pkgdir"/usr/share/doc/mini-sendmail
+	make DESTDIR="$pkgdir" install || return 1
+	install -Dm755 sh "$pkgdir"/var/lib/mini-sendmail/
+	install -Dm644 "$srcdir"/README.alpine "$pkgdir"/usr/share/doc/mini-sendmail/
+}
+
+md5sums="0769b6d3ba64fa77a52a90c8866fc4ed  mini_sendmail-1.3.9.tar.gz
+e320e6e098a3f11895fe1cb19f10e4aa  README.alpine
+72508a076484adb3eaf8404292581aa2  sh.c"
+sha256sums="2e2741ade434808b2b95c7df7b2016a4a7e629c3d6c87468a7f58fb183a1967b  mini_sendmail-1.3.9.tar.gz
+d0d21a3fe9c38c84b31ac5290013e1d4021b739372265b3e1c496f73e03dac91  README.alpine
+81928177bfc07d77fd54e95c5af396b865201dbd4c94b703283b2140f6306f7f  sh.c"
+sha512sums="b28c39d94b77acc27a8c9e99583904b43815936b2bf7e27b996685784ff1bc9882bdfc57822ddf62d3198f38ec3df0b766289115cb4e6c23abee93884d2d6bb9  mini_sendmail-1.3.9.tar.gz
+d7b6d145fa05a0b3cffd3dfe6bb00593d7891e7eb151710c040557af48aee1399ed0c68fa70f51d458f0c50dbb619fdda6804f2a69a1424d4b25b4ff13a8e197  README.alpine
+6ef9cd763a5b6d07f116b3785ba5d7a6e15ddcd56004c6fd193feb247e9630716b5c332ab0117fd1acccbb0ff3fe294f433944a1a05284b912780e40ade1cb50  sh.c"
diff --git a/testing/mini-sendmail/README.alpine b/testing/mini-sendmail/README.alpine
new file mode 100644
index 0000000..d8aff8a
--- /dev/null
+++ b/testing/mini-sendmail/README.alpine
_at_@ -0,0 +1,5 @@
+PHP launches sendmail via system(), which in turn uses “/bin/sh -c” internally.
+
+/var/lib/mini-sendmail/sh is a wrapper that supports being called with “-c command” to launch sendmail.
+
+https://knzl.de/setting-up-a-chroot-for-php/
diff --git a/testing/mini-sendmail/sh.c b/testing/mini-sendmail/sh.c
new file mode 100644
index 0000000..a42c88b
--- /dev/null
+++ b/testing/mini-sendmail/sh.c
_at_@ -0,0 +1,33 @@
+/* /bin/sh wrapper for mini_sendmail
+	by Sebastian Kienzl
+	https://knzl.de/setting-up-a-chroot-for-php/
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define MAXARG 64
+
+int main( int argc, char* const argv[] ) {
+    char* args[ MAXARG ] = {};
+
+    if( argc < 3 || strcmp( argv[1], "-c" ) != 0 ) {
+        fprintf( stderr, "Usage: %s -c <cmd>\n", argv[0] );
+        return 1;
+    }
+
+    {
+        char* token;
+        int i = 0;
+        char* argStr = strdup( argv[2] );
+        while( ( token = strsep( &argStr, " " ) ) != NULL ) {
+            if( token && strlen( token ) )
+                args[ i++ ] = token;
+            if( i >= MAXARG )
+                return 2;
+        }
+    }
+
+    return execvp( args[0], args );
+}
-- 
2.7.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Sat Jan 30 2016 - 22:58:30 GMT