SwiftMango
SwiftMango

Reputation: 15294

Fake sudo script not working as expected

I tried to fake a sudo program that requires real superuser password:

#!/bin/sh

su -c "'$*'"

It works when I do

sudo yum

But does not work when I do

sudo yum upgrade

Or any command that has arguments. Bash complains

bash: yum upgrade command not found

Why is this happening?

Upvotes: 0

Views: 881

Answers (1)

William Pursell
William Pursell

Reputation: 212464

You're quoting incorrectly. This is the rare case where you actually want "$*" instead of "$@". But you definitely do not want "'$*'"

Upvotes: 2

Related Questions