Skip to content

Implement --perms and --chmod - #406

Merged
cgwalters merged 1 commit into
containers:masterfrom
smcv:create-perms
Jun 22, 2021
Merged

cgwalters merged 1 commit into
containers:masterfrom
smcv:create-perms

Conversation

@smcv

@smcv smcv commented Feb 16, 2021

Copy link
Copy Markdown
Collaborator

Based on #405 to avoid conflicts in test-run.sh, but could be separated if maintainers object to #405 for some reason.

@smcv

smcv commented Feb 16, 2021

Copy link
Copy Markdown
Collaborator Author

If accepted, this obsoletes #265. I implemented the syntax suggested on #265, with --perms "sticking" to the next --dir, --tmpfs, etc., rather than setting a default for all subsequent options.

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I gave this one a superficial review and it LGTM. If you prefer it can be merged as is. Will try to do a deeper pass soon.

Comment thread bubblewrap.c Resolved
Comment thread bwrap.xml Resolved
Comment thread bwrap.xml Resolved
@smcv

smcv commented Jun 10, 2021

Copy link
Copy Markdown
Collaborator Author

Changes in today's push:

  • files with g+w or g+x get their parents created g+rx
  • files with o+w or o+x get their parents created o+rx
  • documentation improvements:
    • clarify behaviour of newly-created parents
    • clarify that --perms applies to the next file-creating operation and then is forgotten, with an example

@smcv
smcv requested a review from cgwalters June 10, 2021 09:41
This allows files and directories created programmatically by bubblewrap
to be made less permissive (as requested in containers#346) or more permissive
(as requested in containers#131 and containers#329).

Resolves: containers#131
Resolves: containers#329
Resolves: containers#346
Signed-off-by: Simon McVittie <[email protected]>
@smcv

smcv commented Jun 10, 2021

Copy link
Copy Markdown
Collaborator Author

Rebased to resolve conflict with #409 (see also #420).

bekcpear added a commit to bekcpear/testEbuilds.sh that referenced this pull request Jun 16, 2021
bekcpear added a commit to bekcpear/testEbuilds.sh that referenced this pull request Jun 16, 2021
bekcpear added a commit to bekcpear/testEbuilds.sh that referenced this pull request Jun 16, 2021
Comment thread bubblewrap.c
if (next_perms >= 0)
op->perms = next_perms;
else
op->perms = 0666;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously though, since we weren't calling fchmod() the 0666 permission was modified by umask. Oh I see, but we invoke umask(0) explicitly.

But wait...that means we've been defaulting to making e.g. files world writable by default? That seems...pretty broken? Obviously not related to your PR, and your PR will let us fix it but...ew? May be worth adding something to the docs about this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But wait...that means we've been defaulting to making e.g. files world writable by default?

Yes, for at least --file.

That seems...pretty broken?

I personally think so, but it's what we always did. If you want to change the defaults, that would be an incompatible change, but maybe a worthwhile one.

ew?

Agreed. However, note that #265 was going to realign --file with --bind-data by making --bind-data use mode 0666 (which I didn't like).

May be worth adding something to the docs about this

This branch explicitly documents the defaults in the man page. Previously, you could only find this out by reading the source code or experimenting.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep agreed with all that! I should have been clearer there was no problem with your PR, I just found the default surprising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need option to set permissions on created files/dir /dev/shm has permissions 755 --tmpfs with mode=777

2 participants