My mistake. I read the patch incorrectly. Thanks regards, Eric
On Wed, Nov 30, 2011 at 10:51 AM, Devaraj Das <[email protected]> wrote: > Eric, I was looking at what I did, and I am not clear on what I missed.. The > umask is restored to the old value at some point after the file creation (and > this was already done; i didn't change that part). > > Could you please clarify? > > On Nov 29, 2011, at 8:50 PM, Eric Yang wrote: > >> It looks like the latest change to FileUtil is changing ambari agent >> process umask after file has been created. The umask should be >> restored to existing umask after the process is done creating the >> files. This prevents untracked umask changes lingering in the system. >> What is the reason to preserve umask change? >> >> regards, >> Eric >> >> ---------- Forwarded message ---------- >> From: <[email protected]> >> Date: Tue, Nov 29, 2011 at 8:22 PM >> Subject: svn commit: r1208264 - in /incubator/ambari/trunk: >> agent/src/main/python/ambari_agent/ >> controller/src/main/java/org/apache/ambari/controller/ >> controller/src/main/java/org/apache/ambari/resource/statemachine/ >> To: [email protected] >> >> >> Author: ddas >> Date: Wed Nov 30 04:22:15 2011 >> New Revision: 1208264 >> >> URL: http://svn.apache.org/viewvc?rev=1208264&view=rev >> Log: >> Follow-up commit to AMBARI-140 >> >> Modified: >> incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py >> URL: >> http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py?rev=1208264&r1=1208263&r2=1208264&view=diff >> ============================================================================== >> --- incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py >> (original) >> +++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py >> Wed Nov 30 04:22:15 2011 >> @@ -36,11 +36,18 @@ def writeFile(action, result): >> oldCwd = os.getcwd() >> fileInfo = action['file'] >> try: >> - path = >> AmbariConfig.config.get('agent','prefix')+"/clusters/"+action['clusterId']+"-"+action['role'] >> + if fileInfo['path'].startswith('/'): >> + path = fileInfo['path'] >> + else: >> + path = >> AmbariConfig.config.get('agent','prefix')+"/clusters/"+action['clusterId']+"-"+action['role'] >> logger.info("path: %s" % path) >> os.chdir(path) >> user=fileInfo['owner'] >> + if user is None: >> + user=getpass.getuser() >> group=fileInfo['group'] >> + if group is None: >> + group=getpass.getgroup() >> filename=fileInfo['path'] >> content=fileInfo['data'] >> try: >> @@ -50,9 +57,15 @@ def writeFile(action, result): >> group=getgrnam(group)[2] >> except Exception: >> logger.warn("can not find user uid/gid: (%s/%s) for writing %s" >> % (user, group, filename)) >> - permission=int(fileInfo['permission']) >> - umask=int(fileInfo['umask']) >> + if fileInfo['permission'] is not None: >> + permission=int(fileInfo['permission'],8) >> + else: >> + permission=0750 >> oldMask = os.umask(0) >> + if fileInfo['umask'] is not None: >> + umask=int(fileInfo['umask']) >> + else: >> + umask=oldMask >> os.umask(int(umask)) >> prefix = os.path.dirname(filename) >> try: >
