ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_svinfo.c
Revision: 7329
Committed: Thu Feb 18 21:07:50 2016 UTC (8 years, 1 month ago) by michael
Content type: text/x-csrc
File size: 4814 byte(s)
Log Message:
- Now that we got time_t to work nicely on openbsd with snprintf's conversion specifiers,
  we ran into a similiar issue on Raspbian/ARMv7's time_t which is of signed 32 bit and
  doesn't cope at all with %j. Instead of doing tricks, get rid of time_t everywhere and
  forever and use uintmax_t instead which has at least a 'standardized' conversion specifier
  associated with it.

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2016 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_svinfo.c
23 * \brief Includes required functions for processing the SVINFO command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "irc_string.h"
30 #include "ircd.h"
31 #include "send.h"
32 #include "conf.h"
33 #include "log.h"
34 #include "parse.h"
35 #include "modules.h"
36
37
38 /*! \brief SVINFO command handler
39 *
40 * \param source_p Pointer to allocated Client struct from which the message
41 * originally comes from. This can be a local or remote client.
42 * \param parc Integer holding the number of supplied arguments.
43 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
44 * pointers.
45 * \note Valid arguments for this command are:
46 * - parv[0] = command
47 * - parv[1] = TS_CURRENT for the server
48 * - parv[2] = TS_MIN for the server
49 * - parv[3] = unused
50 * - parv[4] = server's idea of UTC time
51 */
52 static int
53 ms_svinfo(struct Client *source_p, int parc, char *parv[])
54 {
55 intmax_t deltat = 0, theirtime = 0;
56
57 if (!IsServer(source_p) || !MyConnect(source_p))
58 return 0;
59
60 if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
61 {
62 /*
63 * A server with the wrong TS version connected; since we're
64 * TS_ONLY we can't fall back to the non-TS protocol so
65 * we drop the link -orabidoo
66 */
67 sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
68 "Link %s dropped, wrong TS protocol version (%s,%s)",
69 get_client_name(source_p, SHOW_IP), parv[1], parv[2]);
70 sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
71 "Link %s dropped, wrong TS protocol version (%s,%s)",
72 get_client_name(source_p, MASK_IP), parv[1], parv[2]);
73 ilog(LOG_TYPE_IRCD,
74 "Link %s dropped, wrong TS protocol version (%s,%s)",
75 get_client_name(source_p, SHOW_IP), parv[1], parv[2]);
76
77 exit_client(source_p, "Incompatible TS version");
78 return 0;
79 }
80
81 /*
82 * Since we're here, might as well set CurrentTime while we're at it
83 */
84 set_time();
85
86 theirtime = strtoimax(parv[4], NULL, 10);
87 deltat = imaxabs(theirtime - CurrentTime);
88
89 if (deltat > ConfigGeneral.ts_max_delta)
90 {
91 sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
92 "Link %s dropped, excessive TS delta (my TS=%ju, their TS=%ji, delta=%ji)",
93 get_client_name(source_p, SHOW_IP), CurrentTime, theirtime, deltat);
94 sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
95 "Link %s dropped, excessive TS delta (my TS=%ju, their TS=%ji, delta=%ji)",
96 get_client_name(source_p, MASK_IP), CurrentTime, theirtime, deltat);
97 ilog(LOG_TYPE_IRCD,
98 "Link %s dropped, excessive TS delta (my TS=%ju, their TS=%ji, delta=%ji)",
99 get_client_name(source_p, SHOW_IP), CurrentTime, theirtime, deltat);
100
101 exit_client(source_p, "Excessive TS delta");
102 return 0;
103 }
104
105 if (deltat > ConfigGeneral.ts_warn_delta)
106 {
107 sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
108 "Link %s notable TS delta (my TS=%ju, their TS=%ji, delta=%ji)",
109 get_client_name(source_p, SHOW_IP), CurrentTime, theirtime, deltat);
110 sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
111 "Link %s notable TS delta (my TS=%ju, their TS=%ji, delta=%ji)",
112 get_client_name(source_p, MASK_IP), CurrentTime, theirtime, deltat);
113 }
114
115 return 0;
116 }
117
118 static struct Message svinfo_msgtab =
119 {
120 .cmd = "SVINFO",
121 .args_min = 5,
122 .args_max = MAXPARA,
123 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
124 .handlers[CLIENT_HANDLER] = m_ignore,
125 .handlers[SERVER_HANDLER] = ms_svinfo,
126 .handlers[ENCAP_HANDLER] = m_ignore,
127 .handlers[OPER_HANDLER] = m_ignore
128 };
129
130 static void
131 module_init(void)
132 {
133 mod_add_cmd(&svinfo_msgtab);
134 }
135
136 static void
137 module_exit(void)
138 {
139 mod_del_cmd(&svinfo_msgtab);
140 }
141
142 struct module module_entry =
143 {
144 .version = "$Revision$",
145 .modinit = module_init,
146 .modexit = module_exit,
147 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision