~ubuntu-branches/ubuntu/lucid/inspircd/lucid-security

« back to all changes in this revision

Viewing changes to src/cmd_gline.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Giacomo Catenazzi, Darren Blaber, Matt Arnold, Giacomo Catenazzi
  • Date: 2008-03-06 07:56:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080306075647-z8a4phxkn3vo3ajx
Tags: 1.1.17+dfsg-1
[ Darren Blaber ]
* New upstream release, fix /etc/init.d/inspircd stop.
* Fix the postrm script so there is no duplicate update-rc.d
* Fix the manpage so there are no more errors in it

[ Matt Arnold ]
*  Fix prerm so it works (Closes: #466924)

[ Giacomo Catenazzi ]
* Added me as uploader
* Add again support of dpatch in debian/rules
* Build sources only once!
* Correct make clean target, not to include generated ./inspircd on sources
* Don't change permission of configuration files, when starting inspircd
  (separation of policy and program).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *       | Inspire Internet Relay Chat Daemon |
3
3
 *       +------------------------------------+
4
4
 *
5
 
 *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
 
5
 *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6
6
 * See: http://www.inspircd.org/wiki/index.php/Credits
7
7
 *
8
8
 * This program is free but copyrighted software; see
27
27
 */
28
28
CmdResult cmd_gline::Handle (const char** parameters, int pcnt, userrec *user)
29
29
{
 
30
        std::string target = parameters[0];
 
31
        
30
32
        if (pcnt >= 3)
31
33
        {
32
 
                IdentHostPair ih = ServerInstance->XLines->IdentSplit(parameters[0]);
 
34
                IdentHostPair ih;
 
35
                userrec* find = ServerInstance->FindNick(target.c_str());
 
36
                if (find)
 
37
                {
 
38
                        std::string c = std::string("*@") + find->GetIPString();
 
39
                        ih.first = "*";
 
40
                        ih.second = find->GetIPString();
 
41
                        target = c.c_str();
 
42
                }
 
43
                else
 
44
                        ih = ServerInstance->XLines->IdentSplit(target.c_str());
 
45
 
 
46
                if (ih.first.empty())
 
47
                {
 
48
                        user->WriteServ("NOTICE %s :*** Target not found", user->nick);
 
49
                        return CMD_FAILURE;
 
50
                }
 
51
 
33
52
                if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
34
53
                        return CMD_FAILURE;
35
54
 
36
 
                if (!strchr(parameters[0],'@'))
37
 
                {       
38
 
                        user->WriteServ("NOTICE %s :*** G-Line must contain a username, e.g. *@%s",user->nick,parameters[0]);
39
 
                        return CMD_FAILURE;
40
 
                }
41
 
                else if (strchr(parameters[0],'!'))
 
55
                else if (strchr(target.c_str(),'!'))
42
56
                {
43
 
                        user->WriteServ("NOTICE %s :*** G-Line cannot contain a nickname!",user->nick);
 
57
                        user->WriteServ("NOTICE %s :*** G-Line cannot operate on nick!user@host masks",user->nick);
44
58
                        return CMD_FAILURE;
45
59
                }
46
60
 
47
61
                long duration = ServerInstance->Duration(parameters[1]);
48
 
                if (ServerInstance->XLines->add_gline(duration,user->nick,parameters[2],parameters[0]))
 
62
                if (ServerInstance->XLines->add_gline(duration,user->nick,parameters[2],target.c_str()))
49
63
                {
50
64
                        int to_apply = APPLY_GLINES;
51
65
 
52
 
                        FOREACH_MOD(I_OnAddGLine,OnAddGLine(duration, user, parameters[2], parameters[0]));
 
66
                        FOREACH_MOD(I_OnAddGLine,OnAddGLine(duration, user, parameters[2], target.c_str()));
53
67
 
54
68
                        if (!duration)
55
69
                        {
56
 
                                ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick,parameters[0]);
 
70
                                ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick,target.c_str());
57
71
                                to_apply |= APPLY_PERM_ONLY;
58
72
                        }
59
73
                        else
60
74
                        {
61
75
                                time_t c_requires_crap = duration + ServerInstance->Time();
62
 
                                ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s",user->nick,parameters[0],
 
76
                                ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s",user->nick,target.c_str(),
63
77
                                                ServerInstance->TimeString(c_requires_crap).c_str());
64
78
                        }
65
79
 
67
81
                }
68
82
                else
69
83
                {
70
 
                        user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick,parameters[0]);
 
84
                        user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick,target.c_str());
71
85
                }
72
86
 
73
87
        }
74
88
        else
75
89
        {
76
 
                if (ServerInstance->XLines->del_gline(parameters[0]))
 
90
                if (ServerInstance->XLines->del_gline(target.c_str()))
77
91
                {
78
 
                        FOREACH_MOD(I_OnDelGLine,OnDelGLine(user, parameters[0]));
79
 
                        ServerInstance->SNO->WriteToSnoMask('x',"%s Removed G-line on %s.",user->nick,parameters[0]);
 
92
                        FOREACH_MOD(I_OnDelGLine,OnDelGLine(user, target.c_str()));
 
93
                        ServerInstance->SNO->WriteToSnoMask('x',"%s Removed G-line on %s.",user->nick,target.c_str());
80
94
                }
81
95
                else
82
96
                {
83
 
                        user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick,parameters[0]);
 
97
                        user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick,target.c_str());
84
98
                }
85
99
        }
86
100