diff --git a/Template.md b/Template.md index cccba32..6d7dbb9 100644 --- a/Template.md +++ b/Template.md @@ -1,35 +1,17 @@ -# To run commands as another user, use su -c or sudo. +# (Message goes here) ### Problematic code: - ./configure - make - su root - make install + (Simple example of problematic code) ### Correct code: - ./configure - make - sudo make install # or su -c 'make install' root + (Simple example of above code, only fixed) ### Rationale: -`su` doesn't actually switch user. It starts a brand new shell, running as another user. You can't put `su foo` in a script to make the following command run as user `foo`. - -Use `sudo -u username cmd` or `su -c cmd username` instead. +(An explanation of why the code is problematic and how the correct code is an improvement) ### Contraindications -If you want to present the user with a root shell or when you're redirecting input, you can ignore this message: - - until mycommand - do - echo "Failed. You will now get a root shell. Fix problem and exit to retry." - su - done - -or - - exec < mycommands - su foo +(Cases where the user may choose to ignore this warning, if any.) \ No newline at end of file