3 Replies - 1209 Views - Last Post: 27 October 2009 - 09:10 PM

#1 level1   User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 65
  • Joined: 12-June 08

User permissions

Posted 27 October 2009 - 08:32 PM

My set up: : I have a Mac running OS 10.4 set up as a server running on the network at the shop where I work. Server only accessed locally (192.168...). Sever is running php 5.2.4 and MySQL. I know just enough php and 0 unix/linux/anything about computers, so feel free to dumb it down for me! ;)

What is happening : I am trying to write a script in php that creates a folder on the server. Later that folder would be accessed by a network user to transfer files into the folder manually. And then even later php would create a backup of the folder and its contents. I can create the folder just fine, but my problem comes down to user permissions. No matter what I try I cannot get the folder to be created through the php script and be writable by the network user. [ I go to 192.168.1.X/create-folder.php, folder gets created, perms don't allow network users write access. ]

What I've tried :
mkdir($newFolder)
This has user 'www' as owner. Group read only, Others read only.

mkdir($newFolder, 0777)
This has user 'www' as owner. Group read only, Others read only too! Got permission denied error but creates folder - seems perms set to 644 (since user creating directory isn't root?)

Logged into server directly, created a folder w/ perms of 777 in hopes that I could copy that folder and rename using
copy($file1, $file2)
And although it copied, the perms got set to 644.

Many minor variations of the above and google, google, google, google. Gettin nowhere :crazy:
----------

After writing this up, I'm guessing that I need to create the folder as root user so the permissions can get set to 777. However, I was never able to get the exec function to work in php, probably because of user permissions, and in my mind even if I did get the exec fn to work I can't sudo because I would be prompted for a password, which the exec fn couldn't get passed.

I'm looking for anything that will change the permissions for me, in any sort of ass-backwards way, so long as it be automatic and immediate (by immediate I mean executed right after the folder is created. I'm not trying to rush you into giving me advice).

I appreciate any advice or suggestions you can give!

Is This A Good Question/Topic? 0
  • +

Replies To: User permissions

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,157
  • Joined: 10-May 07

Re: User permissions

Posted 27 October 2009 - 08:37 PM

If the file is getting copied, can you try throwing chmod() at it, to alter the permissions to the desired 777? <-- this would in your php script, not at the command line.
Was This Post Helpful? 1
  • +
  • -

#3 level1   User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 65
  • Joined: 12-June 08

Re: User permissions

Posted 27 October 2009 - 09:05 PM

Yep, that fixed all my problems. Hahaha. I guess I glossed over that one and went straight to trying chown(), which didn't working. I guess I thought mkdir($dir, 0777) didn't work so why would chmod!? Wow, I feel sheepish and friggin relieved at the same time. Thx No 2!
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6727
  • View blog
  • Posts: 31,157
  • Joined: 10-May 07

Re: User permissions

Posted 27 October 2009 - 09:10 PM

chown() won't work because that only changes the owner. Since www created it, & is changing ownership, this does nothing for the access privileges.

If you need to know what those numbers mean (& might explain why that didn't fix your situation) check this tutorial.

Either way, glad to see that worked for you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1