Cron Error: USER environment variable is not defined...

Solutions for other advanced phplisters

Cron Error: USER environment variable is not defined...

Postby theloft101 » 11:29pm, Thu 17 May, 2007

in README.commandline it says:

"The normal PHPlist access restrictions are bypassed, but the Unix users who are allowed to run the script should be mentioned in the "commandline_users" config variable. The identity of a user is determined by the USER environment variable, which may not always match your system."

The solution is to uncomment line #137:
#$commandline_users = array();

and thereby work around it. But then you are not verifying the identity of the shell user accessing the script. If you still want the validation to take place, here's a hack to facilitate this:

1. First you will have to determine the key in the array $_SERVER that contains your server login name. Phplist assumes it to be "USER". I found mine was "LOGNAME", not "USER".

2. You can do this with the following PHP code added to [pathtophplist]/admin/index.php on line 64:
print_r($_SERVER); die;
upload the file and then execute it from the commandline. You should see a printout of the server array. Look for the server username and find it's associated key. For me this was "LOGNAME"

3. now delete line 64 which you just added in step 2.

4. just after (line 136) in config.php

# or you can use the following to disable the check (take off the # in front of the line)
#$commandline_users = array();

add the following three lines:

#you may need to change this to something else if your server enviroment uses a $_SERVER key other than USER
#$commandline_user_key="USER";
$commandline_user_key="LOGNAME";

REPLACE LOGNAME WITH THE KEY YOU DISCOVERED IN #2.

5. Finally in /admin/index.php replace all:

$_SERVER["USER"]
with
$_SERVER[$GLOBALS["commandline_user_key"]]

there should be 3 instances.

That should fix it and you now have server user validation back!
theloft101
phpList newbie
 
Posts: 1
Joined: 11:10pm, Thu 17 May, 2007

Postby H2B2 » 1:02am, Sun 20 May, 2007

Thanks! I've included a link to this thread in the docs: http://docs.phplist.com/CommandLineScriptExamples
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Re: Cron Error: USER environment variable is not defined...

Postby ma128376 » 8:29pm, Wed 03 Mar, 2010

Nice post!

Worked for me. After step 3 just add the following line to index.php (line 94 after 'if ($GLOBALS["commandline"]) {' )

Code: Select all
$_SERVER["USER"] = $_SERVER["LOGNAME"];


That should do the trick
ma128376
phpList newbie
 
Posts: 1
Joined: 8:20pm, Wed 03 Mar, 2010

Re: Cron Error: USER environment variable is not defined...

Postby marknitro » 5:04pm, Thu 03 Nov, 2011

Thanks ma128376,

I couldn't get it to work all the way until I saw your post of what to do after step 3.

Cheers,

Mark C Johnson
marknitro
phpList newbie
 
Posts: 1
Joined: 5:01pm, Thu 03 Nov, 2011


Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

cron