--- loncom/loncron 2001/01/10 17:20:44 1.12 +++ loncom/loncron 2001/01/10 17:49:56 1.14 @@ -45,13 +45,6 @@ ENDERROUT # ================================================================ Main Program -# ----------------------------- Make sure this process is running from user=www -my $wwwid=getpwnam('www'); -if ($wwwid!=$<) { - print("User ID mismatch. This program must be run as user 'www'\n") unless $noprint; - exit 1; -} - # ------------------------------------------------------------ Read access.conf { my $config=IO::File->new("/etc/httpd/conf/access.conf"); @@ -64,6 +57,31 @@ if ($wwwid!=$<) { } } +# --------------------------------------- Make sure that LON-CAPA is configured +# I only test for one thing here (lonHostID). This is just a safeguard. +if ('{[[[[lonHostID]]]]}' eq $perlvar{'lonHostID'}) { + print("User ID mismatch. This program must be run as user 'www'\n"); + $emailto=$perlvar{'lonSysEMail'}; + $hostname=`/bin/hostname`; + chop $hostname; + $hostname=~s/[^\w\.]//g; # make sure is safe to pass through shell + $subj="LON: Unconfigured machine $hostname"; + system("echo 'Unconfigured machine $hostname.' |\ + mailto $emailto -s '$subj' > /dev/null"); + exit 1; +} + +# ----------------------------- Make sure this process is running from user=www +my $wwwid=getpwnam('www'); +if ($wwwid!=$<) { + print("User ID mismatch. This program must be run as user 'www'\n"); + $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}"; + $subj="LON: $perlvar{'lonHostID'} User ID mismatch"; + system("echo 'User ID mismatch. loncron must be run as user www.' |\ + mailto $emailto -s '$subj' > /dev/null"); + exit 1; +} + # ------------------------------------------------------------- Read hosts file { my $config=IO::File->new("$perlvar{'lonTabDir'}/hosts.tab");