LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-22-2004, 01:56 PM   #1
adamwenner
Member
 
Registered: Aug 2003
Distribution: windows xp home, windows 98, red hat 9, fedora core 3, redhat enterprise linux, win2000 pro/server
Posts: 217

Rep: Reputation: 32
permissions for directory tree


hello, i am running some software that will create files at random times (like log files and such) into one directory in htdocs/

the program (run as root on startup) can write the files just fine, but then as nobody (the user apache runs as) a CGI script cannot write to and/or delete these files

easy response #1: run program as nobody, cannot be done becuase that opens up security holes with being able to login to a bash shell with nobody, which is a system account

easy response #2: set SGID on htdocs/ directory, cannot be done because then the default umask is 022, which A: will not allow anyone in the group to write to it and B: it makes new directories under htdocs/, which will not inherit the group owner from htdocs/

easy response #3: change default umask for machine, security risk

easy response #4: set a cron job to chmod 777 htdocs -R, doing that currently, but there has to be a cleaner way to do it

thanks for your help

--adam
 
Old 10-22-2004, 02:46 PM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
What are the original permissions of the files you want to edit/delete?

What is the user / group owning the files to be modified?

What language are you using for your CGI scripts? (perl?)

Permissions of 777 on contents of htdocs (or any other area) is not a good idea!
 
Old 10-22-2004, 09:05 PM   #3
adamwenner
Member
 
Registered: Aug 2003
Distribution: windows xp home, windows 98, red hat 9, fedora core 3, redhat enterprise linux, win2000 pro/server
Posts: 217

Original Poster
Rep: Reputation: 32
the original permissions are 644 and are owned by root by default

the cgi script is a bash script, i guess is the programming language used in it


i know permissions of 777 is a bad idea, but my options were quite limited at the time, thats why im asking the question in the first place

thanks for your help
--adam
 
Old 10-23-2004, 07:39 AM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Check your /etc/passwd and /etc/group files for "apache"

If this account doesn't exist, create it

(as root)
groupadd apache

useradd -g apache -c "Account for Apache" apache

Edit your httpd.conf and change the lines for User and Group to:

User apache
Group apache

Change ownership of the htdocs files to apache:apache

Restart httpd
apachectl restart

Run the program which creates the files as the new user
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help: regarding comparing two directory tree structures raj_thota Linux - Software 2 11-02-2005 12:19 PM
Help: regarding comparing two directory tree structures raj_thota Solaris / OpenSolaris 1 11-02-2005 07:16 AM
Help! How do you delete a directory tree? johnmcollier Linux - Security 0 10-24-2003 02:29 AM
Directory Tree Question GreatMilenko Linux - Security 3 06-02-2002 01:48 PM
Hiding directory tree except for 'home' Will Linux - General 7 11-11-2001 02:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration