cups service: fix client sockets

Use systemd to create the directory for UNIX socket. Also use localhost instead
of 127.0.0.1 as is done in default cupsd.conf so that IPv6 is enabled when
available.

(cherry picked from commit 9c1c424e525b637560d91b99430b83cdaed24820)
release-18.03-flake
Nikolay Amiantov 2018-02-23 13:41:15 +03:00 committed by Vladimír Čunát
parent 9b53db5d7e
commit 6b3d6a9f7a
No known key found for this signature in database
GPG Key ID: E747DF1F9575A3AA
2 changed files with 8 additions and 3 deletions

View File

@ -124,7 +124,7 @@ in
listenAddresses = mkOption {
type = types.listOf types.str;
default = [ "127.0.0.1:631" ];
default = [ "localhost:631" ];
example = [ "*:631" ];
description = ''
A list of addresses and ports on which to listen.
@ -321,7 +321,10 @@ in
''}
'';
serviceConfig.PrivateTmp = true;
serviceConfig = {
PrivateTmp = true;
RuntimeDirectory = [ "cups" ];
};
};
systemd.services.cups-browsed = mkIf avahiEnabled

View File

@ -39,7 +39,9 @@ import ./make-test.nix ({pkgs, ... }: {
$client->waitForUnit("cups.service");
$client->sleep(10); # wait until cups is fully initialized
$client->succeed("lpstat -r") =~ /scheduler is running/ or die;
$client->succeed("lpstat -H") =~ "localhost:631" or die;
# Test that UNIX socket is used for connections.
$client->succeed("lpstat -H") =~ "/var/run/cups/cups.sock" or die;
# Test that HTTP server is available too.
$client->succeed("curl --fail http://localhost:631/");
$client->succeed("curl --fail http://server:631/");
$server->fail("curl --fail --connect-timeout 2 http://client:631/");