~ci-train-bot/lightdm/lightdm-ubuntu-zesty-1679

« back to all changes in this revision

Viewing changes to src/xdmcp-server.c

  • Committer: Robert Ancell
  • Date: 2015-10-29 23:10:32 UTC
  • mto: This revision was merged to the branch mainline in revision 2235.
  • Revision ID: robert.ancell@canonical.com-20151029231032-fh9difqxe7thkyg4
Implement XDMCP ForwardQuery

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
}
200
200
 
201
201
static void
202
 
handle_query (XDMCPServer *server, GSocket *socket, GSocketAddress *address, XDMCPPacket *packet)
 
202
handle_query (XDMCPServer *server, GSocket *socket, GSocketAddress *address, gchar **authentication_names)
203
203
{
204
204
    XDMCPPacket *response;
205
205
    gchar **i;
206
206
    gchar *authentication_name = NULL;
207
207
 
208
208
    /* If no authentication requested and we are configured for none then allow */
209
 
    if (packet->Query.authentication_names[0] == NULL && server->priv->key == NULL)
 
209
    if (authentication_names[0] == NULL && server->priv->key == NULL)
210
210
        authentication_name = "";
211
211
 
212
 
    for (i = packet->Query.authentication_names; *i; i++)
 
212
    for (i = authentication_names; *i; i++)
213
213
    {
214
214
        if (strcmp (*i, get_authentication_name (server)) == 0 && server->priv->key != NULL)
215
215
        {
240
240
    xdmcp_packet_free (response);
241
241
}
242
242
 
 
243
static void
 
244
handle_forward_query (XDMCPServer *server, GSocket *socket, GSocketAddress *address, XDMCPPacket *packet)
 
245
{
 
246
    GSocketFamily family;
 
247
    GInetAddress *client_inet_address;
 
248
    GSocketAddress *client_address;
 
249
    gint i;
 
250
    guint16 port = 0;
 
251
 
 
252
    family = g_socket_get_family (socket);
 
253
    switch (family)
 
254
    {
 
255
    case G_SOCKET_FAMILY_IPV4:
 
256
        if (packet->ForwardQuery.client_address.length != 4)
 
257
        {
 
258
            g_warning ("Ignoring IPv4 XDMCP ForwardQuery with client address of length %d", packet->ForwardQuery.client_address.length);
 
259
            return;
 
260
        }
 
261
        break;
 
262
    case G_SOCKET_FAMILY_IPV6:
 
263
        if (packet->ForwardQuery.client_address.length != 16)
 
264
        {
 
265
            g_warning ("Ignoring IPv6 XDMCP ForwardQuery with client address of length %d", packet->ForwardQuery.client_address.length);
 
266
            return;
 
267
        }
 
268
        break;
 
269
    default:
 
270
        g_warning ("Unknown socket family %d", family);
 
271
        return;
 
272
    }
 
273
 
 
274
    for (i = 0; i < packet->ForwardQuery.client_port.length; i++)
 
275
        port = port << 8 | packet->ForwardQuery.client_port.data[i];
 
276
 
 
277
    client_inet_address = g_inet_address_new_from_bytes (packet->ForwardQuery.client_address.data, family);
 
278
    client_address = g_inet_socket_address_new (client_inet_address, port);
 
279
    g_object_unref (client_inet_address);
 
280
 
 
281
    handle_query (server, socket, client_address, packet->ForwardQuery.authentication_names);
 
282
 
 
283
    g_object_unref (client_address);
 
284
}
 
285
 
243
286
static guint8
244
287
atox (char c)
245
288
{
636
679
            case XDMCP_BroadcastQuery:
637
680
            case XDMCP_Query:
638
681
            case XDMCP_IndirectQuery:
639
 
                handle_query (server, socket, address, packet);
 
682
                handle_query (server, socket, address, packet->Query.authentication_names);
640
683
                break;
 
684
            case XDMCP_ForwardQuery:
 
685
                handle_forward_query (server, socket, address, packet);
641
686
            case XDMCP_Request:
642
687
                handle_request (server, socket, address, packet);
643
688
                break;