Просмотр исходного кода

AMBARI-8940. Ambari overrides user/groups settings configured by cluster admins (aonishuk)

Andrew Onishuk 10 лет назад
Родитель
Сommit
dc097d18d4

+ 10 - 2
ambari-common/src/main/python/resource_management/core/providers/accounts.py

@@ -51,7 +51,12 @@ class UserProvider(Provider):
       command.append("--system")
 
     if self.resource.groups:
-      command += ["-G", ",".join(self.resource.groups)]
+      
+      groups = self.resource.groups
+      if self.user and self.user_groups:
+        groups += self.user_groups
+      
+      command += ["-G", ",".join(groups)]
 
     for option_name, option_flag in options.items():
       option_value = getattr(self.resource, option_name)
@@ -74,7 +79,10 @@ class UserProvider(Provider):
       return pwd.getpwnam(self.resource.username)
     except KeyError:
       return None
-
+    
+  @property
+  def user_groups(self):
+    return [g.gr_name for g in grp.getgrall() if self.resource.username in g.gr_mem]
 
 class GroupProvider(Provider):
   def action_create(self):

+ 1 - 0
ambari-common/src/main/python/resource_management/core/providers/system.py

@@ -244,6 +244,7 @@ class ExecuteProvider(Provider):
   def action_run(self):
     if self.resource.creates:
       if os.path.exists(self.resource.creates):
+        Logger.info("Skipping %s due to creates" % self.resource)
         return
       
     env = self.resource.environment

+ 3 - 0
ambari-common/src/main/python/resource_management/core/resources/accounts.py

@@ -39,6 +39,9 @@ class User(Resource):
   comment = ResourceArgument()
   uid = ResourceArgument()
   gid = ResourceArgument()
+  """
+  If the user exists, and there are some groups, appends to existant
+  """
   groups = ForcedListArgument(default=[]) # supplementary groups
   home = ResourceArgument()
   shell = ResourceArgument()

+ 23 - 1
ambari-common/src/main/python/resource_management/libraries/functions/get_namenode_states.py

@@ -1,3 +1,25 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Ambari Agent
+
+"""
+
 from resource_management.libraries.script import UnknownConfiguration
 
 __all__ = ["get_namenode_states", "get_active_namenode"]
@@ -47,4 +69,4 @@ def get_active_namenode(hdfs_site):
   if active_namenodes:
     return active_namenodes[0]
   else:
-    return UnknownConfiguration('fs_root')
+    return UnknownConfiguration('fs_root')

+ 16 - 0
contrib/fast-hdfs-resource/dependency-reduced-pom.xml

@@ -1,3 +1,19 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>