From: ccc_rex@waikato.ac.nz
Newsgroups: news.software.anu-news
Subject: Rights IDs added dynamically ignored
Date: 30 Sep 92 09:07:08 +1200
Organization: University of Waikato, Hamilton, New Zealand

We are running ANU News 6.0-2 on VMS V5.4-3.

Another programmer set up a system to grant the rights identifiers
NEWS_USER and NEWS_NONETPOST dynamically to the process if the time wasn't
between 10:00 and 17:00 on a working day, for a certain class of users.
NEWS_USER is the rights ID that grants access to the news items' directories.

Unfortunately, News uses the SYS$FIND_HELD system service to determine which
rights IDs the user holds.  This returns those IDs that are in the disk
database, not those in memory.  This meant that NEWS_NONETPOST was ignored.

VMS V5.4 added a new item (JPI$_PROCESS_RIGHTS) to SYS$GETJPI which returns
those rights IDs the process currently holds in memory.

The following difference file on NEWSSITE.C shows the modifications to the
procedure no_priv() to accomplish this.  The version of C (3.2) we have
doesn't define JPI$_PROCESS_RIGHTS in SYS$LIBRARY:getjpi.h so I had to
define it myself.

Is it worthwhile putting this in News 6.1, or are there still sites using
pre 5.4 VMS.  Perhaps it can be added conditionally?

Rex Croft       ccc_rex@waikato.ac.nz
VMS Systems Programmer
University of Waikato
Hamilton
New Zealand

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

************
File NEWSSITE.C;179
  256   /*
  257    *	Modified 29-Sep-1992, Rex Croft, University of Waikato
  258    *	Rather than looking at authorized rights IDs on disk, look at the
  259    *	ones currently held in memory.
  260    */
  261   #define JPI$_PROCESS_RIGHTS 814
  262   no_priv()
******
File NEWSSITE.C_ORIG;1
  256   
  257   no_priv()
************
************
File NEWSSITE.C;179
  266     short jpi_held_len = 0;
  267     struct
  268       {
  269         int     id;
  270         int     attr;
  271       } jpi_held[100];
  272     struct
  273       {
  274         short   len;                    /* buffer length */
  275         short   item_code;              /* information item requested */
  276         char    *buf;                   /* return buffer */
  277         int     *rlen;                  /* return length */
  278         int     endoflist;
  279       } jpi_itemlist  = {4*2*(100-1),JPI$_PROCESS_RIGHTS,
  280   			(char *) jpi_held,(int *) &jpi_held_len,0};
  281   
******
File NEWSSITE.C_ORIG;1
  261   
************
************
File NEWSSITE.C;179
  286   /*
  287    *  holder[0] = (getgid() << 16) + getuid();
  288    *  holder[1] = 0;
  289    *  idindx = 0;
  290    */
  291     mgr_priv = 1;
  292   
  293     if (sys$getjpi(0,0,0,&jpi_itemlist,0,0,0) & 1) {
  294       jpi_held_len /= 8;			/* get number of IDs returned */
  295       for( idindx=0; idindx<jpi_held_len; idindx++ ) {
  296         held_ids[idindx] = jpi_held[idindx].id;
  297         if (held_ids[idindx] == mgr_id) mgr_priv = 0;
  298       }
  299     }
  300   
  301     held_ids[idindx] = 0;
  302   
  303   /*
  304    *  while ((lstatus = sys$find_held(holder,&id,&attribs,&contxt)) & 1) {
  305    *    held_ids[idindx++] = id;
  306    *    if (id == mgr_id) mgr_priv = 0;
  307    *    }
  308    *  held_ids[idindx] = 0;
  309    *  sys$finish_rdb(&contxt);
  310    */
  311   
  312     if (mem_sysprv) nosysprv();
******
File NEWSSITE.C_ORIG;1
  266     holder[0] = (getgid() << 16) + getuid();
  267     holder[1] = 0;
  268     idindx = 0;
  269     mgr_priv = 1;
  270     while ((lstatus = sys$find_held(holder,&id,&attribs,&contxt)) & 1) {
  271       held_ids[idindx++] = id;
  272       if (id == mgr_id) mgr_priv = 0;
  273       }
  274     held_ids[idindx] = 0;
  275     sys$finish_rdb(&contxt);
  276     if (mem_sysprv) nosysprv();
************

Number of difference sections found: 3