Welcome Guest, Not a member yet? Register   Sign In
mkdir problems
#1

[eluser]Guntars[/eluser]
When I use
Code:
mkdir($dir,0777,true);
$dir is a full path. Directory creates fine, but chmod is 755 and I can't change permissions, always denied, and edit folder via ftp. Looks something wrong somewhere, but I can't find where. Any Ideas?
#2

[eluser]bretticus[/eluser]
Remember your web server *typically* runs as a different user and your root folder my be owned by your user account for shell/ftp access. If that is the case, you need to chown (give ownership) of the root folder (in which these folders you make via php reside) to the web server user.
#3

[eluser]umefarooq[/eluser]
you have to check who is owner of this folder, if it is Linux OS, while creating folder owner is missing because you can not change the permissions of the folder from ftp also, you check in ftp who's the owner of that folder
#4

[eluser]Guntars[/eluser]
I know abourt that, but why when creates directory, it's change permisions from 777 to 755. I have debian linux. Somewhere seems umask. But where, usualy I can change umask in apache PHP?
#5

[eluser]jedd[/eluser]
[quote author="Guntars" date="1245713356"]I know abourt that, but why when creates directory, it's change permisions from 777 to 755. I have debian linux.[/quote]

Good man (or woman). Up until this point I was disinclined to help, since google would answer this faster than I could hit reply ....

Quote:Somewhere seems umask. But where, usualy I can change umask in apache PHP?

You need to play with the umask command, specifically modifying the /etc/apache2/envvars file. Probably something like:
Code:
umask 000
.. assuming you want 777 at the other end.

Of course, you probably do not want 777 permissions on your files, as this is relatively (read hugely) insecure.

With Debian, apache runs as uid: www-data and gid: www-data

Caveat here - this is out of the box, but you can configure your apache to run scripts as a given user, and some hosting sites (my system at Uni for example) do this. The best way to check is to exec("touch /tmp/bob") or similar and then investigate that file.

Now, if you can't change the perms from within apache/php on a file that you just created, then that is quite odd. You (apache) may need to own the parent directory of that file, and/or change permissions of same.

Given the nature of the questions you're asking, my suspicion is that you're doing (or are about to do) something quite dangerous. You may want to elucidate on what you're trying to create, and where in the file system - as there are probably cleaner ways of doing this.
#6

[eluser]Guntars[/eluser]
Thanks for fast reply, just, I want t know, what's happen. And when I create permissions to 777 I wan't to know why it's change to 755, that's never happens on other servers.
#7

[eluser]Guntars[/eluser]
It works, thanks, I know 777 not a good for security, which one you recomend for file upload?
#8

[eluser]jedd[/eluser]
If you are setting perms to 777 and they're reverting to 755 - I do not know. Are you sure they're set to 777 at all, ever, or are you checking the return value of the call to make them 777, and how are you trying to set them to 777 in the first place?

Part of your problem might be the parent directory permissions, but that might affect inheritance, but should not force changes back from what you've set file perms to.

Why other systems behave differently - probably because Debian is a bit more secure out of the box than most other distros, and certainly than most other OS's.

For security, if the (web) server is running as www-data, then you should be fine to have 770 on an upload directory, I'd have thought - though I've not done file uploads in PHP before, there's no reason it should behave any differently than any other file creation activity.
#9

[eluser]Guntars[/eluser]
I was put umask 000 in /etc/apache2/envvars file, retart apache. Now works great, I can create any directories with permisions, which one I want.

Now I use perms 755 for upload. Main my woried was if I need permisions 777 I want if they are 777, not 755.

Great Help, Thank You very much.
I was yesterday spent lot of hours in google and not get the right answer, you give me in a minutes.




Theme © iAndrew 2016 - Forum software by © MyBB