Forum Moderators: phranque

Message Too Old, No Replies

cannot delete directory content, suspect .htaccess

         

diddly

4:31 am on May 28, 2014 (gmt 0)

10+ Year Member



Hello,
I created a folder on my website with the intention to store "dotfiles", i.e. files starting with a ".".
I wanted a simple directory listing, no html, but the dotfiles do not display because, I suspect, apache sees them as hidden.
Searching the web indicated that this could be solved with .htaccess.

I have not solved it so far, but now I cannot delete the files in that folder anymore, which is the more pressing issue right now.
looking at the file permissions with ssh and filezilla (sftp), i see no difference to other files that are deletable.
I suspect that the .htaccess file in that folder is causing this (i cannot delete the .htaccess file either, not with filezilla or ssh).

the current .htaccess for that folder looks like this:
IndexOptions +FancyIndexing +SuppressIcon +SuppressRules +ShowForbidden
IndexIgnore *~ *# RCS CVS *,v *,t
IndexStyleSheet "/css/def.css"

(i know, it's probably totally wrong)

fwiw, the directory was first called ".dotfiles" and i renamed it to "dotfiles". inside are, amongst others, a ".config" folder and a .bashrc.

I do not have root or sudo access on the server (Ubuntu with Apache/2.2.16 (Debian) ).
I have succesfully used .htaccess on other directories.

graeme_p

5:24 am on May 28, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you checked both file ownership AND permissions? ls -l when logged in over ssh.

not2easy

5:29 am on May 28, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi diddly and welcome to the Forums. There are settings by default in various places that could cause this issue. Where are you trying to "see" the files, is it via ControlPanel in File Manager, FTP or some other method? Can you view dotfiles (.htaccess) that are in directories or folders on your computer? We'd need a little additional information about the environment to help you determine where to look for the fix.

lucy24

6:20 am on May 28, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



the dotfiles do not display because, I suspect, apache sees them as hidden

I think that's a default setting in the config file, but the syntax is so weird I can't make sense of it :(

:: detour to Apache docs ::

Multiple IndexIgnore directives add to the list, rather than the replacing the list of ignored files.

So it's cumulative rather than replacing any earlier directive. (Query: How, then, do you override earlier settings if you want to include something that was previously excluded?)

You said htaccess. Do you also have access to the config file, or only your own directory?

now I cannot delete the files

Can't see them, or can see them but not delete them?

phranque

9:20 am on May 28, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i would look for something like this <FilesMatch "^\.ht"> container in your server config file that denies access to dotfiles.

this is only going to affect http(s) access.
it won't affect ftp or ssh protocols.
with ftp it could possibly be a setting in the ftp client.
with ssh that's probably going to be a permissions/ownership problem.

diddly

9:07 am on May 29, 2014 (gmt 0)

10+ Year Member



Thank you for the many answers!

atm it looks like the file perimission/ownership issue is unrelated to that .htaccess file.
it looks like a problem i had before on that server. we thought it solved but maybe it came back after an upgrade, i don't know.
i have contacted admin.

answering your questions:
i have checked both ownership and permissions:
me@xxxxxxxxxxxxx:~/webroot$ ll
total 80
drwxrwxr-x 14 www-data www-data 4096 May 29 09:19 ./
drwxrwxrwx 33 www-data www-data 4096 May 26 16:08 ../
-rw-r--r-- 1 www-data www-data 484 May 2 19:58 .htaccess
drwxrwsr-x 2 www-data www-data 4096 Oct 25 2013 adminer/
drwxrwxr-x 5 me users 4096 May 27 19:12 blog/
drwxr-xr-x 3 www-data www-data 4096 May 17 18:01 collection/
drwxrwxr-x 4 www-data www-data 4096 May 28 05:07 custom/
drwxr-xr-x 4 www-data www-data 4096 May 25 15:54 dotfiles/
drwxrwxr-x 2 www-data www-data 4096 Apr 24 19:16 files/
-rw-rw-r-- 1 www-data www-data 11857 May 17 21:40 forums.html
drwxrwxr-x 2 www-data www-data 4096 May 19 22:22 img/
-rw-rw-r-- 1 www-data www-data 1624 May 28 04:59 index.html
drwxrwxr-x 3 www-data www-data 4096 Apr 9 08:00 photos/

the problematic folders are the ones where i am not the owner and do not have group write permission.

the behavior is the same whether i look at or try to delete the files with filezilla or ssh (both on an archlinux baremetal install).

i can see the problematic files and folders ok, both with filezilla or ssh.

is this the apache servers global config: /etc/apache2/apache2.conf
it contains this:
please keep in mind that i can look at the file but not change it.
ServerRoot "/etc/apache2"
LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
TimeOut 300
KeepAlive on
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 1
MaxSpareServers 5
MaxClients 25
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_worker_module>
StartServers 1
MaxClients 25
MinSpareThreads 1
MaxSpareThreads 4
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
User www-data
Group www-data
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
DefaultType text/plain
HostnameLookups On
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
LogLevel warn
LogLevel debug
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
ServerTokens Full
ServerSignature On
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/default
EnableSendfile Off
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.19
PassengerRuby /usr/bin/ruby1.8


it makes sense to hide
.ht*
from clients, but i don't understand how this could affect ALL dotfiles?

phranque

10:32 am on May 29, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



add yourself to the group web-data.
then change permissions so that group members also have write access. (chmod 775)

graeme_p

12:35 pm on May 29, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@phranque, diddly cannot change www-data group membership without root access.

@diddly, if this is on shared hosting you may be able to:

1) fix the issue from a control panel
2) upload a script that will fix it (looks like iterating over all folders and contents adding group write to each will work)
3) ask your host to fix it or tell you how to fix it.

phranque

9:15 pm on May 29, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, diddly!


without sufficient privileges you won't be able to fix the problem with a script, either.

graeme_p

3:26 pm on May 30, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A script can work:

the problematic folders are the ones where i am not the owner and do not have group write permission.


So, if a script runs as www-data (as many scripts do on shared hosting - PHP almost certainly, possibly CGI scripts as well, sometimes even other things) it can chmod the problematic files.

What I cannot understand is why the dotfiles directory is owned by www-data - usually, www-data owns files uploaded through a web interface or created by a script. How did you create it?

diddly

6:50 pm on May 30, 2014 (gmt 0)

10+ Year Member



thanks again.
this servers administrator is a friend. he changed some permissions already and i can delete the files now.
it is, however, noteable that i still have different permissions when creating files with filezilla (sftp?) or ssh terminal:

-rw-r--r-- 1 me www-data 0 May 30 20:04 created-with-filezilla
-rw-rw-r-- 1 me www-data 0 May 30 20:06 created-with-ssh-terminal


he's going to re-install or move the server from ubuntu to debian really soon, so hopefully better luck then.


i did remove the .htaccess file of the folder with the dotfiles and am back to zero now.
the hidden files still don't show.
looking at /etc/apche2/apache.conf from my previous post:
it makes sense to hide .ht* files from clients, but i don't understand how this could affect ALL dotfiles?
and, is it possible to override global settings like these?
from the apache documentation i got the impression that it is possible, but i've been trying most options (see post 1) without success.

not2easy

7:04 pm on May 30, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



IF you have Control Panel, you just click where it says "Show Hidden Files" on opening File Manager.

phranque

11:50 am on May 31, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
...
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/default

i would look in these config include files for additional directives that may explain your server's response.