Git Product home page Git Product logo

oschmod's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar mergify[bot] avatar nurelin avatar yakdriver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

oschmod's Issues

Add support for string based mode

Is your feature request related to a problem? Please describe.

Most of the time, when using GNU Coreutils chmod, I use the following syntax

chmod +x script.sh,
chmod go-rwx readonly.txt

But python doesn't have this, sadly ...

Describe the solution you'd like

Let's fork and implement this, and open a pull request ! Would you accept this feature ?

From GNU coreutils chmod --help, it should support this expression

[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+

Describe alternatives you've considered

subprocess.run(["chmod", ...]) but it's not portable.

Additional context

oschmod does not work with pathlib.Path in Windows

Describe the bug

The pathlib works with oschmod on OSX and Linux pathlib.Path, but on Windows, we get TypeError: Objects of type 'WindowsPath' can not be converted to Unicode.

Your configuration

Windows 8.1, Python 3.9.6

Steps to reproduce

Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import oschmod
>>> import pathlib
>>> p = pathlib.Path('E:/Projects/test.txt')
>>> oschmod.get_mode(p)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 163, in get_mode
    return win_get_permissions(path)
  File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 364, in win_get_permissions
    return _win_get_permissions(path, get_object_type(path))
  File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 376, in _win_get_permissions
    sec_des = win32security.GetNamedSecurityInfo(
TypeError: Objects of type 'WindowsPath' can not be converted to Unicode.
>>> oschmod.get_mode('E:/Projects/test.txt')
7

Expected behavior
pathlib.Path works with oschmod operations

What happened instead
pathlib.Path with oschmod operations fails with TypeError

Additional context
Add any other context about the problem here.

Inheritance options ?

Currently, on Windows, oschmod removes/disables inheritance to simplify permissions. However, it might be helpful to add some inheritance capabilities.

Add CLI

If this utility is useful, it could use a CLI. Should be easy to add.

Exception on Windows machines which are members of a domain but not connected to a domain controller

Describe the bug

Calling get_mode on a Windows machine which is a member of a domain but which is disconnected from its domain controller produces an exception from win32security.LookupAccountSid().

Your configuration

Windows 10 x64, Python 3.7, oschmod==0.3.9

Steps to reproduce

oschmod.get_mode(pathname)

What happened

Traceback (most recent call last)
File "...\oschmod\__init__.py", line 163, in get_mode
    return win_get_permissions(path)
File "...\oschmod\__init__.py", line 364, in win_get_permissions
    return _win_get_permissions(path, get_object_type(path))
File "...\oschmod\__init__.py", line 387, in _win_get_permissions
    win32security.LookupAccountSid(None, ace[2]) != \
pywintypes.error: (1789, 'LookupAccountSid', 'The trust relationship between this workstation and the primary domain controller failed.')

Additional context
I'm not an expert in windows security (traceback was retyped from a screenshot of a teamviewer session!) so am not sure if this is even resolvable or oschmod's problem. But apparently being part of a domain, but not connected to a domain controller, is a reasonable scenario for Windows devices.

Deal with "Others"

On Windows, for any permissions set for others, oschmod uses the built-in "Users" group. However, it might be helpful to allow this to be specified by the user and default to "Users" if not.

Add verbose mode

In BSD chmod and probably others, there is a verbose option:

-v      Cause chmod to be verbose, showing filenames as the mode is modified.  If the
-v flag is specified more than once, the old and new modes of the file will also be
printed, in both octal and symbolic notation.

Add ability to add SYSTEM permissions on Windows

Currently, oschmod removes permissions for SYSTEM on Windows. I'm not sure how much this will mess with things but it shouldn't be too hard to add an option to put in a full-privilege ACE for SYSTEM.

conda-forge distribution

It would be nice if there was a conda distribution available from conda-forge.

Pip really is not sufficient for conda users, especially those who might want to publish conda packages that depend on this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.