示例#1
0
文件: fsal_compat.c 项目: ic-hep/emi3
fsal_status_t WRAP_HPSSFSAL_InitClientContext(fsal_op_context_t * p_thr_context)
{
  return HPSSFSAL_InitClientContext((hpssfsal_op_context_t *) p_thr_context);
}
示例#2
0
fsal_status_t HPSSFSAL_GetClientContext(hpssfsal_op_context_t * p_thr_context,  /* IN/OUT  */
                                        hpssfsal_export_context_t * p_export_context,   /* IN */
                                        fsal_uid_t uid, /* IN */
                                        fsal_gid_t gid, /* IN */
                                        fsal_gid_t * alt_groups,        /* IN */
                                        fsal_count_t nb_alt_groups      /* IN */
    )
{

  fsal_count_t ng = nb_alt_groups;
  unsigned int i;
  fsal_status_t st;

  /* sanity check */
  if(!p_thr_context || !p_export_context)
    Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetClientContext);

  /* if the credential is too old, renew it */
  if(time(NULL) - p_thr_context->credential.last_update > (int)CredentialLifetime)
    {
      st = HPSSFSAL_InitClientContext(p_thr_context);
      if(FSAL_IS_ERROR(st))
        return st;
    }

  /* set the export specific context */
  p_thr_context->export_context = p_export_context;

  /* Extracted from  /opt/hpss/src/nfs/nfsd/nfs_Dispatch.c */

#if HPSS_MAJOR_VERSION == 5
  strcpy(p_thr_context->credential.hpss_usercred.SecPWent.Name, "NFS.User");
  p_thr_context->credential.hpss_usercred.SecLabel = 0; /* Symbol? */
  p_thr_context->credential.hpss_usercred.CurAccount = ACCT_REC_DEFAULT;
  p_thr_context->credential.hpss_usercred.DefAccount = ACCT_REC_DEFAULT;
  p_thr_context->credential.hpss_usercred.SecPWent.Uid = uid;
  p_thr_context->credential.hpss_usercred.SecPWent.Gid = gid;
#elif  (HPSS_MAJOR_VERSION == 6) || (HPSS_MAJOR_VERSION == 7)
  strcpy(p_thr_context->credential.hpss_usercred.Name, "NFS.User");
  p_thr_context->credential.hpss_usercred.CurAccount = ACCT_REC_DEFAULT;
  p_thr_context->credential.hpss_usercred.DefAccount = ACCT_REC_DEFAULT;
  p_thr_context->credential.hpss_usercred.Uid = uid;
  p_thr_context->credential.hpss_usercred.Gid = gid;
#endif

  if(ng > HPSS_NGROUPS_MAX)
    ng = HPSS_NGROUPS_MAX;

  if((ng > 0) && (alt_groups == NULL))
    Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetClientContext);

  p_thr_context->credential.hpss_usercred.NumGroups = ng;

  for(i = 0; i < ng; i++)
    p_thr_context->credential.hpss_usercred.AltGroups[i] = alt_groups[i];

#if (HPSS_MAJOR_VERSION == 5)

  /* traces: prints p_credential structure */
  if (isFullDebug(COMPONENT_FSAL))
    {
      LogFullDebug(COMPONENT_FSAL, "credential modified:");
      LogFullDebug(COMPONENT_FSAL, "\tuid = %d, gid = %d",
                    p_thr_context->credential.hpss_usercred.SecPWent.Uid,
                    p_thr_context->credential.hpss_usercred.SecPWent.Gid);
      LogFullDebug(COMPONENT_FSAL, "\tName = %s",
                    p_thr_context->credential.hpss_usercred.SecPWent.Name);

      for(i = 0; i < p_thr_context->credential.hpss_usercred.NumGroups; i++)
	LogFullDebug(COMPONENT_FSAL, "\tAlt grp: %d",
                      p_thr_context->credential.hpss_usercred.AltGroups[i]);
    }
#elif ( HPSS_MAJOR_VERSION == 6 )

  /* traces: prints p_credential structure */
  if (isFullDebug(COMPONENT_FSAL))
    {
      LogFullDebug(COMPONENT_FSAL, "credential modified:");
      LogFullDebug(COMPONENT_FSAL, "\tuid = %d, gid = %d",
                    p_thr_context->credential.hpss_usercred.Uid,
                    p_thr_context->credential.hpss_usercred.Gid);
      LogFullDebug(COMPONENT_FSAL, "\tName = %s",
                    p_thr_context->credential.hpss_usercred.Name);

      for(i = 0; i < p_thr_context->credential.hpss_usercred.NumGroups; i++)
	LogFullDebug(COMPONENT_FSAL, "\tAlt grp: %d",
                      p_thr_context->credential.hpss_usercred.AltGroups[i]);
    }
#elif ( HPSS_MAJOR_VERSION == 7 )

  /* traces: prints p_credential structure */
  if (isFullDebug(COMPONENT_FSAL))
    {
      LogFullDebug(COMPONENT_FSAL, "credential modified:");
      LogFullDebug(COMPONENT_FSAL, "\tuid = %d, gid = %d",
                    p_thr_context->credential.hpss_usercred.Uid,
                    p_thr_context->credential.hpss_usercred.Gid);
      LogFullDebug(COMPONENT_FSAL, "\tName = %s",
                    p_thr_context->credential.hpss_usercred.Name);

      for(i = 0; i < p_thr_context->credential.hpss_usercred.NumGroups; i++)
	LogFullDebug(COMPONENT_FSAL, "\tAlt grp: %d",
                      p_thr_context->credential.hpss_usercred.AltGroups[i]);
    }
#endif

  Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_GetClientContext);

}