00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "stdinc.h"
00027 #include "handlers.h"
00028 #include "client.h"
00029 #include "common.h"
00030 #include "ircd.h"
00031 #include "irc_string.h"
00032 #include "numeric.h"
00033 #include "fdlist.h"
00034 #include "s_bsd.h"
00035 #include "s_conf.h"
00036 #include "s_log.h"
00037 #include "s_serv.h"
00038 #include "send.h"
00039 #include "msg.h"
00040 #include "parse.h"
00041 #include "modules.h"
00042 #include "s_user.h"
00043 #include "hash.h"
00044
00045 static void mo_chgident(struct Client *, struct Client *, int, char *[]);
00046 static void mo_chghost(struct Client *, struct Client *, int, char *[]);
00047 static void mo_chgname(struct Client *, struct Client *, int, char *[]);
00048
00049 struct Message chgident_msgtab = {
00050 "CHGIDENT", 0, 0, 2, 0, MFLG_SLOW, 0,
00051 {m_unregistered, m_not_oper, mo_chgident, mo_chgident, mo_chgident, m_ignore}
00052 };
00053
00054 struct Message chghost_msgtab = {
00055 "CHGHOST", 0, 0, 2, 0, MFLG_SLOW, 0,
00056 {m_unregistered, m_not_oper, mo_chghost, mo_chghost, mo_chghost, m_ignore}
00057 };
00058
00059 struct Message chgname_msgtab = {
00060 "CHGNAME", 0, 0, 2, 0, MFLG_SLOW, 0,
00061 {m_unregistered, m_not_oper, mo_chgname, mo_chgname, mo_chgname, m_ignore}
00062 };
00063
00064 #ifndef STATIC_MODULES
00065 void
00066 _modinit(void)
00067 {
00068 mod_add_cmd(&chgident_msgtab);
00069 mod_add_cmd(&chghost_msgtab);
00070 mod_add_cmd(&chgname_msgtab);
00071 }
00072
00073 void
00074 _moddeinit(void)
00075 {
00076 mod_del_cmd(&chgname_msgtab);
00077 mod_del_cmd(&chghost_msgtab);
00078 mod_del_cmd(&chgident_msgtab);
00079 }
00080
00081 const char *_version = "$Revision: 564 $";
00082 #endif
00083
00084 static void
00085 mo_chgident(struct Client *client_p, struct Client *source_p,
00086 int parc, char *parv[])
00087 {
00088 struct Client *target_p = NULL;
00089
00090 if (MyClient(source_p) && !IsOperAdmin(source_p))
00091 {
00092 sendto_one(source_p, form_str(ERR_NOPRIVS),
00093 me.name, parv[0], "CHGIDENT");
00094 return;
00095 }
00096
00097 if (EmptyString(parv[2]))
00098 {
00099 parv[2] = parv[1];
00100
00101 target_p = source_p;
00102 if (!IsClient(target_p))
00103 return;
00104 }
00105 else {
00106 target_p = find_client(parv[1]);
00107
00108 if (target_p == NULL || !IsClient(target_p))
00109 {
00110 sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
00111 return;
00112 }
00113 }
00114
00115 if (strlen(parv[2]) > USERLEN || !*parv[2] || !valid_username(parv[2]))
00116 {
00117 sendto_one(source_p, ":%s NOTICE %s :Invalid username", me.name, parv[0]);
00118 return;
00119 }
00120
00121 strcpy(target_p->username, parv[2]);
00122
00123 if (MyClient(source_p))
00124 {
00125 sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
00126 ":%s ENCAP * CHGIDENT %s %s",
00127 parv[0], target_p->name, parv[2]);
00128 sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
00129 me.name, parv[0], target_p->name, target_p->username,
00130 target_p->host);
00131 }
00132
00133 if (MyConnect(target_p) && IsClient(source_p))
00134 sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
00135 me.name, target_p->name, target_p->username, target_p->host);
00136 }
00137
00138 static void
00139 mo_chghost(struct Client *client_p, struct Client *source_p,
00140 int parc, char *parv[])
00141 {
00142 struct Client *target_p = NULL;
00143
00144 if (MyClient(source_p) && !IsOperAdmin(source_p))
00145 {
00146 sendto_one(source_p, form_str(ERR_NOPRIVS),
00147 me.name, parv[0], "CHGHOST");
00148 return;
00149 }
00150
00151 if (EmptyString(parv[2]))
00152 {
00153 parv[2] = parv[1];
00154
00155 target_p = source_p;
00156 if (!IsClient(target_p))
00157 return;
00158 }
00159 else {
00160 target_p = find_client(parv[1]);
00161 if (target_p == NULL || !IsClient(target_p))
00162 {
00163 sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
00164 return;
00165 }
00166 }
00167
00168 if (strlen(parv[2]) > HOSTLEN || !*parv[2] || !valid_hostname(parv[2]))
00169 {
00170 sendto_one(source_p, ":%s NOTICE %s :Invalid hostname", me.name, parv[0]);
00171 return;
00172 }
00173
00174 strcpy(target_p->host, parv[2]);
00175 SetIPSpoof(target_p);
00176
00177 if (MyClient(source_p))
00178 {
00179 sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
00180 ":%s ENCAP * CHGHOST %s %s",
00181 parv[0], target_p->name, parv[2]);
00182 sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
00183 me.name, parv[0], target_p->name, target_p->username,
00184 target_p->host);
00185 }
00186
00187 if (MyConnect(target_p) && IsClient(source_p))
00188 sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
00189 me.name, target_p->name, target_p->username, target_p->host);
00190 }
00191
00192 static void
00193 mo_chgname(struct Client *client_p, struct Client *source_p,
00194 int parc, char *parv[])
00195 {
00196 struct Client *target_p = NULL;
00197
00198 if (MyClient(source_p) && !IsOperAdmin(source_p))
00199 {
00200 sendto_one(source_p, form_str(ERR_NOPRIVS),
00201 me.name, parv[0], "CHGNAME");
00202 return;
00203 }
00204
00205 if (EmptyString(parv[2]))
00206 {
00207 parv[2] = parv[1];
00208 target_p = source_p;
00209 }
00210 else if ((target_p = find_client(parv[1])) == NULL)
00211 {
00212 sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
00213 return;
00214 }
00215
00216 if (strlen(parv[2]) > REALLEN || !*parv[2])
00217 {
00218 sendto_one(source_p, ":%s NOTICE %s :Invalid realname", me.name, parv[0]);
00219 return;
00220 }
00221
00222 if (parc > 3 && MyClient(source_p))
00223 sendto_one(source_p, ":%s NOTICE %s :Warning -- too many parameters "
00224 "for CHGNAME. You are probably missing a : before the new "
00225 "IRC name.", me.name, parv[0]);
00226
00227 strcpy(target_p->info, parv[2]);
00228
00229 if (MyClient(source_p))
00230 {
00231 sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
00232 ":%s ENCAP * CHGNAME %s :%s",
00233 parv[0], target_p->name, parv[2]);
00234 sendto_one(source_p, ":%s NOTICE %s :%s realname changed to [%s]",
00235 me.name, parv[0], target_p->name, target_p->info);
00236 }
00237
00238 if (MyClient(target_p) && IsClient(source_p))
00239 sendto_one(target_p, ":%s NOTICE %s :Your realname is now [%s]",
00240 me.name, target_p->name, target_p->info);
00241 }