[mod.computers.vax] Installed images and priveleges

STEINBERGER@SRI-KL.ARPA.UUCP (02/14/87)

I have been trying to use SYS$CRELNM to create a supervisor mode logical
name in the user's process table.  The default in this call is to use
user mode, unless you specify supervisor, exec, or kernel AND have SYSNAM
privelege.  Thus ordinary users with TMPMBX and NETMBX who attempt this
will end up creating a USER mode logical name in their process table;
and this is a highly temporary state of affairs (as documented).  I now
know that the routine LIB$SET_LOGICAL will do exactly what I had in mind,
but since I never was able to get  SYS$CRELNM to work as I described and
would like to know why I submit this question.

This was my startegy, that alas has not yet worked.  I wrote a subroutine
that was installed as a known image and given SYSNAM priv.  In the subroutine,
I use SYS$SETPRV to get SYSNAM privelege.  Next I make the call to SYS$CRELNM.
Finally, for debugging, I make a last call to SYS$SETPRV to remove SYSNAM
priv and see what priveleges were in effect prior to the call.  When I
run from an account that has all privs authorized, the prog works fine,
and a supervisor mode logical name is created.  When run from an unpriveleged
account this doe not happen.  In both cases, the final call to SYS$SETPRV
showed a mask of 1080004 (HEX), indicating SYSNAM, TMPMBX and NETMBX were
in effect.  I don't know why it didn't do what I wanted.

Should/Can Installed images be used to do the kind of thing I want (i.e.
temporarily grant priveleges)?  Did I install the image properly?
Were the programs linked with the correct options?  When it runs there
are no error messages.  Thanks to any and all who reply.


This is the way I linked the subroutine:

$ LINK/SHARE/NOTRACE set_logical,sys$input/opt
  UNIVERSAL=SET_LOGICAL   !so calling routines can LINK to it (find start adr)
$

Here is how I installed it:
INSTALL> ADD/SHARE $DISK2:[RIC]SET_LOGICAL /PRIV=SYSNAM

The following is necessary so the run-time image can find the installed image.
$ DEFINE SET_LOGICAL $DISK2:[RIC]SET_LOGICAL  !because it's not in SYS$SHARE

This is how I linked it to the main routine:
$LINK TEST_SET_LOGICAL,sys$input/opt
 set_logical/shareable
$

Here are the 2 programs (subroutine first):  (Tabs may get distorted.)

______________________________________________________________________________

	options /extend_source

	subroutine set_logical(logical_name,equivalence_name)

C*******Set a SUPERVISOR mode logical name in the user's PROCESS table.
C       This must be an installed image and given SYSNAM priv.

      implicit integer (a-z)

      include '($LNMDEF)'
      include '($SSDEF)'
      include '($PSLDEF)'
      include '($STRDEF)'

      structure /itmlst/
        union
          map
            integer*2          buflen
            integer*2          code
            integer*4          bufadr
            integer*4          retlenadr
          end map
          map
            integer*4          end_list  /0/
          end map
        end union
      end structure

      byte access_mode, enbflg
      character*80 logical_name,equivalence_name, text, text2
      integer*4 status, priv_mask(2) /2*0/
      integer*4 prvprv(2)

      record /itmlst/ lnmlist(2)

      status = str$trim(text,logical_name,tlen)
      if (.not. status)call lib$signal(%val(status))
      status = str$upcase(text,text)
      status = str$trim(text2,equivalence_name,tlen2)
      if (.not. status)call lib$signal(%val(status))
      status = str$upcase(text2,text2)

      lnmlist(1).buflen    = tlen2
      lnmlist(1).code      = LNM$_STRING
      lnmlist(1).bufadr    = %loc(text2)
      lnmlist(1).retlenadr = 0            !must pass placeholder

C*****The actual ACCESS mode used in creating the logical name is
C     USER if the program is run without SYSNAM priv. 
C     See SYSTEM SERVICES, p 6-5.

      priv_mask(1) = '0004'X                   !the mask for SYSNAM
      enbflg = 1                               !enable the privelege
      status = sys$setprv(%val(enbflg),priv_mask,,)
      if (.not. status)call lib$signal(%val(status))
      access_mode = PSL$C_SUPER
      status = sys$crelnm(,'LNM$PROCESS',text(1:tlen),
     +         access_mode,lnmlist)
      if (.not. status)call lib$signal(%val(status))

      priv_mask(1) = '0004'X                   !the mask for SYSNAM
      enbflg = 0                               !disable the privelege
      status = sys$setprv(%val(enbflg),priv_mask,,prvprv)
      write(6,100)prvprv(2),prvprv(1)
  100 format(' Privelege mask was (HEX): ',z8,5x,z8)

      return
 1000 end

______________________________________________________________________________

	options /extend_source

	program test_set_logical

	implicit integer (a-z)

	character*80 logical_name, equivalence_name
	integer retlen

  80	write(6,'($,a)')' Enter logical name (^Z to exit): '
	read(5,fmt='(a)',end=1000)logical_name
	write(6,'($,a)')' Enter equivalence name (^Z to exit): '
     read(5,fmt='(a)',end=1000)equivalence_name

	call set_logical(logical_name,equivalence_name)

	goto 80

 1000 end
-------