ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/conf.c (file contents):
Revision 8500 by michael, Thu Apr 5 13:00:49 2018 UTC vs.
Revision 8963 by michael, Sat May 11 21:06:49 2019 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2018 ircd-hybrid development team
4 > *  Copyright (c) 1997-2019 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
# Line 95 | Line 95 | conf_dns_callback(void *vptr, const stru
95   {
96    struct MaskItem *const conf = vptr;
97  
98 <  conf->dns_pending = 0;
98 >  conf->dns_pending = false;
99  
100    if (addr)
101 <    memcpy(&conf->addr, addr, sizeof(conf->addr));
101 >    memcpy(conf->addr, addr, sizeof(*conf->addr));
102    else
103 <    conf->dns_failed = 1;
103 >    conf->dns_failed = true;
104   }
105  
106   /* conf_dns_lookup()
# Line 112 | Line 112 | conf_dns_callback(void *vptr, const stru
112   static void
113   conf_dns_lookup(struct MaskItem *conf)
114   {
115 <  if (conf->dns_pending)
115 >  if (conf->dns_pending == true)
116      return;
117  
118 <  conf->dns_pending = 1;
118 >  conf->dns_pending = true;
119  
120    if (conf->aftype == AF_INET)
121      gethost_byname_type(conf_dns_callback, conf, conf->host, T_A);
# Line 152 | Line 152 | conf_make(enum maskitem_type type)
152    dlink_list *list = NULL;
153  
154    conf->type   = type;
155 <  conf->active = 1;
155 >  conf->active = true;
156    conf->aftype = AF_INET;
157  
158    if ((list = map_to_list(type)))
# Line 171 | Line 171 | conf_free(struct MaskItem *conf)
171  
172    xfree(conf->name);
173  
174 <  if (conf->dns_pending)
174 >  if (conf->dns_pending == true)
175      delete_resolver_queries(conf);
176    if (conf->passwd)
177      memset(conf->passwd, 0, strlen(conf->passwd));
# Line 187 | Line 187 | conf_free(struct MaskItem *conf)
187    xfree(conf->whois);
188    xfree(conf->user);
189    xfree(conf->host);
190 +  xfree(conf->addr);
191 +  xfree(conf->bind);
192    xfree(conf->cipher_list);
193  
194    DLINK_FOREACH_SAFE(node, node_next, conf->hub_list.head)
# Line 217 | Line 219 | static int
219   attach_iline(struct Client *client_p, struct MaskItem *conf)
220   {
221    const struct ClassItem *const class = conf->class;
222 <  int a_limit_reached = 0;
222 >  bool a_limit_reached = false;
223  
224 <  struct ip_entry *ipcache = ipcache_find_or_add_address(&client_p->ip);
224 >  struct ip_entry *ipcache = ipcache_record_find_or_add(&client_p->ip);
225    ++ipcache->count_local;
226    AddFlag(client_p, FLAGS_IPHASH);
227  
228    if (class->max_total && class->ref_count >= class->max_total)
229 <    a_limit_reached = 1;
229 >    a_limit_reached = true;
230    else if (class->max_perip_local && ipcache->count_local > class->max_perip_local)
231 <    a_limit_reached = 1;
231 >    a_limit_reached = true;
232    else if (class->max_perip_global &&
233             (ipcache->count_local + ipcache->count_remote) > class->max_perip_global)
234 <    a_limit_reached = 1;
234 >    a_limit_reached = true;
235  
236 <  if (a_limit_reached)
236 >  if (a_limit_reached == true)
237    {
238      if (!IsConfExemptLimits(conf))
239        return TOO_MANY;   /* Already at maximum allowed */
# Line 252 | Line 254 | attach_iline(struct Client *client_p, st
254   static int
255   verify_access(struct Client *client_p)
256   {
257 <  struct MaskItem *conf = NULL;
257 >  struct MaskItem *conf;
258  
259    if (HasFlag(client_p, FLAGS_GOTID))
260 <  {
259 <    conf = find_address_conf(client_p->host, client_p->username,
260 <                             &client_p->ip,
261 <                             client_p->ip.ss.ss_family,
260 >    conf = find_address_conf(client_p->host, client_p->username, &client_p->ip,
261                               client_p->connection->password);
263  }
262    else
263    {
264      char non_ident[USERLEN + 1] = "~";
265  
266      strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
267 <    conf = find_address_conf(client_p->host, non_ident,
270 <                             &client_p->ip,
271 <                             client_p->ip.ss.ss_family,
267 >    conf = find_address_conf(client_p->host, non_ident, &client_p->ip,
268                               client_p->connection->password);
269    }
270  
271 <  if (!conf)
271 >  if (conf == NULL)
272      return NOT_AUTHORIZED;
273  
274    assert(IsConfClient(conf) || IsConfKill(conf));
275  
276 <  if (IsConfClient(conf))
276 >  if (IsConfKill(conf))
277    {
278 <    if (IsConfRedir(conf))
279 <    {
280 <      sendto_one_numeric(client_p, &me, RPL_REDIR,
285 <                         conf->name ? conf->name : "",
286 <                         conf->port);
287 <      return NOT_AUTHORIZED;
288 <    }
278 >    sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
279 >    return BANNED_CLIENT;
280 >  }
281  
282 <    if (IsConfDoSpoofIp(conf))
283 <    {
284 <      if (IsConfSpoofNotice(conf))
285 <        sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
286 <                             client_p->name, client_p->host, conf->name);
282 >  if (IsConfRedir(conf))
283 >  {
284 >    sendto_one_numeric(client_p, &me, RPL_REDIR,
285 >                       conf->name ? conf->name : "",
286 >                       conf->port);
287 >    return NOT_AUTHORIZED;
288 >  }
289  
290 <      strlcpy(client_p->host, conf->name, sizeof(client_p->host));
291 <    }
290 >  if (IsConfDoSpoofIp(conf))
291 >  {
292 >    if (IsConfSpoofNotice(conf))
293 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
294 >                           client_p->name, client_p->host, conf->name);
295  
296 <    return attach_iline(client_p, conf);
296 >    strlcpy(client_p->host, conf->name, sizeof(client_p->host));
297    }
298  
299 <  sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
303 <  return BANNED_CLIENT;
299 >  return attach_iline(client_p, conf);
300   }
301  
302   /* check_client()
# Line 404 | Line 400 | conf_detach(struct Client *client_p, enu
400      free_dlink_node(node);
401  
402      if (conf->type == CONF_CLIENT)
403 <      remove_from_cidr_check(&client_p->ip, conf->class);
403 >      class_ip_limit_remove(conf->class, &client_p->ip);
404  
405 <    if (--conf->class->ref_count == 0 && conf->class->active == 0)
405 >    if (--conf->class->ref_count == 0 && conf->class->active == false)
406      {
407        class_free(conf->class);
408        conf->class = NULL;
409      }
410  
411 <    if (--conf->ref_count == 0 && conf->active == 0)
411 >    if (--conf->ref_count == 0 && conf->active == false)
412        conf_free(conf);
413    }
414   }
# Line 430 | Line 426 | conf_attach(struct Client *client_p, str
426      return 1;
427  
428    if (conf->type == CONF_CLIENT)
429 <    if (cidr_limit_reached(IsConfExemptLimits(conf),
434 <                           &client_p->ip, conf->class))
429 >    if (class_ip_limit_add(conf->class, &client_p->ip, IsConfExemptLimits(conf)) == true)
430        return TOO_MANY;    /* Already at maximum allowed */
431  
432    conf->class->ref_count++;
# Line 524 | Line 519 | operator_find(const struct Client *who,
519              break;
520            case HM_IPV4:
521              if (who->ip.ss.ss_family == AF_INET)
522 <              if (match_ipv4(&who->ip, &conf->addr, conf->bits))
522 >              if (match_ipv4(&who->ip, conf->addr, conf->bits))
523                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
524                    return conf;
525              break;
526            case HM_IPV6:
527              if (who->ip.ss.ss_family == AF_INET6)
528 <              if (match_ipv6(&who->ip, &conf->addr, conf->bits))
528 >              if (match_ipv6(&who->ip, conf->addr, conf->bits))
529                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
530                    return conf;
531              break;
# Line 563 | Line 558 | set_default_conf(void)
558  
559    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
560    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
566
567  memset(&ConfigServerInfo.ip, 0, sizeof(ConfigServerInfo.ip));
568  ConfigServerInfo.specific_ipv4_vhost = 0;
569  memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6));
570  ConfigServerInfo.specific_ipv6_vhost = 0;
571
561    ConfigServerInfo.default_max_clients = MAXCLIENTS_MAX;
562    ConfigServerInfo.max_nick_length = 9;
563    ConfigServerInfo.max_topic_length = 80;
564    ConfigServerInfo.hub = 0;
565  
566 <  log_del_all();
566 >  log_iterate(log_free);
567  
568    ConfigLog.use_logging = 1;
569  
# Line 612 | Line 601 | set_default_conf(void)
601    ConfigGeneral.kline_min_cidr = 16;
602    ConfigGeneral.kline_min_cidr6 = 48;
603    ConfigGeneral.invisible_on_connect = 1;
615  ConfigGeneral.tkline_expire_notices = 1;
616  ConfigGeneral.ignore_bogus_ts = 0;
604    ConfigGeneral.disable_auth = 0;
605    ConfigGeneral.kill_chase_time_limit = 90;
606    ConfigGeneral.default_floodcount = 8;
# Line 695 | Line 682 | read_conf(FILE *file)
682   * called as a result of the server receiving a HUP signal.
683   */
684   void
685 < conf_rehash(int sig)
685 > conf_rehash(bool sig)
686   {
687 <  if (sig)
687 >  if (sig == true)
688    {
689      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
690                           "Got signal SIGHUP, reloading configuration file(s)");
# Line 708 | Line 695 | conf_rehash(int sig)
695  
696    /* don't close listeners until we know we can go ahead with the rehash */
697  
698 <  read_conf_files(0);
698 >  read_conf_files(false);
699  
700    load_conf_modules();
701    check_conf_klines();
# Line 744 | Line 731 | lookup_confhost(struct MaskItem *conf)
731  
732    assert(res);
733  
734 <  memcpy(&conf->addr, res->ai_addr, res->ai_addrlen);
735 <  conf->addr.ss_len = res->ai_addrlen;
749 <  conf->addr.ss.ss_family = res->ai_family;
734 >  memcpy(conf->addr, res->ai_addr, res->ai_addrlen);
735 >  conf->addr->ss_len = res->ai_addrlen;
736  
737    freeaddrinfo(res);
738   }
# Line 759 | Line 745 | lookup_confhost(struct MaskItem *conf)
745   * side effects - none
746   */
747   int
748 < conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
748 > conf_connect_allowed(struct irc_ssaddr *addr)
749   {
750    struct ip_entry *ip_found = NULL;
751 <  const struct MaskItem *conf = find_dline_conf(addr, aftype);
751 >  const struct MaskItem *conf = find_dline_conf(addr);
752  
753    if (conf)
754    {
# Line 772 | Line 758 | conf_connect_allowed(struct irc_ssaddr *
758      return BANNED_CLIENT;
759    }
760  
761 <  ip_found = ipcache_find_or_add_address(addr);
761 >  ip_found = ipcache_record_find_or_add(addr);
762  
763 <  if ((CurrentTime - ip_found->last_attempt) < ConfigGeneral.throttle_time)
763 >  if ((event_base->time.sec_monotonic - ip_found->last_attempt) < ConfigGeneral.throttle_time)
764    {
765      if (ip_found->connection_count >= ConfigGeneral.throttle_count)
766        return TOO_FAST;
# Line 784 | Line 770 | conf_connect_allowed(struct irc_ssaddr *
770    else
771      ip_found->connection_count = 1;
772  
773 <  ip_found->last_attempt = CurrentTime;
773 >  ip_found->last_attempt = event_base->time.sec_monotonic;
774    return 0;
775   }
776  
# Line 931 | Line 917 | clear_out_old_conf(void)
917      {
918        struct MaskItem *conf = node->data;
919  
920 <      conf->active = 0;
920 >      conf->active = false;
921        dlinkDelete(&conf->node, *iterator);
922  
923        if (!conf->ref_count)
# Line 1002 | Line 988 | clear_out_old_conf(void)
988   }
989  
990   static void
991 < conf_handle_tls(int cold)
991 > conf_handle_tls(bool cold)
992   {
993 <  if (!tls_new_cred())
993 >  if (tls_new_cred() == false)
994    {
995 <    if (cold)
995 >    if (cold == true)
996      {
997        ilog(LOG_TYPE_IRCD, "Error while initializing TLS");
998        exit(EXIT_FAILURE);
# Line 1027 | Line 1013 | conf_handle_tls(int cold)
1013   * side effects - read all conf files needed, ircd.conf kline.conf etc.
1014   */
1015   void
1016 < read_conf_files(int cold)
1016 > read_conf_files(bool cold)
1017   {
1018    const char *filename = NULL;
1019    char chanmodes[IRCD_BUFSIZE] = "";
# Line 1046 | Line 1032 | read_conf_files(int cold)
1032  
1033    if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL)
1034    {
1035 <    if (cold)
1035 >    if (cold == true)
1036      {
1037        ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1038             filename, strerror(errno));
# Line 1061 | Line 1047 | read_conf_files(int cold)
1047      }
1048    }
1049  
1050 <  if (!cold)
1050 >  if (cold == false)
1051      clear_out_old_conf();
1052  
1053    read_conf(conf_parser_ctx.conf_file);
1054    fclose(conf_parser_ctx.conf_file);
1055  
1056 <  log_reopen_all();
1056 >  log_iterate(log_reopen);
1057    conf_handle_tls(cold);
1058  
1059    isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
# Line 1096 | Line 1082 | read_conf_files(int cold)
1082   void
1083   conf_add_class_to_conf(struct MaskItem *conf, const char *name)
1084   {
1085 <  if (EmptyString(name) || (conf->class = class_find(name, 1)) == NULL)
1085 >  if (EmptyString(name) || (conf->class = class_find(name, true)) == NULL)
1086    {
1087      conf->class = class_default;
1088  
# Line 1180 | Line 1166 | valid_tkline(const char *data, const int
1166     * If the incoming time is in seconds convert it to minutes for the purpose
1167     * of this calculation
1168     */
1169 <  if (!minutes)
1169 >  if (minutes == 0)
1170      result = result / 60;
1171  
1172    if (result > MAX_TDKLINE_TIME)
# Line 1197 | Line 1183 | valid_tkline(const char *data, const int
1183   * outputs      - 1 if valid, else 0
1184   * side effects - none
1185   */
1186 < int
1186 > bool
1187   valid_wild_card_simple(const char *data)
1188   {
1189    const unsigned char *p = (const unsigned char *)data;
# Line 1210 | Line 1196 | valid_wild_card_simple(const char *data)
1196      {
1197        ++p;
1198        if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1199 <        return 1;
1199 >        return true;
1200      }
1201      else if (!IsMWildChar(tmpch))
1202      {
1203        if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1204 <        return 1;
1204 >        return true;
1205      }
1206      else
1207        ++wild;
1208    }
1209  
1210 <  return !wild;
1210 >  return wild == 0;
1211   }
1212  
1213   /* valid_wild_card()
# Line 1232 | Line 1218 | valid_wild_card_simple(const char *data)
1218   * output       - 0 if not valid, 1 if valid
1219   * side effects - NOTICE is given to source_p if warn is 1
1220   */
1221 < int
1221 > bool
1222   valid_wild_card(int count, ...)
1223   {
1224    unsigned char tmpch = '\0';
# Line 1270 | Line 1256 | valid_wild_card(int count, ...)
1256          if (++nonwild >= ConfigGeneral.min_nonwildcard)
1257          {
1258            va_end(args);
1259 <          return 1;
1259 >          return true;
1260          }
1261        }
1262      }
1263    }
1264  
1265    va_end(args);
1266 <  return 0;
1281 < }
1282 <
1283 < /* find_user_host()
1284 < *
1285 < * inputs       - pointer to client placing kline
1286 < *              - pointer to user_host_or_nick
1287 < *              - pointer to user buffer
1288 < *              - pointer to host buffer
1289 < * output       - 0 if not ok to kline, 1 to kline i.e. if valid user host
1290 < * side effects -
1291 < */
1292 < static int
1293 < find_user_host(struct Client *source_p, char *user_host_or_nick,
1294 <               char *luser, char *lhost)
1295 < {
1296 <  struct Client *target_p = NULL;
1297 <  char *hostp = NULL;
1298 <
1299 <  if (lhost == NULL)
1300 <  {
1301 <    strlcpy(luser, user_host_or_nick, USERLEN*4 + 1);
1302 <    return 1;
1303 <  }
1304 <
1305 <  if ((hostp = strchr(user_host_or_nick, '@')) || *user_host_or_nick == '*')
1306 <  {
1307 <    /* Explicit user@host mask given */
1308 <    if (hostp)                            /* I'm a little user@host */
1309 <    {
1310 <      *(hostp++) = '\0';                       /* short and squat */
1311 <
1312 <      if (*user_host_or_nick)
1313 <        strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */
1314 <      else
1315 <        strcpy(luser, "*");
1316 <
1317 <      if (*hostp)
1318 <        strlcpy(lhost, hostp, HOSTLEN + 1);    /* here is my host */
1319 <      else
1320 <        strcpy(lhost, "*");
1321 <    }
1322 <    else
1323 <    {
1324 <      luser[0] = '*';             /* no @ found, assume its *@somehost */
1325 <      luser[1] = '\0';
1326 <      strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1);
1327 <    }
1328 <
1329 <    return 1;
1330 <  }
1331 <  else
1332 <  {
1333 <    /* Try to find user@host mask from nick */
1334 <    /* Okay to use source_p as the first param, because source_p == client_p */
1335 <    if ((target_p =
1336 <        find_chasing(source_p, user_host_or_nick)) == NULL)
1337 <      return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1338 <
1339 <    if (HasFlag(target_p, FLAGS_EXEMPTKLINE))
1340 <    {
1341 <      if (IsClient(source_p))
1342 <        sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
1343 <      return 0;
1344 <    }
1345 <
1346 <    /*
1347 <     * Turn the "user" bit into "*user", blow away '~'
1348 <     * if found in original user name (non-idented)
1349 <     */
1350 <    strlcpy(luser, target_p->username, USERLEN*4 + 1);
1351 <
1352 <    if (target_p->username[0] == '~')
1353 <      luser[0] = '*';
1354 <
1355 <    strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1356 <    return 1;
1357 <  }
1358 <
1359 <  return 0;
1266 >  return false;
1267   }
1268  
1269   /* XXX should this go into a separate file ? -Dianora */
# Line 1389 | Line 1296 | find_user_host(struct Client *source_p,
1296   *
1297   * - Dianora
1298   */
1299 < int
1300 < parse_aline(const char *cmd, struct Client *source_p,
1394 <            int parc, char **parv,
1395 <            char **up_p, char **h_p, uintmax_t *tkline_time,
1396 <            char **target_server, char **reason)
1299 > bool
1300 > parse_aline(const char *cmd, struct Client *source_p, int parc, char **parv, struct aline_ctx *aline)
1301   {
1398  uintmax_t found_tkline_time=0;
1302    static char default_reason[] = CONF_NOREASON;
1303 <  static char user[USERLEN*4+1];
1304 <  static char host[HOSTLEN*4+1];
1303 >  static char user[USERLEN * 2 + 1];
1304 >  static char host[HOSTLEN * 2 + 1];
1305  
1306 <  parv++;
1307 <  parc--;
1306 >  ++parv;
1307 >  --parc;
1308  
1309 <  found_tkline_time = valid_tkline(*parv, TK_MINUTES);
1407 <
1408 <  if (found_tkline_time)
1309 >  if (aline->add == true && (aline->duration = valid_tkline(*parv, TK_MINUTES)))
1310    {
1311 <    parv++;
1312 <    parc--;
1412 <
1413 <    if (tkline_time)
1414 <      *tkline_time = found_tkline_time;
1415 <    else
1416 <    {
1417 <      sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd);
1418 <      return 0;
1419 <    }
1311 >    ++parv;
1312 >    --parc;
1313    }
1314  
1315    if (parc == 0)
1316    {
1317      sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1318 <    return 0;
1318 >    return false;
1319    }
1320  
1321 <  if (h_p == NULL)
1322 <    *up_p = *parv;
1321 >  if (aline->simple_mask == true)
1322 >  {
1323 >    aline->mask = *parv;
1324 >    aline->user = NULL;
1325 >    aline->host = NULL;
1326 >  }
1327    else
1328    {
1329 <    if (find_user_host(source_p, *parv, user, host) == 0)
1330 <      return 0;
1329 >    struct split_nuh_item nuh;
1330 >
1331 >    nuh.nuhmask  = *parv;
1332 >    nuh.nickptr  = NULL;
1333 >    nuh.userptr  = user;
1334 >    nuh.hostptr  = host;
1335 >
1336 >    nuh.nicksize = 0;
1337 >    nuh.usersize = sizeof(user);
1338 >    nuh.hostsize = sizeof(host);
1339  
1340 <    *up_p = user;
1341 <    *h_p = host;
1340 >    split_nuh(&nuh);
1341 >
1342 >    aline->mask = NULL;
1343 >    aline->user = user;
1344 >    aline->host = host;
1345    }
1346  
1347 <  parc--;
1348 <  parv++;
1347 >  ++parv;
1348 >  --parc;
1349  
1350    if (parc)
1351    {
1352      if (irccmp(*parv, "ON") == 0)
1353      {
1354 <      parc--;
1355 <      parv++;
1354 >      ++parv;
1355 >      --parc;
1356  
1357        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1358        {
1359          sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
1360 <        return 0;
1360 >        return false;
1361        }
1362  
1363        if (parc == 0 || EmptyString(*parv))
1364        {
1365          sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1366 <        return 0;
1366 >        return false;
1367        }
1368  
1369 <      *target_server = *parv;
1370 <      parc--;
1371 <      parv++;
1369 >      aline->server = *parv;
1370 >      ++parv;
1371 >      --parc;
1372      }
1373      else
1374 <    {
1467 <      /* Make sure target_server *is* NULL if no ON server found
1468 <       * caller probably NULL'd it first, but no harm to do it again -db
1469 <       */
1470 <      if (target_server)
1471 <        *target_server = NULL;
1472 <    }
1374 >      aline->server = NULL;
1375    }
1376  
1377 <  if (reason)
1377 >  if (aline->add == true)
1378    {
1379 <    if (parc && !EmptyString(*parv))
1380 <      *reason = *parv;
1379 >    if (parc == 0 || EmptyString(*parv))
1380 >      aline->reason = default_reason;
1381      else
1382 <      *reason = default_reason;
1382 >      aline->reason = *parv;
1383    }
1384  
1385 <  return 1;
1385 >  return true;
1386   }
1387  
1388   /* match_conf_password()
# Line 1490 | Line 1392 | parse_aline(const char *cmd, struct Clie
1392   * output       - 1 or 0 if match
1393   * side effects - none
1394   */
1395 < int
1395 > bool
1396   match_conf_password(const char *password, const struct MaskItem *conf)
1397   {
1398    const char *encr = NULL;
1399  
1400    if (EmptyString(password) || EmptyString(conf->passwd))
1401 <    return 0;
1401 >    return false;
1402  
1403    if (conf->flags & CONF_FLAGS_ENCRYPTED)
1404      encr = crypt(password, conf->passwd);
1405    else
1406      encr = password;
1407  
1408 <  return encr && !strcmp(encr, conf->passwd);
1408 >  return encr && strcmp(encr, conf->passwd) == 0;
1409   }
1410  
1411   /*
# Line 1588 | Line 1490 | split_nuh(struct split_nuh_item *const i
1490      else
1491      {
1492        /* No @ found */
1493 <      if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
1493 >      if (iptr->nickptr == NULL || strpbrk(iptr->nuhmask, ".:"))
1494          strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
1495        else
1496          strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines