-
Notifications
You must be signed in to change notification settings - Fork 96
Getlogin #6775
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
base: 8.4.x
Are you sure you want to change the base?
Getlogin #6775
Conversation
This makes logs consistent for easier parsing
2b00ed1
to
567ddd5
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.
The resolver code is run by the scheduler (i.e. the server) not the client, so this isn't going to extract the user who actioned the operation, you would need to shift this into the Cylc client code (cylc.flow.network.client
).
However, the client cannot be trusted in this situation (because it is being run by a different user), so it is not possible to achieve this (#6773 (comment)).
if user == self.schd.owner: | ||
log_user = "" # don't log user name if owner |
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.
I think this PR is effectively equivalent to:
if user == self.schd.owner: | |
log_user = "" # don't log user name if owner | |
if user == self.schd.owner or not user: | |
user = os.getlogin() |
I.E:
- Log the user name if provided with the request.
- Otherwise log the scheduler owner.
@psa - Oliver's comment above sounds like we're going to shut this PR down, but after discussing it offline he's suggested changes on the issue to make it acceptable.
And (IMO at least) we should document that use of sudo to interact with shared role accounts is common (for many reasons, not just workflows), and if Cylc commands are executed in this way (which Cylc has no control over) then Cylc will log the sudo-user merely as a convenience - strictly speaking this information should not be trusted, but logging the provided information (in the careful way described) does not in any way imply reduced security beyond what you opt into by use of sudo in the first place. For properly secure Cylc-based authorized user attribution, go via the Cylc UI Server (web UI now, hopefully CLI in future too). |
I'm working on re-writing this based on the feedback in #6773 (comment) |
f8f790e
to
892c703
Compare
This passes the discovered CLI user, if available, and adds them with a reference to who it might be. Uses getlogin by default, which grabs the user based on the controlling terminal and if that fails uses getuser which pulls from environment variables. This passed couched in the terms of "possibly on behalf of" as this is data from the client and so is not reliable.
default=CommsMeth.ZMQ.value | ||
) | ||
), | ||
'behalf_of': behalf_of |
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.
Send the full message through using the existing auth_user
field rather than creating a new behalf_of
one.
auth_user = '<actor> (possibly on behalf of <user>)'
That way no changes will be required in cylc/flow/network/resolvers.py
to log this and the feature will be fully backwards compatible.
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.
@oliver-sanders
I've been poking at this but need help from someone with more py-zmq knowledge.
I was expecting self.socket.get(zmq.PLAIN_USERNAME)
in async_request()
to achieve this. I've not found a way to get the username on the client side.
Ideas on how I might approach this?
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.
@psa, ZMQ doesn't come into it, just replace behalf_of
with auth_user
and supply it with the full text:
'behalf_of': behalf_of | |
'auth_user': f'{actor} (possibly on behalf of {user})' |
Where actor
is the actual user account (i.e. $USER
) and user
is the name of the person who is acting via sudo
(i.e. $LOGNAME
).
Drafted after nearly 2 months inactivity |
Ping @psa, let us know if you need any assistance to unstick this PR. |
Thanks @oliver-sanders This has ended up on the backburner due to some personal stuff going on right now. I might not get to it until October . But, I've added a reminder in October to make sure that it doesn't get lost. |
Provide more consistent logging messages so they're easier to parse and log the username from the system if a command isn't being run by the owner or a scheduler user.
Fixes #6773
Check List
CONTRIBUTING.md
and added my name as a Code Contributor.setup.cfg
(andconda-environment.yml
if present).?.?.x
branch.