wyrie
2010-10-18 4b88c2b95d7e21820adad02317aa0cfee98b29c1
server/plugins-available/shelluser_base_plugin.inc.php
@@ -89,9 +89,15 @@
            $app->log("Executed command: ".$command,LOGLEVEL_DEBUG);
            $app->log("Added shelluser: ".$data['new']['username'],LOGLEVEL_DEBUG);
            
            //* Create .bash_history file
            touch(escapeshellcmd($data['new']['dir']).'/.bash_history');
            chmod(escapeshellcmd($data['new']['dir']).'/.bash_history', 0755);
            chown(escapeshellcmd($data['new']['dir']).'/.bash_history', escapeshellcmd($data['new']['username']));
            chgrp(escapeshellcmd($data['new']['dir']).'/.bash_history', escapeshellcmd($data['new']['pgroup']));
            //* Disable shell user temporarily if we use jailkit
            if($data['new']['chroot'] == 'jailkit') {
               $command = 'usermod -L '.escapeshellcmd($data['new']['username']);
               $command = 'usermod -s /bin/false -L '.escapeshellcmd($data['new']['username']);
               exec($command);
               $app->log("Disabling shelluser temporarily: ".$command,LOGLEVEL_DEBUG);
            }
@@ -100,7 +106,7 @@
            $app->log("UID = $uid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR);
         }
      } else {
         $app->log("Skippung insert of user:".$data['new']['username'].", parent user ".$data['new']['puser']." does not exist.",LOGLEVEL_WARN);
         $app->log("Skipping insertion of user:".$data['new']['username'].", parent user ".$data['new']['puser']." does not exist.",LOGLEVEL_WARN);
      }
   }
   
@@ -128,6 +134,16 @@
               exec($command);
               $app->log("Executed command: $command ",LOGLEVEL_DEBUG);
               $app->log("Updated shelluser: ".$data['old']['username'],LOGLEVEL_DEBUG);
               //* Create .bash_history file
               if(!is_file($data['new']['dir']).'/.bash_history') {
                  touch(escapeshellcmd($data['new']['dir']).'/.bash_history');
                  chmod(escapeshellcmd($data['new']['dir']).'/.bash_history', 0755);
                  chown(escapeshellcmd($data['new']['dir']).'/.bash_history',escapeshellcmd($data['new']['username']));
                  chgrp(escapeshellcmd($data['new']['dir']).'/.bash_history',escapeshellcmd($data['new']['pgroup']));
               }
            } else {
               // The user does not exist, so we insert it now
               $this->insert($event_name,$data);
@@ -136,7 +152,7 @@
            $app->log("UID = $uid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR);
         }
      } else {
         $app->log("Skippung update for user:".$data['new']['username'].", parent user ".$data['new']['puser']." does not exist.",LOGLEVEL_WARN);
         $app->log("Skipping update for user:".$data['new']['username'].", parent user ".$data['new']['puser']." does not exist.",LOGLEVEL_WARN);
      }
   }
   
@@ -172,4 +188,4 @@
} // end class
?>
?>