# cups-driver.pl # Functions for CUPS printer drivers $webmin_windows_driver = 0; $cups_ppd_dir = "/etc/cups/ppd"; $lpoptions = &has_command("lpoptions.cups") ? "lpoptions.cups" : "lpoptions"; # is_windows_driver(path, &printer) # Returns the server, share, username, password, workgroup, program # if path is a webmin windows driver sub is_windows_driver { if ($_[1]->{'dev'} =~ /^smb:\/\/(\S*):(\S*)\@(\S*)\/(\S*)\/(\S*)$/) { return { 'user' => $1, 'pass' => $2, 'workgroup' => $3, 'server' => $4, 'share' => $5, 'program' => $_[0] }; } elsif ($_[1]->{'dev'} =~ /^smb:\/\/(\S*):(\S*)\@(\S*)\/(\S*)$/) { return { 'user' => $1, 'pass' => $2, 'server' => $3, 'share' => $4, 'program' => $_[0] }; } elsif ($_[1]->{'dev'} =~ /^smb:\/\/(\S*)\/(\S*)\/(\S*)$/) { return { 'workgroup' => $1, 'server' => $2, 'share' => $3, 'program' => $_[0] }; } elsif ($_[1]->{'dev'} =~ /^smb:\/\/(\S*)\/(\S*)$/) { return { 'server' => $1, 'share' => $2, 'program' => $_[0] }; } else { return undef; } } # is_driver(path, &printer) # Returns the driver name if some path is a CUPS driver, or undef sub is_driver { if (!$_[0] || !-r $_[0]) { return { 'mode' => 0, 'desc' => $text{'cups_none'} }; } local $ppd = &parse_cups_ppd($_[0]); if ($ppd->{'NickName'}) { # Looks like a CUPS PPD file! return { 'mode' => 1, 'manuf' => $ppd->{'Manufacturer'}, 'model' => $ppd->{'ModelName'}, 'nick' => $ppd->{'NickName'}, 'desc' => "$ppd->{'Manufacturer'} $ppd->{'ModelName'}" }; } else { # Some other kind of interface file return { 'mode' => 2, 'file' => $_[0], 'desc' => $_[0] }; } } # create_windows_driver(&printer, &driver) sub create_windows_driver { if ($_[1]->{'workgroup'} && $_[1]->{'user'}) { $_[0]->{'dev'} = "smb://$_[1]->{'user'}:$_[1]->{'pass'}\@$_[1]->{'workgroup'}/$_[1]->{'server'}/$_[1]->{'share'}"; } elsif ($_[1]->{'workgroup'}) { $_[0]->{'dev'} = "smb://$_[1]->{'workgroup'}/$_[1]->{'server'}/$_[1]->{'share'}"; } elsif ($_[1]->{'user'}) { $_[0]->{'dev'} = "smb://$_[1]->{'user'}:$_[1]->{'pass'}\@$_[1]->{'server'}/$_[1]->{'share'}"; } else { $_[0]->{'dev'} = "smb://$_[1]->{'server'}/$_[1]->{'share'}"; } return $_[1]->{'program'}; } # create_driver(&printer, &driver) sub create_driver { local $drv = "$cups_ppd_dir/$_[0]->{'name'}.ppd"; undef($cups_driver_options); if ($_[1]->{'mode'} == 0) { &unlink_file($drv); return undef; } elsif ($_[1]->{'mode'} == 2) { &unlink_file($drv); return $_[1]->{'file'}; } else { # Copy the driver into place if ($_[1]->{'ppd'} =~ /\.gz$/) { &system_logged("gunzip -c ".quotemeta($_[1]->{'ppd'}). " >".quotemeta($drv)); } else { ©_source_dest($_[1]->{'ppd'}, $drv); } chmod(0777, $drv); $cups_driver_options = $_[1]->{'opts'}; # for modify_printer return $drv; } } # delete_driver(name) sub delete_driver { &unlink_file("$cups_ppd_dir/$_[0].ppd"); } # driver_input(&printer, &driver) sub driver_input { printf "<tr> <td><input type=radio name=mode value=0 %s> %s</td>\n", $_[1]->{'mode'} == 0 ? 'checked' : '', $text{'cups_none'}; print "<td>($text{'cups_nonemsg'})</td> </tr>\n"; printf "<tr> <td><input type=radio name=mode value=2 %s> %s</td>", $_[1]->{'mode'} == 2 ? 'checked' : '', $text{'cups_prog'}; printf "<td><input name=program size=40 value='%s'></td> </tr>\n", $_[1]->{'mode'} == 2 ? $_[0]->{'iface'} : ''; # Display all the CUPS drivers 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 = &backquote_command("find --version 2>&1", 1); local $flag = $findver =~ /GNU\s+find\s+version\s+([0-9\.]+)/i && $1 >= 4.2 ? "-L" : ""; foreach my $mp (split(/\s+/, $config{'model_path'})) { &open_execute_command(FIND, "find $flag ".quotemeta($mp). " -type f -print", 1, 1); while(<FIND>) { chop; next if (/\.xml$/); # Ignore XML PPD sources /([^\/]+)$/; next if ($donefile{$1}++); push(@files, $_); } close(FIND); } &read_file("$module_config_directory/ppd-cache", \%cache); foreach $f (@files) { if (!defined($cache{$f})) { $outofdate = $f; last; } } if ($outofdate || scalar(keys %cache) != scalar(@files)) { # Cache is out of date undef(%cache); local %donecache; foreach $f (@files) { local $ppd = &parse_cups_ppd($f); local $nn = $ppd->{'NickName'}; $cache{$f} = $donecache{$nn} ? "duplicate" : $ppd->{'NickName'}; $donecache{$nn}++; } &write_file("$module_config_directory/ppd-cache", \%cache); } local %done; print "<td><select name=ppd size=10>\n"; foreach $f (sort { $cache{$a} cmp $cache{$b} } keys %cache) { if ($cache{$f} && $cache{$f} ne "duplicate" && !$done{$cache{$f}}++) { printf "<option value=%s %s>%s\n", $f, $_[1]->{'nick'} eq $cache{$f} ? 'selected' : '', $cache{$f}; $currppd = $f if ($_[1]->{'nick'} eq $cache{$f}); } } print "</select>\n"; # Display driver option inputs if ($currppd) { local $ppd = &parse_cups_ppd($currppd); print "<br><b>",&text('cups_opts', $ppd->{'NickName'}), "</b><table>\n"; open(OPTS, "$lpoptions -p '$_[0]->{'name'}' -l 2>/dev/null |"); while(<OPTS>) { if (/^(\S+)\/([^:]+):\s*(.*)/ && $1 ne "PageRegion") { print "<tr>\n" if ($i%2 == 0); local $code = $1; local $disp = $2; local @opts = split(/\s+/, $3); print "<td><b>$disp:</b></td>\n"; print "<td><select name=ppd_$code>\n"; foreach $o (@opts) { local $sel = ($o =~ s/^\*//); printf "<option value='%s' %s>%s\n", $o, $sel ? "selected" : "", $ppd->{$code}->{$o} ? $ppd->{$code}->{$o} : $o; } print "</select></td>\n"; print "<tr>\n" if ($i%2 == 1); } } close(OPTS); print "</table>\n"; } print "</td> </tr>\n"; return undef; } # parse_driver() # Parse driver selection from %in and return a driver structure sub parse_driver { if ($in{'mode'} == 0) { return { 'mode' => 0 }; } elsif ($in{'mode'} == 2) { $in{'program'} =~ /^(\S+)/ && -x $1 || &error(&text('cups_eprog', $in{'program'})); return { 'mode' => 2, 'file' => $in{'program'} }; } elsif ($in{'mode'} == 1) { # CUPS printer driver local $ppd = &parse_cups_ppd($in{'ppd'}); local $rv = { 'mode' => 1, 'ppd' => $in{'ppd'}, 'nick' => $ppd->{'NickName'}, 'manuf' => $ppd->{'Manufacturer'}, 'model' => $ppd->{'ModelName'} }; foreach $i (keys %in) { $rv->{'opts'}->{$1} = $in{$i} if ($i =~ /^ppd_(.*)$/); } return $rv; } } 1;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
CHANGELOG | File | 1.16 KB | 0644 |
|
acl_security.pl | File | 4.4 KB | 0755 |
|
aix-lib.pl | File | 9.45 KB | 0755 |
|
ascii.txt | File | 4.19 KB | 0644 |
|
base_coas_driver | File | 560 B | 0755 |
|
bw.fig | File | 2.75 KB | 0644 |
|
bw.ps | File | 6.46 KB | 0644 |
|
caldera-driver.pl | File | 12.31 KB | 0755 |
|
cancel_all.cgi | File | 535 B | 0755 |
|
catalog.devices | File | 12.34 KB | 0644 |
|
cgi_args.pl | File | 284 B | 0755 |
|
cluster.cgi | File | 2.06 KB | 0755 |
|
cluster_add.cgi | File | 2.13 KB | 0755 |
|
cluster_delete.cgi | File | 529 B | 0755 |
|
colour.fig | File | 2.91 KB | 0644 |
|
colour.ps | File | 6.63 KB | 0644 |
|
config-AlmaLinux-7.0-ALL | File | 323 B | 0644 |
|
config-Amazon-Linux-2-ALL | File | 323 B | 0644 |
|
config-CentOS-Linux-7.0-ALL | File | 323 B | 0644 |
|
config-CentOS-Stream-Linux-8.0-ALL | File | 323 B | 0644 |
|
config-CloudLinux-8.0-ALL | File | 323 B | 0644 |
|
config-Oracle-Linux-8.0-ALL | File | 323 B | 0644 |
|
config-Redhat-Enterprise-Linux-7.0-ALL | File | 323 B | 0644 |
|
config-Rocky-Linux-7.0-ALL | File | 323 B | 0644 |
|
config-Scientific-Linux-7.0-ALL | File | 323 B | 0644 |
|
config-aix | File | 281 B | 0644 |
|
config-coherent-linux | File | 323 B | 0644 |
|
config-corel-linux | File | 228 B | 0644 |
|
config-debian-linux | File | 228 B | 0644 |
|
config-debian-linux-3.1-3.9 | File | 327 B | 0644 |
|
config-debian-linux-4.0-ALL | File | 333 B | 0644 |
|
config-freebsd | File | 230 B | 0644 |
|
config-generic-linux | File | 228 B | 0644 |
|
config-gentoo-linux | File | 248 B | 0644 |
|
config-hpux | File | 323 B | 0644 |
|
config-irix | File | 213 B | 0644 |
|
config-macos | File | 230 B | 0644 |
|
config-mandrake-linux | File | 245 B | 0644 |
|
config-mandrake-linux-8.0-ALL | File | 276 B | 0644 |
|
config-msc-linux | File | 228 B | 0644 |
|
config-netbsd | File | 230 B | 0644 |
|
config-open-linux | File | 309 B | 0644 |
|
config-open-linux-3.1e | File | 239 B | 0644 |
|
config-openSUSE-Linux-15.0-ALL | File | 318 B | 0644 |
|
config-openbsd | File | 230 B | 0644 |
|
config-openmamba-linux | File | 229 B | 0644 |
|
config-pardus-linux | File | 228 B | 0644 |
|
config-redhat-linux | File | 228 B | 0644 |
|
config-redhat-linux-24.0-ALL | File | 339 B | 0644 |
|
config-redhat-linux-7.0 | File | 283 B | 0644 |
|
config-redhat-linux-7.1 | File | 286 B | 0644 |
|
config-redhat-linux-7.2-8.1 | File | 394 B | 0644 |
|
config-redhat-linux-9.0-23.0 | File | 337 B | 0644 |
|
config-slackware-linux | File | 228 B | 0644 |
|
config-slackware-linux-8.1-ALL | File | 246 B | 0644 |
|
config-solaris | File | 304 B | 0644 |
|
config-solaris-10-ALL | File | 330 B | 0644 |
|
config-solaris-9 | File | 296 B | 0644 |
|
config-suse-linux | File | 226 B | 0644 |
|
config-suse-linux-8.2-ALL | File | 322 B | 0644 |
|
config-trustix-linux | File | 313 B | 0644 |
|
config-turbo-linux | File | 228 B | 0644 |
|
config-united-linux | File | 322 B | 0644 |
|
config-unixware | File | 302 B | 0644 |
|
config.info | File | 1.31 KB | 0644 |
|
config.info.ca | File | 1.53 KB | 0644 |
|
config.info.cs | File | 1.25 KB | 0644 |
|
config.info.de | File | 1.43 KB | 0644 |
|
config.info.es | File | 1.17 KB | 0644 |
|
config.info.fr | File | 1.63 KB | 0644 |
|
config.info.hu | File | 707 B | 0644 |
|
config.info.ja | File | 823 B | 0644 |
|
config.info.nl | File | 1.41 KB | 0644 |
|
config.info.no | File | 1.37 KB | 0644 |
|
config.info.pl | File | 1.45 KB | 0644 |
|
config.info.pt_BR | File | 1.58 KB | 0644 |
|
config.info.ru | File | 1.74 KB | 0644 |
|
config.info.sv | File | 651 B | 0644 |
|
config.info.tr | File | 1.39 KB | 0644 |
|
config.info.uk | File | 1.81 KB | 0644 |
|
config.info.zh | File | 573 B | 0644 |
|
config.info.zh_TW | File | 539 B | 0644 |
|
cups-driver.pl | File | 6.37 KB | 0755 |
|
cups-lib.pl | File | 8.67 KB | 0755 |
|
defaultacl | File | 73 B | 0644 |
|
delete_printer.cgi | File | 690 B | 0755 |
|
delete_printers.cgi | File | 839 B | 0755 |
|
drivers | File | 18.34 KB | 0644 |
|
edit_printer.cgi | File | 10.08 KB | 0755 |
|
freebsd-lib.pl | File | 7.26 KB | 0755 |
|
hpux-driver.pl | File | 3.13 KB | 0755 |
|
hpux-lib.pl | File | 9.83 KB | 0755 |
|
index.cgi | File | 5.83 KB | 0755 |
|
irix-driver.pl | File | 3.13 KB | 0755 |
|
irix-lib.pl | File | 10.68 KB | 0755 |
|
linux-lib.pl | File | 8.97 KB | 0755 |
|
list_jobs.cgi | File | 2.25 KB | 0755 |
|
log_parser.pl | File | 1021 B | 0755 |
|
lpadmin-lib.pl | File | 19.89 KB | 0755 |
|
lprng-lib.pl | File | 10.26 KB | 0755 |
|
module.info | File | 494 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 159 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 223 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 290 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 306 B | 0644 |
|
module.info.ca | File | 167 B | 0644 |
|
module.info.ca.auto | File | 16 B | 0644 |
|
module.info.cs | File | 31 B | 0644 |
|
module.info.cs.auto | File | 155 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 168 B | 0644 |
|
module.info.de | File | 148 B | 0644 |
|
module.info.de.auto | File | 16 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 362 B | 0644 |
|
module.info.es | File | 38 B | 0644 |
|
module.info.es.auto | File | 157 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 217 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 246 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 168 B | 0644 |
|
module.info.fr | File | 39 B | 0644 |
|
module.info.fr.auto | File | 176 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 205 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 188 B | 0644 |
|
module.info.hu | File | 19 B | 0644 |
|
module.info.hu.auto | File | 173 B | 0644 |
|
module.info.it | File | 0 B | 0644 |
|
module.info.it.auto | File | 177 B | 0644 |
|
module.info.ja | File | 27 B | 0644 |
|
module.info.ja.auto | File | 213 B | 0644 |
|
module.info.ko | File | 25 B | 0644 |
|
module.info.ko.auto | File | 176 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 219 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 189 B | 0644 |
|
module.info.ms | File | 152 B | 0644 |
|
module.info.ms.auto | File | 16 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 196 B | 0644 |
|
module.info.nl | File | 33 B | 0644 |
|
module.info.nl.auto | File | 133 B | 0644 |
|
module.info.no | File | 31 B | 0644 |
|
module.info.no.auto | File | 137 B | 0644 |
|
module.info.pl | File | 160 B | 0644 |
|
module.info.pl.auto | File | 16 B | 0644 |
|
module.info.pt | File | 39 B | 0644 |
|
module.info.pt.auto | File | 149 B | 0644 |
|
module.info.pt_BR | File | 42 B | 0644 |
|
module.info.pt_BR.auto | File | 155 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 199 B | 0644 |
|
module.info.ru | File | 25 B | 0644 |
|
module.info.ru.auto | File | 245 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 184 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 192 B | 0644 |
|
module.info.sv | File | 30 B | 0644 |
|
module.info.sv.auto | File | 141 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 393 B | 0644 |
|
module.info.tr | File | 27 B | 0644 |
|
module.info.tr.auto | File | 166 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 281 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 304 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 189 B | 0644 |
|
module.info.zh | File | 24 B | 0644 |
|
module.info.zh.auto | File | 136 B | 0644 |
|
module.info.zh_TW | File | 30 B | 0644 |
|
module.info.zh_TW.auto | File | 142 B | 0644 |
|
old-caldera-driver.pl | File | 9.74 KB | 0755 |
|
openbsd-lib.pl | File | 7.26 KB | 0755 |
|
prefs.info | File | 40 B | 0644 |
|
printconf-driver.pl | File | 9.52 KB | 0755 |
|
rbac-mapping | File | 248 B | 0644 |
|
redhat-driver.pl | File | 12.42 KB | 0755 |
|
restart.cgi | File | 301 B | 0755 |
|
save_printer.cgi | File | 5.85 KB | 0755 |
|
solaris-driver.pl | File | 4.03 KB | 0755 |
|
solaris-lib.pl | File | 12.17 KB | 0755 |
|
sortdrivers-by-drv.pl | File | 222 B | 0755 |
|
sortdrivers.pl | File | 242 B | 0755 |
|
start.cgi | File | 377 B | 0755 |
|
stop.cgi | File | 374 B | 0755 |
|
stp | File | 2.45 KB | 0644 |
|
suse-driver.pl | File | 10.62 KB | 0755 |
|
test_form.cgi | File | 887 B | 0755 |
|
test_print.cgi | File | 1.19 KB | 0755 |
|
unixware-lib.pl | File | 7.81 KB | 0755 |
|
view_job.cgi | File | 909 B | 0755 |
|
webmin-driver.pl | File | 1.04 KB | 0755 |
|