| 1 |
michael |
7305 |
/* |
| 2 |
|
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
|
* |
| 4 |
michael |
8752 |
* Copyright (c) 1998-2019 ircd-hybrid development team |
| 5 |
michael |
7305 |
* |
| 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 conf_gecos.c |
| 23 |
|
|
* \brief Implements gecos {} block configuration management. |
| 24 |
michael |
7312 |
* \version $Id$ |
| 25 |
michael |
7305 |
*/ |
| 26 |
|
|
|
| 27 |
|
|
#include "stdinc.h" |
| 28 |
|
|
#include "list.h" |
| 29 |
|
|
#include "send.h" |
| 30 |
|
|
#include "client.h" |
| 31 |
|
|
#include "ircd.h" |
| 32 |
|
|
#include "memory.h" |
| 33 |
|
|
#include "conf.h" |
| 34 |
|
|
#include "conf_gecos.h" |
| 35 |
|
|
|
| 36 |
|
|
|
| 37 |
|
|
static dlink_list gecos_list; |
| 38 |
|
|
|
| 39 |
|
|
|
| 40 |
|
|
const dlink_list * |
| 41 |
|
|
gecos_get_list(void) |
| 42 |
|
|
{ |
| 43 |
|
|
return &gecos_list; |
| 44 |
|
|
} |
| 45 |
|
|
|
| 46 |
|
|
void |
| 47 |
|
|
gecos_clear(void) |
| 48 |
|
|
{ |
| 49 |
|
|
dlink_node *node, *node_next; |
| 50 |
|
|
|
| 51 |
|
|
DLINK_FOREACH_SAFE(node, node_next, gecos_list.head) |
| 52 |
|
|
{ |
| 53 |
|
|
struct GecosItem *gecos = node->data; |
| 54 |
|
|
|
| 55 |
michael |
8656 |
if (gecos->in_database == false) |
| 56 |
michael |
7305 |
gecos_delete(gecos); |
| 57 |
|
|
} |
| 58 |
|
|
} |
| 59 |
|
|
|
| 60 |
|
|
void |
| 61 |
|
|
gecos_delete(struct GecosItem *gecos) |
| 62 |
|
|
{ |
| 63 |
|
|
dlinkDelete(&gecos->node, &gecos_list); |
| 64 |
|
|
xfree(gecos->mask); |
| 65 |
|
|
xfree(gecos->reason); |
| 66 |
|
|
xfree(gecos); |
| 67 |
|
|
} |
| 68 |
|
|
|
| 69 |
|
|
struct GecosItem * |
| 70 |
|
|
gecos_make(void) |
| 71 |
|
|
{ |
| 72 |
|
|
struct GecosItem *gecos = xcalloc(sizeof(*gecos)); |
| 73 |
|
|
dlinkAdd(gecos, &gecos->node, &gecos_list); |
| 74 |
|
|
|
| 75 |
|
|
return gecos; |
| 76 |
|
|
} |
| 77 |
|
|
|
| 78 |
|
|
struct GecosItem * |
| 79 |
|
|
gecos_find(const char *name, int (*compare)(const char *, const char *)) |
| 80 |
|
|
{ |
| 81 |
|
|
dlink_node *node; |
| 82 |
|
|
|
| 83 |
|
|
DLINK_FOREACH(node, gecos_list.head) |
| 84 |
|
|
{ |
| 85 |
|
|
struct GecosItem *gecos = node->data; |
| 86 |
|
|
|
| 87 |
michael |
8603 |
if (compare(gecos->mask, name) == 0) |
| 88 |
michael |
7305 |
return gecos; |
| 89 |
|
|
} |
| 90 |
|
|
|
| 91 |
|
|
return NULL; |
| 92 |
|
|
} |
| 93 |
|
|
|
| 94 |
|
|
void |
| 95 |
|
|
gecos_expire(void) |
| 96 |
|
|
{ |
| 97 |
|
|
dlink_node *node, *node_next; |
| 98 |
|
|
|
| 99 |
|
|
DLINK_FOREACH_SAFE(node, node_next, gecos_list.head) |
| 100 |
|
|
{ |
| 101 |
|
|
struct GecosItem *gecos = node->data; |
| 102 |
|
|
|
| 103 |
michael |
8473 |
if (gecos->expire == 0 || gecos->expire > CurrentTime) |
| 104 |
michael |
7305 |
continue; |
| 105 |
|
|
|
| 106 |
|
|
if (ConfigGeneral.tkline_expire_notices) |
| 107 |
|
|
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary X-line for [%s] expired", |
| 108 |
|
|
gecos->mask); |
| 109 |
|
|
gecos_delete(gecos); |
| 110 |
|
|
} |
| 111 |
|
|
} |