patch to work in php-fpm jail
patch to work in php-fpm jail

--- a/mini_sendmail.c
+++ b/mini_sendmail.c
@@ -30,7 +30,8 @@
 ** don't want the features you can undef the symbols; some of them mean
 ** a significant savings in executable size.
 */
-#define DO_RECEIVED	/* whether to add a "Received:" header */
+/* whether to add a "Received:" header */
+#undef DO_RECEIVED
 #define DO_GETPWUID	/* whether to try a getpwuid() if getlogin() fails */
 #define DO_MINUS_SP	/* whether to implement the -s and -p flags */
 #define DO_DNS		/* whether to do a name lookup on -s, or just IP# */
@@ -122,6 +123,8 @@
 	{
 	if ( strncmp( argv[argn], "-f", 2 ) == 0 && argv[argn][2] != '\0' )
 	    fake_from = &(argv[argn][2]);
+		else if ( strncmp( argv[argn], "-f", 2) == 0)
+           fake_from = &(argv[++argn][0]);
 	else if ( strcmp( argv[argn], "-t" ) == 0 )
 	    parse_message = 1;
 #ifdef DO_MINUS_SP
@@ -145,15 +148,14 @@
 	++argn;
 	}
 
-    username = getlogin();
-    if ( username == (char*) 0 )
-	{
+	if ( fake_from == (char*) 0 ) {
+       username = getlogin();
+       if ( username == (char*) 0 ) {
 #ifdef DO_GETPWUID
 	struct passwd* pw = getpwuid( getuid() );
-	if ( pw == (struct passwd*) 0 )
-	    {
-	    (void) fprintf( stderr, "%s: can't determine username\n", argv0 );
-	    exit( 1 );
+           if ( pw == (struct passwd*) 0 ) {
+               (void) fprintf( stderr, "%s: can't determine username\n", argv0 );
+               exit( 1 );
 	    }
 	username = pw->pw_name;
 #else /* DO_GETPWUID */
@@ -162,16 +164,17 @@
 #endif /* DO_GETPWUID */
 	}
 
-    if ( gethostname( hostname, sizeof(hostname) - 1 ) < 0 )
-	show_error( "gethostname" );
-
-    if ( fake_from == (char*) 0 )
 	(void) snprintf( from, sizeof(from), "%s@%s", username, hostname );
-    else
+  } else {
 	if ( strchr( fake_from, '@' ) == (char*) 0 )
-	    (void) snprintf( from, sizeof(from), "%s@%s", fake_from, hostname );
+		(void) snprintf( from, sizeof(from), "%s@%s", fake_from, hostname );
 	else
 	    (void) snprintf( from, sizeof(from), "%s", fake_from );
+	}
+
+    if ( gethostname( hostname, sizeof(hostname) - 1 ) < 0 )
+       show_error( "gethostname" );
+
 
     /* Strip off any angle brackets in the from address. */
     while ( from[0] == '<' )

comments