0

I am trying to set up remote desktop into a Debian stretch distribution, I set up the file /etc/gdm3/daemon.conf.

[daemon]
WaylandEnable = false

[security]
DisallowTCP = false

[xdmcp]
Enable = true
Port = 177

[chooser]

[debug]
# Uncomment the line below to turn on debugging
# More verbose logs
# Additionally lets the X server dump core if it crashes
Enable = true

But when I restart the debian system, I see the following output on netstat:

udp6       0      0 :::177                  :::*                                11059/gdm3    

That is using udp6 and not udp4.

I have tried disabling inet6 into the system with the following lines into /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

I refresh the settings with sysctl -p, and restart the services with sudo init 3; sudo unit 5, but nothing change. I have rebooted the VM even, and still the same.

Any idea how I can force xdcmp to be listening on UDP v4 and not udp6?? Thanks in advance.

I am doing this to figure out the settings needed into another machine with the same linux distribution where I want to set up remote access to the desktop (so, I am gonna get the same issue). Actually I can access with xvnc running into the other host, but I want to set up xdmcp to request the login on remote access.

The exact system I am running:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 9.4 (stretch)
Release:    9.4
Codename:   stretch

$ apt-cache show gdm3
Package: gdm3
Version: 3.22.3-3+deb9u1
. . .
2
  • The commands to disable IPv6 make sense, but you should verify they had the actual effect: does ip -6 address give any output after the change is done (it shouldn't)? Then on debian there's no special use of init 5 it never meant "graphical mode" as on other Linux distributions. You should specifically restart gdm3 using the method available (systemctl, service ...). Commented Jun 2, 2018 at 14:57
  • @A.B When I run ip -6 no ip6 address were assigned to the interfaces. I run init 3 and init 5, to force gdm is reloaded. In my scenario init 5 start the graphical mode. Sorry for don't specify that. Commented Jun 2, 2018 at 15:18

1 Answer 1

1

I think I have found the response to my question. I have downloaded the source code for gdm3, and I have located where the socket is set up for xdmcp.

static gboolean
open_port (GdmXdmcpDisplayFactory *factory)
{
        struct sockaddr_storage serv_sa = { 0 };

        g_debug ("GdmXdmcpDisplayFactory: Start up on host %s, port %d",
                 factory->priv->hostname ? factory->priv->hostname : "(null)",
                 factory->priv->port);

        /* Open socket for communications */
#ifdef ENABLE_IPV6
        factory->priv->socket_fd = do_bind (factory->priv->port, AF_INET6, &serv_sa);
        if (factory->priv->socket_fd < 0)
#endif
                factory->priv->socket_fd = do_bind (factory->priv->port, AF_INET, &serv_sa);

        if G_UNLIKELY (factory->priv->socket_fd < 0) {
                g_warning (_("Could not create socket!"));
                return FALSE;
        }

        fd_set_close_on_exec (factory->priv->socket_fd);

        if (factory->priv->use_multicast) {
                setup_multicast (factory);
        }

        return TRUE;
}

Here can be seen that if the package was build to support IP6 and the bind operation finish properly, the socket will be listening only for UDP6, and not for UDP4.

The solution should be rebuild the package without the IP6 support, or modify the source code so that a new parameter is included to enable/disable IP6 from the file /etc/gdm3/daemon.conf.


Updated more information from the comments.

static int
create_socket (struct addrinfo *ai)
{
        int sock;

        sock = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol);
        if (sock < 0) {
                g_warning ("socket: %s", g_strerror (errno));
                return sock;
        }

#if defined(ENABLE_IPV6) && defined(IPV6_V6ONLY)
    if (ai->ai_family == AF_INET6) {
        int zero = 0;
        if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &zero, sizeof(zero)) < 0)
            g_warning("setsockopt(IPV6_V6ONLY): %s", g_strerror(errno));
    }
#endif

        if (bind (sock, ai->ai_addr, ai->ai_addrlen) < 0) {
                g_warning ("bind: %s", g_strerror (errno));
                close (sock);
                return -1;
        }

        return sock;
}

And we can see the following into proc filesystem:

$ cat /proc/sys/net/ipv6/bindv6only 
0

So, it looks no dual bind is made. It should be because IPV6_V6ONLY is defined.


After rebuilt the package without ip6 support:

udp        0      0 0.0.0.0:177             0.0.0.0:*                           - 
3
  • 1
    Actually Linux systems default to a dual IPv4-IPv6 stack for sockets behaviour. So just listening to the IPv6 socket will simultaneously listen to IPv4. Behaviour can be changed systemwide ( /proc/sys/net/ipv6/bindv6only ) or from the application with setsockopt(2), search IPV6_V6ONLY there: man 7 ipv6. So you have probably no Ipv4/IPv6 issue (but maybe an other one since you think you have a problem). Commented Jun 2, 2018 at 14:51
  • I have checked /proc/sys/net/ipv6/bindv6only that is 0, and into the source code I have found a conditional block with IPV6_V6ONLY, that call setsockopt. Commented Jun 2, 2018 at 14:57
  • 1
    I have rebuilt the gdm3 package without ip6 support vi gdm3-3.22.3/debian/rules +53, and removed the line --enable-ipv6=yes. Now it is working like a charm. Commented Jun 2, 2018 at 15:21

You must log in to answer this question.