LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-05-2016, 04:16 PM   #1
fatherjack
LQ Newbie
 
Registered: Apr 2016
Location: Ireland
Distribution: CentOS / Debian
Posts: 6

Rep: Reputation: Disabled
Strange permissions issue with files in Apache.


Hi All.

I'm having issues with directory listings in Apache on a CentOS 6 (x64) box.

The scenario:

I'm logged into the server as root, and am in the /var/www/html/mydir directory.

I've downloaded a file using wget from another server, but the file does not show in a directory listing when viewed from a browser.

The file permissions look to be good, and changing them to 777 does not help, however doing a cp filename newfilename against this file creates an identical copy that IS visible in a directory listing. The file permissions and ownership look identical, and I cannot see any difference between the two files. Am I missing something here?

Thanks.
 
Old 04-06-2016, 02:42 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
The file permissions look to be good, and changing them to 777 does not help, however doing a cp filename newfilename against this file creates an identical copy that IS visible in a directory listing. The file permissions and ownership look identical, and I cannot see any difference between the two files. Am I missing something here?
What happens if you try to GET the file directly, like: http://myhost/mydir/filename
BTW you should use 644 for the files in the webserver and 755 for directories

Last edited by bathory; 04-06-2016 at 02:53 AM.
 
Old 04-06-2016, 08:12 AM   #3
fatherjack
LQ Newbie
 
Registered: Apr 2016
Location: Ireland
Distribution: CentOS / Debian
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hi Bathory

Thanks for the reply.

So if I try a direct on the files, I get a 403 Forbidden (as expected):

You don't have permission to access /mydir/myfile.zip on this server.

Furthermore, I tried a known non-existent file, and received a 404 as I'd expect.

Also, to your point about permissions, 644 is what I have for the files - I gave 777 as an example to show that even the most permissive mode resulted in failure. File permissions are as below:

-rw-r--r--. 1 root root 361482835 Mar 25 12:09 myfile-copy.zip
-rw-r--r--. 1 root root 361482835 Mar 25 12:37 myfile.zip

Also I did an md5sum, and the checksums came up identical.

Thanks.
 
Old 04-06-2016, 08:46 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Doh strange indeed,
Check if there is something that forbids the specific filename in apache config file or in a .htaccess inside /mydir:
Code:
<Files myfile.zip>
Deny from all
</Files>
 
Old 04-06-2016, 11:18 AM   #5
fatherjack
LQ Newbie
 
Registered: Apr 2016
Location: Ireland
Distribution: CentOS / Debian
Posts: 6

Original Poster
Rep: Reputation: Disabled
Yea weird huh?

No luck there either. Also, by moving to an intermediate filename, i.e.:

mv myfile-copy.zip myfile-copy2.zip
mv myfile.zip myfile-copy.zip
mv myfile-copy2.zip myfile.zip

I'm able to make myfile.zip downloadable, and myfile-copy.zip returns 403! Also tried:

ln myfile.zip test.zip

Which creates a hard link to the bad file, and that also returns a 403, so there's something about that file!
 
Old 04-06-2016, 02:29 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Since you're using Centos, it could be SELinux. Try
Code:
restorecon -r /var/www/html
and see how it goes
 
2 members found this post helpful.
Old 04-06-2016, 02:52 PM   #7
fatherjack
LQ Newbie
 
Registered: Apr 2016
Location: Ireland
Distribution: CentOS / Debian
Posts: 6

Original Poster
Rep: Reputation: Disabled
Great, SELinux is was! I ran restorecon against /var/www/html and both the bad file, and the hard link I created appeared in the listing!

Thanks a bunch for your help Bathory, that was driving me nuts for a while there!
 
Old 04-06-2016, 03:17 PM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by fatherjack View Post
Great, SELinux is was! I ran restorecon against /var/www/html and both the bad file, and the hard link I created appeared in the listing!

Thanks a bunch for your help Bathory, that was driving me nuts for a while there!
Glad to see it worked.
You may mark the thread SOLVED from the Thread Tools on top of the page

Cheers
 
Old 04-06-2016, 04:01 PM   #9
fatherjack
LQ Newbie
 
Registered: Apr 2016
Location: Ireland
Distribution: CentOS / Debian
Posts: 6

Original Poster
Rep: Reputation: Disabled
Sure, will do. Thanks again.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SAMBA - strange permissions issue with files copied from a DVD taylorkh Linux - Server 5 12-01-2009 05:55 PM
repost - Apache 2.2.3 on Centos 5 (RHEL5) permissions issue djjoshuad Red Hat 2 04-19-2007 04:47 AM
Strange scp issue while copying files gettons_slack Linux - Software 2 08-26-2006 06:33 AM
need help with a permissions issue reloading bind and apache Pauly Linux - General 1 04-05-2005 05:47 PM
apache failed...strange issue chadi Linux - General 0 12-29-2004 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration