sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit 4e660975a99cba67526b62dff930b334d550b4b4
parent a95ce5ce6575ac68a6af2c6c4cbb001be5799737
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue, 27 Sep 2016 14:28:14 -0400

Merge pull request #911 from thejan2009/setgid-setuid

Split setgid and setuid, add privilege check [RFC]
Diffstat:
Msway/main.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sway/main.c b/sway/main.c @@ -156,10 +156,18 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } if (getuid() != geteuid() || getgid() != getegid()) { - if (setgid(getgid()) != 0 || setuid(getuid()) != 0) { + if (setgid(getgid()) != 0) { sway_log(L_ERROR, "Unable to drop root"); exit(EXIT_FAILURE); } + if (setuid(getuid()) != 0) { + sway_log(L_ERROR, "Unable to drop root"); + exit(EXIT_FAILURE); + } + } + if (setuid(0) != -1) { + sway_log(L_ERROR, "Root privileges can be restored."); + exit(EXIT_FAILURE); } char *socket_path = getenv("SWAYSOCK"); if (!socket_path) {