-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Add privilege check to render-template script #1728
Conversation
Fyi, the e2e tests are green again on master. |
This reverts commit c50799f.
Automated comment from CodeApprove ➜⏳ @jotaen4tinypilot please review this Pull Request |
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.
Automated comment from CodeApprove ➜
⏳ Approval Pending (2 unresolved comments)
Approval will be granted automatically when all comments are resolved
In: scripts/render-template:
Shall we put a comment here for future reference? I’m thinking, we could just add the link to https://github.com/tiny-pilot/tinypilot-pro/issues/1190.
In: scripts/render-template:
> Line 30
if os.geteuid() == 0:
Question: I’m wondering what the difference is between putting this check here (at file top level) vs. putting it into main
? Intuitively, I might have put it into main
(although it probably also doesn’t matter that much, though).
👀 @jdeanwallace it's your turn please take a look
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.
Automated comment from CodeApprove ➜
In: scripts/render-template:
Oh that's an interesting thought 🤔 Like you said, it probably doesn't matter because the program is always only run as the main program, but then technically it should then be in the main
function. Furthermore, the main
function doesn't deal with parsing args, so perhaps it should rather be within the if __name__ == '__main__'
block where we parse the other (non-existent) args? I went for the latter for now.
In: scripts/render-template:
Ah yes, done.
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.
Automated comment from CodeApprove ➜
Approved: I have approved this change on CodeApprove and all of my comments have been resolved.
Resolves https://github.com/tiny-pilot/tinypilot-pro/issues/1190
Please refer to https://github.com/tiny-pilot/tinypilot-pro/issues/1190#issue-2094765706 for PR rationale.
Executing the
render-template
script with root privileges with now fail. For example, as part of the TinyPilot installation:Notes
We had to expand the previously used
render-template
command into multiple independent commands because the exit code was being ignored/swallowed.To execute
render-template
as thetinypilot
user, we use therunuser
command instead ofsu
. Based on therunuser
manual,runuser
can only be used by root users which is currently the only way we userender-template
: