{"id":15658385,"url":"https://github.com/yakdriver/oschmod","last_synced_at":"2025-04-14T00:00:30.781Z","repository":{"id":37863002,"uuid":"254634011","full_name":"YakDriver/oschmod","owner":"YakDriver","description":"chmod for Windows, macOS and Linux","archived":false,"fork":false,"pushed_at":"2023-01-16T10:04:35.000Z","size":195,"stargazers_count":23,"open_issues_count":17,"forks_count":6,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-27T14:11:08.344Z","etag":null,"topics":["chmod","linux","permissions","python","security-tools","stat","windows"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/oschmod/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YakDriver.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-10T12:53:13.000Z","updated_at":"2025-01-11T23:06:10.000Z","dependencies_parsed_at":"2023-02-10T02:31:23.160Z","dependency_job_id":null,"html_url":"https://github.com/YakDriver/oschmod","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YakDriver%2Foschmod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YakDriver%2Foschmod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YakDriver%2Foschmod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YakDriver%2Foschmod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YakDriver","download_url":"https://codeload.github.com/YakDriver/oschmod/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799931,"owners_count":21163403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chmod","linux","permissions","python","security-tools","stat","windows"],"created_at":"2024-10-03T13:12:18.193Z","updated_at":"2025-04-14T00:00:30.747Z","avatar_url":"https://github.com/YakDriver.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp\u003e\n    \u003ca href=\"./LICENSE\" alt=\"License\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/YakDriver/oschmod.svg\" /\u003e\u003c/a\u003e\n    \u003ca href=\"http://travis-ci.org/YakDriver/oschmod\" alt=\"Build status\"\u003e\n        \u003cimg src=\"https://travis-ci.org/YakDriver/oschmod.svg?branch=main\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://pypi.python.org/pypi/oschmod\" alt=\"Python versions\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/pyversions/oschmod.svg\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://pypi.python.org/pypi/oschmod\" alt=\"Version\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/v/oschmod.svg\" /\u003e\u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/YakDriver/oschmod\" alt=\"Mergify\"/\u003e\n\u003c/p\u003e\n\n# oschmod\n\n***oschmod*** sets consistent file permissions across Windows, Linux and macOS.\n\n## oschmod TL;DR\n\n***oschmod*** brings `chmod` functionality to **Windows**, macOS, and Linux! If you're not familiar, `chmod` is a handy macOS and Linux-only tool for setting file permissions. \n\nPrior to ***oschmod***, Windows file permissions couldn't be set in the familiar `chmod` way. Tools did not translate `chmod`-style permissions into Windows-style file permissions. Even though Python's `os.chmod()` sets read, write, and execute file permissions, on Windows, `os.chmod()` basically has no effect. Even worse, Python on Windows gives no warnings or errors. If you think you set file permissions on Windows with `os.chmod()`, you're wrong!\n\n***oschmod*** allows you to set consistent file permissions in a consistent way across platforms.\n\n* Read more about [oschmod](https://medium.com/@dirk.avery/securing-files-on-windows-macos-and-linux-7b2b9899992) on Medium\n* For more background, have a look at the [oschmod Wiki](https://github.com/YakDriver/oschmod/wiki).\n\n## Installation\n\n```console\n$ pip install oschmod\n```\n\n## GNU Documentation\n\n***oschmod*** changes the file mode bits of each given file according to mode, which can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits.\n\nThe format of a symbolic mode is `[ugoa...][+-=][perms...]` where perms is zero or more letters from the set `rwx`. Multiple symbolic modes can be given, separated by commas.\n\nA combination of the letters `ugoa` controls which users' access to the file will be changed: the user who owns it (`u`), other users in the file's group (`g`), other users not in the file's group (`o`), or all users (`a`). If none of these are given, the effect is as if `a` were given.\n\n*(Modified from the GNU manpage for chmod.)*\n\n## Command line interface\n\n***oschmod*** brings the ability to set consistent file permissions using the command line to Windows, macOS, and Linux platforms. If you are familiar with `chmod`, ***oschmod*** works similarly, albeit with fewer options.\n\n```console\n$ oschmod -h\nusage: oschmod [-h] [-R] mode object\n\nChange the mode (permissions) of a file or directory\n\npositional arguments:\n  mode        octal or symbolic mode of the object\n  object      file or directory\n\noptional arguments:\n  -h, --help  show this help message and exit\n  -R          apply mode recursively\n```\n\n## Command line examples\n\nYou can use symbolic (e.g., \"u+rw\") or octal (e.g., \"600) representations of modes. Multiple mode modifications can be made in a single call by separating modifiers with commas.\n\n### Symbolic representation examples\n\nSymbolic representation mode modifiers have three parts:\n    \n1. **whom:** To whom does the modification apply? You can include zero or more of `[ugoa]*` where `a` is for all, `u` is for the file owner (i.e., \"**u**ser\"), `g` is for the file group, and `o` is for others. In other words, `ugo` is equivalent to `a`. Also, if you do not provide a \"whom,\" ***oschmod*** assumes you mean `a` (everyone).\n2. **operation:** Which operation should be applied? You must include one and only one operation, `[+-=]{1}`, per modifier (although you can have multiple modifiers). `+` adds permissions, `-` removes permissions, and `=` sets permissions regardless of previous permissions. `+` and `-` modifications often depend on the current permissions.\n3. **permission:** Which permission or permissions will be affected? You can include zero or more of `[rwx]*` where `r` is for read, `w` is for write, and `x` is for execute. If you do not include a permission with `+` or `-` (e.g., `u-`), the modifier has no effect. However, if you use no permissions with `=` (e.g., `o=`), all permissions are removed.\n\n**Example 1:** To give everyone execute permissions on a file (all of these are equivalent):\n\n```console\n$ oschmod +x \u003cfile name\u003e\n$ oschmod a+x \u003cfile name\u003e\n$ oschmod ugo+x \u003cfile name\u003e\n```\n\n**Example 2:** To remove read, write, and execute permissions from the file group and all others (these are equivalent):\n\n```console\n$ oschmod go-rwx \u003cfile name\u003e\n$ oschmod go= \u003cfile name\u003e\n```\n\n**Example 3:** To give the file owner read and execute permissions, and remove execute permissions from the group and all others:\n\n```console\n$ oschmod u+rx,go-x \u003cfile name\u003e\n```\n\n**Example 4:** To give everyone all permissions, and then remove execute write from the group, and execute from all others:\n\n```console\n$ oschmod a+rwx,g-w,o-x \u003cfile name\u003e\n```\n\n### Octal representation examples\n\nFor more about what octal representations mean, see [this article](https://medium.com/@dirk.avery/securing-files-on-windows-macos-and-linux-7b2b9899992) on Medium.\n\n**Example 5:** To give everyone read, write, and execute permissions on a file:\n\n```console\n$ oschmod 777 \u003cfile name\u003e\n```\n\n**Example 6:** To lock down a file to just give the file owner read, write, and execute permissions and deny all permissions to everyone else:\n\n```console\n$ oschmod 700 \u003cfile name\u003e\n```\n\n## Python usage\n\nYou can use ***oschmod*** from Python code. Any of the command line examples above will work very similarly. For example, *Example 4* above, in Python code, would look like this:\n\n```python\nimport oschmod\noschmod.set_mode(\"myfile\", \"a+rwx,g-w,o-x\")\n```\n\n*Example 5* above, in Python code, could be done in two ways:\n\n```python\nimport oschmod\noschmod.set_mode(\"myfile\", \"777\")\noschmod.set_mode(\"myfile\", 0o777)\n```\n\n***oschmod*** is compatible with bitwise permissions as defined in the `stat` module. To give a file's owner read, write, and execute permissions and deny the group and others any permissions (i.e., equivalent of `700`):\n\n```python\nimport oschmod\nimport stat\noschmod.set_mode('myfile', stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)\n```\n\nReplacing `os.chmod()` with ***oschmod*** should usually be an easy drop-in replacement. Replacement will allow you to get consistent file permission settings on Windows, macOS, and Linux:\n\nIf this is your Python code using `os.chmod()`:\n\n```python\nimport os\nos.chmod('myfile1', 'u+x')\nos.chmod('myfile2', 0o777)\n```\n\nThe replacement using ***oschmod*** is very similar:\n\n```python\nimport oschmod\noschmod.set_mode('myfile1', 'u+x')\noschmod.set_mode('myfile2', 0o777)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyakdriver%2Foschmod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyakdriver%2Foschmod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyakdriver%2Foschmod/lists"}