130 zebra_item_t zitem, scan;
149 if(storage_get(user->
sm->
st,
"privacy-items",
jid_user(user->
jid), NULL, &os) == st_SUCCESS) {
150 if(os_iter_first(os))
152 o = os_iter_object(os);
155 if(!os_object_get_str(os, o,
"list", &str)) {
182 if(os_object_get_str(os, o,
"type", &str))
199 if(!os_object_get_str(os, o,
"value", &str)) {
200 log_debug(
ZONE,
"no value on non-fall-through item, dropping this item");
204 switch(zitem->
type) {
208 if(zitem->
jid == NULL) {
209 log_debug(
ZONE,
"invalid jid '%s' on item, dropping this item", str);
227 if(strcmp(str,
"to") == 0)
229 else if(strcmp(str,
"from") == 0)
231 else if(strcmp(str,
"both") == 0)
232 zitem->
to = zitem->
from = 1;
233 else if(strcmp(str,
"none") != 0) {
234 log_debug(
ZONE,
"invalid value '%s' on s10n item, dropping this item", str);
249 os_object_get_bool(os, o,
"deny", &zitem->
deny);
256 os_object_get_int(os, o,
"order", &(zitem->
order));
259 os_object_get_int(os, o,
"block", (
int*) &(zitem->
block));
263 for(scan = zlist->
items; scan != NULL; scan = scan->
next)
269 if(zlist->
last == NULL)
280 if(zlist->
items == scan) {
282 zlist->
items = zitem;
291 }
while(os_iter_next(os));
297 if(storage_get(user->
sm->
st,
"privacy-default",
jid_user(user->
jid), NULL, &os) == st_SUCCESS) {
298 if(os_iter_first(os))
300 o = os_iter_object(os);
302 if(os_object_get_str(os, o,
"default", &str)) {
310 }
while(os_iter_next(os));
323 unsigned char domres[2048];
325 log_debug(
ZONE,
"running match on list %s for %s (packet type 0x%x) (%s)", zlist->
name,
jid_full(jid), ptype, in ?
"incoming" :
"outgoing");
328 for(scan = zlist->
items; scan != NULL; scan = scan->
next) {
357 for(i = 0; i < ritem->
ngroups; i++)
410 zebra_list_t zlist = NULL;
413 if(pkt->
to == NULL || pkt->
to->
node[0] ==
'\0')
451 log_debug(
ZONE,
"denying incoming packet based on privacy policy");
468 zebra_list_t zlist = NULL;
506 log_debug(
ZONE,
"denying outgoing packet based on privacy policy");
528 int ns, query, list, item;
539 for(zitem = zlist->
items; zitem != NULL; zitem = zitem->
next) {
542 switch(zitem->
type) {
556 if(zitem->
to == 1 && zitem->
from == 1)
558 else if(zitem->
to == 1)
560 else if(zitem->
from == 1)
576 snprintf(order, 14,
"%d", zitem->
order);
612 jid_t notify_jid = NULL;
614 for(scan = zlist->
items; scan != NULL; scan = scan->
next) {
616 if(zlist->
items == scan) {
618 if(zlist->
items != NULL)
621 assert(scan->
prev != NULL);
623 if(scan->
next != NULL)
627 if (zlist->
last == scan)
631 sprintf(filter,
"(&(list=%zu:%s)(type=3:jid)(value=%zu:%s))",
633 storage_delete(st,
"privacy-items",
jid_user(user->
jid), filter);
636 notify_jid = scan->
jid;
644 if(notify_jid != NULL &&
pres_trust(user, notify_jid))
645 for(sscan = user->
sessions; sscan != NULL; sscan = sscan->
next) {
660 int ns, query, list, name, active, def, item, type, value, action, order, blocking, jid, push = 0;
661 char corder[14], str[256], filter[1024];
663 zebra_list_t zlist, old;
665 zebra_item_t zitem, scan;
727 o = os_object_new(os);
728 os_object_put(o,
"default", zlist->
name, os_type_STRING);
731 if(ret != st_SUCCESS)
734 log_debug(
ZONE,
"blocking created '%s' privacy list and set it default", zlist->
name);
769 for(scan = zlist->
items; scan != NULL; scan = scan->
next)
801 if(zlist->
last == NULL) {
806 zlist->
items = zitem;
811 o = os_object_new(os);
812 os_object_put(o,
"list", zlist->
name, os_type_STRING);
813 os_object_put(o,
"type",
"jid", os_type_STRING);
814 os_object_put(o,
"value",
jid_full(zitem->
jid), os_type_STRING);
815 os_object_put(o,
"deny", &zitem->
deny, os_type_BOOLEAN);
816 os_object_put(o,
"order", &zitem->
order, os_type_INTEGER);
817 os_object_put(o,
"block", &zitem->
block, os_type_INTEGER);
820 if(ret != st_SUCCESS) {
830 if(scan != NULL && scan->
deny) {
849 result =
pkt_create(pkt->
sm,
"iq",
"result", NULL, NULL);
861 if(result->
from != NULL) {
881 result =
pkt_create(pkt->
sm,
"iq",
"result", NULL, NULL);
891 for(zitem = zlist->
items; zitem != NULL; zitem = zitem->
next) {
925 if((list < 0 && active < 0 && def < 0) || (list >= 0 && (active >=0 || def >= 0)))
966 if(action < 0 || order < 0 || (type >= 0 && value < 0)) {
976 o = os_object_new(os);
977 os_object_put(o,
"list", zlist->
name, os_type_STRING);
985 if(zitem->
jid == NULL) {
996 os_object_put(o,
"type",
"jid", os_type_STRING);
997 os_object_put(o,
"value",
jid_full(zitem->
jid), os_type_STRING);
1009 os_object_put(o,
"type",
"group", os_type_STRING);
1010 os_object_put(o,
"value", zitem->
group, os_type_STRING);
1016 os_object_put(o,
"type",
"subscription", os_type_STRING);
1020 os_object_put(o,
"value",
"to", os_type_STRING);
1023 os_object_put(o,
"value",
"from", os_type_STRING);
1025 zitem->
to = zitem->
from = 1;
1026 os_object_put(o,
"value",
"both", os_type_STRING);
1028 os_object_put(o,
"value",
"none", os_type_STRING);
1054 os_object_put(o,
"deny", &zitem->
deny, os_type_BOOLEAN);
1059 zitem->
order = atoi(corder);
1061 os_object_put(o,
"order", &zitem->
order, os_type_INTEGER);
1080 os_object_put(o,
"block", &zitem->
block, os_type_INTEGER);
1083 for(scan = zlist->
items; scan != NULL; scan = scan->
next)
1089 if(zlist->
last == NULL)
1094 zlist->
last = zitem;
1100 if(zlist->
items == scan) {
1102 zlist->
items = zitem;
1117 sprintf(filter,
"(list=%zu:%s)", strlen(zlist->
name), zlist->
name);
1123 if(ret != st_SUCCESS) {
1132 if(zlist->
items == NULL) {
1168 o = os_object_new(os);
1170 os_object_put(o,
"default", zlist->
name, os_type_STRING);
1176 log_debug(
ZONE,
"default list is now '%s'", (zlist != NULL) ? zlist->
name :
"(NONE)");
1197 log_debug(
ZONE,
"request to make list '%s' active, but there's no such list", str);
1222 log_debug(
ZONE,
"request to make list '%s' default, but there's no such list");
1229 o = os_object_new(os);
1231 os_object_put(o,
"default", zlist->
name, os_type_STRING);
1242 result =
pkt_create(pkt->
sm,
"iq",
"result", NULL, NULL);
1263 result =
pkt_create(pkt->
sm,
"iq",
"result", NULL, NULL);
1295 if(z->
def != NULL) {
1314 storage_delete(mi->
sm->
st,
"privacy-items",
jid_user(jid), NULL);
1315 storage_delete(mi->
sm->
st,
"privacy-default",
jid_user(jid), NULL);
1326 if (mod->
init)
return 0;