[LON-CAPA-cvs] cvs: loncom /metadata_database searchcat.pl

www lon-capa-cvs@mail.lon-capa.org
Sat, 04 Jan 2003 19:23:31 -0000


www		Sat Jan  4 14:23:31 2003 EDT

  Modified files:              
    /loncom/metadata_database	searchcat.pl 
  Log:
  According to Scott's suggestion, it is better to check the user ID than
  to allow running as root, and then fix ownerships.
  
  
Index: loncom/metadata_database/searchcat.pl
diff -u loncom/metadata_database/searchcat.pl:1.26 loncom/metadata_database/searchcat.pl:1.27
--- loncom/metadata_database/searchcat.pl:1.26	Sat Jan  4 10:04:12 2003
+++ loncom/metadata_database/searchcat.pl	Sat Jan  4 14:23:31 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # searchcat.pl "Search Catalog" batch script
 #
-# $Id: searchcat.pl,v 1.26 2003/01/04 15:04:12 www Exp $
+# $Id: searchcat.pl,v 1.27 2003/01/04 19:23:31 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -164,6 +164,18 @@
 # ------------------------------------- Only run if machine is a library server
 exit unless $perlvar{'lonRole'} eq 'library';
 
+# ----------------------------- Make sure this process is running from user=www
+
+my $wwwid=getpwnam('www');
+if ($wwwid!=$<) {
+   $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
+   $subj="LON: $perlvar{'lonHostID'} User ID mismatch";
+   system("echo 'User ID mismatch. searchcat.pl must be run as user www.' |\
+ mailto $emailto -s '$subj' > /dev/null");
+   exit 1;
+}
+
+
 # ---------------------------------------------------------- We are in business
 
 open(LOG,'>'.$perlvar{'lonDaemons'}.'/logs/searchcat.log');
@@ -251,7 +263,6 @@
 # -------------------------------------------------- Copy over the new db-files
     system('mv '.$prodir.'/nohist_new_resevaldata.db '.
 	         $prodir.'/nohist_resevaldata.db');
-    system('chown www:www '.$prodir.'/nohist_resevaldata.db');
 }
 # --------------------------------------------------- Close database connection
 $dbh->disconnect;