diff options
| author | ivan <ivan> | 2003-06-25 12:13:50 +0000 |
|---|---|---|
| committer | ivan <ivan> | 2003-06-25 12:13:50 +0000 |
| commit | 4d94dfdf5171220e62511e48de6f36b97d5eadfb (patch) | |
| tree | f96aa3c6cfb7db5c2b2d45915c0e14778d2e6e81 /plex.pls | |
| parent | 7d0906c0b1eb4df0a66371268317e07802abaa2b (diff) | |
Diffstat (limited to 'plex.pls')
| -rw-r--r-- | plex.pls | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -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 +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 ". |
