From 05354759ae5feb624c9ded249dabfc7ebf123781 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 02 Jan 2012 13:54:33 -0500
Subject: [PATCH] Fixed: FS#1952 - Folders created by folder protection function belong to the root user
---
server/plugins-available/shelluser_base_plugin.inc.php | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/server/plugins-available/shelluser_base_plugin.inc.php b/server/plugins-available/shelluser_base_plugin.inc.php
index e420293..efde3ab 100755
--- a/server/plugins-available/shelluser_base_plugin.inc.php
+++ b/server/plugins-available/shelluser_base_plugin.inc.php
@@ -234,13 +234,13 @@
if (!file_exists($sshkeys)){
// add root's key
- $app->file->mkdirs($sshdir, '0755');
+ $app->file->mkdirs($sshdir, '0700');
if(is_file('/root/.ssh/authorized_keys')) file_put_contents($sshkeys, file_get_contents('/root/.ssh/authorized_keys'));
// Remove duplicate keys
- $existing_keys = file($sshkeys);
+ $existing_keys = @file($sshkeys);
$new_keys = explode("\n", $userkey);
- $final_keys_arr = array_merge($existing_keys, $new_keys);
+ $final_keys_arr = @array_merge($existing_keys, $new_keys);
$new_final_keys_arr = array();
if(is_array($final_keys_arr) && !empty($final_keys_arr)){
foreach($final_keys_arr as $key => $val){
@@ -273,7 +273,8 @@
$this->app->log("ssh-rsa key updated in ".$sshkeys,LOGLEVEL_DEBUG);
}
// set proper file permissions
- exec("chown -R ".escapeshellcmd($this->data['new']['puser']).":".escapeshellcmd($this->data['new']['pgroup'])." ".$usrdir);
+ // exec("chown -R ".escapeshellcmd($this->data['new']['puser']).":".escapeshellcmd($this->data['new']['pgroup'])." ".$usrdir);
+ exec("chown -R ".escapeshellcmd($this->data['new']['puser']).":".escapeshellcmd($this->data['new']['pgroup'])." ".$sshdir);
exec("chmod 600 '$sshkeys'");
}
--
Gitblit v1.9.1