Read-only mode support
authorJamie Cameron <jcameron@webmin.com>
Sat, 24 Nov 2007 00:22:56 +0000 (00:22 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sat, 24 Nov 2007 00:22:56 +0000 (00:22 +0000)
21 files changed:
lpadmin/caldera-driver.pl
lpadmin/cluster_add.cgi
lpadmin/cups-driver.pl
lpadmin/cups-lib.pl
lpadmin/freebsd-lib.pl
lpadmin/hpux-driver.pl
lpadmin/hpux-lib.pl
lpadmin/index.cgi
lpadmin/irix-driver.pl
lpadmin/irix-lib.pl
lpadmin/lang/en
lpadmin/linux-lib.pl
lpadmin/lpadmin-lib.pl
lpadmin/lprng-lib.pl
lpadmin/module.info
lpadmin/redhat-driver.pl
lpadmin/solaris-lib.pl
lpadmin/suse-driver.pl
lpadmin/test_print.cgi
lpadmin/unixware-lib.pl
lpadmin/view_job.cgi

index 5aa61d1..9e9ce76 100644 (file)
@@ -174,7 +174,7 @@ else {
        &lock_file($drv);
        if ($gconfig{'os_version'} >= 2.4) {
                # Create the 2.4 driver program
-               system("cp $base_driver $drv");
+               &copy_source_dest($base_driver, $drv);
                }
        else {
                # Create the 2.3 driver program
index 07ec295..56da0db 100755 (executable)
@@ -34,7 +34,7 @@ $add_error_msg = join("", @_);
 }
 &remote_error_setup(\&add_error);
 
-# Make sure each host is set up for firewalling
+# Make sure each host is set up for printer administration
 foreach $s (@add) {
        $add_error_msg = undef;
        local $host = { 'id' => $s->{'id'} };
@@ -60,7 +60,8 @@ foreach $s (@add) {
                next;
                }
 
-       @printers = &remote_foreign_call($s->{'host'}, "lpadmin", "list_printers");
+       @printers = &remote_foreign_call($s->{'host'}, "lpadmin",
+                                        "list_printers");
        print &text('add_ok', $s->{'host'}, scalar(@printers)),"<p>\n";
        &add_cluster_server($s);
        }
index 292ba0c..783e76e 100644 (file)
@@ -132,9 +132,11 @@ printf "<td><input name=program size=40 value='%s'></td> </tr>\n",
 printf "<tr> <td valign=top><input type=radio name=mode value=1 %s> %s</td>\n",
        $_[1]->{'mode'} == 1 ? 'checked' : '', $text{'cups_driver'};
 local (@ppds, $d, $f, $ppd, %cache, $outofdate, @files, %donefile);
-local $findver = `find --version 2>&1`;
-local $flag = $findver =~ /GNU\s+find\s+version\s+4\.2/i ? "-L" : "";
-open(FIND, "find $flag ".quotemeta($config{'model_path'})." -type f -print |");
+local $findver = &backquote_command("find --version 2>&1", 1);
+local $flag = $findver =~ /GNU\s+find\s+version\s+([0-9\.]+)/i && $1 >= 4.2 ?
+               "-L" : "";
+&open_execute_command(FIND, "find $flag ".quotemeta($config{'model_path'}).
+                           " -type f -print", 1, 1);
 while(<FIND>) {
        chop;
        /([^\/]+)$/;
index 57f195a..13602e1 100644 (file)
@@ -27,7 +27,7 @@ sub get_printer
 {
 local($stat, @rv, $body, $avl, $con, $sys, %prn, $_, $out);
 local $esc = quotemeta($_[0]);
-$out = `$lpstat -l -p $esc`;
+$out = &backquote_command("$lpstat -l -p $esc", 1);
 return undef if ($out =~ /non-existent\s+printer/);
 if ($out =~ /^printer\s+(\S+)\s+(\S+).*\n([\000-\377]*)$/) {
        # printer exists..
@@ -51,7 +51,7 @@ else { $prn{'banner'} = 1; }
 
 if (!$_[1]) {
        # request availability
-       $avl = `$lpstat -a $prn{'name'} 2>&1`;
+       $avl = &backquote_command("$lpstat -a $prn{'name'} 2>&1", 1);
        if ($avl =~ /^\S+\s+not accepting.*\n\s*(.*)/) {
                $prn{'accepting'} = 0;
                $prn{'accepting_why'} = lc($1) eq "reason unknown" ? "" : $1;
@@ -77,7 +77,7 @@ foreach my $file ("/etc/printers.conf", "/etc/cups/printers.conf") {
                }
        }
 if (!$uri) {
-       $con = `$lpstat -v $prn{'name'} 2>&1`;
+       $con = &backquote_command("$lpstat -v $prn{'name'} 2>&1", 1);
        if ($con =~ /^device for \S+:\s+(\S+)/) {
                $uri = $1;
                }
@@ -107,8 +107,10 @@ else {
        }
 
 # Check if this is the default printer
-`$lpstat -d 2>&1` =~ /destination: (\S+)/;
-if ($1 eq $prn{'name'}) { $prn{'default'} = 1; }
+if (&backquote_command("$lpstat -d 2>&1", 1) =~ /destination:\s+(\S+)/ &&
+    $1 eq $prn{'name'}) {
+       $prn{'default'} = 1;
+       }
 
 return \%prn;
 }
@@ -158,7 +160,7 @@ return $_[0] !~ /^(msize|alias|rnoqueue|ctype|sysv|allow)$/;
 sub list_classes
 {
 local($stat, %rv);
-$stat = `$lpstat -c 2>&1`;
+$stat = &backquote_command("$lpstat -c 2>&1", 1);
 while($stat =~ /^members of class (\S+):\n((\s+\S+\n)+)([\000-\377]*)$/) {
        $stat = $4;
        $rv{$1} = [ grep { $_ ne "" } split(/\s+/, $2) ];
index 7c4b9de..e4a83b6 100644 (file)
@@ -35,7 +35,7 @@ foreach $l (&list_printcap()) {
                if (!$_[1]) {
                        # call lpc to get status
                        local $esc = quotemeta($prn{'name'});
-                       $out = `lpc status $esc 2>&1`;
+                       $out = &backquote_command("lpc status $esc 2>&1", 1);
                        $prn{'accepting'} = ($out =~ /queuing is enabled/);
                        $prn{'enabled'} = ($out =~ /printing is enabled/);
                        }
@@ -227,7 +227,7 @@ sub apply_status
 {
 local($out);
 local $esc = quotemeta($_[0]->{'name'});
-$out = `lpc status $esc 2>&1`;
+$out = &backquote_command("lpc status $esc 2>&1", 1);
 if ($_[0]->{'enabled'} && $out !~ /printing is enabled/)
        { &backquote_logged("lpc up $esc"); }
 elsif (!$_[0]->{'enabled'} && $out =~ /printing is enabled/)
index dac538c..5d8808c 100644 (file)
@@ -63,7 +63,7 @@ closedir(DIR);
 print "</select></td> </tr>\n";
 
 if (&has_ghostscript()) {
-       local $out = `$config{'gs_path'} -help 2>&1`;
+       local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
        if ($out =~ /Available devices:\n((\s+.*\n)+)/) {
                print "<tr> <td valign=top>\n";
                printf "<input type=radio name=drv value=1 %s>\n",
index edeb14c..b596c8b 100644 (file)
@@ -15,7 +15,7 @@ while(<STAT>) {
 close(STAT);
 
 # make models executable
-`chmod 755 $config{'model_path'}/*`;
+&system_logged("chmod 755 $config{'model_path'}/* >/dev/null 2>&1");
 
 return &unique(@rv);
 }
@@ -26,7 +26,7 @@ sub get_printer
 {
 local($stat, @rv, $body1, $body2, $avl, $con, $sys, %prn, $_, $out);
 local $esc = quotemeta($_[0]);
-$out = `lpstat -p$esc`;
+$out = &backquote_command("lpstat -p$esc", 1);
 if ($out =~ /^printer\s+(\S+)\s+(.*)\n(.*)\n(.*)$/) {
        # printer exists
        $prn{'name'} = $1;
@@ -56,7 +56,7 @@ if (!$prn{'enabled'} && $body1 =~ /^\s+(.*)/) {
 
 if (!$_[1]) {
        # request availability
-       $avl = `lpstat -a$esc 2>&1`;
+       $avl = &backquote_command("lpstat -a$esc 2>&1", 1);
        if ($avl =~ /^\S+\s+not accepting.*\n\s+(.*)/) {
                $prn{'accepting'} = 0;
                $prn{'accepting_why'} = $1;
@@ -68,7 +68,7 @@ if (!$_[1]) {
        }
 
 # request connection
-$con = `lpstat -v$esc 2>&1`;
+$con = &backquote_command("lpstat -v$esc 2>&1", 1);
 if ($con =~ /^device for \S+:\s+(\S+)\n\s+(remote to:)\s+(\S+)\s+(on)\s+(\S+)/) {
        $prn{'rhost'} = $5;
        $prn{'rqueue'} = $3;
@@ -76,8 +76,10 @@ if ($con =~ /^device for \S+:\s+(\S+)\n\s+(remote to:)\s+(\S+)\s+(on)\s+(\S+)/)
 elsif ($con =~ /^device for \S+:\s+(\S+)/) { $prn{'dev'} = $1; }
 
 # Check if this is the default printer
-`lpstat -d 2>&1` =~ /destination: (\S+)/;
-if ($1 eq $prn{'name'}) { $prn{'default'} = 1; }
+if (&backquote_command("$lpstat -d 2>&1", 1) =~ /destination:\s+(\S+)/ &&
+    $1 eq $prn{'name'}) {
+       $prn{'default'} = 1;
+       }
 
 return \%prn;
 }
@@ -130,7 +132,7 @@ if ($drv->{'mode'} == 1) {
        $desc = $drv->{'desc'};
        }
 elsif ($drv->{'mode'} == 2) {
-       $out = `head $drv->{'prog'} | grep -e interface  -e Printer -e /model/`;
+       $out = &backquote_command("head $drv->{'prog'} | grep -e interface -e Printer -e /model/", 1);
        if ($out =~ /interface for\s+(.*)/) { $desc = $1; }
        elsif ($out =~ /\s+(\S.*)interface/) { $desc = $1; }
        elsif ($out =~ /Printer Command Language level\s+(\S+)/) { $desc = "PCL$1"; }
@@ -155,7 +157,7 @@ return $_[0] !~ /^(allow|alias|ctype|banner|desc|editdest|msize|direct|rnoqueue|
 sub list_classes
 {
 local($stat, %rv);
-$stat = `lpstat -c 2>&1`;
+$stat = &backquote_command("lpstat -c 2>&1", 1);
 while($stat =~ /^members of class (\S+):\n((\s+\S+\n)+)([\000-\377]*)$/) {
        $stat = $4;
        $rv{$1} = [ grep { $_ ne "" } split(/\s+/, $2) ];
@@ -172,7 +174,8 @@ local(%prn, $cmd, $out, $model, $dummy, $scheduler);
 local $wdrv = &is_windows_driver($prn{'iface'});
 local $hdrv = &is_hpnp_driver($prn{'iface'});
 $scheduler = &sched_running();
-$dummy = "webmin.tmp"; `touch $config{'model_path'}/$dummy`;
+$dummy = "webmin.tmp";
+&system_logged("touch $config{'model_path'}/$dummy");
 
 # create lpadmin command
 local $esc = quotemeta($prn{'name'});
@@ -237,24 +240,28 @@ if ($?) { &error("lpsched failed : <pre>$out</pre>"); }
 ## Link to windows webmin driver
 &lock_file("$hpux_iface_path/$prn{'name'}");
 if ($wdrv) {
-       `rm $hpux_iface_path/$esc`;
-       `ln -s $drivers_directory/$esc.smb $hpux_iface_path/$esc`;
+       &unlink_file("$hpux_iface_path/$prn{'name'}");
+       &symlink_file("$drivers_directory/$prn{'name'}.smb",
+                       "$hpux_iface_path/$prn{'name'}");
        }
 
 ## Link to webmin hpnp driver
 if ($hdrv) {
-       `rm $hpux_iface_path/$esc`;
-       `ln -s $drivers_directory/$esc.hpnp $hpux_iface_path/$esc`;
+       &unlink_file("$hpux_iface_path/$prn{'name'}");
+       &symlink_file("$drivers_directory/$prn{'name'}.hpnp",
+                       "$hpux_iface_path/$prn{'name'}");
        }
 
 ## Link to webmin driver
 if ($prn{'iface'} eq "$drivers_directory/$prn{'name'}" && !$wdrv) {
-       `rm $hpux_iface_path/$esc`;
-       `ln -s $drivers_directory/$esc $hpux_iface_path/$esc`;
+       &unlink_file("$hpux_iface_path/$prn{'name'}");
+       &symlink_file("$drivers_directory/$prn{'name'}",
+                       "$hpux_iface_path/$prn{'name'}");
        }
 &unlock_file("$hpux_iface_path/$prn{'name'}");
+
 &lock_file("$config{'model_path'}/$dummy");
-`rm $config{'model_path'}/$dummy`;
+&unlink_file("$config{'model_path'}/$dummy");
 &unlock_file("$config{'model_path'}/$dummy");
 
 # start scheduler
@@ -340,7 +347,7 @@ sleep(1);
 # Returns 1 if running and 0 if not running
 sub sched_running
 {
-local $out = `lpstat -r 2>&1`;
+local $out = &backquote_command("lpstat -r 2>&1", 1);
 if ($out =~ /not/) { return 0; }
 else { return 1; }
 }
index d65a470..8e3dda3 100755 (executable)
@@ -212,7 +212,7 @@ if (&foreign_check("servers")) {
        }
 if ($access{'cluster'} && @allservers) {
        print &ui_buttons_row("cluster.cgi",
-                             $text{'index_cluster'}, $text{'index_clusterdesc'});
+                     $text{'index_cluster'}, $text{'index_clusterdesc'});
        }
 
 print &ui_buttons_end();
index bcfd35c..6c5b45d 100644 (file)
@@ -63,7 +63,7 @@ closedir(DIR);
 print "</select></td> </tr>\n";
 
 if (&has_ghostscript()) {
-       local $out = `$config{'gs_path'} -help 2>&1`;
+       local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
        if ($out =~ /Available devices:\n((\s+.*\n)+)/) {
                print "<tr> <td valign=top>\n";
                printf "<input type=radio name=drv value=1 %s>\n",
index da8704d..1257162 100644 (file)
@@ -22,7 +22,7 @@ sub get_printer
 {
 local($stat, @rv, $body, $body, $avl, $con, $sys, %prn, $_, $out);
 local $esc = quotemeta($_[0]);
-$out = `/usr/bin/lpstat -p$esc`;
+$out = &backquote_command("/usr/bin/lpstat -p$esc", 1);
 if ($out =~ /^printer\s+(\S+)\s*(.*)\s+(enabled|disabled)\s+since\s+(.+?)\n?(.*)?$/) {
        # printer exists
        $prn{'name'} = $1;
@@ -51,7 +51,7 @@ if (!$prn{'enabled'} && $body =~ /^\s+(.*)/) {
 
 if (!$_[1]) {
        # request availability
-       $avl = `/usr/bin/lpstat -a$esc 2>&1`;
+       $avl = &backquote_command("/usr/bin/lpstat -a$esc 2>&1", 1);
        if ($avl =~ /^\S+\s+not accepting.*\n\s+(.*)/) {
                $prn{'accepting'} = 0;
                $prn{'accepting_why'} = $1;
@@ -63,7 +63,7 @@ if (!$_[1]) {
        }
 
 # request connection
-$con = `/usr/bin/lpstat -v$esc 2>&1`;
+$con = &backquote_command("/usr/bin/lpstat -v$esc 2>&1", 1);
 if ($con =~ /^device for \S+:\s+(\S+)\n\s+(remote to:)\s+(\S+)\s+(on)\s+(\S+)/) {
        $prn{'rhost'} = $5;
        $prn{'rqueue'} = $3;
@@ -71,8 +71,10 @@ if ($con =~ /^device for \S+:\s+(\S+)\n\s+(remote to:)\s+(\S+)\s+(on)\s+(\S+)/)
 elsif ($con =~ /^device for \S+:\s+(\S+)/) { $prn{'dev'} = $1; }
 
 # Check if this is the default printer
-`/usr/bin/lpstat -d 2>&1` =~ /destination: (\S+)/;
-if ($1 eq $prn{'name'}) { $prn{'default'} = 1; }
+if (&backquote_command("$lpstat -d 2>&1", 1) =~ /destination:\s+(\S+)/ &&
+    $1 eq $prn{'name'}) {
+       $prn{'default'} = 1;
+       }
 
 return \%prn;
 }
@@ -120,7 +122,7 @@ if ($drv->{'mode'} == 1) {
        $desc = $drv->{'desc'};
        }
 elsif ($drv->{'mode'} == 2) {
-       $out = `head $drv->{'prog'} | grep -e interface  -e Printer -e /model/`;
+       $out = &backquote_command("head $drv->{'prog'} | grep -e interface -e Printer -e /model/", 1);
        if ($out =~ /interface for\s+(.*)/) { $desc = $1; }
        elsif ($out =~ /\s+(\S.*)interface/) { $desc = $1; }
        elsif ($out =~ /Printer Command Language level\s+(\S+)/) { $desc = "PCL$1"; }
@@ -145,7 +147,7 @@ return $_[0] !~ /^(allow|alias|ctype|banner|desc|editdest|msize|direct|rnoqueue|
 sub list_classes
 {
 local($stat, %rv);
-$stat = `/usr/bin/lpstat -c 2>&1`;
+$stat = &backquote_command("/usr/bin/lpstat -c 2>&1", 1);
 while($stat =~ /^members of class (\S+):\n((\s+\S+\n)+)([\000-\377]*)$/) {
        $stat = $4;
        $rv{$1} = [ grep { $_ ne "" } split(/\s+/, $2) ];
@@ -214,7 +216,7 @@ $out = &backquote_logged("$cmd 2>&1");
 if ($?) { &error("lpadmin failed : <pre>$out</pre>"); }
 
 if ($prn{'rhost'}) {
-  `rm $irix_iface_path/$esc.tmp`;
+  &unlink_file("$irix_iface_path/$prn{'name'}.tmp");
 }
 
 ## Link to windows webmin driver
@@ -358,7 +360,7 @@ sleep(1);
 # Returns 1 if running and 0 if not running
 sub sched_running
 {
-local $out = `lpstat -r 2>&1`;
+local $out = &backquote_command("lpstat -r 2>&1", 1);
 if ($out =~ /not/) { return 0; }
 else { return 1; }
 }
index 5af85fb..0dfc5e1 100644 (file)
@@ -118,6 +118,7 @@ jobs_bytes=bytes
 jobs_test=Print Test Page
 jobs_cancelsel=Cancel Selected Jobs
 jobs_on=On printer $1
+jobs_return=list of print jobs
 
 cancel_ecannot=You are not allowed to cancel print jobs
 cancel_err=Failed to cancel print job
index d8c294f..a2d4dd4 100644 (file)
@@ -36,7 +36,7 @@ foreach $l (&list_printcap()) {
                if (!$_[1]) {
                        # call lpc to get status
                        local $esc = quotemeta($prn{'name'});
-                       $out = `lpc status $esc 2>&1`;
+                       $out = &backquote_command("lpc status $esc 2>&1", 1);
                        $prn{'accepting'} = ($out =~ /queuing is enabled/);
                        $prn{'enabled'} = ($out =~ /printing is enabled/);
                        }
@@ -274,7 +274,7 @@ sub apply_status
 {
 local($out);
 local $esc = quotemeta($_[0]->{'name'});
-$out = `lpc status $esc 2>&1`;
+$out = &backquote_command("lpc status $esc 2>&1", 1);
 if ($_[0]->{'enabled'} && $out !~ /printing is enabled/)
        { &backquote_logged("lpc up $esc"); }
 elsif (!$_[0]->{'enabled'} && $out =~ /printing is enabled/)
index 981d7b4..8416e98 100644 (file)
@@ -339,7 +339,7 @@ printf "<td><input name=iface value=\"%s\" size=35></td> </tr>\n",
        $drv->{'mode'} == 2 ? $drv->{'prog'} : "";
 
 if (&has_ghostscript()) {
-       local $out = `$config{'gs_path'} -help 2>&1`;
+       local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
        if ($out =~ /Available devices:\n((\s+.*\n)+)/i) {
                print "<tr> <td valign=top>\n";
                printf "<input type=radio name=drv value=1 %s>\n",
@@ -475,7 +475,7 @@ return 0;
 sub list_uniprint
 {
 local (@rv, $f, $d);
-local $out = `$config{'gs_path'} -help 2>&1`;
+local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
 if ($out =~ /Search path:\n((\s+.*\n)+)/i) {
        foreach $d (split(/\s+/, $1)) {
                next if ($d !~ /^\//);
@@ -582,6 +582,7 @@ return $_[0]->{'desc'} ? $_[0]->{'desc'} : $_[0]->{'host'};
 sub save_on_cluster
 {
 return ( ) if (!$config{'servers'});
+return ( ) if (&is_readonly_mode());
 local ($new, $prn, $drv, $conn, $webmin, $mode) = @_;
 &remote_error_setup(\&slave_error_handler);
 local $slave;
@@ -621,6 +622,7 @@ return @slaveerrs;
 sub delete_on_cluster
 {
 return ( ) if (!$config{'servers'});
+return ( ) if (&is_readonly_mode());
 local ($prn) = @_;
 &remote_error_setup(\&slave_error_handler);
 local $slave;
index b4a9e28..6cdc829 100644 (file)
@@ -46,7 +46,7 @@ foreach $l (&list_printcap()) {
                if (!$_[1]) {
                        # call lpc to get status
                        local $esc = quotemeta($prn{'name'});
-                       $out = `lpc -P$esc status 2>&1`;
+                       $out = &backquote_command("lpc -P$esc status 2>&1", 1);
                        if ($out =~ /\n(\S+)\s+(\S+)\s+(\S+)/) {
                                $prn{'accepting'} = $3 eq 'enabled';
                                $prn{'enabled'} = $2 eq 'enabled';
@@ -338,7 +338,7 @@ else {
 # Returns the pid if lpsched is running, 0 if not, -1 if cannot be stopped
 sub sched_running
 {
-local $out = `lpc lpd all 2>&1`;
+local $out = &backquote_command("lpc lpd all 2>&1", 1);
 return $out =~ /pid\s+(\d+)/ ? $1 : 0;
 }
 
index d7e0ab8..4b05ddd 100644 (file)
@@ -24,3 +24,4 @@ desc_zh_TW.UTF-8=印表機管理者
 desc_zh_CN.UTF-8=打印机管理
 desc_ja_JP.UTF-8=プリンタ管理
 desc_ko_KR.UTF-8=프린터 관리
+readonly=1
index 7e7bfed..f3d4d6a 100644 (file)
@@ -197,7 +197,7 @@ else {
        # copy the standard filter into place
        &lock_file("$sd/filter");
        unlink("$sd/filter");
-       system("cp $base_driver $sd/filter");
+       &copy_source_dest("$base_driver", "$sd/filter");
        &unlock_file("$sd/filter");
        return "$sd/filter";
        }
index 62d90fa..76af98d 100755 (executable)
@@ -46,7 +46,7 @@ sub get_printer
 {
 local($stat, @rv, $body, $avl, $con, $sys, %prn, $_, $out);
 local $esc = quotemeta($_[0]);
-$out = `lpstat -l -p $esc`;
+$out = &backquote_command("lpstat -l -p $esc", 1);
 if ($out =~ /^printer\s+(\S+)\s*(.*)\s+(enabled|disabled)\s+since\s+([^\.]*)\.\s+(.*)\.\n([\000-\377]*)$/) {
        # printer exists
        $prn{'name'} = $1;
@@ -97,7 +97,7 @@ if ($body =~ /PPD:\s+(\S+)/ && $1 ne "none" && $1 ne "/dev/null") {
 
 if (!$_[1]) {
        # request availability
-       $avl = `lpstat -a $esc 2>&1`;
+       $avl = &backquote_command("lpstat -a $esc 2>&1", 1);
        if ($avl =~ /^\S+\s+not accepting.*\n\s+(.*)/) {
                $prn{'accepting'} = 0;
                $prn{'accepting_why'} = $1;
@@ -109,7 +109,7 @@ if (!$_[1]) {
        }
 
 # request connection
-$con = `lpstat -v $esc 2>&1`;
+$con = &backquote_command("lpstat -v $esc 2>&1", 1);
 if ($con =~ /^device for \S+:\s+(\S+)/) {
        # Prints to a local file
        $prn{'dev'} = $1;
@@ -131,14 +131,15 @@ elsif ($con =~ /^system for \S+:\s+(\S+)\s+\(as printer (\S+)\)/ ||
        # Prints to a remote server
        $prn{'rhost'} = $1;
        $prn{'rqueue'} = $2 || $prn{'name'};
-       $sys = `lpsystem -l $prn{'rhost'} 2>&1`;
+       $sys = &backquote_command("lpsystem -l $prn{'rhost'} 2>&1", 1);
        $sys =~ /Type:\s+(\S+)/; $prn{'rtype'} = $1;
        }
 
 # Check if this is the default printer
 if (!defined($default_printer)) {
-       `lpstat -d 2>&1` =~ /destination: (\S+)/;
-       $default_printer = $1;
+       if (&backquote_command("lpstat -d 2>&1", 1) =~ /destination:\s+(\S+)/) {
+               $default_printer = $1;
+               }
        }
 if ($default_printer eq $prn{'name'}) { $prn{'default'} = 1; }
 
@@ -212,7 +213,7 @@ return $_[0] !~ /^(msize|alias|riface|rnoqueue|ipp)$/;
 sub list_classes
 {
 local($stat, %rv);
-$stat = `lpstat -c 2>&1`;
+$stat = &backquote_command("lpstat -c 2>&1", 1);
 while($stat =~ /^members of class (\S+):\n((\s+\S+\n)+)([\000-\377]*)$/) {
        $stat = $4;
        $rv{$1} = [ grep { $_ ne "" } split(/\s+/, $2) ];
@@ -322,10 +323,10 @@ if ($prn{'default'}) {
        }
 
 # Build filter table 
-open(STAT, "/usr/bin/ls -1 /etc/lp/fd/*.fd |");
+&open_execute_command(STAT, "/usr/bin/ls -1 /etc/lp/fd/*.fd", 1, 1);
 while(<STAT>) {
        $file = substr($_, rindex($_, "/") +1, -4 );
-       `/usr/sbin/lpfilter -f $file -F /etc/lp/fd/$file.fd`;
+       &system_logged("/usr/sbin/lpfilter -f $file -F /etc/lp/fd/$file.fd");
         }
 close(STAT);
 
index 58e670e..99d2ecc 100644 (file)
@@ -154,7 +154,7 @@ else {
        &unlock_file($aps);
        if (!-r "$apsfilter_base.$device") {
                &lock_file("$apsfilter_base.$device");
-               local $conf = `cat $apsfilter_config`;
+               local $conf = &read_file_contents($apsfilter_config);
                $conf =~ s/<gs_device_name>/$device/g;
                &open_tempfile(CONF, ">$apsfilter_base.$device");
                &print_tempfile(CONF, $conf);
@@ -202,7 +202,7 @@ if ($drv->{'mode'} == 2 || 1) {
                        $u, $drv->{'device'} eq $u ? 'selected' : '', $d->[1];
                $found++ if ($drv->{'device'} eq $u);
                }
-       local $out = `$config{'gs_path'} -help 2>&1`;
+       local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
        $out =~ /Available devices:\n((\s+.*\n)+)/i;
        foreach $d (split(/\s+/, $1)) {
                if ($driver{$d}) {
@@ -255,7 +255,7 @@ else {
        printf "<option value=ps %s>Postscript\n",
                $drv->{'device'} eq 'PS' ? 'selected' : '';
        $found++ if ($drv->{'device'} eq 'PS');
-       local $out = `$config{'gs_path'} -help 2>&1`;
+       local $out = &backquote_command("$config{'gs_path'} -help 2>&1", 1);
        $out =~ /Available devices:\n((\s+.*\n)+)/i;
        foreach $d (split(/\s+/, $1)) {
                if ($d ne 'stp' && $driver{$d}) {
index cc45802..cdc5f90 100755 (executable)
@@ -20,23 +20,25 @@ elsif ($in{'mode'} == 2) {
        }
 else {
        $file = &transname();
-       open(FILE, ">$file");
-       print FILE $in{'file'};
-       close(FILE);
+       &open_tempfile(FILE, ">$file", 0, 1);
+       &print_tempfile(FILE, $in{'file'});
+       &close_tempfile(FILE);
        }
 
 $cmd = &print_command($in{'name'}, $file);
-print &text('test_exec', "<tt>$cmd</tt>"),"<br>\n";
-print "<pre>";
 if ($access{'user'} eq '*') {
-       open(CMD, "$cmd 2>&1 |");
+       # Run as root
        }
 elsif ($access{'user'}) {
-       open(CMD, "su '$access{'user'}' -c '$cmd' 2>&1 |");
+       $cmd = &command_as_user($access{'user'}, 0, $cmd);
        }
 else {
-       open(CMD, "su '$remote_user' -c '$cmd' 2>&1 |");
+       $cmd = &command_as_user($remote_user, 0, $cmd);
        }
+
+print &text('test_exec', "<tt>$cmd</tt>"),"<br>\n";
+print "<pre>";
+&open_execute_command(CMD, $cmd, 1);
 while(<CMD>) {
        print;
        }
@@ -47,5 +49,7 @@ if ($?) { print "<b>$text{'test_failed'}</b> <p>\n"; }
 else { print "$text{'test_ok'} <p>\n"; }
 
 unlink($file) if ($in{'mode'} == 3);
-&ui_print_footer("", $text{'index_return'});
+&ui_print_footer("list_jobs.cgi?name=".&urlize($in{'name'}),
+                 $text{'jobs_return'},
+                "", $text{'index_return'});
 
index 82f5b22..76fdfde 100644 (file)
@@ -192,11 +192,11 @@ $cmd = "lpadmin -p $esc -D $desc";
 if ($prn{'allow_all'}) { $cmd .= " -u allow:all"; }
 elsif ($prn{'deny_all'}) { $cmd .= " -u deny:all"; }
 elsif ($prn{'allow'}) {
-       system("lpadmin -p $esc -u deny:all >/dev/null 2>&1");
+       &system_logged("lpadmin -p $esc -u deny:all >/dev/null 2>&1");
        $cmd .= " -u allow:".join(',', map { quotemeta($_) } @{$prn{'allow'}});
        }
 elsif ($prn{'deny'}) {
-       system("lpadmin -p $esc -u allow:all >/dev/null 2>&1");
+       &system_logged("lpadmin -p $esc -u allow:all >/dev/null 2>&1");
        $cmd .= " -u deny:".join(',', map { quotemeta($_) } @{$prn{'deny'}});
        }
 if ($prn{'dev'}) {
index 5603298..22d77ff 100755 (executable)
@@ -14,7 +14,7 @@ foreach $j (@jobs) {
 if ($job) {
        # print job exists.. dump it
        @pf = @{$job->{'printfile'}};
-       $type = `file $pf[0]`;
+       $type = &backquote_command("file ".quotemeta($pf[0]), 1);
        if ($type =~ /postscript/i) {
                print "Content-type: application/postscript\n";
                }