-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LibOS] Add
loader.uid
and loader.gid
manifest options
By default, Gramine uses the root user (uid = gid = 0), which may cause some apps to refuse to run. This commit allows Gramine to run an app with another user than root. We also set effective UID/GID to the same value as UID/GID respectively. Signed-off-by: Denis Zygann <[email protected]>
- Loading branch information
Denis Zygann
authored and
Dmitrii Kuvaiskii
committed
Oct 5, 2021
1 parent
f28deaf
commit 299500a
Showing
7 changed files
with
95 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,5 +114,6 @@ | |
/tcp_msg_peek | ||
/tmp | ||
/udp | ||
/uid_gid | ||
/unix | ||
/vfork_and_exec |
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,24 @@ | ||
#include <err.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
int main(int argc, char** argv) { | ||
uid_t uid = getuid(); | ||
uid_t euid = geteuid(); | ||
|
||
if (uid != 1338 || euid != 1338) { | ||
errx(EXIT_FAILURE, "UID/effective UID are not equal to the value in the manifest"); | ||
} | ||
|
||
uid_t gid = getgid(); | ||
uid_t egid = getegid(); | ||
|
||
if (gid != 1337 || egid != 1337) { | ||
errx(EXIT_FAILURE, "GID/effective GID are not equal to the value in the manifest"); | ||
} | ||
|
||
puts("TEST OK"); | ||
return 0; | ||
} |
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,19 @@ | ||
loader.preload = "file:{{ gramine.libos }}" | ||
libos.entrypoint = "uid_gid" | ||
loader.env.LD_LIBRARY_PATH = "/lib:{{ arch_libdir }}:/usr/{{ arch_libdir }}" | ||
loader.argv0_override = "uid_gid" | ||
|
||
loader.uid = 1338 | ||
loader.gid = 1337 | ||
|
||
fs.mount.lib.type = "chroot" | ||
fs.mount.lib.path = "/lib" | ||
fs.mount.lib.uri = "file:{{ gramine.runtimedir() }}" | ||
|
||
sgx.nonpie_binary = true | ||
sgx.debug = true | ||
|
||
sgx.trusted_files = [ | ||
"file:{{ gramine.runtimedir() }}/", | ||
"file:uid_gid", | ||
] |