sudo-project / sudo

Utility to execute a command as another user
https://www.sudo.ws
Other
1.15k stars 208 forks source link

how to test sudo -b? #328

Closed trackers-lover closed 6 months ago

trackers-lover commented 8 months ago

Can you tell me how to test the sudo - b parameter?

AlexBaranowski commented 6 months ago

It depends on what you want to test. The easiest way to check if this parameter works at all is to invoke some long command ex. sleep.

sudo -b sleep 15.0

Then you can check that this is running.

sudo ps aux | egrep '[s]leep'

Example output for the interactive run:

[Alex@NormandySR2 ~]$ sudo -b sleep 15.0
[Alex@NormandySR2 ~]$ ps aux | egrep '[s]leep'
root       23100  0.0  0.0 238312  5072 pts/1    S    19:09   0:00 sudo -b sleep 15.0
root       23105  0.0  0.0 220952  1792 pts/1    S    19:09   0:00 sleep 15.0
[Alex@NormandySR2 ~]$ sudo pstree -lp 23100
sudo(23100)───sleep(23105)

Finally, the whole test might require a little parsing if you want to automate it. This is simple functional test.