tldm-universe/Ardent/UV/APP.PROGS/PERMS.B

80 lines
2.8 KiB
Plaintext
Raw Permalink Normal View History

2024-09-09 21:51:08 +00:00
******************************************************************************
*
* Permissions handling subroutine for UniVerse Files
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Ardent Software Inc.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*
*******************************************************************************
*
* Maintenence log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description.........................................
* 10/14/98 23801 SAP Change copyrights.
* 01/31/94 12895 DMK Check supplementary groups via SYSTEM(1017).
* 01/06/93 10825 PVW Root has valid permissions regardless.
* 12/21/92 10696 PVW Created subroutine.
*
*******************************************************************************
SUBROUTINE PERMISSIONS (FILE, MODE, IN, OUT)
* FILE - contains the file variable
* MODE - contains the mode of operation
* 0 - return the permission and file type
* 1 - return TRUE or FALSE flag for requested permissions
* 99 - subroutine failed
* IN - contains data passed into the subroutine
* if MODE = 0 then null
* MODE = 1 then requested permissions
* OUT - contains data passed out of the subroutine
* if MODE = 0 then attribute 1 is the permissions
* attribute 2 is the file type
* if MODE = 1 then attribute 1 contains TRUE or FALSE
* flag requested permissions okay
*
OUT = ''
STATUS FILE.INFO FROM FILE THEN
FILE.PERM = OCONV(FILE.INFO<5>,"MO") "R%7"
I = LEN(FILE.PERM)
FILE.TYPE = FILE.PERM[I-6,I-4]
FILE.PERM = FILE.PERM[I-2,I]
BEGIN CASE
CASE MODE = 0
OUT<1> = FILE.PERM
OUT<2> = FILE.TYPE
CASE MODE = 1
REQUESTED.PERM = IN<1>
EFFECTIVE.USER.ID = SYSTEM(28)
GROUP.LIST = SYSTEM(30) ;* primary group
GROUP.LIST<-1> = SYSTEM(1017) ;* supplementary groups
FILE.USER.ID = FILE.INFO<8>
FILE.GROUP.ID = FILE.INFO<9>
IF EFFECTIVE.USER.ID = FILE.USER.ID THEN
FILE.PERM = FILE.PERM[1,1]
END ELSE
LOCATE FILE.GROUP.ID IN GROUP.LIST SETTING POS THEN
FILE.PERM = FILE.PERM[2,1]
END ELSE
FILE.PERM = FILE.PERM[3,1]
END
END
IF REQUESTED.PERM = BITAND(REQUESTED.PERM,FILE.PERM) THEN
OUT<1> = 1
END
IF EFFECTIVE.USER.ID = 0 THEN
OUT<1> = 1
END
END CASE
END ELSE
MODE = 99
END
RETURN
END