memcpy(tg, itg, sizeof(trustgroup));
tg->name = getsstring(tg->name->content, TRUSTNAMELEN);
- tg->createdby = getsstring(tg->createdby->content, NICKLEN);
+ tg->createdby = getsstring(tg->createdby->content, CREATEDBYLEN);
tg->contact = getsstring(tg->contact->content, CONTACTLEN);
tg->comment = getsstring(tg->comment->content, COMMENTLEN);
if(!tg->name || !tg->createdby || !tg->contact || !tg->comment) {
/* unfortunately we can't just memcpy the new one over */
vnewtg.name = getsstring(newtg->name->content, TRUSTNAMELEN);
- vnewtg.createdby = getsstring(newtg->createdby->content, NICKLEN);
+ vnewtg.createdby = getsstring(newtg->createdby->content, CREATEDBYLEN);
vnewtg.contact = getsstring(newtg->contact->content, CONTACTLEN);
vnewtg.comment = getsstring(newtg->comment->content, COMMENTLEN);
if(!vnewtg.name || !vnewtg.createdby || !vnewtg.contact || vnewtg.comment) {
vnewtg.maxusage = newtg->maxusage;
vnewtg.expires = newtg->expires;
vnewtg.lastseen = newtg->lastseen;
- vnewtg.lastmaxuserreset = newtg->lastmaxuserreset;
+ vnewtg.lastmaxusereset = newtg->lastmaxusereset;
memcpy(oldtg, &vnewtg, sizeof(trustgroup));
static char buf[512];
if(oformat) {
- snprintf(buf, sizeof(buf), "#%u,%s,%u,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->count, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxuserreset, tg->createdby->content, tg->contact->content, tg->comment->content);
+ snprintf(buf, sizeof(buf), "#%u,%s,%u,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->count, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content);
} else {
- snprintf(buf, sizeof(buf), "%u,%s,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxuserreset, tg->createdby->content, tg->contact->content, tg->comment->content);
+ snprintf(buf, sizeof(buf), "%u,%s,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content);
}
return buf;
tg->expires = (time_t)expires;
tg->lastseen = (time_t)lastseen;
- tg->lastmaxuserreset = (time_t)lastmaxusereset;
+ tg->lastmaxusereset = (time_t)lastmaxusereset;
createdby = &line[pos];
contact = strchr(createdby, ',');
*comment++ = '\0';
tg->name = getsstring(name, TRUSTNAMELEN);
- tg->createdby = getsstring(createdby, NICKLEN);
+ tg->createdby = getsstring(createdby, CREATEDBYLEN);
tg->comment = getsstring(comment, COMMENTLEN);
tg->contact = getsstring(contact, CONTACTLEN);
if(!tg->name || !tg->createdby || !tg->comment || !tg->contact) {
#define COMMENTLEN 300
#define TRUSTNAMELEN 100
#define TRUSTHOSTLEN 100
+#define CREATEDBYLEN NICKLEN + 1
+
#define MAXTGEXTS 5
#define MAXTRUSTEDFOR 50000
unsigned int count;
-
struct trusthost *parent, *children;
unsigned int marker;
unsigned int maxusage;
time_t expires;
time_t lastseen;
- time_t lastmaxuserreset;
+ time_t lastmaxusereset;
sstring *createdby, *contact, *comment;
trusthost *hosts;
controlreply(sender, "ID: : %u", tg->id);
controlreply(sender, "Last used : %s", (tg->count>0)?"(now)":((tg->lastseen>0)?trusts_timetostr(tg->lastseen):"(never)"));
controlreply(sender, "Max usage : %d", tg->maxusage);
- controlreply(sender, "Last max reset : %s", tg->lastmaxuserreset?trusts_timetostr(tg->lastmaxuserreset):"(never)");
+ controlreply(sender, "Last max reset : %s", tg->lastmaxusereset?trusts_timetostr(tg->lastmaxusereset):"(never)");
controlreply(sender, "Host Current Max Last seen Group ID Group name");
}
trustsdb->createtable(trustsdb, NULL, NULL,
- "CREATE TABLE ? (id INT PRIMARY KEY, name VARCHAR(?), trustedfor INT, mode INT, maxperident INT, maxusage INT, expires INT, lastseen INT, lastmaxuserreset INT, createdby VARCHAR(?), contact VARCHAR(?), comment VARCHAR(?))",
- "Tdddd", groups, TRUSTNAMELEN, NICKLEN, CONTACTLEN, COMMENTLEN
+ "CREATE TABLE ? (id INT PRIMARY KEY, name VARCHAR(?), trustedfor INT, mode INT, maxperident INT, maxusage INT, expires INT, lastseen INT, lastmaxusereset INT, createdby VARCHAR(?), contact VARCHAR(?), comment VARCHAR(?))",
+ "Tdddd", groups, TRUSTNAMELEN, CREATEDBYLEN, CONTACTLEN, COMMENTLEN
);
/* I'd like multiple keys here but that's not gonna happen on a cross-database platform :( */
tg.maxusage = strtoul(result->get(result, 5), NULL, 10);
tg.expires = (time_t)strtoul(result->get(result, 6), NULL, 10);
tg.lastseen = (time_t)strtoul(result->get(result, 7), NULL, 10);
- tg.lastmaxuserreset = (time_t)strtoul(result->get(result, 8), NULL, 10);
- tg.createdby = getsstring(rtrim(result->get(result, 9)), NICKLEN);
+ tg.lastmaxusereset = (time_t)strtoul(result->get(result, 8), NULL, 10);
+ tg.createdby = getsstring(rtrim(result->get(result, 9)), CREATEDBYLEN);
tg.contact = getsstring(rtrim(result->get(result, 10)), CONTACTLEN);
tg.comment = getsstring(rtrim(result->get(result, 11)), COMMENTLEN);
itg->id = tgmaxid + 1;
itg->maxusage = 0;
itg->lastseen = 0;
- itg->lastmaxuserreset = 0;
+ itg->lastmaxusereset = 0;
tg = tg_copy(itg);
if(!tg)
void trustsdb_inserttg(char *table, trustgroup *tg) {
trustsdb->squery(trustsdb,
- "INSERT INTO ? (id, name, trustedfor, mode, maxperident, maxusage, expires, lastseen, lastmaxuserreset, createdby, contact, comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
- "Tusuuuutttsss", table, tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, tg->expires, tg->lastseen, tg->lastmaxuserreset, tg->createdby->content, tg->contact->content, tg->comment->content
+ "INSERT INTO ? (id, name, trustedfor, mode, maxperident, maxusage, expires, lastseen, lastmaxusereset, createdby, contact, comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "Tusuuuutttsss", table, tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, tg->expires, tg->lastseen, tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content
);
}
void tg_update(trustgroup *tg) {
trustsdb->squery(trustsdb,
- "UPDATE ? SET name = ?, trustedfor = ?, maxperident = ?, maxusage = ?, expires = ?, lastseen = ?, lastmaxuserreset = ?, createdby = ?, contact = ?, comment = ? WHERE id = ?",
- "Tsuuuutttsssu", "groups", tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, tg->expires, tg->lastseen, tg->lastmaxuserreset, tg->createdby->content, tg->contact->content, tg->comment->content, tg->id
+ "UPDATE ? SET name = ?, trustedfor = ?, maxperident = ?, maxusage = ?, expires = ?, lastseen = ?, lastmaxusereset = ?, createdby = ?, contact = ?, comment = ? WHERE id = ?",
+ "Tsuuuutttsssu", "groups", tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, tg->expires, tg->lastseen, tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content, tg->id
);
}
itg.mode = enforceident;
itg.maxperident = maxperident;
itg.expires = howlong + time(NULL);
- itg.createdby = getsstring(createdby, NICKLEN);
+ itg.createdby = getsstring(createdby, CREATEDBYLEN);
itg.contact = getsstring(contact, CONTACTLEN);
itg.comment = getsstring(comment, COMMENTLEN);
itg.name = getsstring(name, TRUSTNAMELEN);
return 1;
}
-static int modifymaxperuser(trustgroup *tg, char *num) {
- unsigned int maxperuser = strtoul(num, NULL, 10);
+static int modifymaxperident(trustgroup *tg, char *num) {
+ unsigned int maxperident = strtoul(num, NULL, 10);
- if(maxperuser > MAXPERIDENT)
+ if(maxperident > MAXPERIDENT)
return 0;
- tg->maxperident = maxperuser;
+ tg->maxperident = maxperident;
return 1;
}
trustgroup *tg;
nick *sender = source;
char *what, *to, validfields[512];
- struct trustmodification *mods = (struct trustmodification []){ MS(expires), MS(enforceident), MS(maxperuser), MS(contact), MS(comment), MS(trustedfor) };
+ struct trustmodification *mods = (struct trustmodification []){ MS(expires), MS(enforceident), MS(maxperident), MS(contact), MS(comment), MS(trustedfor) };
int modcount = sizeof(mods) / sizeof(struct trustmodification);
int i;
StringBuf b;