Skip to content

Add support for Brother MFC-L2700DN #25654

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

Merged
merged 2 commits into from
Jul 13, 2017
Merged

Add support for Brother MFC-L2700DN #25654

merged 2 commits into from
Jul 13, 2017

Conversation

4z3
Copy link
Contributor

@4z3 4z3 commented May 9, 2017

Motivation for this change
Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

mkdir -p $out/share/cups/model

ln $dir/cupswrapper/brother_lpdwrapper_MFCL2700DN $out/lib/cups/filter
ln $dir/cupswrapper/brother-MFCL2700DN-cups-en.ppd $out/share/cups/model
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite sure, if nix handles hard-links properly. Does a symlink -s also works here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nix handles hard-links properly.

coreutils ghostscript gnugrep gnused which
]}

interpreter=${stdenv.cc.libc.out}/lib/ld-linux.so.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interpreter="$(cat $NIX_CC/nix-support/dynamic-linker)"

is a little bit more portable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Haven't seen that construct before.

homepage = "http://www.brother.com/";
license = stdenv.lib.licenses.unfree;
maintainers = [ stdenv.lib.maintainers.tv ];
platforms = stdenv.lib.platforms.linux;
Copy link
Member

@Mic92 Mic92 May 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binary package added is i386-specific. This should be limited here.

name = "mfcl2700dncupswrapper-${meta.version}";

src = fetchurl {
url = "http://download.brother.com/welcome/dlf102086/${name}.i386.deb";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there also an 64-bit package available?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope.

homepage = "http://www.brother.com/";
license = stdenv.lib.licenses.gpl2Plus;
maintainers = [ stdenv.lib.maintainers.tv ];
platforms = stdenv.lib.platforms.linux;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same platform restriction as below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite its source archive name, mfcl2700dncupswrapper contains just generic Perl scripts and a PPD file.

4z3 added 2 commits May 10, 2017 00:20

Verified

This commit was signed with the committer’s verified signature.
vcunat Vladimír Čunát
substituteInPlace $dir/cupswrapper/brother_lpdwrapper_MFCL2700DN \
--replace /usr/bin/perl ${perl}/bin/perl \
--replace "basedir =~" "basedir = \"$basedir\"; #" \
--replace "PRINTER =~" "PRINTER = \"MFCL2700DN\"; #"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a symlink racecondition vulnerability in this wrapper code. I will make a pull request to harden cups against these kind of attacks.

@Mic92 Mic92 mentioned this pull request May 10, 2017
7 tasks
Mic92 added a commit to Mic92/nixpkgs that referenced this pull request May 10, 2017
printer driver and wrapper are often not written with security in mind.

While reviewing NixOS#25654 I found
a symlink-race vulnerability within the wrapper code, when writing
unique files in /tmp.
I expect this script to be reused in other models as well
as similar vulnerabilities in the code of other vendors. Therefore
I propose to make /tmp of cups.service private so that only processes
with the same privileges are able to access these files.

nativeBuildInputs = [ dpkg makeWrapper ];

phases = [ "installPhase" ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FRidh doesn't like skipping phases like this, although it's documented in the manual as a method to do things. Not sure what others think about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xABAB the attribute phases is documented mentioning it can be used for skipping phases but I don't think its explicitly recommended to use it for skipping phases. The issue is that sometimes logic in some of the phases is needed but not executed because the phases are introduced. A common case is multiple outputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what's your suggestion here?

--replace "basedir =~" "basedir = \"$basedir\"; #" \
--replace "PRINTER =~" "PRINTER = \"MFCL2700DN\"; #"

wrapProgram $dir/cupswrapper/brother_lpdwrapper_MFCL2700DN \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"$dir"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why quote $dir here when $out isn't quoted anywhere? Only reason I could imagine is ShellCheck complaining :)


nativeBuildInputs = [ dpkg makeWrapper ];

phases = [ "installPhase" ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

--replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$dir\"; #" \
--replace "PRINTER =~" "PRINTER = \"MFCL2700DN\"; #"

wrapProgram $dir/lpd/filter_MFCL2700DN \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@Mic92 Mic92 merged commit 30223dd into NixOS:master Jul 13, 2017
@4z3 4z3 deleted the mfcl2700dn branch July 13, 2017 21:05
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.

None yet

6 participants