-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cups-browsed: Added AllowResharingRemoteCUPSPrinters directive to cups-browsed #218
Conversation
utils/cups-browsed.c
Outdated
num_options = cupsAddOption("printer-is-shared", "true", | ||
num_options, NULL); | ||
debug_printf("Setting printer-is-shared bit.\n"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To which option set are you adding the "printer-is-shared" option here? "cupsAddOption()" needs the option set to add the option to as its 4th argument, where you set NULL. See the source code of cupsAddOption() in CUPS, file cups/options.c
. Did you actually build and test this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tillkamppeter , I added this commit to get reviews from you about the code and therefore, did not completely test the code. However, I have added a new commit, after studying more about sending requests and changing options, which would change the printer-is-shared
option when required. Kindly let me know if anything needs to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also is not the correct thing. Here you are setting the printer-is-shared bit on the remote print queue. Once this does not make sense as on the remote server all these printers are shared, otherwise you would not see them as a client. Also you are sending the request for setting the shared bit to your local CUPS, but the printers are on remote CUPS servers. The request will error.
Did you test what you are doing? With the new option set you should have your local queues for BrowsePolled printers shared, with the new option not set they should be not shared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tillkamppeter , I am facing trouble while testing the code. When I try to modify the attribute printer-is-shared
of the queue on the client, it shows the error unauthorised. Even when trying to change the printer-is-shared bit from web interface, the error is
Cannot change printer-is-shared for remote queues
. I really want to solve this issue but I wanted your help to figure out why remote queue, instead of local queue is appearing on the client side. On the cups-browsed.conf
file on the client, the following options are set.
BrowseRemoteProtocols dnssd cups
BrowseInterval 60
BrowseTimeout 300
BrowsePoll 192.168.43.210:631
OnlyUnsupportedByCUPS Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the device URI of the local queue with which you get the error (run lpstat -v
)? Does it have a PPD file in /etc/cups/ppd/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Device URI, which appears on the client is implicitclass://D1_172_20_10_7/
where D1 is the description of the printer on the server. There also exists the following ppd file for this printer.
ppd_file.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tillkamppeter , I think my issue might be related to this issue and therefore, queues pointing to remote queues should not be changed. Could you please confirm this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CUPS actually does not allow re-sharing print queues which point to a remote CUPS queue. CUPS recognizes these queues in two ways (search for |= CUPS_PRINTER_REMOTE
in the scheduler/printers.c
file of the CUPS source code):
- The device URI is CUPS-typical, like for example
ipp://host:631/printers/queue
(resource is/printers/queue
, not/ipp/print
or/ipp/print/queue
) oripp://service_name._ipp._tcp.local/cups
(resource/cups
instead of no resource). - The PPD file contains
*APRemoteQueueID: ...
.
Long time ago I followed the CUPS functionality by letting cups-browsed add a *APRemoteQueueID: ...
line to the PPD. Simply search for "*APRemoteQueueID:
" in utils/cups-browsed.c
and comment out these lines for your further studies. Then restart cups-browsed. Now you should be able to share such a queue.
Note that all queues discovered by BrowsePoll are remote CUPS queues, so the cups-browsed as it is now will always add *APRemoteQueueID: ...
to the PPD file.
There are two solutions: Either remove the code for adding *APRemoteQueueID: ...
altogether or add a second boolean directive to cups-browsed.conf
, call it "AllowResharingRemoteCUPSPrinters" and if set to "Yes" let the *APRemoteQueueID: ...
not be added. Your directive will only take effect then.
@tillkamppeter , In that case, I've observed that print queues are automatically shared if |
@tillkamppeter , Should I squash the commits for this to be merged? |
Note that all discovered remote CUPS queues are shared on their CUPS servers., otherwise they would not be discoverable. I do not know why now all client queues get shared when we allow re-sharing by the cups-browsed code. Perhaps this is a local default on your client. |
Apparently, they were shared because in |
@tillkamppeter , I've tested and added the |
Have you taken care that the |
@tillkamppeter , I have taken care of that in my latest commit. |
utils/cups-browsed.c
Outdated
@@ -430,6 +430,8 @@ static unsigned int BrowseInterval = 60; | |||
static unsigned int BrowseTimeout = 300; | |||
static uint16_t BrowsePort = 631; | |||
static browsepoll_t **BrowsePoll = NULL; | |||
int NewBrowsePollQueuesShared = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@V1krant, could you add the "static" here? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure. I forgot to add that during testing and added that now.
@V1krant, OK, we are shortly before merging your Pull Request. Could you adjust the indentation of your code with the already existing code, the tabs in the file should stand for 8 spaces, or better, use only spaces. |
Sure, I'll just update it and push the commit.
I've tested it for all situations except for old versions of cups (for the |
@tillkamppeter , I've squashed the commits and replaced tabs with spaces. Kindly let me know if any further changes are required |
3158552
to
20ceb1f
Compare
…es to cups-browsed
@V1krant, thank you very much. I merged your work now. |
Hey! Thanks so much for your work guys!!! Thanks for contributing it. If you ever come to Uruguay let me know! |
Hi Till,
The directive
NewBrowsePollQueuesShared
which shares printers discovered by the browse poll directive is added in the methodbrowse_poll_get_printers
as here it was already being checked for printers discovered by BrowsePoll directive.Kindly let me know if this patch requires any modifications.