we can create links (hard links, symbolic links) now
added winix functions: ln winix function 'default' can be used without redirecting now added new tickets types: TypeProgress, TypeString, TypeMultistring, TypeImages, TypeFiles now tickets are combined with files added winix functions: showtickets fixed mountpoints: when the default root mount was created its parameter table was empty and it caused accessing to a non-existing objects fixed logger: modifiers (log1, log2, log3) were incorrectly treated added modifier: log4 (debug info) now we are moving threads to a new plugin 'thread' created directory: plugins/thread (not finished yet) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@704 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
57
core/app.cpp
57
core/app.cpp
@@ -182,7 +182,7 @@ return true;
|
||||
|
||||
void App::ProcessRequestThrow()
|
||||
{
|
||||
ReadRequest();
|
||||
ReadRequest();
|
||||
|
||||
// when BaseUrlRedirect() return true we didn't have to set everything in request.Read()
|
||||
// in the future request.Read() can be split and at the beginning only environment variables will be read
|
||||
@@ -214,15 +214,11 @@ void App::ProcessRequest()
|
||||
log << log2 << config.log_delimiter << logend;
|
||||
|
||||
ProcessRequestThrow();
|
||||
|
||||
SaveSessionsIfNeeded();
|
||||
|
||||
if( request.function )
|
||||
request.function->Clear();
|
||||
SaveSessionsIfNeeded(); // !! przerzucic to na watek sesji
|
||||
|
||||
request.Clear();
|
||||
system.load_avg.StopRequest();
|
||||
log << logsave;
|
||||
log << logendrequest;
|
||||
}
|
||||
catch(const std::exception & e)
|
||||
{
|
||||
@@ -313,20 +309,13 @@ void App::Make()
|
||||
|
||||
// request.status can be changed by function_parser
|
||||
if( request.status == WINIX_ERR_OK )
|
||||
{
|
||||
plugin.Call(WINIX_PREPARE_REQUEST);
|
||||
|
||||
if( system.DirsHaveReadExecPerm() )
|
||||
{
|
||||
if( request.method == Request::post )
|
||||
functions.MakePost();
|
||||
|
||||
if( request.redirect_to.empty() && request.status == WINIX_ERR_OK )
|
||||
functions.MakeGet();
|
||||
}
|
||||
else
|
||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
if( request.status == WINIX_ERR_OK )
|
||||
functions.CheckFunctionAndSymlink();
|
||||
|
||||
if( request.status == WINIX_ERR_OK )
|
||||
functions.MakeFunction();
|
||||
|
||||
if( request.session->spam_score > 0 )
|
||||
log << log1 << "App: spam score: " << request.session->spam_score << logend;
|
||||
@@ -538,17 +527,17 @@ void App::SendHeaders(bool compressing, Header header)
|
||||
if( !request.redirect_to.empty() )
|
||||
{
|
||||
FCGX_PutS("Status: 301 Moved Permanently\r\n", fcgi_request.out);
|
||||
AssignString(request.redirect_to, request.aredirect_to);
|
||||
UrlEncode(request.redirect_to, request.aredirect_to);
|
||||
FCGX_FPrintF(fcgi_request.out, "Location: %s\r\n", request.aredirect_to.c_str());
|
||||
log << log2 << "Redirect to: " << request.redirect_to << logend;
|
||||
log << log2 << "Redirect to: " << request.aredirect_to << logend;
|
||||
}
|
||||
else
|
||||
if( !request.x_sendfile.empty() )
|
||||
{
|
||||
static std::string temp, temp2; // !! wrzucic gdzies to
|
||||
|
||||
AssignString(config.http_header_send_file, temp);
|
||||
AssignString(request.x_sendfile, temp2);
|
||||
Ezc::WideToUTF8(config.http_header_send_file, temp);
|
||||
Ezc::WideToUTF8(request.x_sendfile, temp2);
|
||||
FCGX_FPrintF(fcgi_request.out, "%s: %s\r\n", temp.c_str(), temp2.c_str());
|
||||
|
||||
FCGX_PutS("Status: 200 OK\r\n", fcgi_request.out);
|
||||
@@ -833,7 +822,7 @@ bool App::DropPrivileges(const std::string & user, uid_t uid, gid_t gid, bool ad
|
||||
{
|
||||
if( initgroups(user.c_str(), gid) < 0 )
|
||||
{
|
||||
log << log1 << "App: I can't init groups for user: " << user << logend << logsave;
|
||||
log << log1 << "App: I can't init groups for user: " << user << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -841,7 +830,7 @@ bool App::DropPrivileges(const std::string & user, uid_t uid, gid_t gid, bool ad
|
||||
{
|
||||
if( setgroups(1, &gid) < 0 )
|
||||
{
|
||||
log << log1 << "App: I can't init groups for user: " << user << logend << logsave;
|
||||
log << log1 << "App: I can't init groups for user: " << user << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -849,20 +838,20 @@ bool App::DropPrivileges(const std::string & user, uid_t uid, gid_t gid, bool ad
|
||||
// for setting real and saved gid too
|
||||
if( setgid(gid) )
|
||||
{
|
||||
log << log1 << "App: I can't change real and saved gid" << logend << logsave;
|
||||
log << log1 << "App: I can't change real and saved gid" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( setuid(uid) < 0 )
|
||||
{
|
||||
log << log1 << "App: I can't drop privileges to user: " << user
|
||||
<< " (uid:" << (int)uid << ")" << logend << logsave;
|
||||
<< " (uid:" << (int)uid << ")" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( getuid()==0 || geteuid()==0 )
|
||||
{
|
||||
log << log1 << "App: sorry, for security reasons you should not run me as the root" << logend << logsave;
|
||||
log << log1 << "App: sorry, for security reasons you should not run me as the root" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -880,14 +869,14 @@ bool App::DropPrivileges()
|
||||
if( config.user.empty() )
|
||||
{
|
||||
log << log1 << "App: you should specify user name in the config file "
|
||||
<< "to which I have to drop privileges" << logend << logsave;
|
||||
<< "to which I have to drop privileges" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( config.group.empty() )
|
||||
{
|
||||
log << log1 << "App: you should specify group name in the config file "
|
||||
<< "to which I have to drop privileges" << logend << logsave;
|
||||
<< "to which I have to drop privileges" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -896,13 +885,13 @@ bool App::DropPrivileges()
|
||||
|
||||
if( !p )
|
||||
{
|
||||
log << log1 << "App: there is no such a user as: \"" << config.user << "\"" << logend << logsave;
|
||||
log << log1 << "App: there is no such a user as: \"" << config.user << "\"" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !g )
|
||||
{
|
||||
log << log1 << "App: there is no such a group as: \"" << config.group << "\"" << logend << logsave;
|
||||
log << log1 << "App: there is no such a group as: \"" << config.group << "\"" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -922,7 +911,7 @@ bool App::Demonize()
|
||||
|
||||
if( pid == -1 )
|
||||
{
|
||||
log << log1 << "App: I can't demonize myself (fork problem)" << logend << logsave;
|
||||
log << log1 << "App: I can't demonize myself (fork problem)" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -935,7 +924,7 @@ bool App::Demonize()
|
||||
// child
|
||||
if( setsid() == -1 )
|
||||
{
|
||||
log << log1 << "App: I can't demonize myself (setsid problem)" << logend << logsave;
|
||||
log << log1 << "App: I can't demonize myself (setsid problem)" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user