Ignore:
Timestamp:
Jun 7, 2011, 12:58:14 PM (13 years ago)
Author:
achernya
Message:
Merge r1803-1877 from trunk to branches/fc15-dev
Location:
branches/fc15-dev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/fc15-dev

  • branches/fc15-dev/server/common/oursrc/execsys/ldapize.pl

    r1798 r1878  
    77use Net::LDAP::Filter;
    88
    9 sub report_error
    10 {
    11     my $proto = shift;
    12     my $mesg = shift;
    13 
    14     if ($proto eq 'git') {
    15         $mesg = "ERR \n  " . $mesg . "\n";
    16         my $len = length($mesg)+4;
    17         printf "%04x%s", $len, $mesg;
    18     } else {
    19         print $mesg;
    20     }
    21     exit 0;
    22 }
    23 
    249my $url = $ARGV[0];
    2510my ($proto, $hostname, $path) = $url =~ m|^(.*?)://([^/]*)(.*)| or die "Could not match URL";
    2611my $mesg;
    2712
     13my $vhostName = $hostname;
     14
     15vhost:
    2816# oh my gosh Net::LDAP::Filter SUCKS
    2917my $filter = bless({and =>
     
    3220     {or =>
    3321         [{equalityMatch => {attributeDesc  => 'scriptsVhostName',
    34                              assertionValue => $hostname}},
     22                             assertionValue => $vhostName}},
    3523          {equalityMatch => {attributeDesc  => 'scriptsVhostAlias',
    36                              assertionValue => $hostname}}]}]},
     24                             assertionValue => $vhostName}}]}]},
    3725    'Net::LDAP::Filter');
    3826
    39 my $ldap = Net::LDAP->new("ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/");
     27my $ldap = Net::LDAP->new("ldapi://%2fvar%2frun%2fslapd-scripts.socket/");
    4028$mesg = $ldap->bind();
    4129$mesg->code && die $mesg->error;
     
    4634
    4735my $vhostEntry = $mesg->pop_entry;
    48 if (!$vhostEntry)
    49 {
    50     report_error($proto, "Could not find Host $hostname");
     36if (!defined $vhostEntry) {
     37  $vhostName ne '*' or die 'No vhost for *';
     38  $vhostName =~ s/^(?:\*\.)?[^.]*/*/;  # Try next wildcard
     39  goto vhost;
    5140}
     41
    5242my $vhostDirectory = $vhostEntry->get_value('scriptsVhostDirectory');
    5343
     
    5949my ($homeDirectory, $uidNumber, $gidNumber) =
    6050    map { $userEntry->get_value($_) } qw(homeDirectory uidNumber gidNumber);
     51(my $scriptsdir = $homeDirectory) =~ s{(?:/Scripts)?$}{/Scripts};
    6152
    6253if ($proto eq 'svn') {
    6354  chdir '/usr/libexec/scripts-trusted';
    64   exec('/usr/sbin/suexec', $uidNumber, $gidNumber, '/usr/libexec/scripts-trusted/svn', "$homeDirectory/Scripts/svn/$vhostDirectory");
     55  exec('/usr/sbin/suexec', $uidNumber, $gidNumber, '/usr/libexec/scripts-trusted/svn', "$scriptsdir/svn/$vhostDirectory");
    6556} elsif ($proto eq 'git') {
     57  if ($vhostEntry->get_value('scriptsVhostName') eq 'notfound.example.com') {
     58    # git-daemon doesn’t report useful errors yet
     59    my $msg = "ERR No such host $hostname\n";
     60    printf '%04x%s', length($msg) + 4, $msg;
     61    exit;
     62  }
    6663  chdir '/usr/libexec/scripts-trusted';
    67   exec('/usr/sbin/suexec', $uidNumber, $gidNumber, '/usr/libexec/scripts-trusted/git', "$homeDirectory/Scripts/git/$vhostDirectory");
     64  exec('/usr/sbin/suexec', $uidNumber, $gidNumber, '/usr/libexec/scripts-trusted/git', "$scriptsdir/git/$vhostDirectory");
    6865} elsif ($proto eq 'http') {
    69   print "suexec $uidNumber $gidNumber $homeDirectory/Scripts/web/$vhostDirectory/$path\n";
     66  print "suexec $uidNumber $gidNumber $scriptsdir/web/$vhostDirectory/$path\n";
    7067} else {
    7168  die "Unknown protocol\n";
Note: See TracChangeset for help on using the changeset viewer.