X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=plex.pls;h=4c5ab472a1e99ef9e3e51675372ca021a1f3ceaa;hb=4d94dfdf5171220e62511e48de6f36b97d5eadfb;hp=a1bd1cc5715e05800ed1863d41e9e44c12c33c10;hpb=f447e74c146d83b9348ed3dcb32104d2b2991ac9;p=iceplex.git diff --git a/plex.pls b/plex.pls index a1bd1cc..4c5ab47 100644 --- a/plex.pls +++ b/plex.pls @@ -8,12 +8,15 @@ # the same terms as Perl itself. use strict; -use subs qw(pick_server); +use subs qw(suidsetup pick_server); use CGI; use CGI::Carp qw(fatalsToBrowser); -use Digest::MD5; +use Digest::MD5 qw(md5_hex); +use DBI; use Net::SSH qw(ssh); +suidsetup(); + # pull in configuration use vars qw($dsn $user $pass $mp3path $port); use vars qw($override_query $fileno_query); @@ -61,21 +64,34 @@ my $filename = "$mp3path/$customer-$user-$fileno.mp3"; $dbh->disconnect; #generate a mountpoint -my $mountpoint = md5_hex($cgi->remote_host. $$. time. int(rand(4294967296))); +md5_hex($cgi->remote_host. $$. time. int(rand(4294967296))) =~ /^(\w+)$/; +my $mountpoint = $1; #signal encoder to start streaming to mountpoint & wait for confirmation -ssh($server, 'yashout', $filename, $mountpoint ); +warn "ssh $server yashout $filename $mountpoint $port\n"; +ssh($server, 'yashout', $filename, $mountpoint, $port ); #send file back to client browser print $cgi->header( -type => $extension2type{$extension} ); -print "[playlist]\nNumberOfEntries=1\n" if $extension eq 'pls'; +print "[playlist]\nNumberOfEntries=1\nFile1=" if $extension eq 'pls'; print "http://$server:$port/$mountpoint\n"; ### # subroutiens ### +sub suidsetup { + $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; + $ENV{'SHELL'} = '/bin/sh'; + $ENV{'IFS'} = " \t\n"; + $ENV{'CDPATH'} = ''; + $ENV{'ENV'} = ''; + $ENV{'BASH_ENV'} = ''; + + $< = $>; #correct uid for spawned ssh process +} + sub pick_server { my $sth = $dbh->prepare( "SELECT servername FROM iceplex_servers ".