0

Time ago i had this answer but i cannot recall how exactly was the syntax. I have two files. One is binary file called "changeuid" and second is "do.sh". I need to run changeuid which will change my uid and after execution, content of do.sh, which consist of list of commands available only for uid given by changeuid script, to be executed. What i dont remember is how this was done. Ive been testing few variants none worked or maybe tasks inside them which werent similar to what original ones do were wrong. So .. might be:

./changeuid < sh do.sh
./changeuid < . do.sh
./changeuid < source do.sh
source do.sh < ./changeuid
sh do.sh < ./changeuid

Solution? Thx in advance.

soundhax
  • 155
  • 3

2 Answers2

0

It rather depends on exactly what the changeuid program is doing.

I suspect that it's designed to change your uid to a given value, then run another program, and then exit (by which point you'll be back to your normal user). If that's right, then it'll need your other program to be passed to it as an argument:

./changeuid do.sh

You'll also need both changeuid and do.sh to be executable.

I'm not really sure why you'd need a separate changeuid program to do this, though. There are three ways of doing it with standard Linux commands: use su, or sudo, or runuser. Which one you choose will depend on whether you're running this as root already.

For more info, try man su, etc.

If changeuid takes commands to run on stdin, then it would be

./changeuid < do.sh
chiastic-security
  • 20,430
  • 4
  • 39
  • 67
  • what i can be sure is that a "<" was present – soundhax Oct 02 '15 at 15:59
  • @soundhax It's conceivable that `changeuid` takes a script to run on stdin, although that would be a bit weird. If that were the case then it would just be `./changeuid < do.sh`. – chiastic-security Oct 02 '15 at 16:20
  • yep my bad sorry is very obviously what is happening but i was confused cuz exactly line which printed some sort of result of all this job was missing so i was unable to see the final result, expected one.thx again anywayz. – soundhax Oct 02 '15 at 16:49
  • @soundhax You're welcome. I've added something to reflect the possibility of taking the script on stdin. Please do mark as accepted answer if you found it useful. – chiastic-security Oct 02 '15 at 16:51
0

After some real test figured out... correct solution was:

./changeuid < ./script.sh

I didnt figured cuz something else was missing.

soundhax
  • 155
  • 3