Skip to content

Conversation

@zdohnal
Copy link
Member

@zdohnal zdohnal commented Dec 3, 2025

The function cupsAdminGetServerSettings() did not take different policies as policy, which resulted into adding their contents into output array settings.

If the caller uses the same array for cupsAdminSetServerSettings(), there is possibility to add such directives at the end of configuration file if a different tool removes those directives from the original file.

Possibly reason for dangling JobPrivate*, SubscriptionPrivate* directives outside of policy scope...

The function `cupsAdminGetServerSettings()` did not take different
policies as policy, which resulted into adding their contents into
output array `settings`.

If the caller uses the same array for `cupsAdminSetServerSettings()`,
there is possibility to add such directives at the end of configuration
file if a different tool removes those directives from the original
file.
@mdeslaur
Copy link

mdeslaur commented Dec 3, 2025

Nice catch, this does indeed look like it is what is causing the directives to be added at the end of the config file.

Copy link
Member

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, the problem here is that we extract the --user-cancel-any policy and we only want that to come from the default policy. Soooo, let's set in_policy to 1 for the default policy and -1 for any other policy, and then the following && in_policy can be changed to && in_policy > 0.

(we track things a little differently in the save function with an in_default_policy variable, so you could duplicate that pattern as well if you like...)

@zdohnal
Copy link
Member Author

zdohnal commented Dec 4, 2025

@michaelrsweet @mdeslaur thanks!

Additionally (related to reason for #1443) we should fix that we get and set only the correct directives in correct places, otherwise we might share unknown broken directives via those functions.

I would make a list of cupsd directives which can be outside of Location and Policy scopes, and only those directives will be saved/set in cupsAdmin{Get,Set}ServerSettings functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants