-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust/sim: Remove dependency on nightly Rust
Awaiting stabilization in rust-lang/rust#42839
- Loading branch information
1 parent
22037d4
commit 9dd4bb0
Showing
6 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
// This wrapper is only needed because the std implementation of peer_cred is | ||
// nightly only. https://github.com/rust-lang/rust/issues/42839 | ||
#define _GNU_SOURCE | ||
#include <sys/socket.h> | ||
|
||
// WARNING: If this struct changes, it must also change identically in sim.rs. | ||
struct UCred { | ||
pid_t pid; | ||
uid_t uid; | ||
gid_t gid; | ||
}; | ||
|
||
int peer_cred_c(int sockfd, struct UCred* cred) | ||
{ | ||
socklen_t len = sizeof(struct ucred); | ||
struct ucred ucred; | ||
cred.pid = -1; | ||
cred.uid = -1; | ||
cred.gid = -1; | ||
|
||
if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1) { | ||
return errno; | ||
} | ||
|
||
cred->pid = ucred.pid; | ||
cred->uid = ucred.uid; | ||
cred->gid = ucred.gid; | ||
return 0; | ||
} |