Jump to content

What exactly happens when I chown a file?


Jen

Recommended Posts

What is man chown?  I'm actually trying to change some file access permissions on a server.  I have a file containing password data that needs to be inaccessible to the general public (and currently is accessible), and I have a file containing other data that needs to be written to periodically by my php script (which I currently can't do because of denied access).
Link to comment
Share on other sites

If you're going to be working with the server much more, I recommend picking up a basic Unix book. [tt]man[/tt] is the [tt]man[/tt]ual command; it is used to look up information on commands. You can even [tt]man man[/tt] to learn about [tt]man[/tt].

If you need to change permissions, you want to use [tt]chmod[/tt], not [tt]chown[/tt]. If the file is within your web root, you can use Apache's File directives to deny access as well.
Link to comment
Share on other sites

'chown' changes who owns the file and what group has rights to that file.
'chmod' changes permission for the file, like the above mentioned.
  chmod ing a file can be good and/or bad.  It gives owner rights, user rights and guest rights.  Kinda like global read/write access to your files.

I went on vacation one week and when I got back someone change my employeer's webfiles to be owned by a non-existant group. Apache didnt like that and freaked out and the website.. well didnt work like it should of ;)

The someones were two coworkers who were trying to 'test' something on a live server :)
Link to comment
Share on other sites

Your reply confuses me.  I'm not using Unix, and the server I speak of is a web server, and I don't think they use Unix either.  I've been trying to set up a little news box on a website, with the ability for the site's owner to use a form to change the news contents.  I have two problems:  firstly, anyone could find the password file on the server and view (and probably change) its contents; secondly, my script doesn't have the access permissions to write to the file containing news data.  Here is my original post concerning this project:  http://www.phpfreaks.com/forums/index.php/topic,103311.0.html
Link to comment
Share on other sites

[quote]Your reply confuses me.  I'm not using Unix, and the server I speak of is a web server, and I don't think they use Unix either.[/quote]

A webserver is just an application like any other running on an operating system. Most commonly php is used with the apache webserver which is most commonly installed on a Unix varient of some sort. eg; Linux or BSD.
Link to comment
Share on other sites

If you are writing directly to a file, you will need the file to be at least a chmod level of 755? even 777 on some setups which means that script (your php file) needs to be fully executable by anyone who writes it as does the file you are editing.

Please someone correct me if I am wrong about the permissions though.

As for storing your passwords in a text file, if you are not using some sort of encryption and storing them in plain text, that's a no no :).  Also keeping the file in a location not accessible via the URL.

Say your website is served via this path on the webserver

[code]
/var/html/www/index.html
[/code]

The webserver would be able to display anything in the /www/ directory.  You would need to put your password file lower in the heriarchy(sp) 
[code]
<?php
//PHP for locating password file (semi-pseudo)

require("../myPasswords.php");
?>
[/code]

The file would be stored in
[code]
/var/
[/code]

So, if a user points their browser to http://www.myplace.com/  they can only get any file that is served out of that /var/html/www directory.  Anything prior to that (like /var or /var/html) will not be able to served by the webserver as easily.

Whew.. hope this makes somewhat sense, my spelling can be horrible at times.
Link to comment
Share on other sites

Ok, Sharkbait, that explains a lot, thanks!  I'm very new to this stuff; never done anything outside of simple html and css before, so I'm just getting my feet wet right now.  Will I have better luck accessing my files if they were stored "lower in the heirarchy," as you say?  Or would I still have my problem with denied access?
Link to comment
Share on other sites

I have more questions.  How do  I manage to encrypt my password files?  Can this be done with a php command while writing to a file?  I encryption still necessary if the password file is stored outsid the www file?  The file heirarchy looks like this:
[code]
apdwbux04/www/customer/www.---.com/htdocs/index.html
[/code]
(where --- is the web url for the site)
Should I put the password in the apdwbux04 file then?  I'm having trouble getting to that file with my ftp client.  When I click to view it, I cannot see the contents, even though I know there should be at least a www folder in there.  Should I be able to view the contents of this folder with my ftp client?  Should I just use a php script to create the files rather than trying to ftp them to that folder?  Is this something I should be contacting the web host about?  Sorry for asking so many questions.
Link to comment
Share on other sites

Can you use a database? If not, and you can't get the file outside of the webroot, I would precede the file's name with a period. In UNIX this indicates a hidden file, which Apache normally hides from indexing. This still would not deny outside access. You could create a folder called "password" and save the file in there as ".htaccess". This would deny the outside world if your host is configured properly; I'm not sure how it would affect Apache though. Also, use md5 to store the information in your password file.

Since I always use a database, I'm not sure if these are the best methods.
Link to comment
Share on other sites

How do I use md5?  Do I need special software or php scripting for it?  I don't know squat about databases, and I don't think it's necessary to store one password and a paragraph worth of news to put on a web page.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.