unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
user.c (2884B)
1 /* 2 * IRC - Internet Relay Chat, src/modules/user.c 3 * (C) 2005 The UnrealIRCd Team 4 * 5 * See file AUTHORS in IRC package for additional names of 6 * the programmers. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 1, or (at your option) 11 * any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23 #include "unrealircd.h" 24 25 CMD_FUNC(cmd_user); 26 27 #define MSG_USER "USER" 28 29 ModuleHeader MOD_HEADER 30 = { 31 "user", 32 "5.0", 33 "command /user", 34 "UnrealIRCd Team", 35 "unrealircd-6", 36 }; 37 38 MOD_INIT() 39 { 40 CommandAdd(modinfo->handle, MSG_USER, cmd_user, 4, CMD_UNREGISTERED); 41 MARK_AS_OFFICIAL_MODULE(modinfo); 42 return MOD_SUCCESS; 43 } 44 45 MOD_LOAD() 46 { 47 return MOD_SUCCESS; 48 } 49 50 MOD_UNLOAD() 51 { 52 return MOD_SUCCESS; 53 } 54 55 /** The USER command, together with NICK this will register a user. 56 * As per UnrealIRCd 5 this command is only available to local clients. 57 * Intraserver traffic is handled through the UID command. 58 * parv[1] = username 59 * parv[2] = client host name (ignored) 60 * parv[3] = server host name (ignored) 61 * parv[4] = real name / gecos 62 * 63 * NOTE: Be advised that multiple USER messages are possible, 64 * hence, always check if a certain struct is already allocated... -- Syzop 65 */ 66 CMD_FUNC(cmd_user) 67 { 68 const char *username; 69 const char *realname; 70 char *p; 71 72 if (!MyConnect(client) || IsServer(client)) 73 return; 74 75 if (MyConnect(client) && (client->local->listener->options & LISTENER_SERVERSONLY)) 76 { 77 exit_client(client, NULL, "This port is for servers only"); 78 return; 79 } 80 81 if ((parc < 5) || BadPtr(parv[4])) 82 { 83 sendnumeric(client, ERR_NEEDMOREPARAMS, "USER"); 84 return; 85 } 86 87 username = parv[1]; 88 realname = parv[4]; 89 90 make_user(client); 91 92 /* set::modes-on-connect */ 93 client->umodes |= CONN_MODES; 94 client->user->server = me_hash; 95 strlcpy(client->info, realname, sizeof(client->info)); 96 strlcpy(client->user->username, username, sizeof(client->user->username)); 97 98 /* This cuts the username off at @, uh okay.. */ 99 if ((p = strchr(client->user->username, '@'))) 100 *p = '\0'; 101 102 if (*client->name && is_handshake_finished(client)) 103 { 104 /* NICK and no-spoof already received, now we have USER... */ 105 if (USE_BAN_VERSION && MyConnect(client)) 106 { 107 sendto_one(client, NULL, ":IRC!IRC@%s PRIVMSG %s :\1VERSION\1", 108 me.name, client->name); 109 } 110 register_user(client); 111 return; 112 } 113 }