[1773] 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:03:25 2001

Message-Id: <200104261703.NAA06257@melbourne-city-street.mit.edu>
Date: Thu, 26 Apr 2001 12:58:31 -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"

Thanks for fixing the problems in the code. I am testing
the other queries and I will have to make the following changes. I
will submit a patch if you prefer. Sorry about the trouble:

In qaccess.pc, because the container id is the second argument
in amcn and dmcn, access_container is not working properly. 

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") && strcmp(q->shortname, "dmcn"))
	cnt_id = *(int *)argv[1];

  EXEC SQL SELECT acl_id, acl_type, memacl_id, memacl_type, cname
    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;
}

In Queries2.c the argc for gmoc and gsoc should be 2 instead of 0:

{
    /* Q_GMOC - GET_MACHINES_OF_CONTAINER, v7 */
    "get_machines_of_container",
    "gmoc",
    7,
    RETRIEVE,
    NULL,
    MCNTMAP_TABLE,
    NULL,
    gmoc_fields,
    2,
    NULL,
    2,
    NULL,
    &gmoc_validate,
  },

  {
    /* Q_GSOC - GET_SUBCONTAINERS_OF_CONTAINER, v7 */
    "get_subcontainers_of_container",
    "gsoc",
    7,
    RETRIEVE,
    NULL,
    CONTAINERS_TABLE,
    NULL,
    gsoc_fields,
    1,
    NULL,
    2,
    NULL,
    &gsoc_validate,
  },


At 07:07 PM 4/25/2001 -0400, Garry Zacheiss wrote:
>	No patch is necessary; I've made this changed, and also fixed
>two other bugs.  In update_container() in qsupport.pc, you were
>selecting from the table "container" instead of "containers" in one
>place, and also opening the cursor csr_ucon but closing csr_gubr.  The
>"ucon" query looks like it's working now.
>
>Garry
> 


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