              <<< VAXAXP::NOTES$:[NOTES$LIBRARY]VMSNOTES.NOTE;1 >>>
               -< VAX and Alpha VMS - Digital Internal Use Only >-
================================================================================
Note 1335.4                    Group logical names                        4 of 4
BSS::JILSON "WFH in the Chemung River Valley"       179 lines   7-AUG-1996 10:58
                                -< From STARS >-
--------------------------------------------------------------------------------
[OpenVMS] How To Create GROUP Logical Name Tables At Boot Time

     Any party granted access to the following copyrighted information
     (protected under Federal Copyright Laws), pursuant to a duly executed
     Digital Service Agreement may, under the terms of such agreement copy
     all or selected portions of this information for internal use and
     distribution only. No other copying or distribution for any other
     purpose is authorized.
Copyright (c) Digital Equipment Corporation 1991, 1993. All rights reserved

PRODUCT:    VAX VMS Versions 4.n
            OpenVMS VAX, Versions 5.0 and above

COMPONENT:  Logicals

SOURCE:     Digital Equipment Corporation


OVERVIEW:

Creating GROUP logical name tables during boot time or startup is
not as straightforward as it may seem.  The following commands look
like they should create a logical name table for group [5,*]:

    $ SET UIC [5,0]
    $ CREATE/NAME_TABLE/EXECUTIVE/PARENT=(LNM$SYSTEM_DIRECTORY) -
             /ATTRIBUTES=NO_ALIAS/PROTECTION=(S:RWED,O:R,G:R,W) -
             LNM$GROUP_000005
    $ SET UIC [1,4]

However, once the system is up, you find that the GROUP logical name
table no longer exists or the logicals that were placed in that table
are gone.


ANALYSIS:

When a user logs into his group for the first time after the system
is up, a GROUP logical name table is created in KERNEL mode with the
attribute of NO_ALIAS.

The NO_ALIAS attribute causes the previous definition of
LNM$GROUP_nnnnnn, set up during boot, to be deleted since it was
created in a lesser mode (EXEC) than KERNEL. Therefore, all the
logicals are lost.


PROCEDURES:

There are a few different ways a group logical name table can
be successfully created from SYSTARTUP_V5.COM or from a procedure
called by SYSTARTUP_V5.COM.  Implement the solution below that
best fits your needs.

1)  Run LOGINOUT.EXE as a detached process with a command file of
    your DEFINE commands as the input file.  LOGINOUT.EXE is used
    so that a GROUP logical name table is created in KERNEL mode
    and so that a CLI is created for the process enabling it to
    interpret the DCL DEFINE commands in the input file.

         $!CREATE_DETACH_PROCESS.COM
         $!
         $ SYSMGR = F$TRNLNM("SYS$MANAGER")
         $ RUN/DETACH/UIC=[group,0]/INPUT='SYSMGR'DEFINE_LOGICALS.COM -
             /OUTPUT='SYSMGR'DEFINE_LOGICALS.LOG   SYS$SYSTEM:LOGINOUT
         $ EXIT

    ------------------------------------------------

         $!SYS$MANAGER:DEFINE_LOGICALS.COM
         $ SET PROCESS/PRIVILEGE=(SYSNAM,SYSPRV)
         $ DEFINE/GROUP A_LOGICAL 1
         $ DEFINE/GROUP B_LOGICAL 2
         $ EXIT

2)  Submit a command file similar to DEFINE_LOGICALS.COM listed above.

         $ SUBMIT/USER=user-in-group DEFINE_LOGICALS.COM

    The "/USER" qualifier must be included on the SUBMIT command,
    specifying an account with the desired group number and the
    GRPNAM privilege defaulted in the account's UAF record.
    Furthermore, the directory and file to be submitted must be GROUP
    accessible (at least G:RE) so that other group users can READ it.

3)  Run an "empty" program with the $RUN/UIC=[group,account] command.
    A process is created, along with the LNM$GROUP_nnnnnn name table
    for the group in which that process was created.

         ;
         ;      DUMMY.MAR
         ;
                .Entry  Dummy,^M<>
                RET
                .End    Dummy

    Below are the commands necessary to compile, link and run
    DUMMY.MAR:

         $ MACRO DUMMY
         $ LINK DUMMY

         $ RUN/UIC=[group,0] Dummy


4)  This is an example of a Macro program that creates the GROUP
    LOGICAL NAME table.  Logicals can then be added into that table
    without fear of loosing them.  Use the commands below to compile,
    link and run the program successfully.

         $ MACRO CRELNT
         $ LINK CRELNT
         --------------------
         $ SET PROCESS/PRIVILEGE=(CMKRNL,SETPRV)
         $ SAVE_UIC = F$GETJPI("","UIC")
         $ SET UIC [group,0]
         $ RUN CRELNT
         $ DEFINE/TABLE=LNM$GROUP_nnnnnn logical equivalence
         $ DEFINE/TABLE=LNM$GROUP_nnnnnn logical equivalence
         .etc.
         $ SET UIC 'SAVE_UIC'

;
;       CRELNT.MAR
;
;       Purpose: To create a group logical name table
;
;       Commands needed to compile this program are:
;               $ MACRO CRELNT
;               $ LINK CRELNT
;
;
;       Commands needed to run this program successfully from a
;       privileged account:
;               $ SET PROCESS/PRIVILEGE=(CMKRNL,SETPRV)
;               $ SAVE_UIC = F$GETJPI("","UIC")
;               $ SET UIC [group,0]
;               $ RUN CRELNT
;               $ DEFINE/TABLE=LNM$GROUP_nnnnnn logical equivalence
;               $ DEFINE/TABLE=LNM$GROUP_nnnnnn logical equivalence
;                .etc.
;               $ SET UIC 'SAVE_UIC'
;
        .PSECT  DATA,NOEXE,WRT,long
        $LNMdef                             ; Logical name definitions
        $PSLdef                             ; Access mode level defs
        $PRVdef                             ; Privilege definitions
JPIITM: .WORD   4,JPI$_UIC                  ; Job Process Information
        .ADDRESS  UIC                       ; Item list.  Here we get
        .LONG   0,0                         ; UIC of the current PRC.
UIC:    .BLKL   1                           ; Store UIC value here.

CTRSTR: .ASCID  /LNM$GROUP_!OW/      ; $FAO format string
TABNAM: .ASCID  /LNM$GROUP_000000/          ; $FAO changes this value

PRIV:   .QUAD   <PRV$M_SYSNAM!PRV$M_SYSPRV> ; Necessary privs
PROMSK: .WORD   ^XFEE0                      ; (RWED,R,R,) protection
ATTR:   .LONG   LNM$M_NO_ALIAS              ; No duplicate logicals
PARTAB: .ASCID  /LNM$SYSTEM_DIRECTORY/      ; Shareable table
ACMODE: .BYTE   PSL$C_KERNEL                ; Place in KERNEL mode

        .PSECT  CODE,EXE,NOWRT
        .Entry  Create_Group_Logical_Table,^M<>

        $GetJPI_S       itmlst=JPIITM           ; Get UIC of OUR proc

        $FAO_S          ctrstr=CTRSTR,outbuf=TABNAM,- ; Format name of
                        p1=UIC+2                      ; GRP log table

        $SetPRV_S       enbflg=#1,prvadr=Priv         ; SYSNAM/SYSPRV

        $CreLNT_S -                                     ; Create the
                attr=ATTR,promsk=PROMSK,tabnam=TABNAM,- ; Group Log
                partab=PARTAB,acmode=ACMODE             ; Name Table.

        $SetPRV_S       enbflg=#0,prvadr=Priv         ; Disable privs.
        RET

        .End    Create_Group_Logical_Table
