Skip to content

Fixes in "printers@cinnamon.org"#13524

Open
hans-fritz-pommes wants to merge 19 commits intolinuxmint:masterfrom
hans-fritz-pommes:patch-1
Open

Fixes in "printers@cinnamon.org"#13524
hans-fritz-pommes wants to merge 19 commits intolinuxmint:masterfrom
hans-fritz-pommes:patch-1

Conversation

@hans-fritz-pommes
Copy link

@hans-fritz-pommes hans-fritz-pommes commented Feb 1, 2026

I encountered several small issues with the printers applet.
I modified the applet.js in /usr/share/cinnamon/applets/printers@cinnamon.org and tested printing documents.
The things I did correct:

  • The "Cancel all jobs" command didn't work for an user who had no permisisons to run cancel -a for a specific printer, even if all of the jobs on this printer belonged to him.
    -> Now the "Cancel all jobs" command tries to cancel every single job, not cancel -a for every printer
  • The appearance of the listed jobs was really bad: e.g. when you had more than one job, the description for every job was "<desc. first job><desc. second job><desc..." and so on.
  • The job description consisted of: (job number) lpstat -o (lpstat several times, if there was more than one job - see point before)
    -> The description is now: (job number) 'document_name' on <printer_name> (<size in Bytes/MB/KB>) by <user> (using lpq -a).

The following problem could occur:
If a job has the same number as byte-size like the job-id of the following one, the username and the filesize of the first one will be strange (job-id and functions stay working).
I would say this will happen that seldom - we should ignore it.
Which user will open the menu exactly in that minute and have a problem with a strange username or filesize?

EDIT: fixed in new commit

@hans-fritz-pommes
Copy link
Author

Oh and I changed icons. If you think they're ugly, just revert it

@hans-fritz-pommes hans-fritz-pommes marked this pull request as draft February 1, 2026 19:18
@hans-fritz-pommes
Copy link
Author

I have an idea how to fix this mini-problem (identical bytes & job-number). But later

Fix mini-problem (See linuxmint#13524)
@hans-fritz-pommes hans-fritz-pommes marked this pull request as ready for review February 1, 2026 20:54
@hans-fritz-pommes
Copy link
Author

Ok, now the identical bytes/document-name & job-number-problem is fixed.

@hans-fritz-pommes hans-fritz-pommes marked this pull request as draft February 2, 2026 12:36
@hans-fritz-pommes
Copy link
Author

Sorry that I'm so chaotic
I forgot to take care of document names with whitespaces

Support filenames with whitespaces
@hans-fritz-pommes hans-fritz-pommes marked this pull request as ready for review February 2, 2026 14:11
@claudiux claudiux requested a review from clefebvre February 2, 2026 14:13
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 1 potential issue(s):

⚠️ lang_bind

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:218

Util.spawn_async(['/usr/bin/lpq', '-a'], Lang.bind(this, function(out2) {

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.


Automated pattern check.

Improved with mtwebsters ideas
(linuxmint#13524)
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 1 potential issue(s):

⚠️ lang_bind

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:203

Util.spawn_async(['/usr/bin/lpq', '-a'], Lang.bind(this, function(out2) {

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.


Automated pattern check.

@hans-fritz-pommes
Copy link
Author

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or maintainability issues, or that may already be provided by Cinnamon. Having code flagged by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.

Found 1 potential issue(s):

⚠️ lang_bind

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:218

Util.spawn_async(['/usr/bin/lpq', '-a'], Lang.bind(this, function(out2) {

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

Automated pattern check.

What should be done with that?

@leigh123linux
Copy link
Member

Please squash the commits into one.

@mtwebster
Copy link
Member

mtwebster commented Mar 5, 2026

What should be done with that?

What it suggests - use an arrow function instead of using Lang.bind(). Look at other applets, it's a pretty straightforward change.

removed deprecated lang.bind
@hans-fritz-pommes
Copy link
Author

By the way:
I was wondering why ever lpstat was used for gathering the job-data.
This pull request removed lpq. I thought every system having lpstat also has lpq since it's a part of cups?

Adressing linuxmint#9265
Necessary update to catch the error reason
@hans-fritz-pommes
Copy link
Author

Those new commits intend to make it compatible with a turned-off CUPS-service

@hans-fritz-pommes
Copy link
Author

hans-fritz-pommes commented Mar 9, 2026

Please squash the commits into one.

I will do that when merging

🤦oups merging is not my task, right?

improved error handling
improved error handling
added this.removed
removed unnecessary timeout
@hans-fritz-pommes
Copy link
Author

hans-fritz-pommes commented Mar 10, 2026

Now the guy from #13039 shouldn't have problems anymore with missing lpq and there shouldn't be a problem with missing / not running cups (#9265).

improved looking of error-handling
@mtwebster
Copy link
Member

Can we drop the python script? util.spawnCommandLineAsyncIO() should work fine in this case - they're all fixed arguments. Sorry I should have caught this earlier...

- exchanged "Util.spawn_async(...)" & "tool.py" with "Util.spawnCommandLineAsyncIO(...)"
- exchanged "GLib.format_size_for_display(...)" with "GLib.format_size(...)"
- exchanged "cancel-print-dialog.py" with "ModalDialog.ConfirmDialog"
@github-actions
Copy link

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 5 potential issue(s):

ℹ️ shell_string_spawn

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:181

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:192

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -l', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:214

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -d', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:242

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -o', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:265

Util.spawnCommandLineAsyncIO('/usr/bin/lpq -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.


Automated pattern check.

@github-actions
Copy link

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 5 potential issue(s):

ℹ️ shell_string_spawn

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:181

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:192

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -l', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:214

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -d', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:242

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -o', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:265

Util.spawnCommandLineAsyncIO('/usr/bin/lpq -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.


Automated pattern check.

@github-actions
Copy link

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 5 potential issue(s):

ℹ️ shell_string_spawn

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:181

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:192

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -l', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:214

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -d', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:242

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -o', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:265

Util.spawnCommandLineAsyncIO('/usr/bin/lpq -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.


Automated pattern check.

@hans-fritz-pommes
Copy link
Author

hans-fritz-pommes commented Mar 11, 2026

Can we drop the python script? util.spawnCommandLineAsyncIO() should work fine in this case - they're all fixed arguments. Sorry I should have caught this earlier...

Why would it be insecure if there were user inputs?
And why is there no function with argv and the possibility to catch stdout, stderr and exitCode?

(It's just about understanding)

@hans-fritz-pommes
Copy link
Author

Ah and I replaced the second python script - this means now we don't have Gtk-dialogs anymore. Instead: A Cinnamon modal dialog.

@mtwebster
Copy link
Member

Why would it be insecure if there were user inputs?

You can get a lot more info with Google or asking AI to explain shell injection vulnerabilities... but basically,

This is safe - it will always run exactly that command, you're using a static string.

Util.spawnCommandLineAsyncIO('/usr/bin/lpq -a', ()=>{});

but, for example filename restrictions are fairly lax...

image
let file = file.get_basename() // '; dangerous-command ~'
let cmd = "ls -la " + file;
Util.spawnCommandLineAsyncIO(file, ()=>{}); // ls -la ; dangerous-command ~

That example is pretty extreme and unlikely, but it's a real concern, and we're all better off being in the habit of using argv variants in the first place, to prevent misinterpretation like this.

And why is there no function with argv and the possibility to catch stdout, stderr and exitCode?

Because I didn't notice it was missing before implementing our pattern checker here - I'll be adding one for sure. You could use GLib.spawn_async_with_pipes or Gio.Subprocess api directly (which is what spawnCommandLineAsyncIO uses internally), but they're much less convenient to setup and use. For your purposes here, it's ok.

replaced error message cut 69 with 70
removed unnecessary line with printError = falsr;
@github-actions
Copy link

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 5 potential issue(s):

ℹ️ shell_string_spawn

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:180

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:191

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -l', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:213

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -d', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:241

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -o', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:264

Util.spawnCommandLineAsyncIO('/usr/bin/lpq -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.


Automated pattern check.

@hans-fritz-pommes
Copy link
Author

Should I port to spawnAsyncIO or just leave it?

@github-actions
Copy link

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 5 potential issue(s):

ℹ️ shell_string_spawn

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:180

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:191

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -l', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:213

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -d', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:241

Util.spawnCommandLineAsyncIO('/usr/bin/lpstat -o', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:264

Util.spawnCommandLineAsyncIO('/usr/bin/lpq -a', (stdout, stderr, exitCode) => {

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.


Automated pattern check.

@hans-fritz-pommes
Copy link
Author

hans-fritz-pommes commented Mar 15, 2026

oups - not intentionally updated my fork

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