You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2011-05-23 16:28:45

goneri
Member
Registered: 2007-02-20
Posts: 27
Website

chdir and relative path

Hi,

in GLPI 0.80rc3, cron.php use a relative path to the log but a chdir is done before the log file is open. Because of that the logger is not able to record issue.

The patch:

diff --git a/front/cron.php.orig b/front/cron.php
index 1b0e601..696993f 100644
--- a/front/cron.php.orig
+++ b/front/cron.php
@@ -33,13 +33,17 @@
 // Purpose of file:
 // ----------------------------------------------------------------------
 
+// Use canonicalized absolute pathname because we will
+// play with chdir
+define('GLPI_ROOT', realpath('..'));
+include (GLPI_ROOT . "/inc/includes.php");
+
+
+
 // Ensure current directory when run from crontab
 chdir(dirname($_SERVER["SCRIPT_FILENAME"]));
 
 
-define('GLPI_ROOT', '..');
-include (GLPI_ROOT . "/inc/includes.php");
-
 if (!is_writable(GLPI_LOCK_DIR)) {
    echo "\tERROR : " .GLPI_LOCK_DIR. " not writable\n";
    echo "\trun script as 'apache' user\n";

Offline

#2 2011-05-23 16:38:02

remi
GLPI-DEV
From: Champagne
Registered: 2007-04-28
Posts: 7,127
Website

Re: chdir and relative path

I don't see any issue with previous code.

chdir goes to glpi/front, so .. is the right directory.

Your patch will break call from command line (where . is current directory, often, user's home)


Dév. Fedora 29 - PHP 5.6/7.0/7.1/7.2/7.3/7.4 - MariaDB 10.3 - GLPI master
Certifié ITILv3 - RPM pour Fedora, RHEL et CentOS sur https://blog.remirepo.net/

Offline

#3 2011-05-23 18:02:40

goneri
Member
Registered: 2007-02-20
Posts: 27
Website

Re: chdir and relative path

indeed, in can't reproduce the issue. Sorry sad

Cheers

Offline

#4 2011-05-23 20:08:33

JMD
GLPI - Lead
Registered: 2004-09-13
Posts: 9,180
Website

Re: chdir and relative path

I close ...


JMD / Jean-Mathieu Doléans - Glpi-project.org - Association Indepnet
Apportez votre pierre au  projet GLPI   : Soutenir

Offline

Board footer

Powered by FluxBB