diff options
author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-04 12:15:12 +0000 |
---|---|---|
committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-04 12:15:12 +0000 |
commit | aa250655e5837c52ebaab59f75d19e189174e1ad (patch) | |
tree | f969d1e6beb0c0b7fa45ba291a17efa91bfb16e0 /src | |
parent | b9edf1d40fa3247cab6ceea113ea07b35b20018c (diff) | |
download | zabbix-aa250655e5837c52ebaab59f75d19e189174e1ad.tar.gz zabbix-aa250655e5837c52ebaab59f75d19e189174e1ad.tar.xz zabbix-aa250655e5837c52ebaab59f75d19e189174e1ad.zip |
- [DEV-173] added support of notification escalations on server side
user permissions
git-svn-id: svn://svn.zabbix.com/trunk@5752 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r-- | src/zabbix_server/escalator/escalator.c | 83 |
1 files changed, 53 insertions, 30 deletions
diff --git a/src/zabbix_server/escalator/escalator.c b/src/zabbix_server/escalator/escalator.c index fe324fd8..fc9149d7 100644 --- a/src/zabbix_server/escalator/escalator.c +++ b/src/zabbix_server/escalator/escalator.c @@ -40,47 +40,70 @@ ZBX_USER_MSG void *next; }; -static void add_user_msg(DB_OPERATION *operation, ZBX_USER_MSG **user_msg, char *subject, char *message) +static int check_perm2system(zbx_uint64_t userid) { DB_RESULT result; DB_ROW row; + int res = SUCCEED; + + result = DBselect( "select count(g.usrgrpid) from usrgrp g, users_groups ug where ug.userid=" ZBX_FS_UI64 + " and g.usrgrpid = ug.usrgrpid and g.users_status=%d", + userid, + GROUP_STATUS_DISABLED); + + if (NULL != (row = DBfetch(result)) && SUCCEED != DBis_null(row[0]) && atoi(row[0]) > 0) + res = FAIL; + + DBfree_result(result); + + return res; +} + +static void add_user_msg(zbx_uint64_t userid, ZBX_USER_MSG **user_msg, char *subject, char *message) +{ ZBX_USER_MSG *p; - zbx_uint64_t userid; - switch (operation->object) { - case OPERATION_OBJECT_USER: - case OPERATION_OBJECT_GROUP: - /* user group disabled ? */ - result = DBselect("select ug.userid from users_groups ug,usrgrp g" - " WHERE ug.%s=" ZBX_FS_UI64 " AND g.usrgrpid=ug.usrgrpid AND g.users_status=%d", - operation->object == OPERATION_OBJECT_USER ? "userid" : "usrgrpid", - operation->objectid, - GROUP_STATUS_ACTIVE); + if (SUCCEED != check_perm2system(userid)) + return; + + p = *user_msg; + while (NULL != p) { + if (p->userid == userid && 0 == strcmp(p->subject, subject) + && 0 == strcmp(p->message, message)) + break; - while (NULL != (row = DBfetch(result))) { - userid = zbx_atoui64(row[0]); + p = p->next; + } - p = *user_msg; - while (NULL != p) { - if (p->userid == userid && 0 == strcmp(p->subject, subject) - && 0 == strcmp(p->message, message)) - break; + if (NULL == p) { + p = zbx_malloc(p, sizeof(ZBX_USER_MSG)); - p = p->next; - } + p->userid = userid; + p->subject = strdup(subject); + p->message = strdup(message); + p->next = *user_msg; - if (NULL == p) { - p = zbx_malloc(p, sizeof(ZBX_USER_MSG)); + *user_msg = p; + } +} - p->userid = userid; - p->subject = strdup(subject); - p->message = strdup(message); - p->next = *user_msg; +static void add_object_msg(DB_OPERATION *operation, ZBX_USER_MSG **user_msg, char *subject, char *message) +{ + DB_RESULT result; + DB_ROW row; - *user_msg = p; + switch (operation->object) { + case OPERATION_OBJECT_USER: + add_user_msg(operation->objectid, user_msg, subject, message); + break; + case OPERATION_OBJECT_GROUP: + result = DBselect("select ug.userid from users_groups ug,usrgrp g" + " WHERE ug.usrgrpid=" ZBX_FS_UI64 " AND g.usrgrpid=ug.usrgrpid AND g.users_status=%d", + operation->objectid, + GROUP_STATUS_ACTIVE); - } - } + while (NULL != (row = DBfetch(result))) + add_user_msg(zbx_atoui64(row[0]), user_msg, subject, message); DBfree_result(result); break; @@ -383,7 +406,7 @@ static void execute_operations(DB_ESCALATION *escalation, DB_EVENT *event, DB_AC longdata = action->longdata; } - add_user_msg(&operation, &user_msg, shortdata, longdata); + add_object_msg(&operation, &user_msg, shortdata, longdata); break; case OPERATION_TYPE_COMMAND: add_command_alert(escalation, event, action, operation.longdata); |