From: "GWDGV1::MOELLER" <moeller@gwdgv1.dnet.gwdg.de>
Newsgroups: vmsnet.internals
Subject: RE: Help patching MAILSHR
Date: Mon, 14 Sep 1992 13:47:02 +0200
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List

Dale Miller <domiller@ualr.edu> writes:
> I have been trying to modify the mailshr patch posted Claude Barbe to verify
> if a user exists in the local sysuaf, and transparently re-write the address
> if not.  I can get the code to work fine in Macro using a call to sys$getuai,
> but I can't figure out how to get it into a patch.  Apparently sys$getuai does
> not translate to an address that can be used by patch (unlike sys$setprv or
> sys$fao which are also used in the patch).
>
> Okay, now the question.  How can I accomplish finding the validity of a user
> in a manner that can be used in a patch to mailshr?

SYS$GETUAI lives in a privileged shareable image (SECURESHR),
so LIB$FIND_IMAGE_SYMBOL would be required to dynamically access it
(unless MAILSHR was already linked with SECURESHR, which it isn't).

What I've done once (and even put into production use):
You can provide a shareable image of your own, which does the required
function (and could be linked with whatever additional images you'd like).
Since apart from entry point lookup, the code for activating a shareable image
is in the (undocumented, but resident) SYS$IMGACT system service,
that image and all of its additional libraries can be dynamically activated,
and in order to call it you just have to arrange for a fixed entry point
address (e.g. 0). You may wish to make sure that you don't activate
the image more than once - I'm not sure if that is required because
my patch affected code usually executed only once.

In essence, the patch then goes:

{ deposit *full* filespec of your shareable image at MY_IMGNAM }
{ MY_IMGNAM_LEN = length of that filespec }

{ make sure R0 and R1 can be destroyed }
'       movl    r2,-(sp)'               ! save r2
'       subl2   #210,sp'                ! room for imgact data
'       movl    sp,r2'                  !       +0: image desc
'       clrq    b^8(r2)'                !       +8: inadr/retadr
'       movab   l^MY_IMGNAM,b^4(r2)'    !       +10: hdrbuf
'       movl    #MY_IMGNAM_LEN,(r2)'    ! len of image name
'       pushl   #0'                     ! $IMGACT_S _
'       pushl   #0'                     !       _
'       pushaq  b^8(r2)'                !       retadr=8(r2),_
'       pushaq  b^8(r2)'                !       inadr=8(r2),_
'       pushl   #30'                    !     imgctl=#iac$m_expreg!iac$m_merge,_
'       pushab  b^10(r2)'               !       hdrbuf=x^10(r2),_
'       pushl   #0'                     !       _
'       pushaq  (r2)'                   !       name=(r2)
'       calls   #8,@#7FFEDF90'          !
'       blbc    r0,my_error'            !
'       calls   #0,@#7FFEE400'          ! $IMGFIX_S
'       blbc    r0,my_error'            !
'       movl    b^8(r2),r1'             ! save base adress in R1
'my_error: addl2        #210,sp'        ! cleanup
'       movl    (sp)+,r2'               ! restore r2
{ activation status is in R0 }
{ if o.k., R1 points to the start of the image }

This patch has worked for me unchanged since VMS V4.x

Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
PSI%(0262)45050352008::MOELLER      Phone: +49 551 201516 | No claim intended!
Internet: moeller@gwdgv1.dnet.gwdg.de   | This space intentionally left blank.