identd: Respond for INVALID-PORT and NO-USER errors
This commit is contained in:
parent
963ba2bf2d
commit
77ac0863f8
|
@ -140,13 +140,29 @@ identd_read_ready (GDataInputStream *in_stream, GAsyncResult *res, ident_info *i
|
||||||
remote = g_ascii_strtoull (p + 1, NULL, 0);
|
remote = g_ascii_strtoull (p + 1, NULL, 0);
|
||||||
g_free (read_buf);
|
g_free (read_buf);
|
||||||
|
|
||||||
if (!local || !remote || local > G_MAXUINT16 || remote > G_MAXUINT16)
|
g_snprintf (buf, sizeof (buf), "%"G_GUINT16_FORMAT", %"G_GUINT16_FORMAT" : ",
|
||||||
goto cleanup;
|
(guint16)MIN(local, G_MAXUINT16), (guint16)MIN(remote, G_MAXUINT16));
|
||||||
|
|
||||||
info->username = g_strdup (g_hash_table_lookup (responses, GINT_TO_POINTER (local)));
|
if (!local || !remote || local > G_MAXUINT16 || remote > G_MAXUINT16)
|
||||||
|
{
|
||||||
|
g_strlcat (buf, "ERROR : INVALID-PORT\r\n", sizeof (buf));
|
||||||
|
g_info ("Identd: Recieved invalid port");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info->username = g_hash_table_lookup (responses, GINT_TO_POINTER (local));
|
||||||
if (!info->username)
|
if (!info->username)
|
||||||
goto cleanup;
|
{
|
||||||
g_hash_table_remove (responses, GINT_TO_POINTER (local));
|
g_strlcat (buf, "ERROR : NO-USER\r\n", sizeof (buf));
|
||||||
|
g_info ("Identd: Recieved invalid local port");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const gsize len = strlen (buf);
|
||||||
|
|
||||||
|
g_hash_table_steal (responses, GINT_TO_POINTER (local));
|
||||||
|
|
||||||
|
g_snprintf (buf + len, sizeof (buf) - len, "USERID : UNIX : %s\r\n", info->username);
|
||||||
|
|
||||||
if ((sok_addr = g_socket_connection_get_remote_address (info->conn, NULL)))
|
if ((sok_addr = g_socket_connection_get_remote_address (info->conn, NULL)))
|
||||||
{
|
{
|
||||||
|
@ -162,8 +178,9 @@ identd_read_ready (GDataInputStream *in_stream, GAsyncResult *res, ident_info *i
|
||||||
g_object_unref (inet_addr);
|
g_object_unref (inet_addr);
|
||||||
g_free (addr);
|
g_free (addr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_snprintf (buf, sizeof (buf), "%"G_GUINT16_FORMAT", %"G_GUINT16_FORMAT" : USERID : UNIX : %s\r\n", (guint16)local, (guint16)remote, info->username);
|
|
||||||
out_stream = g_io_stream_get_output_stream (G_IO_STREAM (info->conn));
|
out_stream = g_io_stream_get_output_stream (G_IO_STREAM (info->conn));
|
||||||
g_output_stream_write_async (out_stream, buf, strlen (buf), G_PRIORITY_DEFAULT,
|
g_output_stream_write_async (out_stream, buf, strlen (buf), G_PRIORITY_DEFAULT,
|
||||||
NULL, (GAsyncReadyCallback)identd_write_ready, info);
|
NULL, (GAsyncReadyCallback)identd_write_ready, info);
|
||||||
|
|
Loading…
Reference in New Issue