-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
cockpit: support setting owner/group in fsreplace1 #21128
base: main
Are you sure you want to change the base?
Conversation
2602089
to
489d3f5
Compare
20ea543
to
8554761
Compare
Only triggered Fedora for now, lets review one round and then run all tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Nice unit tests with the mocking!
doc/protocol.md
Outdated
* `uid`: an integer, the uid of the file owner (`st_uid`) | ||
* `owner`: a string, or an integer, the uid of the file owner (`st_uid`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These conflict. Please document which one wins, or that specifying both is an error. Same for group.
Is there some deeper reason to allow both? AFAIUI, owner
can take an uid, so this feels redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well @allisonkarlitskaya argued that this should take the fsinfo fields so those are uid/gid/owner/group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, fsinfo calls this user
, not owner
.
We also discussed this in a call: we should just implement user
and group
(supporting either strings or ints), not uid
and gid
.
pkg/playground/test.js
Outdated
}) | ||
.catch(exc => { | ||
console.log(exc); | ||
fsreplace_error.textContent = exc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, doesn't this need a .toString()
Otherwise you'll just get some useless "[Object]".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For one instance it worked, but yeah safer to toString()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still no .toString(), reopening.
@@ -257,9 +257,16 @@ declare module 'cockpit' { | |||
remove(): void; | |||
} | |||
|
|||
interface ReplaceAttrs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least mode
should also get added while you're at it. I think. I'm not 100% sure what we should do with this and its interaction with umask...
size
is also in the fsinfo blob. This would be been an interesting alternative to the size-hint attribute we added at the top level. I think maybe the ship has sailed on that one already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but many fields are already not possible from fsinfo so hmm tagging that along seems arbitrary.
Mode does not make sense but I don't want to add it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, we want to use this in files soon (tm) but we ofcourse have no hint that we support this. As passing attrs={} just silently ignores it. But maybe we can read the tag, which I hope is returned by await file.replace("")
.
96db00e
to
2764d3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
doc/protocol.md
Outdated
- `owner`: a string, or an integer, the uid of the file owner (`st_uid`) | ||
- `group`: a string, or an integer, the gid of the file group (`st_gid`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This renders wrong: https://github.com/jelly/cockpit/blob/fsreplace1-chown/doc/protocol.md#payload-fsreplace1
You may have to indent these two a bit more. Please also document that you (currently) have to set both of these.
Also see the outstanding thread to rename owner → user for consistency (I agree to this).
pkg/playground/test.js
Outdated
}) | ||
.catch(exc => { | ||
console.log(exc); | ||
fsreplace_error.textContent = exc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still no .toString(), reopening.
src/cockpit/channels/filesystem.py
Outdated
if owner is None or group is None: | ||
raise ChannelError('protocol-error', message='"owner" or "group" attribute is empty') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that means as soon as you specify any attrs in fsreplace1, you always have to specify user and group. This is fine right now, but we'll have to relax this in the future once we start supporting other attributes. We only need to enforce "neither or both", not "always both".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the logic here would have be if you specify owner you have to specify group and vice-versa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but right now it's not "if", it's "you always have to specify user and group". E.g. you couldn't call file.replace({ mode: 0755 })
(in a future where we support more attributes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I've added this new logic which also gives a better error message.
2764d3e
to
3bedec1
Compare
Cockpit-files wants to support uploading or creating a file owned by the current directory which might be different from the logged in user. For example as superuser uploading a database into `/var/lib/postgresql` which would be owned by `postgres` and the database file should receive the same permissions.
3bedec1
to
98c455f
Compare
.catch(exc => { | ||
fsreplace_error.textContent = exc.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 2 added lines are not executed by any test.
Cockpit-files wants to support uploading or creating a file owned by the current directory which might be different from the logged in user.
For example as superuser uploading a database into
/var/lib/postgresql
which would be owned bypostgres
and the database file should receive the same permissions.