--- parser3/src/main/pa_common.C 2003/03/21 07:08:28 1.147 +++ parser3/src/main/pa_common.C 2003/05/30 10:45:37 1.151 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_COMMON_C="$Date: 2003/03/21 07:08:28 $"; +static const char* IDENT_COMMON_C="$Date: 2003/05/30 10:45:37 $"; #include "pa_common.h" #include "pa_exception.h" @@ -186,7 +186,7 @@ static int http_request(String& response const char* host, int port, const char* request, int timeout, - bool fail_on_status_ne_200){ + bool fail_on_status_ne_200) { if(!host) throw Exception("http.host", origin_string, @@ -247,7 +247,9 @@ static int http_request(String& response closesocket(sock); /*re*/throw; } +#ifdef PA_USE_ALARM } +#endif } #ifndef DOXYGEN @@ -450,6 +452,23 @@ bool file_read(Pool& pool, const String& return result; } +#ifdef PA_SAFE_MODE +void check_safe_mode(struct stat finfo, const String& file_spec, const char* fname) { + if(finfo.st_uid/*foreign?*/!=geteuid() + && finfo.st_gid/*foreign?*/!=getegid()) + throw Exception("parser.runtime", + &file_spec, + "parser is in safe mode: " + "reading files of foreign group and user disabled " + "[recompile parser with --disable-safe-mode configure option], " + "actual filename '%s', " + "fuid(%d)!=euid(%d) or fgid(%d)!=egid(%d)", + fname, + finfo.st_uid, geteuid(), + finfo.st_gid, getegid()); +} +#endif + bool file_read_action_under_lock(Pool& pool, const String& file_spec, const char* action_name, File_read_action action, void *context, bool as_text, @@ -482,12 +501,7 @@ bool file_read_action_under_lock(Pool& p strerror(errno), errno, fname); #ifdef PA_SAFE_MODE - if(finfo.st_uid/*foreign?*/!=geteuid() - && finfo.st_gid/*foreign?*/!=getegid()) - throw Exception("parser.runtime", - &file_spec, - "parser is in safe mode: reading files of foreign group and user disabled [recompile parser with --disable-safe-mode configure option], actual filename '%s'", - fname); + check_safe_mode(finfo, file_spec, fname); #endif action(pool, finfo, f, file_spec, fname, as_text, context); @@ -961,6 +975,7 @@ int pa_sleep(unsigned long secs, unsigne // attributed meaning +/// http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 static size_t date_attribute(const VDate& vdate, char *buf, size_t buf_size) { const char month_names[12][4]={ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; @@ -973,7 +988,7 @@ static size_t date_attribute(const VDate throw Exception(0, 0, "bad time in attribute value (seconds from epoch=%ld)", when); - return snprintf(buf, MAX_STRING, "%s, %.2d-%s-%.4d %.2d:%.2d:%.2d GMT", + return snprintf(buf, MAX_STRING, "%s, %.2d %s %.4d %.2d:%.2d:%.2d GMT", days[tms->tm_wday], tms->tm_mday,month_names[tms->tm_mon],tms->tm_year+1900, tms->tm_hour,tms->tm_min,tms->tm_sec);