You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ambari.apache.org by "Jeffrey Smith (Jira)" <ji...@apache.org> on 2026/08/09 15:17:00 UTC

[jira] [Created] (AMBARI-26622) Inconsistent behaviour between root and non root sudo.py behaviour

Jeffrey Smith created AMBARI-26622:
--------------------------------------

             Summary: Inconsistent behaviour between root and non root sudo.py behaviour
                 Key: AMBARI-26622
                 URL: https://issues.apache.org/jira/browse/AMBARI-26622
             Project: Ambari
          Issue Type: Bug
    Affects Versions: 3.0.0, trunk, 3.1.0
            Reporter: Jeffrey Smith


In sudo.py, the makedir(path, mode) function has different behaviour depending on if Ambari is running as root or not.

The root branch:
{{def makedir(path, mode):}}
{{{}{{    os.mkdir(path)

}}{}}}The non-root branch:{{{}{{
}}{}}}
{{def makedir(path, mode):}}
{{    shell.checked_call(["mkdir", path], sudo=True)}}
{{{}    chmod(path, mode)

{}}}This means that when Ambari is running as root, it is silently dropping the mode option but not doing so when run as any other user. This results in inconsistent behaviour between these two scenarios. 

According to the Python documentation, the default argument for mode is 0o777 if not specified - this could create a situation where a folder is expected to be secure but is not actually since all users might be able to read/write to that directory.

({{{}from the docs: os.{}}}{{{}mkdir{}}}({_}path{_}, {_}mode=0o777{_}, {_}*{_}, {_}dir_fd=None{_}))

This is a simple fix - passing mode to {{os.mkdir(path, mode)}} when Ambari runs as root.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ambari.apache.org
For additional commands, e-mail: issues-help@ambari.apache.org