[LON-CAPA-cvs] cvs: loncom / lond

albertel lon-capa-cvs@mail.lon-capa.org
Sun, 29 Aug 2004 04:12:18 -0000


albertel		Sun Aug 29 00:12:18 2004 EDT

  Modified files:              
    /loncom	lond 
  Log:
  - fixing Rick's du so it works well
  
  
Index: loncom/lond
diff -u loncom/lond:1.244 loncom/lond:1.245
--- loncom/lond:1.244	Sat Aug 28 11:52:51 2004
+++ loncom/lond	Sun Aug 29 00:12:18 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.244 2004/08/28 15:52:51 banghart Exp $
+# $Id: lond,v 1.245 2004/08/29 04:12:18 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -57,7 +57,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.244 $'; #' stupid emacs
+my $VERSION='$Revision: 1.245 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -1302,12 +1302,13 @@
 
 sub du_handler {
     my ($cmd, $ududir, $client) = @_;
-    my $userinput = "$cmd:$ududir";
-    my $duout='';
-    my $du_cmd;
-    $du_cmd = 'du -ks '.$ududir.' 2>/dev/null)';
-    $duout = qx[$du_cmd];
-    print $client "$du_cmd -- $ududir -- $duout\n";
+    if ($ududir=~/\.\./ || $ududir!~m|^/home/httpd/|) {
+	&Failure($client,"refused\n","$cmd:$ududir");
+	return 1;
+    }
+    my $duout = `du -ks $ududir 2>/dev/null`;
+    $duout=~s/[^\d]//g; #preserve only the numbers
+    &Reply($client,"$duout\n","$cmd:$ududir");
     return 1;
 }
 &register_handler("du", \&du_handler, 0, 1, 0);