[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: (deb-cat) sudo as lp



Adjunto una mostra sintètica per posar a prova el «sudo».



__________
I'm using this express-made address because personal addresses aren't
masked enough at lists.debian.org archives.
#!/bin/sh
JobID="$1"	# Example: "773"
JobUsername="$2"	# Example: "user"
JobCaption="$3"	# Example: "My cooking recipes"
JobCopiesNr=$4	# Example: 1
JobOptions="$5"	# Example: "job-uuid=urn:uuid:548ddfa3-2658-3adc-5371-878ae2b364b9 job-originating-host-name=localhost time-at-creation=1473669154 time-at-processing=1473669154"
Job_Content="$6" # Example: "/var/spool/cups/d00773-001" (usually a PDF file with only root:root permissions "rw,r,")

# Environment variables example:
# CONTENT_TYPE=application/pdf	# The MIME media type associated with the submitted job file, for example "application/postscript".
# PRINTER_INFO=My virtual printer
# USER=root	# The user executing the filter, typically "lp" or "root"; consult the cups-files.conf file for the current setting
# CUPS_SERVER=/var/run/cups/cups.sock
# HOME=/var/spool/cups/tmp
# RIP_MAX_CACHE=128m
# TMPDIR=/var/spool/cups/tmp
# CUPS_SERVERROOT=/etc/cups	# The root directory of the server
# CUPS_CACHEDIR=/var/cache/cups	# The directory where semi-persistent cache files can be found and stored
# PRINTER_STATE_REASONS=none
# CUPS_REQUESTROOT=/var/spool/cups
# PATH=/usr/lib/cups/filter:/usr/bin:/usr/sbin:/bin:/usr/bin	# The standard execution path for external programs that may be run by the filter
# DEVICE_URI=file:///dev/null
# CUPS_STATEDIR=/var/run/cups
# CUPS_MAX_MESSAGE=2047	# The maximum size of a message sent to stderr, including any leading prefix and the trailing newline
# LANG=ia.UTF-8	# The default language locale (typically C or en)
# CUPS_SERVERBIN=/usr/lib/cups
# CUPS_FILETYPE=document	# The type of file being printed: "job-sheet" for a banner page and "document" for a regular print file
# PPD=/etc/cups/ppd/My_printer.ppd	# The full pathname of the PostScript Printer Description (PPD) file for this printer
# CUPS_FONTPATH=/usr/share/cups/fonts
# IPP_PORT=631
# AUTH_INFO_REQUIRED=none
# PRINTER_LOCATION=My printer location
# CUPS_DOCROOT=/usr/share/cups/doc-root
# SERVER_ADMIN=root@system
# PWD=/
# CHARSET=utf-8	# The default text character set, typically "utf-8". 
# PRINTER=My_printer	# The name of the printer
# SOFTWARE=CUPS/1.7.2	# The name and version number of the server (typically CUPS/major.minor)
# CUPS_DATADIR=/usr/share/cups	# The directory where data files can be found
# FINAL_CONTENT_TYPE=printer/My_printer	# The MIME media type associated with the output destined for the printer, for example "application/vnd.cups-postscript".
# CUPS_ENCRYPTION=IfRequested
# CLASS	# (can be unset) When a job is submitted to a printer class, contains the name of the destination printer class. Otherwise this environment variable will not be set.
# RIP_CACHE	# (can be unset) The recommended amount of memory to use for Raster Image Processors (RIPs).
# TZ	# (can be unset) The timezone of the server

if [ "$1" = "FesRemot" ] ; then
	echo "Faig remot"
	shift
	echo "\$ $*"
	eval "$@"
	Result=$?
else
	date '+%FT%T%z' >> "/tmp/${PRINTER}.log"
	sudo -n -u $JobUsername "$0" FesRemot "ls /home/" >> "/tmp/${PRINTER}.log" 2>&1
	echo "Result=$?" >> "/tmp/${PRINTER}.log"
fi
exit $Result

Reply to: