## hostaccess.acl_type = "USER"))
if (flag)
return(SMS_IN_USE);
- else
- return(SMS_SUCCESS);
+ if (ingres_errno)
+ return(sms_errcode);
+ return(SMS_SUCCESS);
##}
user = *(int *)argv[0];
## repeat retrieve (type = u.potype, id = u.pop_id)
## where u.users_id = @user
+ if (ingres_errno) return(sms_errcode);
if (!strcmp(strtrim(type), "POP"))
set_pop_usage(id, -1);
return(SMS_IN_USE);
## repeat delete mcmap where mcmap.mach_id = @id
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
## repeat retrieve (flag = any(svc.clu_id where svc.clu_id=@id))
if (flag)
return(SMS_IN_USE);
- else
- return(SMS_SUCCESS);
+ if (ingres_errno)
+ return(sms_errcode);
+ return(SMS_SUCCESS);
##}
if (set_next_object_id("gid", "list"))
return(SMS_INGRES_ERR);
## repeat retrieve (ngid = values.value) where values.name = "gid"
+ if (ingres_errno) return(sms_errcode);
sprintf(argv[idx], "%d", ngid);
} else {
strcpy(argv[idx], "-1");
## zephyr.iui_type = "LIST" and zephyr.iui_id = @id))
if (flag)
return(SMS_IN_USE);
- else
- return(SMS_SUCCESS);
+ if (ingres_errno)
+ return(sms_errcode);
+ return(SMS_SUCCESS);
##}
## repeat retrieve (flag = servers.inprogress) where servers.#name = @name
if (flag)
return(SMS_IN_USE);
- else
- return(SMS_SUCCESS);
+ if (ingres_errno)
+ return(sms_errcode);
+ return(SMS_SUCCESS);
##}
## where serverhosts.service=uppercase(@name) and serverhosts.mach_id=@id
if (flag)
return(SMS_IN_USE);
- else
- return(SMS_SUCCESS);
+ if (ingres_errno)
+ return(sms_errcode);
+ return(SMS_SUCCESS);
##}
##{
int mach_id, status;
char *type, *name, *access;
-## int fid;
+## int fid, total;
type = argv[2];
mach_id = *(int *)argv[3];
name = argv[4];
access = argv[6];
var_phys_id = 0;
+ fid = *(int *)argv[0];
if (!strcmp(type, "NFS")) {
status = check_nfs(mach_id, name, access);
- fid = *(int *)argv[0];
## replace nfsquota (phys_id = var_phys_id) where nfsquota.filsys_id = fid
+ if (ingres_errno) return(sms_errcode);
return(status);
- } else
- return(SMS_SUCCESS);
+ } else if (!strcmp(type, "AFS")) {
+ total = 0;
+## retrieve (total = sum(nfsquota.quota where nfsquota.filsys_id = fid))
+ if (ingres_errno) return(sms_errcode);
+ if (total != 0) {
+## delete nfsquota where nfsquota.filsys_id = fid
+ if (ingres_errno) return(sms_errcode);
+## append nfsquota (quota = total, filsys_id = fid,
+## phys_id = 0, users_id = 0)
+ if (ingres_errno) return(sms_errcode);
+ }
+ } else {
+## replace nfsquota (phys_id = 0) where nfsquota.filsys_id = fid
+ if (ingres_errno) return(sms_errcode);
+ }
+ return(SMS_SUCCESS);
##}
register char *cp2;
caccess = (isupper(*access)) ? tolower(*access) : *access;
- if (caccess != 'r' && caccess != 'w') return(SMS_FILESYS_ACCESS);
+ if (caccess != 'r' && caccess != 'w' && caccess != 'n')
+ return(SMS_FILESYS_ACCESS);
status = SMS_NFS;
## range of np is nfsphys
## endretrieve
}
## }
-
+ if (ingres_errno)
+ return(sms_errcode);
return(status);
##}
id = *(int *)argv[0];
## range of q is nfsquota
-## range of fs is filesys
## range of n is nfsphys
## repeat replace n (allocated=n.allocated-sum(q.quota where q.filsys_id=@id))
-## where n.nfsphys_id = fs.phys_id and fs.filsys_id = @id
+## where n.nfsphys_id = filesys.phys_id and filesys.filsys_id = @id
## repeat delete q where q.filsys_id = @id
## repeat delete fsgroup where fsgroup.filsys_id = @id
## repeat delete fsgroup where fsgroup.group_id = @id
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
## repeat retrieve (exists = any(filesys.label where filesys.phys_id = @id))
if (exists)
return(SMS_IN_USE);
+ if (ingres_errno)
+ return(sms_errcode);
return(SMS_SUCCESS);
##}
## q.filsys_id = @fs
## repeat replace nfsphys (allocated = nfsphys.allocated - @quota)
## where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
## char *name;
name = argv[1];
-## range of s is strings
-## repeat retrieve (id = s.string_id) where s.string = @name
-## inquire_equel (rowcount = "rowcount")
- if (rowcount == 0) {
+ if (name_to_id(name, "STRING", &id) != SMS_SUCCESS) {
if (q->type != APPEND) return(SMS_STRING);
## range of v is values
## retrieve (id = v.value) where v.#name = "strings_id"
id++;
## replace v (value = id) where v.#name = "strings_id"
## append to strings (string_id = id, string = name)
+ cache_entry(name, "STRING", id);
}
+ if (ingres_errno) return(sms_errcode);
*(int *)argv[1] = id;
- return(0);
+ return(SMS_SUCCESS);
##}
who = cl->client_id;
id = *(int *)argv[0];
-## range of m is machine
-## repeat replace m (modtime = "now", modby = @who, modwith = @entity)
-## where m.mach_id = @id
+## repeat replace machine (modtime = "now", modby = @who, modwith = @entity)
+## where machine.mach_id = @id
return(SMS_SUCCESS);
##}
who = cl->client_id;
id = *(int *)argv[0];
-## range of c is cluster
-## repeat replace c (modtime = "now", modby = @who, modwith = @entity)
-## where c.clu_id = @id
+## repeat replace cluster (modtime = "now", modby = @who, modwith = @entity)
+## where cluster.clu_id = @id
return(SMS_SUCCESS);
##}
register int (*action)();
register int actarg;
client *cl;
-##{
+{
register int i, j;
char **argv, *malloc();
-## int id, rowcount;
-## char *name;
+ int id, status;
i = q->vcnt - 2;
while (sq_get_data(sq, &argv)) {
id = atoi(argv[i]);
- free(argv[i]);
- argv[i] = malloc(256);
- name = argv[i];
if (id > 0)
-## repeat retrieve (name = users.login) where users.users_id = @id
- else {
- id = -id;
-## repeat retrieve (name = strings.string) where strings.string_id = @id
- id = -id;
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
- sprintf(argv[i], "#%d", id);
- }
+ status = id_to_name(id, "USER", &argv[i]);
+ else
+ status = id_to_name(-id, "STRING", &argv[i]);
+ if (status && status != SMS_NO_MATCH)
+ return(status);
(*action)(q->vcnt, argv, actarg);
for (j = 0; j < q->vcnt; j++)
free(argv[j]);
}
sq_destroy(sq);
return(SMS_SUCCESS);
-##}
+}
/**
register int (*action)();
int actarg;
client *cl;
-##{
+{
char **argv, *index();
char *ptype, *p;
-## char box[129], *name;
-## int mid, sid, rowcount;
+ int mid, sid, status;
/* for each row */
while (sq_get_data(sq, &argv)) {
*p++ = 0;
mid = atoi(argv[2]);
sid = atoi(p);
- free(argv[2]);
if (!strcmp(ptype, "POP")) {
-## repeat retrieve (box=machine.#name) where machine.mach_id=@mid
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
+ status = id_to_name(mid, "MACHINE", &argv[2]);
+ if (status == SMS_NO_MATCH)
return(SMS_MACHINE);
} else if (!strcmp(ptype, "SMTP")) {
-## repeat retrieve (box=strings.string) where strings.string_id=@sid
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
+ status = id_to_name(sid, "STRING", &argv[2]);
+ if (status == SMS_NO_MATCH)
return(SMS_STRING);
} else /* ptype == "NONE" */ {
goto skip;
}
+ if (status) return(status);
if (!strcmp(q->shortname, "gpob")) {
sid = atoi(argv[4]);
- free(argv[4]);
- argv[4] = malloc(256);
- name = argv[4];
if (sid > 0)
-## repeat retrieve (name = users.login) where users.users_id = @sid
- else {
- sid = -sid;
-## repeat retrieve (name = strings.string)
-## where strings.string_id = @sid
- sid = -sid;
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- sprintf(name, "#%d", sid);
+ status = id_to_name(sid, "USER", &argv[4]);
+ else
+ status = id_to_name(-sid, "STRING", &argv[4]);
}
+ if (status && status != SMS_NO_MATCH) return(status);
- argv[2] = box;
(*action)(q->vcnt, argv, actarg);
skip:
/* free saved data */
sq_destroy(sq);
return (SMS_SUCCESS);
-##}
+}
/* followup_glin: fix the ace_name in argv[8]. argv[7] will contain the
register int (*action)();
int actarg;
client *cl;
-##{
+{
char **argv, *malloc(), *realloc(), *type;
-## char *name;
-## int id, rowcount;
- int i, idx;
+ int id, i, idx, status;
idx = 8;
if (!strcmp(q->shortname, "gsin"))
sms_trim_args(q->vcnt, argv);
id = atoi(argv[i = q->vcnt - 2]);
- free(argv[i]);
- name = argv[i] = malloc(256);
if (id > 0)
-## repeat retrieve (name = users.login) where users.users_id = @id
- else {
- id = -id;
-## repeat retrieve (name = strings.string) where strings.string_id = @id
- id = -id;
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- sprintf(argv[i], "#%d", id);
+ status = id_to_name(id, "USER", &argv[i]);
+ else
+ status = id_to_name(-id, "STRING", &argv[i]);
+ if (status && status != SMS_NO_MATCH)
+ return(status);
id = atoi(argv[idx]);
type = argv[idx - 1];
- if ((name = malloc(33)) == NULL)
- return(SMS_NO_MEM);
if (!strcmp(type, "LIST")) {
-## repeat retrieve (name = list.#name) where list.list_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "LIST", &argv[idx]);
} else if (!strcmp(type, "USER")) {
-## repeat retrieve (name = users.login) where users.users_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "USER", &argv[idx]);
} else if (!strcmp(type, "KERBEROS")) {
-## repeat retrieve (name = strings.string) where strings.string_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "STRING", &argv[idx]);
} else if (!strcmp(type, "NONE")) {
- strcpy(name, "NONE");
- } else
- strcpy(name, "???");
- free(argv[idx]);
- argv[idx] = name;
+ status = 0;
+ free(argv[idx]);
+ argv[idx] = strsave("NONE");
+ } else {
+ status = 0;
+ free(argv[idx]);
+ argv[idx] = strsave("???");
+ }
+ if (status && status != SMS_NO_MATCH)
+ return(status);
if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1) {
argv[6] = realloc(argv[6], strlen(UNIQUE_GID) + 1);
sq_destroy(sq);
return (SMS_SUCCESS);
-##}
-
-
-/** followup_amtl - followup for amtl and dmfl; when adding a list
- ** member to a maillist, make member list a maillist also
- ** unless list is a user-group.
- ** Then set_list_modtime_by_id.
- **
- ** Inputs:
- ** argv[0] - list_id
- ** argv[1] - member_type
- ** argv[2] - member_id
- **
- **/
-
-followup_amtl(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int list_id;
-## int member_id;
-## int exists, who;
-## char *entity;
-
- list_id = *(int *)argv[0];
- entity = cl->entity;
- who = cl->client_id;
-
-## range of l is list
-## repeat replace l (modtime = "now", modby = @who, modwith = @entity)
-## where l.#list_id = @list_id
-
- /* if query is not amtl or if member_type is not LIST then return */
- if (bcmp(q->shortname, "amtl", 4) || bcmp(argv[1], "LIST", 4))
- return(SMS_SUCCESS);
-
- member_id = *(int *)argv[2];
-
- /* is parent list a mailing list? */
-## repeat retrieve (exists = l.maillist) where l.#list_id=@list_id
- if (!exists)
- return(SMS_SUCCESS);
-
- /* list is not a user-group; add list to maillist table */
-## repeat replace l (maillist = 1) where l.#list_id = @member_id
- return(SMS_SUCCESS);
-##}
+}
/* followup_gnfq: Fix the directory name & modby fields
char **argv, *malloc();
## int id, rowcount;
## char *name, *label;
+ int status;
while (sq_get_data(sq, &argv)) {
id = atoi(argv[3]);
}
id = atoi(argv[6]);
- free(argv[6]);
- argv[6] = malloc(256);
- name = argv[6];
if (id > 0)
-## repeat retrieve (name = users.login) where users.users_id = @id
- else {
- id = -id;
-## repeat retrieve (name = strings.string) where strings.string_id = @id
- id = -id;
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
- sprintf(argv[6], "#%d", id);
- }
+ status = id_to_name(id, "USER", &argv[6]);
+ else
+ status = id_to_name(-id, "STRING", &argv[6]);
+ if (status && status != SMS_NO_MATCH)
+ return(status);
(*action)(q->vcnt, argv, actarg);
for (j = 0; j < q->vcnt; j++)
free(argv[j]);
## where nq.filsys_id = @fs and nq.users_id = @user
## repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
## where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
register int (*action)();
int actarg;
client *cl;
-##{
-## char *name;
-## int rowcount, id;
+{
+ int id, i, status;
char **argv;
- int i;
while (sq_get_data(sq, &argv)) {
sms_trim_args(q->vcnt, argv);
id = atoi(argv[i = q->vcnt - 2]);
- free(argv[i]);
- name = argv[i] = malloc(256);
if (id > 0)
-## repeat retrieve (name = users.login) where users.users_id = @id
- else {
- id = -id;
-## repeat retrieve (name = strings.string) where strings.string_id = @id
- id = -id;
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- sprintf(argv[i], "#%d", id);
+ status = id_to_name(id, "USER", &argv[i]);
+ else
+ status = id_to_name(-id, "STRING", &argv[i]);
+ if (status && status != SMS_NO_MATCH)
+ return(status);
for (i = 1; i < 8; i+=2) {
id = atoi(argv[i+1]);
- free(argv[i+1]);
- if ((name = argv[i+1] = malloc(33)) == NULL)
- return(SMS_NO_MEM);
if (!strcmp(argv[i], "LIST")) {
-## repeat retrieve (name = list.#name) where list.list_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "LIST", &argv[i+1]);
} else if (!strcmp(argv[i], "USER")) {
-## repeat retrieve (name = users.login) where users.users_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "USER", &argv[i+1]);
} else if (!strcmp(argv[i], "KERBEROS")) {
-## repeat retrieve (name = strings.string) where strings.string_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "STRING", &argv[i+1]);
} else if (!strcmp(argv[i], "NONE")) {
- strcpy(name, "NONE");
+ status = 0;
+ free(argv[i+1]);
+ argv[i+1] = strsave("NONE");
} else {
- strcpy(name, "???");
+ status = 0;
+ free(argv[i+1]);
+ argv[i+1] = strsave("???");
}
+ if (status && status != SMS_NO_MATCH)
+ return(status);
}
/* send the data */
}
sq_destroy(sq);
return(SMS_SUCCESS);
-##}
+}
/* followup_gsha:
register int (*action)();
int actarg;
client *cl;
-##{
-## char *name;
-## int rowcount, id;
+{
char **argv;
- int i;
+ int i, id, status;
while (sq_get_data(sq, &argv)) {
sms_trim_args(q->vcnt, argv);
id = atoi(argv[4]);
- free(argv[4]);
- name = argv[4] = malloc(256);
if (id > 0)
-## repeat retrieve (name = users.login) where users.users_id = @id
- else {
- id = -id;
-## repeat retrieve (name = strings.string) where strings.string_id = @id
- id = -id;
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- sprintf(argv[4], "#%d", id);
+ status = id_to_name(id, "USER", &argv[4]);
+ else
+ status = id_to_name(-id, "STRING", &argv[4]);
+ if (status && status != SMS_NO_MATCH)
+ return(status);
id = atoi(argv[2]);
- free(argv[2]);
- if ((name = argv[2] = malloc(33)) == NULL)
- return(SMS_NO_MEM);
if (!strcmp(argv[1], "LIST")) {
-## repeat retrieve (name = list.#name) where list.list_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "LIST", &argv[2]);
} else if (!strcmp(argv[1], "USER")) {
-## repeat retrieve (name = users.login) where users.users_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "USER", &argv[2]);
} else if (!strcmp(argv[1], "KERBEROS")) {
-## repeat retrieve (name = strings.string) where strings.string_id = @id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(name, "???");
+ status = id_to_name(id, "STRING", &argv[2]);
} else if (!strcmp(argv[1], "NONE")) {
- strcpy(name, "NONE");
+ status = 0;
+ free(argv[2]);
+ argv[2] = strsave("NONE");
} else {
- strcpy(name, "???");
+ status = 0;
+ free(argv[2]);
+ argv[2] = strsave("???");
}
+ if (status && status != SMS_NO_MATCH)
+ return(status);
/* send the data */
(*action)(q->vcnt, argv, actarg);
}
sq_destroy(sq);
return(SMS_SUCCESS);
-##}
+}
\f
##{
## int user, id, rowcount;
## char *box, potype[9];
+ int status;
box = argv[2];
user = *(int *)argv[0];
## repeat retrieve (id = users.pop_id, potype = users.#potype)
## where users.users_id = @user
+ if (ingres_errno) return(sms_errcode);
if (!strcmp(strtrim(potype), "POP"))
set_pop_usage(id, -1);
if (!strcmp(argv[1], "POP")) {
-## repeat retrieve (id=machine.mach_id) where machine.name=uppercase(@box)
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(SMS_MACHINE);
+ status = name_to_id(box, "MACHINE", &id);
+ if (status == SMS_NO_MATCH)
+ return(SMS_MACHINE);
+ else if (status)
+ return(status);
## repeat replace users (#potype = "POP", pop_id = @id)
## where users.users_id = @user
set_pop_usage(id, 1);
} else if (!strcmp(argv[1], "SMTP")) {
-## range of s is strings
-## repeat retrieve (id = s.string_id) where s.string = @box
-## inquire_equel (rowcount = "rowcount")
- if (rowcount == 0) {
-## range of v is values
-## repeat retrieve (id = v.value) where v.name = "strings_id"
+ if (index(box, '/') || index(box, '|'))
+ return(SMS_BAD_CHAR);
+ status = name_to_id(box, "STRING", &id);
+ if (status == SMS_NO_MATCH) {
+## repeat retrieve (id = values.value) where values.name = "strings_id"
id++;
-## repeat replace v (value = @id) where v.name = "strings_id"
+## repeat replace values (value = @id) where values.name = "strings_id"
## append to strings (string_id = id, string = box)
- }
+ } else if (status)
+ return(status);
## repeat replace users (#potype = "SMTP", box_id = @id)
## where users.users_id = @user
} else /* argv[1] == "NONE" */ {
set_pobox_modtime(q, argv, cl);
## repeat replace tblstats (updates = tblstats.updates + 1, modtime = "now")
## where tblstats.#table = "users"
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
##{
char *argv[13], *malloc(), *realloc();
## char *name, acl_type[9], listname[33], active[5], public[5], hidden[5];
-## char maillist[5], group[5], gid[6], acl_name[33], desc[256], modtime[27];
+## char maillist[5], group[5], gid[6], acl_name[256], desc[256], modtime[27];
## char modby[256], modwith[9];
## int id, rowcount, acl_id, hid, modby_id;
- int returned;
+ int returned, status;
struct save_queue *sq, *sq_create();
returned = rowcount = 0;
argv[0] = listname; argv[1] = active; argv[2] = public; argv[3] = hidden;
argv[4] = maillist; argv[5] = group; argv[6] = gid; argv[7] = acl_type;
- argv[8] = acl_name; argv[9] = desc; argv[10] = modtime; argv[11] = modby;
- argv[12] = modwith;
+ argv[9] = desc; argv[10] = modtime; argv[12] = modwith;
while (sq_get_data(sq, &id)) {
if (id == 0)
if (atoi(gid) == -1)
argv[6] = UNIQUE_GID;
+ argv[8] = malloc(0);
if (!strcmp(acl_type, "LIST")) {
-## repeat retrieve (acl_name = l.#name) where l.list_id = @acl_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(acl_name, "???");
+ status = id_to_name(acl_id, "LIST", &argv[8]);
} else if (!strcmp(acl_type, "USER")) {
-## repeat retrieve (acl_name = users.#login)
-## where users.users_id = @acl_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(acl_name, "???");
+ status = id_to_name(acl_id, "USER", &argv[8]);
} else if (!strcmp(acl_type, "KERBEROS")) {
-## repeat retrieve (acl_name = strings.string)
-## where strings.string_id = @acl_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- strcpy(acl_name, "???");
+ status = id_to_name(acl_id, "STRING", &argv[8]);
} else if (!strcmp(acl_type, "NONE")) {
- strcpy(acl_name, "NONE");
- } else
- strcpy(acl_name, "???");
+ status = 0;
+ free(argv[8]);
+ argv[8] = strsave("NONE");
+ } else {
+ status = 0;
+ free(argv[8]);
+ argv[8] = strsave("???");
+ }
+ if (status && status != SMS_NO_MATCH) return(status);
+ argv[11] = malloc(0);
if (modby_id > 0)
-## repeat retrieve (modby = users.login) where users.users_id = @modby_id
- else {
- modby_id = -modby_id;
-## repeat retrieve (modby = strings.string)
-## where strings.string_id = @modby_id
- modby_id = -modby_id;
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- sprintf(modby, "#%d", modby_id);
- if (ingres_errno) return(sms_errcode);
+ status = id_to_name(modby_id, "USER", &argv[11]);
+ else
+ status = id_to_name(-modby_id, "STRING", &argv[11]);
+ if (status && status != SMS_NO_MATCH) return(status);
sms_trim_args(q->vcnt, argv);
returned++;
(*action)(q->vcnt, argv, actarg);
+ free(argv[8]);
+ free(argv[11]);
}
sq_destroy(sq);
-## repeat replace tblstats (retrieves = tblstats.retrieves + 1)
-## where tblstats.#table = "list"
-
+ if (ingres_errno) return(sms_errcode);
return (SMS_SUCCESS);
##}
char **argv;
client *cl;
##{
-## int id, lid, mid, exists, error;
-## char *mtype, dtype[9];
- int ancestors[MAXLISTDEPTH], acount, a;
- int descendants[MAXLISTDEPTH], dcount, d;
+## int id, lid, mid, exists, error, who, ref;
+## char *mtype, dtype[9], *entity;
+ int ancestors[MAXLISTDEPTH], aref[MAXLISTDEPTH], acount, a;
+ int descendants[MAXLISTDEPTH], dref[MAXLISTDEPTH], dcount, d;
+ int status;
char *dtypes[MAXLISTDEPTH];
- char *iargv[3];
+ char *iargv[3], *buf;
## range of m is imembers
lid = *(int *)argv[0];
mtype = argv[1];
mid = *(int *)argv[2];
+ /* if the member is already a direct member of the list, punt */
## repeat retrieve (exists = any(m.list_id where m.list_id=@lid and
## m.member_id = @mid and m.member_type = @mtype
## and m.direct = 1))
if (exists)
return(SMS_EXISTS);
+ if (!strcasecmp(mtype, "STRING")) {
+ buf = malloc(0);
+ status = id_to_name(mid, "STRING", &buf);
+ if (status) return(status);
+ if (index(buf, '/') || index(buf, '|')) {
+ free(buf);
+ return(SMS_BAD_CHAR);
+ }
+ free(buf);
+ }
+
ancestors[0] = lid;
+ aref[0] = 1;
acount = 1;
-## repeat retrieve (id = m.list_id)
+## repeat retrieve (id = m.list_id, ref = m.ref_count)
## where m.member_id = @lid and m.member_type = "LIST" {
+ aref[acount] = ref;
ancestors[acount++] = id;
if (acount >= MAXLISTDEPTH) {
## endretrieve
}
descendants[0] = mid;
dtypes[0] = mtype;
+ dref[0] = 1;
dcount = 1;
error = 0;
if (!strcmp(mtype, "LIST")) {
-## repeat retrieve (id = m.member_id, dtype = m.member_type)
+## repeat retrieve (id = m.member_id, dtype = m.member_type,
+## ref = m.ref_count)
## where m.list_id = @mid {
switch (dtype[0]) {
case 'L':
error++;
## endretrieve
}
+ dref[dcount] = ref;
descendants[dcount++] = id;
if (dcount >= MAXLISTDEPTH) {
error++;
## repeat retrieve (exists = any(m.ref_count where m.list_id = @lid
## and m.member_id = @mid
## and m.member_type = @mtype))
+ ref = aref[a] * dref[d];
if (exists) {
if (a == 0 && d == 0)
-## replace m (ref_count = m.ref_count+1, direct = 1)
+## replace m (ref_count = m.ref_count+ref, direct = 1)
## where m.list_id = lid and m.member_id = mid and
## m.member_type = mtype
else
-## replace m (ref_count = m.ref_count+1)
+## replace m (ref_count = m.ref_count+ref)
## where m.list_id = lid and m.member_id = mid and
## m.member_type = mtype
} else {
## member_type=mtype, ref_count = 1)
else
## append imembers (list_id=lid, member_id = mid,
-## member_type=mtype, ref_count = 1)
+## member_type=mtype, ref_count = ref)
iargv[0] = (char *)lid;
iargv[1] = mtype;
iargv[2] = (char *)mid;
}
}
}
+ lid = *(int *)argv[0];
+ entity = cl->entity;
+ who = cl->client_id;
+## repeat replace list (modtime = "now", modby = @who, modwith = @entity)
+## where list.#list_id = @lid
if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
char **argv;
client *cl;
##{
-## int id, lid, mid, cnt, exists, error;
-## char *mtype, dtype[9];
- int ancestors[MAXLISTDEPTH], acount, a;
- int descendants[MAXLISTDEPTH], dcount, d;
+## int id, lid, mid, cnt, exists, error, who, ref;
+## char *mtype, dtype[9], *entity;
+ int ancestors[MAXLISTDEPTH], aref[MAXLISTDEPTH], acount, a;
+ int descendants[MAXLISTDEPTH], dref[MAXLISTDEPTH], dcount, d;
char *dtypes[MAXLISTDEPTH];
char *iargv[3];
lid = *(int *)argv[0];
mtype = argv[1];
mid = *(int *)argv[2];
+ /* if the member is not a direct member of the list, punt */
## repeat retrieve (exists = any(m.list_id where m.list_id=@lid and
## m.member_id = @mid and m.member_type = @mtype
## and m.direct = 1))
if (!exists)
return(SMS_NO_MATCH);
ancestors[0] = lid;
+ aref[0] = 1;
acount = 1;
-## repeat retrieve (id = m.list_id)
+## repeat retrieve (id = m.list_id, ref = m.ref_count)
## where m.member_id = @lid and m.member_type = "LIST" {
+ aref[acount] = ref;
ancestors[acount++] = id;
if (acount >= MAXLISTDEPTH)
## endretrieve
return(SMS_INTERNAL);
descendants[0] = mid;
dtypes[0] = mtype;
+ dref[0] = 1;
dcount = 1;
error = 0;
if (!strcmp(mtype, "LIST")) {
-## repeat retrieve (id = m.member_id, dtype = m.member_type)
+## repeat retrieve (id = m.member_id, dtype = m.member_type,
+## ref = m.ref_count)
## where m.list_id = @mid {
switch (dtype[0]) {
case 'L':
error++;
## endretrieve
}
+ dref[dcount] = ref;
descendants[dcount++] = id;
if (dcount >= MAXLISTDEPTH)
## endretrieve
## repeat retrieve (cnt = m.ref_count)
## where m.list_id = @lid and m.member_id = @mid
## and m.member_type = @mtype
- if (cnt <= 1) {
+ ref = aref[a] * dref[d];
+ if (cnt <= ref) {
iargv[0] = (char *)lid;
iargv[1] = mtype;
iargv[2] = (char *)mid;
## m.member_type = mtype
incremental_clear_after();
} else if (a == 0 && d == 0) {
-## replace m (ref_count = m.ref_count-1, direct = 0)
+## replace m (ref_count = m.ref_count-ref, direct = 0)
## where m.list_id = lid and m.member_id = mid and
## m.member_type = mtype
} else {
-## replace m (ref_count = m.ref_count-1)
-## where m.list_id = lid and m.member_idn = mid and
+## replace m (ref_count = m.ref_count-ref)
+## where m.list_id = lid and m.member_id = mid and
## m.member_type = mtype
}
}
}
+ lid = *(int *)argv[0];
+ entity = cl->entity;
+ who = cl->client_id;
+## repeat replace list (modtime = "now", modby = @who, modwith = @entity)
+## where list.#list_id = @lid
if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
if (!strcmp(atype, "RLIST")) {
sq_save_data(sq, aid);
/* get all the list_id's of containing lists */
-## range of m is imembers
## repeat retrieve (listid = m.list_id)
## where m.member_type = "LIST" and m.member_id = @id {
sq_save_unique_data(sq, listid);
}
sq_destroy(sq);
+ if (ingres_errno) return(sms_errcode);
if (!found) return(SMS_NO_MATCH);
return(SMS_SUCCESS);
##}
rargv[3] = hidden;
rargv[4] = maillist;
rargv[5] = group;
+## range of m is imembers
if (direct) {
## repeat retrieve (name = list.#name, active = text(list.#active),
## public = text(list.#public), hidden = text(list.#hidden),
## }
}
+ if (ingres_errno) return(sms_errcode);
if (!found) return(SMS_NO_MATCH);
return(SMS_SUCCESS);
##}
int (*action)();
int actarg;
##{
-## int list_id;
-## char member_name[129];
+## int list_id, member_id;
+## char member_name[129], member_type[9];
char *targv[2];
+ int members;
+ struct save_queue *sq;
list_id = *(int *)argv[0];
- targv[0] = "USER";
- targv[1] = member_name;
+ members = 0;
+ sq = sq_create();
+
+## repeat retrieve (member_type = imembers.#member_type,
+## member_id = imembers.#member_id)
+## where imembers.#list_id = @list_id and imembers.direct = 1 {
+ if (members++ > 49)
+## endretrieve
+ sq_save_data(sq, (member_type[0] << 24) | (member_id & 0xffffff));
+## }
+ if (members <= 49) {
+ targv[1] = malloc(0);
+ while (sq_remove_data(sq, &member_id)) {
+ switch (member_id >> 24) {
+ case 'U':
+ targv[0] = "USER";
+ id_to_name(member_id & 0xffffff, "USER", &targv[1]);
+ (*action)(2, targv, actarg);
+ break;
+ case 'L':
+ targv[0] = "LIST";
+ id_to_name(member_id & 0xffffff, "LIST", &targv[1]);
+ (*action)(2, targv, actarg);
+ break;
+ case 'S':
+ targv[0] = "STRING";
+ id_to_name(member_id & 0xffffff, "STRING", &targv[1]);
+ (*action)(2, targv, actarg);
+ break;
+ case 'K':
+ targv[0] = "KERBEROS";
+ id_to_name(member_id & 0xffffff, "STRING", &targv[1]);
+ (*action)(2, targv, actarg);
+ break;
+ default:
+ sq_destroy(sq);
+ return(SMS_INTERNAL);
+ }
+ }
+ free(targv[1]);
+ sq_destroy(sq);
+ return(SMS_SUCCESS);
+ }
+ sq_destroy(sq);
+ targv[1] = member_name;
+ targv[0] = "USER";
## range of m is imembers
## repeat retrieve (member_name = users.login)
-## where m.#list_id = @list_id and m.member_type = "USER"
-## and m.member_id = users.users_id and m.direct = 1
+## where m.#list_id = @list_id and m.#member_type = "USER"
+## and m.#member_id = users.users_id and m.direct = 1
## sort by #member_name
## {
(*action)(2, targv, actarg);
## }
+ if (ingres_errno) return(sms_errcode);
targv[0] = "LIST";
## repeat retrieve (member_name = list.name)
-## where m.#list_id = @list_id and m.member_type = "LIST"
-## and m.member_id = list.#list_id and m.direct = 1
+## where m.#list_id = @list_id and m.#member_type = "LIST"
+## and m.#member_id = list.#list_id and m.direct = 1
## sort by #member_name
## {
(*action)(2, targv, actarg);
## }
+ if (ingres_errno) return(sms_errcode);
targv[0] = "STRING";
## repeat retrieve (member_name = strings.string)
-## where m.#list_id = @list_id and m.member_type = "STRING"
-## and m.member_id = strings.string_id and m.direct = 1
+## where m.#list_id = @list_id and m.#member_type = "STRING"
+## and m.#member_id = strings.string_id and m.direct = 1
## sort by #member_name
## {
(*action)(2, targv, actarg);
## }
+ if (ingres_errno) return(sms_errcode);
targv[0] = "KERBEROS";
## repeat retrieve (member_name = strings.string)
-## where m.#list_id = @list_id and m.member_type = "KERBEROS"
-## and m.member_id = strings.string_id and m.direct = 1
+## where m.#list_id = @list_id and m.#member_type = "KERBEROS"
+## and m.#member_id = strings.string_id and m.direct = 1
## sort by #member_name
## {
(*action)(2, targv, actarg);
## }
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
## repeat retrieve (ct = count(imembers.list_id
## where imembers.list_id = @list and
## imembers.direct = 1))
+ if (ingres_errno) return(sms_errcode);
sprintf(countbuf, "%d", ct);
(*action)(1, rargv, actarg);
return(SMS_SUCCESS);
## retrieve (name = rvar.rfield) where qual {
(*action)(1, rargv, actarg);
## }
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount")
-## repeat replace tblstats (retrieves = tblstats.retrieves + 1)
-## where tblstats.#table = @rtbl
if (rowcount == 0)
return(SMS_NO_MATCH);
return(SMS_SUCCESS);
## retrieve (sname = sh.service, mname = machine.name) where qual {
(*action)(2, rargv, actarg);
## }
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount")
-## repeat replace tblstats (retrieves = tblstats.retrieves + 1)
-## where tblstats.#table = "serverhosts"
if (rowcount == 0)
return(SMS_NO_MATCH);
return(SMS_SUCCESS);
## repeat retrieve (mid = sh.mach_id, machname = m.name)
## where sh.service = "POP" and m.mach_id = sh.mach_id and
## sh.value2 - sh.value1 = max(sh.value2-sh.value1 where sh.service="POP")
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount == 0)
return(SMS_NO_POBOX);
## pmodwith=@entity)
## where u.#users_id = @users_id
## inquire_equel(rowcount = "rowcount");
+ if (ingres_errno) return(sms_errcode);
if (rowcount != 1)
return(SMS_INTERNAL);
set_pop_usage(mid, 1);
if (set_next_object_id("list_id", "list"))
return(SMS_NO_ID);
## repeat retrieve (list_id = values.value) where values.name = "list_id"
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
## acl_type = "USER", acl_id = @users_id, modtime = "now",
## modby = @who, modwith = @entity)
## where values.name = "gid"
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
incremental_clear_before();
## repeat append imembers (#list_id = @list_id, member_type = "USER",
## member_id = @users_id, ref_count = 1, direct = 1)
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
- incremental_after("members", 0, argv);
+ incremental_after("members", 0, aargv);
com_err(whoami, 0, "group list created");
/* decide where to put filesystem */
m_id = mid;
}
## }
+ if (ingres_errno) return(sms_errcode);
if (maxsize == 0)
return(SMS_NO_FILESYS);
## lockertype = "HOMEDIR", modtime = "now",
## modby = @who, modwith = @entity)
## where values.name = "filsys_id"
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
/* set quota */
## repeat retrieve (quota = values.value) where values.name = "def_quota"
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_NO_QUOTA);
## #quota = @quota, phys_id = @pid, modtime = "now",
## modby = @who, modwith = @entity)
## where values.name = "filsys_id"
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
## repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
## where nfsphys.nfsphys_id = filesys.#phys_id and
## filesys.filsys_id = values.value and values.name = "filsys_id"
+ if (ingres_errno) return(sms_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
aargv[0] = login;
aargv[1] = login;
sprintf(buffer, "nq.users_id = %d and nq.filsys_id = values.value and values.name = \"filsys_id\"", users_id);
- incremental_after("nfsquota", buffer, argv);
+ incremental_after("nfsquota", buffer, aargv);
com_err(whoami, 0, "quota of %d assigned", quota);
+ if (ingres_errno) return(sms_errcode);
+
+ cache_entry(login, "USER", users_id);
## repeat replace tblstats (updates = tblstats.updates + 1, modtime = "now")
## where tblstats.table = "users"
## repeat replace tblstats (appends = tblstats.appends + 1, modtime = "now")
## where tblstats.table = "list" or tblstats.table = "filesys" or
## tblstats.table = "nfsquota"
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
## int mach_id = id;
## int n = count;
-## range of sh is serverhosts
-## repeat replace sh (value1 = sh.value1 + @n)
-## where sh.service = "POP" and sh.#mach_id = @mach_id
+## repeat replace serverhosts (value1 = serverhosts.value1 + @n)
+## where serverhosts.service = "POP" and serverhosts.#mach_id = @mach_id
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
vo++;
}
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
}
## char *table;
## char *namefield;
## char *idfield;
-## int id;
-## int rowcount;
+## int id, rowcount;
+ int status;
register char *c;
+
name = argv[vo->index];
table = vo->table;
- /* minor kludge to upcasify machine names */
- if (!strcmp(table, "machine"))
- for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
namefield = vo->namefield;
idfield = vo->idfield;
+
+ if ((!strcmp(table, "users") && !strcmp(namefield, "login")) ||
+ !strcmp(table, "machine") ||
+ !strcmp(table, "filesys") ||
+ !strcmp(table, "list") ||
+ !strcmp(table, "cluster") ||
+ !strcmp(table, "string")) {
+ if (!strcmp(table, "machine"))
+ for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
+ status = name_to_id(name, table, &id);
+ if (status == 0) {
+ *(int *)argv[vo->index] = id;
+ return(SMS_EXISTS);
+ } else if (status == SMS_NO_MATCH || status == SMS_NOT_UNIQUE)
+ return(vo->error);
+ else
+ return(status);
+ }
+
if (!strcmp(namefield, "uid")) {
## retrieve (id = table.idfield) where table.namefield = int4(name)
if (ingres_errno) return(sms_errcode);
##{
## char *name, *table, *namefield, *idfield;
## int id;
+ int status;
register char *c;
c = name = argv[vo->index];
else
return(SMS_EXISTS);
}
-## retrieve (id = table.idfield) where table.namefield = name
- if (ingres_errno) return(sms_errcode);
- if (id == -1 || id == *(int *)argv[vo->index - 1])
+ status = name_to_id(name, table, &id);
+ if (status == SMS_NO_MATCH || id == *(int *)argv[vo->index - 1])
return(SMS_EXISTS);
else
return(vo->error);
/* uppercase type fields */
for (c = value; *c; c++) if (islower(*c)) *c = toupper(*c);
-## range of a is alias
-## repeat retrieve (exists = any(a.trans where a.name = @typename and
-## a.type = "TYPE" and
-## a.trans = @value))
+## repeat retrieve (exists = any(alias.trans where alias.name = @typename and
+## alias.type = "TYPE" and alias.trans = @value))
if (ingres_errno) return(sms_errcode);
return (exists ? SMS_EXISTS : vo->error);
##}
## char *name;
## char *field_type;
## char data_type[129];
-## int id;
-## int rowcount;
+## int id, rowcount;
+ int status;
char *index();
register char *c;
*index(data_type, ' ') = 0;
if (!strcmp(data_type, "user")) {
/* USER */
-## repeat retrieve (id = users.users_id) where users.login = @name
-## inquire_equel (rowcount = "rowcount")
- if (rowcount != 1) return(SMS_USER);
-
+ status = name_to_id(name, data_type, &id);
+ if (status && (status == SMS_NO_MATCH || status == SMS_NOT_UNIQUE))
+ return(SMS_USER);
+ if (status) return(status);
} else if (!strcmp(data_type, "list")) {
/* LIST */
-## repeat retrieve (id = list.list_id) where list.#name = @name
-## inquire_equel (rowcount = "rowcount")
- if (rowcount != 1) {
+ status = name_to_id(name, data_type, &id);
+ if (status && status == SMS_NOT_UNIQUE)
+ return(SMS_LIST);
+ if (status == SMS_NO_MATCH) {
/* if idfield is non-zero, then if argv[0] matches the string
* that we're trying to resolve, we should get the value of
* values.[idfield] for the id.
if (rowcount != 1) return(SMS_LIST);
} else
return(SMS_LIST);
- }
+ } else if (status) return(status);
} else if (!strcmp(data_type, "machine")) {
/* MACHINE */
for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
-## repeat retrieve (id = machine.mach_id) where machine.#name = @name
-## inquire_equel (rowcount = "rowcount")
- if (rowcount != 1) return(SMS_MACHINE);
-
+ status = name_to_id(name, data_type, &id);
+ if (status && (status == SMS_NO_MATCH || status == SMS_NOT_UNIQUE))
+ return(SMS_MACHINE);
+ if (status) return(status);
} else if (!strcmp(data_type, "string")) {
/* STRING */
-## range of s is strings
-## repeat retrieve (id = s.string_id) where s.string = @name
-## inquire_equel (rowcount = "rowcount")
- if (rowcount == 0) {
- if (q->type != APPEND) return(SMS_STRING);
-## range of v is values
-## retrieve (id = v.value) where v.#name = "strings_id"
+ status = name_to_id(name, data_type, &id);
+ if (status && status == SMS_NOT_UNIQUE)
+ return(SMS_STRING);
+ if (status == SMS_NO_MATCH) {
+ if (q->type != APPEND && q->type != UPDATE) return(SMS_STRING);
+## retrieve (id = values.value) where values.#name = "strings_id"
id++;
-## replace v (value = id) where v.#name = "strings_id"
+## replace values (value = id) where values.#name = "strings_id"
## append to strings (string_id = id, string = name)
- }
+ } else if (status) return(status);
} else if (!strcmp(data_type, "none")) {
id = 0;
} else {