FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Switch user and drop privileges by joe4dev · Pull Request #13 · localstack/lambda-runtime-init · GitHub

Switch user and drop privileges - #13

Merged
joe4dev merged 8 commits into
localstackfrom
switch-user-and-drop-privileges
Mar 8, 2023
Merged

Switch user and drop privileges#13
joe4dev merged 8 commits into
localstackfrom
switch-user-and-drop-privileges

Conversation

joe4dev commented Mar 7, 2023

Copy link
Copy Markdown
Member

Depends on #12

Switch to sbx_user1051 user for runtime parity and drop root privileges.

Limitations

  • DropPrivileges breaks debugging after syscall. Debugging before the syscall is possible and resuming (at least) a few lines before the syscall works but stepping over the syscall or any breakpoint beyond the syscalls breaks debugging. Hence, we need to disable DropPrivileges for debugging:
    • Manually comment DropPriviledges
    • Introduce an environment variable to conditionally skip DropPriviledges

joe4dev requested a review from dominikschubert March 7, 2023 12:33
joe4dev self-assigned this Mar 7, 2023
joe4dev requested a review from dfangl March 7, 2023 12:48

dominikschubert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Minor nits, otherwise LGTM! 🚀

Comment thread cmd/localstack/user.go Outdated
Comment thread cmd/localstack/user.go Outdated
Comment on lines +83 to +92
func DropPrivileges(userToSwitchTo string) {
// Lookup user and group IDs for the user we want to switch to.
userInfo, err := user.Lookup(userToSwitchTo)
if err != nil {
log.Errorln("Error looking up user:", userToSwitchTo, err)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
func DropPrivileges(userToSwitchTo string) {
// Lookup user and group IDs for the user we want to switch to.
userInfo, err := user.Lookup(userToSwitchTo)
if err != nil {
log.Errorln("Error looking up user:", userToSwitchTo, err)
}
func DropPrivileges(userToSwitchTo string) error {
// Lookup user and group IDs for the user we want to switch to.
userInfo, err := user.Lookup(userToSwitchTo)
if err != nil {
log.Errorln("Error looking up user:", userToSwitchTo, err)
return err
}
...
return nil

This is more of a general feedback for the methods in this file. It would generally be better to "fail" early and bubble up the error when receiving an error we don't plan to recover from.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done for methods without a return value. Should we return a tuple for all methods with return values?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

switched to warn logging for recoverable errors for now

Comment thread cmd/localstack/user.go Outdated
Comment thread cmd/localstack/user.go Outdated
Comment thread cmd/localstack/main.go Outdated

dfangl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Only problem I have is the location of the privilege dropping, which should, in my opinion, be after binding port 53 and extracting the archives.

Comment thread cmd/localstack/main.go

dfangl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM now. We should however merge the other PR first, and might want to rebase this one to the localstack branch.

dfangl force-pushed the switch-user-and-drop-privileges branch from df38614 to 95959e2 Compare March 8, 2023 13:35
joe4dev added 2 commits March 8, 2023 15:14
Using warning level for recoverable warnings rather than breaking errors.

dominikschubert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM 👍

joe4dev merged commit 6fbdf2e into localstack Mar 8, 2023
joe4dev deleted the switch-user-and-drop-privileges branch March 8, 2023 14:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL