views:

27

answers:

1

Whenever we use chmod, we set different authorities to different users types like

owner, group, others, all

What I dont know is, how do define who is owner, who is group and who are others.

Can we use this while implementing login system? What I mean is, by verifying a username, I want to define if the logged in user is owner, a group or others so that I can deny access to file or folder.

May be my title does not reflect the question, if someone with rep power finds a better title, please edit it?

+3  A: 

Are you trying to use file system permissions to allow or deny access to the files served by php, or to php scripts themselves?

This is not possible. There is always one and only one user who runs apache and php. What that user is called depends on your system: it could be called "apache" or "www" or even "nobody".

When you implement a login system to your website, you are not dealing with this. When you implement a login system, you are doing nothing more than associating a token to the current session. Then according to the token you can change the normal course of the php script (allowing or denying access, display one or another data template, etc...). But, for the operating system, there is absolutely no difference.

You should take a look at some php tutorials about authentication. If you don't want to implement one yourself, this is a viable solution: http://framework.zend.com/manual/en/zend.auth.introduction.html

Palantir
I know the way you are saying. My question actually is While setting a permission like (0700) and 7 is for the owner, who is the owner, can we define an owner personally
Starx
It's the user who physically created the file (the logged in user, or the user that runs the apache or ftp daemons), or another user, if the owner or the root performed a chown command. But in a hosting environment, this is totally irrelevant. The only thing you should be worried for is that apache has access to those files.
Palantir
If you have access to the server, do a ls -l and you'll see the owners and groups. FTP can also show that information (look for file properties, if it's not display straight on).
Palantir