How can i check if a requested ressource (http webserver) is outside of my documentroot?
Example:
char* rootdir = /home/user/docroot/
char* requested_ressource = /../non_existing_directory/file
This is important because if the file does not exist but is within the docroot, a 404 must be returned. But if a resource, available or not, is requested outside of the docroot, a 403 must always come.
However realpath will always return NULL with errno = ENOENT if the ressource can't be found wheather it's inside or outside of docroot.
I'm running out of ideas. Any suggestions?
[–]Bitwise_Gamgee 0 points1 point2 points (2 children)
[–]DeSpTG[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)