unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
svslogin.c (2621B)
1 /* 2 * IRC - Internet Relay Chat, src/modules/svslogin.c 3 * (C) 2022 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 #define MSG_SVSLOGIN "SVSLOGIN" 26 27 CMD_FUNC(cmd_svslogin); 28 29 ModuleHeader MOD_HEADER 30 = { 31 "svslogin", 32 "6.0", 33 "command /SVSLOGIN", 34 "UnrealIRCd Team", 35 "unrealircd-6", 36 }; 37 38 MOD_INIT() 39 { 40 CommandAdd(modinfo->handle, MSG_SVSLOGIN, cmd_svslogin, MAXPARA, CMD_USER|CMD_SERVER); 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 /* 56 * SVSLOGIN message 57 * 58 * parv[1]: propagation mask 59 * parv[2]: target 60 * parv[3]: account name (SVID) 61 */ 62 CMD_FUNC(cmd_svslogin) 63 { 64 Client *target; 65 66 if (MyUser(client) || (parc < 3) || !parv[3]) 67 return; 68 69 /* We actually ignore parv[1] since this is a broadcast message. 70 * It is a broadcast message because we want ALL servers to know 71 * that the user is now logged in under account xyz. 72 */ 73 74 target = find_client(parv[2], NULL); 75 if (target) 76 { 77 if (IsServer(target)) 78 return; 79 80 if (target->user == NULL) 81 make_user(target); 82 83 strlcpy(target->user->account, parv[3], sizeof(target->user->account)); 84 user_account_login(recv_mtags, target); 85 if (MyConnect(target) && IsDead(target)) 86 return; /* was killed due to *LINE on ~a probably */ 87 } else { 88 /* It is perfectly normal for target to be NULL as this 89 * happens during registration phase (pre-connect). 90 * It just means we cannot set any properties for this user, 91 * which is fine in that case, since it will be synced via 92 * the UID message instead. 93 * We still have to broadcast the message, which is why 94 * we do not return here. 95 */ 96 } 97 98 /* Propagate to the rest of the network */ 99 sendto_server(client, 0, 0, NULL, ":%s SVSLOGIN %s %s %s", 100 client->name, parv[1], parv[2], parv[3]); 101 }