allow to not change fast cgi socket permissions
New config options: fcgi_set_socket_chmod (bool) - default true fcgi_set_socket_owner (bool) - default true
This commit is contained in:
@@ -184,16 +184,28 @@ void App::InitPlugins()
|
||||
}
|
||||
|
||||
|
||||
bool App::InitFCGI(char * sock, char * sock_user, char * sock_group)
|
||||
bool App::TranslateFCGInames(char * sock, char * sock_user, char * sock_group)
|
||||
{
|
||||
if( !wide_to_utf8(config.fcgi_socket, sock, WINIX_OS_PATH_SIZE) )
|
||||
{
|
||||
log << log1 << "App: I cannot correctly change FastCGI socket path to utf-8 string" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !wide_to_utf8(config.fcgi_socket_user, sock_user, WINIX_OS_USERNAME_SIZE) )
|
||||
return false;
|
||||
if( config.fcgi_set_socket_owner )
|
||||
{
|
||||
if( !wide_to_utf8(config.fcgi_socket_user, sock_user, WINIX_OS_USERNAME_SIZE) )
|
||||
{
|
||||
log << log1 << "App: I cannot correctly change FastCGI user name to utf-8 string" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !wide_to_utf8(config.fcgi_socket_group, sock_group, WINIX_OS_USERNAME_SIZE) )
|
||||
return false;
|
||||
if( !wide_to_utf8(config.fcgi_socket_group, sock_group, WINIX_OS_USERNAME_SIZE) )
|
||||
{
|
||||
log << log1 << "App: I cannot correctly change FastCGI group name to utf-8 string" << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -204,33 +216,39 @@ return true;
|
||||
*/
|
||||
bool App::InitFCGIChmodChownSocket(char * sock, char * sock_user, char * sock_group)
|
||||
{
|
||||
if( chmod(sock, config.fcgi_socket_chmod) < 0 )
|
||||
if( config.fcgi_set_socket_chmod )
|
||||
{
|
||||
log << log1 << "App: I cannot chmod a FastCGI socket, check fcgi_socket_chmod in the config" << logend;
|
||||
return false;
|
||||
if( chmod(sock, config.fcgi_socket_chmod) < 0 )
|
||||
{
|
||||
log << log1 << "App: I cannot chmod a FastCGI socket, check fcgi_socket_chmod in the config" << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
passwd * pw = getpwnam(sock_user);
|
||||
|
||||
if( !pw )
|
||||
if( config.fcgi_set_socket_owner )
|
||||
{
|
||||
log << log1 << "App: there is no a user: " << config.fcgi_socket_user << logend;
|
||||
return false;
|
||||
}
|
||||
passwd * pw = getpwnam(sock_user);
|
||||
|
||||
if( !pw )
|
||||
{
|
||||
log << log1 << "App: there is no a user: " << config.fcgi_socket_user << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
group * gr = getgrnam(sock_group);
|
||||
|
||||
if( !gr )
|
||||
{
|
||||
log << log1 << "App: there is no a group: " << config.fcgi_socket_group << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
group * gr = getgrnam(sock_group);
|
||||
|
||||
if( !gr )
|
||||
{
|
||||
log << log1 << "App: there is no a group: " << config.fcgi_socket_group << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( chown(sock, pw->pw_uid, gr->gr_gid) < 0 )
|
||||
{
|
||||
log << log1 << "App: I cannot chown a FastCGI socket, check fcgi_socket_user "
|
||||
<< "and fcgi_socket_group in the config" << logend;
|
||||
return false;
|
||||
if( chown(sock, pw->pw_uid, gr->gr_gid) < 0 )
|
||||
{
|
||||
log << log1 << "App: I cannot chown a FastCGI socket, check fcgi_socket_user "
|
||||
<< "and fcgi_socket_group in the config" << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -243,7 +261,7 @@ char sock[WINIX_OS_PATH_SIZE];
|
||||
char sock_user[WINIX_OS_USERNAME_SIZE];
|
||||
char sock_group[WINIX_OS_USERNAME_SIZE];
|
||||
|
||||
if( !InitFCGI(sock, sock_user, sock_group) )
|
||||
if( !TranslateFCGInames(sock, sock_user, sock_group) )
|
||||
return false;
|
||||
|
||||
unlink(sock);
|
||||
|
Reference in New Issue
Block a user