Re: help with sudo

Anthony Martinez <[email protected]>
Newsgroups gmane.org.user-groups.nmlug
Message-ID <[email protected]>
On Tue, Sep 25, 2007 at 06:15:28PM -0600, Chris McMahon wrote:
> Hi NMLUG...
> 
> For a complicated reason, I need to run a script that sets euid to
> several different values.  I have sudo ALL privileges, but I won't get
> root on the machine in question.
> 
> Under sudo, I can set euid once, but I haven't figured out a way to
> set euid more than once.  Here's a toy Ruby script that shows the
> problem:
> 
> #################
> euids = [2205, 2206, 2207]
> 
> euids.each do |id|
> 
>     Process.euid = id
>     puts "euid is: "
>     puts Process.euid
> 
> end
> ####################

Just as an aside, I'd probably encapsulate that into a method like the
following:

def run_as_euid(euid)
    orig_euid = Process.euid
    Process.euid = euid
    yield
    Process.euid = orig_euid
end
[2205,2206,2207].each do |e|
    run_as_euid(e) do
        puts "euid is: #{Process.euid}"
    end
end

That's a matter of preference, though :)
> 
> Here's the output of this script running as me, and under sudo:
> 
> cmcmahon@machine:~$ ruby sudodemo.rb
> sudodemo.rb:7:in `euid=': Operation not permitted (Errno::EPERM)
>         from sudodemo.rb:7
>         from sudodemo.rb:5:in `each'
>         from sudodemo.rb:5
> cmcmahon@machine:~$ sudo ruby sudodemo.rb
> euid is:
> 2205
> sudodemo.rb:7:in `euid=': Operation not permitted (Errno::EPERM)
>         from sudodemo.rb:7
>         from sudodemo.rb:5:in `each'
>         from sudodemo.rb:5
> cmcmahon@machine:~$
> 
> 
> I also have access to the user whose euid is 2205, and that user also
> has sudo ALL privileges.  I've tried doing "sudo -v" as the 2205 user
> and then running the script as me, but I get the same result.
> 
> It may not be possible to do what I want to do, but any suggestions
> would be appreciated.
> Thanks,
> -Chris
> _______________________________________________
> NMLUG mailing list
> [email protected]
> http://lists.b9.com/cgi-bin/mailman/listinfo/nmlug
> 

-- 
All C programs do the same thing: look at a character and do nothing with it.
-- Peter Weinberger

_______________________________________________
NMLUG mailing list
[email protected]
http://lists.b9.com/cgi-bin/mailman/listinfo/nmlug
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHAHJHKaiGM/xGKzQRAsf0AKDH+USv8qPHu5MS1HArSlvhu/ab/ACfV5WC
5sj/tocgHdSbzRFYZPUFtr0=
=YWZb
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.