~alpine/aports

testing/mini-sendmail: new aport v1 PROPOSED

Stuart Cardall: 1
 testing/mini-sendmail: new aport

 3 files changed, 97 insertions(+), 0 deletions(-)
mini_sendmail is statically compiled & is designed to be placed into a
chroot. It connects to localhost:25 to send email. The sh that
accompanies it is a wrapper used by php mail().

I bind mount a ro,nosuid,nodev 200k tmpfs containing sh & mini_sendmail
into LXC containers. This itself is bind mounted into a
noexec,nosuid,nodev /var/www.

You cannot do this with busybox sendmail. I've tested this with exim.

Stuart.

On 01/31/2016 06:37 AM, Valery Kartel wrote:
Yes I noticed too & sent a version 2 patch last night with a LICENSE in
the $pkg-doc.

Stuart.

On 02/10/2016 02:34 AM, Isaac Dunham wrote:
> From mini_sendmail.c
------------------------------------------------------------------------

/* mini_sendmail - accept email on behalf of real sendmail
**
** Copyright � 1999,2015 by Jef Poskanzer <jef@mail.acme.com>.
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
**    notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
**    notice, this list of conditions and the following disclaimer in the
**    documentation and/or other materials provided with the distribution.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE
** ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
*/
On 02/09/2016 06:18 PM, Natanael Copa wrote:
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.alpinelinux.org/~alpine/aports/patches/2271/mbox | git am -3
Learn more about email & git

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

---
 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
@@ -0,0 +1,59 @@
# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@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
@@ -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
@@ -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@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
It is the same as the busybox sendmail
31 січ. 2016 00:58 "Stuart Cardall" <developer@it-offshore.co.uk> пише: