X7ROOT File Manager
Current Path:
/usr/libexec/webmin/lpadmin
usr
/
libexec
/
webmin
/
lpadmin
/
📁
..
📄
CHANGELOG
(1.16 KB)
📄
acl_security.pl
(4.4 KB)
📄
aix-lib.pl
(9.45 KB)
📄
ascii.txt
(4.19 KB)
📄
base_coas_driver
(560 B)
📄
bw.fig
(2.75 KB)
📄
bw.ps
(6.46 KB)
📄
caldera-driver.pl
(12.31 KB)
📄
cancel_all.cgi
(535 B)
📄
catalog.devices
(12.34 KB)
📄
cgi_args.pl
(284 B)
📄
cluster.cgi
(2.06 KB)
📄
cluster_add.cgi
(2.13 KB)
📄
cluster_delete.cgi
(529 B)
📄
colour.fig
(2.91 KB)
📄
colour.ps
(6.63 KB)
📄
config-AlmaLinux-7.0-ALL
(323 B)
📄
config-Amazon-Linux-2-ALL
(323 B)
📄
config-CentOS-Linux-7.0-ALL
(323 B)
📄
config-CentOS-Stream-Linux-8.0-ALL
(323 B)
📄
config-Oracle-Linux-8.0-ALL
(323 B)
📄
config-Redhat-Enterprise-Linux-7.0-ALL
(323 B)
📄
config-Rocky-Linux-7.0-ALL
(323 B)
📄
config-Scientific-Linux-7.0-ALL
(323 B)
📄
config-aix
(281 B)
📄
config-coherent-linux
(323 B)
📄
config-corel-linux
(228 B)
📄
config-debian-linux
(228 B)
📄
config-debian-linux-3.1-3.9
(327 B)
📄
config-debian-linux-4.0-ALL
(333 B)
📄
config-freebsd
(230 B)
📄
config-generic-linux
(228 B)
📄
config-gentoo-linux
(248 B)
📄
config-hpux
(323 B)
📄
config-irix
(213 B)
📄
config-macos
(230 B)
📄
config-mandrake-linux
(245 B)
📄
config-mandrake-linux-8.0-ALL
(276 B)
📄
config-msc-linux
(228 B)
📄
config-netbsd
(230 B)
📄
config-open-linux
(309 B)
📄
config-open-linux-3.1e
(239 B)
📄
config-openbsd
(230 B)
📄
config-openmamba-linux
(229 B)
📄
config-pardus-linux
(228 B)
📄
config-redhat-linux
(228 B)
📄
config-redhat-linux-24.0-ALL
(339 B)
📄
config-redhat-linux-7.0
(283 B)
📄
config-redhat-linux-7.1
(286 B)
📄
config-redhat-linux-7.2-8.1
(394 B)
📄
config-redhat-linux-9.0-23.0
(337 B)
📄
config-slackware-linux
(228 B)
📄
config-slackware-linux-8.1-ALL
(246 B)
📄
config-solaris
(304 B)
📄
config-solaris-10-ALL
(330 B)
📄
config-solaris-9
(296 B)
📄
config-suse-linux
(226 B)
📄
config-suse-linux-8.2-ALL
(322 B)
📄
config-trustix-linux
(313 B)
📄
config-turbo-linux
(228 B)
📄
config-united-linux
(322 B)
📄
config-unixware
(302 B)
📄
config.info
(1.31 KB)
📄
config.info.ca
(1.53 KB)
📄
config.info.cs
(1.25 KB)
📄
config.info.de
(1.43 KB)
📄
config.info.es
(1.17 KB)
📄
config.info.fr
(1.63 KB)
📄
config.info.hu
(707 B)
📄
config.info.ja
(823 B)
📄
config.info.nl
(1.41 KB)
📄
config.info.no
(1.37 KB)
📄
config.info.pl
(1.45 KB)
📄
config.info.pt_BR
(1.58 KB)
📄
config.info.ru
(1.74 KB)
📄
config.info.sv
(651 B)
📄
config.info.tr
(1.39 KB)
📄
config.info.uk
(1.81 KB)
📄
config.info.zh
(573 B)
📄
config.info.zh_TW
(539 B)
📄
cups-driver.pl
(6.37 KB)
📄
cups-lib.pl
(8.67 KB)
📄
defaultacl
(73 B)
📄
delete_printer.cgi
(690 B)
📄
delete_printers.cgi
(839 B)
📄
drivers
(18.34 KB)
📄
edit_printer.cgi
(10.08 KB)
📄
freebsd-lib.pl
(7.26 KB)
📄
hpux-driver.pl
(3.13 KB)
📄
hpux-lib.pl
(9.83 KB)
📁
images
📄
index.cgi
(5.83 KB)
📄
irix-driver.pl
(3.13 KB)
📄
irix-lib.pl
(10.68 KB)
📁
lang
📄
linux-lib.pl
(8.97 KB)
📄
list_jobs.cgi
(2.25 KB)
📄
log_parser.pl
(1021 B)
📄
lpadmin-lib.pl
(19.89 KB)
📄
lprng-lib.pl
(10.26 KB)
📄
module.info
(494 B)
📄
module.info.af
(0 B)
📄
module.info.af.auto
(159 B)
📄
module.info.ar
(0 B)
📄
module.info.ar.auto
(223 B)
📄
module.info.be
(0 B)
📄
module.info.be.auto
(290 B)
📄
module.info.bg
(0 B)
📄
module.info.bg.auto
(306 B)
📄
module.info.ca
(167 B)
📄
module.info.ca.auto
(16 B)
📄
module.info.cs
(31 B)
📄
module.info.cs.auto
(155 B)
📄
module.info.da
(0 B)
📄
module.info.da.auto
(168 B)
📄
module.info.de
(148 B)
📄
module.info.de.auto
(16 B)
📄
module.info.el
(0 B)
📄
module.info.el.auto
(362 B)
📄
module.info.es
(38 B)
📄
module.info.es.auto
(157 B)
📄
module.info.eu
(0 B)
📄
module.info.eu.auto
(217 B)
📄
module.info.fa
(0 B)
📄
module.info.fa.auto
(246 B)
📄
module.info.fi
(0 B)
📄
module.info.fi.auto
(168 B)
📄
module.info.fr
(39 B)
📄
module.info.fr.auto
(176 B)
📄
module.info.he
(0 B)
📄
module.info.he.auto
(205 B)
📄
module.info.hr
(0 B)
📄
module.info.hr.auto
(188 B)
📄
module.info.hu
(19 B)
📄
module.info.hu.auto
(173 B)
📄
module.info.it
(0 B)
📄
module.info.it.auto
(177 B)
📄
module.info.ja
(27 B)
📄
module.info.ja.auto
(213 B)
📄
module.info.ko
(25 B)
📄
module.info.ko.auto
(176 B)
📄
module.info.lt
(0 B)
📄
module.info.lt.auto
(219 B)
📄
module.info.lv
(0 B)
📄
module.info.lv.auto
(189 B)
📄
module.info.ms
(152 B)
📄
module.info.ms.auto
(16 B)
📄
module.info.mt
(0 B)
📄
module.info.mt.auto
(196 B)
📄
module.info.nl
(33 B)
📄
module.info.nl.auto
(133 B)
📄
module.info.no
(31 B)
📄
module.info.no.auto
(137 B)
📄
module.info.pl
(160 B)
📄
module.info.pl.auto
(16 B)
📄
module.info.pt
(39 B)
📄
module.info.pt.auto
(149 B)
📄
module.info.pt_BR
(42 B)
📄
module.info.pt_BR.auto
(155 B)
📄
module.info.ro
(0 B)
📄
module.info.ro.auto
(199 B)
📄
module.info.ru
(25 B)
📄
module.info.ru.auto
(245 B)
📄
module.info.sk
(0 B)
📄
module.info.sk.auto
(184 B)
📄
module.info.sl
(0 B)
📄
module.info.sl.auto
(192 B)
📄
module.info.sv
(30 B)
📄
module.info.sv.auto
(141 B)
📄
module.info.th
(0 B)
📄
module.info.th.auto
(393 B)
📄
module.info.tr
(27 B)
📄
module.info.tr.auto
(166 B)
📄
module.info.uk
(0 B)
📄
module.info.uk.auto
(281 B)
📄
module.info.ur
(0 B)
📄
module.info.ur.auto
(304 B)
📄
module.info.vi
(0 B)
📄
module.info.vi.auto
(189 B)
📄
module.info.zh
(24 B)
📄
module.info.zh.auto
(136 B)
📄
module.info.zh_TW
(30 B)
📄
module.info.zh_TW.auto
(142 B)
📄
old-caldera-driver.pl
(9.74 KB)
📄
openbsd-lib.pl
(7.26 KB)
📄
prefs.info
(40 B)
📄
printconf-driver.pl
(9.52 KB)
📄
rbac-mapping
(248 B)
📄
redhat-driver.pl
(12.42 KB)
📄
restart.cgi
(301 B)
📄
save_printer.cgi
(5.85 KB)
📄
solaris-driver.pl
(4.03 KB)
📄
solaris-lib.pl
(12.17 KB)
📄
sortdrivers-by-drv.pl
(222 B)
📄
sortdrivers.pl
(242 B)
📄
start.cgi
(377 B)
📄
stop.cgi
(374 B)
📄
stp
(2.45 KB)
📄
suse-driver.pl
(10.62 KB)
📄
test_form.cgi
(887 B)
📄
test_print.cgi
(1.19 KB)
📄
unixware-lib.pl
(7.81 KB)
📄
view_job.cgi
(909 B)
📄
webmin-driver.pl
(1.04 KB)
Editing: irix-lib.pl
# irix-lib.pl # Functions for irix-style printer management $irix_iface_path = "/var/spool/lp/interface"; # list_printers() # Returns an array of known printer names sub list_printers { local(@rv, $_); open(STAT, "/usr/bin/lpstat -p |"); while(<STAT>) { if (/^printer\s+(\S+)/) { push(@rv, $1); } } close(STAT); return &unique(@rv); } # get_printer(name, [nostatus]) # Returns a reference to an associative array of printer details sub get_printer { local($stat, @rv, $body, $body, $avl, $con, $sys, %prn, $_, $out); local $esc = quotemeta($_[0]); $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; $prn{'enabled'} = $3 eq "enabled"; $body = $5; } else { # no printer found return undef; } # Interface $prn{'iface'} = "$irix_iface_path/$prn{'name'}"; # Description local $wdrv = &is_windows_driver($prn{'iface'}); local $hdrv = &is_hpnp_driver($prn{'iface'}); $prn{'desc'} = $wdrv ? &grep_interface($wdrv->{'program'}) : $hdrv ? &grep_interface($hdrv->{'program'}) : &grep_interface($prn{'iface'}); # printer enabled? if (!$prn{'enabled'} && $body =~ /^\s+(.*)/) { $prn{'enabled_why'} = $1 eq "reason unknown" ? "" : $1; } if (!$_[1]) { # request availability $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; if ($prn{'accepting_why'} eq "reason unknown") { $prn{'accepting_why'} = ""; } } else { $prn{'accepting'} = 1; } } # request connection $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; } elsif ($con =~ /^device for \S+:\s+(\S+)/) { $prn{'dev'} = $1; } # Check if this is the default printer if (&backquote_command("$lpstat -d 2>&1", 1) =~ /destination:\s+(\S+)/ && $1 eq $prn{'name'}) { $prn{'default'} = 1; } return \%prn; } sub get_jobs { local @jobs; local $esc = quotemeta($_[0]); open(STAT, "/usr/bin/lpstat -o$esc |"); while(<STAT>) { if (/^(\S+-\d+)\s+(\S+)\s+(\d+)\s+(\S+ \d+ \d+:\d+)\s+(.*)/) { local(%job, $d, $f, @pf); $job{'id'} = $1; # local $id = $2; $job{'user'} = $2; $job{'size'} = $3; $job{'when'} = $4; $job{'printing'} = ($5 =~ /^on /); # if ($job{'user'} =~ /(\S+)\!/ && # -d ($d="/var/spool/lp/tmp/$1")) { # opendir(DIR, $d); # foreach $f (readdir(DIR)) { # push(@pf, "$d/$f") if ($f =~ /^$id-[1-9]/); # } # closedir(DIR); # $job{'printfile'} = @pf ? \@pf : undef; # } push(@jobs, \%job); } } close(STAT); return @jobs; } # grep_interface($iface) # try to find a description in the interface/model sub grep_interface { local($iface, $desc, $out); $iface = $_[0]; local $drv = &is_driver($iface); if ($drv->{'mode'} == 1) { $desc = $drv->{'desc'}; } elsif ($drv->{'mode'} == 2) { $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"; } elsif ($out =~ /\/model\/(\S+).*/) { $desc = $1; } elsif ($out =~ /^#\s+(.*)/) { $desc = $1; } else { $desc = "None"; } } else { $desc = "None"; } return $desc; } # printer_support(option) sub printer_support { return $_[0] !~ /^(allow|alias|ctype|banner|desc|editdest|msize|direct|rnoqueue|ipp)$/; } # list_classes() # Returns an associative array of print classes sub list_classes { local($stat, %rv); $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) ]; } return \%rv; } # create_printer(&details) # Create a new printer sub create_printer { local(%prn, $cmd, $out, $model, $dummy, $scheduler); %prn = %{$_[0]}; #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`; # create lpadmin command local $esc = quotemeta($prn{'name'}); $cmd = "/usr/lib/lpadmin -p$esc"; ## remote unix printer if ($prn{'rhost'}) { if ($prn{'iface'}) { &error("lpadmin failed : <pre>No model allowed for remote unix printer.</pre>"); } ©_netface_driver($_[0]); $cmd .= " -i$irix_iface_path/$esc.tmp"; $cmd .= " -v/dev/null"; } ## remote windows printer #elsif ($wdrv) { # $cmd .= " -m$dummy"; # $cmd .= " -v/dev/null"; # } ## remote HPNP printer #elsif ($hdrv) { # $cmd .= " -m$dummy"; # $cmd .= " -v/dev/null"; # } ## local printer with webmin driver #elsif ($prn{'iface'} eq "$drivers_directory/$prn{'name'}") { # $cmd .= " -m$dummy"; # $cmd .= " -v".quotemeta($prn{'dev'}); # } ## local printer with IRIX model elsif ($prn{'iface'} =~ $config{'model_path'}) { $model = substr($prn{'iface'}, length($config{'model_path'}) + 1); $cmd .= " -m$model"; $cmd .= " -v".quotemeta($prn{'dev'}); } else { &error("lpadmin failed : <pre>Action not supported.</pre>"); } # stop scheduler #$out = &backquote_logged("/usr/lib/lpshut 2>&1"); # call lpadmin $out = &backquote_logged("$cmd 2>&1"); if ($?) { &error("lpadmin failed : <pre>$out</pre>"); } if ($prn{'rhost'}) { &unlink_file("$irix_iface_path/$prn{'name'}.tmp"); } ## Link to windows webmin driver #&lock_file("$irix_iface_path/$prn{'name'}"); #if ($wdrv) { # `rm $irix_iface_path/$prn{'name'}`; # `ln -s $drivers_directory/$prn{'name'}.smb $irix_iface_path/$prn{'name'}`; # } ## Link to webmin hpnp driver #if ($hdrv) { # `rm $irix_iface_path/$prn{'name'}`; # `ln -s $drivers_directory/$prn{'name'}.hpnp $irix_iface_path/$prn{'name'}`; # } ## Link to webmin driver #if ($prn{'iface'} eq "$drivers_directory/$prn{'name'}" && !$wdrv) { # `rm $irix_iface_path/$prn{'name'}`; # `ln -s $drivers_directory/$prn{'name'} $irix_iface_path/$prn{'name'}`; # } #&unlock_file("$irix_iface_path/$prn{'name'}"); #&lock_file("$config{'model_path'}/$dummy"); #`rm $config{'model_path'}/$dummy`; #&unlock_file("$config{'model_path'}/$dummy"); # start scheduler #if ($scheduler) { # $out = &backquote_logged("/usr/lib/lpsched 2>&1"); # if ($?) { &error("lpsched failed : <pre>$out</pre>"); } # } #change printer parameters &modify_printer($_[0]); } # copy_netface_driver(&prn) # Copies netface driver to interfaces directory and changes # remote host address, name and type of remote printer. sub copy_netface_driver { local (%prn); %prn = %{$_[0]}; my ($cmd, $rname, $rtype, $nettype, $driver_file ) = (); if ( $prn{'rtype'} eq "s5" ) { $nettype = "sgi"; $cmd = "/usr/bsd/rsh -l lp $prn{'rhost'} " . "\'grep \"^NAME\" $irix_iface_path/$prn{'rqueue'}\'"; $rname = &backquote_logged("$cmd"); if ($?) { &error("Failed to read remote printer's name : <pre>$rname</pre>"); } $cmd = "/usr/bsd/rsh -l lp $prn{'rhost'} " . "\'grep \"^TYPE\" $irix_iface_path/$prn{'rqueue'}\'"; $rtype = &backquote_logged("$cmd"); if ($?) { &error("Failed to read remote printer's type : <pre>$rtype</pre>"); } } else { $nettype = "bsd"; $rname = "BSD Printer"; $rtype = "PostScript"; } undef local $/; open (NETFACE,"<$config{'model_path'}/netface") or &error("Failed to open netface driver."); $driver_file = <NETFACE>; close (NETFACE); $driver_file =~ s/^TYPE=unknown/$rtype/m; $driver_file =~ s/^NAME=/$rname/m; $driver_file =~ s/^NETTYPE=/NETTYPE=$nettype/m; $driver_file =~ s/^HOSTNAME=/HOSTNAME=$prn{'rhost'}/m; $driver_file =~ s/^HOSTPRINTER=/HOSTPRINTER=$prn{'rqueue'}/m; &open_tempfile(INTERFACE,">$irix_iface_path/$prn{'name'}.tmp", 1) || &error("Failed to open interface for $prn{'name'}."); &print_tempfile(INTERFACE, $driver_file); &close_tempfile(INTERFACE); } # modify_printer(&details) # Change an existing printer sub modify_printer { local(%prn, $cmd, $out); %prn = %{$_[0]}; # make the default local $esc = quotemeta($prn{'name'}); if ($prn{'default'}) { $out = &backquote_logged("/usr/lib/lpadmin -d$esc 2>&1"); if ($?) { &error("Failed to set default : <pre>$out</pre>"); } } # enable or disable if ($prn{'enabled'}) { $cmd = "/usr/bin/enable $esc"; } elsif ($prn{'enabled_why'}) { local $wesc = quotemeta($prn{'enabled_why'}); $cmd = "/usr/bin/enable $esc ; /usr/bin/disable -r$wesc $esc"; } else { $cmd = "/usr/bin/enable $esc ; /usr/bin/disable $esc"; } $out = &backquote_logged("$cmd 2>&1"); # accepting or rejecting requests if ($prn{'accepting'}) { $cmd = "/usr/lib/accept $esc"; } elsif ($prn{'accepting_why'}) { local $wesc = quotemeta($prn{'accepting_why'}); $cmd = "/usr/lib/accept $esc ; /usr/lib/reject -r$wesc $esc"; } else { $cmd = "/usr/lib/accept $esc ; /usr/lib/reject $esc"; } $out = &backquote_logged("$cmd 2>&1"); } # delete_printer(name) # Deletes some existing printer sub delete_printer { local($out, $scheduler); #$scheduler = &sched_running(); local $esc = quotemeta($_[0]); # delete print jobs $out = &backquote_logged("/usr/bin/cancel -a $esc 2>&1"); if ($?) { &error("cancel failed : <pre>$out</pre>"); } # call lpadmin $out = &backquote_logged("/usr/lib/lpadmin -x$esc 2>&1"); if ($?) { &error("lpadmin failed : <pre>$out</pre>"); } } # cancel_job(printer, id) # Cancels some print job sub cancel_job { local($out); local $iesc = quotemeta($_[1]); $out = &backquote_logged("/usr/bin/cancel $iesc 2>&1"); if ($?) { &error("cancel failed : <pre>$out</pre>"); } sleep(1); } # sched_running() # Returns 1 if running and 0 if not running sub sched_running { local $out = &backquote_command("lpstat -r 2>&1", 1); if ($out =~ /not/) { return 0; } else { return 1; } } # start_sched() # Start lpsched sub start_sched { my $cmd = "/usr/lib/lpshut > /dev/null 2>&1;" . "/sbin/killall lpautoenable;" . "rm -f /var/spool/lp/SCHEDLOCK /var/spool/lp/FIFO;" . "/usr/lib/lpsched 2>&1"; local $out = &backquote_logged($cmd); if ($?) { &error("failed to start lpsched : <tt>$out</tt>"); } } # stop_sched(pid) # Stop the running lpsched process sub stop_sched { local $out = &backquote_logged("/usr/lib/lpshut 2>&1"); if ($?) { &error("lpshut failed : <tt>$out</tt>"); } } # print_command(printer, file) # Returns the command to print some file on some printer sub print_command { local $esc = quotemeta($_[0]); local $fesc = quotemeta($_[1]); return "lp -d$esc $fesc"; } # check_print_system() sub check_print_system { &has_command("lpstat") || return &text('irix_ecmd', "<tt>lpstat</tt>"); -d $irix_iface_path || return &text('irix_eiface',"<tt>$irix_iface_path</tt>"); return undef; } @device_files = ("/dev/plp", "/dev/ttyd1", "/dev/ttyd2", "/dev/null"); @device_names = ("Parallel", "Serial 1", "Serial 2", "Null Device");
Upload File
Create Folder