#include <mit-copyright.h>
#include "query.h"
-#include "sms_server.h"
+#include "mr_server.h"
#include <ctype.h>
extern char *whoami, *strsave();
-extern int ingres_errno, sms_errcode;
+extern int ingres_errno, mr_errcode;
/* Specialized Access Routines */
client *cl;
{
if (cl->users_id != *(int *)argv[0])
- return(SMS_PERM);
+ return(MR_PERM);
else
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
}
## retrieve (id = u.users_id) where qual
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1 || id != cl->users_id)
- return(SMS_PERM);
+ return(MR_PERM);
else
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## where list.#list_id = @list_id
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
/* parse client structure */
- if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+ if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
return(status);
/* if amtl or dmfl and list is public allow client to add or delete self */
if (((!strcmp("amtl", q->shortname) && flags) ||
(!strcmp("dmfl", q->shortname))) &&
(!strcmp("USER", argv[1]))) {
- if (*(int *)argv[2] == client_id) return(SMS_SUCCESS);
+ if (*(int *)argv[2] == client_id) return(MR_SUCCESS);
/* if update_list, don't allow them to change the GID */
} else if (!strcmp("ulis", q->shortname)) {
if ((!strcmp(argv[7], UNIQUE_GID) && (gid != -1)) ||
(strcmp(argv[7], UNIQUE_GID) && (gid != atoi(argv[7]))))
- return(SMS_PERM);
+ return(MR_PERM);
}
/* check for client in access control list */
status = find_member(acl_type, acl_id, client_type, client_id, 0);
- if (!status) return(SMS_PERM);
+ if (!status) return(MR_PERM);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## acl_type = list.#acl_type) where list.#list_id = @list_id
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
if (!flags)
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
/* parse client structure */
- if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+ if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
return(status);
/* check for client in access control list */
status = find_member(acl_type, acl_id, client_type, client_id, 0);
if (!status)
- return(SMS_PERM);
+ return(MR_PERM);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## acl_type = list.#acl_type) where list.#name = @listname
## inquire_equel(rowcount = "rowcount");
if (rowcount > 1)
- return(SMS_WILDCARD);
+ return(MR_WILDCARD);
if (rowcount == 0)
- return(SMS_NO_MATCH);
+ return(MR_NO_MATCH);
if (!flags)
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
/* parse client structure */
- if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+ if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
return(status);
/* check for client in access control list */
status = find_member(acl_type, acl_id, client_type, client_id, 0);
if (!status)
- return(SMS_PERM);
+ return(MR_PERM);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
if (!strcmp(argv[0], "USER") || !strcmp(argv[0], "RUSER")) {
if (cl->users_id == *(int *)argv[1])
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
}
- return(SMS_PERM);
+ return(MR_PERM);
}
client *cl;
{
if (!strcmp(argv[0], "TRUE") && !strcmp(argv[2], "FALSE"))
- return(SMS_SUCCESS);
- return(SMS_PERM);
+ return(MR_SUCCESS);
+ return(MR_PERM);
}
## where servers.#name = uppercase(@name)
## inquire_equel(rowcount = "rowcount")
if (rowcount > 1)
- return(SMS_PERM);
+ return(MR_PERM);
/* parse client structure */
- if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+ if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
return(status);
/* check for client in access control list */
status = find_member(acl_type, acl_id, client_type, client_id, 0);
- if (!status) return(SMS_PERM);
+ if (!status) return(MR_PERM);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
- return(SMS_PERM);
+ return(MR_PERM);
if (users_id == cl->users_id)
- return(SMS_SUCCESS);
- if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
+ return(MR_SUCCESS);
+ if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
return(status);
status = find_member("LIST", list_id, client_type, client_id, 0);
if (status)
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
else
- return(SMS_PERM);
+ return(MR_PERM);
##}
client *cl;
##{
## int nuid, rowcount;
+## char *mit_id;
+
+#ifdef notdef
+ /* this is currently disabled because we need an index on ID's
+ * before it can run in finite time.
+ */
+ mit_id = argv[U_MITID];
+## retrieve (rowcount = any(u.#mit_id where u.#mit_id = mit_id))
+ if (ingres_errno) return(mr_errcode);
+ if (rowcount) return(MR_EXISTS);
+#endif notdef
if (!strcmp(argv[1], UNIQUE_UID) || atoi(argv[1]) == -1) {
if (set_next_object_id("uid", "users"))
- return(SMS_INGRES_ERR);
+ return(MR_INGRES_ERR);
## repeat retrieve (nuid = values.value) where values.name = "uid"
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
sprintf(argv[1], "%d", nuid);
}
sprintf(argv[0], "#%s", argv[1]);
}
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
/* For now, only allow users to be deleted if their status is 0 */
## repeat retrieve (flag = u.status) where u.users_id = @id
if (flag != 0 && flag != 4)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
-## repeat delete nfsquota where nfsquota.users_id = @id
+## repeat delete quota where quota.entity_id = @id and quota.type = "USER"
## repeat delete krbmap where krbmap.users_id = @id
## repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
## and imembers.member_type = "USER"))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(filesys.label where filesys.owner=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(list.name where list.acl_id=@id and
## list.acl_type = "USER"))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
## servers.acl_type = "USER"))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag=any(hostaccess.acl_id where hostaccess.acl_id=@id and
## hostaccess.acl_type = "USER"))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
if (ingres_errno)
- return(sms_errcode);
- return(SMS_SUCCESS);
+ return(mr_errcode);
+ return(MR_SUCCESS);
##}
## and u.pop_id != 0 and u.users_id = @id))
## where u.users_id = @id
if (!flag)
- return(SMS_MACHINE);
+ return(MR_MACHINE);
if (strcmp(strtrim(type), "POP"))
set_pop_usage(mid, 1);
- return(SMS_SUCCESS);
+ return(MR_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 (ingres_errno) return(mr_errcode);
if (!strcmp(strtrim(type), "POP"))
set_pop_usage(id, -1);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## repeat retrieve (flag = any(users.login where users.potype = "POP"
## and users.pop_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(serverhosts.mach_id
## where serverhosts.mach_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(nfsphys.mach_id where nfsphys.mach_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(hostaccess.mach_id where hostaccess.mach_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(printcap.mach_id where printcap.mach_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
+## repeat retrieve (flag = any(printcap.quotaserver where printcap.quotaserver=@id))
+ if (flag)
+ return(MR_IN_USE);
## repeat retrieve (flag = any(palladium.mach_id where palladium.mach_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat delete mcmap where mcmap.mach_id = @id
- if (ingres_errno) return(sms_errcode);
- return(SMS_SUCCESS);
+ if (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
id = *(int *)argv[0];
## repeat retrieve (flag = any(mcmap.mach_id where mcmap.clu_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(svc.clu_id where svc.clu_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
if (ingres_errno)
- return(sms_errcode);
- return(SMS_SUCCESS);
+ return(mr_errcode);
+ return(MR_SUCCESS);
##}
if (!strcmp(argv[idx], UNIQUE_GID) || atoi(argv[idx]) == -1) {
if (atoi(argv[idx - 1])) {
if (set_next_object_id("gid", "list"))
- return(SMS_INGRES_ERR);
+ return(MR_INGRES_ERR);
## repeat retrieve (ngid = values.value) where values.name = "gid"
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
sprintf(argv[idx], "%d", ngid);
} else {
strcpy(argv[idx], "-1");
}
}
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
## and imembers.member_type = "LIST"))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(imembers.member_id where imembers.list_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(filesys.label where filesys.owners=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(capacls.tag where capacls.list_id=@id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(list.name where list.acl_id=@id and
## list.acl_type = "LIST" and list.list_id != @id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
## servers.acl_type = "LIST"))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
+## repeat retrieve (flag = any(quota.entity_id where quota.entity_id=@id and
+## quota.type = "GROUP"))
+ if (flag)
+ return(MR_IN_USE);
## repeat retrieve (flag=any(hostaccess.acl_id where hostaccess.acl_id=@id and
## hostaccess.acl_type = "LIST"))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = any(zephyr.class
## where zephyr.xmt_type = "LIST" and zephyr.xmt_id = @id or
## zephyr.sub_type = "LIST" and zephyr.sub_id = @id or
## zephyr.iws_type = "LIST" and zephyr.iws_id = @id or
## zephyr.iui_type = "LIST" and zephyr.iui_id = @id))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
if (ingres_errno)
- return(sms_errcode);
- return(SMS_SUCCESS);
+ return(mr_errcode);
+ return(MR_SUCCESS);
##}
## repeat retrieve (flag = any(serverhosts.service
## where serverhosts.service=uppercase(@name)))
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
## repeat retrieve (flag = servers.inprogress) where servers.#name = @name
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
if (ingres_errno)
- return(sms_errcode);
- return(SMS_SUCCESS);
+ return(mr_errcode);
+ return(MR_SUCCESS);
##}
## repeat retrieve (flag=serverhosts.inprogress)
## where serverhosts.service=uppercase(@name) and serverhosts.mach_id=@id
if (flag)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
if (ingres_errno)
- return(sms_errcode);
- return(SMS_SUCCESS);
+ return(mr_errcode);
+ return(MR_SUCCESS);
##}
** filesystem (nfsphys_id for NFS, 0 for RVD)
**
** Errors:
- ** SMS_NFS - specified directory not exported
- ** SMS_FILESYS_ACCESS - invalid filesys access
+ ** MR_NFS - specified directory not exported
+ ** MR_FILESYS_ACCESS - invalid filesys access
**
**/
setup_afil(q, argv)
struct query *q;
char *argv[];
-{
- char *type;
+##{
+ char *type, *name;
int mach_id;
- char *name;
- char *access;
+## int ok;
+## char ftype[32], *access;
type = argv[1];
mach_id = *(int *)argv[2];
access = argv[5];
var_phys_id = 0;
+ sprintf(ftype, "fs_access_%s", type);
+## retrieve (ok = any(alias.trans where alias.name = ftype and
+## alias.type = "TYPE" and alias.trans = access))
+ if (ingres_errno) return(mr_errcode);
+ if (ok == 0) return(MR_FILESYS_ACCESS);
+
if (!strcmp(type, "NFS"))
return (check_nfs(mach_id, name, access));
else
- return(SMS_SUCCESS);
-}
+ return(MR_SUCCESS);
+##}
/* Verify the arguments, depending on the FStype. Also, if this is an
* the new phys_id.
*/
-setup_ufil(q, argv)
+setup_ufil(q, argv, cl)
struct query *q;
char *argv[];
+ client *cl;
##{
int mach_id, status;
- char *type, *name, *access;
-## int fid, total;
+ char *type, *name;
+## int fid, total, who;
+## char *entity, ftype[32], *access;
type = argv[2];
mach_id = *(int *)argv[3];
access = argv[6];
var_phys_id = 0;
fid = *(int *)argv[0];
+ who = cl->client_id;
+ entity = cl->entity;
+
+ sprintf(ftype, "fs_access_%s", type);
+## retrieve (total = any(alias.trans where alias.name = ftype and
+## alias.type = "TYPE" and alias.trans = access))
+ if (ingres_errno) return(mr_errcode);
+ if (total == 0) return(MR_FILESYS_ACCESS);
if (!strcmp(type, "NFS")) {
status = check_nfs(mach_id, name, access);
-## replace nfsquota (phys_id = var_phys_id) where nfsquota.filsys_id = fid
- if (ingres_errno) return(sms_errcode);
+## replace quota (phys_id = var_phys_id) where quota.filsys_id = fid
+ if (ingres_errno) return(mr_errcode);
return(status);
} else if (!strcmp(type, "AFS")) {
total = 0;
-## retrieve (total = sum(nfsquota.quota where nfsquota.filsys_id = fid))
- if (ingres_errno) return(sms_errcode);
+## retrieve (total = sum(quota.quota where quota.filsys_id = fid
+## and quota.phys_id != 0))
+ if (ingres_errno) return(mr_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);
+## append quota (quota = total, filsys_id = fid,
+## phys_id = 0, entity_id = 0, type = "ANY",
+## modtime = "now", modby = who, modwith = entity)
+ if (ingres_errno) return(mr_errcode);
}
} else {
-## replace nfsquota (phys_id = 0) where nfsquota.filsys_id = fid
- if (ingres_errno) return(sms_errcode);
+## replace quota (phys_id = 0) where quota.filsys_id = fid
+ if (ingres_errno) return(mr_errcode);
}
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
register char *cp1;
register char *cp2;
- caccess = (isupper(*access)) ? tolower(*access) : *access;
- if (caccess != 'r' && caccess != 'w' && caccess != 'n')
- return(SMS_FILESYS_ACCESS);
-
- status = SMS_NFS;
+ status = MR_NFS;
## range of np is nfsphys
## repeat retrieve (var_phys_id = np.#nfsphys_id, dir = trim(np.#dir))
## where np.#mach_id = @mach_id sort by #dir:d {
cp2++;
}
if (*cp2 == 0) {
- status = SMS_SUCCESS;
+ status = MR_SUCCESS;
## endretrieve
}
## }
if (ingres_errno)
- return(sms_errcode);
+ return(mr_errcode);
return(status);
##}
## int id;
id = *(int *)argv[0];
-## range of q is nfsquota
+## range of q is quota
## range of n is nfsphys
## repeat replace n (allocated=n.allocated-sum(q.quota where q.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);
+ if (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
id = *(int *)argv[0];
## repeat retrieve (exists = any(filesys.label where filesys.phys_id = @id))
if (exists)
- return(SMS_IN_USE);
+ return(MR_IN_USE);
if (ingres_errno)
- return(sms_errcode);
- return(SMS_SUCCESS);
+ return(mr_errcode);
+ return(MR_SUCCESS);
##}
-/* setup_dnfq: Remove allocation from nfsphys before deleting quota.
+/* setup_dqot: Remove allocation from nfsphys before deleting quota.
* argv[0] = filsys_id
- * argv[1] = users_id
+ * argv[1] = type if "update_quota" or "delete_quota"
+ * argv[2 or 1] = users_id or list_id
*/
-setup_dnfq(q, argv, cl)
+setup_dqot(q, argv, cl)
struct query *q;
char **argv;
client *cl;
##{
-## int quota, fs, user;
+## int quota, fs, id;
+## char *qtype;
fs = *(int *)argv[0];
- user = *(int *)argv[1];
+ if (!strcmp(q->name, "update_quota") || !strcmp(q->name, "delete_quota")) {
+ qtype = argv[1];
+ id = *(int *)argv[2];
+ } else {
+ qtype = "USER";
+ id = *(int *)argv[1];
+ }
-## range of q is nfsquota
-## repeat retrieve (quota = q.#quota) where q.users_id = @user and
-## q.filsys_id = @fs
+## range of q is #quota
+## repeat retrieve (quota = q.#quota) where q.type = @qtype and
+## q.entity_id = @id and 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);
+ if (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
## char *name;
name = argv[1];
- if (name_to_id(name, "STRING", &id) != SMS_SUCCESS) {
- if (q->type != APPEND) return(SMS_STRING);
+ if (name_to_id(name, "STRING", &id) != MR_SUCCESS) {
+ if (q->type != APPEND) return(MR_STRING);
## range of v is values
## retrieve (id = v.value) where v.#name = "strings_id"
id++;
## append to strings (string_id = id, string = name)
cache_entry(name, "STRING", id);
}
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
*(int *)argv[1] = id;
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## replace table (modtime = "now", modby = who, modwith = entity)
## where table.#name = name
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
/* generic set_modtime_by_id routine. This takes the table name from
id = *(int *)argv[0];
## replace table (modtime = "now", modby = who, modwith = entity)
## where table.id_name = id
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## repeat replace u (fmodtime = "now", fmodby = @who, fmodwith = @entity)
## where u.#users_id = @users_id
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## repeat replace users (pmodtime = "now", pmodby = @who, pmodwith = @entity)
## where users.#users_id = @users_id
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## replace table (modtime = "now", modby = who, modwith = entity)
## where table.#name = uppercase(name)
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
id = *(int *)argv[0];
## repeat replace machine (modtime = "now", modby = @who, modwith = @entity)
## where machine.mach_id = @id
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
id = *(int *)argv[0];
## repeat replace cluster (modtime = "now", modby = @who, modwith = @entity)
## where cluster.clu_id = @id
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
id = *(int *)argv[1];
## repeat replace sh (modtime = "now", modby = @who, modwith = @entity)
## where sh.service = uppercase(@serv) and sh.mach_id = @id
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
dir = argv[1];
## repeat replace np (modtime = "now", modby = @who, modwith = @entity)
## where np.#dir = @dir and np.mach_id = @id
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## repeat replace fs (modtime = "now", modby = @who, modwith = @entity,
## #phys_id = @var_phys_id) where fs.#label = @label
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## repeat replace z (modtime = "now", modby = @who, modwith = @entity)
## where z.#class = @class
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
status = id_to_name(id, "USER", &argv[i]);
else
status = id_to_name(-id, "STRING", &argv[i]);
- if (status && status != SMS_NO_MATCH)
+ if (status && status != MR_NO_MATCH)
return(status);
(*action)(q->vcnt, argv, actarg);
for (j = 0; j < q->vcnt; j++)
free(argv);
}
sq_destroy(sq);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
}
## potype="NONE", pmodtime="now", pmodby=@who, pmodwith=@entity)
## where u.#login = @login
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
/* for each row */
while (sq_get_data(sq, &argv)) {
- sms_trim_args(2, argv);
+ mr_trim_args(2, argv);
ptype = argv[1];
p = index(argv[2], ':');
*p++ = 0;
if (!strcmp(ptype, "POP")) {
status = id_to_name(mid, "MACHINE", &argv[2]);
- if (status == SMS_NO_MATCH)
- return(SMS_MACHINE);
+ if (status == MR_NO_MATCH)
+ return(MR_MACHINE);
} else if (!strcmp(ptype, "SMTP")) {
status = id_to_name(sid, "STRING", &argv[2]);
- if (status == SMS_NO_MATCH)
- return(SMS_STRING);
+ if (status == MR_NO_MATCH)
+ return(MR_STRING);
} else /* ptype == "NONE" */ {
goto skip;
}
else
status = id_to_name(-sid, "STRING", &argv[4]);
}
- if (status && status != SMS_NO_MATCH) return(status);
+ if (status && status != MR_NO_MATCH) return(status);
(*action)(q->vcnt, argv, actarg);
skip:
}
sq_destroy(sq);
- return (SMS_SUCCESS);
+ return (MR_SUCCESS);
}
idx = 12;
while (sq_get_data(sq, &argv)) {
- sms_trim_args(q->vcnt, argv);
+ mr_trim_args(q->vcnt, argv);
id = atoi(argv[i = q->vcnt - 2]);
if (id > 0)
status = id_to_name(id, "USER", &argv[i]);
else
status = id_to_name(-id, "STRING", &argv[i]);
- if (status && status != SMS_NO_MATCH)
+ if (status && status != MR_NO_MATCH)
return(status);
id = atoi(argv[idx]);
free(argv[idx]);
argv[idx] = strsave("???");
}
- if (status && status != SMS_NO_MATCH)
+ if (status && status != MR_NO_MATCH)
return(status);
if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1) {
}
sq_destroy(sq);
- return (SMS_SUCCESS);
+ return (MR_SUCCESS);
}
-/* followup_gnfq: Fix the directory name & modby fields
+/* followup_gqot: Fix the entity name, directory name & modby fields
* argv[0] = filsys_id
- * argv[2] = ascii(quota)
+ * argv[1] = type
+ * argv[2] = entity_id
+ * argv[3] = ascii(quota)
*/
-followup_gnfq(q, sq, v, action, actarg, cl)
+followup_gqot(q, sq, v, action, actarg, cl)
struct query *q;
register struct save_queue *sq;
struct validate *v;
char **argv, *malloc();
## int id, rowcount;
## char *name, *label;
- int status;
+ int status, idx;
+ if (!strcmp(q->name, "get_quota") ||
+ !strcmp(q->name, "get_quota_by_filesys"))
+ idx = 4;
+ else
+ idx = 3;
while (sq_get_data(sq, &argv)) {
- id = atoi(argv[3]);
- free(argv[3]);
- argv[3] = malloc(256);
- name = argv[3];
+ if (idx == 4) {
+ switch (argv[1][0]) {
+ case 'U':
+ status = id_to_name(atoi(argv[2]), "USER", &argv[2]);
+ break;
+ case 'G':
+ case 'L':
+ status = id_to_name(atoi(argv[2]), "LIST", &argv[2]);
+ break;
+ case 'A':
+ free(argv[2]);
+ argv[2] = strsave("system:anyuser");
+ break;
+ default:
+ id = atoi(argv[2]);
+ argv[2] = malloc(8);
+ sprintf(argv[2], "%d", id);
+ }
+ }
+ id = atoi(argv[idx]);
+ free(argv[idx]);
+ argv[idx] = malloc(256);
+ name = argv[idx];
if (id == 0) {
label = argv[0];
## repeat retrieve (name = filesys.#name) where filesys.#label = @label
}
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1) {
- sprintf(argv[3], "#%d", id);
+ sprintf(argv[idx], "#%d", id);
}
- id = atoi(argv[6]);
+ id = atoi(argv[idx+3]);
if (id > 0)
- status = id_to_name(id, "USER", &argv[6]);
+ status = id_to_name(id, "USER", &argv[idx+3]);
else
- status = id_to_name(-id, "STRING", &argv[6]);
- if (status && status != SMS_NO_MATCH)
+ status = id_to_name(-id, "STRING", &argv[idx+3]);
+ if (status && status != MR_NO_MATCH)
return(status);
(*action)(q->vcnt, argv, actarg);
for (j = 0; j < q->vcnt; j++)
free(argv);
}
sq_destroy(sq);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
-/* followup_anfq: Add allocation to nfsphys after creating quota.
+/* followup_aqot: Add allocation to nfsphys after creating quota.
* argv[0] = filsys_id
- * argv[2] = ascii(quota)
+ * argv[1] = type if "add_quota" or "update_quota"
+ * argv[2 or 1] = id
+ * argv[3 or 2] = ascii(quota)
*/
-followup_anfq(q, argv, cl)
+followup_aqot(q, argv, cl)
struct query *q;
char **argv;
client *cl;
##{
-## int quota, user, fs, who;
-## char *entity;
+## int quota, id, fs, who;
+## char *entity, *qtype;
fs = *(int *)argv[0];
- user = *(int *)argv[1];
- quota = atoi(argv[2]);
+ if (!strcmp(q->name, "add_quota") || !strcmp(q->name, "update_quota")) {
+ qtype = argv[1];
+ id = *(int *)argv[2];
+ quota = atoi(argv[3]);
+ } else {
+ qtype = "USER";
+ id = *(int *)argv[1];
+ quota = atoi(argv[2]);
+ }
who = cl->client_id;
entity = cl->entity;
-## repeat replace nq (modtime = "now", modby = @who, modwith = @entity)
-## where nq.filsys_id = @fs and nq.users_id = @user
+## repeat replace q (modtime = "now", modby = @who, modwith = @entity)
+## where q.filsys_id = @fs and q.type = @qtype and q.entity_id = @id
## 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);
+ if (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
+followup_gpce(q, sq, v, action, actarg, cl)
+ struct query *q;
+ register struct save_queue *sq;
+ struct validate *v;
+ register int (*action)();
+ register int actarg;
+ client *cl;
+{
+ register int i, j;
+ char **argv, *malloc();
+ int id, status;
+
+ i = q->vcnt - 2;
+ while (sq_get_data(sq, &argv)) {
+ id = atoi(argv[PCAP_QSERVER]);
+ status = id_to_name(id, "MACHINE", &argv[PCAP_QSERVER]);
+ if (status) return (status);
+ id = atoi(argv[i]);
+ if (id > 0)
+ status = id_to_name(id, "USER", &argv[i]);
+ else
+ status = id_to_name(-id, "STRING", &argv[i]);
+ if (status && status != MR_NO_MATCH)
+ return(status);
+ (*action)(q->vcnt, argv, actarg);
+ for (j = 0; j < q->vcnt; j++)
+ free(argv[j]);
+ free(argv);
+ }
+ sq_destroy(sq);
+ return(MR_SUCCESS);
+}
+
+
/* followup_gzcl:
*/
char **argv;
while (sq_get_data(sq, &argv)) {
- sms_trim_args(q->vcnt, argv);
+ mr_trim_args(q->vcnt, argv);
id = atoi(argv[i = q->vcnt - 2]);
if (id > 0)
status = id_to_name(id, "USER", &argv[i]);
else
status = id_to_name(-id, "STRING", &argv[i]);
- if (status && status != SMS_NO_MATCH)
+ if (status && status != MR_NO_MATCH)
return(status);
for (i = 1; i < 8; i+=2) {
free(argv[i+1]);
argv[i+1] = strsave("???");
}
- if (status && status != SMS_NO_MATCH)
+ if (status && status != MR_NO_MATCH)
return(status);
}
free(argv);
}
sq_destroy(sq);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
}
int i, id, status;
while (sq_get_data(sq, &argv)) {
- sms_trim_args(q->vcnt, argv);
+ mr_trim_args(q->vcnt, argv);
id = atoi(argv[4]);
if (id > 0)
status = id_to_name(id, "USER", &argv[4]);
else
status = id_to_name(-id, "STRING", &argv[4]);
- if (status && status != SMS_NO_MATCH)
+ if (status && status != MR_NO_MATCH)
return(status);
id = atoi(argv[2]);
free(argv[2]);
argv[2] = strsave("???");
}
- if (status && status != SMS_NO_MATCH)
+ if (status && status != MR_NO_MATCH)
return(status);
/* send the data */
free(argv);
}
sq_destroy(sq);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
}
## repeat retrieve (id = users.pop_id, potype = users.#potype)
## where users.users_id = @user
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (!strcmp(strtrim(potype), "POP"))
set_pop_usage(id, -1);
if (!strcmp(argv[1], "POP")) {
status = name_to_id(box, "MACHINE", &id);
- if (status == SMS_NO_MATCH)
- return(SMS_MACHINE);
+ if (status == MR_NO_MATCH)
+ return(MR_MACHINE);
else if (status)
return(status);
## repeat replace users (#potype = "POP", pop_id = @id)
set_pop_usage(id, 1);
} else if (!strcmp(argv[1], "SMTP")) {
if (index(box, '/') || index(box, '|'))
- return(SMS_BAD_CHAR);
+ return(MR_BAD_CHAR);
status = name_to_id(box, "STRING", &id);
- if (status == SMS_NO_MATCH) {
+ if (status == MR_NO_MATCH) {
## repeat retrieve (id = values.value) where values.name = "strings_id"
id++;
## repeat replace values (value = @id) where values.name = "strings_id"
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);
+ if (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
sq_save_data(sq, id);
rowcount++;
## }
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (rowcount == 0)
- return(SMS_NO_MATCH);
+ return(MR_NO_MATCH);
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;
## desc = l.#desc, modtime = l.#modtime, modby_id = l.#modby,
## modwith =l.#modwith)
## where l.list_id = @id
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (atoi(gid) == -1)
argv[6] = UNIQUE_GID;
free(argv[8]);
argv[8] = strsave("???");
}
- if (status && status != SMS_NO_MATCH) return(status);
+ if (status && status != MR_NO_MATCH) return(status);
argv[11] = malloc(0);
if (modby_id > 0)
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);
+ if (status && status != MR_NO_MATCH) return(status);
- sms_trim_args(q->vcnt, argv);
+ mr_trim_args(q->vcnt, argv);
returned++;
(*action)(q->vcnt, argv, actarg);
free(argv[8]);
}
sq_destroy(sq);
- if (ingres_errno) return(sms_errcode);
- return (SMS_SUCCESS);
+ if (ingres_errno) return(mr_errcode);
+ return (MR_SUCCESS);
##}
* how many different ancestors a member is allowed to have.
*/
-#define MAXLISTDEPTH 100
+#define MAXLISTDEPTH 1024
int add_member_to_list(q, argv, cl)
struct query *q;
## m.member_id = @mid and m.member_type = @mtype
## and m.direct = 1))
if (exists)
- return(SMS_EXISTS);
+ return(MR_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);
+ return(MR_BAD_CHAR);
}
free(buf);
}
## endretrieve
}
## }
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (acount >= MAXLISTDEPTH) {
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
}
descendants[0] = mid;
dtypes[0] = mtype;
## endretrieve
}
## }
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (error)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
}
for (a = 0; a < acount; a++) {
lid = ancestors[a];
mid = descendants[d];
mtype = dtypes[d];
if (mid == lid && !strcmp(mtype, "LIST")) {
- return(SMS_LISTLOOP);
+ return(MR_LISTLOOP);
}
## repeat retrieve (exists = any(m.ref_count where m.list_id = @lid
## and m.member_id = @mid
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 (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
## 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 (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (!exists)
- return(SMS_NO_MATCH);
+ return(MR_NO_MATCH);
ancestors[0] = lid;
aref[0] = 1;
acount = 1;
if (acount >= MAXLISTDEPTH)
## endretrieve
## }
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (acount >= MAXLISTDEPTH)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
descendants[0] = mid;
dtypes[0] = mtype;
dref[0] = 1;
if (dcount >= MAXLISTDEPTH)
## endretrieve
## }
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (error)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
}
for (a = 0; a < acount; a++) {
lid = ancestors[a];
mid = descendants[d];
mtype = dtypes[d];
if (mid == lid && !strcmp(mtype, "LIST")) {
- return(SMS_LISTLOOP);
+ return(MR_LISTLOOP);
}
## repeat retrieve (cnt = m.ref_count)
## where m.list_id = @lid and m.member_id = @mid
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 (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
## }
/* now process each one */
while (sq_get_data(sq, &id)) {
- if (get_ace_internal("LIST", id, action, actarg) == SMS_SUCCESS)
+ if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
found++;
}
}
## }
/* now process each one */
while (sq_get_data(sq, &id)) {
- if (get_ace_internal("LIST", id, action, actarg) == SMS_SUCCESS)
+ if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
found++;
}
- if (get_ace_internal("USER", aid, action, actarg) == SMS_SUCCESS)
+ if (get_ace_internal("USER", aid, action, actarg) == MR_SUCCESS)
found++;
}
## }
/* now process each one */
while (sq_get_data(sq, &id)) {
- if (get_ace_internal("LIST", id, action, actarg) == SMS_SUCCESS)
+ if (get_ace_internal("LIST", id, action, actarg) == MR_SUCCESS)
found++;
}
- if (get_ace_internal("KERBEROS", aid, action, actarg) == SMS_SUCCESS)
+ if (get_ace_internal("KERBEROS", aid, action, actarg) == MR_SUCCESS)
found++;
}
sq_destroy(sq);
- if (ingres_errno) return(sms_errcode);
- if (!found) return(SMS_NO_MATCH);
- return(SMS_SUCCESS);
+ if (ingres_errno) return(mr_errcode);
+ if (!found) return(MR_NO_MATCH);
+ return(MR_SUCCESS);
##}
found++;
## }
- if (!found) return(SMS_NO_MATCH);
- return(SMS_SUCCESS);
+ if (!found) return(MR_NO_MATCH);
+ return(MR_SUCCESS);
##}
## }
}
- if (ingres_errno) return(sms_errcode);
- if (!found) return(SMS_NO_MATCH);
- return(SMS_SUCCESS);
+ if (ingres_errno) return(mr_errcode);
+ if (!found) return(MR_NO_MATCH);
+ return(MR_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(MR_INTERNAL);
+ }
+ }
+ free(targv[1]);
+ sq_destroy(sq);
+ return(MR_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);
+ if (ingres_errno) return(mr_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);
+ if (ingres_errno) return(mr_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);
+ if (ingres_errno) return(mr_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);
+ if (ingres_errno) return(mr_errcode);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## repeat retrieve (ct = count(imembers.list_id
## where imembers.list_id = @list and
## imembers.direct = 1))
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
sprintf(countbuf, "%d", ct);
(*action)(1, rargv, actarg);
- return(SMS_SUCCESS);
+ return(MR_SUCCESS);
##}
## retrieve (name = rvar.rfield) where qual {
(*action)(1, rargv, actarg);
## }
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount")
if (rowcount == 0)
- return(SMS_NO_MATCH);
- return(SMS_SUCCESS);
+ return(MR_NO_MATCH);
+ return(MR_SUCCESS);
##}
## retrieve (sname = sh.service, mname = machine.name) where qual {
(*action)(2, rargv, actarg);
## }
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount")
if (rowcount == 0)
- return(SMS_NO_MATCH);
- return(SMS_SUCCESS);
+ return(MR_NO_MATCH);
+ return(MR_SUCCESS);
##}
/* register_user - change user's login name and allocate a pobox, group,
* filesystem, and quota for them. The user's status must start out as 0,
* and is left as 2. Arguments are: user's UID, new login name, and user's
- * type for filesystem allocation (SMS_FS_STUDENT, SMS_FS_FACULTY,
- * SMS_FS_STAFF, SMS_FS_MISC).
+ * type for filesystem allocation (MR_FS_STUDENT, MR_FS_FACULTY,
+ * MR_FS_STAFF, MR_FS_MISC).
*/
register_user(q, argv, cl)
/* find user */
## repeat retrieve (users_id = u.#users_id)
-## where u.#uid = @uid and (u.status = 0 or u.status = 5)
+## where u.#uid = @uid and (u.status = 0 or u.status = 5 or u.status = 6)
## inquire_equel(rowcount = "rowcount");
if (rowcount == 0)
- return(SMS_NO_MATCH);
+ return(MR_NO_MATCH);
if (rowcount > 1)
- return(SMS_NOT_UNIQUE);
+ return(MR_NOT_UNIQUE);
/* check new login name */
## repeat retrieve (flag = any(u.#login where u.#login = @login and
## u.#users_id != users_id))
- if (ingres_errno) return(sms_errcode);
- if (flag) return(SMS_IN_USE);
+ if (ingres_errno) return(mr_errcode);
+ if (flag) return(MR_IN_USE);
## repeat retrieve (flag = any(l.#name where l.#name = @login))
- if (ingres_errno) return(sms_errcode);
- if (flag) return(SMS_IN_USE);
+ if (ingres_errno) return(mr_errcode);
+ if (flag) return(MR_IN_USE);
## repeat retrieve (flag = any(filesys.#label where filesys.#label = @login))
- if (ingres_errno) return(sms_errcode);
- if (flag) return(SMS_IN_USE);
+ if (ingres_errno) return(mr_errcode);
+ if (flag) return(MR_IN_USE);
com_err(whoami, 0, "new login name OK");
/* choose place for pobox, put in mid */
## 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);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount == 0)
- return(SMS_NO_POBOX);
+ return(MR_NO_POBOX);
/* change login name, set pobox */
sprintf(buffer, "u.users_id = %d", users_id);
## pmodwith=@entity)
## where u.#users_id = @users_id
## inquire_equel(rowcount = "rowcount");
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
set_pop_usage(mid, 1);
com_err(whoami, 0, "set login name to %s and pobox to %s", login,
strtrim(machname));
/* create group list */
if (set_next_object_id("gid", "list"))
- return(SMS_NO_ID);
+ return(MR_NO_ID);
if (set_next_object_id("list_id", "list"))
- return(SMS_NO_ID);
+ return(MR_NO_ID);
## repeat retrieve (list_id = values.value) where values.name = "list_id"
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
incremental_clear_before();
## repeat append list (name = @login, #list_id = @list_id, active = 1,
## public = 0, hidden = 0, maillist = 0, group = 1,
## acl_type = "USER", acl_id = @users_id, modtime = "now",
## modby = @who, modwith = @entity)
## where values.name = "gid"
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
sprintf(buffer, "l.list_id = %d", list_id);
incremental_after("list", buffer, 0);
aargv[0] = (char *) list_id;
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);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
incremental_after("members", 0, aargv);
com_err(whoami, 0, "group list created");
m_id = mid;
}
## }
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (maxsize == 0)
- return(SMS_NO_FILESYS);
+ return(MR_NO_FILESYS);
/* create filesystem */
if (set_next_object_id("filsys_id", "filesys"))
- return(SMS_NO_ID);
+ return(MR_NO_ID);
incremental_clear_before();
## repeat append filesys (filsys_id = values.value, phys_id = @pid,
## label = @login, type = "NFS", mach_id = @m_id,
## lockertype = "HOMEDIR", modtime = "now",
## modby = @who, modwith = @entity)
## where values.name = "filsys_id"
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_INTERNAL);
incremental_after("filesys",
"fs.filsys_id = values.value and values.name = \"filsys_id\"",
0);
/* set quota */
## repeat retrieve (quota = values.value) where values.name = "def_quota"
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
- return(SMS_NO_QUOTA);
+ return(MR_NO_QUOTA);
incremental_clear_before();
-## repeat append nfsquota (#users_id = @users_id, filsys_id = values.value,
-## #quota = @quota, phys_id = @pid, modtime = "now",
-## modby = @who, modwith = @entity)
+## repeat append #quota (entity_id = @users_id, filsys_id = values.value,
+## type = "USER",
+## #quota = @quota, phys_id = @pid, modtime = "now",
+## modby = @who, modwith = @entity)
## where values.name = "filsys_id"
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_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);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
- return(SMS_INTERNAL);
+ return(MR_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, aargv);
+ aargv[1] = "USER";
+ aargv[2] = login;
+ sprintf(buffer, "q.entity_id = %d and q.filsys_id = values.value and q.type = \"USER\" and values.name = \"filsys_id\"", users_id);
+ incremental_after("quota", buffer, aargv);
com_err(whoami, 0, "quota of %d assigned", quota);
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
cache_entry(login, "USER", users_id);
## 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);
+## tblstats.table = "quota"
+ if (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
## 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);
+ if (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
##}
/* look for the record */
## range of rvar is table
## retrieve (rowcount = count(rvar.name where qual))
- if (ingres_errno) return(sms_errcode);
- if (rowcount == 0) return(SMS_NO_MATCH);
- if (rowcount > 1) return(SMS_NOT_UNIQUE);
- return(SMS_EXISTS);
+ if (ingres_errno) return(mr_errcode);
+ if (rowcount == 0) return(MR_NO_MATCH);
+ if (rowcount > 1) return(MR_NOT_UNIQUE);
+ return(MR_EXISTS);
##}
validate_fields(q, argv, vo, n)
break;
case V_SORT:
- status = SMS_EXISTS;
+ status = MR_EXISTS;
break;
case V_LOCK:
break;
}
- if (status != SMS_EXISTS) return(status);
+ if (status != MR_EXISTS) return(status);
vo++;
}
- if (ingres_errno) return(sms_errcode);
- return(SMS_SUCCESS);
+ if (ingres_errno) return(mr_errcode);
+ return(MR_SUCCESS);
}
{
while (*s)
if (illegalchars[*s++])
- return(SMS_BAD_CHAR);
- return(SMS_EXISTS);
+ return(MR_BAD_CHAR);
+ return(MR_EXISTS);
}
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(MR_EXISTS);
+ } else if (status == MR_NO_MATCH || status == MR_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);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel (rowcount = "rowcount")
} else {
## retrieve (id = table.idfield) where table.namefield = name
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel (rowcount = "rowcount")
}
if (rowcount != 1) return(vo->error);
*(int *)argv[vo->index] = id;
- return(SMS_EXISTS);
+ return(MR_EXISTS);
##}
validate_name(argv, vo)
}
## retrieve (rowcount = countu(table.namefield
## where table.namefield = name))
- if (ingres_errno) return(sms_errcode);
- return ((rowcount == 1) ? SMS_EXISTS : vo->error);
+ if (ingres_errno) return(mr_errcode);
+ return ((rowcount == 1) ? MR_EXISTS : vo->error);
##}
validate_date(argv, vo)
## retrieve (dd = interval("years", date(idate) - date("today")))
## inquire_equel (errorno = "errorno")
- if (errorno != 0 || dd > 5.0) return(SMS_DATE);
- return(SMS_EXISTS);
+ if (errorno != 0 || dd > 5.0) return(MR_DATE);
+ return(MR_EXISTS);
##}
c = name = argv[vo->index];
while (*c)
if (illegalchars[*c++])
- return(SMS_BAD_CHAR);
+ return(MR_BAD_CHAR);
table = vo->table;
/* minor kludge to upcasify machine names */
if (!strcmp(table, "machine"))
id = -1;
if (idfield == 0) {
if (!strcmp(argv[vo->index], argv[vo->index - 1]))
- return(SMS_EXISTS);
+ return(MR_EXISTS);
## retrieve (id = any(table.namefield where table.namefield = name))
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
if (id)
return(vo->error);
else
- return(SMS_EXISTS);
+ return(MR_EXISTS);
}
status = name_to_id(name, table, &id);
- if (status == SMS_NO_MATCH || id == *(int *)argv[vo->index - 1])
- return(SMS_EXISTS);
+ if (status == MR_NO_MATCH || id == *(int *)argv[vo->index - 1])
+ return(MR_EXISTS);
else
return(vo->error);
##}
c = value = argv[vo->index];
while (*c)
if (illegalchars[*c++])
- return(SMS_BAD_CHAR);
+ return(MR_BAD_CHAR);
/* uppercase type fields */
for (c = value; *c; c++) if (islower(*c)) *c = toupper(*c);
## 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);
+ if (ingres_errno) return(mr_errcode);
+ return (exists ? MR_EXISTS : vo->error);
##}
/* validate member or type-specific data field */
/* get corresponding data type associated with field type name */
## repeat retrieve (data_type = alias.trans)
## where alias.#name = @field_type and alias.type = "TYPEDATA"
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel (rowcount = "rowcount")
- if (rowcount != 1) return(SMS_TYPE);
+ if (rowcount != 1) return(MR_TYPE);
/* now retrieve the record id corresponding to the named object */
if (index(data_type, ' '))
if (!strcmp(data_type, "user")) {
/* USER */
status = name_to_id(name, data_type, &id);
- if (status && (status == SMS_NO_MATCH || status == SMS_NOT_UNIQUE))
- return(SMS_USER);
+ if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
+ return(MR_USER);
if (status) return(status);
} else if (!strcmp(data_type, "list")) {
/* LIST */
status = name_to_id(name, data_type, &id);
- if (status && status == SMS_NOT_UNIQUE)
- return(SMS_LIST);
- if (status == SMS_NO_MATCH) {
+ if (status && status == MR_NOT_UNIQUE)
+ return(MR_LIST);
+ if (status == MR_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.
name = vo->idfield;
## repeat retrieve (id = values.value) where values.#name = @name
## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) return(SMS_LIST);
+ if (rowcount != 1) return(MR_LIST);
} else
- return(SMS_LIST);
+ return(MR_LIST);
} else if (status) return(status);
} else if (!strcmp(data_type, "machine")) {
/* MACHINE */
for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
status = name_to_id(name, data_type, &id);
- if (status && (status == SMS_NO_MATCH || status == SMS_NOT_UNIQUE))
- return(SMS_MACHINE);
+ if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
+ return(MR_MACHINE);
if (status) return(status);
} else if (!strcmp(data_type, "string")) {
/* STRING */
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);
+ if (status && status == MR_NOT_UNIQUE)
+ return(MR_STRING);
+ if (status == MR_NO_MATCH) {
+ if (q->type != APPEND && q->type != UPDATE) return(MR_STRING);
## retrieve (id = values.value) where values.#name = "strings_id"
id++;
## replace values (value = id) where values.#name = "strings_id"
} else if (!strcmp(data_type, "none")) {
id = 0;
} else {
- return(SMS_TYPE);
+ return(MR_TYPE);
}
/* now set value in argv */
*(int *)argv[vo->index] = id;
- return (SMS_EXISTS);
+ return (MR_EXISTS);
##}
table = vo->table;
idfield = vo->idfield;
## replace table (modtime = "now") where table.idfield = 0
- if (ingres_errno) return(sms_errcode);
+ if (ingres_errno) return(mr_errcode);
## inquire_equel (rowcount = "rowcount")
if (rowcount != 1)
return(vo->error);
else
- return(SMS_EXISTS);
+ return(MR_EXISTS);
##}