ANU News Patch Patch ID: 930831_newssite.c!bailey@genetics.upenn.edu Date: 31-Aug-1993 Author: Charles Bailey bailey@genetics.upenn.edu News Version: 6.1beta8 News Files: NewsSite.C Description: Use $GetJPI() to obtain process rights identifiers if running under vms 5.4 or later; if not, use $Find_Held() to obtain rigths identifiers from UAF. Replaces compile-time decision in previous code. *** newssite.c; --- newssite_new.c; ************** *** 24,26 **-- **/ --- 24,29 ----- + ** V6.1b7 31-Aug-1993 Charles Bailey bailey@genetics.upenn.edu + ** - change no_priv() to try $GetJPI or $Find_Held based on VMS + ** version, rather than requiring compile-time decision **-- **/ ************** *** 216,228 } /* ! *** This test is not valid; the contents of the C header files do not ! *** necessarily correspond with the VMS version we're running under. ! *** C headers are not constructed from STARLET at the time of compiler ! *** installation, so re-installing it after an upgrade doesn't help. [pr] ! * ! * If we have a version of VMS that does not know about the JPI$_RIGHTSLIST ! * item, we better not try and use it... */ #ifndef JPI$_RIGHTSLIST #define ORIGINAL_no_priv --- 219,226 ----- } /* ! * If we have a version of C that does not include the JPI$_RIGHTSLIST ! * item, we need to define it here. */ #ifndef JPI$_RIGHTSLIST #define JPI$_RIGHTSLIST 806 /* from VAXC 3.2 jpidef.h */ ************** *** 225,231 * item, we better not try and use it... */ #ifndef JPI$_RIGHTSLIST ! #define ORIGINAL_no_priv #endif /* --- 223,229 ----- * item, we need to define it here. */ #ifndef JPI$_RIGHTSLIST ! #define JPI$_RIGHTSLIST 806 /* from VAXC 3.2 jpidef.h */ #endif /* ************** *** 232,238 * no_priv * * Return 1 if the user is not an authorised news manager - check the ! * list of held identifiers */ int no_priv() --- 230,240 ----- * no_priv * * Return 1 if the user is not an authorised news manager - check the ! * list of held identifiers ! * ! * (Use $GetJPI if we're running VMS 5.4 or later; if we're ! * runing an older version of VMS, use $Find_Held) ! * 31-Aug-1993 Charles Bailey bailey@genetics.upenn.edu */ int no_priv() ************** *** 238,244 int no_priv() { int mgr_id, mem_sysprv; - #ifdef ORIGINAL_no_priv int id = 0, contxt = 0, lstatus, idindx; unsigned int holder[2]; #else --- 240,245 ----- int no_priv() { int mgr_id, mem_sysprv; int id = 0, contxt = 0, lstatus, idindx; unsigned int holder[2]; struct id_attr { ************** *** 241,247 #ifdef ORIGINAL_no_priv int id = 0, contxt = 0, lstatus, idindx; unsigned int holder[2]; - #else struct id_attr { unsigned long identifier ; unsigned long attributes ; --- 242,247 ----- int mgr_id, mem_sysprv; int id = 0, contxt = 0, lstatus, idindx; unsigned int holder[2]; struct id_attr { unsigned long identifier ; unsigned long attributes ; ************** *** 257,263 unsigned long terminator ; } jpi_item_list = {sizeof (held_id_attr), JPI$_RIGHTSLIST, (void *) held_id_attr, &jpi_return_length, 0}; ! #endif if (mgr_priv != -1) return(mgr_priv); if ((mem_sysprv = sysprv_off) != 0) sysprv(); if (!*mgrid) mgr_id = -1; --- 257,263 ----- unsigned long terminator ; } jpi_item_list = {sizeof (held_id_attr), JPI$_RIGHTSLIST, (void *) held_id_attr, &jpi_return_length, 0}; ! if (mgr_priv != -1) return(mgr_priv); if ((mem_sysprv = sysprv_off) != 0) sysprv(); if (!*mgrid) mgr_id = -1; ************** *** 262,272 if ((mem_sysprv = sysprv_off) != 0) sysprv(); if (!*mgrid) mgr_id = -1; else if (!(sys$asctoid(c$dsc(mgrid),&mgr_id,0) & 1)) mgr_id = -1; - #ifdef ORIGINAL_no_priv - holder[0] = (getgid() << 16) | getuid(); - holder[1] = 0; - idindx = 0; - #endif mgr_priv = 1; /* * SYS$FIND_HELD looks up the RIGHTSLIST database for identifiers held. --- 262,267 ----- if ((mem_sysprv = sysprv_off) != 0) sysprv(); if (!*mgrid) mgr_id = -1; else if (!(sys$asctoid(c$dsc(mgrid),&mgr_id,0) & 1)) mgr_id = -1; mgr_priv = 1; /* ************** *** 268,273 idindx = 0; #endif mgr_priv = 1; /* * SYS$FIND_HELD looks up the RIGHTSLIST database for identifiers held. * What is more relevant is the list of rights identifiers currently held by --- 263,269 ----- if (!*mgrid) mgr_id = -1; else if (!(sys$asctoid(c$dsc(mgrid),&mgr_id,0) & 1)) mgr_id = -1; mgr_priv = 1; + /* * SYS$FIND_HELD looks up the RIGHTSLIST database for identifiers held. * What is more relevant is the list of rights identifiers currently held by ************** *** 274,293 * the process, which can be obtained using the JPI$_RIGHTSLIST item of the * SYS$GETJPI system call. */ ! #ifdef ORIGINAL_no_priv ! while ((lstatus = sys$find_held(holder,&id,0,&contxt)) & 1) { ! held_ids[idindx++] = id; ! if (id == mgr_id) mgr_priv = 0; ! } ! held_ids[idindx] = 0; ! sys$finish_rdb(&contxt); ! #else ! if (sys$getjpiw (0,0,0,&jpi_item_list,0,0,0) & 1) { ! int ident_count = jpi_return_length / sizeof (struct id_attr); ! held_ids[ident_count] = 0; ! while (--ident_count >= 0) { ! held_ids[ident_count] = held_id_attr[ident_count].identifier; ! if (held_ids[ident_count] == mgr_id) mgr_priv = 0; } } #endif --- 270,283 ----- * the process, which can be obtained using the JPI$_RIGHTSLIST item of the * SYS$GETJPI system call. */ ! if ((vms_major >= 5) && (vms_minor >= 4)) { ! if (sys$getjpiw (0,0,0,&jpi_item_list,0,0,0) & 1) { ! int ident_count = jpi_return_length / sizeof (struct id_attr); ! held_ids[ident_count] = 0; ! while (--ident_count >= 0) { ! held_ids[ident_count] = held_id_attr[ident_count].identifier; ! if (held_ids[ident_count] == mgr_id) mgr_priv = 0; ! } } } else { ************** *** 290,296 if (held_ids[ident_count] == mgr_id) mgr_priv = 0; } } ! #endif if (mem_sysprv) nosysprv(); return(mgr_priv); } --- 280,296 ----- } } } ! else { ! holder[0] = (getgid() << 16) | getuid(); ! holder[1] = 0; ! idindx = 0; ! while ((lstatus = sys$find_held(holder,&id,0,&contxt)) & 1) { ! held_ids[idindx++] = id; ! if (id == mgr_id) mgr_priv = 0; ! } ! held_ids[idindx] = 0; ! sys$finish_rdb(&contxt); ! } if (mem_sysprv) nosysprv(); return(mgr_priv); } *** patchlist.h;-1 --- patchlist.h ************** *** 1,1 =+=+= End =+=+= --- 1,2 ----- + 930831_newssite.c!bailey@genetics.upenn.edu =+=+= End =+=+=