When creating your own GUI using Apache, you may want to use ElectricCommander ectool commands. The ectool login command fails when executed as Apache under Linux with the following response:
"Login failed. ["Couldn't write session file: Permission denied"]"
ectool login, by default, creates in the user’s Home directory a .ecsession file containing the session ID, or token.
The token is:
- Held on the Commander server
- Expired on the Commander server after:
- 72 hours (3 days) of no use. Using the token resets the timer.
- each server restart
- Stored on the client in a file in a directory that is unique to:
- the OS user - each user has a unique .ecsession file
- the host - can have a different .ecsession file on a different host
- the Commander server - each session to a different Commander server has a different token
The default .ecsession file is located in the user’s space.
- On Windows
- Windows Vista, Windows7, by default, for user “build”: “C:\Users\build\AppData\Local\Electric Cloud\ElectricCommander”
- Windows XP and 2003 by default, for user “build”: “C:\Documents and Settings\build\Local Settings\Application Data\Electric Cloud\ElectricCommander”.
- On Linux, by default, “~/.ecsession”.
The issue is that processes running as “nobody”, such as those started by Apache, do not have write access to their own Home directory.
ectool has a means to override this location by using the environment variable COMMANDER_SESSIONFILE, which can direct ectool to store the session file in a different location.
Use the following code to set an alternate session ID location and check the result of the ectool login command.
$ectool = "/opt/electriccloud/electriccommander/bin/ectool \--server $ecserver "; putenv("COMMANDER_SESSIONFILE=/tmp/tmpsession"); $cmd = "$ectool login admin changeme"; $login_output = system($cmd, $return_code); echo "Login Successful? "; echo " Ouput = $login_output "; echo " Return Code = $return_code ";