From: STUBRBEE@EKU.BITNET (Oooooooops)
Newsgroups: comp.os.vms
Subject: Set Protection (problems..)
Date: 29 Sep 92 03:41:30 GMT
Distribution: world
Organization: The Internet

Dudes,
     I have gotten a couple of programs from vaxers about how to set protection
from a high livel language.  I have come across a s-l-i-g-h-t bug.  If you
don't have READ and WRITE privs to the file already it just dies.  It says
insufficient privs.  Is there anyway around this????  I know that
the dcl verb SET PROTECTION must work becuse its installed with privs.  So will
it be impossible for this to work for me.  By the way here is some sample code
Arne sent me  (Thanx dude! :)  )

David

[inherit('sys$library:starlet')]

program z(input,output);

type
   string = varying [256] of char;
   grpmem = record
               case boolean of
                  true  : (mem,grp : [word] 0..65535;);
                  false : (dummy   : unsigned;);
            end;
   protmask = record
                 case boolean of
                    true  : (mask  : packed array [0..15] of boolean;);
                    false : (dummy : [word] 0..65535;);
              end;

var
   fabblk : FAB$TYPE;
   xabblk : XAB$TYPE;
   fnm    : string;
   uic    : grpmem;
   prot   : protmask;
   stat   : integer;
   i      : integer;

begin
   fnm:='LOGIN.COM';
   fabblk.FAB$B_BID:=FAB$C_BID;
   fabblk.FAB$B_BLN:=FAB$C_BLN;
   fabblk.FAB$B_FAC:=FAB$M_UPD;
   fabblk.FAB$B_FNS:=fnm.length;
   fabblk.FAB$L_FNA:=iaddress(fnm.body);
   fabblk.FAB$L_XAB:=iaddress(xabblk);
   xabblk.XAB$B_COD:=XAB$C_PRO;
   xabblk.XAB$B_BLN:=XAB$C_PROLEN;
   xabblk.XAB$L_NXT:=0;
   (* display owner & protection *)
   stat:=$open(fab:=fabblk);
   uic.dummy:=xabblk.XAB$L_UIC;
   prot.dummy:=xabblk.XAB$W_PRO;
   stat:=$close(fab:=fabblk);
   writeln('UIC=[',oct(uic.grp),',',oct(uic.mem),']');
   write('protection=');
   for i:=0 to 15 do write((not prot.mask[i]):1);
   writeln;
   (* change protection to W:E *)
   stat:=$open(fab:=fabblk);
   prot.dummy:=xabblk.XAB$W_PRO;
   prot.mask[14]:=not(true);
   xabblk.XAB$W_PRO:=prot.dummy;
   stat:=$close(fab:=fabblk);
   (* display owner & protection *)
   stat:=$open(fab:=fabblk);
   uic.dummy:=xabblk.XAB$L_UIC;
   prot.dummy:=xabblk.XAB$W_PRO;
   stat:=$close(fab:=fabblk);
   writeln('UIC=[',oct(uic.grp),',',oct(uic.mem),']');
   write('protection=');
   for i:=0 to 15 do write((not prot.mask[i]):1);
   writeln;
end.


{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}
{ Name         : David Barbee                  Aliases  : Sybie                }
{ Bitnet       : STUBRBEE@EKU                  Internet : I wish!              }
{ Disclaimer   : Listen to me?!?  Can't imagine why.                           }
{ Last Words   : Oh *beep*!  (Censored for our more sensitive readers)         }
{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}
 ssss y   y b     i eeeee  '  ssss   u   u ttttt i l     i ttttt i eeeee  ssss
s      y y  b     i e      ' s       u   u   t   i l     i   t   i e     s
 sss    y   bbbb  i eee   '   sss    u   u   t   i l     i   t   i eee    sss
    s   y   b   b i e            s   u   u   t   i l     i   t   i e         s
ssss    y   bbbb  i eeeee    ssss     uuu    t   i lllll i   t   i eeeee     s
                                                                            s
ssssssssssssssssssssssss Programmer: David Barbee sssssssssssssssssssssssss