Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Best and Proper Permissions Settings for Directory Post 302381910 by Dr. DOT on Monday 21st of December 2009 10:57:30 AM
Old 12-21-2009
Best and Proper Permissions Settings for Directory

I am interested in knowing the proper, yet security-conscious settings for a directory. Here's my scenario:

1. I have a username for FTP access to my server called "user".
2. For the purpose of the scenario, PHP runs as "nobody" on my server.
3. I have a directory off the document root called "sample".
4. The "sample" directory is chmod'd at 0755 (drwxr-xr-x)
5. "sample" is owned by "user" and the group is set to "user" so it looks like this:
drwxr-xr-x 2 user user 4096 Dec 21 10:30 sample

The above is all very straight forward and standard.

So I want to have a PHP script be able to create (mkdir) and delete (rmdir) directories under "sample". Yet, I don't want to obviously overly expose my server by opening up the permissions (I could easily chmod sample to 0777 and make it world write-able).

What is the best combination of permissions, owner settings and/or group settings to allow my script to create and delete directories under "sample" while retaining the ability for "user" to continue to FTP into the directory? I also will have a PHP script that creates, updates and deletes files in the directories in "sample" that will need to allow "user" to gain full FTP access to them.

I have tried each of the following in PHP scripts and I continue to get "Operation Not Permitted" errors:
> shell_exec('chmod 0777 newDirectory');
> shell_exec('chmod 0777 newFile');
> shell_exec('chown 0777 newDirectory');
> shell_exec('chown 0777 newFile');
> shell_exec('chgrp 0777 newDirectory');
> shell_exec('chgrp 0777 newFile');
> chmod('newDirectory', 0777);
> ftp_site($conn_id, 'chmod 0777 newDirectory')

Nothing seems to work.

Thanks for helping.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

determine owner directory permissions from within the directory

From within a directory, how do I determine whether I have write permission for it. test -w pwd ; echo ? This doesn't work as it returns false, even though I have write permission. (4 Replies)
Discussion started by: Sniper Pixie
4 Replies

2. UNIX for Dummies Questions & Answers

permissions of a directory

Read and write bits make sense for a directory but what about the execute permission bit What does that imply?Is it just a filler? Saurabh (3 Replies)
Discussion started by: smehra
3 Replies

3. UNIX for Dummies Questions & Answers

Directory Permissions

Hi all. Only one of the following makes any kind of sense as a possible permission field for a UNIX file. Which one? --w------- ----rwxrwx -r-------- --rwx----- ----r----- I think it is no. 3. I dont think it would be 2, because why would you want to give groups and... (1 Reply)
Discussion started by: hawaiifiver
1 Replies

4. UNIX for Dummies Questions & Answers

Linux Server Network Settings - Share Directory Structure

Hello Unix Gurus Who I Hope Reads This, I have quasi-inherited control over a Linux cluster at a university research lab. The post-doc that set it up is gone, and the person in charge of administering the cluster doesn't know a ton about Linux. Amongst other things, I want to use the cluster... (0 Replies)
Discussion started by: mbl
0 Replies

5. Shell Programming and Scripting

unix shell and getting proper directory

I am deploying a shell script in korn shell that will be called from a cronjob. It has to call other scripts in the same directory. However, the directory will change from server to server. The directories are not in my path and I cannot change that. Is there an easy way to set a variable... (4 Replies)
Discussion started by: guessingo
4 Replies

6. Shell Programming and Scripting

Checking directory permissions on UNIX directory

Hi, How do i check if I have read/write/execute rights on a UNIX directory? What I'm doing is checking read access on the files but i also want to check if user has rights on the direcory in whcih these files are present. if then...... And I check if the directory exists by using... (6 Replies)
Discussion started by: chetancrsp18
6 Replies

7. Solaris

Directory Permissions for 2 users on 1 directory

we want to allow user to FTP files into a directory, and then the program (PLSQL) will read and process the file, and then move the file to other directory for archiving. the user id: uftp1, group: ftp the program run in oracle database, thus have the user Id: oraprod, group: dba how to... (2 Replies)
Discussion started by: siakhooi
2 Replies

8. UNIX for Dummies Questions & Answers

Directory permissions

i have an application that writes to a directory. let's call the directory: /var/app/ the permissions of this directory is: drwxrwxr-x Now the files that the application creates in this directory usually dont have read permissions for others. i know there's something called... (3 Replies)
Discussion started by: SkySmart
3 Replies

9. Shell Programming and Scripting

Proper way to use a path with spaces in the directory name

I am using the below bash loop: or f in /media/cmccabe/My Book Western Digital/10_29and30_2015/*.bam ; do bname=`basename $f` pref=${bname%%.bam} samtools view -H $f | sed '/^@PG/d' | samtools reheader - $f > /home/cmccabe/Desktop/NGS/${pref}_newheader.bam done is the... (1 Reply)
Discussion started by: cmccabe
1 Replies
UMASK(3)								 1								  UMASK(3)

umask - Changes the current umask

SYNOPSIS
int umask ([int $mask]) DESCRIPTION
umask(3) sets PHP's umask to $mask & 0777 and returns the old umask. When PHP is being used as a server module, the umask is restored when each request is finished. PARAMETERS
o $mask - The new umask. RETURN VALUES
umask(3) without arguments simply returns the current umask otherwise the old umask is returned. EXAMPLES
Example #1 umask(3) example <?php $old = umask(0); chmod("/path/some_dir/some_file.txt", 0755); umask($old); // Checking if ($old != umask()) { die('An error occurred while changing back the umask'); } ?> NOTES
Note Avoid using this function in multithreaded webservers. It is better to change the file permissions with chmod(3) after creating the file. Using umask(3) can lead to unexpected behavior of concurrently running scripts and the webserver itself because they all use the same umask. PHP Documentation Group UMASK(3)
All times are GMT -4. The time now is 04:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy