/* * mr_pass - registration message handler */ int mr_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { char password[BUFSIZE]; int arg, len; assert(0 != cptr); assert(cptr == sptr); assert(!IsRegistered(sptr)); /* Some clients (brokenly) send "PASS x y" rather than "PASS :x y" * when the user enters "x y" as the password. Unsplit arguments to * work around this. */ for (arg = 1, len = 0; arg < parc; ++arg) { ircd_strncpy(password + len, parv[arg], sizeof(password) - len); len += strlen(parv[arg]); password[len++] = ' '; } if (len > 0) --len; password[len] = '\0'; if (EmptyString(password)) return need_more_params(cptr, "PASS"); ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN); return cli_auth(cptr) ? auth_set_password(cli_auth(cptr), password) : 0; }
/** Handle a PASS message from an unregistered connection. * * \a parv[1..\a parc-1] is a possibly broken-up password. Since some * clients do not prefix the password with ':', this functions stitches * the elements back together before using it. * * See @ref m_functions for discussion of the arguments. * @param[in] cptr Client that sent us the message. * @param[in] sptr Original source of message. * @param[in] parc Number of arguments. * @param[in] parv Argument vector. */ int mr_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { char password[BUFSIZE]; int arg, len; assert(0 != cptr); assert(cptr == sptr); assert(!IsRegistered(sptr)); /* Some clients (brokenly) send "PASS x y" rather than "PASS :x y" * when the user enters "x y" as the password. Unsplit arguments to * work around this. */ for (arg = 1, len = 0; arg < parc; ++arg) { ircd_strncpy(password + len, parv[arg], sizeof(password) - len); len += strlen(parv[arg]); password[len++] = ' '; } if (len > 0) --len; password[len] = '\0'; if (EmptyString(password)) return need_more_params(cptr, "PASS"); #if defined(DDB) if (IsUserPort(cptr)) { /* * PASS :server_pass[:ddb_pass] * PASS :ddb_pass */ char *ddb_pwd; ddb_pwd = strchr(password, ':'); if (ddb_pwd) *ddb_pwd++ = '\0'; else ddb_pwd = password; ircd_strncpy(cli_ddb_passwd(cptr), ddb_pwd, DDBPWDLEN); } #endif ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN); return cli_auth(cptr) ? auth_set_password(cli_auth(cptr), password) : 0; }
/* * mr_pass - registration message handler */ int mr_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { const char* password = parc > 1 ? parv[1] : 0; assert(0 != cptr); assert(cptr == sptr); assert(!IsRegistered(sptr)); if (EmptyString(password)) return need_more_params(cptr, "PASS"); /* TODO: For protocol negotiation */ #if 0 if (ircd_strcmp(password,"PROT")==0) { /* Do something here */ } #endif ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN); return 0; }
/** Handle a SERVER message from an unregistered connection. * * \a parv has the following elements: * \li \a parv[1] is the server name * \li \a parv[2] is the hop count to the server * \li \a parv[3] is the start timestamp for the server * \li \a parv[4] is the link timestamp * \li \a parv[5] is the protocol version (P10 or J10) * \li \a parv[6] is the numnick mask for the server * \li \a parv[7] is a string of flags like +hs to mark hubs and services * \li \a parv[\a parc - 1] is the server description * * See @ref m_functions for discussion of the arguments. * @param[in] cptr Client that sent us the message. * @param[in] sptr Original source of message. * @param[in] parc Number of arguments. * @param[in] parv Argument vector. */ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { char* host; struct ConfItem* aconf; struct Jupe* ajupe; unsigned int hop; int ret; unsigned short prot; time_t start_timestamp; time_t timestamp; time_t recv_time; time_t ghost; if (IsUserPort(cptr)) return exit_client_msg(cptr, cptr, &me, "Cannot connect a server to a user port"); if (parc < 8) { need_more_params(sptr, "SERVER"); return exit_client(cptr, cptr, &me, "Need more parameters"); } host = clean_servername(parv[1]); if (!host) { sendto_opmask(0, SNO_OLDSNO, "Bogus server name (%s) from %s", host, cli_name(cptr)); return exit_client_msg(cptr, cptr, &me, "Bogus server name (%s)", host); } if ((ajupe = jupe_find(host)) && JupeIsActive(ajupe)) return exit_client_msg(cptr, sptr, &me, "Juped: %s", JupeReason(ajupe)); /* check connection rules */ if (0 != conf_eval_crule(host, CRULE_ALL)) { ServerStats->is_ref++; sendto_opmask(0, SNO_OLDSNO, "Refused connection from %s.", cli_name(cptr)); return exit_client(cptr, cptr, &me, "Disallowed by connection rule"); } log_write(LS_NETWORK, L_NOTICE, LOG_NOSNOTICE, "SERVER: %s %s[%s]", host, cli_sockhost(cptr), cli_sock_ip(cptr)); /* * Detect protocol */ hop = atoi(parv[2]); start_timestamp = atoi(parv[3]); timestamp = atoi(parv[4]); prot = parse_protocol(parv[5]); if (!prot) return exit_client_msg(cptr, sptr, &me, "Bogus protocol (%s)", parv[5]); else if (prot < atoi(MINOR_PROTOCOL)) return exit_new_server(cptr, sptr, host, timestamp, "Incompatible protocol: %s", parv[5]); Debug((DEBUG_INFO, "Got SERVER %s with timestamp [%s] age %Tu (%Tu)", host, parv[4], start_timestamp, cli_serv(&me)->timestamp)); if (timestamp < OLDEST_TS || start_timestamp < OLDEST_TS) return exit_client_msg(cptr, sptr, &me, "Bogus timestamps (%s %s)", parv[3], parv[4]); /* If the server had a different name before, change it. */ if (!EmptyString(cli_name(cptr)) && (IsUnknown(cptr) || IsHandshake(cptr)) && 0 != ircd_strcmp(cli_name(cptr), host)) hChangeClient(cptr, host); ircd_strncpy(cli_name(cptr), host, HOSTLEN); ircd_strncpy(cli_info(cptr), parv[parc-1][0] ? parv[parc-1] : cli_name(&me), REALLEN); cli_hopcount(cptr) = hop; if (conf_check_server(cptr)) { ++ServerStats->is_ref; sendto_opmask(0, SNO_OLDSNO, "Received unauthorized connection from %s", cli_name(cptr)); log_write(LS_NETWORK, L_NOTICE, LOG_NOSNOTICE, "Received unauthorized " "connection from %C [%s]", cptr, ircd_ntoa(&cli_ip(cptr))); return exit_client(cptr, cptr, &me, "No Connect block"); } host = cli_name(cptr); update_load(); if (!(aconf = find_conf_byname(cli_confs(cptr), host, CONF_SERVER))) { ++ServerStats->is_ref; sendto_opmask(0, SNO_OLDSNO, "Access denied. No conf line for server %s", cli_name(cptr)); return exit_client_msg(cptr, cptr, &me, "Access denied. No conf line for server %s", cli_name(cptr)); } #if defined(USE_SSL) if (!verify_sslclifp(cptr, aconf)) { ++ServerStats->is_ref; sendto_opmask(0, SNO_OLDSNO, "Access denied (SSL fingerprint mismatch) %s", cli_name(cptr)); return exit_client_msg(cptr, cptr, &me, "No Access (SSL fingerprint mismatch) %s", cli_name(cptr)); } #endif if (*aconf->passwd && !!strcmp(aconf->passwd, cli_passwd(cptr))) { ++ServerStats->is_ref; sendto_opmask(0, SNO_OLDSNO, "Access denied (passwd mismatch) %s", cli_name(cptr)); return exit_client_msg(cptr, cptr, &me, "No Access (passwd mismatch) %s", cli_name(cptr)); } memset(cli_passwd(cptr), 0, sizeof(cli_passwd(cptr))); ret = check_loop_and_lh(cptr, sptr, &ghost, host, (parc > 7 ? parv[6] : NULL), timestamp, hop, 1); if (ret != 1) return ret; make_server(cptr); cli_serv(cptr)->timestamp = timestamp; cli_serv(cptr)->prot = prot; cli_serv(cptr)->ghost = ghost; memset(cli_privs(cptr), 255, sizeof(struct Privs)); ClrPriv(cptr, PRIV_SET); SetServerYXX(cptr, cptr, parv[6]); update_uworld_flags(cptr); if (*parv[7] == '+') set_server_flags(cptr, parv[7] + 1); recv_time = TStime(); check_start_timestamp(cptr, timestamp, start_timestamp, recv_time); ret = server_estab(cptr, aconf); if (feature_bool(FEAT_RELIABLE_CLOCK) && abs(cli_serv(cptr)->timestamp - recv_time) > 30) { sendto_opmask(0, SNO_OLDSNO, "Connected to a net with a " "timestamp-clock difference of %Td seconds! " "Used SETTIME to correct this.", timestamp - recv_time); sendcmdto_prio_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(), cli_name(&me)); } return ret; }
/* * mr_pass - registration message handler */ int mr_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { const char* password; char* loc = NULL; char* locargv[3] = {NULL, NULL, NULL}; assert(0 != cptr); assert(cptr == sptr); assert(!IsRegistered(sptr)); /* TODO: For protocol negotiation */ #if 0 if (ircd_strcmp(password,"PROT")==0) { /* Do something here */ } #endif if (parc == 2 && parv[1][0] == ':') { /* * All hail code duplication! * * Here we emulate parse_client, for the benefit of buggy clients. * If there's only one arg that starts with a literal ':', we * split it again. Thus, a valid line might be: * PASS ::X username :pass phrase * or * PASS ::I-line-pass X username :pass phrase * or * PASS ::I-Line-pass /X/username/passphrase * PASS ::/X/username/passphrase * PASS ::/username/passphrase * PASS ::/passphrase ??pull username from user/ident string?? * * after a while we'll remove the non '/' version * when noone is using it anymore, and clean * this function up significantly. */ char* s = &parv[1][1]; parc = 1; for (;;) { while (*s == ' ') *s++ = 0; if (*s == 0) break; if (*s == ':') { parv[parc++] = s + 1; break; } parv[parc++] = s; if (parc >= MAXPARA) break; while (*s != ' ' && *s) s++; } parv[parc] = NULL; } password = parc > 1 ? parv[1] : 0; if (!EmptyString(password)) ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN); if (feature_bool(FEAT_LOGIN_ON_CONNECT) && !cli_loc(cptr)) { /* Check for leading '/' to indicate new-fangled LOC syntax */ if (parc > 1 && parv[1][0] == '/') loc = parv[1]+1; else if (parc > 2 && parv[2][0] == '/') loc = parv[2]+1; if (loc && *loc) { /* Split loc up into locargv[0 through 2] */ int locargc = 0; locargv[locargc++] = loc; for ( ; *loc; loc++) { if (*loc == '/') { *loc = 0; locargv[locargc++] = loc + 1; if (locargc > 2) break; } } if (locargc == 2) { /* Missing service nick, fill in default and shift arguments up */ locargv[2] = locargv[1]; locargv[1] = locargv[0]; locargv[0] = (char *)feature_str(FEAT_LOC_DEFAULT_SERVICE); } } else if (parc > 3) { /* Old style for backward compatability: */ locargv[0] = parv[parc - 3]; locargv[1] = parv[parc - 2]; locargv[2] = parv[parc - 1]; } if (locargv[0] && *locargv[0] && locargv[1] && *locargv[1]) { cli_loc(cptr) = MyMalloc(sizeof(struct LOCInfo)); memset(cli_loc(cptr), 0, sizeof(struct LOCInfo)); cli_loc(cptr)->cookie = 0; ircd_strncpy(cli_loc(cptr)->service, locargv[0], NICKLEN); ircd_strncpy(cli_loc(cptr)->account, locargv[1], ACCOUNTLEN); if (locargv[2] && *locargv[2]) ircd_strncpy(cli_loc(cptr)->password, locargv[2], ACCPASSWDLEN); else ircd_strncpy(cli_loc(cptr)->password, "", ACCPASSWDLEN); } /* handle retries */ if ((cli_name(cptr))[0] && cli_cookie(cptr) == COOKIE_VERIFIED) return register_user(cptr, cptr, cli_name(cptr), cli_user(cptr)->username); } return 0; }
/** Attempt to send a sequence of bytes to the connection. * As a side effect, updates \a cptr's FLAG_BLOCKED setting * and sendB/sendK fields. * @param cptr Client that should receive data. * @param buf Message buffer to send to client. * @return Negative on connection-fatal error; otherwise * number of bytes sent. */ unsigned int deliver_it(struct Client *cptr, struct MsgQ *buf) { unsigned int bytes_written = 0; unsigned int bytes_count = 0; assert(0 != cptr); #if defined(USE_SSL) switch (client_sendv(cptr, buf, &bytes_count, &bytes_written)) { #else switch (os_sendv_nonb(cli_fd(cptr), buf, &bytes_count, &bytes_written)) { #endif case IO_SUCCESS: ClrFlag(cptr, FLAG_BLOCKED); cli_sendB(cptr) += bytes_written; cli_sendB(&me) += bytes_written; /* A partial write implies that future writes will block. */ if (bytes_written < bytes_count) SetFlag(cptr, FLAG_BLOCKED); break; case IO_BLOCKED: SetFlag(cptr, FLAG_BLOCKED); break; case IO_FAILURE: cli_error(cptr) = errno; SetFlag(cptr, FLAG_DEADSOCKET); break; } return bytes_written; } /** Complete non-blocking connect()-sequence. Check access and * terminate connection, if trouble detected. * @param cptr Client to which we have connected, with all ConfItem structs attached. * @return Zero on failure (caller should exit_client()), non-zero on success. */ static int completed_connection(struct Client* cptr) { struct ConfItem *aconf; time_t newts; struct Client *acptr; int i; #if defined(USE_SSL) char *sslfp; int r; #endif assert(0 != cptr); /* * get the socket status from the fd first to check if * connection actually succeeded */ if ((cli_error(cptr) = os_get_sockerr(cli_fd(cptr)))) { const char* msg = strerror(cli_error(cptr)); if (!msg) msg = "Unknown error"; sendto_opmask(0, SNO_OLDSNO, "Connection failed to %s: %s", cli_name(cptr), msg); return 0; } if (!(aconf = find_conf_byname(cli_confs(cptr), cli_name(cptr), CONF_SERVER))) { sendto_opmask(0, SNO_OLDSNO, "Lost Server Line for %s", cli_name(cptr)); return 0; } #if defined(USE_SSL) if (aconf->flags & CONF_SSL) { r = ssl_connect(&(cli_socket(cptr))); if (r == -1) { sendto_opmask(0, SNO_OLDSNO, "Connection failed to %s: SSL error", cli_name(cptr)); return 0; } else if (r == 0) return 1; sslfp = ssl_get_fingerprint(cli_socket(cptr).s_ssl); if (sslfp) ircd_strncpy(cli_sslclifp(cptr), sslfp, BUFSIZE+1); SetSSL(cptr); } #endif if (s_state(&(cli_socket(cptr))) == SS_CONNECTING) socket_state(&(cli_socket(cptr)), SS_CONNECTED); if (!EmptyString(aconf->passwd)) sendrawto_one(cptr, MSG_PASS " :%s", aconf->passwd); /* * Create a unique timestamp */ newts = TStime(); for (i = HighestFd; i > -1; --i) { if ((acptr = LocalClientArray[i]) && (IsServer(acptr) || IsHandshake(acptr))) { if (cli_serv(acptr)->timestamp >= newts) newts = cli_serv(acptr)->timestamp + 1; } } assert(0 != cli_serv(cptr)); cli_serv(cptr)->timestamp = newts; SetHandshake(cptr); /* * Make us timeout after twice the timeout for DNS look ups */ cli_lasttime(cptr) = CurrentTime; ClearPingSent(cptr); /* TODO: NEGOCIACION envia_config_req(cptr); */ sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s6 :%s", cli_name(&me), cli_serv(&me)->timestamp, newts, MAJOR_PROTOCOL, NumServCap(&me), feature_bool(FEAT_HUB) ? "h" : "", cli_info(&me)); #if defined(DDB) ddb_burst(cptr); #endif return (IsDead(cptr)) ? 0 : 1; } /** Close the physical connection. Side effects: MyConnect(cptr) * becomes false and cptr->from becomes NULL. * @param cptr Client to disconnect. */ void close_connection(struct Client *cptr) { struct ConfItem* aconf; if (IsServer(cptr)) { ServerStats->is_sv++; ServerStats->is_sbs += cli_sendB(cptr); ServerStats->is_sbr += cli_receiveB(cptr); ServerStats->is_sti += CurrentTime - cli_firsttime(cptr); /* * If the connection has been up for a long amount of time, schedule * a 'quick' reconnect, else reset the next-connect cycle. */ if ((aconf = find_conf_exact(cli_name(cptr), cptr, CONF_SERVER))) { /* * Reschedule a faster reconnect, if this was a automatically * connected configuration entry. (Note that if we have had * a rehash in between, the status has been changed to * CONF_ILLEGAL). But only do this if it was a "good" link. */ aconf->hold = CurrentTime; aconf->hold += ((aconf->hold - cli_since(cptr) > feature_int(FEAT_HANGONGOODLINK)) ? feature_int(FEAT_HANGONRETRYDELAY) : ConfConFreq(aconf)); /* if (nextconnect > aconf->hold) */ /* nextconnect = aconf->hold; */ } } else if (IsUser(cptr)) { ServerStats->is_cl++; ServerStats->is_cbs += cli_sendB(cptr); ServerStats->is_cbr += cli_receiveB(cptr); ServerStats->is_cti += CurrentTime - cli_firsttime(cptr); } else ServerStats->is_ni++; #if defined(USE_ZLIB) /* * Siempre es una conexion nuestra */ if (cli_connect(cptr)->zlib_negociation & ZLIB_IN) { inflateEnd(cli_connect(cptr)->comp_in); MyFree(cli_connect(cptr)->comp_in); } if (cli_connect(cptr)->zlib_negociation & ZLIB_OUT) { deflateEnd(cli_connect(cptr)->comp_out); MyFree(cli_connect(cptr)->comp_out); } #endif if (-1 < cli_fd(cptr)) { flush_connections(cptr); LocalClientArray[cli_fd(cptr)] = 0; close(cli_fd(cptr)); socket_del(&(cli_socket(cptr))); /* queue a socket delete */ cli_fd(cptr) = -1; cli_freeflag(cptr) &= ~FREEFLAG_SOCKET; } SetFlag(cptr, FLAG_DEADSOCKET); MsgQClear(&(cli_sendQ(cptr))); client_drop_sendq(cli_connect(cptr)); DBufClear(&(cli_recvQ(cptr))); memset(cli_passwd(cptr), 0, sizeof(cli_passwd(cptr))); set_snomask(cptr, 0, SNO_SET); det_confs_butmask(cptr, 0); if (cli_listener(cptr)) { release_listener(cli_listener(cptr)); cli_listener(cptr) = 0; } for ( ; HighestFd > 0; --HighestFd) { if (LocalClientArray[HighestFd]) break; } } /** Close all unregistered connections. * @param source Oper who requested the close. * @return Number of closed connections. */ int net_close_unregistered_connections(struct Client* source) { int i; struct Client* cptr; int count = 0; assert(0 != source); for (i = HighestFd; i > 0; --i) { if ((cptr = LocalClientArray[i]) && !IsRegistered(cptr)) { send_reply(source, RPL_CLOSING, get_client_name(source, HIDE_IP)); exit_client(source, cptr, &me, "Oper Closing"); ++count; } } return count; }
/** Close the physical connection. Side effects: MyConnect(cptr) * becomes false and cptr->from becomes NULL. * @param cptr Client to disconnect. */ void close_connection(struct Client *cptr) { struct ConfItem* aconf; if (IsServer(cptr)) { ServerStats->is_sv++; ServerStats->is_sbs += cli_sendB(cptr); ServerStats->is_sbr += cli_receiveB(cptr); ServerStats->is_sti += CurrentTime - cli_firsttime(cptr); /* * If the connection has been up for a long amount of time, schedule * a 'quick' reconnect, else reset the next-connect cycle. */ if ((aconf = find_conf_exact(cli_name(cptr), cptr, CONF_SERVER))) { /* * Reschedule a faster reconnect, if this was a automatically * connected configuration entry. (Note that if we have had * a rehash in between, the status has been changed to * CONF_ILLEGAL). But only do this if it was a "good" link. */ aconf->hold = CurrentTime; aconf->hold += ((aconf->hold - cli_since(cptr) > feature_int(FEAT_HANGONGOODLINK)) ? feature_int(FEAT_HANGONRETRYDELAY) : ConfConFreq(aconf)); /* if (nextconnect > aconf->hold) */ /* nextconnect = aconf->hold; */ } } else if (IsUser(cptr)) { ServerStats->is_cl++; ServerStats->is_cbs += cli_sendB(cptr); ServerStats->is_cbr += cli_receiveB(cptr); ServerStats->is_cti += CurrentTime - cli_firsttime(cptr); } else ServerStats->is_ni++; if (-1 < cli_fd(cptr)) { flush_connections(cptr); LocalClientArray[cli_fd(cptr)] = 0; close(cli_fd(cptr)); socket_del(&(cli_socket(cptr))); /* queue a socket delete */ cli_fd(cptr) = -1; } SetFlag(cptr, FLAG_DEADSOCKET); MsgQClear(&(cli_sendQ(cptr))); client_drop_sendq(cli_connect(cptr)); DBufClear(&(cli_recvQ(cptr))); memset(cli_passwd(cptr), 0, sizeof(cli_passwd(cptr))); set_snomask(cptr, 0, SNO_SET); det_confs_butmask(cptr, 0); if (cli_listener(cptr)) { release_listener(cli_listener(cptr)); cli_listener(cptr) = 0; } for ( ; HighestFd > 0; --HighestFd) { if (LocalClientArray[HighestFd]) break; } }
/* * mr_pass - registration message handler */ int mr_pass(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { char password[BUFSIZE]; int arg, len, i = 0, emptypass = 0; char* locargv[3] = {NULL, NULL, NULL}; char *tmp = NULL; assert(0 != cptr); assert(cptr == sptr); assert(!IsRegistered(sptr)); /* Some clients (brokenly) send "PASS x y" rather than "PASS :x y" * when the user enters "x y" as the password. Unsplit arguments to * work around this. */ for (arg = 1, len = 0; arg < parc; ++arg) { ircd_strncpy(password + len, parv[arg], sizeof(password) - len); len += strlen(parv[arg]); password[len++] = ' '; } if (len > 0) --len; password[len] = '\0'; if (feature_bool(FEAT_LOGIN_ON_CONNECT) && feature_bool(FEAT_EXTENDED_ACCOUNTS) && !cli_loc(cptr) && (password[0] != '\0')) { emptypass = 1; tmp = password; if (*tmp == '/') { *tmp = '\0'; tmp++; } else { tmp = strstr(tmp, " /"); if (tmp != NULL) { *tmp = '\0'; tmp += 2; } } while ((tmp != NULL) && *tmp && (i<3)) { locargv[i++] = tmp; tmp = strstr(tmp, "/"); if (tmp != NULL) { *tmp = '\0'; tmp++; } } if ((i>1) && !EmptyString(locargv[i-2]) && !EmptyString(locargv[i-1])) { cli_loc(cptr) = (struct LOCInfo *)MyMalloc(sizeof(struct LOCInfo)); memset(cli_loc(cptr), 0, sizeof(struct LOCInfo)); cli_loc(cptr)->cookie = 0; ircd_strncpy(cli_loc(cptr)->password, locargv[--i], ACCPASSWDLEN); ircd_strncpy(cli_loc(cptr)->account, locargv[--i], ACCOUNTLEN); if ((i>0) && !EmptyString(locargv[i-1])) ircd_strncpy(cli_loc(cptr)->service, locargv[--i], NICKLEN); else ircd_strncpy(cli_loc(cptr)->service, feature_str(FEAT_LOC_DEFAULT_SERVICE), NICKLEN); } } if ((password[0] == '\0') && !(cli_loc(cptr)) && !emptypass) return need_more_params(cptr, "PASS"); if (cli_loc(cptr) && (password[0] == '\0') && !emptypass) { if (cli_auth(cptr)) auth_end_loc(cli_auth(cptr)); MyFree(cli_loc(cptr)); } if (cli_passwd(cptr)[0] == '\0') ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN); return cli_auth(cptr) ? auth_set_password(cli_auth(cptr), password) : 0; }