Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Strange Opendir Problem, does not work for /home directory
jedipi
post Jul 23 2005, 12:02 PM
Post #1


Premium Member
Group Icon

Group: Members
Posts: 352
Joined: 2-March 05
From: Australia
Member No.: 2,859



The following is the content of my test.cgi.
Permission is 777,
CODE

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
$ss="/home";

if (opendir(DIR, $ss)){
  print "open $ss ok\n";
}
else {
  print "fail open $ss !\n";
}



after run this scripte, the result is : fail open /home !

It works if I change the value of $ss from /home to /tmp.

Why does it not work when the value of $ss is /home??
How can I make it work for /home directory??

Please help. Thank you.
Go to the top of the page
 
+Quote Post
Quatrux
post Jul 23 2005, 08:51 PM
Post #2


the Q
Group Icon

Group: [HOSTED]
Posts: 1,124
Joined: 13-July 05
From: Lithuania, Vilnius
Member No.: 7,059
myCENTs:4.06



maybe your home directory permissions are not readable or the dir belongs to root or something ? try to connect to ftp thru php and open the dir, more about it here:

ftp connect

oh darn only now i remember that your script is an cgi/perl script, anyway if you include a php file thru cgi the server will stil parse it.

CODE

<!--#include virtual="/open.php" -->


<!--
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
-->


anyway, i don't know much of this language, maybe you have something native biggrin.gif
Go to the top of the page
 
+Quote Post
jedipi
post Jul 24 2005, 03:22 PM
Post #3


Premium Member
Group Icon

Group: Members
Posts: 352
Joined: 2-March 05
From: Australia
Member No.: 2,859



I did a test on RHEL, but fail.
It is the same problem. /home directory cannot be accessed.
But why??? sad.gif

Even the permission is set to 777. It just does not work.
is it anything to do with the setting of apache???
I did not change any setting of my apache server.
Default setting is used.
Go to the top of the page
 
+Quote Post
qwijibow
post Jul 25 2005, 12:56 PM
Post #4


Way Out Of Control - You need a life :)
Group Icon

Group: Members
Posts: 1,366
Joined: 14-September 04
From: Nottingham England
Member No.: 570



I assume you are using the perl script through a web server, possably apache ???

for securety, apache runs as user "nobody" for securety reasons.
nobody doesnt have a /home and so does not have access.

this prevents a compromised web server getting access to usernames (stored in /home)

nobody DOES have access to /tmp however.

you chould change the access rightas to /home, but i would not recomend this.

just re-think whatever you are trying to accumplish, and re-design it to work more securely.
Go to the top of the page
 
+Quote Post
jedipi
post Jul 26 2005, 03:51 PM
Post #5


Premium Member
Group Icon

Group: Members
Posts: 352
Joined: 2-March 05
From: Australia
Member No.: 2,859



After a few day, the problem was fixed finally.

My friend just tell me to disable SELINUX.
After SELINUX is disable, the test script runs well.

to qwijibow: you are quite right. I should design my script to work more securely.
However, I just started to learn perl about two weeks ago.
I will spend more time on it.

Thanks for your help.
Go to the top of the page
 
+Quote Post
mastercomputers
post Jul 27 2005, 08:40 AM
Post #6


PESTICIDAL MANIAC
Group Icon

Group: Members
Posts: 626
Joined: 1-September 04
From: Auckland, New Zealand
Member No.: 27



I've written a guide on making SELinux co-operate with Apache, it's not really a good idea to disable SELinux so I looked for a method to work with this.

You'll want to look up the "chcon" command (change security context) and you may want to use "ls -Z" to display what you need altered or to show you if it's correct.

chcon -t httpd_sys_content_t -R $HOME/public_html

Say in your /home/UserName/ directory you have a directory called public_html, this command issued above, will make all directories, sub-directories and files all allow access for httpd (apache) to be able use public_html as we specifically made it contain system content that apache is allowed to view.

httpd_sys_exec_script_t should be set on all cgi/perl scripts as well as the cgi-bin directory.

Have a look at This Post for more information and better ways of setting permissions on your directories.

There could be more of these httpd_sys_ prefixed contexts, but the top two are the most common and most likely ones you'll ever need, I've not used any other context than these two on my own personal servers.

This should hopefully get you comfortable with SELinux.


Cheers,


MC
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Help! Problem With My Flash-Drive(2)
  2. Ip Problem(8)
  3. MSN Help(5)
  4. Plasma Effect In Photoshop(7)
  5. ATI Video Card Problem! Need Help(5)
  6. Problem Accessing My Cpanel(9)
  7. Einstein Quiz(30)
  8. Photoshop Cropping Problem(7)
  9. Blue Screen - irql_not_less_or_equal(35)
  10. Spam Problem On My Forums(26)
  11. Frustrating Problem With XP On Laptop(20)
  12. Problem With Drag And Drop (or So It Seems).(12)
  13. Theme Hospital Cheats Don't Work(10)
  14. Comment For My Work(10)
  15. I6networks....does Not Work!(4)
  1. Strange Error When Trying To Install Fedora Core 9(6)
  2. Explorer Does Not Run(9)
  3. Choice Of Motherboard For Linux Virtualization(5)
  4. Problem With Div's In Ie6 And Lower(4)
  5. Type Checking Not Work On For .. In Loop(2)
  6. Undoing The Privacy Option On A Folder In Win Xp Home(3)
  7. Pc Problem(8)
  8. Graphics Driver Out...(2)
  9. Hard To Work With Spyware(5)
  10. Problem Setting Up Wireless Internet & Wireless Nintendo Wii(4)
  11. System Is Crashed - Hardware Problem(3)
  12. Domain Transfers(3)
  13. Non-destructive Recovery Xp-home(3)


 



- Lo-Fi Version Time is now: 2nd December 2008 - 12:31 PM