- synced = 0;
- xsb_broadcast("trrequestsync", NULL, "%s", "");
- controlreply(np, "Synchronisation request sent.");
+ if(!parsetg(argv[0], &tg, 0)) {
+ abandonreplication("bad trustgroup line: %s", argv[0]);
+ return CMD_ERROR;
+ }
+
+ otg = tg_getbyid(tg.id);
+
+ if(otg && !tg_modify(otg, &tg)) {
+ abandonreplication("unable to modify database");
+ return CMD_ERROR;
+ }
+
+ freesstring(tg.name);
+ freesstring(tg.createdby);
+ freesstring(tg.contact);
+ freesstring(tg.comment);
+
+ if(!otg) {
+ abandonreplication("unable to lookup id");
+ return CMD_ERROR;
+ }
+
+ tg_update(otg);
+
+ return CMD_OK;
+}
+
+static int xsb_trmodifyhost(void *source, int argc, char **argv) {
+ trustgroup *tg;
+ trusthost th, *oth;
+ unsigned int groupid;
+
+ if(!synced)
+ return CMD_OK;
+
+ if(!masterserver(source))
+ return CMD_ERROR;
+
+ if(argc < 1) {
+ abandonreplication("bad number of arguments");
+ return CMD_ERROR;
+ }
+
+ if(!parseth(argv[0], &th, &groupid, 0)) {
+ abandonreplication("bad trusthost line: %s", argv[0]);
+ return CMD_ERROR;
+ }
+
+ tg = tg_getbyid(groupid);
+
+ for(oth=tg->hosts;oth;oth=oth->next) {
+ if(ipmask_check(&oth->ip, &th.ip, th.bits) && th.bits == oth->bits)
+ break;
+ }
+
+ if(oth && !th_modify(oth, &th)) {
+ abandonreplication("unable to modify database");
+ return CMD_ERROR;
+ }
+
+ if(!oth) {
+ abandonreplication("unable to lookup host");
+ return CMD_ERROR;
+ }
+
+ th_update(oth);