Changeset 38640


Ignore:
Timestamp:
Jul 26, 2008, 4:07:57 PM (9 years ago)
Author:
pmagrath@…
Message:

Fix various clean target related bugs caused by the new privilege dropping code.

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

Legend:

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

    r37794 r38640  
    5252   
    5353        # start gsoc08-privileges
    54         if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
     54        #if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
    5555        # if started with sudo but have dropped the privileges
    56                 ui_debug "Can't guarantee a good clean without elevated privileges."
     56        #       ui_debug "Can't guarantee a good clean without elevated privileges."
    5757                # TODO: modify so that privilege descalation is conditional on needing
    5858                # to clean a directory in the /opt hierarchy.
    59                 ui_debug "Going to escalate privileges back to root."
    60                 seteuid $euid   
    61                 setegid $egid
    62                 ui_debug "euid changed to: [geteuid]"
    63                 ui_debug "egid changed to: [getegid]"
    64         }
     59        #       ui_debug "Going to escalate privileges back to root."
     60        #       seteuid $euid   
     61        #       setegid $egid
     62        #       ui_debug "euid changed to: [geteuid]"
     63        #       ui_debug "egid changed to: [getegid]"
     64        #}
    6565        # end gsoc08-privileges
    6666}
     
    6969    global UI_PREFIX
    7070        global ports_clean_dist ports_clean_work ports_clean_archive
    71         global ports_clean_all
     71        global ports_clean_all usealtworkpath
    7272
    7373        if {[info exists ports_clean_all] && $ports_clean_all == "yes" || \
     
    8888                 clean_work
    8989        }
    90 
     90       
     91        # start gsoc-08 privileges
     92        if {$usealtworkpath == "yes"} {
     93                ui_info "$UI_PREFIX [format [msgcat::mc "Removing alt source directory for %s"] [option portname]]"
     94                clean_altsource
     95        }
     96        # end gsoc-08 privileges
     97       
    9198    return 0
     99}
     100
     101proc clean_altsource {args} {
     102    global usealtworkpath worksymlink
     103   
     104    set sourcepath [string map {"work" ""} $worksymlink]
     105
     106        if {[file isdirectory $sourcepath]} {
     107                ui_debug "Removing directory: ${sourcepath}"
     108                if {[catch {delete $sourcepath} result]} {
     109                        ui_debug "$::errorInfo"
     110                        ui_error "$result"
     111                }
     112        } else {
     113                ui_debug "No alt source directory found to remove."
     114        }
     115
     116        return 0
    92117}
    93118
     
    173198                }
    174199        } else {
    175                 ui_debug "No work directory found to remove."
     200                ui_debug "No work directory found to remove at: ${portbuildpath}"
    176201        }
    177202
  • branches/gsoc08-privileges/base/src/port1.0/portutil.tcl

    r38147 r38640  
    13971397proc open_statefile {args} {
    13981398    global workpath worksymlink place_worksymlink portname portpath ports_ignore_older
    1399     global altprefix macportsuser euid egid usealtworkpath env applications_dir
     1399    global altprefix macportsuser euid egid usealtworkpath env applications_dir portbuildpath
    14001400   
    14011401        # start gsoc08-privileges
     
    14591459                set newworkpath "$altprefix/[ string range $workpath 1 end ]"
    14601460                set newworksymlink "$altprefix/[ string range $worksymlink 1 end ]"
     1461                set newportbuildpath "$altprefix/[ string range $portbuildpath 1 end ]"
    14611462               
    14621463                set sourcepath [string map {"work" ""} $worksymlink]
     
    14701471                        ui_debug "Going to copy: ${sourcepath}Portfile"
    14711472                        file copy ${sourcepath}Portfile $newsourcepath
    1472                         ui_debug "Going to copy: ${sourcepath}files"
    1473                         file copy ${sourcepath}files $newsourcepath
     1473                        if {[file exists ${sourcepath}files] } {
     1474                                ui_debug "Going to copy: ${sourcepath}files"
     1475                                file copy ${sourcepath}files $newsourcepath
     1476                        }
    14741477                }
    14751478               
    14761479                set workpath $newworkpath
    14771480                set worksymlink $newworksymlink
     1481                set portbuildpath $newportbuildpath
    14781482               
    14791483                ui_debug "Going to use $newworkpath for statefile."
Note: See TracChangeset for help on using the changeset viewer.