- Timestamp:
- Jun 7, 2011, 12:58:14 PM (13 years ago)
- Location:
- branches/fc15-dev
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fc15-dev
- Property svn:mergeinfo changed
/trunk (added) merged: 1811,1813-1819,1821-1825,1838,1848-1856,1858-1872,1877
- Property svn:mergeinfo changed
-
branches/fc15-dev/server/common/oursrc/execsys/ldapize.pl
r1798 r1878 7 7 use Net::LDAP::Filter; 8 8 9 sub report_error10 {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 24 9 my $url = $ARGV[0]; 25 10 my ($proto, $hostname, $path) = $url =~ m|^(.*?)://([^/]*)(.*)| or die "Could not match URL"; 26 11 my $mesg; 27 12 13 my $vhostName = $hostname; 14 15 vhost: 28 16 # oh my gosh Net::LDAP::Filter SUCKS 29 17 my $filter = bless({and => … … 32 20 {or => 33 21 [{equalityMatch => {attributeDesc => 'scriptsVhostName', 34 assertionValue => $ hostname}},22 assertionValue => $vhostName}}, 35 23 {equalityMatch => {attributeDesc => 'scriptsVhostAlias', 36 assertionValue => $ hostname}}]}]},24 assertionValue => $vhostName}}]}]}, 37 25 'Net::LDAP::Filter'); 38 26 39 my $ldap = Net::LDAP->new("ldapi://%2fvar%2frun%2f dirsrv%2fslapd-scripts.socket/");27 my $ldap = Net::LDAP->new("ldapi://%2fvar%2frun%2fslapd-scripts.socket/"); 40 28 $mesg = $ldap->bind(); 41 29 $mesg->code && die $mesg->error; … … 46 34 47 35 my $vhostEntry = $mesg->pop_entry; 48 if (!$vhostEntry) 49 { 50 report_error($proto, "Could not find Host $hostname"); 36 if (!defined $vhostEntry) { 37 $vhostName ne '*' or die 'No vhost for *'; 38 $vhostName =~ s/^(?:\*\.)?[^.]*/*/; # Try next wildcard 39 goto vhost; 51 40 } 41 52 42 my $vhostDirectory = $vhostEntry->get_value('scriptsVhostDirectory'); 53 43 … … 59 49 my ($homeDirectory, $uidNumber, $gidNumber) = 60 50 map { $userEntry->get_value($_) } qw(homeDirectory uidNumber gidNumber); 51 (my $scriptsdir = $homeDirectory) =~ s{(?:/Scripts)?$}{/Scripts}; 61 52 62 53 if ($proto eq 'svn') { 63 54 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"); 65 56 } 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 } 66 63 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"); 68 65 } 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"; 70 67 } else { 71 68 die "Unknown protocol\n";
Note: See TracChangeset
for help on using the changeset viewer.