Remote IP

Kurt Pfeifle k1pfeifle at gmx.net
Thu Oct 11 13:09:30 PDT 2007


Matthias Jansen wrote:

>>> in a backend programm I'm writing, I need the information which IP
>>> address the printing job is from. The only place I found this infor-
>>> mation is in the corresponding file /var/spool/cups/c000<id> but this
>>> file is per default only readable by root but the process of my
>>> backend is spawned as lp.
>> Backends which are set to 0700 permission and owned by root are run as
>> root.
> 
> Thanks for that info! Then the script will be able to parse the cxxxx 
> file to get the hostname.

If by "parse" you mean "grep" and "strings" (basically)... this is

 (a) ugly
 (b) unreliable long-term (format may change)

You should rather use the "testipp" utility that does build when you
compile CUPS (dunno if the distro packagers do ship it -- maybe one
should make a request for them to package this and some more of the
CUPS-provided test utilities...).

Use it like this:

 /path/to/testipp /var/spool/cups/cNNNNN

and parse what output *that* gives to you.

>>> I already tried Net::CUPS (as my backend is
>>> a perl script) but this doesn't seem to give me the information I need.
>>>
>>> Is there any other way?
>> I don't know what info Net::CUPS provides at all. But what you are
>> looking for is the IPP job attribute called "job-originating-host-name".
> 
> Yes, I know. This information can be parsed from the cxxxx file.
> 
>> AFAIK, there is no way to access the client IP or hostname value via an
>> environment variable set by CUPS.
> 
> So, parsing the cxxxx file will be the only way to retrieve the IP at 
> the moment?

Yes.


-- 
Kurt Pfeifle
System & Network Printing Consultant ---- Linux/Unix/Windows/Samba/CUPS
Infotec Deutschland GmbH  .....................  Hedelfinger Strasse 58
A RICOH Company  ...........................  D-70327 Stuttgart/Germany




More information about the cups mailing list