New Ticket     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 52672 for trunk/base/src

Show
Ignore:
Timestamp:
06/20/09 17:29:20 (9 months ago)
Author:
jmr@…
Message:

skip seteuid/setegid calls if macportsuser is root

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portutil.tcl

    r52548 r52672  
    23672367    global euid macportsuser 
    23682368 
    2369     if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } { 
    2370     # if started with sudo but have dropped the privileges 
    2371         seteuid $euid 
    2372         ui_debug "euid changed to: [geteuid]" 
    2373         chown  ${path} ${macportsuser} 
    2374         ui_debug "chowned $path to $macportsuser" 
    2375         seteuid [name_to_uid "$macportsuser"] 
    2376         ui_debug "euid changed to: [geteuid]" 
    2377     } elseif { [getuid] == 0 } { 
    2378     # if started with sudo but have elevated back to root already 
    2379         chown  ${path} ${macportsuser} 
     2369    if { [getuid] == 0 } { 
     2370        if {[geteuid] != 0} { 
     2371            # if started with sudo but have dropped the privileges 
     2372            seteuid $euid 
     2373            ui_debug "euid changed to: [geteuid]" 
     2374            chown  ${path} ${macportsuser} 
     2375            ui_debug "chowned $path to $macportsuser" 
     2376            seteuid [name_to_uid "$macportsuser"] 
     2377            ui_debug "euid changed to: [geteuid]" 
     2378        } else { 
     2379            # if started with sudo but have elevated back to root already 
     2380            chown  ${path} ${macportsuser} 
     2381        } 
    23802382    } 
    23812383} 
     
    23882390    global euid egid macportsuser 
    23892391 
    2390     if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } { 
     2392    if { [getuid] == 0 && [geteuid] != 0 } { 
    23912393    # if started with sudo but have dropped the privileges 
    23922394        ui_debug "Can't run $action on this port without elevated privileges. Escalating privileges back to root." 
     
    23942396        seteuid $euid 
    23952397        ui_debug "euid changed to: [geteuid]. egid changed to: [getegid]." 
    2396     } 
    2397  
    2398     if { [getuid] != 0 } { 
    2399         return -code error "MacPorts requires root privileges for this action"; 
     2398    } elseif { [getuid] != 0 } { 
     2399        return -code error "MacPorts requires root privileges for this action" 
    24002400    } 
    24012401} 
     
    24082408    if { [geteuid] == 0 } { 
    24092409        if { [catch { 
    2410                 ui_debug "changing euid/egid - current euid: $euid - current egid: $egid" 
    2411  
    2412                 #seteuid [name_to_uid [file attributes $workpath -owner]] 
    2413                 #setegid [name_to_gid [file attributes $workpath -group]] 
    2414  
    2415                 setegid [uname_to_gid "$macportsuser"] 
    2416                 seteuid [name_to_uid "$macportsuser"] 
    2417                 ui_debug "egid changed to: [getegid]" 
    2418                 ui_debug "euid changed to: [geteuid]" 
     2410                if {[name_to_uid "$macportsuser"] != 0} { 
     2411                    ui_debug "changing euid/egid - current euid: $euid - current egid: $egid" 
     2412 
     2413                    #seteuid [name_to_uid [file attributes $workpath -owner]] 
     2414                    #setegid [name_to_gid [file attributes $workpath -group]] 
     2415 
     2416                    setegid [uname_to_gid "$macportsuser"] 
     2417                    seteuid [name_to_uid "$macportsuser"] 
     2418                    ui_debug "egid changed to: [getegid]" 
     2419                    ui_debug "euid changed to: [geteuid]" 
     2420                } 
    24192421            }] 
    24202422        } {