Ejemplo n.º 1
0
int
decode_arst(struct attribute *patr, char *name, char *rescn, char *val)
{
    int	  rc;
    attribute temp;

    if ((val == (char *)0) || (strlen(val) == 0)) {
        free_arst(patr);
        /* _SET cleared in free_arst */
        patr->at_flags |= ATR_VFLAG_MODIFY | ATR_VFLAG_MODCACHE;

        return (0);
    }

    if ((patr->at_flags & ATR_VFLAG_SET) && (patr->at_val.at_arst)) {
        /* already have values, decode new into temp	*/
        /* then use set(incr) to add new to existing	*/

        temp.at_flags   = 0;
        temp.at_type    = ATR_TYPE_ARST;
        temp.at_user_encoded = NULL;
        temp.at_priv_encoded = NULL;
        temp.at_val.at_arst = 0;
        if ((rc = decode_arst_direct(&temp, val)) != 0)
            return (rc);
        rc = set_arst(patr, &temp, SET);
        free_arst(&temp);
        return (rc);

    } else {
        /* decode directly into real attribute */
        return (decode_arst_direct(patr, val));
    }
}
Ejemplo n.º 2
0
int node_acl(
  pbs_attribute *new_attr,     /*derive props into this pbs_attribute*/
  void          *pnode,   /*pointer to a pbsnode struct     */
  int            actmode) /*action mode; "NEW" or "ALTER"   */

  {
  int   rc = 0;

  struct pbsnode  *np;
  pbs_attribute    temp;

  np = (struct pbsnode*)pnode; /*because of at_action arg type*/

  switch (actmode)
    {

    case ATR_ACTION_NEW:

      /* if node has a property list, then copy array_strings    */
      /* into temp to use to setup a copy, otherwise setup empty */

      if (np->nd_acl != NULL)
        {
        /* setup temporary pbs_attribute with the array_strings */
        /* from the node        */

        temp.at_val.at_arst = np->nd_acl;
        temp.at_flags = ATR_VFLAG_SET;
        temp.at_type  = ATR_TYPE_ARST;

        rc = set_arst(new_attr, &temp, SET);
        }
      else
        {
        /* Node has no properties, setup empty pbs_attribute */

        new_attr->at_val.at_arst = 0;
        new_attr->at_flags       = 0;
        new_attr->at_type        = ATR_TYPE_ARST;
        }

      break;

    case ATR_ACTION_ALTER:

      /* update node with new attr_strings */

      np->nd_acl = new_attr->at_val.at_arst;

      break;

    default:

      rc = PBSE_INTERNAL;

      break;
    }  /* END switch(actmode) */

  return(rc);
  }  /* END node_prop_list() */
Ejemplo n.º 3
0
int decode_arst_merge(

  pbs_attribute *patr,    /* O (modified) */
  char          *name,    /* I pbs_attribute name (notused) */
  char          *rescn,   /* I resource name (notused) */
  char          *val)     /* I pbs_attribute value */

  {
  int           rc;
  pbs_attribute new_attr;
  pbs_attribute tmp;

  if ((val == NULL) || (strlen(val) == 0))
    {
    free_arst(patr);

    patr->at_flags &= ~ATR_VFLAG_MODIFY; /* _SET cleared in free_arst */

    return(0);
    }

  if (!(patr->at_flags & ATR_VFLAG_SET) || (patr->at_val.at_arst == NULL))
    {
    /* decode directly into real pbs_attribute */

    return(decode_arst_direct(patr,val));
    }

  memset(&new_attr,0x0,sizeof(pbs_attribute));
  memset(&tmp,0x0,sizeof(pbs_attribute));

  /* already have values, decode new into temp */
  /* then use set(incr) to add new to existing */

  /* convert value string into pbs_attribute array */

  if ((rc = decode_arst_direct(&new_attr,val)) != 0)
    {
    /* FAILURE */

    return(rc);
    }

  /* copy patr to temp, and new to patr */

  tmp.at_val.at_arst = patr->at_val.at_arst;
  patr->at_val.at_arst = new_attr.at_val.at_arst;

  /* incr original patr value onto new patr */

  tmp.at_flags |= ATR_VFLAG_SET;
  rc = set_arst(patr,&tmp,MERGE);

  free_arst(&tmp);

  return(rc);
  }  /* END decode_arst_merge() */
Ejemplo n.º 4
0
int decode_arst(

  pbs_attribute *patr,    /* O (modified) */
  char          *name,    /* I pbs_attribute name (notused) */
  char          *rescn,   /* I resource name (notused) */
  char          *val,     /* I pbs_attribute value */
  int            perm) /* only used for resources */

  {
  int           rc;
  pbs_attribute temp;

  if ((val == NULL) || (strlen(val) == 0))
    {
    free_arst(patr);

    patr->at_flags &= ~ATR_VFLAG_MODIFY; /* _SET cleared in free_arst */

    return(0);
    }

  memset(&temp, 0, sizeof(pbs_attribute));

  if ((patr->at_flags & ATR_VFLAG_SET) && (patr->at_val.at_arst))
    {
    /* already have values, decode new into temp */
    /* then use set(incr) to add new to existing */


    /* convert value string into pbs_attribute array */

    if ((rc = decode_arst_direct(&temp,val)) != 0)
      {
      /* FAILURE */

      return(rc);
      }

    rc = set_arst(patr,&temp,INCR);

    free_arst(&temp);

    return(rc);
    }

  /* decode directly into real pbs_attribute */

  return(decode_arst_direct(patr,val));
  }  /* END decode_arst() */
Ejemplo n.º 5
0
int set_acl_arst(

  pbs_attribute *attr,  /* I/O */
  pbs_attribute *new_attr,   /* I */
  enum batch_op     op)    /* I */

  {

  struct array_strings *newpas = NULL;

  assert(attr && new_attr && (new_attr->at_flags & ATR_VFLAG_SET));

  newpas = new_attr->at_val.at_arst;

  //Empty input so empty the output.
  if (newpas == NULL)
    {
    if(op == SET)
      {
      free_arst(attr);
      attr->at_flags |= ATR_VFLAG_SET | ATR_VFLAG_MODIFY;
      }
    return(PBSE_NONE);
    }
  int rc = set_arst(attr,new_attr,op);
  if(rc != PBSE_NONE)
    {
    return(rc);
    }
  if(attr->at_val.at_arst->as_usedptr == 0)
    {
    free_arst(attr);
    attr->at_flags |= ATR_VFLAG_SET | ATR_VFLAG_MODIFY;
    }
  return(PBSE_NONE);
  }
Ejemplo n.º 6
0
int node_status_list(

  pbs_attribute *new_attr,           /*derive status into this pbs_attribute*/
  void          *pnode,         /*pointer to a pbsnode struct     */
  int            actmode)       /*action mode; "NEW" or "ALTER"   */

  {
  int              rc = 0;

  struct pbsnode  *np;
  pbs_attribute    temp;

  np = (struct pbsnode *)pnode;    /* because of at_action arg type */

  switch (actmode)
    {

    case ATR_ACTION_NEW:

      /* if node has a status list, then copy array_strings    */
      /* into temp to use to setup a copy, otherwise setup empty */

      if (np->nd_status != NULL)
        {
        /* setup temporary pbs_attribute with the array_strings */
        /* from the node                                    */

        temp.at_val.at_arst = np->nd_status;
        temp.at_flags = ATR_VFLAG_SET;
        temp.at_type  = ATR_TYPE_ARST;

        rc = set_arst(new_attr, &temp, SET);
        }
      else
        {
        /* node has no properties, setup empty pbs_attribute */

        new_attr->at_val.at_arst = NULL;
        new_attr->at_flags       = 0;
        new_attr->at_type        = ATR_TYPE_ARST;
        }

      break;

    case ATR_ACTION_ALTER:

      if (np->nd_status != NULL)
        {
        free(np->nd_status->as_buf);
        free(np->nd_status);

        np->nd_status = NULL;
        }

      /* update node with new attr_strings */

      np->nd_status = new_attr->at_val.at_arst;

      new_attr->at_val.at_arst = NULL;
      /* update number of status items listed in node */
      /* does not include name and subnode property */

      if (np->nd_status != NULL)
        np->nd_nstatus = np->nd_status->as_usedptr;
      else
        np->nd_nstatus = 0;

      break;

    default:

      rc = PBSE_INTERNAL;

      break;
    }  /* END switch(actmode) */

  return(rc);
  }  /* END node_status_list() */