-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1035 from QiWang19/sigstore
Set default rootless sigstore
- Loading branch information
Showing
8 changed files
with
117 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package rootless | ||
|
||
import ( | ||
"os" | ||
"strconv" | ||
) | ||
|
||
// GetRootlessEUID returns the UID of the current user (in the parent userNS, if any) | ||
// | ||
// Podman and similar software, in “rootless” configuration, when run as a non-root | ||
// user, very early switches to a user namespace, where Geteuid() == 0 (but does not | ||
// switch to a limited mount namespace); so, code relying on Geteuid() would use | ||
// system-wide paths in e.g. /var, when the user is actually not privileged to write to | ||
// them, and expects state to be stored in the home directory. | ||
// | ||
// If Podman is setting up such a user namespace, it records the original UID in an | ||
// environment variable, allowing us to make choices based on the actual user’s identity. | ||
func GetRootlessEUID() int { | ||
euidEnv := os.Getenv("_CONTAINERS_ROOTLESS_UID") | ||
if euidEnv != "" { | ||
euid, _ := strconv.Atoi(euidEnv) | ||
return euid | ||
} | ||
return os.Geteuid() | ||
} |
This file contains 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