Changeset 1198 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Feb 17, 2011, 1:20:36 AM (13 years ago)
Author:
Bruno Cornec
Message:
  • Fix sudoers format fr env_keep (at least on gentoo)
  • Fix pb_get_sudocmds to deal correctly with additional params, and handle correctly spaces before sudo
  • Add full path names on sudo commands for gentoo
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1197 r1198  
    29612961print PBOUT "Defaults:root !requiretty\n";
    29622962# Keep proxy configuration while using sudo
    2963 print PBOUT "Defaults:$pbac->{$ENV{'PBPROJ'}} env_keep += \\\"http_proxy ftp_proxy\\\"\n";
     2963print PBOUT "Defaults:$pbac->{$ENV{'PBPROJ'}}    env_keep += \\\"http_proxy ftp_proxy\\\"\n";
    29642964EOF
    29652965    # Try to restrict security to what is really needed
    29662966    if ($vtype =~ /^vm/) {
    29672967        my $hpath = pb_distro_get_param($pbos,pb_conf_get("ospathcmd-halt"));
    2968         my @sudocmds = pb_get_sudocmds($pbos,$ntpline,$hpath);
     2968        my @sudocmds = pb_get_sudocmds($pbos,$ntpline,"sudo $hpath");
    29692969        print SCRIPT << "EOF";
    29702970# This is needed in order to be able on VM to halt the machine from the $pbac->{$ENV{'PBPROJ'}} account at least
     
    37663766       
    37673767my $pbos = shift;
    3768 my @lines = shift;
    37693768my %sudocmds;
    37703769
    3771 foreach my $c (split(/;/,$pbos->{'update'}),split(/;/,$pbos->{'install'}),@lines) {
    3772     next if ($c !~ /^sudo/);
    3773     # remove sudo
    3774     $c =~ s/^sudo\s+//;
    3775     # remove leading spaces
    3776     $c =~ s/^\s+//;
    3777     # remove ending spaces
    3778     $c =~ s/\s+$//;
     3770pb_log(2,"pb_get_sudocmds entering with lines:".Dumper(@_)."\n");
     3771foreach my $c (split(/;/,$pbos->{'update'}),split(/;/,$pbos->{'install'}),@_) {
     3772    pb_log(2,"pb_get_sudocmds analyses $c\n");
     3773    next if ($c !~ /^\s*sudo/);
     3774    # remove sudo and leading spaces
     3775    $c =~ s/^\s*sudo\s+//;
    37793776    # keep only the command, not the params
    37803777    $c =~ s/([^\s]+)\s.*$/$1/;
    37813778    $sudocmds{$c} = "";
    37823779}
    3783 pb_log(2,"pb_get_sudcomds returns ".Dumper(%sudocmds)."\n");
     3780pb_log(2,"pb_get_sudocmds returns ".Dumper(keys %sudocmds)."\n");
    37843781return(keys %sudocmds);
    37853782}
Note: See TracChangeset for help on using the changeset viewer.