Bug 52817

Summary: Long directory path sucks (but it's really a valid path!!!)
Product: Apache httpd-2 Reporter: Tianyin Xu <tixu>
Component: CoreAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: normal CC: aramaswamis, tixu
Priority: P2    
Version: 2.4.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Patch to report exactly why ServerRoot isn't identified as a directory

Description Tianyin Xu 2012-03-03 23:44:40 UTC
Hi, sorry, maybe it's a little bit weird. But I do have a very long directory path (but not that long to exceed the buffer length 16*1024*1024) to put in my configuration file, like 

ServerRoot /very/long/directory/path

Then, the apache tells: 
"httpd: Syntax error on line 33 of /home/tianyin/apache-2.4.1/conf/httpd.conf: ServerRoot must be a valid directory"

But I have to say that it is for sure a valid directory. I can use "cd" to go to that directory. 

When looking at the source code, the problem seems that it uses the "stat" to check the path state and simply check the return value (0 for success, 1 for failure). 

I think it's necessary to check the errno and tell users the exact problem instead of just saying "invalid" (I have to say this bugs me a while), for example: 

EACCES Search permission is denied for one of the directories in the path prefix of path.  (See also path_resolution(7).)

EBADF fd is bad.

EFAULT Bad address.

ELOOP  Too many symbolic links encountered while traversing the path.

ENAMETOOLONG File name too long.

ENOENT A component of path does not exist, or path is an empty string.

ENOMEM Out of memory (i.e., kernel memory).

ENOTDIR A component of the path prefix of path is not a directory.

EOVERFLOW (stat()) path refers to a file whose size cannot be represented in the type off_t.
Comment 1 William A. Rowe Jr. 2019-08-07 16:06:41 UTC
Created attachment 36714 [details]
Patch to report exactly why ServerRoot isn't identified as a directory
Comment 2 William A. Rowe Jr. 2019-08-07 16:07:06 UTC
Hello, thanks for your feedback. Would you take the attached patch for a spin?