New Ticket     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 38144

Show
Ignore:
Timestamp:
07/08/2008 13:35:34 (4 years ago)
Author:
pmagrath@…
Message:

Added a new procedure for recursive chowning of directories. Inserted calls to this procedure where necessary.

Location:
branches/gsoc08-privileges/base/src/port1.0
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/gsoc08-privileges/base/src/port1.0/portextract.tcl

    r38096 r38144  
    9494proc extract_main {args} { 
    9595    global UI_PREFIX euid egid worksrcpath macportsuser 
    96     global filespath 
    9796     
    9897    if {![exists distfiles] && ![exists extract.only]} { 
     
    103102    foreach distfile [option extract.only] { 
    104103        ui_info "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $distfile]" 
    105         if {[file exists $filespath/$distfile]} { 
    106                 option extract.args "$filespath/$distfile" 
    107         } else { 
    108                 option extract.args "[option distpath]/$distfile" 
    109         } 
     104        option extract.args "[option distpath]/$distfile" 
    110105        if {[catch {command_exec extract} result]} { 
    111106            return -code error "$result" 
     
    117112                seteuid $euid    
    118113                ui_debug "euid changed to: [geteuid]" 
    119                 file attributes "${worksrcpath}" -owner [name_to_uid "$macportsuser"] 
     114                chown  ${worksrcpath} ${macportsuser} 
    120115                ui_debug "chowned $worksrcpath to $macportsuser" 
    121116                seteuid [name_to_uid "$macportsuser"] 
    122117                ui_debug "euid changed to: [geteuid]" 
     118        } else { 
     119                ui_debug "no need to chown $worksrcpath. uid=[getuid]. euid=[geteuid]." 
    123120        } 
     121                 
    124122        # end gsoc08-privileges 
    125123         
  • branches/gsoc08-privileges/base/src/port1.0/portutil.tcl

    r38016 r38144  
    718718# Provides "sed in place" functionality 
    719719proc reinplace {args}  { 
     720        global euid macportsuser 
     721 
    720722    set extended 0 
    721723    while 1 { 
     
    776778     
    777779        close $tmpfd 
     780     
     781                # start gsoc08-privileges 
     782                if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } { 
     783                # if started with sudo but have dropped the privileges 
     784                        seteuid $euid    
     785                        ui_debug "euid changed to: [geteuid]" 
     786                        chown $file ${macportsuser} 
     787                        ui_debug "chowned $file to $macportsuser" 
     788                        seteuid [name_to_uid "$macportsuser"] 
     789                        ui_debug "euid changed to: [geteuid]" 
     790                } else { 
     791                        ui_debug "no need to chown $file. uid=[getuid]. euid=[geteuid]." 
     792                } 
     793                         
     794                # end gsoc08-privileges 
    778795     
    779796        set attributes [file attributes $file] 
     
    22482265} 
    22492266 
     2267## 
     2268# Recusively chown the given file or directory to the specified user. 
     2269# 
     2270# @param path the file/directory to be chowned 
     2271# @param user the user to chown file to 
     2272proc chown {path user} { 
     2273        file attributes $path -owner [name_to_uid "$user"] 
     2274         
     2275    if {[file isdirectory $path]} { 
     2276                foreach g [glob [file join $path *]] { 
     2277                        chown $g $user 
     2278                } 
     2279    } 
     2280} 
     2281