summaryrefslogtreecommitdiff
path: root/pinyweb/suid
diff options
context:
space:
mode:
Diffstat (limited to 'pinyweb/suid')
-rw-r--r--pinyweb/suid/piny-suid.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/pinyweb/suid/piny-suid.c b/pinyweb/suid/piny-suid.c
index 40c497f..badc580 100644
--- a/pinyweb/suid/piny-suid.c
+++ b/pinyweb/suid/piny-suid.c
@@ -1,7 +1,10 @@
+#define _GNU_SOURCE
+
#include <errno.h>
#include <pwd.h>
#include <regex.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <syslog.h>
@@ -107,8 +110,32 @@ int main( int argc, char *argv[] ) {
char buf[sz];
snprintf( buf, sz, "/usr/share/piny-suid/%s", argv[2] );
+ char *path_info;
+ if ( asprintf( &path_info, "PATH_INFO=%s", getenv( "PATH_INFO" ) ) < 0 ) {
+ syslog( LOG_ERR, "Unable to allocate PATH_INFO space." );
+ fprintf( stderr, "Internal error preparing environment.\n" );
+ return 1;
+ };
+
+ char *script_name;
+ if ( asprintf( &script_name, "SCRIPT_NAME=%s", getenv( "SCRIPT_NAME" ) ) < 0 ) {
+ syslog( LOG_ERR, "Unable to allocate SCRIPT_NAME space." );
+ fprintf( stderr, "Internal error preparing environment.\n" );
+ return 1;
+ };
+
+ char *query_string;
+ if ( asprintf( &query_string, "QUERY_STRING=%s", getenv( "QUERY_STRING" ) ) < 0 ) {
+ syslog( LOG_ERR, "Unable to allocate QUERY_STRING space." );
+ fprintf( stderr, "Internal error preparing environment.\n" );
+ return 1;
+ };
+
char * const env[] =
- { NULL
+ { path_info
+ , script_name
+ , query_string
+ , NULL
};
syslog( LOG_NOTICE, "Going to exec '%s' as '%s'", buf, argv[1] );