cups-pdf-2.6.1/0000755000215500007650000000000011642640457012434 5ustar vrbehrstaffcups-pdf-2.6.1/contrib/0000755000215500007650000000000011642640525014070 5ustar vrbehrstaffcups-pdf-2.6.1/contrib/Contents0000644000215500007650000000227311642640525015614 0ustar vrbehrstaffThis directory contains software that was contributed by various users to CUPS-PDF. It enhances functionality or supports the setup of CUPS-PDF on different platforms. As far as not explicitly stated otherwise all of the contributed software is distributed under the same license as CUPS-PDF (GPL) - check ../COPYING for more information. Currently the following contributions are available: * SELinux-HOWTO by Doc Walker A collection of scripts and documentation on how to set up CUPS-PDF in a SELinux environment (e.g. FC4 or FC5). (C) 2006 by Doc Walker Remi Collet provided a new .te file with v2.4.8 (C) 2008 by Remi Collet * pstitleiconv by Nickolay Kondrashov This filter allows conversion of character encoding in PS files for processing by CUPS-PDF. This will allow international characters in filenames when printing from Windows clients. (C) 2006 by Nickolay Kondrashov * cups-pdf-dispatch by Nickolay Kondrashov An elaborate postprocessing script for CUPS-PDF that allows sending mails with the created PDFs to users. (C) 2006 by Nickolay Kondrashov cups-pdf-2.6.1/contrib/SELinux-HOWTO/0000755000215500007650000000000011642635005016312 5ustar vrbehrstaffcups-pdf-2.6.1/contrib/SELinux-HOWTO/cups_pdf.te0000644000215500007650000000155511527522755020466 0ustar vrbehrstaffpolicy_module(cups_pdf,CUPSVERSION) require { class dir { add_name create getattr remove_name search setattr write }; class file { create getattr read setattr unlink write }; type cupsd_t; type home_root_t; type user_home_dir_t; type user_home_t; type print_spool_t; type unconfined_home_dir_t; type unconfined_home_t; } allow cupsd_t home_root_t:dir { getattr search }; allow cupsd_t user_home_dir_t:dir { getattr search }; allow cupsd_t user_home_t:dir { add_name create getattr remove_name search setattr write }; allow cupsd_t user_home_t:file { create getattr read setattr unlink write }; allow cupsd_t unconfined_home_dir_t:dir { getattr search }; allow cupsd_t unconfined_home_t:dir { add_name create getattr remove_name search setattr write }; allow cupsd_t unconfined_home_t:file { create getattr read setattr unlink write }; cups-pdf-2.6.1/contrib/SELinux-HOWTO/INSTALL-SELinux0000644000215500007650000000310011642635005020662 0ustar vrbehrstaffHOWTO: Enable CUPS-PDF to work with SELinux ------------------------------------------- Security-enhanced Linux (SELinux) is a set of extensions to the standard Linux kernel that add mandatory access controls to help prevent failures in system security due to malicious or flawed applications. It is enabled by default on Fedora Core 4 and 5, as well as other mainstream distributions. See for more background information. In order to use CUPS-PDF with SELinux enabled, you will need to compile and install the following security policy module: $ cd cups-pdf-2.6.1/contrib/SELinux-HOWTO $ ./update-module Compiling type enforcement file 'cups_pdf.te' --> 'cups_pdf.mod'. checkmodule: loading policy configuration from cups_pdf.te checkmodule: policy configuration loaded checkmodule: writing binary representation (version 5) to cups_pdf.mod Creating policy package 'cups_pdf.mod' --> 'cups_pdf.pp'. Installing security policy 'cups_pdf.pp' into current machine policy. cups_pdf 2.6.1 $ sudo service cups restart Stopping cups: [ OK ] Starting cups: [ OK ] You should now be able to print via CUPS-PDF. View the SELinux audit log to verify the newly-installed mandatory access controls allow CUPS-PDF to print properly: $ sudo tail -F -n 1000 /var/log/audit/audit.log | grep AVC You should see various messages indicating security granted to the cupsd daemon. Refer to for more information. cups-pdf-2.6.1/contrib/SELinux-HOWTO/update-module0000755000215500007650000000544611527522755021027 0ustar vrbehrstaff#!/bin/sh ### # # Update SELinux policy module for CUPS-PDF # # Shell script created by Rx on 7 May 06 # removed some bashisms, Feb. 18th, 2011, VB # ### SELINUXENABLED=`which selinuxenabled` GETENFORCE=`which getenforce` GETSEBOOL=`which getsebool` CHECKMODULE=`which checkmodule` SEMODULE_PACKAGE=`which semodule_package` SEMODULE=`which semodule` echo "" if [ "x$SELINUXENABLED" = "x" ]; then echo "Cannot locate executable 'selinuxenabled' (via 'which' command)." echo "Script '$0' terminated (exit code 1)." exit 1 fi if [ x"$GETENFORCE" = "x" ]; then echo "Cannot locate executable 'getenforce' (via 'which' command)." echo "Script '$0' terminated (exit code 2)." exit 2 fi if [ x"$GETSEBOOL" = "x" ]; then echo "Cannot locate executable 'getsebool' (via 'which' command)." echo "Script '$0' terminated (exit code 3)." exit 3 fi if [ x"$CHECKMODULE" = "x" ]; then echo "Cannot locate executable 'checkmodule' (via 'which' command)." echo "The following command will correct this (re-run this script afterward):" echo "$ sudo yum install checkpolicy" echo "Script '$0' terminated (exit code 4)." exit 4 fi if [ x"$SEMODULE_PACKAGE" = "x" ]; then echo "Cannot locate executable 'semodule_package' (via 'which' command)." echo "Script '$0' terminated (exit code 5)." exit 5 fi if [ x"$SEMODULE" = "x" ]; then echo "Cannot locate executable 'semodule' (via 'which' command)." echo "Script '$0' terminated (exit code 6)." exit 6 fi if [ `$SELINUXENABLED` ]; then echo "SELinux is not enabled; this script is unnecessary." echo "Script '$0' terminated (exit code 11)." exit 11 fi if [ `$GETENFORCE` != "Enforcing" ]; then echo "SELinux is not in 'Enforcing' mode; this script is unnecessary." echo "The following command will correct this (re-run this script afterward):" echo "$ sudo setenforce 1" echo "Script '$0' terminated (exit code 12)." exit 12 fi if [ "`$GETSEBOOL cupsd_disable_trans`" = "cupsd_disable_trans --> on" ]; then echo "Security policy ignored for cupsd transactions; this script is unnecessary." echo "The following command will correct this (re-run this script afterward):" echo "$ sudo setsebool -P cupsd_disable_trans 0" echo "Script '$0' terminated (exit code 13)." exit 13 fi MODULE="cups_pdf" if [ -f $MODULE.te ]; then echo "Compiling type enforcement file '$MODULE.te' --> '$MODULE.mod'." checkmodule -M -m -o $MODULE.mod $MODULE.te fi if [ -f $MODULE.mod ]; then echo "Creating policy package '$MODULE.mod' --> '$MODULE.pp'." semodule_package -o $MODULE.pp -m $MODULE.mod fi if [ -f $MODULE.pp ]; then echo "Installing security policy '$MODULE.pp' into current machine policy." sudo semodule -i $MODULE.pp fi echo "`sudo semodule -l | grep $MODULE`" cups-pdf-2.6.1/contrib/SELinux-HOWTO/cups_pdf.te_orig0000644000215500007650000000103011642634663021472 0ustar vrbehrstaffmodule cups_pdf 2.6.1; require { class dir { add_name create getattr remove_name search setattr write }; class file { create getattr read setattr unlink write }; type cupsd_t; type home_root_t; type user_home_dir_t; type user_home_t; } allow cupsd_t home_root_t:dir { getattr search }; allow cupsd_t user_home_dir_t:dir { getattr search }; allow cupsd_t user_home_t:dir { add_name create getattr remove_name search setattr write }; allow cupsd_t user_home_t:file { create getattr read setattr unlink write }; cups-pdf-2.6.1/contrib/pstitleiconv-0.2/0000755000215500007650000000000011641673213017107 5ustar vrbehrstaffcups-pdf-2.6.1/contrib/pstitleiconv-0.2/ChangeLog0000644000215500007650000000026311527522755020671 0ustar vrbehrstaff2006-05-15 Nickolay Kondrashov * Added inspiration reference to cups-pdf. 2006-05-15 Nickolay Kondrashov * Initial release. cups-pdf-2.6.1/contrib/pstitleiconv-0.2/pstitleiconv0000755000215500007650000000661211527522755021574 0ustar vrbehrstaff#!/usr/bin/perl -w # Copyright 2006 Nickolay Kondrashov # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use strict; use Text::Iconv; my $CONFIG_PATH = "/etc/cups/pstitleiconv.conf"; ### CONFIGURATION ############################## # set default configuration parameters my $FROMCODE='ascii'; my $TOCODE='utf-8'; # read config file contents my $CONFIG_CONTENTS; { local $/; open( CONFIG, $CONFIG_PATH ) or die "ERROR: Failed to open config file $CONFIG_PATH: $!\n"; $CONFIG_CONTENTS = ; close( CONFIG ) or die "ERROR: Failed to close config file $CONFIG_PATH: $!\n"; } # eval config file contents eval $CONFIG_CONTENTS; if( $@ ) { die "ERROR: Failed to evaluate config file contents: $@\n" } ### SUBS ####################################### sub try_decode_ps_hex_string { my( $string ) = @_; if( $string =~ m/^<[0-9a-fA-F \t]*>$/ ) { $string =~ tr/ \t<>//d; # remove whitespace and brackets $string = pack( 'H*', $string ); } return $string; } sub encode_ps_hex_string { my( $string ) = @_; return '<'. uc( unpack( 'H*', $string ) ). '>'; } sub convert_title { my( $converter, $original_title ) = @_; warn "DEBUG: decoding title: $original_title\n"; my $decoded_title = try_decode_ps_hex_string( $original_title ); warn "DEBUG: converting title: $decoded_title\n"; my $converted_title = $converter->convert( $decoded_title ); unless( defined $converted_title ) { warn "WARNING: failed to convert title, leaving as is.\n"; return $original_title; } warn "DEBUG: encoding title: $converted_title\n"; my $encoded_title = encode_ps_hex_string( $converted_title ); warn "DEBUG: encoded title: $encoded_title\n"; return $encoded_title; } ### MAIN ####################################### my( $printer, $jobid, $username, $title, $copies, $options, $filename ) = @_; my $fh; if( defined $filename ) { open( $fh, $filename ) or die "ERROR: Failed to open $filename: $!\n"; } else { $fh = *STDIN; } my $converter = new Text::Iconv( $FROMCODE, $TOCODE ); my $rec_depth = 0; my $got_title = 0; while( <$fh> ) { if( m/^\%!/ ) { if( $rec_depth == 0 ) { warn "DEBUG: found beginning of postscript code: $_\n"; } else { warn "DEBUG: found beginning of embedded (e)ps code: $_\n"; } $rec_depth++; } elsif( m/^\%\%EOF/ ) { $rec_depth--; if( $rec_depth == 0 ) { warn "DEBUG: found end of postscript code: $_\n"; } elsif( $rec_depth > 0 ) { warn "DEBUG: found end of embedded (e)ps code: $_\n"; } else { warn "WARNING: found unexpected end of ps code: $_\n"; } } elsif( $rec_depth == 1 && ! $got_title && s/^\%\%Title: ([^\r\n]*)(\r?\n?)$/ "\%\%Title: ". convert_title( $converter, $1 ). $2 /e ) { warn "DEBUG: title converted\n"; $got_title = 1; } print; } close $fh; cups-pdf-2.6.1/contrib/pstitleiconv-0.2/README0000644000215500007650000000227311527522755020002 0ustar vrbehrstaff PSTITLEICONV v0.1 README PSTITLEICONV is the CUPS filter for converting PostScript document embedded title character encoding. INSTALLING Copy pstitleiconv to the CUPS filter directory (usually /usr/lib/cups/filter). Copy pstitleiconv.conf to /etc/cups directory (or modify pstitleiconv to use your location) USAGE PSTITLEICONV intended usage is in the filter chain before cups-pdf backend to make international characters in the resulting filenames to appear correctly. Just add following line to the cups-pdf ppd file, somewhere near the top, say, just after *Name definitions: *cupsFilter: "application/vnd.cups-postscript 0 pstitleiconv" Then, specify source (client system) and target (host) character encodings in the /etc/pstitleiconv.conf file (look there for details). COMMENTS Parts of the code were inspired by or taken from cups-pdf CUPS backend. Unfortunately, the author was not able to find a better way to pass source and target encoding to the filter instance. So, for the time being, configuration file /etc/cups/pstitleiconv.conf remains the only source, sorry. If you could think of a better way, please inform me. AUTHOR Nickolay Kondrashov cups-pdf-2.6.1/contrib/pstitleiconv-0.2/pstitleiconv.conf0000644000215500007650000000035711527522755022515 0ustar vrbehrstaff# configuration file for pstitleiconv cups filter # this file is interpreted by perl # $FROMCODE # charset to convert from # Default: # ascii #$FROMCODE = "ascii" # $TOCODE # charset to convert to # Default: # utf-8 #$TOCODE = "utf-8" cups-pdf-2.6.1/contrib/cups-pdf-dispatch-0.1/0000755000215500007650000000000011641673231017701 5ustar vrbehrstaffcups-pdf-2.6.1/contrib/cups-pdf-dispatch-0.1/cups-pdf-dispatch.conf0000644000215500007650000000617311527522755024104 0ustar vrbehrstaff# cups-pdf-dispatch.conf # Configuration file for cups-pdf-dispatch. # This file is interpreted by perl. # $CHARSET # Charset of messages # $CHARSET = "utf-8"; # $FROM_MAILADDR # "From" address # $FROM_MAILADDR = "root"; # $FROM_REALNAME # "From" address real name # $FROM_REALNAME = "PDF Printer"; # $SUBJECT_FORMAT # Mail subject format string, arguments: file basename # $SUBJECT_FORMAT = "Printout: \%s"; # $MAX_ATTACHMENT_SIZE # Maximum size for files sent by e-mail. # Undef to disable the limit (not recommended). # $MAX_ATTACHMENT_SIZE = 5 * 1024 * 1024; # 5Mb # $BODY_MIME_TYPE # MIME-type for the message content # $BODY_MIME_TYPE = 'text/plain'; # $FILE_ATTACHED_MSG_FORMAT # Format for message saying the file is attached. # Arguments: prettyfied file name # $FILE_ATTACHED_MSG_FORMAT = # "Your PDF file %s is attached.\n"; # $FILE_TOO_BIG_MSG_FORMAT # Format for message saying the file is too big and has not been attached in # order to save e-mail traffic. # Arguments: file size, maximum attachment size # $FILE_TOO_BIG_MSG_FORMAT = # "Your PDF file size is \%s, which is greater than\n". # "\%s attachment size limit set by administrator.\n\n". # "The file has been left on the server to save e-mail traffic.\n"; # $FILE_STORED_MSG_FORMAT # Format for message saying the file will be stored at specified location. # Arguments: location # $FILE_STORED_MSG_FORMAT = # "It is stored until midnight at the following location:\n\%s\n"; # $FILE_REMOVED_MSG # Message saying file has been removed from the server after sending # $FILE_REMOVED_MSG = # "It has been removed from the server after sending.\n"; # @FILE_SIZE_DIMENSIONS # Postfixes to attach when constructing human-readable file sizes. # @FILE_SIZE_DIMENSIONS = qw(bytes Kb Mb Gb); # $TRY_STRIP_JOB_IDS # Try to remove job-id filename prefix (both added by samba and by cups-pdf) # when naming attachments. # $TRY_STRIP_JOB_IDS = 1; # (try) # @APP_PREFIXES # Application-specific prefixes to remove from attachment names when # $TRY_STRIP_APP_PREFIXES is on. # @APP_PREFIXES = qw( # Microsoft_Word_-_ # Microsoft_Excel_-_ # Microsoft_PowerPoint_-_ # Microsoft_Access_-_ # Microsoft_Outlook_-_ # ); # $TRY_STRIP_APP_PREFIXES # Try to remove application-specific prefixes set in @APP_PREFIXES when # naming attachments. # $TRY_STRIP_APP_PREFIXES = 1; # (try) # $REMOVE_SENT # Whether to remove or not files after sending # $REMOVE_SENT = 1; # (remove) # $LINK_FORMAT # File location link format. # Arguments: username, filename # $LINK_FORMAT = "\\\\". uc( hostname() ). "\\printouts\$\\\%s\\\%s"; # # (i.e. \\HOST\printouts$\username\filename.pdf) # $GET_USER_MAILADDR_SUB # Reference to a function which converts username to e-mail address. # Arguments: username # Returns: e-mail address # $GET_USER_MAILADDR_SUB = sub{ $_[0]. '@'. hostname() }; # # (i.e. user@hostname) # $GET_USER_REALNAME_SUB # Reference to a function which converts username to user's realname (used # when constructing To: header). # Arguments: username # Returns: user's real name # $GET_USER_REALNAME_SUB = sub{ (split( /,/, (getpwnam($_[0]))[6], 2 ))[0] }; # # (i.e. user's real name from gecos) cups-pdf-2.6.1/contrib/cups-pdf-dispatch-0.1/cups-pdf-dispatch0000755000215500007650000001447711527522755023171 0ustar vrbehrstaff#!/usr/bin/perl -w # Copyright 2006 Nickolay Kondrashov # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use strict; use Sys::Hostname; use File::Basename; use Mail::Header; use MIME::Lite; use MIME::Words; my $CONFIG_PATH = "/etc/cups/cups-pdf-dispatch.conf"; ### CONFIGURATION ############################## # set default configuration parameters my $CHARSET = "utf-8"; my $FROM_MAILADDR = "root"; my $FROM_REALNAME = "PDF Printer"; my $SUBJECT_FORMAT = "Printout: \%s"; my $MAX_ATTACHMENT_SIZE = 5 * 1024 * 1024; # 5Mb my $BODY_MIME_TYPE = 'text/plain'; my $FILE_ATTACHED_MSG_FORMAT = "Your PDF file %s is attached.\n"; my $FILE_TOO_BIG_MSG_FORMAT = "Your PDF file size is \%s, which is greater than\n". "\%s attachment size limit set by administrator.\n\n". "The file has been left on the server to save e-mail traffic.\n"; my $FILE_STORED_MSG_FORMAT = "It is stored until midnight at the following location:\n\%s\n"; my $FILE_REMOVED_MSG = "It has been removed from the server after sending.\n"; my @FILE_SIZE_DIMENSIONS = qw(bytes Kb Mb Gb); my $TRY_STRIP_JOB_IDS = 1; my @APP_PREFIXES = qw( Microsoft_Word_-_ Microsoft_Excel_-_ Microsoft_PowerPoint_-_ Microsoft_Access_-_ Microsoft_Outlook_-_ ); my $TRY_STRIP_APP_PREFIXES = 1; my $REMOVE_SENT = 1; my $LINK_FORMAT = "\\\\". uc( hostname() ). "\\printouts\$\\\%s\\\%s"; my $GET_USER_MAILADDR_SUB = sub{ $_[0]. '@'. hostname() }; my $GET_USER_REALNAME_SUB = sub{ (split( /,/, (getpwnam($_[0]))[6], 2 ))[0] }; # read config file contents my $CONFIG_CONTENTS; { local $/; open( CONFIG, $CONFIG_PATH ) or die "Failed to open config file $CONFIG_PATH: $!\n"; $CONFIG_CONTENTS = ; close( CONFIG ) or die "Failed to close config file $CONFIG_PATH: $!\n"; } # eval config file contents eval $CONFIG_CONTENTS; if( $@ ) { die "Failed to evaluate config file contents: $@\n" } # check parameters unless( defined( $FROM_MAILADDR ) && length( $FROM_MAILADDR ) ) { die "From mail address is not set."; } ### SUBS ####################################### # formats human-readable file size string sub format_file_size { my( $size ) = @_; my $dim = 0; while( $dim <= scalar( @FILE_SIZE_DIMENSIONS ) && $size > 1024<<($dim*10) ) { $dim++ } return ( $size>>($dim*10) ). " ". $FILE_SIZE_DIMENSIONS[$dim]; } sub strip_job_ids { my( $file_basename ) = @_; $file_basename =~ s/^job_[0-9]+-([^\.])/$1/; $file_basename =~ s/^smbprn_[0-9]{8}_([^\.])/$1/; return $file_basename; } sub strip_prefixes { my( $file_basename, @prefixes ) = @_; foreach (@prefixes) { $file_basename =~ s/^\Q$_\E([^\.])/$1/; } return $file_basename; } # Taken this function from another project of mine. # Can't remember exactly what it's purpose is, but # it seems to correct some bug in underlying MIME::Words # implementation. sub hacked_encode_mimewords { my ( $words ) = @_; my $encoded_words = MIME::Words::encode_mimeword( $words, 'Q', $CHARSET ); $encoded_words =~ s/ /_/g; return $encoded_words; } ### MAIN ####################################### my( $filename, $username ) = @ARGV; my $file_basename = basename( $filename ); my $file_prettyname = $file_basename; if( $TRY_STRIP_JOB_IDS ) { $file_prettyname = strip_job_ids( $file_prettyname ); } if( $TRY_STRIP_APP_PREFIXES ) { $file_prettyname = strip_prefixes( $file_prettyname, @APP_PREFIXES ); } my $file_size; { my @file_stat = stat( $filename ); unless( scalar( @file_stat ) ) { die "Failed to stat PDF file $filename: $!\n" } $file_size = $file_stat[7]; } my $file_link = sprintf( $LINK_FORMAT, $username, $file_basename ); my $user_mailaddr = $GET_USER_MAILADDR_SUB->( $username ); unless( defined( $user_mailaddr ) ) { warn "User $username has no e-mail address.\n"; exit 0 } my $user_realname = $GET_USER_REALNAME_SUB->( $username ); my $from_header = defined $FROM_REALNAME ? hacked_encode_mimewords( $FROM_REALNAME ). '<'. $FROM_MAILADDR. '>' : $FROM_MAILADDR; my $to_header = defined $user_realname ? hacked_encode_mimewords( $user_realname ). '<'. $user_mailaddr. '>' : $user_mailaddr; my $subject_header = hacked_encode_mimewords( sprintf( $SUBJECT_FORMAT, $file_prettyname ) ); # prevent encoded headers from (incorrect) folding Mail::Header->fold_length( 'From', 1023 ); Mail::Header->fold_length( 'To', 1023 ); Mail::Header->fold_length( 'Subject', 1023 ); Mail::Header->fold_length( 'Content-Type', 1023 ); Mail::Header->fold_length( 'Content-Disposition', 1023 ); my $msg; my $remove_after_sending = 0; if( !defined $MAX_ATTACHMENT_SIZE || $file_size < $MAX_ATTACHMENT_SIZE ) { my $body_text = sprintf( $FILE_ATTACHED_MSG_FORMAT, $file_prettyname ). "\n". ( $REMOVE_SENT ? $FILE_REMOVED_MSG : sprintf( $FILE_STORED_MSG_FORMAT, $file_link ) ); $msg = new MIME::Lite( From => $from_header, To => $to_header, Subject => $subject_header, Type => 'multipart/mixed' ); $msg->attach( Encoding=> 'quoted-printable', Type => "$BODY_MIME_TYPE; charset=$CHARSET", Data => $body_text ); $msg->attach( Encoding => 'base64', Type => 'application/pdf', Disposition => 'attachment', Path => $filename, Filename => hacked_encode_mimewords( $file_prettyname ) ); $remove_after_sending = $REMOVE_SENT; } else { my $body_text = sprintf( $FILE_TOO_BIG_MSG_FORMAT, format_file_size( $file_size ), format_file_size( $MAX_ATTACHMENT_SIZE ) ). "\n". sprintf( $FILE_STORED_MSG_FORMAT, $file_link ); $msg = new MIME::Lite( From => $from_header, To => $to_header, Subject => $subject_header, Encoding=> 'quoted-printable', Type => "$BODY_MIME_TYPE; charset=$CHARSET", Data => $body_text ); } $msg->send(); if( $remove_after_sending ) { unlink $filename or die "Failed to remove PDF file $filename: $!\n"; } exit 0 cups-pdf-2.6.1/contrib/cups-pdf-dispatch-0.1/examples/0000755000215500007650000000000011527522755021526 5ustar vrbehrstaffcups-pdf-2.6.1/contrib/cups-pdf-dispatch-0.1/examples/cups-pdf-dispatch-ldap.conf0000644000215500007650000000374511527522755026642 0ustar vrbehrstaff# cups-pdf-dispatch.conf # Configuration file for cups-pdf-dispatch. # This file is interpreted by perl. # This is (tested) example of using LDAP to fetch user info/e-mail. #### LOCAL CODE #### my %USERINFO_CACHE = (); my $LDAP_HOST = 'localhost'; my $LDAP_BASE = 'ou=people,dc=avtomatikarus,dc=com'; my $LDAP_FILTER_FORMAT = '(&(objectClass=inetOrgPerson)(uid=%s))'; my $LDAP_TLS_CAFILE = '/etc/ldap/cacert.pem'; my $LDAP_TLS_VERIFY = 'require'; sub get_userinfo { my( $username ) = @_; my $userinfo = {}; use Net::LDAP; my $LDAP = new Net::LDAP( $LDAP_HOST, onerror => 'die' ) or die "$@\n"; $LDAP->start_tls( verify => $LDAP_TLS_VERIFY, cafile => $LDAP_TLS_CAFILE ); $LDAP->bind(); my $msg = $LDAP->search( base => $LDAP_BASE, filter => sprintf( $LDAP_FILTER_FORMAT, $username ), attrs => [ 'cn', 'sn', 'mail' ] ); my $entry = $msg->shift_entry(); if( defined $entry ) { $userinfo->{realname} = sprintf( "%s %s", $entry->get_value( 'cn' ), $entry->get_value( 'sn' ) ); $userinfo->{mailaddr} = $entry->get_value( 'mail' ); } $LDAP->unbind(); return $userinfo; } #### END LOCAL CODE #### # $GET_USER_MAILADDR_SUB # Reference to a function which converts username to e-mail address. # Arguments: username # Returns: e-mail address # $GET_USER_MAILADDR_SUB = sub{ $_[0]. '@'. hostname() }; # # (i.e. user@hostname) $GET_USER_MAILADDR_SUB = sub { unless( defined $USERINFO_CACHE{$_[0]} ) { $USERINFO_CACHE{$_[0]} = get_userinfo( $_[0] ); } return $USERINFO_CACHE{$_[0]}->{mailaddr}; }; # $GET_USER_REALNAME_SUB # Reference to a function which converts username to user's realname (used # when constructing To: header). # Arguments: username # Returns: user's real name # $GET_USER_REALNAME_SUB = sub{ (split( /,/, (getpwnam($_[0]))[6], 2 ))[0] }; # # (i.e. user's real name from gecos) $GET_USER_REALNAME_SUB = sub { unless( defined $USERINFO_CACHE{$_[0]} ) { $USERINFO_CACHE{$_[0]} = get_userinfo( $_[0] ); } return $USERINFO_CACHE{$_[0]}->{realname}; }; cups-pdf-2.6.1/contrib/cups-pdf-dispatch-0.1/examples/cups-pdf-dispatch-ru.conf0000644000215500007650000001001311527522755026332 0ustar vrbehrstaff# cups-pdf-dispatch.conf # Configuration file for cups-pdf-dispatch. # This file is interpreted by perl. # This is template conffile with messages translated into russian. # $CHARSET # Charset of messages # $CHARSET = "utf-8"; # $FROM_MAILADDR # "From" address # $FROM_MAILADDR = "root"; # $FROM_REALNAME # "From" address real name # $FROM_REALNAME = "PDF Printer"; $FROM_REALNAME = "PDF-принтер"; # $SUBJECT_FORMAT # Mail subject format string, arguments: file basename # $SUBJECT_FORMAT = "Printout: \%s"; $SUBJECT_FORMAT = 'Распечатка: %s'; # $MAX_ATTACHMENT_SIZE # Maximum size for files sent by e-mail. # Undef to disable the limit (not recommended). # $MAX_ATTACHMENT_SIZE = 5 * 1024 * 1024; # 5Mb # $BODY_MIME_TYPE # MIME-type for the message content # $BODY_MIME_TYPE = 'text/plain'; # $FILE_ATTACHED_MSG_FORMAT # Format for message saying the file is attached. # Arguments: prettyfied file name # $FILE_ATTACHED_MSG_FORMAT = # "Your PDF file %s is attached.\n"; $FILE_ATTACHED_MSG_FORMAT = "Ваш файл \%s приложен.\n"; # $FILE_TOO_BIG_MSG_FORMAT # Format for message saying the file is too big and has not been attached in # order to save e-mail traffic. # Arguments: file size, maximum attachment size # $FILE_TOO_BIG_MSG_FORMAT = # "Your PDF file size is \%s, which is greater than\n". # "\%s attachment size limit set by administrator.\n\n". # "The file has been left on the server to save e-mail traffic.\n"; $FILE_TOO_BIG_MSG_FORMAT = "Размер вашего файла: %s, что превышает максимум в %s,\n". "установленный администратором для вложений.\n\n". "Файл был оставлен на сервере для экономии трафика электронной ". "почты.\n"; # $FILE_STORED_MSG_FORMAT # Format for message saying the file will be stored at specified location. # Arguments: location # $FILE_STORED_MSG_FORMAT = # "It is stored until midnight at the following location:\n\%s\n"; $FILE_STORED_MSG_FORMAT = "Он будет хранится до полуночи по следующему адресу:\n\%s\n"; # $FILE_REMOVED_MSG # Message saying file has been removed from the server after sending # $FILE_REMOVED_MSG = # "It has been removed from the server after sending.\n"; $FILE_REMOVED_MSG = "Он был удален с сервера после отправки.\n"; # @FILE_SIZE_DIMENSIONS # Postfixes to attach when constructing human-readable file sizes. # @FILE_SIZE_DIMENSIONS = qw(bytes Kb Mb Gb); @FILE_SIZE_DIMENSIONS = qw(байт Кб Мб Гб); # $TRY_STRIP_JOB_IDS # Try to remove job-id filename prefix (both added by samba and by cups-pdf) # when naming attachments. # $TRY_STRIP_JOB_IDS = 1; # (try) # @APP_PREFIXES # Application-specific prefixes to remove from attachment names when # $TRY_STRIP_APP_PREFIXES is on. # @APP_PREFIXES = qw( # Microsoft_Word_-_ # Microsoft_Excel_-_ # Microsoft_PowerPoint_-_ # Microsoft_Access_-_ # Microsoft_Outlook_-_ # ); @APP_PREFIXES = ( @APP_PREFIXES, qw( Topplan_-_ ) ); # $TRY_STRIP_APP_PREFIXES # Try to remove application-specific prefixes set in @APP_PREFIXES when # naming attachments. # $TRY_STRIP_APP_PREFIXES = 1; # (try) # $REMOVE_SENT # Whether to remove or not files after sending # $REMOVE_SENT = 1; # (remove) # $LINK_FORMAT # File location link format. # Arguments: username, filename # $LINK_FORMAT = "\\\\". uc( hostname() ). "\\printouts\$\\\%s\\\%s"; # # (i.e. \\HOST\printouts$\username\filename.pdf) # $GET_USER_MAILADDR_SUB # Reference to a function which converts username to e-mail address. # Arguments: username # Returns: e-mail address # $GET_USER_MAILADDR_SUB = sub{ $_[0]. '@'. hostname() }; # # (i.e. user@hostname) # $GET_USER_REALNAME_SUB # Reference to a function which converts username to user's realname (used # when constructing To: header). # Arguments: username # Returns: user's real name # $GET_USER_REALNAME_SUB = sub{ (split( /,/, (getpwnam($_[0]))[6], 2 ))[0] }; # # (i.e. user's real name from gecos) cups-pdf-2.6.1/contrib/cups-pdf-dispatch-0.1/README0000644000215500007650000000264611527522755020600 0ustar vrbehrstaff CUPS-PDF-DISPATCH v0.1 README CUPS-PDF-DISPATCH is a postprocessing script for cups-pdf. INSTALLING Copy cups-pdf-dispatch to your favorite binaries directory (/usr/local/bin is a good choice). Copy cups-pdf-dispatch.conf template to /etc/cups directory (or modify cups-pdf-dispatch to use your location). Modify copied cups-pdf-dispatch.conf to suit your needs (look there for details). Set PostProcessing option in cups-pdf.conf (usually located at /etc/cups/cups-pdf.conf) to location of the cups-pdf-dispatch script (f.e. /usr/local/bin/cups-pdf-dispatch). I18N The main I18N obstacle, when making PDF's from postscript output, is the document titles - they are usually specified in client's machine charset. Cups-pdf uses postscript title to construct PDF filename when job filename is not available (or if you specify to use them preferably). PSTITLEICONV was made to take care of converting title encoding. You could get it from the contrib directory of cups-pdf package. COMMENTS It's a bit "overengineered", but it works. For instance, messages may need to be localized, instead of providing the ability to change them in the conffile. Additionaly, there must be a more elegant way to allow fetching of user info/e-mail from arbitrary sources (may be just use some generic source?). If you have any hints/bugfixes/improvements, please, don't hesitate to contact me. AUTHOR Nickolay Kondrashov cups-pdf-2.6.1/COPYING0000644000215500007650000003542311527522755013500 0ustar vrbehrstaff GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS cups-pdf-2.6.1/extra/0000755000215500007650000000000011642636366013563 5ustar vrbehrstaffcups-pdf-2.6.1/extra/CUPS-PDF.ppd0000644000215500007650000005071411527522755015456 0ustar vrbehrstaff*PPD-Adobe: "4.3" *% *% "$Id: postscript.ppd,v 1.1.1.1 2000/08/24 19:23:13 goffioul Exp $" *% *% Sample Postscript driver PPD file for the Common UNIX Printing *% System (CUPS). *% *% Michael Goffioul *% *% Changes to the original file by Volker Behr, Martin-Eric Racine, *% Nickolay Kondrashov and other contributors: *% added IEEE-1284 device id - 2008-03-24 *% added custom page size - 2006-05-18 *% replaced page descriptions - 2006-05-18 *% InputSlot constraints removed - 2006-05-11 *% maxed out imageable regions - 2006-05-11 *% added pstitleiconv filter - 2006-05-11 *% added ledger paper size - 2006-01-29 *% match Adobe specifications - 2005-12-23 *% additional paper formats - 2005-02-03 and 2005-02-07 *% made A4 default paper size - 2005-02-03 *% Color enabled - 2003-12-02 *% *FormatVersion: "4.3" *FileVersion: "1.1" *LanguageVersion: English *LanguageEncoding: ISOLatin1 *PCFileName: "CUPS-PDF.PPD" *Manufacturer: "Generic" *Product: "(CUPS v1.1)" *ModelName: "Generic CUPS-PDF Printer" *ShortNickName: "Generic CUPS-PDF Printer" *NickName: "Generic CUPS-PDF Printer" *1284DeviceID: "MFG:Generic;MDL:CUPS-PDF Printer;DES:Generic CUPS-PDF Printer;CLS:PRINTER;CMD:POSTSCRIPT;" *% cupsFilter: "application/vnd.cups-postscript 0 pstitleiconv" *PSVersion: "(2017.000) 0" *LanguageLevel: "2" *ColorDevice: True *DefaultColorSpace: RGB *FileSystem: False *Throughput: "8" *LandscapeOrientation: Plus90 *TTRasterizer: Type42 *HWMargins: 0 0 0 0 *VariablePaperSize: True *MaxMediaWidth: 100000 *MaxMediaHeight: 100000 *NonUIOrderDependency: 100 AnySetup *CustomPageSize *CustomPageSize True: "pop pop pop <>setpagedevice" *End *ParamCustomPageSize Width: 1 points 36 100000 *ParamCustomPageSize Height: 2 points 36 100000 *ParamCustomPageSize Orientation: 3 int 0 3 *ParamCustomPageSize WidthOffset: 4 points 0 0 *ParamCustomPageSize HeightOffset: 5 points 0 0 *OpenGroup: General/General *OpenUI *PageSize/Page Size: PickOne *OrderDependency: 100 AnySetup *PageSize *DefaultPageSize: A4 *PageSize 11x14/11x14: "<>setpagedevice" *PageSize 11x17/11x17: "<>setpagedevice" *PageSize 13x19/13x19: "<>setpagedevice" *PageSize 16x20/16x20: "<>setpagedevice" *PageSize 16x24/16x24: "<>setpagedevice" *PageSize 2A/2A: "<>setpagedevice" *PageSize 4A/4A: "<>setpagedevice" *PageSize 8x10/8x10: "<>setpagedevice" *PageSize 8x12/8x12: "<>setpagedevice" *PageSize A0/A0: "<>setpagedevice" *PageSize A1/A1: "<>setpagedevice" *PageSize A2/A2: "<>setpagedevice" *PageSize A3/A3: "<>setpagedevice" *PageSize A4/A4: "<>setpagedevice" *PageSize A5/A5: "<>setpagedevice" *PageSize AnsiA/ANSI A: "<>setpagedevice" *PageSize AnsiB/ANSI B: "<>setpagedevice" *PageSize AnsiC/ANSI C: "<>setpagedevice" *PageSize AnsiD/ANSI D: "<>setpagedevice" *PageSize AnsiE/ANSI E: "<>setpagedevice" *PageSize ArchA/Arch A: "<>setpagedevice" *PageSize ArchB/Arch B: "<>setpagedevice" *PageSize ArchC/Arch C: "<>setpagedevice" *PageSize ArchD/Arch D: "<>setpagedevice" *PageSize ArchE/Arch E: "<>setpagedevice" *PageSize C0/C0: "<>setpagedevice" *PageSize C1/C1: "<>setpagedevice" *PageSize C2/C2: "<>setpagedevice" *PageSize C3/C3: "<>setpagedevice" *PageSize C4/C4: "<>setpagedevice" *PageSize C5/C5: "<>setpagedevice" *PageSize Env10/Envelope #10: "<>setpagedevice" *PageSize EnvC5/Envelope C5: "<>setpagedevice" *PageSize EnvDL/Envelope DL: "<>setpagedevice" *PageSize EnvMonarch/Envelope Monarch: "<>setpagedevice" *PageSize Executive/Executive: "<>setpagedevice" *PageSize ISOB0/B0 (ISO): "<>setpagedevice" *PageSize ISOB1/B1 (ISO): "<>setpagedevice" *PageSize ISOB2/B2 (ISO): "<>setpagedevice" *PageSize ISOB3/B3 (ISO): "<>setpagedevice" *PageSize ISOB4/B4 (ISO): "<>setpagedevice" *PageSize ISOB5/B5 (ISO): "<>setpagedevice" *PageSize JISB0/B0 (JIS): "<>setpagedevice" *PageSize JISB1/B1 (JIS): "<>setpagedevice" *PageSize JISB2/B2 (JIS): "<>setpagedevice" *PageSize JISB3/B3 (JIS): "<>setpagedevice" *PageSize JISB4/B4 (JIS): "<>setpagedevice" *PageSize JISB5/B5 (JIS): "<>setpagedevice" *PageSize Ledger/Ledger: "<>setpagedevice" *PageSize Legal/US Legal: "<>setpagedevice" *PageSize Letter/US Letter: "<>setpagedevice" *PageSize RA0/RA0: "<>setpagedevice" *PageSize RA1/RA1: "<>setpagedevice" *PageSize RA2/RA2: "<>setpagedevice" *PageSize RA3/RA3: "<>setpagedevice" *PageSize RA4/RA4: "<>setpagedevice" *PageSize SRA0/SRA0: "<>setpagedevice" *PageSize SRA1/SRA1: "<>setpagedevice" *PageSize SRA2/SRA2: "<>setpagedevice" *PageSize SRA3/SRA3: "<>setpagedevice" *PageSize SRA4/SRA4: "<>setpagedevice" *PageSize SuperA/Super A: "<>setpagedevice" *PageSize SuperB/Super B: "<>setpagedevice" *PageSize TabloidExtra/Tabloid Extra: "<>setpagedevice" *PageSize Tabloid/Tabloid: "<>setpagedevice" *CloseUI: *PageSize *OpenUI *PageRegion: PickOne *OrderDependency: 100 AnySetup *PageRegion *DefaultPageRegion: A4 *PageRegion 11x14/11x14: "<>setpagedevice" *PageRegion 11x17/11x17: "<>setpagedevice" *PageRegion 13x19/13x19: "<>setpagedevice" *PageRegion 16x20/16x20: "<>setpagedevice" *PageRegion 16x24/16x24: "<>setpagedevice" *PageRegion 2A/2A: "<>setpagedevice" *PageRegion 4A/4A: "<>setpagedevice" *PageRegion 8x10/8x10: "<>setpagedevice" *PageRegion 8x12/8x12: "<>setpagedevice" *PageRegion A0/A0: "<>setpagedevice" *PageRegion A1/A1: "<>setpagedevice" *PageRegion A2/A2: "<>setpagedevice" *PageRegion A3/A3: "<>setpagedevice" *PageRegion A4/A4: "<>setpagedevice" *PageRegion A5/A5: "<>setpagedevice" *PageRegion AnsiA/ANSI A: "<>setpagedevice" *PageRegion AnsiB/ANSI B: "<>setpagedevice" *PageRegion AnsiC/ANSI C: "<>setpagedevice" *PageRegion AnsiD/ANSI D: "<>setpagedevice" *PageRegion AnsiE/ANSI E: "<>setpagedevice" *PageRegion ArchA/Arch A: "<>setpagedevice" *PageRegion ArchB/Arch B: "<>setpagedevice" *PageRegion ArchC/Arch C: "<>setpagedevice" *PageRegion ArchD/Arch D: "<>setpagedevice" *PageRegion ArchE/Arch E: "<>setpagedevice" *PageRegion C0/C0: "<>setpagedevice" *PageRegion C1/C1: "<>setpagedevice" *PageRegion C2/C2: "<>setpagedevice" *PageRegion C3/C3: "<>setpagedevice" *PageRegion C4/C4: "<>setpagedevice" *PageRegion C5/C5: "<>setpagedevice" *PageRegion Env10/Envelope #10: "<>setpagedevice" *PageRegion EnvC5/Envelope C5: "<>setpagedevice" *PageRegion EnvDL/Envelope DL: "<>setpagedevice" *PageRegion EnvMonarch/Envelope Monarch: "<>setpagedevice" *PageRegion Executive/Executive: "<>setpagedevice" *PageRegion ISOB0/B0 (ISO): "<>setpagedevice" *PageRegion ISOB1/B1 (ISO): "<>setpagedevice" *PageRegion ISOB2/B2 (ISO): "<>setpagedevice" *PageRegion ISOB3/B3 (ISO): "<>setpagedevice" *PageRegion ISOB4/B4 (ISO): "<>setpagedevice" *PageRegion ISOB5/B5 (ISO): "<>setpagedevice" *PageRegion JISB0/B0 (JIS): "<>setpagedevice" *PageRegion JISB1/B1 (JIS): "<>setpagedevice" *PageRegion JISB2/B2 (JIS): "<>setpagedevice" *PageRegion JISB3/B3 (JIS): "<>setpagedevice" *PageRegion JISB4/B4 (JIS): "<>setpagedevice" *PageRegion JISB5/B5 (JIS): "<>setpagedevice" *PageRegion Ledger/Ledger: "<>setpagedevice" *PageRegion Legal/US Legal: "<>setpagedevice" *PageRegion Letter/US Letter: "<>setpagedevice" *PageRegion RA0/RA0: "<>setpagedevice" *PageRegion RA1/RA1: "<>setpagedevice" *PageRegion RA2/RA2: "<>setpagedevice" *PageRegion RA3/RA3: "<>setpagedevice" *PageRegion RA4/RA4: "<>setpagedevice" *PageRegion SRA0/SRA0: "<>setpagedevice" *PageRegion SRA1/SRA1: "<>setpagedevice" *PageRegion SRA2/SRA2: "<>setpagedevice" *PageRegion SRA3/SRA3: "<>setpagedevice" *PageRegion SRA4/SRA4: "<>setpagedevice" *PageRegion SuperA/Super A: "<>setpagedevice" *PageRegion SuperB/Super B: "<>setpagedevice" *PageRegion TabloidExtra/Tabloid Extra: "<>setpagedevice" *PageRegion Tabloid/Tabloid: "<>setpagedevice" *CloseUI: *PageRegion *DefaultImageableArea: A4 *ImageableArea 11x14/11x14: "0 0 792 1008" *ImageableArea 11x17/11x17: "0 0 792 1224" *ImageableArea 13x19/13x19: "0 0 936 1368" *ImageableArea 16x20/16x20: "0 0 1152 1440" *ImageableArea 16x24/16x24: "0 0 1152 1728" *ImageableArea 2A/2A: "0 0 3370 4768" *ImageableArea 4A/4A: "0 0 4768 6749" *ImageableArea 8x10/8x10: "0 0 576 720" *ImageableArea 8x12/8x12: "0 0 576 864" *ImageableArea A0/A0: "0 0 2384 3370" *ImageableArea A1/A1: "0 0 1684 2384" *ImageableArea A2/A2: "0 0 1191 1684" *ImageableArea A3/A3: "0 0 842 1191" *ImageableArea A4/A4: "0 0 595 842" *ImageableArea A5/A5: "0 0 421 595" *ImageableArea AnsiA/ANSI A: "0 0 612 792" *ImageableArea AnsiB/ANSI B: "0 0 792 1224" *ImageableArea AnsiC/ANSI C: "0 0 1224 1584" *ImageableArea AnsiD/ANSI D: "0 0 1584 2448" *ImageableArea AnsiE/ANSI E: "0 0 2448 3168" *ImageableArea ArchA/Arch A: "0 0 648 864" *ImageableArea ArchB/Arch B: "0 0 864 1296" *ImageableArea ArchC/Arch C: "0 0 1296 1728" *ImageableArea ArchD/Arch D: "0 0 1728 2592" *ImageableArea ArchE/Arch E: "0 0 2592 3456" *ImageableArea C0/C0: "0 0 2599 3676" *ImageableArea C1/C1: "0 0 1836 2599" *ImageableArea C2/C2: "0 0 1298 1836" *ImageableArea C3/C3: "0 0 918 1298" *ImageableArea C4/C4: "0 0 649 918" *ImageableArea C5/C5: "0 0 459 649" *ImageableArea Env10/Envelope #10: "0 0 297 684" *ImageableArea EnvC5/Envelope C5: "0 0 459 649" *ImageableArea EnvDL/Envelope DL: "0 0 312 624" *ImageableArea EnvMonarch/Envelope Monarch: "0 0 279 540" *ImageableArea Executive/Executive: "0 0 522 756" *ImageableArea ISOB0/B0 (ISO): "0 0 2834 4008" *ImageableArea ISOB1/B1 (ISO): "0 0 2004 2834" *ImageableArea ISOB2/B2 (ISO): "0 0 1417 2004" *ImageableArea ISOB3/B3 (ISO): "0 0 1000 1417" *ImageableArea ISOB4/B4 (ISO): "0 0 708 1000" *ImageableArea ISOB5/B5 (ISO): "0 0 498 708" *ImageableArea JISB0/B0 (JIS): "0 0 2919 4127" *ImageableArea JISB1/B1 (JIS): "0 0 2063 2919" *ImageableArea JISB2/B2 (JIS): "0 0 1459 2063" *ImageableArea JISB3/B3 (JIS): "0 0 1029 1459" *ImageableArea JISB4/B4 (JIS): "0 0 727 1029" *ImageableArea JISB5/B5 (JIS): "0 0 518 727" *ImageableArea Ledger/Ledger: "0 0 1224 792" *ImageableArea Legal/US Legal: "0 0 612 1008" *ImageableArea Letter/US Letter: "0 0 612 792" *ImageableArea RA0/RA0: "0 0 2437 3458" *ImageableArea RA1/RA1: "0 0 1729 2437" *ImageableArea RA2/RA2: "0 0 1218 1729" *ImageableArea RA3/RA3: "0 0 864 1218" *ImageableArea RA4/RA4: "0 0 609 864" *ImageableArea SRA0/SRA0: "0 0 2551 3628" *ImageableArea SRA1/SRA1: "0 0 1814 2551" *ImageableArea SRA2/SRA2: "0 0 1275 1814" *ImageableArea SRA3/SRA3: "0 0 907 1275" *ImageableArea SRA4/SRA4: "0 0 637 907" *ImageableArea SuperA/Super A: "0 0 644 1008" *ImageableArea SuperB/Super B: "0 0 936 1368" *ImageableArea TabloidExtra/Tabloid Extra: "0 0 864 1296" *ImageableArea Tabloid/Tabloid: "0 0 792 1224" *DefaultPaperDimension: A4 *PaperDimension 11x14/11x14: "792 1008" *PaperDimension 11x17/11x17: "792 1224" *PaperDimension 13x19/13x19: "936 1368" *PaperDimension 16x20/16x20: "1152 1440" *PaperDimension 16x24/16x24: "1152 1728" *PaperDimension 2A/2A: "3370 4768" *PaperDimension 4A/4A: "4768 6749" *PaperDimension 8x10/8x10: "576 720" *PaperDimension 8x12/8x12: "576 864" *PaperDimension A0/A0: "2384 3370" *PaperDimension A1/A1: "1684 2384" *PaperDimension A2/A2: "1191 1684" *PaperDimension A3/A3: "842 1191" *PaperDimension A4/A4: "595 842" *PaperDimension A5/A5: "421 595" *PaperDimension AnsiA/ANSI A: "612 792" *PaperDimension AnsiB/ANSI B: "792 1224" *PaperDimension AnsiC/ANSI C: "1224 1584" *PaperDimension AnsiD/ANSI D: "1584 2448" *PaperDimension AnsiE/ANSI E: "2448 3168" *PaperDimension ArchA/Arch A: "648 864" *PaperDimension ArchB/Arch B: "864 1296" *PaperDimension ArchC/Arch C: "1296 1728" *PaperDimension ArchD/Arch D: "1728 2592" *PaperDimension ArchE/Arch E: "2592 3456" *PaperDimension C0/C0: "2599 3676" *PaperDimension C1/C1: "1836 2599" *PaperDimension C2/C2: "1298 1836" *PaperDimension C3/C3: "918 1298" *PaperDimension C4/C4: "649 918" *PaperDimension C5/C5: "459 649" *PaperDimension Env10/Envelope #10: "297 684" *PaperDimension EnvC5/Envelope C5: "459 649" *PaperDimension EnvDL/Envelope DL: "312 624" *PaperDimension EnvMonarch/Envelope Monarch: "279 540" *PaperDimension Executive/Executive: "522 756" *PaperDimension ISOB0/B0 (ISO): "2834 4008" *PaperDimension ISOB1/B1 (ISO): "2004 2834" *PaperDimension ISOB2/B2 (ISO): "1417 2004" *PaperDimension ISOB3/B3 (ISO): "1000 1417" *PaperDimension ISOB4/B4 (ISO): "708 1000" *PaperDimension ISOB5/B5 (ISO): "498 708" *PaperDimension JISB0/B0 (JIS): "2919 4127" *PaperDimension JISB1/B1 (JIS): "2063 2919" *PaperDimension JISB2/B2 (JIS): "1459 2063" *PaperDimension JISB3/B3 (JIS): "1029 1459" *PaperDimension JISB4/B4 (JIS): "727 1029" *PaperDimension JISB5/B5 (JIS): "518 727" *PaperDimension Ledger/Ledger: "1224 792" *PaperDimension Legal/US Legal: "612 1008" *PaperDimension Letter/US Letter: "612 792" *PaperDimension RA0/RA0: "2437 3458" *PaperDimension RA1/RA1: "1729 2437" *PaperDimension RA2/RA2: "1218 1729" *PaperDimension RA3/RA3: "864 1218" *PaperDimension RA4/RA4: "609 864" *PaperDimension SRA0/SRA0: "2551 3628" *PaperDimension SRA1/SRA1: "1814 2551" *PaperDimension SRA2/SRA2: "1275 1814" *PaperDimension SRA3/SRA3: "907 1275" *PaperDimension SRA4/SRA4: "637 907" *PaperDimension SuperA/Super A: "644 1008" *PaperDimension SuperB/Super B: "936 1368" *PaperDimension TabloidExtra/Tabloid Extra: "864 1296" *PaperDimension Tabloid/Tabloid: "792 1224" *OpenUI *Resolution/Output Resolution: PickOne *OrderDependency: 100 AnySetup *Resolution *DefaultResolution: 300dpi *Resolution 150dpi/150 DPI: "<>setpagedevice" *Resolution 300dpi/300 DPI: "<>setpagedevice" *Resolution 600dpi/600 DPI: "<>setpagedevice" *Resolution 1200dpi/1200 DPI: "<>setpagedevice" *Resolution 2400dpi/2400 DPI: "<>setpagedevice" *CloseUI: *Resolution *CloseGroup: General *DefaultFont: Courier *Font AvantGarde-Book: Standard "(001.006S)" Standard ROM *Font AvantGarde-BookOblique: Standard "(001.006S)" Standard ROM *Font AvantGarde-Demi: Standard "(001.007S)" Standard ROM *Font AvantGarde-DemiOblique: Standard "(001.007S)" Standard ROM *Font Bookman-Demi: Standard "(001.004S)" Standard ROM *Font Bookman-DemiItalic: Standard "(001.004S)" Standard ROM *Font Bookman-Light: Standard "(001.004S)" Standard ROM *Font Bookman-LightItalic: Standard "(001.004S)" Standard ROM *Font Courier: Standard "(002.004S)" Standard ROM *Font Courier-Bold: Standard "(002.004S)" Standard ROM *Font Courier-BoldOblique: Standard "(002.004S)" Standard ROM *Font Courier-Oblique: Standard "(002.004S)" Standard ROM *Font Helvetica: Standard "(001.006S)" Standard ROM *Font Helvetica-Bold: Standard "(001.007S)" Standard ROM *Font Helvetica-BoldOblique: Standard "(001.007S)" Standard ROM *Font Helvetica-Narrow: Standard "(001.006S)" Standard ROM *Font Helvetica-Narrow-Bold: Standard "(001.007S)" Standard ROM *Font Helvetica-Narrow-BoldOblique: Standard "(001.007S)" Standard ROM *Font Helvetica-Narrow-Oblique: Standard "(001.006S)" Standard ROM *Font Helvetica-Oblique: Standard "(001.006S)" Standard ROM *Font NewCenturySchlbk-Bold: Standard "(001.009S)" Standard ROM *Font NewCenturySchlbk-BoldItalic: Standard "(001.007S)" Standard ROM *Font NewCenturySchlbk-Italic: Standard "(001.006S)" Standard ROM *Font NewCenturySchlbk-Roman: Standard "(001.007S)" Standard ROM *Font Palatino-Bold: Standard "(001.005S)" Standard ROM *Font Palatino-BoldItalic: Standard "(001.005S)" Standard ROM *Font Palatino-Italic: Standard "(001.005S)" Standard ROM *Font Palatino-Roman: Standard "(001.005S)" Standard ROM *Font Symbol: Special "(001.007S)" Special ROM *Font Times-Bold: Standard "(001.007S)" Standard ROM *Font Times-BoldItalic: Standard "(001.009S)" Standard ROM *Font Times-Italic: Standard "(001.007S)" Standard ROM *Font Times-Roman: Standard "(001.007S)" Standard ROM *Font ZapfChancery-MediumItalic: Standard "(001.007S)" Standard ROM *Font ZapfDingbats: Special "(001.004S)" Standard ROM *% *% End of "$Id: postscript.ppd,v 1.1.1.1 2000/08/24 19:23:13 goffioul Exp $". *% cups-pdf-2.6.1/extra/cups-pdf.conf0000644000215500007650000002246511642634006016151 0ustar vrbehrstaff# cups-pdf.conf -- CUPS Backend Configuration (version 2.6.1, 2011-10-04) # 18.09.2005, Volker C. Behr # Experimentelle Physik V, Universitaet Wuerzburg # behr@physik.uni-wuerzburg.de # http://www.cups-pdf.de # # # This code may be freely distributed as long as this header # is preserved. Changes to the code should be clearly indicated. # # This code is distributed under the GPL. # (http://www.gnu.org/copyleft/gpl.html) # # For more detailed licensing information see cups-pdf.c in the # corresponding version number. ########################################################################### # # # This is the configuration file for CUPS-PDF. Values that are not set in # # here will use the defaults. Changes take effect immediately without the # # need for restarting any services. # # # # Take care not to add whitespaces at the end of a line! # # # ########################################################################### ########################################################################### # # # Path Settings # # # ########################################################################### ### Key: Out ## CUPS-PDF output directory ## special qualifiers: ## ${HOME} will be expanded to the user's home directory ## ${USER} will be expanded to the user name ## in case it is an NFS export make sure it is exported without ## root_squash! ### Default: /var/spool/cups-pdf/${USER} #Out /var/spool/cups-pdf/${USER} ### Key: AnonDirName ## ABSOLUTE path for anonymously created PDF files ## if anonymous access is disabled this setting has no effect ### Default: /var/spool/cups-pdf/ANONYMOUS #AnonDirName /var/spool/cups-pdf/ANONYMOUS ### Key: Spool ## CUPS-PDF spool directory - make sure there is no user 'SPOOL' on your ## system or change the path ### Default: /var/spool/cups-pdf/SPOOL #Spool /var/spool/cups-pdf/SPOOL ########################################################################### # # # Filename Settings # # # ########################################################################### ### Key: Truncate ## truncate long filenames to a maximum of characters ## this does not consider the full path to the output but only the filename ## without the .pdf-extension or a job-id prefix (see 'Label') ## the minimal value is 8 ### Default: 64 #Truncate 64 ### Key: Cut ## removing file name extensions before appending .pdf to output ## extensions will only be removed if _both_ the following criteria are met: ## - the extension (w/o the dot) is not longer than characters ## - the remaining filename has a minimal length of 1 character ## set Cut to -1 in order to disable cutting ## recommended values: pure UNIX environment : -1 ## mixed environments : 3 ### Default: 3 #Cut 3 ### Key: Label ## label all jobs with a unique job-id in order to avoid overwriting old ## files in case new ones with identical names are created; always true for ## untitled documents ## 0: label untitled documents only ## 1: label all documents with a preceeding "job_#-" ## 2: label all documents with a tailing "-job_#" ### Default: 0 #Label 0 ### Key: TitlePref ## where to look first for a title when creating the output filename ## (title in PS file or title on commandline): ## 0: prefer title from %Title statement in the PS file ## 1: prefer title passed via commandline ### Default: 0 #TitlePref 0 ########################################################################### # # # User Settings # # # ########################################################################### ### Key: AnonUser ## uid for anonymous PDF creation (this might be a security issue) ## this setting has no influence on AnonDirName (see there) ## set this to an empty value to disable anonymous ### Default: nobody #AnonUser nobody ### Key: LowerCase ## This options allows to check user names given to CUPS-PDF additionally ## against their lower case variants. This is necessary since in some ## Windows environments only upper case user names are passed. Usually UNIX ## user names are all lower case and it is save to use this option ## but be aware that it can lead to mis-identifications in case ## you have user names that differ only in upper/lower case. ## check only against user name as passed to CUPS : 0 ## check additionally against lower case user name : 1 ### Default: 1 #LowerCase 1 ### Key: UserPrefix ## some installations require a domain prefix added to the user name ## leave empty for no prefix ### Default: #UserPrefix ### Key: DirPrefix ## if a prefix was defined above this switch toggels whether to include ## the prefix in the output directory's name (if not $HOME) or not ## 0: do not include, 1: include ### Default: 0 #DirPrefix 0 ### Key: RemovePrefix ## some installation pass usernames with a prefix (usually a domain name) ## if you do not want this prefix to be used by the ${USER} variable for ## output directories put the part which is to be cut here ### Default: #RemovePrefix ########################################################################### # # # Security Settings # # # ########################################################################### ### Key: AnonUMask ## umask for anonymous output ## these are the _inverse_ permissions to be granted ### Default: 0000 #AnonUMask 0000 ### Key: UserUMask ## umask for user output of known users ## changing this can introduce security leaks if confidential ## information is processed! ### Default: 0077 #UserUMask 0077 ### Key: Grp ## group cups-pdf is supposed to run as - this will also be the gid for all ## created directories and log files ### Default: lp #Grp lp ########################################################################### # # # Log Settings # # # ########################################################################### ### Key: Log ## CUPS-PDF log directory ## set this to an empty value to disable all logging ### Default: /var/log/cups #Log /var/log/cups ### Key: LogType ## log-mode ## 1: errors ## 2: status (i.e. activity) ## 4: debug - this will generate a lot of log-output! ## add up values to combine options, i.e. 7 is full logging ## if logging is disabled these setting have no effect ### Default: 3 #LogType 3 ########################################################################### # # # PDF Conversion Settings # # # ########################################################################### ### Key: GhostScript ## location of GhostScript binary (gs) ## MacOSX: for using pstopdf (recommended) set this to /usr/bin/pstopdf ## or its proper location on your system ### Default: /usr/bin/gs #GhostScript /usr/bin/gs ### Key: GSTmp ## location of temporary files during GhostScript operation ## this must be user-writable like /var/tmp or /tmp ! ### Default: /var/tmp #GSTmp /var/tmp ### Key: GSCall ## command line for calling GhostScript (!!! DO NOT USE NEWLINES !!!) ## MacOSX: for using pstopdf set this to %s %s -o %s %s ### Default: %s -q -dCompatibilityLevel=%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile="%s" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f %s #GSCall %s -q -dCompatibilityLevel=%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile="%s" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f %s ### Key: PDFVer ## PDF version to be created - can be "1.5", "1.4", "1.3" or "1.2" ## MacOSX: for using pstopdf set this to an empty value ### Default: 1.4 #PDFVer 1.4 ### Key: PostProcessing ## postprocessing script that will be called after the creation of the PDF ## as arguments the filename of the PDF, the username as determined by ## CUPS-PDF and the one as given to CUPS-PDF will be passed ## the script will be called with user privileges ## set this to an empty value to use no postprocessing ### Default: #PostProcessing ########################################################################### # # # Experimental Settings # # These settings activate experimental options. If you decide to use # # them I would appreciate any feedback - including an 'ok' if they # # work as expected - so I can eventually put them into the non- # # experimental sections. # # # ########################################################################### ### Key: DecodeHexStrings ## this option will try to decode hex strings in the title to allow ## internationalized titles ## (have a look at contrib/pstitleconv for a suitable filter for data ## from Windows clients) ## 0: disable, 1: enable ### Default: 0 #DecodeHexStrings 0 ### Key: FixNewlines ## this option will try to fix various unusal line delimiters (e.g. ## form feeds) ## especially useful when using non-Linux-generated files ## 0: disable, 1: enable ### Default: 0 #FixNewlines 0 cups-pdf-2.6.1/ChangeLog0000644000215500007650000001744311642637743014223 0ustar vrbehrstaff2011-10-04: CUPS-PDF 2.6.1 - fixed a non-freed pointer, fixed an invalid line in the config due to a typo, added detailed copyright information to contrib/ 2011-10-01 : CUPS-PDF 2.6.0 - new experimental option for various line delimiters, supplementary groups are set in addition to primary 2011-02-18 : CUPS-PDF 2.5.1 - fixed crash due to an uninitialized pointer, improved logging mechanism in case of crashes, improved recognition of untitled documents via stdin, job labels can be set before and after document name, removed several bashisms from SELinux-contribution 2009-01-26 : CUPS-PDF 2.5.0 - new option to truncate long filenames, spoolfile is purged on errors, failed chmod() on output is treated as non-fatal, updates and additions to the documentation, removed additional changelog from source code 2008-06-22 : CUPS-PDF 2.4.8 - fixed too small allocation of postprocessing string, corrected typo in the config file documentation, update for the SELinux .te-file in contrib/ 2008-03-24 : CUPS-PDF 2.4.7 - corrected the exit codes to match CUPS' specifications, original username passed to PostProcessing as 3rd arg, made PPD file auto-selectable via IEEE-1284 device id 2007-05-04 : CUPS-PDF 2.4.6 - optimized default options for GS to produce PDFs 2007-02-27 : CUPS-PDF 2.4.5 - enclosing parentheses () are removed from title, set a more comprehensive identification string 2007-02-02 : CUPS-PDF 2.4.4 - DOS-style path separators '\' are now recognized 2006-11-22 : CUPS-PDF 2.4.3 - replaced 'setenv' by 'putenv' to increase compatibility 2006-09-30 : CUPS-PDF 2.4.2 - several code optimizations, PostScript PPD now uncompressed and rev4 only 2006-06-13 : CUPS-PDF 2.4.1 - added a PDF-to-mail postprocessing script to contrib/, added a new revision of the PostscriptColor PPD file 2006-05-28 : CUPS-PDF 2.4.0 - created the contrib/ directory with additional software 2006-05-17 : CUPS-PDF 2.3.1 - fixed possible read access after end of string, fixed recognition of international characters 2006-05-14 : CUPS-PDF 2.3.0 - experimental option to decode hex strings in title (NK) 2006-04-14 : CUPS-PDF 2.2.0 - new option to remove prefixes from usernames 2006-04-06 : CUPS-PDF 2.1.1 - minor bugfix to read umasks properly 2006-03-25 : CUPS-PDF 2.1.0 - new option to select where to look for title, some code changes and optimizations 2006-02-26 : CUPS-PDF 2.0.5 - several code optimizations 2006-01-29 : CUPS-PDF 2.0.4 - beginning of (E)PS-code now determined by "%!", optimized system call to GS in cups-pdf.conf, some minor code changes, debug information shows version number, updated PostScript PPD file supporting ledger paper 2006-01-07 : CUPS-PDF 2.0.3 - improved checking for root privileges (incl. EUID) 2006-01-04 : CUPS-PDF 2.0.2 - fixed possible testing of an uninitialized variable 2006-01-03 : CUPS-PDF 2.0.1 - fixed hanging jobs when logging is disabled 2005-12-23 : CUPS-PDF 2.0.0 - creation of non-existent parent directories, improved configurability of output directories, option CPHOMESUB is now obsolete, PPD file now matches Adobe specifications 2005-10-23 : CUPS-PDF 2.0beta2 - added support for post-processing script, fixed a bug when parsing cups-pdf.conf 2005-09-18 : CUPS-PDF 2.0beta1 - added support for runtime configuration, introduced cups-pdf.conf, made AnonDirName an abolute path 2005-09-08 : CUPS-PDF 1.7.4 - added some options to cups-pdf.h for MacOSX 2005-07-23 : CUPS-PDF 1.7.3 - fixed GhostScript failure with error 11, fixed segfault when called without root privileges 2005-07-07 : CUPS-PDF 1.7.2 - adjustment of file mode moved to non-privileged child 2005-06-16 : CUPS-PDF 1.7.1 - PDFs are protected during creation by file mode 000 2005-03-07 : CUPS-PDF 1.7.0a 2005-03-01 : CUPS-PDF 1.7.0 - call of GhostScript from a non-privileged child process, no more additional programs in the call of GhostScript, several code optimizations 2005-02-09 : CUPS-PDF 1.6.6 - updated PostScript PPD file supporting more DIN formats 2005-01-04 : CUPS-PDF 1.6.5 - cups-pdf is running with gid of group defined in CPGRP 2004-10-11 : CUPS-PDF 1.6.4 - improved configurability for different versions of 'su' 2004-10-07 : CUPS-PDF 1.6.3 - corrected erroneous call of GhostScript 2004-10-05 : CUPS-PDF 1.6.2 - added necessary quotes in the call of GhostScript 2004-10-03 : CUPS-PDF 1.6.1 - allow users w/o valid shell in /etc/passwd, several code optimizations 2004-09-08 : CUPS-PDF 1.6.0 - new option to check against user names in lower case, new option to label all created PDFs with a job-id 2004-08-10 : CUPS-PDF 1.5.2 - fixed insecure creation of spoolfile, several smaller code optimizations 2004-08-09 : CUPS-PDF 1.5.1 - fixed possible access to element outside allocated area, fixed possible conflict with overlapping memory areas 2004-08-03 : CUPS-PDF 1.5.0 - call to GS without root privileges for enhanced security 2004-08-01 : CUPS-PDF 1.4.3 - added -dSAFER to the call to GS to improve security 2004-02-25 : CUPS-PDF 1.4.2a 2004-02-24 : CUPS-PDF 1.4.2 - improved extraction of filenames, handling of embedded (e)ps code (RVT) 2004-02-09 : CUPS-PDF 1.4.1 - logfile is created with mode 644 if it does not exist 2004-01-27 : CUPS-PDF 1.4.0 - new option to set permissions for PDF output, alternative options for improved image conversion (moved CPGSCALL to cups-pdf.h) 2004-01-06 : CUPS-PDF 1.3.2 - exit status of ghostscript gets logged in debug mode 2004-01-02 : CUPS-PDF 1.3.1a 2003-11-29 : CUPS-PDF 1.3.1 - improved handling of domain prefix 2003-11-02 : CUPS-PDF 1.3 - new option to cut file name extensions 2003-10-25 : CUPS-PDF 1.2 - untitled documents are labelled with job-id, new option to add a domain prefix to user names, removed a minor bug during character replacement 2003-08-02 : CUPS-PDF 1.1 - files not viewable until creation is finished, new qualifier "$HOME" for output directory, "$HOME"-related new define in the header file 2003-07-17 : CUPS-PDF 1.0.1 - improved user name handling for multi-word names, code now distributed under the GPL 2003-06-29 : CUPS-PDF 1.0 - enhanced debug output, replacement of special characters in title, new option in the header file 2003-05-26 : CUPS-PDF 1.0pre3 - several minor bugfixes and improvements 2003-05-21 : CUPS-PDF 1.0pre2 - optimized memory management 2003-05-16 : CUPS-PDF 1.0pre1 - introduced cups-pdf.h, code now entirely written in C, cups-pdfgen is obsolete 2003-02-14 : CUPS-PDF 0.2 - script re-located to /usr/lib/cups/filter/cups-pdfgen 2003-02-12 : CUPS-PDF 0.1 - first beta release cups-pdf-2.6.1/src/0000755000215500007650000000000011642640503013213 5ustar vrbehrstaffcups-pdf-2.6.1/src/cups-pdf.c0000644000215500007650000006273611642634405015122 0ustar vrbehrstaff/* cups-pdf.c -- CUPS Backend (version 2.6.1, 2011-10-04) 08.02.2003, Volker C. Behr Experimentelle Physik V, Universitaet Wuerzburg behr@physik.uni-wuerzburg.de http://www.cups-pdf.de This code may be freely distributed as long as this header is preserved. This code is distributed under the GPL. (http://www.gnu.org/copyleft/gpl.html) --------------------------------------------------------------------------- Copyright (C) 2003-2011 Volker C. Behr This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --------------------------------------------------------------------------- If you want to redistribute modified sources/binaries this header has to be preserved and all modifications should be clearly indicated. In case you want to include this code into your own programs I would appreciate your feedback via email. HISTORY: see ChangeLog in the parent directory of the source archive */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cups-pdf.h" extern int errno; static FILE *logfp=NULL; static void log_event(short type, char message[], char *detail) { time_t secs; char ctype[8], *timestring; if (strlen(conf.log) && (type & conf.logtype)) { (void) time(&secs); timestring=ctime(&secs); timestring[strlen(timestring)-1]='\0'; if (type == CPERROR) snprintf(ctype, 8, "ERROR"); else if (type == CPSTATUS) snprintf(ctype, 8, "STATUS"); else snprintf(ctype, 8, "DEBUG"); if (detail != NULL) { while (detail[strlen(detail)-1] == '\n') detail[strlen(detail)-1]='\0'; fprintf(logfp,"%s [%s] %s (%s)\n", timestring, ctype, message, detail); if ((conf.logtype & CPDEBUG) && (type & CPERROR)) fprintf(logfp,"%s [DEBUG] ERRNO: %d\n", timestring, errno); } else fprintf(logfp,"%s [%s] %s\n", timestring, ctype, message); (void) fflush(logfp); } return; } static void read_config() { FILE *fp; cp_string buffer, key, value; fp=fopen(CPCONFIG,"r"); if (fp==NULL) return; while (fgets(buffer, BUFSIZE, fp) != NULL) { key[0]='\0'; value[0]='\0'; if (sscanf(buffer,"%s %[^\n]",key,value)) { if (!strlen(key) || !strncmp(key,"#",1)) continue; if (!_assign_value(key, value)) (void) fputs("Error in configuration file!\n", stderr); } } (void) fclose(fp); return; } static int create_dir(char *dirname, int nolog) { struct stat fstatus; char buffer[BUFSIZE],*delim; int i; while ((i=strlen(dirname))>1 && dirname[i-1]=='/') dirname[i-1]='\0'; if (stat(dirname, &fstatus) || !S_ISDIR(fstatus.st_mode)) { strncpy(buffer,dirname,BUFSIZE); delim=strrchr(buffer,'/'); if (delim!=buffer) delim[0]='\0'; else delim[1]='\0'; if (create_dir(buffer,nolog)!=0) return 1; (void) stat(buffer, &fstatus); if (mkdir(dirname,fstatus.st_mode)!=0) { if (!nolog) log_event(CPERROR, "failed to create directory", dirname); return 1; } else if (!nolog) log_event(CPSTATUS, "directory created", dirname); if (chown(dirname,fstatus.st_uid,fstatus.st_gid)!=0) if (!nolog) log_event(CPDEBUG, "failed to set owner on directory (non fatal)", dirname); } return 0; } static int init() { struct stat fstatus; struct group *group; cp_string logfile; _set_defaults(); if (strlen(CPCONFIG)) if (!stat(CPCONFIG, &fstatus) && (S_ISREG(fstatus.st_mode) || S_ISLNK(fstatus.st_mode))) read_config(); (void) umask(0077); group=getgrnam(conf.grp); if (group) (void) setgid(group->gr_gid); if (strlen(conf.log)) { if (stat(conf.log, &fstatus) || !S_ISDIR(fstatus.st_mode)) { if (create_dir(conf.log, 1)) return 1; if (chmod(conf.log, 0700)) return 1; log_event(CPSTATUS, "log directory created", conf.log); } snprintf(logfile,BUFSIZE,"%s%s",conf.log,"/cups-pdf_log"); logfp=fopen(logfile, "a"); } if (!group) { log_event(CPERROR, "Grp not found", conf.grp); return 1; } else log_event(CPDEBUG, "switching to new gid", conf.grp); (void) umask(0022); if (stat(conf.spool, &fstatus) || !S_ISDIR(fstatus.st_mode)) { if (create_dir(conf.spool, 0)) { log_event(CPERROR, "failed to create spool directory", conf.spool); return 1; } if (chmod(conf.spool, 0751)) { log_event(CPERROR, "failed to set mode on spool directory", conf.spool); return 1; } if (chown(conf.spool, -1, group->gr_gid)) log_event(CPERROR, "failed to set group id on spool directory (non fatal)", conf.grp); log_event(CPSTATUS, "spool directory created", conf.spool); } (void) umask(0077); return 0; } static char *preparedirname(struct passwd *passwd, char *uname) { int size; char bufin[BUFSIZE], bufout[BUFSIZE], *needle, *cptr; needle=strstr(uname, conf.removeprefix); if ((int)strlen(uname)>(size=strlen(conf.removeprefix))) uname=uname+size; strncpy(bufin, conf.out, BUFSIZE); do { needle=strstr(bufin, "${HOME}"); if (needle == NULL) break; needle[0]='\0'; cptr=needle+7; snprintf(bufout, BUFSIZE, "%s%s%s", bufin, passwd->pw_dir, cptr); strncpy(bufin, bufout, BUFSIZE); } while (needle != NULL); do { needle=strstr(bufin, "${USER}"); if (needle == NULL) break; needle[0]='\0'; cptr=needle+7; if (!conf.dirprefix) snprintf(bufout, BUFSIZE, "%s%s%s", bufin, uname, cptr); else snprintf(bufout, BUFSIZE, "%s%s%s", bufin, passwd->pw_name, cptr); strncpy(bufin, bufout, BUFSIZE); } while (needle != NULL); size=strlen(bufin)+1; cptr=calloc(size, sizeof(char)); if (cptr == NULL) return NULL; snprintf(cptr,size,"%s",bufin); return cptr; } static int prepareuser(struct passwd *passwd, char *dirname) { struct stat fstatus; (void) umask(0000); if (stat(dirname, &fstatus) || !S_ISDIR(fstatus.st_mode)) { if (!strcmp(passwd->pw_name, conf.anonuser)) { if (create_dir(dirname, 0)) { log_event(CPERROR, "failed to create anonymous output directory", dirname); return 1; } if (chmod(dirname, (mode_t)(0777&~conf.anonumask))) { log_event(CPERROR, "failed to set mode on anonymous output directory", dirname); return 1; } log_event(CPDEBUG, "anonymous output directory created", dirname); } else { if (create_dir(dirname, 0)) { log_event(CPERROR, "failed to create user output directory", dirname); return 1; } if (chmod(dirname, (mode_t)(0777&~conf.userumask))) { log_event(CPERROR, "failed to set mode on user output directory", dirname); return 1; } log_event(CPDEBUG, "user output directory created", dirname); } if (chown(dirname, passwd->pw_uid, passwd->pw_gid)) { log_event(CPERROR, "failed to set owner for output directory", passwd->pw_name); return 1; } log_event(CPDEBUG, "owner set for output directory", passwd->pw_name); } (void) umask(0077); return 0; } /* no validation is done here, please use is_ps_hex_string for that */ static void decode_ps_hex_string(char *string) { char *src_ptr, *dst_ptr; int is_lower_digit; /* 0 - higher digit, 1 - lower digit */ char number, digit; dst_ptr=string; /* we should always be behind src_ptr, so it's safe to write over original string */ number=(char)0; is_lower_digit=0; for (src_ptr=string+1;*src_ptr != '>';src_ptr++) { /* begin after start marker */ if (*src_ptr == ' ' || *src_ptr == '\t' ) { /* skip whitespace */ continue; } if (*src_ptr >= 'a') { /* assuming 0 < A < a */ digit=*src_ptr-'a'+(char)10; } else if (*src_ptr >= 'A') { digit=*src_ptr-'A'+(char)10; } else { digit=*src_ptr-'0'; } if (is_lower_digit) { number|=digit; *dst_ptr=number; /* write character */ dst_ptr++; is_lower_digit=0; } else { /* higher digit */ number=digit<<4; is_lower_digit=1; } } if (is_lower_digit) { /* write character with lower digit = 0, as per PostScript Language Reference */ *dst_ptr=number; dst_ptr++; /* is_lower_digit=0; */ } *dst_ptr=0; /* finish him! */ return; } static int is_ps_hex_string(char *string) { int got_end_marker=0; char *ptr; if (string[0] != '<') { /* if has no start marker */ log_event(CPDEBUG, "not a hex string, has no start marker", string); return 0; /* not hex string, obviously */ } for (ptr=string+1;*ptr;ptr++) { /* begin after start marker */ if (got_end_marker) { /* got end marker and still something left */ log_event(CPDEBUG, "not a hex string, trailing characters after end marker", ptr); return 0; /* that's bad! */ } else if (*ptr == '>') { /* here it is! */ got_end_marker=1; log_event(CPDEBUG, "got an end marker in the hex string, expecting 0-termination", ptr); } else if ( !( isxdigit(*ptr) || *ptr == ' ' || *ptr == '\t' ) ) { log_event(CPDEBUG, "not a hex string, invalid character", ptr); return 0; /* that's bad, too */ } } return got_end_marker; } static void alternate_replace_string(char *string) { unsigned int i; log_event(CPDEBUG, "removing alternate special characters from title", string); for (i=0;i<(unsigned int)strlen(string);i++) if ( isascii(string[i]) && /* leaving non-ascii characters intact */ (!isalnum(string[i])) && string[i] != '-' && string[i] != '+' ) string[i]='_'; return; } static void replace_string(char *string) { unsigned int i; log_event(CPDEBUG, "removing special characters from title", string); for (i=0;i<(unsigned int)strlen(string);i++) if ( ( string[i] < '0' || string[i] > '9' ) && ( string[i] < 'A' || string[i] > 'Z' ) && ( string[i] < 'a' || string[i] > 'z' ) && string[i] != '-' && string[i] != '+' ) string[i]='_'; return; } static int preparetitle(char *title) { char *cut; if (title != NULL) { log_event(CPDEBUG, "removing trailing newlines from title", title); while (strlen(title) && ((title[strlen(title)-1] == '\n') || (title[strlen(title)-1] == '\r'))) title[strlen(title)-1]='\0'; } if (conf.decodehexstrings) { log_event(CPSTATUS, "***Experimental Option: DecodeHexStrings", NULL); log_event(CPDEBUG, "checking for hex strings", title); if (is_ps_hex_string(title)) decode_ps_hex_string(title); } if (strlen(title) && title[0]=='(' && title[strlen(title)-1]==')') { log_event(CPDEBUG, "removing enclosing parentheses () from full title", title); title[strlen(title)-1]='\0'; memmove(title, title+1, strlen(title)); } cut=strrchr(title, '/'); if (cut != NULL) { log_event(CPDEBUG, "removing slashes from full title", title); memmove(title, cut+1, strlen(cut+1)+1); } cut=strrchr(title, '\\'); if (cut != NULL) { log_event(CPDEBUG, "removing backslashes from full title", title); memmove(title, cut+1, strlen(cut+1)+1); } cut=strrchr(title, '.'); if ((cut != NULL) && ((int)strlen(cut) <= conf.cut+1) && (cut != title)) { log_event(CPDEBUG, "removing file name extension", cut); cut[0]='\0'; } if (conf.decodehexstrings) { log_event(CPDEBUG, "calling alternate_replace_string", NULL); alternate_replace_string(title); } else replace_string(title); if (strlen(title)>conf.truncate) { title[conf.truncate]='\0'; log_event(CPDEBUG, "truncating title", title); } return strcmp(title, ""); } static char *fgets2(char *fbuffer, int fbufsize, FILE *ffpsrc) { /* like fgets() but linedelimiters are 0x0A, 0x0C, 0x0D (LF, FF, CR). */ int c, pos; char *result; if (!conf.fixnewlines) return fgets(fbuffer, fbufsize, ffpsrc); result=NULL; pos=0; while (pos < fbufsize) { /* pos in [0..fbufsize-1] */ c=fgetc(ffpsrc); /* converts CR/LF to LF in some OSses */ if (c == EOF) /* EOF _or_ error */ break; fbuffer[pos++]=c; if (c == 0x0A || c == 0x0C || c == 0x0D) /* line is at an end */ break; } if (pos > 0 && !ferror(ffpsrc)) { /* at least one char read and no error */ fbuffer[pos]='\0'; result=fbuffer; } return result; } static int preparespoolfile(FILE *fpsrc, char *spoolfile, char *title, char *cmdtitle, int job, struct passwd *passwd) { cp_string buffer; int rec_depth,is_title=0; FILE *fpdest; if (fpsrc == NULL) { log_event(CPERROR, "failed to open source stream", NULL); return 1; } log_event(CPDEBUG, "source stream ready", NULL); fpdest=fopen(spoolfile, "w"); if (fpdest == NULL) { log_event(CPERROR, "failed to open spoolfile", spoolfile); (void) fclose(fpsrc); return 1; } log_event(CPDEBUG, "destination stream ready", spoolfile); if (chown(spoolfile, passwd->pw_uid, -1)) { log_event(CPERROR, "failed to set owner for spoolfile", spoolfile); return 1; } log_event(CPDEBUG, "owner set for spoolfile", spoolfile); rec_depth=0; if (conf.fixnewlines) log_event(CPSTATUS, "***Experimental Option: FixNewlines", NULL); else log_event(CPDEBUG, "using traditional fgets", NULL); while (fgets2(buffer, BUFSIZE, fpsrc) != NULL) { if (!strncmp(buffer, "%!", 2)) { log_event(CPDEBUG, "found beginning of postscript code", buffer); break; } } log_event(CPDEBUG, "now extracting postscript code", NULL); (void) fputs(buffer, fpdest); while (fgets2(buffer, BUFSIZE, fpsrc) != NULL) { (void) fputs(buffer, fpdest); if (!is_title && !rec_depth) if (sscanf(buffer, "%%%%Title: %"TBUFSIZE"c", title)==1) { log_event(CPDEBUG, "found title in ps code", title); is_title=1; } if (!strncmp(buffer, "%!", 2)) { log_event(CPDEBUG, "found embedded (e)ps code", buffer); rec_depth++; } else if (!strncmp(buffer, "%%EOF", 5)) { if (!rec_depth) { log_event(CPDEBUG, "found end of postscript code", buffer); break; } else { log_event(CPDEBUG, "found end of embedded (e)ps code", buffer); rec_depth--; } } } (void) fclose(fpdest); (void) fclose(fpsrc); log_event(CPDEBUG, "all data written to spoolfile", spoolfile); if (cmdtitle == NULL || !strcmp(cmdtitle, "(stdin)")) buffer[0]='\0'; else strncpy(buffer, cmdtitle, BUFSIZE); if (title == NULL || !strcmp(title, "((stdin))")) title[0]='\0'; if (conf.titlepref) { log_event(CPDEBUG, "trying to use commandline title", buffer); if (!preparetitle(buffer)) { log_event(CPDEBUG, "empty commandline title, using PS title", title); if (!preparetitle(title)) log_event(CPDEBUG, "empty PS title", NULL); } else snprintf(title, BUFSIZE, "%s", buffer); } else { log_event(CPDEBUG, "trying to use PS title", title); if (!preparetitle(title)) { log_event(CPDEBUG, "empty PS title, using commandline title", buffer); if (!preparetitle(buffer)) log_event(CPDEBUG, "empty commandline title", NULL); else snprintf(title, BUFSIZE, "%s", buffer); } } if (!strcmp(title, "")) { if (conf.label == 2) snprintf(title, BUFSIZE, "untitled_document-job_%i", job); else snprintf(title, BUFSIZE, "job_%i-untitled_document", job); log_event(CPDEBUG, "no title found - using default value", title); } else { if (conf.label) { strcpy(buffer, title); if (conf.label == 2) snprintf(title, BUFSIZE, "%s-job_%i", buffer, job); else snprintf(title, BUFSIZE, "job_%i-%s", job, buffer); } log_event(CPDEBUG, "title successfully retrieved", title); } return 0; } int main(int argc, char *argv[]) { char *user, *dirname, *spoolfile, *outfile, *gscall, *ppcall; cp_string title; int size; mode_t mode; struct passwd *passwd; gid_t *groups; int ngroups; pid_t pid; if (setuid(0)) { (void) fputs("cups-pdf cannot be called without root privileges!\n", stderr); return 0; } if (init()) return 5; log_event(CPDEBUG, "initialization finished", CPVERSION); if (argc==1) { printf("file cups-pdf:/ \"Virtual PDF Printer\" \"CUPS-PDF\" \"MFG:Generic;MDL:CUPS-PDF Printer;DES:Generic CUPS-PDF Printer;CLS:PRINTER;CMD:POSTSCRIPT;\"\n"); log_event(CPSTATUS, "identification string sent", NULL); return 0; } if (argc<6 || argc>7) { (void) fputs("Usage: cups-pdf job-id user title copies options [file]\n", stderr); log_event(CPERROR, "call contained illegal number of arguments", NULL); return 0; } size=strlen(conf.userprefix)+strlen(argv[2])+1; user=calloc(size, sizeof(char)); if (user == NULL) { (void) fputs("CUPS-PDF: failed to allocate memory\n", stderr); return 5; } snprintf(user, size, "%s%s", conf.userprefix, argv[2]); passwd=getpwnam(user); if (passwd == NULL && conf.lowercase) { log_event(CPDEBUG, "unknown user", user); for (size=0;size<(int) strlen(argv[2]);size++) argv[2][size]=tolower(argv[2][size]); log_event(CPDEBUG, "trying lower case user name", argv[2]); size=strlen(conf.userprefix)+strlen(argv[2])+1; snprintf(user, size, "%s%s", conf.userprefix, argv[2]); passwd=getpwnam(user); } if (passwd == NULL) { if (strlen(conf.anonuser)) { passwd=getpwnam(conf.anonuser); if (passwd == NULL) { log_event(CPERROR, "username for anonymous access unknown", conf.anonuser); free(user); if (logfp!=NULL) (void) fclose(logfp); return 5; } log_event(CPDEBUG, "unknown user", user); size=strlen(conf.anondirname)+4; dirname=calloc(size, sizeof(char)); if (dirname == NULL) { (void) fputs("CUPS-PDF: failed to allocate memory\n", stderr); free(user); if (logfp!=NULL) (void) fclose(logfp); return 5; } snprintf(dirname, size, "%s", conf.anondirname); while (strlen(dirname) && ((dirname[strlen(dirname)-1] == '\n') || (dirname[strlen(dirname)-1] == '\r'))) dirname[strlen(dirname)-1]='\0'; log_event(CPDEBUG, "output directory name generated", dirname); } else { log_event(CPSTATUS, "anonymous access denied", user); free(user); if (logfp!=NULL) (void) fclose(logfp); return 0; } mode=(mode_t)(0666&~conf.anonumask); } else { log_event(CPDEBUG, "user identified", passwd->pw_name); if ((dirname=preparedirname(passwd, argv[2])) == NULL) { (void) fputs("CUPS-PDF: failed to allocate memory\n", stderr); free(user); if (logfp!=NULL) (void) fclose(logfp); return 5; } while (strlen(dirname) && ((dirname[strlen(dirname)-1] == '\n') || (dirname[strlen(dirname)-1] == '\r'))) dirname[strlen(dirname)-1]='\0'; log_event(CPDEBUG, "output directory name generated", dirname); mode=(mode_t)(0666&~conf.userumask); } ngroups=32; groups=calloc(ngroups, sizeof(gid_t)); if (groups == NULL) { (void) fputs("CUPS-PDF: failed to allocate memory\n", stderr); free(user); if (logfp!=NULL) (void) fclose(logfp); return 5; } size=getgrouplist(user, passwd->pw_gid, groups, &ngroups); if (size == -1) { free(groups); groups=calloc(ngroups, sizeof(gid_t)); size=getgrouplist(user, passwd->pw_gid, groups, &ngroups); } if (size < 0) { log_event(CPERROR, "getgrouplist failed", NULL); free(user); free(groups); if (logfp!=NULL) (void) fclose(logfp); return 5; } free(user); if (prepareuser(passwd, dirname)) { free(groups); free(dirname); if (logfp!=NULL) (void) fclose(logfp); return 5; } log_event(CPDEBUG, "user information prepared", NULL); size=strlen(conf.spool)+22; spoolfile=calloc(size, sizeof(char)); if (spoolfile == NULL) { (void) fputs("CUPS-PDF: failed to allocate memory\n", stderr); free(groups); free(dirname); if (logfp!=NULL) (void) fclose(logfp); return 5; } snprintf(spoolfile, size, "%s/cups2pdf-%i", conf.spool, (int) getpid()); log_event(CPDEBUG, "spoolfile name created", spoolfile); if (argc == 6) { if (preparespoolfile(stdin, spoolfile, title, argv[3], atoi(argv[1]), passwd)) { free(groups); free(dirname); free(spoolfile); if (logfp!=NULL) (void) fclose(logfp); return 5; } log_event(CPDEBUG, "input data read from stdin", NULL); } else { if (preparespoolfile(fopen(argv[6], "r"), spoolfile, title, argv[3], atoi(argv[1]), passwd)) { free(groups); free(dirname); free(spoolfile); if (logfp!=NULL) (void) fclose(logfp); return 5; } log_event(CPDEBUG, "input data read from file", argv[6]); } size=strlen(dirname)+strlen(title)+6; outfile=calloc(size, sizeof(char)); if (outfile == NULL) { (void) fputs("CUPS-PDF: failed to allocate memory\n", stderr); if (unlink(spoolfile)) log_event(CPERROR, "failed to unlink spoolfile during clean-up", spoolfile); free(groups); free(dirname); free(spoolfile); if (logfp!=NULL) (void) fclose(logfp); return 5; } snprintf(outfile, size, "%s/%s.pdf", dirname, title); log_event(CPDEBUG, "output filename created", outfile); size=strlen(conf.gscall)+strlen(conf.ghostscript)+strlen(conf.pdfver)+strlen(outfile)+strlen(spoolfile)+6; gscall=calloc(size, sizeof(char)); if (gscall == NULL) { (void) fputs("CUPS-PDF: failed to allocate memory\n", stderr); if (unlink(spoolfile)) log_event(CPERROR, "failed to unlink spoolfile during clean-up", spoolfile); free(groups); free(dirname); free(spoolfile); free(outfile); if (logfp!=NULL) (void) fclose(logfp); return 5; } snprintf(gscall, size, conf.gscall, conf.ghostscript, conf.pdfver, outfile, spoolfile); log_event(CPDEBUG, "ghostscript commandline built", gscall); (void) unlink(outfile); log_event(CPDEBUG, "output file unlinked", outfile); if (putenv(conf.gstmp)) { log_event(CPERROR, "insufficient space in environment to set TMPDIR", conf.gstmp); if (unlink(spoolfile)) log_event(CPERROR, "failed to unlink spoolfile during clean-up", spoolfile); free(groups); free(dirname); free(spoolfile); free(outfile); free(gscall); if (logfp!=NULL) (void) fclose(logfp); return 5; } log_event(CPDEBUG, "TMPDIR set for GhostScript", getenv("TMPDIR")); pid=fork(); if (!pid) { log_event(CPDEBUG, "entering child process", NULL); if (setgid(passwd->pw_gid)) log_event(CPERROR, "failed to set GID for current user", NULL); else log_event(CPDEBUG, "GID set for current user", NULL); if (setgroups(ngroups, groups)) log_event(CPERROR, "failed to set supplementary groups for current user", NULL); else log_event(CPDEBUG, "supplementary groups set for current user", NULL); if (setuid(passwd->pw_uid)) log_event(CPERROR, "failed to set UID for current user", passwd->pw_name); else log_event(CPDEBUG, "UID set for current user", passwd->pw_name); (void) umask(0077); size=system(gscall); (void) snprintf(title,BUFSIZE,"%d",size); log_event(CPDEBUG, "ghostscript has finished", title); if (chmod(outfile, mode)) log_event(CPERROR, "failed to set file mode for PDF file (non fatal)", outfile); else log_event(CPDEBUG, "file mode set for user output", outfile); if (strlen(conf.postprocessing)) { size=strlen(conf.postprocessing)+strlen(outfile)+strlen(passwd->pw_name)+strlen(argv[2])+4; ppcall=calloc(size, sizeof(char)); if (ppcall == NULL) log_event(CPERROR, "failed to allocate memory for postprocessing (non fatal)", NULL); else { snprintf(ppcall, size, "%s %s %s %s", conf.postprocessing, outfile, passwd->pw_name, argv[2]); log_event(CPDEBUG, "postprocessing commandline built", ppcall); size=system(ppcall); snprintf(title,BUFSIZE,"%d",size); log_event(CPDEBUG, "postprocessing has finished", title); free(ppcall); } } else log_event(CPDEBUG, "no postprocessing", NULL); return 0; } log_event(CPDEBUG, "waiting for child to exit", NULL); (void) waitpid(pid,NULL,0); if (unlink(spoolfile)) log_event(CPERROR, "failed to unlink spoolfile (non fatal)", spoolfile); else log_event(CPDEBUG, "spoolfile unlinked", spoolfile); free(groups); free(dirname); free(spoolfile); free(outfile); free(gscall); log_event(CPDEBUG, "all memory has been freed", NULL); log_event(CPSTATUS, "PDF creation successfully finished", passwd->pw_name); if (logfp!=NULL) (void) fclose(logfp); return 0; } cups-pdf-2.6.1/src/cups-pdf.h0000644000215500007650000001206611642634026015115 0ustar vrbehrstaff/* cups-pdf.h -- CUPS Backend Header File (version 2.6.1, 2011-10-04) 16.05.2003, Volker C. Behr Experimentelle Physik V, Universitaet Wuerzburg behr@physik.uni-wuerzburg.de http://www.cups-pdf.de This code may be freely distributed as long as this header is preserved. Changes to the code should be clearly indicated. This code is distributed under the GPL. (http://www.gnu.org/copyleft/gpl.html) For more detailed licensing information see cups-pdf.c in the corresponding version number. */ /* User-customizable settings - if unsure leave the default values / they are reasonable for most systems. */ /* location of the configuration file */ #define CPCONFIG "/etc/cups/cups-pdf.conf" /* --- DO NOT EDIT BELOW THIS LINE --- */ /* The following settings are for internal purposes only - all relevant / options listed below can be set via cups-pdf.conf at runtime */ #define CPVERSION "v2.6.1" #define CPERROR 1 #define CPSTATUS 2 #define CPDEBUG 4 #define BUFSIZE 4096 #define TBUFSIZE "4096" typedef char cp_string[BUFSIZE]; static struct { cp_string anondirname; cp_string anonuser; cp_string ghostscript; cp_string gscall; cp_string grp; cp_string gstmp; cp_string log; cp_string pdfver; cp_string postprocessing; cp_string out; cp_string spool; cp_string userprefix; cp_string removeprefix; int cut; int truncate; short dirprefix; short label; short logtype; short lowercase; short titlepref; short decodehexstrings; short fixnewlines; mode_t anonumask; mode_t userumask; } conf; static void _set_defaults() { snprintf(conf.anondirname,BUFSIZE,"%s","/var/spool/cups-pdf/ANONYMOUS"); snprintf(conf.anonuser,BUFSIZE,"%s","nobody"); snprintf(conf.ghostscript,BUFSIZE,"/usr/bin/gs"); snprintf(conf.gscall,BUFSIZE,"%s","%s -q -dCompatibilityLevel=%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=\"%s\" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f %s"); snprintf(conf.grp,BUFSIZE,"%s","lp"); snprintf(conf.gstmp,BUFSIZE,"%s","TMPDIR=/var/tmp"); snprintf(conf.log,BUFSIZE,"%s","/var/log/cups"); snprintf(conf.pdfver,BUFSIZE,"%s","1.4"); snprintf(conf.postprocessing,BUFSIZE,"%s",""); snprintf(conf.out,BUFSIZE,"%s","/var/spool/cups-pdf/${USER}"); snprintf(conf.spool,BUFSIZE,"%s","/var/spool/cups-pdf/SPOOL"); snprintf(conf.userprefix,BUFSIZE,"%s",""); snprintf(conf.removeprefix,BUFSIZE,"%s",""); conf.cut=3; conf.truncate=64; conf.dirprefix=0; conf.label=0; conf.logtype=3; conf.lowercase=1; conf.titlepref=0; conf.decodehexstrings=0; conf.fixnewlines=0; conf.anonumask=0000; conf.userumask=0077; return; } static int _assign_value(char *key, char *value) { int tmp; if (!strcmp("AnonDirName",key)) strncpy(conf.anondirname,value,BUFSIZE); else if (!strcmp("AnonUser",key)) strncpy(conf.anonuser,value,BUFSIZE); else if (!strcmp("GhostScript",key)) strncpy(conf.ghostscript,value,BUFSIZE); else if (!strcmp("GSCall",key)) strncpy(conf.gscall,value,BUFSIZE); else if (!strcmp("Grp",key)) strncpy(conf.grp,value,BUFSIZE); else if (!strcmp("GSTmp",key)) snprintf(conf.gstmp,BUFSIZE,"%s%s","TMPDIR=",value); else if (!strcmp("Log",key)) strncpy(conf.log,value,BUFSIZE); else if (!strcmp("PDFVer",key)) strncpy(conf.pdfver,value,BUFSIZE); else if (!strcmp("PostProcessing",key)) strncpy(conf.postprocessing,value,BUFSIZE); else if (!strcmp("Out",key)) strncpy(conf.out,value,BUFSIZE); else if (!strcmp("Spool",key)) strncpy(conf.spool,value,BUFSIZE); else if (!strcmp("UserPrefix",key)) strncpy(conf.userprefix,value,BUFSIZE); else if (!strcmp("RemovePrefix",key)) strncpy(conf.removeprefix,value,BUFSIZE); else if (!strcmp("Cut",key)) { tmp=atoi(value); conf.cut=(tmp>=-1)?tmp:-1; } else if (!strcmp("Truncate",key)) { tmp=atoi(value); conf.truncate=(tmp>=8)?tmp:8; } else if (!strcmp("DirPrefix",key)) { tmp=atoi(value); conf.dirprefix=(tmp)?(short)1:(short)0; } else if (!strcmp("Label",key)) { tmp=atoi(value); conf.label=(tmp>2)?(short)2:((tmp<0)?(short)0:(short)tmp); } else if (!strcmp("LogType",key)) { tmp=atoi(value); conf.logtype=(tmp>7)?(short)7:((tmp<0)?(short)0:(short)tmp); } else if (!strcmp("LowerCase",key)) { tmp=atoi(value); conf.lowercase=(tmp)?(short)1:(short)0; } else if (!strcmp("TitlePref",key)) { tmp=atoi(value); conf.titlepref=(tmp)?(short)1:(short)0; } else if (!strcmp("DecodeHexStrings",key)) { tmp=atoi(value); conf.decodehexstrings=(tmp)?(short)1:(short)0; } else if (!strcmp("FixNewlines",key)) { tmp=atoi(value); conf.fixnewlines=(tmp)?(short)1:(short)0; } else if (!strcmp("AnonUMask",key)) { tmp=(int)strtol(value,NULL,8); conf.anonumask=(mode_t)tmp; } else if (!strcmp("UserUMask",key)) { tmp=(int)strtol(value,NULL,8); conf.userumask=(mode_t)tmp; } else return 0; return 1; } cups-pdf-2.6.1/README0000644000215500007650000001074611527522755013326 0ustar vrbehrstaffWelcome to CUPS-PDF v2 CONTENTS: 1. building CUPS-PDF 2. setting up the PDF queue with CUPS 3. note for MacOSX 4. contact 1. building CUPS-PDF -------------------- Edit src/cups-pdf.h if you do not like /etc/cups/cups-pdf.conf as name for the configuration file. To compile CUPS-PDF, invoke gcc in the src/ directory: gcc -O9 -s -o cups-pdf cups-pdf.c To install the binary, simply copy cups-pdf to the backend directory of CUPS (usually /usr/lib/cups/backend). Now copy extra/cups-pdf.conf to /etc/cups (or whatever location you selected in cups-pdf.h above). Here you can set all properties of CUPS-PDF at runtime without the need for restarting any services. (The defaults should work fine on most systems.) In case you want to use the color PostScript driver that comes with CUPS-PDF go to the extra/ subdirectory and copy CUPS-PDF.ppd to your CUPS model directory (usually /usr/share/cups/model [ /Generic ] ). 2. setting up the PDF queue with CUPS ------------------------------------- Important notes: ================ * CUPS-PDF requires root privileges since it has to modify file ownerships. In order to ensure CUPS-PDF is running with the required root privileges you have to make 'root' the owner of the cups-pdf backend and set the file permissions of the backend to 0700 (root only). NOTE: in older versions of CUPS (<1.2.0) you have to set the "RunAsUser" option in cupsd.conf to "No" in order to grant full privileges. * CUPS-PDF needs a fully featured UNIX-filesystem to work. Make sure if any of CUPS-PDF's working directories (e.g. output) are located on an NFS mounted volume they are mounted without root_squash! Other filesystems (e.g. NetWare or Windows shares) are _not_ supported! * CUPS-PDF is known to fail if the gs (GhostScript) binary on a system is compressed by upx (Ultimate Packer for eXecutables). * If you are using SELinux, AppArmour or similar tools, make sure these do not interfere with CUPS-PDF. (You can disable SELinux for CUPS by "setsebool -P cupsd_disable_trans 1" or have a look at contrib/SELinux-HOWTO to make it work) Now you will be able to choose "CUPS-PDF (Virtual PDF Printer)" when setting up a new printer in CUPS (a CUPS-restart may be necessary). To set up a queue for other UNIX clients you should select Postscript as vendor and the Color Printer as model for your new printer; queues that get their input from samba or netatalk (i.e. Windows, OS/2 or MacOS) can be set up as raw queues. On the Windows, OS/2 or MacOS system choose a color postscript driver for that network printer (the drivers for Minolta Page Works or HP DesignJet printers do a good job). Hint: If you want to create grayscale PDFs you just have to choose a grayscale printer driver, i.e. the postscript.ppd that comes with CUPS on the Linux side or a b/w laser printer (e.g. a HP LaserJet) on the Windows side. On the Linux side be aware that the postscript.ppd will not re-process data that is already supplied in Postscript format, i.e. a color Postscript will keep it's colors. Once you print to the new device the output directory selected in cups-pdf.conf (defaults to /var/spool/cups-pdf) will be created and all converted PDF files will be placed in subdirectories named after the owner of the print job. In case the owner cannot be identified (i.e. does not exist on the server) the output is placed in the directory for anonymous operation (if not disabled in cups-pdf.conf - defaults to /var/spool/cups-pdf/ANONYMOUS/). Furthermore if logging is enabled the logfile will be placed by default in /var/log/cups. The file "CUPS-PDF.ppd" is a modified version of the "Postscript.ppd.gz" that comes with CUPS 1.1.15 that is able to handle color output. You should have a look at the contrib/ directory in this bundle which contains several additions to CUPS-PDF which enhance functionality or supports the setup of CUPS-PDF on different platforms. 3. note for MacOSX ------------------ Since MacOSX' AFPL GhostScript does not support the way of PDF generation used by CUPS-PDF you will have to use pstopdf instead. For this the settings of GhostScript, GSCall and PDFVer in cups-pdf.conf have to be changed accordingly. The values are documented in cups-pdf.conf . 4. contact ---------- Volker Christian Behr behr@physik.uni-wuerzburg.de http://www.cups-pdf.de