source: server/common/oursrc/execsys/ldapize.pl @ 825

Last change on this file since 825 was 825, checked in by andersk, 14 years ago
Package the svn vhosting infrastructure into execsys.
  • Property svn:executable set to *
File size: 1.6 KB
RevLine 
[825]1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Net::LDAP;
7use Net::LDAP::Filter;
8
9my $url = $ARGV[0];
10my ($proto, $hostname, $path) = $url =~ m|^(.*?)://([^/]*)(.*)| or die "Could not match URL";
11my $mesg;
12
13# oh my gosh Net::LDAP::Filter SUCKS
14my $filter = bless({or =>
15    [{equalityMatch => {attributeDesc  => 'scriptsVhostName',
16                        assertionValue => $hostname}},
17     {equalityMatch => {attributeDesc  => 'scriptsVhostAlias',
18                        assertionValue => $hostname}}]},
19    'Net::LDAP::Filter');
20
21my $ldap = Net::LDAP->new("ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/");
22$mesg = $ldap->bind();
23$mesg->code && die $mesg->error;
24
25$mesg = $ldap->search(base => "ou=VirtualHosts,dc=scripts,dc=mit,dc=edu",
26                      filter => $filter);
27$mesg->code && die $mesg->error;
28
29my $vhostEntry = $mesg->pop_entry;
30my $vhostDirectory = $vhostEntry->get_value('scriptsVhostDirectory');
31
32$mesg = $ldap->search(base => $vhostEntry->get_value('scriptsVhostAccount'),
33                      scope => 'base', filter => 'objectClass=posixAccount');
34$mesg->code && die $mesg->error;
35
36my $userEntry = $mesg->pop_entry;
37my ($homeDirectory, $uidNumber, $gidNumber) =
38    map { $userEntry->get_value($_) } qw(homeDirectory uidNumber gidNumber);
39
40if ($proto eq 'svn') {
41  chdir '/usr/libexec/scripts-trusted';
42  exec('/usr/sbin/suexec', $uidNumber, $gidNumber, '/usr/libexec/scripts-trusted/svn', "$homeDirectory/Scripts/svn/$vhostDirectory");
43} elsif ($proto eq 'http') {
44  print "suexec $uidNumber $gidNumber $homeDirectory/Scripts/web/$vhostDirectory/$path\n";
45} else {
46  die "Unknown protocol\n";
47}
Note: See TracBrowser for help on using the repository browser.