234 lines
8.1 KiB
C
234 lines
8.1 KiB
C
/****************************************************************************
|
|
|
|
|
| (C) Copyright 1996 Novell, Inc.
|
|
| All Rights Reserved.
|
|
|
|
|
| This program is free software; you can redistribute it and/or
|
|
| modify it under the terms of version 2 of the GNU General Public
|
|
| License as published by the Free Software Foundation.
|
|
|
|
|
| This program is distributed in the hope that it will be useful,
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| GNU General Public License for more details.
|
|
|
|
|
| You should have received a copy of the GNU General Public License
|
|
| along with this program; if not, contact Novell, Inc.
|
|
|
|
|
| To contact Novell about this file by physical or electronic mail,
|
|
| you may find current contact information at www.novell.com
|
|
|
|
|
|***************************************************************************
|
|
|
|
|
| NetWare Advance File Services (NSS) Authorization module
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
|
|
|
| $Author: taysom $
|
|
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
|
|
|
|
| $RCSfile$
|
|
| $Revision: 465 $
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
| This module is used to:
|
|
| This module defines information for using the Z Authorization System.
|
|
|
|
|
| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
|
|
|
|
|
| This header file should ONLY be used for NSS internal development.
|
|
| This includes Semantic Agents (SA) and Loadable Storage Services (LSS).
|
|
| Any other use may cause conflicts which NSS will NOT fix.
|
|
+-------------------------------------------------------------------------*/
|
|
#ifndef _COMNZAS_H_
|
|
#define _COMNZAS_H_
|
|
|
|
#ifndef _OMNI_H_
|
|
#include <library/omni.h>
|
|
#endif
|
|
|
|
//#ifndef _COMNAUTHORIZE_H_
|
|
//#include <comnAuthorize.h>
|
|
//#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define zLEGACY_VALID_TRUSTEE_RIGHTS 0xFF /* All access rights for legacy NCPs*/
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Bit definitaions for authorization attributes
|
|
*-------------------------------------------------------------------------*/
|
|
#define zAUTHORIZE_INHERIT_DOWN 0x8000
|
|
#define zAUTHORIZE_INHERIT_UP 0x4000 /* make directories above this file visible */
|
|
#define zAUTHORIZE_NEGATIVE_RIGHTS 0x2000 /* all other bits will be ignored if set*/
|
|
|
|
|
|
#define zVALID_TRUSTEE_ATTRIBUTES \
|
|
(zAUTHORIZE_INHERIT_DOWN | zAUTHORIZE_INHERIT_UP | \
|
|
zAUTHORIZE_NEGATIVE_RIGHTS)
|
|
|
|
#define BEAST_STACK_ALLOC_SIZE 10
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Structures
|
|
*-------------------------------------------------------------------------*/
|
|
|
|
typedef struct ACLEntry_s
|
|
{ /* an access control list entry */
|
|
UserID_t trusteeID; /* an authenticated ID */
|
|
WORD rights; /* the rights mask */
|
|
WORD attributes; /* the mode and status bits */
|
|
} NSS_MEDIA_STRUCTURE(ACLEntry_s,attributes) ACLEntry_s;
|
|
|
|
/*
|
|
* WARNING -- If this structure changes make sure it does not break
|
|
* VisibilityEntry_s (nssPubs.h) and the routines that use it (such as
|
|
* GetVisibilityList
|
|
*/
|
|
typedef struct VisEntry_s
|
|
{ /* a visiblity list entry */
|
|
UserID_t trusteeID; /* an authenticated ID */
|
|
LONG count; /* count of times used below this entry */
|
|
} NSS_MEDIA_STRUCTURE(VisEntry_s,count) VisEntry_s;
|
|
|
|
/*
|
|
* The following structures are used during on-the-fly upgrading from version 1
|
|
* to version 2 of the auth structures. They can be removed when we are no
|
|
* longer doing the conversion in the ZAS unpack routines.
|
|
*/
|
|
|
|
typedef struct V1_ACLEntry_s
|
|
{ /* an access control list entry (beast version 1)*/
|
|
LONG trusteeID; /* an authenticated ID */
|
|
WORD rights; /* the rights mask */
|
|
WORD attributes; /* the mode and status bits */
|
|
} NSS_MEDIA_STRUCTURE(V1_ACLEntry_s,attributes) V1_ACLEntry_s;
|
|
|
|
typedef struct V1_VisEntry_s
|
|
{ /* a visiblity list entry (beast version 1)*/
|
|
LONG trusteeID; /* an authenticated ID */
|
|
LONG count; /* count of times used below this entry */
|
|
} NSS_MEDIA_STRUCTURE(V1_VisEntry_s,count) V1_VisEntry_s;
|
|
|
|
|
|
/****************************************************************************
|
|
*
|
|
* Z Authorization ACL Overflow Beast
|
|
*
|
|
*****************************************************************************/
|
|
|
|
typedef struct PersistentZasAclOverflowBeast_s
|
|
{
|
|
Zid_t nextOverflowZid; /* link to the next overflow beast */
|
|
LONG numEntries; /* number of overflow entries currently in use*/
|
|
} NSS_MEDIA_STRUCTURE(PersistentZasAclOverflowBeast_s,numEntries) PersistentZasAclOverflowBeast_s;
|
|
|
|
|
|
typedef struct ZasAclOverflowBeast_s
|
|
{
|
|
RootBeast_s root;
|
|
NINT numAlloced; /* amount of space alloced for entries */
|
|
ACLEntry_s *acl; /* PERSISTENT access control list */
|
|
PersistentZasAclOverflowBeast_s p;
|
|
} ZasAclOverflowBeast_s;
|
|
|
|
#define ACLOroot root
|
|
|
|
#define ACLOzid ACLOroot.zid
|
|
#define ACLObeastVersion ACLOroot.beastVersion
|
|
#define ACLObeastClass ACLOroot.beastClass
|
|
#define ACLObeastLatch ACLOroot.mycache.agent.latch
|
|
#define ACLObstState ACLOroot.bstState
|
|
#define ACLOvolume ACLOroot.vol.volume
|
|
#define ACLOcomnOps ACLObeastClass->comnOps
|
|
|
|
/****************************************************************************
|
|
*
|
|
* Z Authorization Visibility Overflow Beast
|
|
*
|
|
*****************************************************************************/
|
|
|
|
typedef struct PersistentZasVisOverflowBeast_s
|
|
{
|
|
Zid_t nextOverflowZid; /* link to the next overflow beast */
|
|
LONG numEntries; /* number of overflow entries */
|
|
} NSS_MEDIA_STRUCTURE(PersistentZasVisOverflowBeast_s,numEntries) PersistentZasVisOverflowBeast_s;
|
|
|
|
|
|
typedef struct ZasVisOverflowBeast_s
|
|
{
|
|
RootBeast_s root;
|
|
NINT numAlloced; /* amount of space alloced for entries */
|
|
VisEntry_s *vis; /* PERSISTENT visibility list */
|
|
PersistentZasVisOverflowBeast_s p;
|
|
} ZasVisOverflowBeast_s;
|
|
|
|
#define VISOroot root
|
|
|
|
#define VISOzid VISOroot.zid
|
|
#define VISObeastVersion VISOroot.beastVersion
|
|
#define VISObeastClass VISOroot.beastClass
|
|
#define VISObeastLatch VISOroot.mycache.agent.latch
|
|
#define VISObstState VISOroot.bstState
|
|
#define VISOuseCount VISOroot.useCount
|
|
#define VISOvolume VISOroot.vol.volume
|
|
#define VISOcomnOps VISObeastClass->comnOps
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Macros
|
|
*-------------------------------------------------------------------------*/
|
|
|
|
/* Add to the beast stack. Expand if needed. */
|
|
#define ZAS_PUSH_BEAST(_status, _errlab, _bstPtr, _stackPtr, _maxentries, _bstmem, _bststk) \
|
|
{ \
|
|
/* this macro assumes an original allocation of BEAST_STACK_ALLOC_SIZE */ \
|
|
if ((_stackPtr) >= _maxentries) \
|
|
{ \
|
|
(_maxentries) += BEAST_STACK_ALLOC_SIZE; \
|
|
if ((_maxentries) == 2 * BEAST_STACK_ALLOC_SIZE) \
|
|
{ /* if we are working from a non-mallac buffer */ \
|
|
(_bststk) = malloc(sizeof(AuthBeast_s *) * (_maxentries)); \
|
|
if ((_bststk) == NULL) \
|
|
{ \
|
|
(_status) = zERR_NO_MEMORY; \
|
|
goto _errlab; \
|
|
} \
|
|
memcpy((_bststk), &(_bstmem), sizeof(AuthBeast_s *) * BEAST_STACK_ALLOC_SIZE); \
|
|
} \
|
|
else \
|
|
{ \
|
|
void *_tmpptr; \
|
|
(_tmpptr) = realloc((_bststk), sizeof(AuthBeast_s *) * (_maxentries)); \
|
|
if ((_tmpptr) == NULL) \
|
|
{ \
|
|
(_status) = zERR_NO_MEMORY; \
|
|
goto _errlab; \
|
|
} \
|
|
(_bststk) = (_tmpptr); \
|
|
} \
|
|
} \
|
|
(*(_bststk))[(_stackPtr)++] = (_bstPtr); \
|
|
}
|
|
|
|
/* Release all beast on the beast stack and release stack memory */
|
|
#define ZAS_CLEANUP_BEAST_STACK(_stackPtr, _maxentries, _bststk) \
|
|
{ \
|
|
while ((_stackPtr) > 0) \
|
|
{ \
|
|
--(_stackPtr);/*UNX_LATCH(&((*(_bststk))[--(_stackPtr)]->AUTHauthInfo.zas->authLatch));*/ \
|
|
COMN_Release(&(*(_bststk))[(_stackPtr)]); \
|
|
} \
|
|
if ((_maxentries) > BEAST_STACK_ALLOC_SIZE) \
|
|
{ /* we have malloced memory for the stack */ \
|
|
free(_bststk); \
|
|
} \
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _COMNZAS_H_ */
|