Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFTP Provider: Fix default folder permissions #26593

Merged
merged 5 commits into from
Oct 25, 2022

Conversation

MatthieuBlais
Copy link
Contributor

Relates #26226

Fixing default mode when creating a directory with paramiko and convert decimal mode to octal mode (paramiko documention)

  • Updating test cases to confirm permissions after masking out the default umask are as we expect whenever we create a new folder.

@boring-cyborg
Copy link

boring-cyborg bot commented Sep 22, 2022

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@uranusjr
Copy link
Member

I don’t think this is a good fix. Instead we should change the default to 0o777.

@MatthieuBlais
Copy link
Contributor Author

MatthieuBlais commented Sep 23, 2022

@uranusjr I can change the default value to 511 which is 0o777 instead. My only concern is that this function mkdir in this class uses decimal value as well. I think it can be confusing if they don't follow the same approach. Is it better to update this function as well?

def mkdir(self, path: str, mode: int = 777) -> None:
        """
        Creates a directory on the remote system.
        :param path: full path to the remote directory to create
        :param mode: permissions to set the directory with
        """
        conn = self.get_conn()
        conn.mkdir(path, mode=int(str(mode), 8))

@MatthieuBlais MatthieuBlais marked this pull request as draft September 23, 2022 07:11
@uranusjr
Copy link
Member

uranusjr commented Sep 28, 2022

Change them both to use octal. Using decimal is a bug in the first place. (We can keep the str case to allow "755" so ease transition.) We can do this in a provider (and bump the major version).

@MatthieuBlais MatthieuBlais force-pushed the sftp_provider_create_directory_mode branch 2 times, most recently from 0d6cc20 to f8041bc Compare October 8, 2022 03:50
@MatthieuBlais MatthieuBlais marked this pull request as ready for review October 9, 2022 06:14
@MatthieuBlais MatthieuBlais force-pushed the sftp_provider_create_directory_mode branch from 86446b8 to f6db51f Compare October 19, 2022 06:01
@MatthieuBlais MatthieuBlais force-pushed the sftp_provider_create_directory_mode branch from f6db51f to bf20f85 Compare October 25, 2022 05:54
@potiuk potiuk merged commit 662a8aa into apache:main Oct 25, 2022
@potiuk
Copy link
Member

potiuk commented Oct 25, 2022

cool !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants