--- parser3/src/main/pa_exec.C 2002/03/25 11:36:24 1.31 +++ parser3/src/main/pa_exec.C 2002/03/27 15:30:36 1.34 @@ -4,7 +4,7 @@ Copyright(c) 2000,2001, 2002 ArtLebedev Group(http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: pa_exec.C,v 1.31 2002/03/25 11:36:24 paf Exp $ + $Id: pa_exec.C,v 1.34 2002/03/27 15:30:36 paf Exp $ @todo setrlimit @@ -73,6 +73,7 @@ static BOOL WINAPI CreateHiddenConsolePr // calculating script's directory char dir[MAX_STRING]; strncpy(dir, szCmdLine, MAX_STRING-1); dir[MAX_STRING-1]=0; + lsplit(dir,' '); // trim arguments rsplit(dir,'/'); rsplit(dir,'\\'); // trim filename chdir(dir); @@ -301,19 +302,20 @@ static void append_env_pair(const Hash:: #endif } -int pa_exec(const String& file_spec, +int pa_exec( + bool forced_allow, + const String& file_spec, const Hash *env, const Array *argv, const String& in, String& out, String& err) { Pool& pool=file_spec.pool(); #ifdef NO_PA_EXECS - - throw Exception(0, 0, - &file_spec, - "parser execs are disabled [recompile parser without --disable-execs configure option]"); - -#else + if(!forced_allow) + throw Exception("parser.runtime", + &file_spec, + "parser execs are disabled [recompile parser without --disable-execs configure option]"); +#endif #ifdef WIN32 @@ -358,7 +360,7 @@ from http://www.apache.org/websrc/cvsweb if(error_size>3) // ".\r\n" szErrorDesc[error_size-3]=0; - throw Exception(0, 0, + throw Exception(0, &file_spec, "(real command line=\"%s\") exec failed - %s (%ld)", cmd, @@ -371,19 +373,20 @@ from http://www.apache.org/websrc/cvsweb char *file_spec_cstr=file_spec.cstr(String::UL_FILE_SPEC); #ifdef NO_FOREIGN_GROUP_FILES - struct stat finfo; - if(stat(file_spec_cstr, &finfo)!=0) - throw Exception(0, 0, - &file_spec, - "stat failed: %s (%d), actual filename '%s'", - strerror(errno), errno, file_spec_cstr); - - if(finfo.st_gid/*foreign?*/!=getegid()) - throw Exception(0, 0, - &file_spec, - "parser executing files of foreign group is disabled [recompile parser without --disable-foreign-group-files configure option], actual filename '%s'", - file_spec_cstr); + if(!forced_allow) { + struct stat finfo; + if(stat(file_spec_cstr, &finfo)!=0) + throw Exception("file.missing", + &file_spec, + "stat failed: %s (%d), actual filename '%s'", + strerror(errno), errno, file_spec_cstr); + if(finfo.st_gid/*foreign?*/!=getegid()) + throw Exception("parser.runtime", + &file_spec, + "parser executing files of foreign group is disabled [recompile parser without --disable-foreign-group-files configure option], actual filename '%s'", + file_spec_cstr); + } #endif char *argv_cstrs[1+10+1]={file_spec_cstr, 0}; @@ -391,7 +394,7 @@ from http://www.apache.org/websrc/cvsweb const int argv_size=argv->size(); const int argv_max=sizeof(argv_cstrs)/sizeof(argv_cstrs[0])-1-1; if(argv_size>argv_max) - throw Exception(0, 0, + throw Exception("parser.runtime", &file_spec, "too many arguments (%d > max %d)", argv_size, argv_max); for(int i=0; i