xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #1521: socket-activation.patch

File socket-activation.patch, 5.6 KB (added by Antoine Martin, 4 years ago)

support socket activation

  • etc/sysconfig/xpra

     
    11TCP_AUTH=sys
    2 AUTH=sys
     2AUTH=peercred
    33#DEBUG=auth,proxy
    44DEBUG=
  • service/xpra.service

     
    11[Unit]
    2 Description=Xpra Proxy Server
     2Description=Xpra System Server
    33Wants=avahi-daemon.socket
    44Documentation=https://xpra.org/trac/wiki/ProxyServer man:xpra
     5After=network.target xpra.socket
     6Requires=xpra.socket
    57
    68[Service]
    79Type=simple
    810EnvironmentFile=-/etc/sysconfig/xpra
    9 ExecStart=/usr/bin/xpra proxy :14500 --daemon=no --bind-tcp=0.0.0.0:14500 --tcp-auth=${TCP_AUTH} --ssl-cert=/etc/xpra/ssl-cert.pem --bind=auto --auth=${AUTH} --socket-dirs=/var/run/xpra --socket-permissions=666 --log-dir=/var/log --pidfile=/var/run/xpra.pid --debug=${DEBUG}
     11#ExecStart=/usr/bin/xpra proxy :14500 --daemon=no --bind-tcp=0.0.0.0:14500 --tcp-auth=${TCP_AUTH} --ssl-cert=/etc/xpra/ssl-cert.pem --bind=auto --auth=${AUTH} --socket-dirs=/var/run/xpra --socket-permissions=666 --log-dir=/var/log --pidfile=/var/run/xpra.pid --debug=${DEBUG}
     12ExecStart=/usr/bin/xpra proxy :14500 --daemon=no --tcp-auth=${TCP_AUTH} --ssl-cert=/etc/xpra/ssl-cert.pem --auth=${AUTH} --socket-dirs=/var/run/xpra --socket-permissions=666 --log-dir=/var/log --pidfile=/var/run/xpra.pid --debug=${DEBUG}
    1013#rely on SIGKILL which returns 128+15=143
    1114SuccessExitStatus=0 143
    1215Restart=on-abnormal
  • service/xpra.socket

     
     1[Unit]
     2Description=Xpra Socket
     3PartOf=xpra.service
     4
     5[Socket]
     6ListenStream=14500
     7ListenStream=/var/run/xpra/system
     8#this is not handled yet:
     9#ListenStream=vsock:x:y
     10SocketUser=root
     11SocketGroup=xpra
     12PassCredentials=true
     13
     14[Install]
     15WantedBy=sockets.target
  • setup.py

     
    143143shadow_ENABLED = SHADOW_SUPPORTED and not (PYTHON3 and LINUX) and DEFAULT       #shadow servers use some GTK2 code..
    144144server_ENABLED = (LOCAL_SERVERS_SUPPORTED or shadow_ENABLED) and not (PYTHON3 and LINUX) and DEFAULT
    145145service_ENABLED = LINUX and server_ENABLED
     146sd_listen_ENABLED = pkg_config_ok("--exists", "libsystemd")
    146147proxy_ENABLED  = DEFAULT
    147148client_ENABLED = DEFAULT
    148149
     
    15341535                    copytodir("etc/sysconfig/xpra", "/etc/sysconfig")
    15351536                elif os.path.exists("/etc/default"):
    15361537                    copytodir("etc/sysconfig/xpra", "/etc/default")
     1538            if sd_listen_ENABLED:
     1539                copytodir("service/xpra.socket", "/lib/systemd/system")
    15371540
    15381541
    15391542    # add build_conf to build step
     
    18701873                ["xpra/server/window/motion.pyx"],
    18711874                **O3_pkgconfig))
    18721875
     1876if sd_listen_ENABLED:
     1877    sdp = pkgconfig("libsystemd")
     1878    cython_add(Extension("xpra.server.sd_listen",
     1879                ["xpra/server/sd_listen.pyx"],
     1880                **sdp))
    18731881
     1882
    18741883toggle_packages(enc_proxy_ENABLED, "xpra.codecs.enc_proxy")
    18751884
    18761885toggle_packages(nvfbc_ENABLED, "xpra.codecs.nvfbc")
  • xpra/scripts/server.py

     
    477477        _, tcp_socket, host_port = setup_tcp_socket(host, iport, "SSL")
    478478        socket = ("SSL", wrap_socket_fn(tcp_socket), host_port)
    479479        sockets.append(socket)
    480         if opts.mdns:
    481             rec = "ssl", [(host, iport)]
    482             mdns_recs.append(rec)
     480        rec = "ssl", [(host, iport)]
     481        mdns_recs.append(rec)
    483482
    484483    # Initialize the TCP sockets before the display,
    485484    # That way, errors won't make us kill the Xvfb
    486485    # (which may not be ours to kill at that point)
     486    tcp_ssl = ssl_opt in TRUE_OPTIONS or (ssl_opt=="auto" and opts.ssl_cert)
     487    def add_tcp_mdns_rec(host, iport):
     488        rec = "tcp", [(host, iport)]
     489        mdns_recs.append(rec)
     490        if tcp_ssl:
     491            #SSL is also available on this TCP socket:
     492            rec = "ssl", [(host, iport)]
     493            mdns_recs.append(rec)
    487494    for host, iport in bind_tcp:
    488495        socket = setup_tcp_socket(host, iport)
    489496        sockets.append(socket)
    490         if opts.mdns:
    491             rec = "tcp", [(host, iport)]
    492             mdns_recs.append(rec)
    493             if ssl_opt in TRUE_OPTIONS or (ssl_opt=="auto" and opts.ssl_cert):
    494                 #SSL is also available on this TCP socket:
    495                 rec = "ssl", [(host, iport)]
    496                 mdns_recs.append(rec)
     497        add_tcp_mdns_rec(host, iport)
    497498
    498499    # VSOCK:
    499500    for cid, iport in bind_vsock:
    500501        socket = setup_vsock_socket(cid, iport)
    501502        sockets.append(socket)
    502         if opts.mdns:
    503             rec = "vsock", [("", iport)]
    504             mdns_recs.append(rec)
     503        rec = "vsock", [("", iport)]
     504        mdns_recs.append(rec)
    505505
     506    # systemd socket activation:
     507    try:
     508        from xpra.server.sd_listen import get_sd_listen_sockets
     509    except ImportError:
     510        pass
     511    else:
     512        sd_sockets = get_sd_listen_sockets()
     513        for stype, sock, addr in sd_sockets:
     514            sockets.append((stype, sock, addr))
     515            if stype=="tcp":
     516                host, iport = addr
     517                add_tcp_mdns_rec(host, iport)
     518
    506519    # Do this after writing out the shell script:
    507520    if display_name[0] != 'S':
    508521        os.environ["DISPLAY"] = display_name