diff options
author | Julian Blake Kongslie <jblake@omgwallhack.org> | 2011-05-23 21:07:21 -0700 |
---|---|---|
committer | Julian Blake Kongslie <jblake@omgwallhack.org> | 2011-05-23 21:07:21 -0700 |
commit | 8b7f289b40c899a3353ac4df35df021482d97a6c (patch) | |
tree | 9a24d41fd6dea13ddaf577d96a8491fc520af0f5 /pinyweb | |
parent | 5d9b4231e88e9fdb1c04fe9ac69e84b23255e4cd (diff) | |
download | piny-code-8b7f289b40c899a3353ac4df35df021482d97a6c.tar.gz piny-code-8b7f289b40c899a3353ac4df35df021482d97a6c.zip |
Copy some environment variables in piny-suid.
Diffstat (limited to 'pinyweb')
-rw-r--r-- | pinyweb/suid/piny-suid.c | 29 |
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] ); |