From:	SMTP%"everhart@star.zko.dec.com" 20-JUN-1996 19:43:12.36
To:	EVERHART
CC:	
Subj:	persona.src

Date: Thu, 20 Jun 1996 17:15:12 -0400
Message-Id: <96062017151175@star.zko.dec.com>
From: everhart@star.zko.dec.com (Glenn C. Everhart 603 881 1497)
To: everhart@gce.mv.com
Subject: persona.src
X-VMS-To: SMTP%"everhart@gce.mv.com"

              <<< VAXAXP::NOTES$:[NOTES$LIBRARY]VMSNOTES.NOTE;1 >>>
               -< VAX and Alpha VMS - Digital Internal Use Only >-
================================================================================
Note 1062.5            SYS$PERSONA and system () DEC C RTL                5 of 8
XDELTA::HOFFMAN "Steve, OpenVMS Engineering"         52 lines  20-JUN-1996 08:56
                           -< This Works Under V7.0 >-
--------------------------------------------------------------------------------

   The following code operates as expected under OpenVMS VAX V7.0:

#include  <descrip.h>
#include  <impdef.h>
#include  <lib$routines.h>
#include  <processes.h>
#include  <ssdef.h>
#include  <starlet.h>
#include  <stdlib.h>
#include  <string.h>
#include  <stsdef.h>
    
main()
    {

    /* until these sys$ calls are in starlet.h... */
    int sys$persona_create( void *,void *,int );
    int sys$persona_assume( void *, int );
    int sys$persona_delete( void * );

    int pers, status;
    struct dsc$descriptor user_dscr;
    $DESCRIPTOR(cmnd_dscr,"DIR");
    char *username = getenv("USER");

    /*
    //	Load the getenv-returned username into a descriptor.
    */
    user_dscr.dsc$w_length  = strlen( username );
    user_dscr.dsc$b_dtype   = DSC$K_DTYPE_T;
    user_dscr.dsc$b_class   = DSC$K_CLASS_S;
    user_dscr.dsc$a_pointer = username;

    status = lib$spawn(&cmnd_dscr);
    if (!$VMS_STATUS_SUCCESS( status )) return status;

    status = sys$persona_create(&pers,&user_dscr,IMP$M_ASSUME_DEFPRIV);
    if (!$VMS_STATUS_SUCCESS( status )) return status;

    status = sys$persona_assume( &pers,
	IMP$M_ASSUME_SECURITY|IMP$M_ASSUME_JOB_WIDE );
    if (!$VMS_STATUS_SUCCESS( status )) return status;

    status = lib$spawn(&cmnd_dscr);
    if (!$VMS_STATUS_SUCCESS( status )) return status;

    status = sys$persona_delete(&pers);
    if (!$VMS_STATUS_SUCCESS( status )) return status;

    return status;
    }
