473,382 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to create symbolic link within a PHP script?

Hi, it seems that I have the following issue when trying to create a
symbolic link within a script:

FROM COMMAND LINE: The owner is set to myself. Thus, it works.

FROM WEB PAGE: It doesn't work as expected.

I know that it runs as one user at the command line and a different
user from the web page. Thus, is it possible to do the following
within the script:

o switch to the correct user
o create the symbolic link
o switch back web page user

BTW, I was using the following command:

exec ( "ln -s " . dirname( SITE_ROOT ) . "/common_directory/* " .
dirname( SITE_ROOT ) . "/new_directory" );

Thanks in advance,

-Conrad

Mar 25 '06 #1
3 7704
It's not possible.
The webserver runs at a specified user that problably is apace.
You cannot access to other user beacuse in ultimate instance is always
apache user that runs the command. If you could login or apache could
change user imagine what hackers would do to webservers. Rub scripts to
figure out the shell's users or even root acess...
If your problem is symbolic link why not use:
http://www.php.net/manual/en/function.symlink.php
?

Regards,
Sjm

Mar 25 '06 #2
sergiojm wrote:
If you could login or apache could change user imagine what hackers
would do to webservers.


Ummm... Apache *can* change users. Google: mod_suexec.

Note: PHP scripts can be run via CGI.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Mar 25 '06 #3
Conrad wrote:
Hi, it seems that I have the following issue when trying to create a
symbolic link within a script:

FROM COMMAND LINE: The owner is set to myself. Thus, it works.

FROM WEB PAGE: It doesn't work as expected.

I know that it runs as one user at the command line and a different
user from the web page. Thus, is it possible to do the following
within the script:

o switch to the correct user
o create the symbolic link
o switch back web page user

BTW, I was using the following command:

exec ( "ln -s " . dirname( SITE_ROOT ) . "/common_directory/* " .
dirname( SITE_ROOT ) . "/new_directory" );

Thanks in advance,

-Conrad


Hi, Conrad,

That depends. If you're running on a shared server, then no, it probably won't
be possible. This will be restricted for security reasons.

If you're running your own server, then you can do it. I wouldn't recommend
doing it in Apache process though, just for security reasons.

What I've done in the past is to create an external script (outside webroot) which:

1. 'su's to the desired user (preferably NOT root!) with posix_setuid()
2. Performs the requested function
3. Returns to the existing user

You will need the setuid bit turned on in the php.ini file. However, I don't
like to do this for the main executable. So rather, I create another executable
with a strange name (so it can't be guessed) and set it's setuid bit on. Then I
specify this "special" executable in the first line of the external script.

It's not great security - but it's some, anyway.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Markus | last post by:
Hello, I'm running on Mac OS X and need to create a soft link to a file. I tried both makealias() and link(). While makealias creates a Finder alias just fine my application that needs to read...
3
by: ozarks | last post by:
I want to setup a database symbolic link within Windows XP to a network drive which has significanlty more space available and can't seem to get it working. Here is my setup.... - I am running...
2
by: JirkaJ | last post by:
Hello, is it possible(and how?) to make a new database in a specified folder - i.e. /home/me/mysqldb? or how may i install mysql on debian to use this folder for data files? thanks j.
22
by: mp | last post by:
i have a python program which attempts to call 'cls' but fails: sh: line 1: cls: command not found i tried creating an alias from cls to clear in .profile, .cshrc, and /etc/profile, but none...
3
by: TK | last post by:
Hi, how can I check wether a file a symbolic link is? Thanks for help. o-o Thomas
4
by: TK | last post by:
Hi, I have to know whether a typical file (under Linux) a symbolic link is (in the sense of the stat()-Funktion). How can I check it excactly? Thanks for help. o-o THomas
1
by: Remote_User | last post by:
Hi All, I am using .NET FW 1.1. Trying to create symbolic link(like in Linux)/file shortcut in the Windows sense across files programmaticaly using C#, could someone give me an idea if this...
1
by: amygrant1701 | last post by:
Hi, I've done this before so I don't see what I could doing wrong here. I'm running mysql 5x on freebsd. I'm using the default data directory of "/var/db/mysql" In there I have several dozen...
11
by: mosscliffe | last post by:
I am trying to create a link to a file, which I can then use in an HTML page. The system is Linux on a hosted web service, running python 2.3. Other than that I have no knowledge of the system....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.