From 75b2f24de884e317ead5cc1650ba5fd80063d16e Mon Sep 17 00:00:00 2001
From: MggMuggins <mggmugginsmc@gmail.com>
Date: Fri, 27 Jul 2018 22:14:18 -0500
Subject: [PATCH] Do setuid in the userutils recipe

---
 recipes/userutils/recipe.sh | 38 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/recipes/userutils/recipe.sh b/recipes/userutils/recipe.sh
index d5cf814d8..3c8640e0f 100644
--- a/recipes/userutils/recipe.sh
+++ b/recipes/userutils/recipe.sh
@@ -1,7 +1,43 @@
 GIT=https://gitlab.redox-os.org/redox-os/userutils.git
+BINS=(
+    id
+    getty
+    groupadd
+    groupmod
+    groupdel
+    login
+    passwd
+    su
+    sudo
+    useradd
+    usermod
+    userdel
+)
 
 function recipe_stage {
-    cp -Rv res "$1/etc"
+    # Reimplement the entire copy bc of suid
+    if [ "$DEBUG" == 1 ]
+    then
+        build=debug
+    else
+        build=release
+    fi
+    
     mkdir -p "$1/bin"
+    
+    for bin in "${BINS[@]}"
+    do
+        cp -v "target/x86_64-unknown-redox/$build/$bin" "$1/bin"
+    done
+    
+    cp -Rv "res" "$1/etc"
+    
     ln -s id "$1/bin/whoami"
+    chmod +s "$1/bin/passwd"
+    chmod +s "$1/bin/sudo"
+    chmod +s "$1/bin/su"
+    
+    docgen ../source ../stage/ref
+    
+    skip=1
 }
-- 
GitLab