At work my group currently use self maintained network printers. We also run our own self contained Linux network for some members of the group. It all works beautifully. The management has decided that it will be more efficient and sustainable for everybody to use centrally maintained printers. This brings us a number of useful features such as being able to submit a print job and then pick it at any printer we want. The problem is that printing will be tied into the central authentication system, which we don't use.
It turns out that we don't actually have to make use of the authentication as such, we just need to make sure that the username a print job is submitted under has the correct username - otherwise you can't pick it up. We could change all of the username and home directories for all of our users to match the centrally managed ones, but understandably we'd prefer not to do that. If we can remap our usernames to the centrally managed ones for printing then everything should just work.
We're currently using cups for our printing needs and as far as I can tell it doesn't support any form of username remapping. Is this correct? I do know that Samba supports username remapping, but I'm not sure if it would work in this configuration. We need:
- local username print (to our server if necessary) -> username remapping to central username -> print job sent to print service.
Can anybody suggest how we might achieve this?
I have now solved this problem. I've added the real printer as normal, then created a new cups backend script called /usr/lib/cups/backend/remap :
I've then added a new fake printer using this backend. The script assumes your fake printer and real printer have the same location but different protocol, so for example:
It replaces the "remap" with "http" in the DEVICE_URI environment variable, updates some other environment variables, looks up the mapped user (in this case based on a custom NIS map) and runs the job on the real printer using the ipp backend but with the updated username.
Cups backends expect arguments as follows:
If $6 is empty, it expects input from stdin.