[1774] in Moira

home help back first fref pref prev next nref lref last post

Re: container stuff on ttsp

daemon@ATHENA.MIT.EDU (Qing Dong)
Thu Apr 26 13:17:26 2001

Message-Id: <200104261717.NAA10775@melbourne-city-street.mit.edu>
Date: Thu, 26 Apr 2001 13:12:34 -0400
To: Garry Zacheiss <zacheiss@mit.edu>
From: Qing Dong <dongq@MIT.EDU>
Cc: Garry Zacheiss <zacheiss@mit.edu>, moiradev@mit.edu
In-Reply-To: <200104252307.TAA27649@hodge-podge.mit.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"

Sorry, I made several mistakes in the previous email. 
The changes to access_container in qaccess.pc should be:

int access_container(struct query *q, char *argv[], client *cl)
{
  EXEC SQL BEGIN DECLARE SECTION;
  int cnt_id, acl_id, memacl_id;
  char acl_type[CONTAINERS_ACL_TYPE_SIZE],
memacl_type[CONTAINERS_ACL_TYPE_SIZE];
  char name[CONTAINERS_CNAME_SIZE], *newname;
  EXEC SQL END DECLARE SECTION;
  int status;

  cnt_id = *(int *)argv[0];
  
  /* if amcn or dmcn, container id is the second argument */
  if (strcmp(q->shortname, "amcn") == 0 || strcmp(q->shortname, "dmcn") == 0)
	cnt_id = *(int *)argv[1];

  EXEC SQL SELECT acl_id, acl_type, memacl_id, memacl_type, name
    INTO :acl_id, :acl_type, :memacl_id, :memacl_type, :name
    FROM containers
    WHERE cnt_id = :cnt_id;

  if (sqlca.sqlerrd[2] != 1)
    return MR_INTERNAL;

  /* if the query is update_container and the containers is to be renamed
   * and it is a top-level container, only dbadmin can do it */
  if (!strcmp(q->shortname, "ucon"))
  {
    newname = argv[1];
    if (strcmp(name, newname) && strchr(name, '/') == NULL)
      return MR_PERM;
  }

  /* check for client in access control list and return success right 
   * away if it's there. */
  if (find_member(acl_type, acl_id, cl))
    return MR_SUCCESS;

  /* If not amcn, dmcn, we lose. */
  if (strcmp(q->shortname, "amcn") && strcmp(q->shortname, "dmcn"))
    return MR_PERM;

  if (find_member(memacl_type, memacl_id, cl))
    return MR_SUCCESS;

  /* Otherwise fail. */
  return MR_PERM;
}



home help back first fref pref prev next nref lref last post