-extern char *whoami, *strsave();
-extern int ingres_errno, mr_errcode;
-
-/* Specialized Access Routines */
-
-/* access_user - verify that client name equals specified login name
- *
- * - since field validation routines are called first, a users_id is
- * now in argv[0] instead of the login name.
- */
-
-access_user(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-{
- if (cl->users_id != *(int *)argv[0])
- return(MR_PERM);
- else
- return(MR_SUCCESS);
-}
-
-
-
-/* access_login - verify that client name equals specified login name
- *
- * argv[0...n] contain search info. q->
- */
-
-access_login(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int rowcount, id;
-## char qual[256];
-
- build_qual(q->qual, q->argc, argv, qual);
-## range of u is users
-## retrieve (id = u.users_id) where qual
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1 || id != cl->users_id)
- return(MR_PERM);
- else
- return(MR_SUCCESS);
-##}
-
-
-
-/* access_list - check access for most list operations
- *
- * Inputs: argv[0] - list_id
- * q - query name
- * argv[2] - member ID (only for queries "amtl" and "dmfl")
- * argv[7] - group IID (only for query "ulis")
- * cl - client name
- *
- * - check that client is a member of the access control list
- * - OR, if the query is add_member_to_list or delete_member_from_list
- * and the list is public, allow access if client = member
- */
-
-access_list(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int list_id, acl_id, flags, rowcount, gid;
-## char acl_type[9];
- char *client_type;
- int client_id, status;
-
- list_id = *(int *)argv[0];
-## repeat retrieve (acl_id = list.#acl_id, acl_type = list.#acl_type,
-## gid = list.#gid, flags = list.#public)
-## where list.#list_id = @list_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_INTERNAL);
-
- /* parse client structure */
- 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(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(MR_PERM);
- }
-
- /* check for client in access control list */
- status = find_member(acl_type, acl_id, client_type, client_id, 0);
- if (!status) return(MR_PERM);
-
- return(MR_SUCCESS);
-##}
-
-
-/* access_visible_list - allow access to list only if it is not hidden,
- * or if the client is on the ACL
- *
- * Inputs: argv[0] - list_id
- * cl - client identifier
- */
-
-access_visible_list(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int list_id, acl_id, flags, rowcount;
-## char acl_type[9];
- char *client_type;
- int client_id, status;
-
- list_id = *(int *)argv[0];
-## repeat retrieve (flags = list.hidden, acl_id = list.#acl_id,
-## acl_type = list.#acl_type) where list.#list_id = @list_id
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_INTERNAL);
- if (!flags)
- return(MR_SUCCESS);
-
-
- /* parse client structure */
- 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(MR_PERM);
-
- return(MR_SUCCESS);
-##}
-
-
-/* access_vis_list_by_name - allow access to list only if it is not hidden,
- * or if the client is on the ACL
- *
- * Inputs: argv[0] - list name
- * cl - client identifier
- */
-
-access_vis_list_by_name(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int acl_id, flags, rowcount;
-## char acl_type[9], *listname;
- char *client_type;
- int client_id, status;
-
- listname = argv[0];
-## repeat retrieve (flags = list.hidden, acl_id = list.#acl_id,
-## acl_type = list.#acl_type) where list.#name = @listname
-## inquire_equel(rowcount = "rowcount");
- if (rowcount > 1)
- return(MR_WILDCARD);
- if (rowcount == 0)
- return(MR_NO_MATCH);
- if (!flags)
- return(MR_SUCCESS);
-
- /* parse client structure */
- 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(MR_PERM);
-
- return(MR_SUCCESS);
-##}
-
-
-/* access_member - allow user to access member of type "USER" and name matches
- * username, or to access member of type "LIST" and list is one that user is
- * on the acl of, or the list is visible.
- */
-
-access_member(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-{
- if (!strcmp(argv[0], "LIST") || !strcmp(argv[0], "RLIST"))
- return(access_visible_list(q, &argv[1], cl));
-
- if (!strcmp(argv[0], "USER") || !strcmp(argv[0], "RUSER")) {
- if (cl->users_id == *(int *)argv[1])
- return(MR_SUCCESS);
- }
-
- return(MR_PERM);
-}
-
-
-/* access_qgli - special access routine for Qualified_get_lists. Allows
- * access iff argv[0] == "TRUE" and argv[2] == "FALSE".
- */
-
-access_qgli(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-{
- if (!strcmp(argv[0], "TRUE") && !strcmp(argv[2], "FALSE"))
- return(MR_SUCCESS);
- return(MR_PERM);
-}
-
-
-/* access_service - allow access if user is on ACL of service. Don't
- * allow access if a wildcard is used.
- */
-
-access_service(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int acl_id, rowcount;
-## char *name, acl_type[9];
- int client_id, status;
- char *client_type;
-
- name = argv[0];
-## repeat retrieve (acl_id = servers.#acl_id, acl_type = servers.#acl_type)
-## where servers.#name = uppercase(@name)
-## inquire_equel(rowcount = "rowcount")
- if (rowcount > 1)
- return(MR_PERM);
-
- /* parse client structure */
- 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(MR_PERM);
-
- return(MR_SUCCESS);
-##}
-
-
-
-/* access_filesys - verify that client is owner or on owners list of filesystem
- * named by argv[0]
- */
-
-access_filesys(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int rowcount, users_id, list_id;
-## char *name;
- int status, client_id;
- char *client_type;
-
- name = argv[0];
-## repeat retrieve (users_id = filesys.owner, list_id = filesys.owners)
-## where filesys.label = @name
-## inquire_equel(rowcount = "rowcount")
-
- if (rowcount != 1)
- return(MR_PERM);
- if (users_id == cl->users_id)
- 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(MR_SUCCESS);
- else
- return(MR_PERM);
-##}
-
-
-\f
-/* Setup Routines */
-
-/* Setup routine for add_user
- *
- * Inputs: argv[0] - login
- * argv[1] - uid
- *
- * Description:
- *
- * - if argv[1] == UNIQUE_UID then set argv[1] = next(uid)
- * - if argv[0] == UNIQUE_LOGIN then set argv[0] = "#<uid>"
- */
-
-setup_ausr(q, argv, cl)
- struct query *q;
- register char *argv[];
- client *cl;
-##{
- int row;
-## int nuid, rowcount;
-
- if (!strcmp(q->shortname, "uusr") || !strcmp(q->shortname, "uuac"))
- row = 2;
- else
- row = 1;
- if (!strcmp(argv[row], UNIQUE_UID) || atoi(argv[row]) == -1) {
- if (set_next_object_id("uid", "users", 1))
- return(MR_INGRES_ERR);
-## repeat retrieve (nuid = values.value) where values.#name = "uid"
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1)
- return(MR_INTERNAL);
- sprintf(argv[row], "%d", nuid);
- }
-
- if (!strcmp(argv[0], UNIQUE_LOGIN) || atoi(argv[row]) == -1) {
- sprintf(argv[0], "#%s", argv[row]);
- }
-
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dusr - verify that the user is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dusr(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-
- id = *(int *)argv[0];
-
- /* 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(MR_IN_USE);
-
-## 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(MR_IN_USE);
-## repeat retrieve (flag = any(filesys.label where filesys.owner=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(list.name where list.acl_id=@id and
-## list.acl_type = "USER"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
-## servers.acl_type = "USER"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag=any(hostaccess.acl_id where hostaccess.acl_id=@id and
-## hostaccess.acl_type = "USER"))
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_spop: verify that there is already a valid POP machine_id in the
- * pop_id field. Also take care of keeping track of the post office usage.
- */
-int setup_spop(q, argv)
-struct query *q;
-char **argv;
-##{
-## int id, mid, flag;
-## char type[9];
-
- id = *(int *)argv[0];
-## repeat retrieve (type = u.potype, mid = u.pop_id,
-## flag = any(machine.name where machine.mach_id = u.pop_id
-## and u.pop_id != 0 and u.users_id = @id))
-## where u.users_id = @id
- if (!flag)
- return(MR_MACHINE);
- if (strcmp(strtrim(type), "POP"))
- set_pop_usage(mid, 1);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dpob: Take care of keeping track of the post office usage.
- */
-int setup_dpob(q, argv)
-struct query *q;
-char **argv;
-##{
-## int id, user;
-## char type[9];
-
- user = *(int *)argv[0];
-## repeat retrieve (type = u.potype, id = u.pop_id)
-## where u.users_id = @user
- if (ingres_errno) return(mr_errcode);
-
- if (!strcmp(strtrim(type), "POP"))
- set_pop_usage(id, -1);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dmac - verify that the machine is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dmac(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-
- id = *(int *)argv[0];
-## repeat retrieve (flag = any(users.login where users.potype = "POP"
-## and users.pop_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(serverhosts.mach_id
-## where serverhosts.mach_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(nfsphys.mach_id where nfsphys.mach_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(hostaccess.mach_id where hostaccess.mach_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(printcap.mach_id where printcap.mach_id=@id))
- if (flag)
- 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(MR_IN_USE);
-
-## repeat delete mcmap where mcmap.mach_id = @id
- if (ingres_errno) return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dclu - verify that the cluster is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dclu(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-
- id = *(int *)argv[0];
-## repeat retrieve (flag = any(mcmap.mach_id where mcmap.clu_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(svc.clu_id where svc.clu_id=@id))
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_alis - if argv[5] is non-zero and argv[6] is UNIQUE_ID, then allocate
- * a new gid and put it in argv[6]. Otherwise if argv[6] is UNIQUE_ID but
- * argv[5] is not, then remember that UNIQUE_ID is being stored by putting
- * a -1 there. Remember that this is also used for ulis, with the indexes
- * at 6 & 7.
- */
-
-int setup_alis(q, argv)
-struct query *q;
-char **argv;
-##{
-## int ngid;
- char *malloc();
- int idx;
-
- if (!strcmp(q->shortname, "alis"))
- idx = 6;
- else if (!strcmp(q->shortname, "ulis"))
- idx = 7;
-
- if (!strcmp(argv[idx], UNIQUE_GID) || atoi(argv[idx]) == -1) {
- if (atoi(argv[idx - 1])) {
- if (set_next_object_id("gid", "list", 1))
- return(MR_INGRES_ERR);
-## repeat retrieve (ngid = values.value) where values.name = "gid"
- if (ingres_errno) return(mr_errcode);
- sprintf(argv[idx], "%d", ngid);
- } else {
- strcpy(argv[idx], "-1");
- }
- }
-
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dlist - verify that the list is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dlis(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-
- id = *(int *)argv[0];
-## repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
-## and imembers.member_type = "LIST"))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(imembers.member_id where imembers.list_id=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(filesys.label where filesys.owners=@id))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = any(capacls.tag where capacls.list_id=@id))
- if (flag)
- 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(MR_IN_USE);
-## repeat retrieve (flag = any(servers.name where servers.acl_id=@id and
-## servers.acl_type = "LIST"))
- if (flag)
- 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(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(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dsin - verify that the service is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dsin(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag;
-## char *name;
-
- name = argv[0];
-## repeat retrieve (flag = any(serverhosts.service
-## where serverhosts.service=uppercase(@name)))
- if (flag)
- return(MR_IN_USE);
-## repeat retrieve (flag = servers.inprogress) where servers.#name = @name
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dshi - verify that the service-host is no longer being referenced
- * and may safely be deleted.
- */
-
-int setup_dshi(q, argv)
- struct query *q;
- char **argv;
-##{
-## int flag, id;
-## char *name;
-
- name = argv[0];
- id = *(int *)argv[1];
-## repeat retrieve (flag=serverhosts.inprogress)
-## where serverhosts.service=uppercase(@name) and serverhosts.mach_id=@id
- if (flag)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/**
- ** setup_add_filesys - verify existance of referenced file systems
- **
- ** Inputs: Add
- ** argv[1] - type
- ** argv[2] - mach_id
- ** argv[3] - name
- ** argv[5] - access
- **
- ** Description:
- ** - for type = RVD:
- ** * allow anything
- ** - for type = NFS:
- ** * extract directory prefix from name
- ** * verify mach_id/dir in nfsphys
- ** * verify access in {r, w, R, W}
- **
- ** Side effect: sets variable var_phys_id to the ID of the physical
- ** filesystem (nfsphys_id for NFS, 0 for RVD)
- **
- ** Errors:
- ** MR_NFS - specified directory not exported
- ** MR_FILESYS_ACCESS - invalid filesys access
- **
- **/
-
-##static int var_phys_id;
-
-setup_afil(q, argv)
- struct query *q;
- char *argv[];
-##{
- char *type, *name;
- int mach_id;
-## int ok;
-## char ftype[32], *access;
-
- type = argv[1];
- mach_id = *(int *)argv[2];
- name = argv[3];
- 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(MR_SUCCESS);
-##}
-
-
-/* Verify the arguments, depending on the FStype. Also, if this is an
- * NFS filesystem, then update any quotas for that filesystem to reflect
- * the new phys_id.
- */
-
-setup_ufil(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
- int mach_id, status;
- char *type, *name;
-## int fid, total, who;
-## char *entity, ftype[32], *access;
-
- type = argv[2];
- mach_id = *(int *)argv[3];
- name = argv[4];
- 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 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;
-## delete quota where quota.type="ANY" and quota.filsys_id = fid
-## retrieve (total = sum(quota.quota where quota.filsys_id = fid
-## and quota.phys_id != 0))
- if (ingres_errno) return(mr_errcode);
- if (total != 0) {
-## 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 quota (phys_id = 0) where quota.filsys_id = fid
- if (ingres_errno) return(mr_errcode);
- }
- return(MR_SUCCESS);
-##}
-
-
-/* Find the NFS physical partition that the named directory is on.
- * This is done by comparing the dir against the mount point of the
- * partition. To make sure we get the correct match when there is
- * more than one, we sort the query in reverse order by dir name.
- */
-
-##check_nfs(mach_id, name, access)
-## int mach_id;
- char *name;
- char *access;
-##{
-## char dir[81];
- char caccess;
- register int status;
- register char *cp1;
- register char *cp2;
-
- 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 {
- cp1 = name;
- cp2 = dir;
- while (*cp2) {
- if (*cp1++ != *cp2) break;
- cp2++;
- }
- if (*cp2 == 0) {
- status = MR_SUCCESS;
-## endretrieve
- }
-## }
- if (ingres_errno)
- return(mr_errcode);
- return(status);
-##}
-
-
-/* setup_dfil: free any quota records and fsgroup info associated with
- * a filesystem when it is deleted. Also adjust the allocation numbers.
- */
-
-setup_dfil(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int id;
-
- id = *(int *)argv[0];
-## 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(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dnfp: check to see that the nfs physical partition does not have
- * any filesystems assigned to it before allowing it to be deleted.
- */
-
-setup_dnfp(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int id, exists;
-## char *dir;
-
- id = *(int *)argv[0];
- dir = argv[1];
-## repeat retrieve (exists = any(filesys.label where filesys.mach_id = @id
-## and filesys.phys_id = nfsphys.nfsphys_id and
-## nfsphys.mach_id = @id and nfsphys.#dir = @dir))
- if (exists)
- return(MR_IN_USE);
- if (ingres_errno)
- return(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_dqot: Remove allocation from nfsphys before deleting quota.
- * argv[0] = filsys_id
- * argv[1] = type if "update_quota" or "delete_quota"
- * argv[2 or 1] = users_id or list_id
- */
-
-setup_dqot(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int quota, fs, id;
-## char *qtype;
-
- fs = *(int *)argv[0];
- 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 #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(mr_errcode);
- return(MR_SUCCESS);
-##}
-
-
-/* setup_sshi: don't exclusive lock the machine table during
- * set_server_host_internal.
- */
-
-setup_sshi(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## set lockmode session where readlock = system
-##}
-
-
-/* setup add_kerberos_user_mapping: add the string to the string
- * table if necessary.
- */
-
-setup_akum(q, argv, cl)
-struct query *q;
-char **argv;
-client *cl;
-##{
-## int id, rowcount;
-## char *name;
-
- name = argv[1];
- 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++;
-## 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(mr_errcode);
- *(int *)argv[1] = id;
- return(MR_SUCCESS);
-##}
-
-
-\f
-/* FOLLOWUP ROUTINES */
-
-/* generic set_modtime routine. This takes the table name from the query,
- * and will update the modtime, modby, and modwho fields in the entry in
- * the table whose name field matches argv[0].
- */
-
-set_modtime(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## char *name, *entity, *table;
-## int who;
-
- entity = cl->entity;
- who = cl->client_id;
- table = q->rtable;
- name = argv[0];
-
-## replace table (modtime = "now", modby = who, modwith = entity)
-## where table.#name = name
- return(MR_SUCCESS);
-##}
-
-/* generic set_modtime_by_id routine. This takes the table name from
- * the query, and the id name from the validate record,
- * and will update the modtime, modby, and modwho fields in the entry in
- * the table whose id matches argv[0].
- */
-
-set_modtime_by_id(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity, *table, *id_name;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
- table = q->rtable;
- id_name = q->validate->object_id;
-
- id = *(int *)argv[0];
-## replace table (modtime = "now", modby = who, modwith = entity)
-## where table.id_name = id
- return(MR_SUCCESS);
-##}
-
-
-/* Sets the finger modtime on a user record. The users_id will be in argv[0].
- */
-
-set_finger_modtime(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int users_id, who;
-## char *entity;
-
- entity = cl->entity;
- who = cl->client_id;
- users_id = *(int *)argv[0];
-
-## repeat replace u (fmodtime = "now", fmodby = @who, fmodwith = @entity)
-## where u.#users_id = @users_id
- return(MR_SUCCESS);
-##}
-
-
-/* Sets the pobox modtime on a user record. The users_id will be in argv[0].
- */
-
-set_pobox_modtime(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int users_id, who;
-## char *entity;
-
- entity = cl->entity;
- who = cl->client_id;
- users_id = *(int *)argv[0];
-
-## repeat replace users (pmodtime = "now", pmodby = @who, pmodwith = @entity)
-## where users.#users_id = @users_id
- return(MR_SUCCESS);
-##}
-
-
-/* Like set_modtime, but uppercases the name first.
- */
-
-set_uppercase_modtime(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *name, *entity, *table;
-## int who;
-
- entity = cl->entity;
- who = cl->client_id;
- table = q->rtable;
- name = argv[0];
-
-## replace table (modtime = "now", modby = who, modwith = entity)
-## where table.#name = uppercase(name)
- return(MR_SUCCESS);
-##}
-
-
-/* Sets the modtime on the machine whose mach_id is in argv[0]. This routine
- * is necessary for add_machine_to_cluster becuase the table that query
- * operates on is "mcm", not "machine".
- */
-
-set_mach_modtime_by_id(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
-
- id = *(int *)argv[0];
-## repeat replace machine (modtime = "now", modby = @who, modwith = @entity)
-## where machine.mach_id = @id
- return(MR_SUCCESS);
-##}
-
-
-/* Sets the modtime on the cluster whose mach_id is in argv[0]. This routine
- * is necessary for add_cluster_data and delete_cluster_data becuase the
- * table that query operates on is "svc", not "cluster".
- */
-
-set_cluster_modtime_by_id(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
-
- id = *(int *)argv[0];
-## repeat replace cluster (modtime = "now", modby = @who, modwith = @entity)
-## where cluster.clu_id = @id
- return(MR_SUCCESS);
-##}
-
-
-/* sets the modtime on the serverhost where the service name is in argv[0]
- * and the mach_id is in argv[1].
- */
-
-set_serverhost_modtime(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity, *serv;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
-
- serv = argv[0];
- id = *(int *)argv[1];
-## repeat replace sh (modtime = "now", modby = @who, modwith = @entity)
-## where sh.service = uppercase(@serv) and sh.mach_id = @id
- return(MR_SUCCESS);
-##}
-
-
-/* sets the modtime on the nfsphys where the mach_id is in argv[0] and the
- * directory name is in argv[1].
- */
-
-set_nfsphys_modtime(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## char *entity, *dir;
-## int who, id;
-
- entity = cl->entity;
- who = cl->client_id;
-
- id = *(int *)argv[0];
- dir = argv[1];
-## repeat replace np (modtime = "now", modby = @who, modwith = @entity)
-## where np.#dir = @dir and np.mach_id = @id
- return(MR_SUCCESS);
-##}
-
-
-/* sets the modtime on a filesystem, where argv[0] contains the filesys
- * label.
- */
-
-set_filesys_modtime(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## char *label, *entity;
-## int who;
-
- entity = cl->entity;
- who = cl->client_id;
-
- label = argv[0];
- if (!strcmp(q->shortname, "ufil"))
- label = argv[1];
-
-## repeat replace fs (modtime = "now", modby = @who, modwith = @entity,
-## #phys_id = @var_phys_id) where fs.#label = @label
- return(MR_SUCCESS);
-##}
-
-
-/* sets the modtime on a zephyr class, where argv[0] contains the class
- * name.
- */
-
-set_zephyr_modtime(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## char *class, *entity;
-## int who;
-
- entity = cl->entity;
- who = cl->client_id;
-
- class = argv[0];
-
-## repeat replace z (modtime = "now", modby = @who, modwith = @entity)
-## where z.#class = @class
- return(MR_SUCCESS);
-##}
-
-
-/* fixes the modby field. This will be the second to last thing in the
- * argv, the argv length is determined from the query structure. It is
- * passed as a pointer to an integer. This will either turn it into a
- * username, or # + the users_id.
- */
-followup_fix_modby(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[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);
-}
-
-
-/* After retrieving a user account, fix the modby field and signature.
- * The modby field is the second to last thing in the
- * argv, the argv length is determined from the query structure. It is
- * passed as a pointer to an integer. This will either turn it into a
- * username, or # + the users_id. Only "gua*" queries have a signature,
- * these are ones tieh U_END return values. "gub*" queries also use this
- * routine but don't have a signature.
- */
-followup_guax(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();
-#ifdef GDSS
- char sigbuf[256], *rawsig, *kname;
- SigInfo si;
-#endif /* GDSS */
- int id, status;
-
- i = q->vcnt - 2;
- while (sq_get_data(sq, &argv)) {
- 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);
-#ifdef GDSS
- if (q->vcnt == U_END) {
- com_err(whoami, 0, "compressing signature");
- rawsig = argv[U_SIGNATURE];
- bcopy(&rawsig[0], &id, sizeof(int));
- id = ntohl(id);
- status = id_to_name(id, "STRING", &kname);
- bcopy(&rawsig[4], &si.timestamp, sizeof(int));
- si.timestamp = ntohl(si.timestamp);
- si.SigInfoVersion = 0; /* XXXXX this isn't used */
- kname_parse(si.pname, si.pinst, si.prealm, kname);
- si.rawsig = (unsigned char *)&rawsig[8];
- GDSS_Recompose(&si, sigbuf);
- argv[U_SIGNATURE] = strsave(sigbuf);
- }
-#endif /* GDSS */
- (*action)(q->vcnt, argv, actarg);
- for (j = 0; j < q->vcnt; j++)
- free(argv[j]);
- free(argv);
- }
- sq_destroy(sq);
- return(MR_SUCCESS);
-}
-
-
-/**
- ** followup_ausr - add finger and pobox entries, set_user_modtime
- **
- ** Inputs:
- ** argv[0] - login (add_user)
- ** argv[3] - last name
- ** argv[4] - first name
- ** argv[5] - middle name
- **
- **/
-
-followup_ausr(q, argv, cl)
- struct query *q;
- char *argv[];
- client *cl;
-##{
-## int who, status, sigwho, id;
-## char *login, *entity, *src, *dst, *name;
-## char fullname[129];
-#ifdef GDSS
- char databuf[32], *kname_unparse();
-## char rawsig[128];
- SigInfo si;
-#endif /* GDSS */
-
- /* build fullname */
- if (strlen(argv[4]) && strlen(argv[5]))
- sprintf(fullname, "%s %s %s", argv[4], argv[5], argv[3]);
- else if (strlen(argv[4]))
- sprintf(fullname, "%s %s", argv[4], argv[3]);
- else
- sprintf(fullname, "%s", argv[3]);
-
-#ifdef GDSS
- sprintf(databuf, "%s:%s", argv[U_NAME], argv[U_MITID]);
- /* skip bytes for timestamp & kname */
- si.rawsig = (unsigned char *)&rawsig[8];
- status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE], &si);
- if (status == 0) {
- name = kname_unparse(si.pname, si.pinst, si.prealm);
- status = name_to_id(name, "STRING", &sigwho);
- if (status == MR_NO_MATCH) {
-## repeat retrieve (sigwho = values.value)
-## where values.name = "strings_id"
- sigwho++;
-## repeat replace values (value = @sigwho)
-## where values.name = "strings_id"
-## append to strings (string_id = sigwho, string = name)
- } else if (status)
- return(status);
- sigwho = htonl(sigwho);
- bcopy(&sigwho, &rawsig[0], sizeof(int));
- si.timestamp = htonl(si.timestamp);
- bcopy(&si.timestamp, &rawsig[4], sizeof(int));
- } else
- return(status);
-#endif /* GDSS */
-
- login = argv[0];
- who = cl->client_id;
- entity = cl->entity;
-
- /* create finger entry, pobox & set modtime on user */
-#ifdef GDSS
-## repeat replace u (modtime = "now", modby=@who, modwith=@entity,
-## #fullname=@fullname, mit_affil = u.mit_year,
-## signature=@rawsig,
-## fmodtime="now", fmodby=@who, fmodwith=@entity,
-## potype="NONE", pmodtime="now", pmodby=@who, pmodwith=@entity)
-## where u.#login = @login
-#else /* GDSS */
-## repeat replace u (modtime = "now", modby=@who, modwith=@entity,
-## #fullname=@fullname, mit_affil = u.mit_year,
-## fmodtime="now", fmodby=@who, fmodwith=@entity,
-## potype="NONE", pmodtime="now", pmodby=@who, pmodwith=@entity)
-## where u.#login = @login
-#endif /* GDSS */
-
- return(MR_SUCCESS);
-##}
-
-
-/* followup_gpob: fixes argv[2] based on the IDs currently there and the
- * type in argv[1]. Then completes the upcall to the user.
- *
- * argv[2] is of the form "123:234" where the first integer is the machine
- * ID if it is a pop box, and the second is the string ID if it is an SMTP
- * box. argv[1] should be "POP", "SMTP", or "NONE". Boxes of type NONE
- * are skipped.
- */
-
-followup_gpob(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-{
- char **argv, *index();
- char *ptype, *p;
- int mid, sid, status;
-
- /* for each row */
- while (sq_get_data(sq, &argv)) {
- mr_trim_args(2, argv);
- ptype = argv[1];
- p = index(argv[2], ':');
- *p++ = 0;
- mid = atoi(argv[2]);
- sid = atoi(p);
-
- if (!strcmp(ptype, "POP")) {
- status = id_to_name(mid, "MACHINE", &argv[2]);
- if (status == MR_NO_MATCH)
- return(MR_MACHINE);
- } else if (!strcmp(ptype, "SMTP")) {
- status = id_to_name(sid, "STRING", &argv[2]);
- if (status == MR_NO_MATCH)
- return(MR_STRING);
- } else /* ptype == "NONE" */ {
- goto skip;
- }
- if (status) return(status);
-
- if (!strcmp(q->shortname, "gpob")) {
- sid = atoi(argv[4]);
- if (sid > 0)
- status = id_to_name(sid, "USER", &argv[4]);
- else
- status = id_to_name(-sid, "STRING", &argv[4]);
- }
- if (status && status != MR_NO_MATCH) return(status);
-
- (*action)(q->vcnt, argv, actarg);
- skip:
- /* free saved data */
- free(argv[0]);
- free(argv[1]);
- free(argv[4]);
- free(argv);
- }
-
- sq_destroy(sq);
- return (MR_SUCCESS);
-}
-
-
-/* followup_glin: fix the ace_name in argv[8]. argv[7] will contain the
- * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[8] into the
- * proper name based on the type, and repace that string in the argv.
- * Also fixes the modby field by called followup_fix_modby.
- */
-
-followup_glin(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-{
- char **argv, *malloc(), *realloc(), *type;
- int id, i, idx, status;
-
- idx = 8;
- if (!strcmp(q->shortname, "gsin"))
- idx = 12;
-
- while (sq_get_data(sq, &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 != MR_NO_MATCH)
- return(status);
-
- id = atoi(argv[idx]);
- type = argv[idx - 1];
-
- if (!strcmp(type, "LIST")) {
- status = id_to_name(id, "LIST", &argv[idx]);
- } else if (!strcmp(type, "USER")) {
- status = id_to_name(id, "USER", &argv[idx]);
- } else if (!strcmp(type, "KERBEROS")) {
- status = id_to_name(id, "STRING", &argv[idx]);
- } else if (!strcmp(type, "NONE")) {
- status = 0;
- free(argv[idx]);
- argv[idx] = strsave("NONE");
- } else {
- status = 0;
- free(argv[idx]);
- argv[idx] = strsave("???");
- }
- if (status && status != MR_NO_MATCH)
- return(status);
-
- if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1) {
- argv[6] = realloc(argv[6], strlen(UNIQUE_GID) + 1);
- strcpy(argv[6], UNIQUE_GID);
- }
-
- /* send the data */
- (*action)(q->vcnt, argv, actarg);
-
- /* free saved data */
- for (i = 0; i < q->vcnt; i++)
- free(argv[i]);
- free(argv);
- }
-
- sq_destroy(sq);
- return (MR_SUCCESS);
-}
-
-
-/* followup_gqot: Fix the entity name, directory name & modby fields
- * argv[0] = filsys_id
- * argv[1] = type
- * argv[2] = entity_id
- * argv[3] = ascii(quota)
- */
-
-followup_gqot(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 j;
- char **argv, *malloc();
-## int id, rowcount;
-## char *name, *label;
- 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)) {
- 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
- } else {
-## repeat retrieve (name = nfsphys.dir) where nfsphys.nfsphys_id = @id
- }
-## inquire_equel(rowcount = "rowcount")
- if (rowcount != 1) {
- sprintf(argv[idx], "#%d", id);
- }
-
- id = atoi(argv[idx+3]);
- if (id > 0)
- status = id_to_name(id, "USER", &argv[idx+3]);
- else
- 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[j]);
- free(argv);
- }
- sq_destroy(sq);
- return(MR_SUCCESS);
-##}
-
-
-/* followup_aqot: Add allocation to nfsphys after creating quota.
- * argv[0] = filsys_id
- * argv[1] = type if "add_quota" or "update_quota"
- * argv[2 or 1] = id
- * argv[3 or 2] = ascii(quota)
- */
-
-followup_aqot(q, argv, cl)
- struct query *q;
- char **argv;
- client *cl;
-##{
-## int quota, id, fs, who;
-## char *entity, *qtype;
-
- fs = *(int *)argv[0];
- 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 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(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:
- */
-
-followup_gzcl(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-{
- int id, i, status;
- char **argv;
-
- while (sq_get_data(sq, &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 != MR_NO_MATCH)
- return(status);
-
- for (i = 1; i < 8; i+=2) {
- id = atoi(argv[i+1]);
- if (!strcmp(argv[i], "LIST")) {
- status = id_to_name(id, "LIST", &argv[i+1]);
- } else if (!strcmp(argv[i], "USER")) {
- status = id_to_name(id, "USER", &argv[i+1]);
- } else if (!strcmp(argv[i], "KERBEROS")) {
- status = id_to_name(id, "STRING", &argv[i+1]);
- } else if (!strcmp(argv[i], "NONE")) {
- status = 0;
- free(argv[i+1]);
- argv[i+1] = strsave("NONE");
- } else {
- status = 0;
- free(argv[i+1]);
- argv[i+1] = strsave("???");
- }
- if (status && status != MR_NO_MATCH)
- return(status);
- }
-
- /* send the data */
- (*action)(q->vcnt, argv, actarg);
-
- /* free saved data */
- for (i = 0; i < q->vcnt; i++)
- free(argv[i]);
- free(argv);
- }
- sq_destroy(sq);
- return(MR_SUCCESS);
-}
-
-
-/* followup_gsha:
- */
-
-followup_gsha(q, sq, v, action, actarg, cl)
- register struct query *q;
- register struct save_queue *sq;
- register struct validate *v;
- register int (*action)();
- int actarg;
- client *cl;
-{
- char **argv;
- int i, id, status;
-
- while (sq_get_data(sq, &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 != MR_NO_MATCH)
- return(status);
-
- id = atoi(argv[2]);
- if (!strcmp(argv[1], "LIST")) {
- status = id_to_name(id, "LIST", &argv[2]);
- } else if (!strcmp(argv[1], "USER")) {
- status = id_to_name(id, "USER", &argv[2]);
- } else if (!strcmp(argv[1], "KERBEROS")) {
- status = id_to_name(id, "STRING", &argv[2]);
- } else if (!strcmp(argv[1], "NONE")) {
- status = 0;
- free(argv[2]);
- argv[2] = strsave("NONE");
- } else {
- status = 0;
- free(argv[2]);
- argv[2] = strsave("???");
- }
- if (status && status != MR_NO_MATCH)
- return(status);
-
- /* send the data */
- (*action)(q->vcnt, argv, actarg);