Google
 

Trailing-Edge - PDP-10 Archives - DEC_CMS-20_V1.0_SRC - cms/sources/chkprv.bli
There are no other files named chkprv.bli in the archive.
MODULE chkprv	(
		IDENT = '1',
		%IF
		    %BLISS(BLISS32)
		%THEN
		    LANGUAGE(BLISS32),
		    ADDRESSING_MODE(EXTERNAL=LONG_RELATIVE,
				    NONEXTERNAL=LONG_RELATIVE)
		%ELSE
		    LANGUAGE(BLISS36)
		%FI
		) =
BEGIN

!
!			  COPYRIGHT (c) 1982 BY
!	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
!
! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
! ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH  LICENSE AND WITH THE
! INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR  ANY  OTHER
! COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
! OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
! TRANSFERRED.
!
! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE  WITHOUT  NOTICE
! AND  SHOULD  NOT  BE  CONSTRUED  AS  A COMMITMENT BY DIGITAL EQUIPMENT
! CORPORATION.
!
! DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY  OF  ITS
! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
!

!++
! FACILITY:	CMS Library Processor
!
! ABSTRACT:
!
!	Check user privileges and lower them if they are too high.
!
! ENVIRONMENT:	VAX/VMS, DS-20
!
! AUTHOR: D. Knight
!
!--
!
! TABLE OF CONTENTS
!

FORWARD ROUTINE
	chkprv;				!Check privileges

!
! INCLUDE FILES:
!

%if %bliss(bliss32) %then
    library 'sys$library:starlet';
%else
    require 'jsys:';
%fi

library 'xport:';

require 'blissx:';

%if %bliss(bliss32) %then

!
! MACROS:
!

macro
	priv1 = 0,0,32,0 %,		!mask word #1
	priv2 = 1,0,32,0 %;		!mask word #2

!
! EQUATED SYMBOLS:
!

literal
	block_size=2,			!mask size
	disable_prv=0,			!disable selected privileges
	enable_prv=1,			!enable selected privileges
	permanent=1,			!permanent indicator
	temporary=0;			!temporary indicator

%fi

!
! OWN STORAGE:
!

!
! EXTERNAL REFERENCES:
!
external routine
	bugsts;
GLOBAL ROUTINE chkprv =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Check the user's privileges.  If he has SYSPRV or BYPASS, then
!	remove them for the duration of the command.  This is necessary
!	to prevent a privileged user outside of the group that owns the
!	library from using the library and unknowingly causing new files
!	to be placed in the library which are not accessible to the
!	owners of the library.
!
! FORMAL PARAMETERS:
!
!	none.
!
! IMPLICIT INPUTS:
!
!	NONE.
!
! IMPLICIT OUTPUTS:
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	TRUE - privileges were removed
!	FALSE - no privileges were removed
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

    BEGIN

%if %bliss(bliss36) %then

    !There is no problem on the 20 or 10
    return false

%fi

%if %bliss(bliss32) %then

    local
	priv_flags : block[block_size],	!This is where we keep the values
	status;

    !Pick up the privilege bits to look at.
    if
	not (status=$setprv(enbflg=disable_prv,prvadr=0,
		prmflg=temporary,prvprv=priv_flags))
    then
	bugsts(.status,lit('Can''t get privileges (CHKPRV)'));

    !See if any of the ones we don't want are present.
    if
	.priv_flags[prv$v_bypass] or
	.priv_flags[prv$v_sysprv]
    then
	!We must remove SYSPRV or BYPASS before continuing
	begin

	!Clear the mask
	priv_flags[priv1]=0;
	priv_flags[priv2]=0;

	!Set which privileges are to be removed
	priv_flags[prv$v_bypass]=1;
	priv_flags[prv$v_sysprv]=1;

	!Now remove the privileges
	if
	    not (status=$setprv(enbflg=disable_prv,prvadr=priv_flags,
				prmflg=temporary,prvprv=0))
	then
	    bugsts(.status,lit('Can''t reset privileges (CHKPRV)'));

	return true
	end
    else
	return false
%fi

    END;				!End of CHKPRV
END				!End of Module CHKPRV
ELUDOM