saned.service masked and cannot be unmasked

Bug #1577137 reported by Kjetil Thuen
80
This bug affects 15 people
Affects Status Importance Assigned to Milestone
sane-backends (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

After upgrading to 16.04 (from 14.04) I noticed the sane daemon (sane-utils 1.0.25+git20150528-1ubuntu2) was no longer running. Attempting to manually start it results in systems complaining that the service is masked:

kjetil at lucien in ~> sudo systemctl start saned
Failed to start saned.service: Unit saned.service is masked.

Unmasking it does not work:

kjetil at lucien in ~> sudo systemctl unmask saned
kjetil at lucien in ~> sudo systemctl start saned
Failed to start saned.service: Unit saned.service is masked.

kjetil at lucien in ~> ps u -C saned
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
kjetil at lucien in ~>

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: sane-utils 1.0.25+git20150528-1ubuntu2
ProcVersionSignature: Ubuntu 4.4.0-21.37-generic 4.4.6
Uname: Linux 4.4.0-21-generic x86_64
ApportVersion: 2.20.1-0ubuntu2
Architecture: amd64
Date: Sun May 1 13:10:31 2016
InstallationDate: Installed on 2012-08-01 (1368 days ago)
InstallationMedia: Ubuntu-Server 12.04 LTS "Precise Pangolin" - Release amd64 (20120424.1)
SourcePackage: sane-backends
UpgradeStatus: Upgraded to xenial on 2016-04-24 (6 days ago)
mtime.conffile..etc.default.saned: 2016-05-01T12:51:02.879807
mtime.conffile..etc.sane.d.saned.conf: 2016-01-10T13:57:20.785810

Revision history for this message
Kjetil Thuen (kjetil-thuen) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in sane-backends (Ubuntu):
status: New → Confirmed
Changed in sane-backends (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Hanky (hankschwie) wrote :

I have the same problem, but at least found a workaround.

The man-page for saned (http://manpages.ubuntu.com/manpages/xenial/man8/saned.8.html) shows a solution using systemd. Two config-files are needed in /etc/systemd/system, saned.socket and saned@.service.

With those files saned seem to work, even though it is masked. scanimage -L shows the network scanners, and xsane and other programmes can access those scanners without problems.

Revision history for this message
Hanky (hankschwie) wrote :
Revision history for this message
jurgen (jurgen-hofmann) wrote :

Hanky, I just tried your solution but without any luck. So I just made those two file and saved them in the path... do I need to do something with permissions?

Bother, this is a very annoying bug as I use the scanner a lot.

Revision history for this message
Hanky (hankschwie) wrote :

@ jurgen:

Perhaps you should have a look at https://wiki.ubuntuusers.de/SANE-Scanserver_im_Netzwerk/, judging from your email address you might be able to read german. Much about saned is documented there, I added my solution just the other day.

Revision history for this message
jurgen (jurgen-hofmann) wrote :

Thanks, I am Dutch (Holland) but I can indeed read and speak German :)

Revision history for this message
Hanky (hankschwie) wrote :

Another Workaround: Don't use systemd for saned. I removed

/lib/systemd/system/saned.service
/lib/systemd/system/saned.socket
/lib/systemd/system/saned@.service,

as well as the "new" files I added in

/etc/systemd/system/saned.socket
/etc/systemd/system/saned@.service,

configured saned as usual, and it works as it did in 14.04.

Revision history for this message
Hanky (hankschwie) wrote :

After doing some research I believe this is not a bug, but a misunderstanding. With systemd in use in 16.04 saned is started only "on demand", when a program calls for it.

The solution from the manpage I described above is actually realised with the sane-utils package, the files are part of that package, only difference is that the are placed in /lib/systemd/system instead of /etc/systemd/system.

sane.socket listens on port 6566 for incoming saned-requests,
`sudo systemtctl status saned.socked` results in

● saned.socket - saned incoming socket
   Loaded: loaded (/lib/systemd/system/saned.socket; enabled; vendor preset: enabled)
   Active: active (listening) since Mi 2016-05-25 16:46:07 CEST; 2h 17min ago
   Listen: [::]:6566 (Stream)
 Accepted: 0; Connected: 0

If saned is configured correctly and a program like xsane calls for it, it is started accordingly.

`sudo systemtctl status saned@*.service` (mark the * !) then will result in something like

● saned@0-192.168.xxx.xx:6566-192.168.xxx.xx:38046.service - Scanner Service (192.168.xxx.xx:38046)
   Loaded: loaded (/lib/systemd/system/saned@.service; indirect; vendor preset: enabled)
   Active: active (running) since Mi 2016-05-25 18:47:01 CEST; 6min ago
 Main PID: 2181 (saned)
   CGroup: /system.slice/system-saned.slice/saned@0-192.168.xxx.xx:6566-192.168.xxx.xx:38046.service
           └─2181 /usr/sbin/saned

Mai 25 18:47:01 computer-name systemd[1]: Started Scanner Service (192.168.xxx.xx:38046).
Mai 25 18:47:01 computer-name saned[2181]: saned (AF-indep+IPv6+systemd) from sane-backends 1.0.25git starting up
Mai 25 18:47:01 computername saned[2181]: check_host: access by remote host: ::ffff:192.168.xxx.xx
Mai 25 18:47:01 computername saned[2181]: init: access granted to saned-user@::ffff:192.168.xxx.xx

sane is loaded by /lib/systemd/system/saned@.service, which starts /usr/bin/saned as requested by xsane.

The service cannot be started manually by something like `sudo systemctl start saned`, because it is only started by incoming requests. `scanimage -L` will also start saned, but it will stop as soon as the process is completed.

Revision history for this message
jurgen (jurgen-hofmann) wrote :

This is very interesting.
A few notes however. Before 16.04 (kubuntu) I never had to configure sane manually, it just worked as it picked up my scanner (pixma MG5700). Furthermore 'sudo systemtctl status saned.socked' only results in 'sudo: systemtctl: command not found'.

I have a fresh 16.04 installation so maybe that is the reason you aforementioned workarounds don't work on my system?

Revision history for this message
Hanky (hankschwie) wrote :

I don't know if kubuntu ships systemd. The command is `systemctl status saned.socket`, sorry about that typo in the post above...

If you just used the scanner plugged into an usb socket of your machine, and not the net-backend, there was no need to configure sane manually... We are talking about saned, the sane network deamon, which is needed to use a scanner in your home network, but is connected to another computer acting as server.

Revision history for this message
jurgen (jurgen-hofmann) wrote :

That is silly of me, I didn't notice you typo (just copy pasted it) :)

Anyway 'sudo systemctl status saned.socket' results in:
● saned.socket - saned incoming socket
   Loaded: loaded (/etc/systemd/system/saned.socket; enabled; vendor preset: enabled)
   Active: active (listening) since Thu 2016-05-26 08:50:24 EAT; 4h 29min ago
   Listen: [::]:6566 (Stream)
 Accepted: 0; Connected: 0

My wife's laptop runs under Kubuntu 15.10. Sane had no difficulty finding our wifi Pixma mg5700. I did not have to configure anything. The scanner is connected with our router (wifi). The scanner worked just fine when I used 15.10 but after the fresh upgrade I get the message:
(sudo systemctl start saned)
'Failed to start saned.service: Unit saned.service is masked'
Tried the same command on my wife's laptop and sane just starts without complaining about masks.

Revision history for this message
jurgen (jurgen-hofmann) wrote :

Hold on a minute!

I just received some updates:
libudev1 (229-4ubuntu5) to 229-4ubuntu6
libudev1:i386 (229-4ubuntu5) to 229-4ubuntu6
python3-urllib3 (1.13.1-2) to 1.13.1-2ubuntu0.16.04.1
systemd (229-4ubuntu5) to 229-4ubuntu6
systemd-sysv (229-4ubuntu5) to 229-4ubuntu6
udev (229-4ubuntu5) to 229-4ubuntu6

Xsane just works fine now (without any configuration). It might be that the two extra config-files in /etc/systemd/system (saned.socket and saned@.service) are still needed. So I will do some more testing before celebrating :)

Revision history for this message
Kjetil Thuen (kjetil-thuen) wrote :

I can confirm that for me, with all packages updated, copying the saned*service files from /lib/systemd/system/ to /etc/systemd/ and then running systemctl start saned.socket made everything work again.

Yay!

I would still say this is a (packaging) bug though. It should work out of the box. Without copying the files, it does not work.

I also tried the Avahi based stand alone mode as described in /usr/share/doc/sane-utils/README.Debian, but I could not make that work. The service never shows up in Avahi.

Revision history for this message
Hanky (hankschwie) wrote :

I don't need the files in /etc/systemd/system, the default ones work after I removed the "new" ones:

Loaded: loaded (/lib/systemd/system/saned.socket; enabled; vendor preset: enabled)
.
Loaded: loaded (/lib/systemd/system/saned@.service; indirect; vendor preset: enabled)

I don't recall using something like `systemctl start saned.socket`, it now is started automatically when booting the machine.

I guess I didn't configure the other sane files correctly before I placed the files in /etc/systemd/system. I had some mistakes (wrong server/client adresses) in /etc/sane.d/saned.conf and /etc/sane.d/net.conf. After I corrected those, it work with the new files. Then I tried without , and it still worked...

Revision history for this message
Kjetil Thuen (kjetil-thuen) wrote :

Right!

I never tried issuing the start command without the files in /etc. At that point I assumed it should just start working when I put the files there. Removing the files in /etc and explicitly stopping/restarting the saned.socket service, it indeed still works.

But this means the system is back to how it was when I first reported the issue. I guess there must have been an update to some systemd related package making the saned.socket service start on boot. However, I cannot see anything that seems relevant in the changelogs. I haven't rebooted since upgrading to Xenial, so it is difficult to say when that might have happened.

Without the start command, systemctl status saned.socket reports "Active: inactive (dead)"

To sum up: It seems that, confusingly, the saned service is masked and impossible to unmask by design, and instead the saned.socket service needs to be running for networked scanning to work.

Since this is a multi purpose server, I am reluctant to reboot it. Can you confirm that everything on your setup is back to the stock config and that it still works after a reboot?

Revision history for this message
Hanky (hankschwie) wrote :

There actually was an update for systemd (as jurgen already posted), so probably there was a "fix" includes, who knows...
I can confirm that my setup is back to stock config, since I even reinstalled sane-utils to make sure. I don't have to explicitly start saned.socket, it works after every reboot, I can confirm that, too.

Revision history for this message
jurgen (jurgen-hofmann) wrote :

While the systemd related updates fixed sane again as I could find the pixma scanner again... However, it turned out to be a scanner from the office downstairs (lol, saves me some electricity but I am not sure whether they would be happy with that ;) ).

To find my own scanner (pixma MG5700 series) I had to upgrade to sane-backends-1.0.26 (from 1.0.25). I added a ppa to my sources.list to do this the easy way:
deb http://ppa.launchpad.net/rolfbensch/sane-git/ubuntu xenial main
deb-src http://ppa.launchpad.net/rolfbensch/sane-git/ubuntu xenial main
This version works like a charm.

Anyway, I am clueless about what the systemd fixed but it did it.

Hanky (hankschwie)
summary: - sane service masked and cannot be unmasked
+ saned.service masked and cannot be unmasked
Revision history for this message
Hanky (hankschwie) wrote :

I checked the whole procedure on a fresh 16.04 install.

To start saned.socket first I needed to run

`sudo systemctl start saned.socket`

However, in /usr/share/doc/sane-utils/README.Debian I found the solution: To use socket.saned from startup, you have to run

`sudo systemctl enable saned.socket`

once. The terminal tells me:

`Created symlink from /etc/systemd/system/sockets.target.wants/saned.socket to /lib/systemd/system/saned.socket.`

On the next reboot saned.socket starts right away. This explains why it was started on my working machine; I definitely tried that command in my attempts to start saned...

If you don't want that automatic start anymore, it has do be disabled again:

`sudo systemctl disable saned.socket`

So I would conclude: This is not a bug, but a feature ;-)

Revision history for this message
Alessandro Polverini (polve) wrote :

I'm running xenial (16.10) and I'm unable to start saned.
A strange thing I see is that the service is linked to /dev/null:

# ls -l /lib/systemd/system/saned.service
lrwxrwxrwx 1 root root 9 mag 19 17:35 /lib/systemd/system/saned.service -> /dev/null

Why is that? Do I need to remove that symlink?

Revision history for this message
Hanky (hankschwie) wrote :

With systemd used in 16.04 (xenial is 16.04, not 16.10, that will be released in october...) saned is not meant to be started manually. saned.socket is listening for incoming requests. saned is started when a program like XSane or scanimage are started and request a start of saned, too. There are quite a few XXX.service files in lib/systemd/system pointing to /dev/null. No need to remove those, since the service is handled other files, in this case by saned@.service in this case.

I'm no expert, but I read that it is necessary when in a foo.socket file an expression `Accept=yes` is used, the corresponding service file has to be foo@.service, while foo.service is not usable. I think that is the reason why it points to /dev/null

Just configure the other saned-files (/etc/sane.d/saned.conf on the server, /etc/sane.d/net.conf on the client), start the socket with `sudo systemctl start saned.socket`, start up XSane, and if you didn't make any mistakes you'll find a saned process running (see my last post).

Revision history for this message
Michael Härtl (h-mh) wrote :

I'm on Linux Mint 18 which is based on Ubuntu 16.04 and have exactly the same problem. Unfortunately the solutions provided here did not work for me. If I understand correctly, the fix should be:

# sudo systemctl start saned.socket
# sudo systemctl enable saned.socket

Still simple scan doesn't work and I never see an instance of saned being started. The scanner is found with "scanimage -L" though and it also worked fine with simple scan in earlier versions.

So something must still be missing. saned does not start for me.

Revision history for this message
Hanky (hankschwie) wrote :

Hi!
I tried to start simple scan with

#SANE_NET_HOSTS=XXX.XXX.XXX.XX simple-scan

and after some time it actually started, using the network scanner on XXX.XXX.XXX.XX, using a saned process.

Revision history for this message
jurgen (jurgen-hofmann) wrote :

I think this is more an 'rules' thing. In post #18 I said that I did not know what made it work but it did. I think it is because I downloaded and installed Scangear from Canon's website. I did this to test the printer and after that I removed the package again. However, it left a 'rules' files behind in /etc/udev/rules.d/ I cannot upload the file because my internet is to slow :(

Anyway, you can create your own:
Open a text editor (kate or gedit)
Note that you'll need root permissions so open gedit or kate in a terminal like this: sudo gedit (or kate).
And paste the following lines:

# 80-canon_mfp2.rules
ACTION!="add", GOTO="canon_mfp_end"
SUBSYSTEM=="usb_device", GOTO="canon_mfp_start"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GOTO="canon_mfp_start"
GOTO="canon_mfp_end"
LABEL="canon_mfp_start"
#MG7500 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="177c", MODE="666"
#MG6600 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="177e", MODE="666"
#MG5600 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="177f", MODE="666"
#MG2900 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="1780", MODE="666"
#MB2000 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="1778", MODE="666"
#MB2300 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="1779", MODE="666"
#MB5000 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="1776", MODE="666"
#MB5300 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="1777", MODE="666"
#E460 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="1788", MODE="666"
#MX490 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="1787", MODE="666"
#E480 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="1789", MODE="666"
#MG7700 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="178b", MODE="666"
#MG6900 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="178c", MODE="666"
#MG6800 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="178d", MODE="666"
#MG5700 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="178e", MODE="666"
#MG3600 series
ATTR{idVendor}=="04a9", ATTR{idProduct}=="178a", MODE="666"
LABEL="canon_mfp_end"

Save the file as 80-canon_mfp2.rules under /etc/udev/rules.d/

I am not sure whether this works but you can always remove the file again. You can, of course, also download and install the Scangear package yourself.

Jurgen

Revision history for this message
Anthony Buckley (tony-buckley) wrote :

I'm also having the same or similar problem with my Epson WF-3520. Worked find at 15.10, nothing after 16.04 upgrade. I was a little confused about which set up some of the comments described here. Mine is a printer / scanner directly connected to the router and accessed wirelessly. So in theory needing to set up a backend is not required(?). I have also bugged this separately at #1613027. I've also tested a few mainline kernels to see where the problem starts (it appears to be all the 4.4... series). Reverting to an earlier kernel allows scanning to work which may be a temporary work-around.
In any case I've tried the solutions raised here, but did not succeed.

Tony

Revision history for this message
penalvch (penalvch) wrote :

Kjetil Thuen, instructions for running saned via systemd are now available from https://help.ubuntu.com/community/SaneDaemonTutorial .

Changed in sane-backends (Ubuntu):
importance: Medium → Undecided
status: Confirmed → Invalid
Revision history for this message
intuiter (vmetsis) wrote :

I am experiencing the same issue after upgrading from 14.04 to 16.04. I have a Brother MFC-L8850CDW network printer/scanner and it used to be detected automatically and work fine with the SimpleScan application. After the upgrade the scanner cannot be detected anymore. The printer still works fine.
I tried a few of the suggestions from the previous posts but no luck.

>sudo service saned status
● saned.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead)

>sudo service saned start
Failed to start saned.service: Unit saned.service is masked.

Any possibility this issue will be resolved soon?

Revision history for this message
penalvch (penalvch) wrote :

intuiter, if you followed the previously provided instructions and it still doesn't work, then you have a problem that has nothing to do with this now closed report.

Hence, you would want to file a new report via a terminal:
ubuntu-bug sane-backends

Please feel free to subscribe me to it.

Revision history for this message
intuiter (vmetsis) wrote :

Thanks for the reply. I was able to get my scanner to work by following a different route.

1. Uninstalled and re-installed sane and sane-utils (not sure this step was necessary)
2. Downloaded and installed the drivers from the official Brother website (in order to use their brsaneconfig4 util)
3. Used brsaneconfig4 to configure the network scanner:
sudo brsaneconfig4 -a name=BrotherScanner model=MFC-L8850CDW ip=<address>

Just listing the steps in case someone else has the same problem.

sane.service still shows inactive (dead), but apparently, as it was mentioned earlier, it gets activated on demand.

Revision history for this message
Ferry Toth (ftoth) wrote :

This is still a problem with Yaketty Yak.

It looks like the systemd configuration files are messed up and urgently need to be fixed.

In my configuration (Epson RX420 scanner/printer) connected via USB with the local user trying to scan:
found USB scanner (vendor=0x04b8 [EPSON], product=0x080f [USB MFP]) at libusb:003:005

However,
scanimage -L

No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).

Updating from the PPA mentioned above scanimage still doesn't work, but XSane does.

Note: the ppa does not support Yaketty, so I added it using Synaptics (adding repository ppa:rolfbensch/sane-git, then changed the distribution field to Xenial.

This updates sane to 1.0.26-git20160712-xenial0

Revision history for this message
Alvaro Gil (alvaro-alvarogil) wrote :

The problem is the documentation is not correct, it states:

       for systemd we need to add 2 configuation files in /etc/systemd/system.

This is incorrect, move the two files to:

       /etc/systemd/

-------------------------------------------

after continue with the tutorial.

sudo systemctl enable saned.socket
sudo systemctl start saned.socket
systemctl status saned.socket

now it will load correctly on restart.

Revision history for this message
penalvch (penalvch) wrote :

Alvaro Gil, the original reporter's problem noted in the Bug Description is the scope of this long closed report.

Despite this, when stating documentation you are referring to https://help.ubuntu.com/community/SaneDaemonTutorial to advise, this was tested working in Xenial at the time of its creation with my hardware. Also, this follows the systemd man page of how to set up unit configuration files as per:
http://manpages.ubuntu.com/manpages/xenial/en/man5/systemd.unit.5.html

However, if you found that when following either your equipment doesn't work, you likely have an equipment specific issue, or perhaps a systemd issue. Hence, to have your issue addressed, you will want to file a new report via a terminal:
ubuntu-bug sane-backends

Please feel free to subscribe me to it.

Revision history for this message
Raphael Mankin (raph-p) wrote :

I am having the same problem on Ubuntu 18.04. It was working on both 16 and 18 until recently.

root@T550:~# systemctl status saned.socket
● saned.socket - saned incoming socket
   Loaded: loaded (/lib/systemd/system/saned.socket; enabled; vendor preset: ena
   Active: active (listening) since Fri 2019-07-05 00:03:10 BST; 1min 46s ago
   Listen: 0.0.0.0:6566 (Stream)
 Accepted: 0; Connected: 0
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/saned.socket

Jul 05 00:03:10 T550 systemd[1]: Listening on saned incoming socket.
root@T550:~# systemctl start saned
Failed to start saned.service: Unit saned.service is masked.
root@T550:~# service saned start
Failed to start saned.service: Unit saned.service is masked.
root@T550:~#

Revision history for this message
penalvch (penalvch) wrote :

Raphael Mankin, as this report is closed, you don't have the same problem, or root cause (although similar symptom).

Despite this, if you would like your issue addressed, please provide necessary debugging information by filing a new report via a terminal:
ubuntu-bug sane-backends

Please feel free to subscribe me to it.

Revision history for this message
Raphael Mankin (raph-p) wrote : Re: [Bug 1577137] Re: saned.service masked and cannot be unmasked

I ave already created a new bug #1835647

On Wed, 2019-07-10 at 00:37 +0000, Christopher M. Penalver wrote:
> Raphael Mankin, as this report is closed, you don't have the same
> problem, or root cause (although similar symptom).
>
> Despite this, if you would like your issue addressed, please provide
> necessary debugging information by filing a new report via a
> terminal:
> ubuntu-bug sane-backends
>
> Please feel free to subscribe me to it.
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.