- Sudo (su "do") allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while providing an audit trail of the commands and their arguments.
DKF: Well that's deeply stupid. But which distros are you talking about? (It's also outside the scope of Tcl...)MAKR: it is - and I know from openSUSE, that they have Defaults targetpw together with ALL ALL=(ALL) ALL which makes sudo almost completely useless ...Someone is confused about Linux and sudo. Ubuntu Linux configures sudo such that you do not use root at all except by using sudo. There is not really a root user, but only root access which can be gained using sudo.[2] There is no root password, only user passwords.
DKF: That's pretty much the standard way of setting it up. Doing it the other way requires a special dose of stupidity...
Googie wrote: Any idea how to get superuser rights by tcl script? It's easy under expect, but I have to do it in clear tcl (without packages). Well? ThanksMGS [2003/05/08] - What superuser rights are you after? Superuser execute right? Or superuser file access rights?Have you tried using 'sudo'? The -S option enables reading password on stdin.You could use this rough code as a basis:
proc sudo:passwd {pipe} { puts "sudo:passwd \[$pipe\]" catch {puts $pipe mypass} fileevent $pipe writable {} } proc sudo:read {pipe} { puts "sudo:read \[$pipe\]" variable $pipe upvar 0 $pipe _ set chars [gets $pipe line] puts " read \[$line\] ($chars chars)" append _(stdout) $line\n if { [eof $pipe] } { puts " got eof" fileevent $pipe readable {} fileevent $pipe writable {} if { [catch {close $pipe} code] } { puts " Got error closing sudo pipe" puts " \[$::errorCode\] $code" } else { puts " Successfully closed sudo pipe" puts " code = \[$code\]" } set _(done) 1 } } proc sudo:run {args} { set cmd [eval concat $args] puts "cmd = \[$cmd\]" set list [concat [list sudo -S] $cmd [list 2>&1]] puts "list = \[$list\]" if { [catch {open |$list r+} pipe] } { puts "\[$::errorCode\] $pipe" } else { puts " open returned \[$pipe\]" fconfigure $pipe -buffering none -blocking 1 fileevent $pipe writable [list sudo:passwd $pipe] fileevent $pipe readable [list sudo:read $pipe] } variable $pipe upvar 0 $pipe _ set _(done) 1 set _(stdout) "" set ns [namespace current] if { [string equal $ns ::] } { set ns "" } return ${ns}::$pipe } set sudo [sudo:run [list ls -l /root]] vwait ${sudo}(done) puts " sudo = \[$sudo\]" upvar #0 $sudo array parray arrayNote you'll have to change 'mypass' in sudo:passwd to whatever your password is.If you're after superuser rights to read protected files, you could always use 'cat' ...
[Tim Jones] [3] and Daniel Steffen [4] [... advice ...]
MAKR (2009-02-24): Keep in mind that if you are using sudo -S, you need to sudo -K before! In a subsequent call sudo may otherwise just pipe the password to stdin of the called program.Also note that sudo is highly configurable. You should document your expectations, especially if you do not control the environment (privileges, password, prompt, environment variables, etc...).