Go to the source code of this file.
Data Structures | |
struct | user_setting_t |
struct | user |
Defines | |
#define | USER_HASH_SIZE 50 |
#define | HOST_HASH_SIZE 50 |
#define | USER_DELETED 1 |
#define | USER_BOT 2 |
#define | USER_LINKED_BOT 4 |
#define | USER_LINKING_BOT 8 |
#define | BTN_USER_CHANGE_FLAGS "uflags" |
#define | BTN_USER_CHANGE_SETTINGS "uset" |
#define | BTN_USER_DELETE "udelete" |
Typedefs | |
typedef struct user | user_t |
Functions | |
int | user_init (void) |
int | user_shutdown (void) |
void | user_walk (hash_table_node_func callback, void *data) |
int | user_load (const char *fname) |
int | user_save (const char *fname) |
const char * | user_invalid_handle (const char *handle) |
user_t * | user_new (const char *handle) |
int | user_delete (user_t *u) |
user_t * | user_lookup_by_handle (const char *handle) |
user_t * | user_lookup_authed (const char *handle, const char *pass) |
user_t * | user_lookup_by_uid (int uid) |
user_t * | user_lookup_by_irchost_nocache (const char *irchost) |
user_t * | user_lookup_by_irchost (const char *irchost) |
int | user_add_ircmask (user_t *u, const char *ircmask) |
int | user_del_ircmask (user_t *u, const char *ircmask) |
int | user_get_setting (user_t *u, const char *chan, const char *setting, char **valueptr) |
int | user_set_setting (user_t *u, const char *chan, const char *setting, const char *newvalue) |
int | user_get_flags (user_t *u, const char *chan, flags_t *flags) |
int | user_set_flags (user_t *u, const char *chan, flags_t *flags) |
int | user_set_flags_str (user_t *u, const char *chan, const char *flags) |
int | user_check_flags (user_t *u, const char *chan, flags_t *flags) |
int | user_check_flags_str (user_t *u, const char *chan, const char *flags) |
int | user_check_partial_flags (user_t *u, const char *chan, flags_t *flags) |
int | user_check_partial_flags_str (user_t *u, const char *chan, const char *flags) |
int | user_has_pass (user_t *u) |
int | user_check_pass (user_t *u, const char *pass) |
int | user_set_pass (user_t *u, const char *pass) |
int | user_count () |
int | user_rand_pass (char *buf, int bufsize) |
int | user_change_handle (user_t *u, const char *newhandle) |
int | partyline_cmd_match_ircmask (void *p, const char *mask, long start, long limit) |
int | partyline_cmd_match_attr (void *p, const char *attr, const char *chan, long start, long limit) |
#define BTN_USER_CHANGE_FLAGS "uflags" |
#define BTN_USER_CHANGE_SETTINGS "uset" |
#define BTN_USER_DELETE "udelete" |
Definition at line 37 of file users.h.
Referenced by partymember_init(), partymember_shutdown(), and user_init().
#define HOST_HASH_SIZE 50 |
#define USER_BOT 2 |
Definition at line 30 of file users.h.
Referenced by append_setting(), botnet_find_min(), botnet_link(), botnet_link_prio(), check_flag_change(), cmd_chinfo(), expired_mask(), party_minus_bot(), partymember_new(), recving_login(), and resolve_dir().
#define USER_DELETED 1 |
Definition at line 29 of file users.h.
Referenced by Compare(), python_to_c_var(), and user_delete().
#define USER_HASH_SIZE 50 |
#define USER_LINKED_BOT 4 |
Definition at line 31 of file users.h.
Referenced by botnet_find_min(), botnet_link_prio(), botnet_link_success(), botnet_recursive_delete(), check_flag_change(), recving_login(), and user_delete().
#define USER_LINKING_BOT 8 |
Definition at line 32 of file users.h.
Referenced by botnet_delete(), botnet_find_min(), botnet_link(), botnet_link_failed(), botnet_link_prio(), botnet_link_success(), check_flag_change(), idx_on_delete(), idx_on_eof(), oldbotnet_on_delete(), oldbotnet_on_eof(), recving_login(), and user_delete().
int partyline_cmd_match_attr | ( | void * | p, | |
const char * | attr, | |||
const char * | chan, | |||
long | start, | |||
long | limit | |||
) |
Definition at line 969 of file users.c.
References flags_t::builtin, callback_match_attr(), cmd_match_data_t::channel, cmd_match_data_t::data, flag_merge_str(), hash_table_walk(), cmd_match_data_t::limit, cmd_match_data_t::musthave, cmd_match_data_t::mustnothave, NULL, cmd_match_data_t::pmember, cmd_match_data_t::start, and flags_t::udef.
Referenced by party_matchattr().
00970 { 00971 cmd_match_data_t mdata; 00972 int plsmns = 1, globchan = 0; 00973 char flagshack[] = "+ "; /* Hack to allow us to use flag_merge_str */ 00974 00975 mdata.start = start; 00976 mdata.limit = limit; 00977 /* FIXME - Once we sort #includes, 'p' should be partymember_t in function declaration */ 00978 mdata.pmember = (partymember_t *)p; 00979 mdata.data = NULL; 00980 mdata.channel = chan; 00981 mdata.musthave[0].builtin = mdata.musthave[0].udef = 0; 00982 mdata.mustnothave[0].builtin = mdata.mustnothave[0].udef = 0; 00983 mdata.musthave[1].builtin = mdata.musthave[1].udef = 0; 00984 mdata.mustnothave[1].builtin = mdata.mustnothave[1].udef = 0; 00985 00986 while (*attr) { 00987 switch (*attr) { 00988 case '+': 00989 plsmns = 1; 00990 break; 00991 case '-': 00992 plsmns = 0; 00993 break; 00994 case '&': 00995 case '|': 00996 if (globchan == 0) { /* Consider only the first & or | */ 00997 globchan++; 00998 mdata.data = attr; 00999 } 01000 break; 01001 default: 01002 flagshack[1] = *attr; 01003 flag_merge_str(plsmns ? &mdata.musthave[globchan] : 01004 &mdata.mustnothave[globchan], flagshack); 01005 break; 01006 } 01007 attr++; 01008 } 01009 01010 hash_table_walk(handle_ht, (hash_table_node_func)callback_match_attr, &mdata); 01011 01012 return 0; 01013 }
int partyline_cmd_match_ircmask | ( | void * | p, | |
const char * | mask, | |||
long | start, | |||
long | limit | |||
) |
Definition at line 953 of file users.c.
References callback_match_ircmask(), cmd_match_data_t::data, hash_table_walk(), cmd_match_data_t::limit, cmd_match_data_t::pmember, and cmd_match_data_t::start.
Referenced by party_matchwild().
00954 { 00955 cmd_match_data_t mdata; 00956 00957 mdata.start = start; 00958 mdata.limit = limit; 00959 /* FIXME - Once we sort #includes, 'p' should be partymember_t in function declaration */ 00960 mdata.pmember = (partymember_t *)p; 00961 mdata.data = mask; 00962 00963 hash_table_walk(handle_ht, (hash_table_node_func)callback_match_ircmask, &mdata); 00964 00965 return 0; 00966 }
int user_add_ircmask | ( | user_t * | u, | |
const char * | ircmask | |||
) |
Definition at line 529 of file users.c.
References cache_check_add(), hash_table_walk(), walker_info_t::ircmask, ircmask_list_add(), user::ircmasks, user::nircmasks, and walker_info_t::u.
Referenced by AddMask(), and party_plus_host().
00530 { 00531 walker_info_t info; 00532 00533 /* Add the ircmask to the user entry. */ 00534 u->ircmasks = (char **)realloc(u->ircmasks, sizeof(char *) * (u->nircmasks+1)); 00535 u->ircmasks[u->nircmasks] = strdup(ircmask); 00536 u->nircmasks++; 00537 00538 /* Put it in the big list. */ 00539 ircmask_list_add(&ircmask_list, ircmask, u); 00540 00541 /* Check irchost_cache_ht for changes in the users. */ 00542 info.u = u; 00543 info.ircmask = ircmask; 00544 hash_table_walk(irchost_cache_ht, cache_check_add, &info); 00545 return(0); 00546 }
int user_change_handle | ( | user_t * | u, | |
const char * | newhandle | |||
) |
Definition at line 824 of file users.c.
References user::handle, hash_table_insert(), hash_table_remove(), NULL, partymember_lookup(), partymember_set_nick(), and user_invalid_handle().
Referenced by party_chhandle().
00825 { 00826 char *old = u->handle; 00827 partymember_t *p = NULL; 00828 00829 if (user_invalid_handle(newhandle)) return 1; 00830 hash_table_remove(handle_ht, u->handle, NULL); 00831 u->handle = strdup(newhandle); 00832 hash_table_insert(handle_ht, u->handle, u); 00833 00834 while ((p = partymember_lookup(old, NULL, -1))) { 00835 partymember_set_nick(p, u->handle); 00836 } 00837 00838 free(u->handle); 00839 return(0); 00840 }
Definition at line 792 of file users.c.
References flag_match_subset(), and user_get_flags().
Referenced by user_check_flags_str().
00793 { 00794 flags_t f; 00795 00796 user_get_flags(u, chan, &f); 00797 return flag_match_subset(flags, &f); 00798 }
int user_check_flags_str | ( | user_t * | u, | |
const char * | chan, | |||
const char * | flags | |||
) |
Definition at line 800 of file users.c.
References flag_from_str(), and user_check_flags().
Referenced by party_chanmembermode().
00801 { 00802 flags_t f; 00803 00804 flag_from_str(&f, flags); 00805 return user_check_flags(u, chan, &f); 00806 }
Definition at line 808 of file users.c.
References flag_match_partial(), and user_get_flags().
Referenced by user_check_partial_flags_str().
00809 { 00810 flags_t f; 00811 00812 user_get_flags(u, chan, &f); 00813 return flag_match_partial(flags, &f); 00814 }
int user_check_partial_flags_str | ( | user_t * | u, | |
const char * | chan, | |||
const char * | flags | |||
) |
Definition at line 816 of file users.c.
References flag_from_str(), and user_check_partial_flags().
Referenced by party_chanmembermode().
00817 { 00818 flags_t f; 00819 00820 flag_from_str(&f, flags); 00821 return user_check_partial_flags(u, chan, &f); 00822 }
int user_check_pass | ( | user_t * | u, | |
const char * | pass | |||
) |
Definition at line 725 of file users.c.
References MD5_Final(), MD5_Hex(), MD5_Init(), MD5_Update(), NULL, and user_get_setting().
Referenced by CheckPass(), and user_lookup_authed().
00726 { 00727 char *hash, *salt, testhex[33]; 00728 unsigned char test[16]; 00729 MD5_CTX ctx; 00730 00731 user_get_setting(u, NULL, "pass", &hash); 00732 user_get_setting(u, NULL, "salt", &salt); 00733 if (!hash || !salt || !strcmp(hash, "none")) return(0); 00734 00735 MD5_Init(&ctx); 00736 MD5_Update(&ctx, salt, strlen(salt)); 00737 MD5_Update(&ctx, pass, strlen(pass)); 00738 MD5_Final(test, &ctx); 00739 MD5_Hex(test, testhex); 00740 return !strcasecmp(testhex, hash); 00741 }
int user_count | ( | ) |
Definition at line 769 of file users.c.
References nusers.
Referenced by create_userfile().
00770 { 00771 return(nusers); 00772 }
int user_del_ircmask | ( | user_t * | u, | |
const char * | ircmask | |||
) |
Definition at line 548 of file users.c.
References cache_user_del(), user::ircmasks, and user::nircmasks.
Referenced by DelMask(), and party_minus_host().
00549 { 00550 int i; 00551 00552 /* Find the ircmask in the user entry. */ 00553 for (i = 0; i < u->nircmasks; i++) { 00554 if (!strcasecmp(u->ircmasks[i], ircmask)) break; 00555 } 00556 if (i == u->nircmasks) return(-1); 00557 00558 /* Get rid of it. */ 00559 memmove(u->ircmasks+i, u->ircmasks+i+1, sizeof(char *) * (u->nircmasks - i - 1)); 00560 u->nircmasks--; 00561 00562 /* Delete matching entries of this user in the host cache. */ 00563 cache_user_del(u, ircmask); 00564 00565 return(0); 00566 }
int user_delete | ( | user_t * | u | ) |
Definition at line 370 of file users.c.
References bind_check(), cache_user_del(), user::flags, garbage_add(), user::handle, hash_table_remove(), ircmask_list_del(), user::ircmasks, user::nircmasks, NULL, nusers, user::uid, USER_DELETED, USER_LINKED_BOT, USER_LINKING_BOT, and user_really_delete().
Referenced by Delete(), party_minus_bot(), party_minus_obot(), party_minus_user(), terminal_shutdown(), and userlist_delete_walker().
00371 { 00372 int i; 00373 00374 if (!u || (u->flags & (USER_DELETED | USER_LINKING_BOT | USER_LINKED_BOT))) return(-1); 00375 00376 nusers--; 00377 hash_table_remove(handle_ht, u->handle, NULL); 00378 hash_table_remove(uid_ht, (void *)u->uid, NULL); 00379 cache_user_del(u, "*"); 00380 for (i = 0; i < u->nircmasks; i++) ircmask_list_del(&ircmask_list, u->ircmasks[i], u); 00381 u->flags |= USER_DELETED; 00382 bind_check(BT_udelete, NULL, NULL, u); 00383 garbage_add(user_really_delete, u, 0); 00384 return(0); 00385 }
Definition at line 583 of file users.c.
References flags_t::builtin, get_flags(), and flags_t::udef.
Referenced by attr_matches_user(), GetFlags(), MatchFlags(), MatchFlagsOr(), party_chattr(), party_whois(), script_getflags(), script_matchflags(), user_check_flags(), and user_check_partial_flags().
00584 { 00585 flags_t *uflags; 00586 00587 if (get_flags(u, chan, &uflags)) return(-1); 00588 00589 flags->builtin = uflags->builtin; 00590 flags->udef = uflags->udef; 00591 return(0); 00592 }
int user_get_setting | ( | user_t * | u, | |
const char * | chan, | |||
const char * | setting, | |||
char ** | valueptr | |||
) |
Definition at line 692 of file users.c.
References find_setting(), NULL, and xml_node_get_str().
Referenced by botnet_find_min(), botnet_link(), botnet_link_prio(), do_link(), Get(), got_join(), party_minus_bot(), party_minus_obot(), party_whois(), recving_login(), script_user_get(), user_check_pass(), user_has_pass(), and user_set_pass().
00693 { 00694 xml_node_t *node = find_setting(u, chan, setting, 0); 00695 00696 return xml_node_get_str(valueptr, node, NULL); 00697 }
int user_has_pass | ( | user_t * | u | ) |
Definition at line 715 of file users.c.
References NULL, and user_get_setting().
Referenced by HasPass().
00716 { 00717 char *hash, *salt; 00718 00719 user_get_setting(u, NULL, "pass", &hash); 00720 user_get_setting(u, NULL, "salt", &salt); 00721 if (hash && salt && strcmp(hash, "none")) return(1); 00722 return(0); 00723 }
int user_init | ( | void | ) |
Definition at line 128 of file users.c.
References bind_add_simple(), BIND_STACKABLE, bind_table_add(), BTN_USER_CHANGE_FLAGS, BTN_USER_CHANGE_SETTINGS, BTN_USER_DELETE, cache_rand_cleanup(), hash_table_create(), HASH_TABLE_FREE_KEY, HASH_TABLE_INTS, HASH_TABLE_STRINGS, HOST_HASH_SIZE, MATCH_MASK, MATCH_NONE, NULL, and USER_HASH_SIZE.
Referenced by eggdrop_init().
00129 { 00130 00131 /* Create hash tables. */ 00132 handle_ht = hash_table_create(NULL, NULL, USER_HASH_SIZE, HASH_TABLE_STRINGS); 00133 uid_ht = hash_table_create(NULL, NULL, USER_HASH_SIZE, HASH_TABLE_INTS); 00134 irchost_cache_ht = hash_table_create(NULL, NULL, HOST_HASH_SIZE, HASH_TABLE_STRINGS | HASH_TABLE_FREE_KEY); 00135 00136 /* And bind tables. */ 00137 BT_uflags = bind_table_add(BTN_USER_CHANGE_FLAGS, 4, "ssss", MATCH_MASK, BIND_STACKABLE); /* DDD */ 00138 BT_uset = bind_table_add(BTN_USER_CHANGE_SETTINGS, 4, "ssss", MATCH_MASK, BIND_STACKABLE); /* DDD */ 00139 BT_udelete = bind_table_add(BTN_USER_DELETE, 1, "U", MATCH_NONE, BIND_STACKABLE); /* DDD */ 00140 00141 /* Add binds. */ 00142 bind_add_simple("event", NULL, "hourly", cache_rand_cleanup); 00143 00144 return(0); 00145 }
const char* user_invalid_handle | ( | const char * | handle | ) |
Definition at line 300 of file users.c.
References _, BAD_HANDLE_CHARS, NULL, and user_lookup_by_handle().
Referenced by party_chhandle(), party_plus_user(), real_user_new(), and user_change_handle().
00301 { 00302 if (user_lookup_by_handle(handle)) return _("Handle already exists!"); 00303 for (; *handle; ++handle) { 00304 if (*handle < 32 || strchr(BAD_HANDLE_CHARS, *handle)) { 00305 return _("Handle contains invalid characters!"); 00306 } 00307 } 00308 return NULL; 00309 }
int user_load | ( | const char * | fname | ) |
Definition at line 170 of file users.c.
References _, append_setting(), g_uid, ircmask_list_add(), user::ircmasks, LOG_MISC, xml_node::next_sibling, user::nircmasks, NULL, nusers, putlog(), real_user_new(), uid_wraparound, xml_doc_delete(), xml_last_error(), xml_node_get_vars(), xml_node_lookup(), xml_node_str(), and xml_parse_file().
Referenced by core_init().
00171 { 00172 int uid; 00173 xml_node_t *root, *user_node, *ircmask_node, *setting_node, *extended_node; 00174 char *handle, *ircmask, *chan, *flag_str; 00175 user_t *u; 00176 00177 if (!(root = xml_parse_file(fname))) { 00178 putlog(LOG_MISC, "*", _("Failed to load userfile '%s': %s"), fname, xml_last_error()); 00179 return -1; 00180 } 00181 00182 xml_node_get_vars(root, "ii", "next_uid", &uid, "uid_wraparound", &uid_wraparound); 00183 g_uid = uid; 00184 00185 user_node = xml_node_lookup(root, 0, "user", 0, 0); 00186 for (; user_node; user_node = user_node->next_sibling) { 00187 /* The only required user fields are 'handle' and 'uid'. */ 00188 xml_node_get_vars(user_node, "sinn", "handle", &handle, "uid", &uid, "ircmask", &ircmask_node, "setting", &setting_node); 00189 00190 if (!handle || !uid) continue; 00191 u = real_user_new(handle, uid); 00192 00193 /* User already exists? */ 00194 if (!u) continue; 00195 00196 /* Irc masks. */ 00197 for (; ircmask_node; ircmask_node = ircmask_node->next_sibling) { 00198 ircmask = xml_node_str(ircmask_node, NULL); 00199 if (!ircmask) continue; 00200 u->ircmasks = realloc(u->ircmasks, sizeof(char *) * (u->nircmasks+1)); 00201 u->ircmasks[u->nircmasks] = strdup(ircmask); 00202 u->nircmasks++; 00203 ircmask_list_add(&ircmask_list, ircmask, u); 00204 } 00205 00206 /* Settings. */ 00207 /* They have to have at least 1 setting, the global one. */ 00208 if (!setting_node) append_setting(u, NULL, NULL, NULL); 00209 for (; setting_node; setting_node = setting_node->next_sibling) { 00210 xml_node_get_vars(setting_node, "ssn", "chan", &chan, "flags", &flag_str, "extended", &extended_node); 00211 append_setting(u, chan, flag_str, extended_node); 00212 } 00213 } 00214 xml_doc_delete(root); 00215 00216 if (nusers == 1) putlog(LOG_MISC, "*", _("Loaded 1 user")); 00217 else putlog(LOG_MISC, "*", _("Loaded %d users"), nusers); 00218 00219 return(0); 00220 }
user_t* user_lookup_authed | ( | const char * | handle, | |
const char * | pass | |||
) |
Definition at line 400 of file users.c.
References NULL, user_check_pass(), and user_lookup_by_handle().
Referenced by dcc_on_read(), irc_on_read(), and telnet_on_read().
00401 { 00402 user_t *u = user_lookup_by_handle(handle); 00403 if (!u) return(NULL); 00404 if (user_check_pass(u, pass)) return(u); 00405 return(NULL); 00406 }
user_t* user_lookup_by_handle | ( | const char * | handle | ) |
Definition at line 392 of file users.c.
References hash_table_find(), and NULL.
Referenced by botnet_link(), callback_match_attr(), callback_match_ircmask(), Egguser_New(), js_to_c_var(), party_chattr(), party_chhandle(), party_chpass(), party_minus_bot(), party_minus_host(), party_minus_obot(), party_minus_user(), party_plus_host(), party_whois(), perl_to_c_var(), recving_login(), script_validhandle(), tcl_to_c_var(), terminal_init(), user_invalid_handle(), and user_lookup_authed().
00393 { 00394 user_t *u = NULL; 00395 if (handle == NULL) return NULL; 00396 hash_table_find(handle_ht, handle, &u); 00397 return(u); 00398 }
user_t* user_lookup_by_irchost | ( | const char * | irchost | ) |
Definition at line 428 of file users.c.
References hash_table_find(), hash_table_insert(), and ircmask_list_find().
Referenced by party_channels(), process_results(), and server_parse_input().
00429 { 00430 user_t *u; 00431 00432 /* Check the irchost cache. */ 00433 if (!hash_table_find(irchost_cache_ht, irchost, &u)) return(u); 00434 00435 /* Look for a match in the ircmask list. */ 00436 ircmask_list_find(&ircmask_list, irchost, &u); 00437 00438 /* Cache it, even if it's null (to prevent future lookups). */ 00439 hash_table_insert(irchost_cache_ht, strdup(irchost), u); 00440 return(u); 00441 }
user_t* user_lookup_by_irchost_nocache | ( | const char * | irchost | ) |
Definition at line 416 of file users.c.
References hash_table_find(), and ircmask_list_find().
Referenced by goterror(), and script_user_find().
00417 { 00418 user_t *u; 00419 00420 /* Check the ircmask cache. */ 00421 if (!hash_table_find(irchost_cache_ht, irchost, &u)) return(u); 00422 00423 /* Look for a match in the ircmask list. We don't cache the result. */ 00424 ircmask_list_find(&ircmask_list, irchost, &u); 00425 return(u); 00426 }
user_t* user_lookup_by_uid | ( | int | uid | ) |
Definition at line 408 of file users.c.
References hash_table_find(), and NULL.
Referenced by Egguser_New(), script_uid_to_handle(), and script_validuid().
00409 { 00410 user_t *u = NULL; 00411 00412 hash_table_find(uid_ht, (void *)uid, &u); 00413 return(u); 00414 }
user_t* user_new | ( | const char * | handle | ) |
Definition at line 329 of file users.c.
References user_setting_t::extended, xml_node::name, user::nsettings, NULL, real_user_new(), user::settings, user_get_uid(), and xml_node_new().
Referenced by create_userfile(), party_plus_bot(), party_plus_obot(), party_plus_user(), script_adduser(), and terminal_init().
00330 { 00331 int uid; 00332 user_t *u; 00333 00334 uid = user_get_uid(); 00335 u = real_user_new(handle, uid); 00336 if (!u) return(NULL); 00337 00338 /* All users have the global setting by default. */ 00339 u->settings = calloc(1, sizeof(*u->settings)); 00340 u->nsettings = 1; 00341 u->settings[0].extended = xml_node_new(); 00342 u->settings[0].extended->name = strdup("extended"); 00343 00344 return(u); 00345 }
int user_rand_pass | ( | char * | buf, | |
int | bufsize | |||
) |
Definition at line 775 of file users.c.
Referenced by create_userfile(), and user_set_pass().
00776 { 00777 int i, c; 00778 00779 bufsize--; 00780 if (!buf || bufsize <= 0) return(-1); 00781 for (i = 0; i < bufsize; i++) { 00782 c = (random() + (random() >> 16) + (random() >> 24)) % 62; 00783 if (c < 10) c += 48; /* Digits. */ 00784 else if (c < 36) c += 55; /* Uppercase. */ 00785 else c += 61; /* Lowercase. */ 00786 buf[i] = c; 00787 } 00788 buf[i] = 0; 00789 return(0); 00790 }
int user_save | ( | const char * | fname | ) |
Definition at line 261 of file users.c.
References g_uid, hash_table_walk(), xml_node::name, NULL, save_walker(), uid_wraparound, unlink_walker(), XML_INDENT, xml_node_delete(), xml_node_new(), xml_node_set_int(), and xml_save_file().
Referenced by core_shutdown_or_restart(), create_userfile(), party_save(), and script_user_save().
00262 { 00263 xml_node_t *root; 00264 00265 root = xml_node_new(); 00266 root->name = strdup("users"); 00267 00268 xml_node_set_int(g_uid, root, "next_uid", 0, 0); 00269 xml_node_set_int(uid_wraparound, root, "uid_wraparound", 0, 0); 00270 hash_table_walk(uid_ht, save_walker, root); 00271 00272 xml_save_file((fname) ? fname : "users.xml", root, XML_INDENT); 00273 00274 hash_table_walk(uid_ht, unlink_walker, NULL); 00275 00276 xml_node_delete(root); 00277 return(0); 00278 }
Definition at line 615 of file users.c.
References append_setting(), flags_t::builtin, channel_sanity_check(), check_flag_change(), get_flags(), global_sanity_check(), NULL, and flags_t::udef.
00616 { 00617 flags_t *oldflags, newflags; 00618 00619 if (get_flags(u, chan, &oldflags)) { 00620 append_setting(u, chan, NULL, NULL); 00621 if (get_flags(u, chan, &oldflags)) return -1; 00622 } 00623 newflags.builtin = flags->builtin; 00624 newflags.udef = flags->udef; 00625 if (check_flag_change(u, chan, oldflags, &newflags)) return(0); 00626 oldflags->builtin = newflags.builtin; 00627 oldflags->udef = newflags.udef; 00628 if (chan) 00629 channel_sanity_check(oldflags); 00630 else 00631 global_sanity_check(oldflags); 00632 return(0); 00633 }
int user_set_flags_str | ( | user_t * | u, | |
const char * | chan, | |||
const char * | flags | |||
) |
Definition at line 635 of file users.c.
References append_setting(), flags_t::builtin, channel_sanity_check(), check_flag_change(), flag_merge_str(), get_flags(), global_sanity_check(), NULL, and flags_t::udef.
Referenced by create_userfile(), party_chattr(), party_plus_bot(), party_plus_obot(), script_setflags(), SetFlags(), and terminal_init().
00636 { 00637 flags_t *oldflags, newflags; 00638 00639 if (get_flags(u, chan, &oldflags)) { 00640 append_setting(u, chan, NULL, NULL); 00641 if (get_flags(u, chan, &oldflags)) return(-1); 00642 } 00643 newflags.builtin = oldflags->builtin; 00644 newflags.udef = oldflags->udef; 00645 flag_merge_str(&newflags, flags); 00646 if (check_flag_change(u, chan, oldflags, &newflags)) return(0); 00647 oldflags->builtin = newflags.builtin; 00648 oldflags->udef = newflags.udef; 00649 if (chan) 00650 channel_sanity_check(oldflags); 00651 else 00652 global_sanity_check(oldflags); 00653 return(0); 00654 }
int user_set_pass | ( | user_t * | u, | |
const char * | pass | |||
) |
Definition at line 743 of file users.c.
References MD5_Final(), MD5_Hex(), MD5_Init(), MD5_Update(), NULL, user_get_setting(), user_rand_pass(), and user_set_setting().
Referenced by create_userfile(), party_chpass(), party_newpass(), and SetPass().
00744 { 00745 char hashhex[33], *salt, new_salt[33]; 00746 unsigned char hash[16]; 00747 MD5_CTX ctx; 00748 00749 user_get_setting(u, NULL, "salt", &salt); 00750 if (!salt) { 00751 salt = new_salt; 00752 user_rand_pass(salt, sizeof(new_salt)); 00753 user_set_setting(u, NULL, "salt", salt); 00754 } 00755 00756 if (!pass || !*pass) { 00757 user_set_setting(u, NULL, "pass", "none"); 00758 return(1); 00759 } 00760 MD5_Init(&ctx); 00761 MD5_Update(&ctx, salt, strlen(salt)); 00762 MD5_Update(&ctx, pass, strlen(pass)); 00763 MD5_Final(hash, &ctx); 00764 MD5_Hex(hash, hashhex); 00765 user_set_setting(u, NULL, "pass", hashhex); 00766 return(0); 00767 }
int user_set_setting | ( | user_t * | u, | |
const char * | chan, | |||
const char * | setting, | |||
const char * | newvalue | |||
) |
Definition at line 699 of file users.c.
References bind_check(), BIND_RET_BREAK, egg_msprintf(), find_setting(), user::handle, NULL, and xml_node_set_str().
Referenced by got_handshake(), party_plus_bot(), party_plus_obot(), script_user_set(), Set(), and user_set_pass().
00700 { 00701 int r; 00702 char *change, buf[64]; 00703 xml_node_t *node; 00704 00705 change = egg_msprintf(buf, sizeof(buf), NULL, "%s %s", chan ? chan : "", setting); 00706 r = bind_check(BT_uset, NULL, change, u->handle, chan, setting, value); 00707 if (change != buf) free(change); 00708 00709 if (r & BIND_RET_BREAK) return(0); 00710 00711 node = find_setting(u, chan, setting, 1); 00712 return xml_node_set_str(value, node, NULL); 00713 }
int user_shutdown | ( | void | ) |
Definition at line 147 of file users.c.
References bind_table_del(), garbage_run(), hash_table_delete(), hash_table_walk(), NULL, and userlist_delete_walker().
Referenced by eggdrop_shutdown().
00148 { 00149 hash_table_walk(uid_ht, userlist_delete_walker, NULL); 00150 00151 /* flush any pending user delete events */ 00152 garbage_run(); 00153 00154 bind_table_del(BT_udelete); 00155 bind_table_del(BT_uset); 00156 bind_table_del(BT_uflags); 00157 00158 hash_table_delete(irchost_cache_ht); 00159 hash_table_delete(uid_ht); 00160 hash_table_delete(handle_ht); 00161 00162 return (0); 00163 }
void user_walk | ( | hash_table_node_func | callback, | |
void * | data | |||
) |
Definition at line 165 of file users.c.
References hash_table_walk().
Referenced by botnet_autolink().
00166 { 00167 hash_table_walk(uid_ht, callback, data); 00168 }