Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Protecting directories from prying eyes
Should we provide a mechanism in 4.0.4 to protect directories from prying eyes?
Like /files, /images, anything below the /textpattern directory.
I did an experiment and visited Mary’s site, 404’s for prying eyes, I went to Zem’s site, prohibited messages. I searched the FAQ and Textbook, nothing showed up, I could search the forum but a new user probably wouldn’t do this.
If those with experience lock down their sites, should it be part of a release?
We Love TXP . TXP Themes . TXP Tags . TXP Planet . TXP Make
Offline
Re: Protecting directories from prying eyes
i support this idea.
it would be most helpful to have a php-based routine to write into the .htaccess file for instance. i would certainly welcome other approaches to this aswell.
A hole turned upside down is a dome, when there’s also gravity.
Offline
Re: Protecting directories from prying eyes
Those are directories that really do exist, so the display of the directory index normally not handled by Textpattern, but by the webserver itself… Are zem/mary protecting them with .htaccess?
Normally when I want to hide a directory index, I simply upload an empty index.html
Offline
Re: Protecting directories from prying eyes
Put an emty index.html in the directory. Done.
Whether contents of directories are displayed or not is a configuration option of the webserver. I am not sure why duplicating that option in textpattern (which would be restricted to a few directories only anyhow) would be a good idea.
It’s not a matter of security either, since currently all files are downloadable by anyone anyhow.
Offline
Re: Protecting directories from prying eyes
right, sorry, i do that, too… empty index.html i mean. argh, that was too easy…
A hole turned upside down is a dome, when there’s also gravity.
Offline
Re: Protecting directories from prying eyes
Yes, an index.html, like the one in the /update directory that says Nothing here., can be easily replicated. I was just curious why it wasn’t part of the package?
Especially the /files and /images directory, since a user has no clue that someone can just bring up his files directory up in a browser, download all his files and his download count in admin is not updated.
Let’s keep in mind that not all of us are geeks, some people running Textpattern are just plain folks wanting to put up a site and pick Textpattern from Fantastico and have at it.
We Love TXP . TXP Themes . TXP Tags . TXP Planet . TXP Make
Offline
Re: Protecting directories from prying eyes
Having an index.html there doesn’t prevent people from downloading the files directly.
Offline
Re: Protecting directories from prying eyes
ruud wrote:
Having an index.html there doesn’t prevent people from downloading the files directly.
No, but an .htaccess file would.
We Love TXP . TXP Themes . TXP Tags . TXP Planet . TXP Make
Offline
Re: Protecting directories from prying eyes
so that brings us back to what we said above.
uhm. so it would be an interesting feature to be able to protect images and downloads directories from within the admin prefs panel, which would write this preference accordingly into the .htaccess file. or would this be stored in mySQL and read out each time a user accesses a page?
A hole turned upside down is a dome, when there’s also gravity.
Offline
Re: Protecting directories from prying eyes
Visitors have to be able to view the images, so you can’t block access to the images.
Adding an index.html or doing <code>chmod 711</code> on the image directory (if PHP runs under your username) is the most you can do. That last trick works because you don’t need read permission on a directory to be able to access the files inside it, execute permission is enough.
- set the file upload path (advanced TXP prefs) to a location that is outside your webspace (may not work in safe_mode)
- <code>chmod 700</code> the files directory (if PHP runs under your username).
Last edited by ruud (2006-09-29 18:18:30)
Offline
Re: Protecting directories from prying eyes
Thanks ruud, it’s always good to have a healthy debate.
We Love TXP . TXP Themes . TXP Tags . TXP Planet . TXP Make
Offline
Re: Protecting directories from prying eyes
If you want to hide the parts of the /textpattern directory that need not be accessible to outsiders, you could add a .htaccess file like this one in the /textpattern directory (not in the root directory!):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !textpattern(/setup)?/?$
RewriteCond %{REQUEST_FILENAME} !textpattern/((setup/)?index|css)\.php$
RewriteCond %{REQUEST_FILENAME} !textpattern/textpattern\.(css|js)$
RewriteCond %{REQUEST_FILENAME} !textpattern/txp_img/.+\.(jpg|gif|png)$
RewriteRule ^(.*) - [F]
</IfModule>
And if you do this, you may also want to move README.txt and HISTORY.txt into the textpattern directory because they reveal the TXP version number.
Last edited by ruud (2006-10-27 20:50:56)
Offline