Skip to content
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

Can't get default printer under Apple sandbox #5676

Closed
Simplestas opened this issue Nov 7, 2019 · 5 comments
Closed

Can't get default printer under Apple sandbox #5676

Simplestas opened this issue Nov 7, 2019 · 5 comments
Assignees
Milestone

Comments

@Simplestas
Copy link

Simplestas commented Nov 7, 2019

Scenario:
try to get default printer in sandboxed app
cupsGetNamedDest(CUPS_HTTP_DEFAULT, 0, 0)
when specific default printer is set in System Preferences - Printers.

Expected:
default printer

Actual:
IPP_STATUS_ERROR_NOT_FOUND

What happens:
libcups tries to access ~/.cups/loptions to get default printer
Apple does provide entitlement com.apple.security.print which does allow that
BUT
cups uses getenv("HOME") to get home folder pathwhich returns ~/Containers/{bundle id}/Data under sandbox
while it should use real home folder (getpwuid(getuid())->pw_dir)

@michaelrsweet
Copy link
Collaborator

Hmm, this seems to be working in Safari (also sandboxed). What version of macOS and CUPS are you using?

@michaelrsweet michaelrsweet self-assigned this Nov 7, 2019
@michaelrsweet michaelrsweet added the unable-to-reproduce Unable to reproduce label Nov 7, 2019
@Simplestas
Copy link
Author

Simplestas commented Nov 7, 2019

That's on macOS 10.15.1 / CUPS 2.3.0

Safari uses PrintCore which talks to cups via printtool daemon.

I.e. PMSessionGetCurrentPrinter works fine in sandbox, but we would like to use cups directly as well.

@michaelrsweet
Copy link
Collaborator

OK, I've created a short test program to reproduce this, and confirmed that ~/.cups can be safely read in a sandboxed application.

Changes will be a little more involved (need to replace all uses of getenv("HOME")) but will see what I can do...

@michaelrsweet michaelrsweet added priority-low and removed unable-to-reproduce Unable to reproduce labels Nov 14, 2019
@michaelrsweet michaelrsweet added this to the CUPS 2.3.x milestone Nov 14, 2019
michaelrsweet added a commit that referenced this issue Nov 14, 2019
…#5676)

- Add "home" global pointing to the user's home directory.
- Use it instead of getenv("HOME") everywhere we needed it.
@michaelrsweet
Copy link
Collaborator

[master e2eb28c] Sandboxed applications were not able to get the default printer (Issue #5676)

Unfortunately, that doesn't do much to help you now - you'll need to wait until this fix makes it into a macOS release...

@Simplestas
Copy link
Author

Thanks, we can work with that.

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

No branches or pull requests

2 participants