[OpenIndiana-discuss] Python abstact socket and config printer applet.py

Bill Sommerfeld sommerfeld at hamachi.org
Wed Dec 13 23:03:31 UTC 2023


On 12/13/23 09:24, Carsten Grzemba via openindiana-discuss wrote:
> I don't know when I have seen the last time the printer applet in mate-panel.
> 
> On my attempts to revive the applet I stumbled on the abstract socket stuff in the Python code of applet.py
> 
> If i try to start
> 
> /usr/share/system-config-printer/applet.py I get the exception
> 
> Process already running (2:No such file or directory). Exiting.
> 
> 
> For the used syntax
> 
> sock.bind("\0printer-applet-lock-user-" + getpass.getuser())
> the error is 2:No such file or directory, the "Process already running" notice is the interpretation of the exception handler
> 
> A sock.bind with an normal string works, but not the style with the leading \0. This is the syntax for abstract sockets on Linux.
> I have no idea if abstract sockets would work on Illumos and Python. But how should work the printer applet on non Linux systems?


Linux unix(7) says:

 >     The abstract socket namespace is a nonportable Linux extension.

It looks like there's support for this in the out-of-illumos-gate lx brand:

https://github.com/TritonDataCenter/illumos-joyent/blob/master/usr/src/uts/common/brand/lx/syscall/lx_socket.c#L390

but that's not handled in the native syscall.

But you can very much do in userspace what this does in the kernel: 
replace the NUL at the start of the pathname with the path to a 
sticky-bitted world-writable directory.

This appears to fix it for me:

--- applet.py~  Tue Mar 14 12:01:25 2023
+++ applet.py   Wed Dec 13 14:59:02 2023
@@ -464,7 +464,7 @@
      try:
          sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
          # Create an abstract socket, by prefixing it with null.
-        sock.bind("\0printer-applet-lock-user-" + getpass.getuser())
+        sock.bind("/tmp/printer-applet-lock-user-" + getpass.getuser())
      except socket.error as err:
          error_code = err.args[0]
          error_string = err.args[1]

but maybe /tmp isn't the best place..





More information about the openindiana-discuss mailing list