473,748 Members | 8,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CRON scripts fail to access group-shared directories

Original thread in
http://www.phpbuilder.com/board/show...1#post10659321

I have CRON scripts with owner/group relationship of "phillip/apache"
that need to access directories within the docroot. The directories,
if I create them, will have owner/group relationship of
"phillip/apache", and all is well since they are all group-accessible
(permissions of 0770).

However, I have a web app within the docroot that has the ability to
spawn folders of its own. These folders will, of course have
owner/group relationship of "apache/apache", and for security purposes
must also have permissions of 0770.

When my CRON scripts accesses the "phillip/apache" folders, all is
well. However, when it access the "apache/apache" folders, I get a PHP
warning "Permission Denied" when trying to access these folders using
this:

[PHP]<? $dirID = opendir($dir); ?>[/PHP]

The original thread I posted has one PHP expert stumped and so far I've
been consistent in stumping everyone else I know, so I'm looking to
break that trend and find someone that can help me figure this out.

Thanx
Phil

Sep 9 '05 #1
6 1781
comp.lang.php wrote:
Original thread in
http://www.phpbuilder.com/board/show...1#post10659321

I have CRON scripts with owner/group relationship of "phillip/apache"
that need to access directories within the docroot. The directories,
if I create them, will have owner/group relationship of
"phillip/apache", and all is well since they are all group-accessible
(permissions of 0770).

However, I have a web app within the docroot that has the ability to
spawn folders of its own. These folders will, of course have
owner/group relationship of "apache/apache", and for security purposes
must also have permissions of 0770.

When my CRON scripts accesses the "phillip/apache" folders, all is
well. However, when it access the "apache/apache" folders, I get a PHP
warning "Permission Denied" when trying to access these folders using
this:

[PHP]<? $dirID = opendir($dir); ?>[/PHP]

The original thread I posted has one PHP expert stumped and so far I've
been consistent in stumping everyone else I know, so I'm looking to
break that trend and find someone that can help me figure this out.

Thanx
Phil


Phil,

The scripts themselves may have an owner/group as phillip/apache - but
what user are they running under?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Sep 9 '05 #2

On 9/9/05 3:30 PM, in article gZ************* *******@comcast .com, "Jerry
Stuckle" <js*******@attg lobal.net> wrote:
Phil,

The scripts themselves may have an owner/group as phillip/apache - but
what user are they running under?


. . . Or more specifically, what "user" is the "cron process" running
under? Crontabs running as root should be OK . . .


Sep 9 '05 #3
Jamie Davison wrote:


On 9/9/05 3:30 PM, in article gZ************* *******@comcast .com, "Jerry
Stuckle" <js*******@attg lobal.net> wrote:

Phil,

The scripts themselves may have an owner/group as phillip/apache - but
what user are they running under?

. . . Or more specifically, what "user" is the "cron process" running
under? Crontabs running as root should be OK . . .



You should never run cron processes under "root" unless they need access
to resources which are restricted to root. It's a huge security hole!

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Sep 9 '05 #4
LeagueWebmaster
6 New Member
On 9/9/05 3:30 PM, in article gZSdnWoBhal-SbzeRVn-qQ@comcast.com, "Jerry
Stuckle" <jstucklex@attg lobal.net> wrote:
[color=blue]
> Phil,
>
> The scripts themselves may have an owner/group as phillip/apache - but
> what user are they running under?[/color]

. . . Or more specifically, what "user" is the "cron process" running
under? Crontabs running as root should be OK . . .
A little help from php in determining file owner and permissions. You created a CRON file so create another entry that runs a php script. Have it go through the same process but report back the Username and GroupName. Remember to try and use the full path to the PHP executable as crontab doesn't run unix profile scripts that might normally add the location of the PHP executable to the envroment path.

;) ie:
* * * * * /usr/bin/php -q /usr/www/myname/mysite/jobs/main.php
[PHP]

// Sample codes for figureing out permissions problems
// where $_tmp_name_ is a string containing the full path to a file
// that is created somewhere else in the PHP Script,
// I'd suggest creating a file in /tmp first as it has more generous permissions
// Note that you normally retrieve the ID's of the groups and names not the
// actual names themselves thus the second function posix_get...
$groupid = filegroup($_tmp _name_);
echo highlight_strin g(print_r( posix_getgrgid( $groupid),true) ,true);

//Some times you need to change the group from in PHP.
//chgrp ( $_tmp_name_, $groupid);

// Returns the user ID of the owner of the file, or FALSE in case of an error.
$userid=fileown er ( $_tmp_name_ );
echo highlight_strin g(print_r(posix _getpwuid($user id),true),true) ;

//Typically changing the userid is a no go as you normally have to have
//the web server running as root.
// chown($_tmp_nam e_, $uid);

[/PHP]
Sep 9 '05 #5
That was it.. the crontab was running under "phillip/phillip" and not
"phillip/apache" due to the fact that "phillip" is "phillip"'s default
user group. If that makes sense.

Phil

Sep 9 '05 #6
LeagueWebmaster
6 New Member
That was it.. the crontab was running under "phillip/phillip" and not
How did you finally determine the actual Group?
Sep 10 '05 #7

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

Similar topics

5
9202
by: deko | last post by:
In regard to running php scripts with cron - Here is a sample script: <?php //debug.php echo "<br> This is a test"; ?> I can call debug.php from a web page on my site like this:
19
5824
by: Eric | last post by:
I'm trying to have some scripts run periodically on Windows XP and found the "Task Scheduler" did not execute my scripts. My scripts are of the form scriptName.py, and will run just by invoking that name in the Command Prompt. Has anyone used the Windows Task Scheduler to run .py scripts, and if so isthere some intracacy to it? Is there a more UNIX version of a cron program one can run on Windows? Has anyone written a simple cron...
0
2562
by: steve | last post by:
I've seen questions about scheduling ASP scripts posted in this group many times so hopefully this will be useful information to a few people. I just wanted to let you all know that our script scheduling service at www.cronservice.co.uk has been rewritten from the ground up and is now better than ever. If you are looking for a way to schedule your ASP scripts and don't have access to cron or task scheduler then you need this service.
2
13349
by: volantecho | last post by:
hi, i m using webmin to create a cron job of a php script. While i click on 'run it now', it works, generate the output. However, the php script doesnt execute for every minutes which i've set to. besides the php scripts, i have other scripts run under cron jobs, such as perl scripts and log files. I couldnt understand why my php scripts doesnt work under cron job.
4
3052
by: vagrantbrad | last post by:
I'm using python 2.4 running on Fedora Core 4. I have written a python program called ipscan.py that checks the external ip address of my cable internet connection, and on change, will update the dns records at my dns provider, zoneedit. So basically, I've setup dynamic dns using python. Once the ip compare and/or update is complete, I log the results to a text file called update.log. When I run the program in a bash shell with the...
2
2743
by: Mark Carter | last post by:
I have some python scripts that run as cron jobs. They connect to external resources (like a newsserver) - for which passwords are required. I currently have them stored in the scripts themselves (ouch!) - and was wondering if there was a more secure solution.
3
3415
by: Pol | last post by:
Can php scripts be initiated as a cron jobs running indefinately in a loop performing a task? Any recommendations for writing a php script that will run as an unix server process that will run indefinitely once it starts? If cron starts it every 10 minutes. How can I check if I my process is running and then end if an instance is already running? Thanks
3
2584
by: dburdick | last post by:
I was referred to this forum as this may be a php specific problem. Some kind of configuration problem maybe. I have some php files that connect to a mysql database and are run as cron jobs. The scripts work fine when run via the command line as root, but when run via the cron they cause a mysql connection error. Call to undefined function: mysql_pconnect()
4
4415
by: J. Frank Parnell | last post by:
Hi there, I have a list of links which point to e.g. thescript.php?album=somePictures1 thescript.php?album=somePictures2 This list is about 3000 links. Each album may have 500 or more pictures in it. the script looks in the specified dir, and creates thumbnails if they are not present. So, displaying a particular album often takes quite a while. I've set the proper php.ini stuff to accomodate the long script_execution's. Thats all
4
3959
by: Phil | last post by:
I have a php script that queries some Oracle DB and outputs a single line of plain text with <brat the end for each query. This is Apache2, php4.4.8 and Oracle Instant Client 10.1.0.5 all on CentOS 4.4 32bit. Php does run as an Apache SO. It works perfectly if I just hit the page in a web-browser (output to browser). It works *perfectly* from the command line (dumps the text to the file per the redirect)
0
9544
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.