3 added 3 characters in body
source | link

I was successful in using the following examples as you've described. Sample scripts:

top.bash
$ cat /tmp/top.bash    
#!/bin/bash

echo "running $0"
sudo -v 
whoami
sudo /tmp/bott.bash
bott.bash
$ more /tmp/bott.bash
#!/bin/bash

echo "running $0"
whoami

Now with the following modification to sudo:

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash

Now as user sam:

$ sudo /tmp/top.bash 
running /tmp/top.bash
root
running /tmp/bott.bash
root

What about running top.bash withwithout sudo?

If I alter the /etc/sudoers file like so:

sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash,/tmp/bott.bash

And then just run /tmp/top.bash as user saml:

$ /tmp/top.bash 
running /tmp/top.bash
sam
running /tmp/bott.bash
root

I get the above. Which is what I would expect.

I was successful in using the following examples as you've described. Sample scripts:

top.bash
$ cat /tmp/top.bash    
#!/bin/bash

echo "running $0"
sudo -v 
whoami
sudo /tmp/bott.bash
bott.bash
$ more /tmp/bott.bash
#!/bin/bash

echo "running $0"
whoami

Now with the following modification to sudo:

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash

Now as user sam:

$ sudo /tmp/top.bash 
running /tmp/top.bash
root
running /tmp/bott.bash
root

What about running top.bash with sudo?

If I alter the /etc/sudoers file like so:

sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash,/tmp/bott.bash

And then just run /tmp/top.bash as user saml:

$ /tmp/top.bash 
running /tmp/top.bash
sam
running /tmp/bott.bash
root

I get the above. Which is what I would expect.

I was successful in using the following examples as you've described. Sample scripts:

top.bash
$ cat /tmp/top.bash    
#!/bin/bash

echo "running $0"
sudo -v 
whoami
sudo /tmp/bott.bash
bott.bash
$ more /tmp/bott.bash
#!/bin/bash

echo "running $0"
whoami

Now with the following modification to sudo:

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash

Now as user sam:

$ sudo /tmp/top.bash 
running /tmp/top.bash
root
running /tmp/bott.bash
root

What about running top.bash without sudo?

If I alter the /etc/sudoers file like so:

sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash,/tmp/bott.bash

And then just run /tmp/top.bash as user saml:

$ /tmp/top.bash 
running /tmp/top.bash
sam
running /tmp/bott.bash
root

I get the above. Which is what I would expect.

2 added 361 characters in body
source | link

I was successful in using the following examples as you've described. Sample scripts:

top.bash
$ cat /tmp/top.bash    
#!/bin/bash

echo "running $0"
sudo -v 
whoami
sudo /tmp/bott.bash
bott.bash
$ more /tmp/bott.bash
#!/bin/bash

echo "running $0"
whoami

Now with the following modification to sudo:

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash

Now as user sam:

$ sudo /tmp/top.bash 
running /tmp/top.bash
root
running /tmp/bott.bash
root

What about running top.bash with sudo?

If I alter the /etc/sudoers file like so:

sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash,/tmp/bott.bash

And then just run /tmp/top.bash as user saml:

$ /tmp/top.bash 
running /tmp/top.bash
sam
running /tmp/bott.bash
root

I get the above. Which is what I would expect.

I was successful in using the following examples as you've described. Sample scripts:

top.bash
$ cat /tmp/top.bash    
#!/bin/bash

echo "running $0"
sudo -v 
whoami
sudo /tmp/bott.bash
bott.bash
$ more /tmp/bott.bash
#!/bin/bash

echo "running $0"
whoami

Now with the following modification to sudo:

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash

Now as user sam:

$ sudo /tmp/top.bash 
running /tmp/top.bash
root
running /tmp/bott.bash
root

I was successful in using the following examples as you've described. Sample scripts:

top.bash
$ cat /tmp/top.bash    
#!/bin/bash

echo "running $0"
sudo -v 
whoami
sudo /tmp/bott.bash
bott.bash
$ more /tmp/bott.bash
#!/bin/bash

echo "running $0"
whoami

Now with the following modification to sudo:

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash

Now as user sam:

$ sudo /tmp/top.bash 
running /tmp/top.bash
root
running /tmp/bott.bash
root

What about running top.bash with sudo?

If I alter the /etc/sudoers file like so:

sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash,/tmp/bott.bash

And then just run /tmp/top.bash as user saml:

$ /tmp/top.bash 
running /tmp/top.bash
sam
running /tmp/bott.bash
root

I get the above. Which is what I would expect.

1
source | link

I was successful in using the following examples as you've described. Sample scripts:

top.bash
$ cat /tmp/top.bash    
#!/bin/bash

echo "running $0"
sudo -v 
whoami
sudo /tmp/bott.bash
bott.bash
$ more /tmp/bott.bash
#!/bin/bash

echo "running $0"
whoami

Now with the following modification to sudo:

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
sam     ALL=(ALL)       NOPASSWD:/tmp/top.bash

Now as user sam:

$ sudo /tmp/top.bash 
running /tmp/top.bash
root
running /tmp/bott.bash
root