Skip to main content

Windows and Linux compatible chmod

Project description

oschmod

Python chmod that works on Windows and Linux

Mergify

Use oschmod to set permissions for files and directories on Windows, Linux and macOS. While Python's standard libraries include a simple command to do this on Linux and macOS (os.chmod()), the same command does not work on Windows.

Usage

The problem is that on Linux and macOS, you can easily set distinct permissions for a file's owner, group, and all others. It takes one command and one mode, or, in other words, a number representing bitwise permissions for reading, writing, and executing. On Linux and macOS, you use the os module and os.chmod().

Misleadingly, on Windows, os.chmod() does not have the same effect and does not give a warning or error. You think you've protected a file but you have not.

For example, on Linux or macOS, to give a file owner read, write, and execute permissions and deny the group and others any permissions (i.e., equivalent of 700), you can make a single call:

import os
import stat
os.chmod('myfile', stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)

Running the same command on Windows does not achieve the same results. The owner isn't given any permissions and the group and others are not denied any permissions. All you can do is restrict anyone from deleting, changing or renaming the file. That's nothing like what os.chmod() does.

However, using oschmod you can use the same command on Windows, macOS or Linux and get the same results:

import oschmod
oschmod.set_mode('myfile', stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)

Installation

$ pip install oschmod

Changelog

0.2.2

Commit Delta: Change from 0.2.0 release

Released: 2020.04.21

Summary:

  • Fix issue with account lookup failing with error (No mapping between account names and security IDs was done.).

0.2.0

Commit Delta: Change from 0.1.5 release

Released: 2020.04.20

Summary:

  • Add recursive version of oschmod.set_mode(): oschmod.set_mode_recursive()

0.1.5

Commit Delta: Change from 0.1.4 release

Released: 2020.04.17

Summary:

  • Create Linux version of permissions test (oschmod.perm_test())

0.1.4

Commit Delta: Change from 0.1.0 release

Released: 2020.04.17

Summary:

  • Revise Windows to keep permissions an object already has for SYSTEM/NT AUTHORITY and don't include those permissions in mode calculation.
  • Fix various minor cosmetic issues.

0.1.0

Commit Delta: Change from 0.0.0 release

Released: 2020.04.15

Summary:

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oschmod-0.2.2.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oschmod-0.2.2-py2.py3-none-any.whl (11.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file oschmod-0.2.2.tar.gz.

File metadata

  • Download URL: oschmod-0.2.2.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.7

File hashes

Hashes for oschmod-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3953fd8c85471289bdd984ad366e26a89a7a9bbd7743019a056af699e72166fa
MD5 38f6c3bbfa49a6b49993d10d2ca455c6
BLAKE2b-256 47a48bd59caaa18f0809b759c6d73b2789e3fbc36f1e5e578663ed7a768ecce7

See more details on using hashes here.

File details

Details for the file oschmod-0.2.2-py2.py3-none-any.whl.

File metadata

  • Download URL: oschmod-0.2.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.7

File hashes

Hashes for oschmod-0.2.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 254ed7132b7e336bcfacfe051266c903e90a4ed48b03724adf834e6977b38bea
MD5 ae6ccad0491d21f66f7f95270b876033
BLAKE2b-256 9ec3263c47306626df7d2c4df3f1307f6558d01044e1c0f4c6c30db14fcfeff2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page