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

Enhance mkdwarfs to support file permission normalization #7

Closed
cipriancraciun opened this issue Nov 29, 2020 · 8 comments
Closed

Enhance mkdwarfs to support file permission normalization #7

cipriancraciun opened this issue Nov 29, 2020 · 8 comments
Assignees
Labels
enhancement New feature or request fixready
Milestone

Comments

@cipriancraciun
Copy link

Just like --no-owner and --no-time are useful to build "generic" images, it would also be useful to have an option that normalizes the file-system permissions. (At the moment they are take verbatim.)

Perhaps the easiest solution is the following:

  • add an option like --perms-norm that basically only cares if any executability bit is set (be it user, group or others), and thus creates entries like r-x r-x r-x or r-- r-- r--;
  • add another option like --perms-umask that takes a octal value and basically caps the permissions; for example --perms-umask 007 would only generate r-x r-x --- or r-- r-- ---;
  • (one could use each option independently of each-other;)
@mhx
Copy link
Owner

mhx commented Nov 29, 2020

The --no-owner and --no-time are actually gone in 0.2.1, they didn't work properly after I overhauled the metadata storage anyway. They've been replaced by --set-owner, --set-group and --set-time, which now also work independently. I think your suggestion would fit in nicely with these.

@mhx mhx added the enhancement New feature or request label Nov 30, 2020
@mhx
Copy link
Owner

mhx commented Dec 5, 2020

Actually, these sorts of things will be possible in the next release using the new transform scripting interface. (I've thrown out Lua scripting in favour of Python as Python is much more approachable for most folks and has much better C++ bindings.)

class mkdwarfs:
    def transform(self, entry):
        logger.debug(f"transforming {entry.path()}")
        entry.set_permissions(entry.permissions() & 0o7555)
        return entry

@cipriancraciun
Copy link
Author

I understand that using an interpreted language opens many possibilities. However I believe that a few common cases should be easily achieved through arguments.

Therefore given how important file permissions are (just like user / group IDs) I think there should be a few options dedicated to them.


For example I would look at how rsync handles this:

  • there are options to set user / group ids (see --chown option);
  • set permissions (see --chmod and --executability options);
  • ignore empty directories, skip non-files;
  • transform symlinks into their referents (thus eliminating the existance of symlinks especially given that you have support for deduplication;)
  • etc.;

@mhx
Copy link
Owner

mhx commented Dec 5, 2020

Oh, I'm not disagreeing. --remove-empty-dirs will already be in the next release, and --chown is essentially --set-owner/--set-group (although I really like the idea of calling it --chown). Dereferencing symlinks is definitely a good idea, too.

@mhx
Copy link
Owner

mhx commented Nov 16, 2022

Okay, after thinking about this some more, I'll implement both --perms-norm as you suggested and --chmod with rsync semantics.

@mhx mhx added this to the v0.7.0 milestone Nov 16, 2022
@mhx mhx self-assigned this Nov 16, 2022
@mhx
Copy link
Owner

mhx commented Nov 17, 2022

I'll probably drop --perms-norm, as you can get the exact same behaviour using --chmod ug-st,=Xr.

mhx added a commit that referenced this issue Nov 17, 2022
@mhx
Copy link
Owner

mhx commented Nov 17, 2022

I've added --chmod support on the wip branch. There's also a special case --chmod=norm that does what --perms-norm was intended to do (by using ug-st,=Xr internally).

@mhx mhx added the fixready label Nov 17, 2022
@mhx
Copy link
Owner

mhx commented Nov 17, 2022

This is in dwarfs-0.7.0-RC2 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixready
Projects
None yet
Development

No branches or pull requests

2 participants