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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/hardware/printers: fix ppdOptions of ensured printers #312261

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

Yarny0
Copy link
Contributor

@Yarny0 Yarny0 commented May 16, 2024

Description of changes

#290240 changed the ensurePrinter mechanism such that it uses lib.cli.toGNUCommandLineShell. However, it missed to remove single quotes (') that have previously been needed to protect options from the shell, but that are now escaped and passed on to lpadmin, thereby breaking ppdOptions.

This pull request removes those superfluous quotes and fixes ppdOptions.

Notifying author of previous pull request: @rhoriguchi

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Note that this pull request does not affect any packages/tests.

Result of nixpkgs-review run on x86_64-linux 1

1 package blacklisted:
  • nixos-install-tools

Add a 馃憤 reaction to pull requests you find important.

Commit a52e27d
changed the `ensurePrinter` mechanism such that it uses
`lib.cli.toGNUCommandLineShell` to assemble the
`lpadmin` command line that creates the required printer.
Before that commit, the command line contained
single quotes (')to protect certain options from being
(mis-)interpreted by the shell.
The new mechanism no longer needs those quotes as
`lib.cli.toGNUCommandLineShell` takes care of quoting/escaping.
Unfortunatelly, the commit missed the
quotes around the `-o` command line part.
`lib.cli.toGNUCommandLineShell` now properly escapes
those quotes, thereby including them in the effective
command line arguments that are passed to `lpadmin`.
The result is that no option is applied anymore.

The commit at hand simply removes the superfluous quotes.
With this change, options are again properly applied as before.
@rhoriguchi
Copy link
Contributor

Hi @Yarny0 could you please post some test code so I can take a look.

@Yarny0
Copy link
Contributor Author

Yarny0 commented May 16, 2024

This code

  services.printing.enable = true;
  services.printing.drivers = [ pkgs.foomatic-db-ppds ];
  hardware.printers.ensurePrinters = [{
    name = "myprinter";
    model = "foomatic-db-ppds/Samsung-ML-371x-Postscript-Samsung.ppd.gz";
    deviceUri = "socket://123.123.123.123:9100";
    ppdOptions.Duplex = "DuplexNoTumble";
  }];

should add a printer myprinter to your system. With current nixos-unstable branch, lpoptions -p myprinter -l will output

Duplex/Double-sided Printing: *None DuplexNoTumble DuplexTumble

i.e., the option was not used. With the pull request at hand applied, lpoptions -p myprinter -l will instead output

Duplex/Double-sided Printing: None *DuplexNoTumble DuplexTumble

showing that the option got applied properly.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/3959

@Yarny0
Copy link
Contributor Author

Yarny0 commented May 23, 2024

Thanks for the approval!

Now that 24.05 got branched off, can someone with sufficient privilegens please add the backport label, so we can avoid this regression in the upcoming release? Thanks!

@rhoriguchi rhoriguchi added the backport staging-24.05 Backport PR automatically label May 23, 2024
@Aleksanaa Aleksanaa added backport release-24.05 Backport PR automatically and removed backport staging-24.05 Backport PR automatically labels May 25, 2024
@SuperSandro2000 SuperSandro2000 merged commit 56744fd into NixOS:master Jun 2, 2024
26 checks passed
Copy link
Contributor

github-actions bot commented Jun 2, 2024

Successfully created backport PR for release-24.05:

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.

None yet

6 participants