📄 admin.c
字号:
{
error = 1;
log_debug(NAME, "[%s] Skipping - Insufficent level to request %s list", FZONE, affiliation);
insert_item_error(jp->x, "403", "Forbidden list retrieval");
continue;
}
}
else if(j_strcmp(xmlns, NS_MUC_ADMIN) != 0)
{
error = 1;
log_debug(NAME, "[%s] Skipping - Badly formed namespace (%s)", FZONE, xmlnode2str(current));
insert_item_error(current, "400", "Invalid Namespace");
continue;
}
}
else
{
error = 1;
log_debug(NAME, "[%s] Skipping - Badly formed request (%s)", FZONE, xmlnode2str(current));
insert_item_error(current, "400", "Badly formed request - extra attributes found");
continue;
}
}
else if(jpacket_subtype(jp) == JPACKET__SET)
{
if(role == NULL && affiliation == NULL)
{
error = 1;
log_debug(NAME, "[%s] Skipping - no role or affiliation given (%s)", FZONE, xmlnode2str(current));
insert_item_error(current, "400", "Badly formed request - no role or affiliation attribute");
continue;
}
if(jabberid == NULL)
{
user = con_room_usernick(room, nick);
if(user)
{
jabberid = jid_full(jid_fix(user->realid));
}
else
{
error = 1;
log_debug(NAME, "[%s] Skipping - can't find jid (%s)", FZONE, xmlnode2str(current));
insert_item_error(current, "400", "Nick not present in room");
continue;
}
}
target = jid_new(jp->p, jabberid);
if(target->user == NULL && role != NULL)
{
error = 1;
log_debug(NAME, "[%s] Skipping - Bad jid (%s)", FZONE, jabberid);
insert_item_error(current, "400", "Badly formed JID");
continue;
}
if(role != NULL && affiliation != NULL)
{
/* Check requesting user has minimum affiliation level */
error = 1;
log_debug(NAME, "[%s] Skipping - Attempting to change role and affiliation (%s)", FZONE, jabberid);
insert_item_error(current, "400", "Bad request - trying to change role and affiliation");
continue;
}
/* Affiliation changes */
if(affiliation != NULL)
{
if(!is_admin(room, from))
{
/* Check requesting user has minimum affiliation level */
error = 1;
log_debug(NAME, "[%s] Skipping - affiliation role requested by non-admin(%s)", FZONE, jabberid);
insert_item_error(current, "403", "Forbidden - No affiliation requested by non-admin");
continue;
}
else if(!is_owner(room, from) && is_admin(room, target))
{
/* Stop admins altering other admins */
error = 1;
log_debug(NAME, "[%s] Skipping - affiliation role requested by non-admin(%s)", FZONE, jabberid);
insert_item_error(current, "403", "Forbidden - No affiliation request between admins");
continue;
}
else if(j_strcmp(affiliation, "owner") == 0)
{
if(!is_owner(room, from))
{
error = 1;
log_debug(NAME, "[%s] Skipping - affiliation role requested by non-owner(%s)", FZONE, jabberid);
insert_item_error(current, "403", "Forbidden - Owner requested");
continue;
}
}
else if(j_strcmp(affiliation, "admin") == 0)
{
if(!is_owner(room, from))
{
error = 1;
log_debug(NAME, "[%s] Skipping - affiliation role requested by non-owner(%s)", FZONE, jabberid);
insert_item_error(current, "403", "Forbidden - Admin requested");
continue;
}
}
else if(j_strcmp(affiliation, "outcast") == 0)
{
if(is_admin(room, target))
{
error = 1;
log_debug(NAME, "[%s] Skipping - affiliation role requested by non-owner(%s)", FZONE, jabberid);
insert_item_error(current, "403", "Forbidden - Admin requested");
continue;
}
}
else if(j_strcmp(affiliation, "member") != 0 && j_strcmp(affiliation, "none") != 0)
{
error = 1;
log_debug(NAME, "[%s] Skipping - affiliation unknown(%s/%s)", FZONE, jabberid, affiliation);
insert_item_error(current, "400", "Unknown affiliation");
continue;
}
}
/* role changes */
if(role != NULL)
{
if(!is_admin(room, from) && !is_moderator(room, from))
{
error = 1;
log_debug(NAME, "[%s] Skipping - Forbidden role change (%s)", FZONE, jabberid);
insert_item_error(current, "403", "Forbidden role change request by non-admin");
continue;
}
else if(j_strcmp(role, "moderator") == 0)
{
if(!is_admin(room, from))
{
error = 1;
log_debug(NAME, "[%s] Skipping - Forbidden moderater request (%s)", FZONE, jabberid);
insert_item_error(current, "403", "Forbidden moderator request by non-admin");
continue;
}
}
else if(j_strcmp(role, "none") == 0)
{
if(is_admin(room, target) || is_moderator(room, target))
{
error = 1;
log_debug(NAME, "[%s] Skipping - Forbidden kick request (%s)", FZONE, jabberid);
insert_item_error(current, "403", "Forbidden Kick request against admin");
continue;
}
}
else if(j_strcmp(role, "participant") != 0 && j_strcmp(role, "visitor") != 0)
{
error = 1;
log_debug(NAME, "[%s] Skipping - role unknown(%s)", FZONE, jabberid);
insert_item_error(current, "400", "Unknown role");
continue;
}
}
}
log_debug(NAME, "[%s] Ok (%s)", FZONE, xmlnode2str(current));
}
/* If theres an error, return */
if(error == 1)
{
jutil_iqresult(jp->x);
xmlnode_put_attrib(jp->x, "type", "error");
xmlnode_insert_node(jp->x, node);
deliver(dpacket_new(jp->x), NULL);
return;
}
/* Now process the checked results */
result = xmlnode_new_tag("query");
xmlnode_put_attrib(result, "xmlns", xmlns);
for(current = xmlnode_get_firstchild(node); current != NULL; current = xmlnode_get_nextsibling(current))
{
jabberid = xmlnode_get_attrib(current, "jid");
nick = xmlnode_get_attrib(current, "nick");
role = xmlnode_get_attrib(current, "role");
affiliation = xmlnode_get_attrib(current, "affiliation");
reason = xmlnode_get_tag_data(current, "reason");
if(jpacket_subtype(jp) == JPACKET__GET)
{
if(role != NULL)
result = con_gen_list(room, xmlns, role);
else
result = con_gen_list(room, xmlns, affiliation);
break;
}
else
{
/* Find jabberid for this user */
if(jabberid == NULL)
{
user = con_room_usernick(room, nick);
jabberid = jid_full(jid_fix(user->realid));
}
else if(user == NULL)
{
user = htb_get(&room->remote, jabberid);
}
/* Convert jabberid into a jid struct */
target = jid_new(jp->p, jabberid);
if(role == NULL && affiliation != NULL)
{
log_debug(NAME, "[%s] Requesting affiliation change for %s to (%s)", FZONE, jabberid, affiliation);
change_affiliate(affiliation, sender, target, reason, from);
if(target->user != NULL)
{
if(j_strcmp(affiliation, "owner") == 0)
{
change_role("moderator", sender, target, reason);
}
else if(j_strcmp(affiliation, "admin") == 0)
{
change_role("moderator", sender, target, reason);
}
else if(j_strcmp(affiliation, "outcast") == 0)
{
change_role("none", sender, target, reason);
}
else
{
change_role("participant", sender, target, reason);
}
}
}
else if(role != NULL && affiliation == NULL)
{
log_debug(NAME, "[%s] Requesting role change for %s to (%s)", FZONE, jabberid, role);
change_role(role, sender, target, reason);
}
else
{
log_debug(NAME, "[%s] Request: role %s, affiliation %s, for %s", FZONE, role, affiliation, jabberid);
}
}
}
jutil_iqresult(jp->x);
if(result)
{
xmlnode_insert_node(jp->x, result);
xmlnode_free(result);
}
deliver(dpacket_new(jp->x), NULL);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -