From a22863604872856437dcb0ccc126f5cea4acef02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Wed, 10 Jun 2009 18:03:22 +0000 Subject: Give proper rights to file when creating since php is run as root and might change permissions in dirs while modifying/creating them. Reported-by: http://forum.pfsense.org/index.php/topic,16890.0.html --- etc/inc/auth.inc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 545c79e..9b82260 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -260,10 +260,13 @@ function local_user_set(& $user) { /* write out ssh authorized key file */ if($user['authorizedkeys']) { - if (!is_dir("{$user_home}/.ssh")) - mkdir("{$user_home}/.ssh", 0700); - $keys = base64_decode($user['authorizedkeys']); - file_put_contents("{$user_home}/.ssh/authorized_keys", $keys); + if (!is_dir("{$user_home}/.ssh")) { + mkdir("{$user_home}/.ssh", 0700); + chown("{$user_home}/.ssh", $user_name); + } + $keys = base64_decode($user['authorizedkeys']); + file_put_contents("{$user_home}/.ssh/authorized_keys", $keys); + chown("{$user_home}/.ssh/authorized_keys", $user_name); } } @@ -898,4 +901,4 @@ function session_auth($backing) { return true; } -?> \ No newline at end of file +?> -- cgit v1.1