[cups.general] Passing extra information from environmenttobackend?

Kurt Pfeifle k1pfeifle at gmx.net
Fri Oct 19 04:43:55 PDT 2007


Erik Forsberg wrote:
>> Johannes Meixner wrote:
>>> Hello,
>>>
>>> On Oct 18 05:00 Erik Forsberg wrote (shortened):
>>>> Is there some way to pass information from the environment of the
>>>> user submitting a print job (via 'lp', 'lpr' or some program using
>>>> libcups, for example KDE's or Gnome's printer systems), to the
>>>> backend?
>>> A command like
>>> lp -o myoption=whatever ...
>>> will make "myoption=whatever" available for filters and for the
>>> backend as argv[5] (if I remember correctly), see "man backend".
>>>  
>>>> I want to know, in my backend, not only which user submitted the
>>>> job, but also which session in a thin client scenario the user was
>>>> submitting from (each user may have multiple sessions).
>>> This is not possible with 'lp' or 'lpr' as is but you could make
>>> a wrapper script which determines what you need and then let it
>>> call 'lp' with appropriate special option settings which are
>>> then evaluated by your special selfmade backend.
> 
> That is unfortunately not good enough, as that will not cover programs
> printing directly via libcups (kdeprint, etc.).
>  
>> One could also store the "myoption=whatever" setting in one of
>>
>>   /etc/cups/lpoptions
>>   ~/.cups/lpoptions
>>
>> (depending on: is the setting user-specific or not?) and rely on it
>> being picked up by the lp/lpr commands automatically.
> 
> Interesting, but will not solve the problem - I might have explained
> badly, but as the same user may have several sessions, on the same
> machine, and I want to distingush between sessions in my backend,

BTW, what do you mean with *MY* backend?

If it is a custom backend, over whose code you have full control, you
can make it read a commandline option that is passed via the print
command. Say "my_session_id=username at session_number". Your backend
just needs to evaluate what it sees as $5 (if backend is a shell script)
or more generally, argv[5]

That's what Johannes already pointed out.

> setting lpoptions in ~/.cups/lpoptions will not help, as these will be
> used by all sessions.
> 
> If there were an environment variable for lpoptions being picked up by
> libcups, that would help, because this variable could be set
> differently in different sessions. 

Why does it *need* to be an env var, why can't it be a commandline
option?

Commandline options could be set differently in different sessions
too. And you could even use your private env var, that you read upon
session start and translate it into a commandline.

All other filters and backends will ignore the "my_session_id=" param
because they all are made to ignore what they don't understand.

> As far as I can see, there is no such environment variable. Would a
> patch providing that functionality be accepted? 

There is currently already a mechanism to transport the info you want
to the backend using a custom commandline param.

But of course, it is Mike's affair to give you a definite answer...

-- 
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