浏览代码

[useradmin] Make new user home dir permissions configurable

krish 10 年之前
父节点
当前提交
8dd2e074cf

+ 5 - 0
apps/useradmin/src/useradmin/conf.py

@@ -21,6 +21,11 @@ Configuration options for the "user admin" application
 from desktop.lib.conf import Config, ConfigSection, coerce_bool
 from desktop.lib.conf import Config, ConfigSection, coerce_bool
 from django.utils.translation import ugettext_lazy as _
 from django.utils.translation import ugettext_lazy as _
 
 
+HOME_DIR_PERMISSIONS = Config(
+    key="home_dir_permissions",
+    help=_("New user home directory is created with these permissions"),
+    type=str,
+    default="0755")
 
 
 DEFAULT_USER_GROUP = Config(
 DEFAULT_USER_GROUP = Config(
     key="default_user_group",
     key="default_user_group",

+ 3 - 0
desktop/conf.dist/hue.ini

@@ -1052,6 +1052,9 @@
 ###########################################################################
 ###########################################################################
 
 
 [useradmin]
 [useradmin]
+  # Default home directory permissions
+  ## home_dir_permissions=0755
+
   # The name of the default user group that users will be a member of
   # The name of the default user group that users will be a member of
   ## default_user_group=default
   ## default_user_group=default
 
 

+ 3 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1054,6 +1054,9 @@
 ###########################################################################
 ###########################################################################
 
 
 [useradmin]
 [useradmin]
+  # Default home directory permissions
+  ## home_dir_permissions=0755
+
   # The name of the default user group that users will be a member of
   # The name of the default user group that users will be a member of
   ## default_user_group=default
   ## default_user_group=default
 
 

+ 3 - 1
desktop/libs/hadoop/src/hadoop/fs/hadoopfs.py

@@ -44,6 +44,7 @@ from hadoop.api.common.ttypes import RequestContext, IOException
 import hadoop.conf
 import hadoop.conf
 from hadoop.fs import normpath, SEEK_SET, SEEK_CUR, SEEK_END
 from hadoop.fs import normpath, SEEK_SET, SEEK_CUR, SEEK_END
 from hadoop.fs.exceptions import PermissionDeniedException
 from hadoop.fs.exceptions import PermissionDeniedException
+from useradmin.conf import HOME_DIR_PERMISSIONS
 
 
 
 
 LOG = logging.getLogger(__name__)
 LOG = logging.getLogger(__name__)
@@ -238,13 +239,14 @@ class Hdfs(object):
     if home_path is None:
     if home_path is None:
       home_path = self.get_home_dir()
       home_path = self.get_home_dir()
 
 
+    mode = int(HOME_DIR_PERMISSIONS.get(), 8)
     if not self.exists(home_path):
     if not self.exists(home_path):
       user = self.user
       user = self.user
       try:
       try:
         try:
         try:
           self.setuser(self.superuser)
           self.setuser(self.superuser)
           self.mkdir(home_path)
           self.mkdir(home_path)
-          self.chmod(home_path, 0755)
+          self.chmod(home_path, mode)
           self.chown(home_path, user, user)
           self.chown(home_path, user, user)
         except IOError:
         except IOError:
           msg = 'Failed to create home dir ("%s") as superuser %s' % (home_path, self.superuser)
           msg = 'Failed to create home dir ("%s") as superuser %s' % (home_path, self.superuser)