School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,148 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,719 people online right now. Registration is fast and FREE... Join Now!




User permissions

 

User permissions

level1

27 Oct, 2009 - 07:32 PM
Post #1

D.I.C Head
**

Joined: 12 Jun, 2008
Posts: 51



Thanked: 9 times
My Contributions
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! wink2.gif

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 :
CODE
mkdir($newFolder)
This has user 'www' as owner. Group read only, Others read only.

CODE
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
CODE
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.gif
----------

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!

User is offlineProfile CardPM
+Quote Post


no2pencil

RE: User Permissions

27 Oct, 2009 - 07:37 PM
Post #2

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,499



Thanked: 303 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
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.
User is online!Profile CardPM
+Quote Post

level1

RE: User Permissions

27 Oct, 2009 - 08:05 PM
Post #3

D.I.C Head
**

Joined: 12 Jun, 2008
Posts: 51



Thanked: 9 times
My Contributions
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!
User is offlineProfile CardPM
+Quote Post

no2pencil

RE: User Permissions

27 Oct, 2009 - 08:10 PM
Post #4

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,499



Thanked: 303 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
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.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:56PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month