- CONN_ID conn;
- CLIENT *client;
- int result;
- size_t len;
- PROC_STAT *proc;
-
- LogDebug("Auth: Got callback on fd %d, events %d", r_fd, events);
- conn = Conn_GetFromProc(r_fd);
- if (conn == NONE) {
- /* Ops, none found? Probably the connection has already
- * been closed!? We'll ignore that ... */
- io_close(r_fd);
- LogDebug("Auth: Got callback for unknown connection!?");
- return;
- }
- proc = Conn_GetProcStat(conn);
- client = Conn_GetClient(conn);
-
- /* Read result from pipe */
- len = Proc_Read(proc, &result, sizeof(result));
- if (len == 0)
- return;
-
- if (len != sizeof(result)) {
- Log(LOG_CRIT, "Auth: Got malformed result!");
- Reject_Client(client);
- return;
- }
-
- if (result == true)
- (void)Hello_User_PostAuth(client);
- else
- Reject_Client(client);
-}
-
-#endif
-
-
-static void
-Reject_Client(CLIENT *Client)
-{
- Log(LOG_ERR,
- "User \"%s\" rejected (connection %d): Access denied!",
- Client_Mask(Client), Client_Conn(Client));
- Conn_Close(Client_Conn(Client), NULL,
- "Access denied! Bad password?", true);
-}
-
-
-static bool
-Hello_User_PostAuth(CLIENT *Client)
-{
- Introduce_Client(NULL, Client, CLIENT_USER);
-
- if (!IRC_WriteStrClient
- (Client, RPL_WELCOME_MSG, Client_ID(Client), Client_Mask(Client)))
- return false;
- if (!IRC_WriteStrClient
- (Client, RPL_YOURHOST_MSG, Client_ID(Client),
- Client_ID(Client_ThisServer()), PACKAGE_VERSION, TARGET_CPU,
- TARGET_VENDOR, TARGET_OS))
- return false;
- if (!IRC_WriteStrClient
- (Client, RPL_CREATED_MSG, Client_ID(Client), NGIRCd_StartStr))
- return false;
- if (!IRC_WriteStrClient
- (Client, RPL_MYINFO_MSG, Client_ID(Client),
- Client_ID(Client_ThisServer()), PACKAGE_VERSION, USERMODES,
- CHANMODES))
- return false;
-
- /* Features supported by this server (005 numeric, ISUPPORT),
- * see <http://www.irc.org/tech_docs/005.html> for details. */
- if (!IRC_Send_ISUPPORT(Client))
- return DISCONNECTED;
-
- if (!IRC_Send_LUSERS(Client))
- return DISCONNECTED;
- if (!IRC_Show_MOTD(Client))
- return DISCONNECTED;
-
- /* Suspend the client for a second ... */
- IRC_SetPenalty(Client, 1);
-
- return CONNECTED;
-}
-
-
-static void
-Kill_Nick( char *Nick, char *Reason )
-{
- REQUEST r;
-
- assert( Nick != NULL );
- assert( Reason != NULL );
-
- r.prefix = (char *)Client_ThisServer( );
- r.argv[0] = Nick;
- r.argv[1] = Reason;
- r.argc = 2;
-
- Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
- IRC_KILL( Client_ThisServer( ), &r );
-} /* Kill_Nick */
-
-
-static void
-Introduce_Client(CLIENT *From, CLIENT *Client, int Type)
-{
- /* Set client type (user or service) */
- Client_SetType(Client, Type);
-
- if (From) {
- if (Conf_IsService(Conf_GetServer(Client_Conn(From)),
- Client_ID(Client)))
- Client_SetType(Client, CLIENT_SERVICE);
- LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",
- Client_TypeText(Client), Client_Mask(Client),
- Client_Modes(Client), Client_ID(From),
- Client_ID(Client_Introducer(Client)),
- Client_Hops(Client), Client_Hops(Client) > 1 ? "s": "");