-$line =~ m{^git-upload-pack ~($USER)/($PATH[.]git)\0host=($HOST)\0$};
-my ($user,$path,$host) = ($1,$2,$3);
-
-# child's output will go directly to inetd
-open CHILD, '-|', 'userv', $user,
- qw(git daemon --inetd --strict-paths
- --user-path=public-git --forbid-override=receive-pack)
- or die "open pipe to userv: $!\n";
-
-# proxy command line to child
-syswrite CHILD, $len_hex.$line
- or die "write to userv: $!\n";
-
-# relay stdin to child
-open STDOUT, ">&CHILD"
- or die "dup: $!\n";
-exec 'cat'
- or die "exec: $!\n";
-
-die
+unless ($line =~ m{^git-upload-pack (?:~($TILDE)/)?($REPO[.]git)\0host=($HOSTNAME)\0$}) {
+ $line =~ s/[^ -~]+/ /g;
+ fail "could not parse \"$line\""
+}
+my ($tilde,$repo,$host) = ($1,$2,$3);
+my $url = $tilde ? "git://$host/~$tilde/$repo" : "git://$host/$repo";
+
+my $user = $vhost_user_from_tilde{$host} ? $tilde : $vhost_default_user{$host};
+fail "no user configuration for $url" unless defined $user;
+
+syslog 'info', "$peer $user $url";
+
+my @opts = ("-DCLIENT=$addr", "-DHOST=$host", "-DREPO=$repo");
+push @opts, "-DTILDE=$tilde" if defined $tilde;
+
+exec 'userv', @opts, $user, 'git-upload-pack'
+ or fail "exec userv: $!";
+
+# end