[srvx-commits] CVS: services/src helpserv.c,1.49,1.50 nickserv.c,1.214,1.215 nickserv.h,1.39,1.40
Brought to you by:
entrope
|
From: Adrian D. <sai...@us...> - 2002-11-11 05:31:12
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv27109
Modified Files:
helpserv.c nickserv.c nickserv.h
Log Message:
Notify helpers if a user they are helping is given an allowauth or handle merge
Index: helpserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/helpserv.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -r1.49 -r1.50
*** helpserv.c 10 Nov 2002 02:01:27 -0000 1.49
--- helpserv.c 11 Nov 2002 05:31:07 -0000 1.50
***************
*** 215,218 ****
--- 215,221 ----
#define HSMSG_NOTIFY_HAND_AUTH "The user for request ID#%lu, $b%s$b, has authenticated to account $b%s$b."
#define HSMSG_NOTIFY_HAND_UNREG "The account for request ID#%lu, $b%s$b, has been unregistered by $b%s$b."
+ #define HSMSG_NOTIFY_HAND_MERGE "The account for request ID#%lu, $b%s$b, has been merged with $b%s$b by %s."
+ #define HSMSG_NOTIFY_ALLOWAUTH "The user for request ID#%lu, $b%s$b, has been permitted by %s to authenticate to account $b%s$b without hostmask checking."
+ #define HSMSG_NOTIFY_UNALLOWAUTH "The user for request ID#%lu, $b%s$b, has had their ability to authenticate without hostmask checking revoked by %s."
#define HSMSG_NOTIFY_REQ_DROP "Request ID#%lu has been $bdropped$b because %s."
***************
*** 3872,3888 ****
}
}
- } else if (!user) {
- /* This is probably a merge. Move everything over to the new user's handle. */
- /* FIXME: There should be a better way to check for this */
-
- if (req->user->handle_info) {
- req->handle = req->user->handle_info;
-
- if (!(req->parent_hand_list = dict_find(helpserv_reqs_byhand_dict, req->handle->handle, NULL))) {
- req->parent_hand_list = helpserv_reqlist_alloc();
- dict_insert(helpserv_reqs_byhand_dict, req->handle->handle, req->parent_hand_list);
- }
- helpserv_reqlist_append(req->parent_hand_list, req);
- }
}
}
--- 3875,3878 ----
***************
*** 3891,3894 ****
--- 3881,3934 ----
}
+ static void handle_nickserv_merge(struct userNode *user, struct handle_info *handle_to, struct handle_info *handle_from) {
+ struct helpserv_reqlist *reqlist_from, *reqlist_to;
+ unsigned int i;
+
+ reqlist_to = dict_find(helpserv_reqs_byhand_dict, handle_to->handle, NULL);
+
+ if ((reqlist_from = dict_find(helpserv_reqs_byhand_dict, handle_from->handle, NULL))) {
+ for (i=0; i < reqlist_from->used; i++) {
+ struct helpserv_request *req=reqlist_from->list[i];
+
+ if (!reqlist_to) {
+ reqlist_to = helpserv_reqlist_alloc();
+ dict_insert(helpserv_reqs_byhand_dict, handle_to->handle, reqlist_to);
+ }
+ req->parent_hand_list = reqlist_to;
+ helpserv_reqlist_append(reqlist_to, req);
+ }
+ dict_remove(helpserv_reqs_byhand_dict, handle_from->handle);
+ }
+
+ if (reqlist_to) {
+ for (i=0; i < reqlist_to->used; i++) {
+ struct helpserv_request *req=reqlist_to->list[i];
+
+ if (req->helper && (req->hs->notify >= NOTIFY_HANDLE)) {
+ helpserv_notify(req->helper, HSMSG_NOTIFY_HAND_MERGE, req->id, handle_to->handle, handle_from->handle, user->nick);
+ }
+ }
+ }
+ }
+
+ static void handle_nickserv_allowauth(struct userNode *user, struct userNode *target, struct handle_info *handle) {
+ struct helpserv_reqlist *reqlist;
+ unsigned int i;
+
+ if ((reqlist = dict_find(helpserv_reqs_bynick_dict, target->nick, NULL))) {
+ for (i=0; i < reqlist->used; i++) {
+ struct helpserv_request *req=reqlist->list[i];
+
+ if (req->helper && (req->hs->notify >= NOTIFY_HANDLE)) {
+ if (handle) {
+ helpserv_notify(req->helper, HSMSG_NOTIFY_ALLOWAUTH, req->id, target->nick, user->nick, handle->handle);
+ } else {
+ helpserv_notify(req->helper, HSMSG_NOTIFY_UNALLOWAUTH, req->id, target->nick, user->nick);
+ }
+ }
+ }
+ }
+ }
+
static time_t helpserv_next_stats(time_t after_when) {
struct tm *timeinfo=localtime(&after_when);
***************
*** 4058,4061 ****
--- 4098,4103 ----
reg_handle_rename_func(handle_nickserv_rename);
reg_unreg_func(handle_nickserv_unreg);
+ reg_allowauth_func(handle_nickserv_allowauth);
+ reg_handle_merge_func(handle_nickserv_merge);
reg_exit_func(helpserv_db_cleanup);
Index: nickserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.c,v
retrieving revision 1.214
retrieving revision 1.215
diff -C2 -r1.214 -r1.215
*** nickserv.c 6 Nov 2002 23:53:01 -0000 1.214
--- nickserv.c 11 Nov 2002 05:31:07 -0000 1.215
***************
*** 1420,1432 ****
}
static NICKSERV_FUNC(cmd_allowauth)
{
struct userNode *target;
struct handle_info *hi;
NICKSERV_MIN_PARMS(2);
if (!(target = GetUserH(argv[1]))) {
! nickserv_notice(user, MSG_NICK_UNKNOWN, argv[1]);
! return 0;
}
if (argc == 2) hi = NULL;
--- 1420,1451 ----
}
+ static allowauth_func_t *allowauth_func_list;
+ static unsigned int allowauth_func_size = 0, allowauth_func_used = 0;
+
+ void
+ reg_allowauth_func(allowauth_func_t func)
+ {
+ if (allowauth_func_used == allowauth_func_size) {
+ if (allowauth_func_size) {
+ allowauth_func_size <<= 1;
+ allowauth_func_list = realloc(allowauth_func_list, allowauth_func_size*sizeof(allowauth_func_t));
+ } else {
+ allowauth_func_size = 8;
+ allowauth_func_list = malloc(allowauth_func_size*sizeof(allowauth_func_t));
+ }
+ }
+ allowauth_func_list[allowauth_func_used++] = func;
+ }
+
static NICKSERV_FUNC(cmd_allowauth)
{
struct userNode *target;
struct handle_info *hi;
+ unsigned int n;
NICKSERV_MIN_PARMS(2);
if (!(target = GetUserH(argv[1]))) {
! nickserv_notice(user, MSG_NICK_UNKNOWN, argv[1]);
! return 0;
}
if (argc == 2) hi = NULL;
***************
*** 1436,1454 ****
}
if (hi) {
! if (hi->opserv_level > user->handle_info->opserv_level) {
! nickserv_notice(user, MSG_USER_OUTRANKED, hi->handle);
! return 0;
! }
! dict_insert(nickserv_allow_auth_dict, strdup(target->nick), hi);
! nickserv_notice(user, NSMSG_AUTH_ALLOWED, target->nick, hi->handle);
! nickserv_notice(target, NSMSG_AUTH_ALLOWED_MSG, hi->handle, hi->handle);
if (nickserv_conf.email_enabled) nickserv_notice(target, NSMSG_AUTH_ALLOWED_EMAIL);
} else {
! if (dict_remove(nickserv_allow_auth_dict, target->nick)) {
! nickserv_notice(user, NSMSG_AUTH_NORMAL_ONLY, target->nick);
! } else {
! nickserv_notice(user, NSMSG_AUTH_UNSPECIAL, target->nick);
! }
}
return 1;
}
--- 1455,1474 ----
}
if (hi) {
! if (hi->opserv_level > user->handle_info->opserv_level) {
! nickserv_notice(user, MSG_USER_OUTRANKED, hi->handle);
! return 0;
! }
! dict_insert(nickserv_allow_auth_dict, strdup(target->nick), hi);
! nickserv_notice(user, NSMSG_AUTH_ALLOWED, target->nick, hi->handle);
! nickserv_notice(target, NSMSG_AUTH_ALLOWED_MSG, hi->handle, hi->handle);
if (nickserv_conf.email_enabled) nickserv_notice(target, NSMSG_AUTH_ALLOWED_EMAIL);
} else {
! if (dict_remove(nickserv_allow_auth_dict, target->nick)) {
! nickserv_notice(user, NSMSG_AUTH_NORMAL_ONLY, target->nick);
! } else {
! nickserv_notice(user, NSMSG_AUTH_UNSPECIAL, target->nick);
! }
}
+ for (n=0; n<allowauth_func_used; n++) allowauth_func_list[n](user, target, hi);
return 1;
}
***************
*** 2408,2411 ****
--- 2428,2449 ----
}
+ static handle_merge_func_t *handle_merge_func_list;
+ static unsigned int handle_merge_func_size = 0, handle_merge_func_used = 0;
+
+ void
+ reg_handle_merge_func(handle_merge_func_t func)
+ {
+ if (handle_merge_func_used == handle_merge_func_size) {
+ if (handle_merge_func_size) {
+ handle_merge_func_size <<= 1;
+ handle_merge_func_list = realloc(handle_merge_func_list, handle_merge_func_size*sizeof(handle_merge_func_t));
+ } else {
+ handle_merge_func_size = 8;
+ handle_merge_func_list = malloc(handle_merge_func_size*sizeof(handle_merge_func_t));
+ }
+ }
+ handle_merge_func_list[handle_merge_func_used++] = func;
+ }
+
static NICKSERV_FUNC(cmd_merge)
{
***************
*** 2413,2417 ****
struct userNode *last_user;
struct chanList *cList, *cListNext;
! unsigned int ii, jj;
char buffer[MAXLEN];
--- 2451,2455 ----
struct userNode *last_user;
struct chanList *cList, *cListNext;
! unsigned int ii, jj, n;
char buffer[MAXLEN];
***************
*** 2425,2428 ****
--- 2463,2468 ----
}
+ for (n=0; n<handle_merge_func_used; n++) handle_merge_func_list[n](user, hi_to, hi_from);
+
/* Append "from" handle's nicks to "to" handle's nick list. */
if (hi_to->nicks) {
***************
*** 3224,3227 ****
--- 3264,3269 ----
if (unreg_func_list) free(unreg_func_list);
if (rf_list) free(rf_list);
+ if (allowauth_func_list) free(allowauth_func_list);
+ if (handle_merge_func_list) free(handle_merge_func_list);
if (nickserv_conf.valid_handle_regex_set) regfree(&nickserv_conf.valid_handle_regex);
if (nickserv_conf.valid_nick_regex_set) regfree(&nickserv_conf.valid_nick_regex);
Index: nickserv.h
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -r1.39 -r1.40
*** nickserv.h 21 Oct 2002 02:31:09 -0000 1.39
--- nickserv.h 11 Nov 2002 05:31:08 -0000 1.40
***************
*** 135,137 ****
--- 135,146 ----
void reg_unreg_func(unreg_func_t func);
+ /* Called just before a handle is merged */
+ typedef void (*handle_merge_func_t)(struct userNode *user, struct handle_info *handle_to, struct handle_info *handle_from);
+ void reg_handle_merge_func(handle_merge_func_t);
+
+ /* Called after an allowauth. handle is null if allowauth authorization was
+ * removed */
+ typedef void (*allowauth_func_t)(struct userNode *user, struct userNode *target, struct handle_info *handle);
+ void reg_allowauth_func(allowauth_func_t func);
+
#endif
|