Page MenuHomeVyOS Platform

unify the chmod_ function of VyOS
Open, Requires assessmentPublicFEATURE REQUEST

Description

VyOS currently has:

def chmod_600(path):
def chmod_750(path):
def chmod_755(path):

which are setting permissions using stats but it would be simpler to express it in Octal and just have one function:

Taking chmod_750 as example:

> from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP
> bitmask = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP
> oct(bitmask)
'0o750'

so chmod_750(path) could be rewritten using chmod(path, 0o750) with def chmod checking for the folder existance and calling os.chmod with the bitmask passed.

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

To explain the permission for the user/group/world are expressed in octal (3 bits) so 755 is binary for 111 101 101

pasik added a subscriber: pasik.Apr 27 2020, 3:00 PM