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

A amount of temporary PPD files in the /tmp directory have not been deleted when the legacy-printer-app is shutdown #17

Open
szlt5 opened this issue Jan 9, 2024 · 5 comments

Comments

@szlt5
Copy link

szlt5 commented Jan 9, 2024

Describe the bug
A amount of temporary PPD files in the /tmp directory have not been deleted when the legacy-printer-app is shutdown.

Expected behavior
The temporary PPD files in the /tmp directory should be deleted when the legacy-printer-app is shutdown.

Additional context
Is the following solution feasible?
(1) In the _prDriverSetup():don't copy a temporary PPD file and just store the real PPD file path.
(2) In the _prCreateJobData(): copy a temporary PPD file from the real PPD file path.
(3) In the _prFreeJobData(): Unlink the temporary PPD file.

@szlt5
Copy link
Author

szlt5 commented Jan 9, 2024

@michaelrsweet
Is it possible to add a callback function to let legacy-printer-app clear some temporary files during shutdown?

@michaelrsweet
Copy link
Member

@szlt5 So currently there is no callback for system shutdown, just for printer deletion. But for a typical printer application you can simply do your cleanup when papplMainloop returns.

I might be able to update the papplCreateTempFile API to keep track of all temporary files and remove them on exit, but that might have some side-effects since PAPPL hasn't done that before... Also, I'm not clear on how legacy-printer-app is managing its temporary files or why it is storing PPD files in /tmp...

@szlt5
Copy link
Author

szlt5 commented Jan 10, 2024

Also, I'm not clear on how legacy-printer-app is managing its temporary files or why it is storing PPD files in /tmp...

My explanation may be incomplete.

In the driver_cb() function, legacy-printer-app initializes the driver_data & driver_attrs based on PPD content and create a physical copy of the PPD file in a temporary file and store the temporary file name in the driver_data->extension structure.

When print a job, set the environment variable "PPD" as the temporary file name so that the CUPS filter defined in the PPD file or a CUPS backend can read it.

legacy-printer-app will delete the temporary file in the printer deletion callback function.

@szlt5
Copy link
Author

szlt5 commented Jan 10, 2024

I propose several solutions, @tillkamppeter can you give me some suggestions?

<Solution 1>: Do not copy a temporary PPD file, let CUPS filter or a CUPS backend read the original PPD file.

<Solution 2>: Just copy a temporary PPD file when create Job Data (_prCreateJobData) and delete it when the job finished (_prFreeJobData).

<Solution 3>: Use @michaelrsweet's solution.

@michaelrsweet
Copy link
Member

@szlt5 A persistent copy of the PPD file should not be stored in /tmp - it sounds like this file needs to remain until the print queue is removed.

Instead, papplPrinterOpenFile can be used to create a persistent PPD file in the state directory (and named consistently with other printer resource files) that can be cleaned up by the delete callback and won't leave old files in /tmp.

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

No branches or pull requests

2 participants