From:	SMTP%"carl@SOL1.GPS.CALTECH.EDU" 31-MAR-1994 09:20:35.71
To:	EVERHART
CC:	
Subj:	RE: Determining someone elses process rights

From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
X-Newsgroups: comp.os.vms
Subject: RE: Determining someone elses process rights
Date: 13 Mar 1994 20:35:41 GMT
Organization: HST Wide Field/Planetary Camera
Lines: 64
Distribution: world
Message-Id: <2lvteu$sph@gap.cco.caltech.edu>
Reply-To: carl@SOL1.GPS.CALTECH.EDU
Nntp-Posting-Host: sol1.gps.caltech.edu
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET

In article <0097B5FD.B94577C0.18534@sgi.siemens.com>, olive@sgi.siemens.com (Chris Olive (x7793)) writes:
=        How about using SYS$FIND_HELD?  That would be the better method to
=use over parsing output from AUTHORIZE.  In the case of AUTHORIZE, you're
=going to need SYSPRV, and I *think* you need SYSPRV (or GRPPRV) in the case
=of $FIND_HELD as well, although I'm not for sure (since pre-v6.0 VMS allows
=all users read access to RIGHTSLIST.DAT, and with a little knowledge of the
=file format of RIGHTSLIST, some bit-mask magic, and expertise with F$FAO and
=F$IDENTIFIER, this information can be had in a simple DCL command procedure
=even from a completely non-privileged account).

Please note that you've also got to use SYS$IDTOASC and SYS$GETUAI if you're
going to use SYS$FIND_HELD (and want to be able to specify the username and get
ascii versions of the identifiers held by the uic corresponding to that
username:  Remember:  You can't count on the username and the corresponding UIC
rightslist identifier being identical).  The program logic goes as follows:
	Use SYS$GETUAI to convert username to UIC.
	Repeatedly use SYS$FIND_HELD to get the rightslist identifiers held by
		that UIC, and SYS$IDTOASC to convert those to strings.
Here's an example:

#include rmsdef
#include ssdef
#include uaidef
#include descrip
unsigned long stat;
#define ckstat(x) if (((stat = x) & 7) != 1) SYS$EXIT(stat)
#define $DESCRIPTOR_D(name) struct dsc$descriptor_d name = \
		{ 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0 }
demo()
{	$DESCRIPTOR_D(usrnam);
	$DESCRIPTOR(usage, "Usage:  FIND_HELD username");
	$DESCRIPTOR(prompt, "Enter next username: ");
	char buff[65];
 	$DESCRIPTOR(nambuf, buff);
	unsigned long context = 0, uic[2] = { 0, 0 }, id;
	struct ITEM_LIST_3
	{	unsigned short buflen, itmcod;
		unsigned long bufadr, reslen;
	} itmlst[] =
	{	{ 8, UAI$_UIC, uic, 0 },
		{ 0, 0, 0, 0 }
	};

	while((((stat = LIB$GET_INPUT(&usrnam, &prompt)) & 7) == 1) &&
		(usrnam.dsc$w_length != 0))
	{	ckstat(SYS$GETUAI(0, 0, &usrnam, itmlst, 0, 0, 0));
		while((((stat = SYS$FIND_HELD(uic, &id, 0, &context)) & 7) == 1)
			&& (((stat = SYS$IDTOASC(id, &nambuf.dsc$w_length,
			&nambuf, 0, 0, 0)) & 7) == 1))
		{	LIB$PUT_OUTPUT(&nambuf);
			nambuf.dsc$w_length = 64;
		}
		if(stat != SS$_NOSUCHID) SYS$EXIT(stat);
	}
	SYS$EXIT(stat == RMS$_EOF ? SS$_NORMAL : stat);
}
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.

