Solved

Web Servers - Directory Permissions

Posted on 1997-05-19
6
207 Views
Last Modified: 2010-04-21
I've got a bit of a dilemna... I am part of a website design
team for a new client, which wants us to setup a membership
system for them.

The membership system allows members to use an online
CGI-driven script to design their homepage. To do this I
setup a users directory where all member accounts will be
stored in, the users have ftponly access to the site. The
users directory and all member subdirectories are now group
owned by the web server group (www) with group write permissions so the CGI scripts can write to their directories.

However, now I find that users can ftp in, change directories to another users directory and also write
to those! Obviously not what I wanted.

Can anyone suggest a way to accomplish the following goals:

1) Allow the web server to write to all subdirectories of
the users directory via CGI.
2) Allow users to ftp into their accounts and have full
read/write access.
3) Prevent users from being able to write to other users
directories.

I would greatly appreciate your suggestions!
Thanks,
Andy
gmd@netmcr.com
0
Comment
Question by:icculus
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
n0thing earned 100 total points
ID: 2006306
Hi,

  The user's home directory should be owned by the user himself.
The permission of the directory should be 2775 drwxrwsr-x, the
group maybe www, but the user should be in other groups else than
www, like wwwuser. This setup will allow:

  1) The owner have the right to write to their own directory and
no one else.
  2) The CGI script's group should be www so it could write to
that directory.

Example:
passwd file: joe:cryptedpasswd:100:200:Joe User:/bin/false
where group 200 would be "wwwuser".
directory's mode should be 2775 drwxrwsr-x joe.www with the SGID
bit on, so any CGI script with the group "www" could write to
that directory but no one else except for the owner himself.
Everyone else could look into that directory and execute CGI
scripts in that directory, but cannot write to it.

Regards,
n0thing
0
 
LVL 1

Author Comment

by:icculus
ID: 2006307
Excelent Answer! Right after receipt I rewrote our membership
system to implement your solution, my tests show it works
exactly as you proposed.

Thank you so much!
Andy
0
 
LVL 1

Author Comment

by:icculus
ID: 2006308
Well,, looks like I spoke a bit too soon...

It looks like the web server can write to files already
present in the directory, however it cannot create
new files...

How would I go about allowing the web server to create
new files in a user's directory?

Thanks much!
andy
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 5

Expert Comment

by:n0thing
ID: 2006309
Any scripts, process which want to write to that directory should
be in the group "www", by default, httpd deamon is own by
nobody.nobody. You'll have to change the group id in the
httpd.conf file to "www" and restart the server.

Regards,
n0thing
0
 
LVL 1

Author Comment

by:icculus
ID: 2006310
The web server is already user www and group www, but
it doesn't belong to the wwuser group, which owns the
directory...

-Andy
0
 
LVL 5

Expert Comment

by:n0thing
ID: 2006311
The user's directory should be joe:www and not joe:wwwuser. If
you set it to joe:wwwuser, then every other users will be able
to write to it and it will defeat the purpose of the SGID bit.
So that way, the owner will be able to write to it, the others
users can't since they belong to the wwwuser but not www. Any
CGI/process with the group ID of www could write to that
directory. Any further questions on the topic, send mail to me
directly minh@qc.bell.ca.

Regards,
Minh Lai
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question