works on download script
This commit is contained in:
@@ -24,7 +24,7 @@ int main (int ac, char **av, char ** env)
|
||||
path = get_value("file", rq_body);
|
||||
path = "./www/" + path;
|
||||
|
||||
status = ::eval_file_read(path);
|
||||
status = ::eval_file_access(path, R_OK);
|
||||
if (status)
|
||||
{
|
||||
std::cout << "Status: " << status << CRLF CRLF;
|
||||
|
||||
@@ -181,7 +181,7 @@ void
|
||||
http_body += HTML_BODY_BOTTOM;
|
||||
}
|
||||
|
||||
size_t eval_file_read(const std::string &path)
|
||||
size_t eval_file_access(const std::string &path, int mode)
|
||||
{
|
||||
if (::access(path.c_str(), F_OK) == -1)
|
||||
{
|
||||
@@ -189,7 +189,7 @@ size_t eval_file_read(const std::string &path)
|
||||
return 404; // NOT_FOUND, file doesn't exist
|
||||
}
|
||||
|
||||
if (::access(path.c_str(), R_OK) == -1)
|
||||
if (::access(path.c_str(), mode) == -1)
|
||||
{
|
||||
std::perror("err access()");
|
||||
return 403; // FORBIDDEN, file doesn't have access permission
|
||||
|
||||
@@ -62,7 +62,7 @@ void
|
||||
fill_body_basic(char **env, std::string & http_body, const std::string & rq_body);
|
||||
|
||||
size_t
|
||||
eval_file_read(const std::string &path);
|
||||
eval_file_access(const std::string &path, int mode);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user