Bug 52817 - Long directory path sucks (but it's really a valid path!!!)
Summary: Long directory path sucks (but it's really a valid path!!!)
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.4.1
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-03 23:44 UTC by Tianyin Xu
Modified: 2019-08-07 16:07 UTC (History)
2 users (show)



Attachments
Patch to report exactly why ServerRoot isn't identified as a directory (1.12 KB, patch)
2019-08-07 16:06 UTC, William A. Rowe Jr.
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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?