EXEC SQL DECLARE csr102 CURSOR FOR
SELECT users_id, login, last, first, status, potype, pop_id, box_id,
- imap_id, modby, fmodby, pmodby, comments, sigwho FROM users
- ORDER BY users_id;
+ imap_id, modby, fmodby, pmodby, comments, sigwho, sponsor_type, sponsor_id
+ FROM users ORDER BY users_id;
EXEC SQL OPEN csr102;
while (1)
{
EXEC SQL BEGIN DECLARE SECTION;
char login[USERS_LOGIN_SIZE], nbuf[USERS_FIRST_SIZE + USERS_LAST_SIZE];
char last[USERS_LAST_SIZE], first[USERS_FIRST_SIZE];
- char potype[USERS_POTYPE_SIZE];
+ char potype[USERS_POTYPE_SIZE], sponsor_type[USERS_SPONSOR_TYPE_SIZE];
int users_id, status, pop_id, box_id, imap_id, modby, fmodby, pmodby;
- int comments, sigwho;
+ int comments, sigwho, sponsor_id;
EXEC SQL END DECLARE SECTION;
EXEC SQL FETCH csr102 INTO :users_id, :login, :last, :first,
:status, :potype, :pop_id, :box_id, :imap_id, :modby, :fmodby,
- :pmodby, :comments, :sigwho;
+ :pmodby, :comments, :sigwho, :sponsor_type, :sponsor_id;
if (sqlca.sqlcode)
break;
u->pmodby = pmodby;
u->comment = comments;
u->sigwho = sigwho;
+ u->sponsor_type = sponsor_type[0];
+ u->sponsor_id = sponsor_id;
switch (u->potype)
{
case 'P':
void fix_printer_ac(void *id);
void fix_printer_lpc_acl(void *id);
void user_check(int id, void *user, void *hint);
+void clear_user_sponsor(struct user *u);
int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
char *field, char *idfield);
int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
"sigwho", "users_id");
+ switch (u->sponsor_type)
+ {
+ case 'U':
+ if (!hash_lookup(users, u->sponsor_id))
+ {
+ printf("User %s has non-existant USER sponsor %d\n",
+ u->login, u->sponsor_id);
+ if (single_fix("Set to no sponsor", 1))
+ clear_user_sponsor(u);
+ }
+ break;
+ case 'L':
+ if (!hash_lookup(lists, u->sponsor_id))
+ {
+ printf("User %s has non-existant LIST sponsor %d\n",
+ u->login, u->sponsor_id);
+ if (single_fix("Set to no sponsor", 1))
+ clear_user_sponsor(u);
+ }
+ break;
+ case 'S':
+ case 'K':
+ if (u->sponsor_id)
+ u->sponsor_id = maybe_fixup_unref_string(u->sponsor_id, id, u->login,
+ "users", "sponsor_id",
+ "users_id");
+ if (u->sponsor_id == 0)
+ clear_user_sponsor(u);
+ }
+
pobox_check(id, u);
}
"modby", "snet_id");
}
+void clear_user_sponsor(struct user *u)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ int rowcount, id = u->users_id;
+ EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL UPDATE users SET sponsor_type = 'NONE', sponsor_id = 0
+ WHERE users_id = :id;
+ rowcount = sqlca.sqlerrd[2];
+ if (rowcount > 0)
+ printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
+ else
+ printf("Not fixed\n");
+ modified("users");
+}
+
void clear_subnet_owner(struct subnet *s)
{
EXEC SQL BEGIN DECLARE SECTION;