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

Retrieve spooled file data #978

Merged
merged 7 commits into from
Dec 16, 2022
Merged

Retrieve spooled file data #978

merged 7 commits into from
Dec 16, 2022

Conversation

Vzor-
Copy link
Contributor

@Vzor- Vzor- commented Jun 23, 2022

Adds the ability to obtain raw, spool file data on Windows printers which have 'keep spooled documents' feature enabled.

  • Requires System property printer.status.jobdata is set to true, e.g.
    • Environment variable QZ_OPTS: -Dprinter.status.jobdata=true
      --OR--
    • qz-tray.properties: printer.status.jobdata=true.

Closes #923

Note: This feature does not work by default on Windows 11 ARM, the spool directory permissions don't allow it.

Edited by @tresf


TODO:

  • feature should be disabled by default
  • test permissions when wrong user tries to read a spooled file

see #923

.idea/misc.xml Outdated Show resolved Hide resolved
@tresf tresf changed the title Job data Retrieve spooled file data Aug 10, 2022
@tresf tresf marked this pull request as draft August 10, 2022 17:51
@tresf
Copy link
Contributor

tresf commented Aug 14, 2022

@Vzor- I'm testing this on Windows 11 running on ARM64, and I get the following error:

[ERROR] 2022-08-14T01:58:24,319 @ qz.printer.status.StatusSession:121
	Failed to retrieve job data from job #5
java.io.FileNotFoundException: Failed to locate spooler output.
	at qz.utils.WindowsUtilities.getSpoolerLocation(WindowsUtilities.java:114) ~[production/:?]
	at qz.printer.status.StatusSession.getJobData(StatusSession.java:114) ~[production/:?]
	at qz.printer.status.StatusSession.createJobDataStream(StatusSession.java:85) ~[production/:?]
	at qz.printer.status.StatusSession.statusChanged(StatusSession.java:45) ~[production/:?]
	at qz.printer.status.StatusMonitor.statusChanged(StatusMonitor.java:168) ~[production/:?]
	at qz.printer.status.WmiPrinterStatusThread.sendPendingStatuses(WmiPrinterStatusThread.java:214) ~[production/:?]
	at qz.printer.status.WmiPrinterStatusThread.ingestChange(WmiPrinterStatusThread.java:137) ~[production/:?]
	at qz.printer.status.WmiPrinterStatusThread.run(WmiPrinterStatusThread.java:108) ~[production/:?]

I can confirm that HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\DefaultSpoolDirectory exists and does point to C:\Windows\system32\spool\PRINTERS and that the location exists, however trying to browse it, I get "Access denied".

C:\>cd C:\Windows\system32\spool\PRINTERS
Access is denied.

@tresf

This comment was marked as outdated.

@tresf tresf marked this pull request as ready for review September 1, 2022 17:52
@tresf
Copy link
Contributor

tresf commented Sep 1, 2022

Question posted publicly: https://superuser.com/questions/1740212

@tresf
Copy link
Contributor

tresf commented Sep 2, 2022

Ok, so I think this is working as a standard user as of 7e151b7. The Files.exists() returns false if you don't have permission, however the Files.isDirectory() will return true if exists even if you can't read it. 🎉

Per findings in https://superuser.com/questions/1740212, a user can read their own spooled files, just not the parent directory.

@tresf
Copy link
Contributor

tresf commented Dec 14, 2022

@Vzor- FYI, I'm going to squash the commits and rebase on master. A backup of the individual commits is here: master...tresf:tray:job-data-backup.

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

Successfully merging this pull request may close these issues.

Printer contents monitoring
2 participants