X-NEWS: msuvx2 news.software.anu-news: 3305 Relay-Version: ANU News - V6.1 08/24/93 VAX/VMS A5.5-2; site msuvx2 Path: nntp.memst.edu!cs.utk.edu!darwin.sura.net!howland.reston.ans.net!usc!hela.iti.org!widener!dsinc!netnews.upenn.edu!hmivax.humgen.upenn.edu!bailey Newsgroups: news.software.anu-news Subject: Patch: rights ID retrieval Message-ID: <1993Aug31.205400.1@hmivax.humgen.upenn.edu> From: bailey@hmivax.humgen.upenn.edu (Charles Bailey) Date: 1 Sep 93 00:54:00 GMT Sender: news@netnews.upenn.edu Organization: HHMI/Human Genetics, Univ of Pa. Nntp-Posting-Host: hmivax.humgen.upenn.edu Lines: 402 In determining whether a particular user can invoke news manager privileges, News checks to see whether the process holds the rights identifier specified by the logical name News_Mgr_ID. Prior to VMS 5.4, this was done by calling $Find_Held to obtain a list of identifiers granted in SYSUAF. Under VMS 5.4 or later, $GetJPI() is called instead to obtain a list of all identifiers held by the process at the moment of the call. The choice between $Find_Held and $GetJPI is made at compile time based on whether the C preprocessor symbol JPI$_RIGHTSLIST is defined. The following patch changes this behavior by deferring the decision to runtime and basing the choice on the version of VMS actually in use at the time News is run: if it is 5.4 or later, $GetJPI is used, otherwise, $Find_Held is used. Since the VMS version info is obtained via $GetSYI, this may produce the 'wrong' result on an Alpha at present; I haven't checked the Alpha patches to see how they handle this. Since decisions are made elsewhere based on vms versions >5 (e.g. calling mail), it seems better to patch site_get_env() to set vms_major = 5 and vms_minor = 5 if compiled on an Alpha, rather than putting any conditional code here. Following a suggestion by Bob Sloane, I'm posting the patch as a VMS Share file, since the mail gateway has mangled some free text patches in the past. If anyone has any comments or suggestions, I'd be happy to hear them. Regards, Charles Bailey !------------------------------------------------------------------------------- ! Dept. of Genetics / Howard Hughes Medical Institute ! University of Pennsylvania School of Medicine Rm. 430 Clinical Research Bldg. ! 422 Curie Blvd. Philadelphia, PA 19104 USA Tel. (215) 898-1699 ! Internet: bailey@genetics.upenn.edu (IN 128.91.200.37) !------------------------------------------------------------------------------- $! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_UNPACK_VERIFY"))' $! $! This archive created: $! Name : PATCH $! By : bailey@hmivax.humgen.upenn.edu $! Date : 31-AUG-1993 20:23:51.73 $! Using: VMS_SHARE 8.4, (C) 1993 Andy Harper, Kings College London UK $! $! Credit is due to these people for their original ideas: $! James Gray, Michael Bednarek $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. 930831_NEWSSITE.PATCH;1 $! $ set="set" $ set symbol/scope=(nolocal,noglobal) $ f=f$parse("SHARE_UNPACK_TEMP","SYS$SCRATCH:."+f$getjpi("","PID")) $ e="write sys$error ""%UNPACK"", " $ w="write sys$output ""%UNPACK"", " $ if .not. f$trnlnm("SHARE_UNPACK_LOG") then $ w = "!" $ if f$getsyi("CPU") .gt. 127 then $ goto start $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto start $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $unpack: subroutine ! P1=filename, P2=checksum, P3=attributes,P4=size $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'" $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn' File skipped" $ delete 'f'* $ exit $dirok: $ x=f$search(P1) $ if x .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped" $ delete 'f'* $ exit $file_absent: $ w "-I-UNPACK, Unpacking ", P5, " of ", P6, " - ", P1, " - ", P4, " Blocks" $ n=P1 $ if P3 .nes. "" then $ n=f $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT/NOJOURNAL 'f'/OUT='n' PROCEDURE GetHex(s,p)LOCAL x1,x2;x1:=INDEX(t,SUBSTR(s,p,1))-1;x2:=INDEX(t, SUBSTR(s,p+1,1))-1;RETURN 16*x1+x2;ENDPROCEDURE;PROCEDURE SkipPartsep LOCAL m; LOOP m:=MARK(NONE);EXITIF m=END_OF(b);DELETE(m);EXITIF INDEX(ERASE_LINE, "-+-+-+-+-+-+-+-+")=1;ENDLOOP;ENDPROCEDURE;PROCEDURE ProcessLine LOCAL c,s,l,b, n,p;c := ERASE_CHARACTER(1);s := ERASE_LINE;IF c = "X" THEN SPLIT_LINE; ENDIF; MOVE_HORIZONTAL(-1);l := LENGTH(s);p := 1;LOOP EXITIF p > l;c := SUBSTR(s,p,1); p := p+1;CASE c FROM ' ' TO '`' ['`']: COPY_TEXT(ASCII(GetHex(s,p))); p:=p+2;[ ' ']: p:=p+1;[INRANGE,OUTRANGE]: COPY_TEXT(c);ENDCASE;ENDLOOP;ENDPROCEDURE; PROCEDURE Decode LOCAL m;POSITION(BEGINNING_OF(b));LOOP m:=MARK(NONE);EXITIF m= END_OF(b);DELETE(m);IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+-")= 1 THEN SkipPartSep;ELSE ProcessLine;MOVE_HORIZONTAL(1);ENDIF;ENDLOOP; ENDPROCEDURE;SET(FACILITY_NAME,"UNPACK");SET(SUCCESS,OFF);SET(INFORMATIONAL, OFF);t:="0123456789ABCDEF";f:=GET_INFO(COMMAND_LINE,"file_name");b:= CREATE_BUFFER(f,f);Decode;WRITE_FILE(b,GET_INFO(COMMAND_LINE,"output_file")); QUIT; $ if p3 .eqs. "" then $ goto dl $ open/write fdl &f $ write fdl "RECORD" $ write fdl P3 $ close fdl $ w "-I-CONVRFM, Converting record format to ", P3 $ convert/fdl=&f &f-1 &P1 $dl: delete 'f'* $ checksum 'P1' $ if checksum$checksum .nes. P2 then $ - e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ exit $ endsubroutine $start: $! $ create 'f' XANU`20News`20Patch XPatch`20ID:`20930831_newssite.c!bailey@genetics.upenn.edu XDate:`2031-Aug-1993 XAuthor:`20Charles`20Bailey`20`20bailey@genetics.upenn.edu XNews`20Version:`206.1beta8 XNews`20Files:`20NewsSite.C XDescription:`20Use`20$GetJPI()`20to`20obtain`20process`20rights`20identifiers V`20if`20running Xunder`20vms`205.4`20or`20later;`20if`20not,`20use`20$Find_Held()`20to`20obtain V`20rigths`20identifiers Xfrom`20UAF.`20`20Replaces`20compile-time`20decision`20in`20previous`20code. X***`20newssite.c; X---`20newssite_new.c; X************** X***`2024,26 X`20`20**-- X`20`20**/ X`20`20`0C X---`2024,29`20----- X+`20**`09V6.1b7`0931-Aug-1993`09Charles`20Bailey`20`20bailey@genetics.upenn.ed Vu X+`20**`09`20`20-`20change`20no_priv()`20to`20try`20$GetJPI`20or`20$Find_Held V`20based`20on`20VMS X+`20**`09`20`20`20`20version,`20rather`20than`20requiring`20compile-time`20dec Vision X`20`20**-- X`20`20**/ X`20`20`0C X************** X***`20216,228 X`20`20`7D X`20`20`0C X`20`20/* X!`20***`20This`20test`20is`20not`20valid;`20the`20contents`20of`20the`20C`20he Vader`20files`20do`20not X!`20***`20necessarily`20correspond`20with`20the`20VMS`20version`20we're`20runn Ving`20under. X!`20***`20C`20headers`20are`20not`20constructed`20from`20STARLET`20at`20the`20 Vtime`20of`20compiler X!`20***`20installation,`20so`20re-installing`20it`20after`20an`20upgrade`20doe Vsn't`20help.`20`20`5Bpr`5D X!`20`20* X!`20`20*`20If`20we`20have`20a`20version`20of`20VMS`20that`20does`20not`20know V`20about`20the`20JPI$_RIGHTSLIST X!`20`20*`20item,`20we`20better`20not`20try`20and`20use`20it... X`20`20`20*/ X`20`20#ifndef`20JPI$_RIGHTSLIST X`20`20#define`20ORIGINAL_no_priv X---`20219,226`20----- X`20`20`7D X`20`20`0C X`20`20/* X!`20`20*`20If`20we`20have`20a`20version`20of`20C`20that`20does`20not`20include V`20the`20JPI$_RIGHTSLIST X!`20`20*`20item,`20we`20need`20to`20define`20it`20here. X`20`20`20*/ X`20`20#ifndef`20JPI$_RIGHTSLIST X`20`20#define`20JPI$_RIGHTSLIST`20806`20`20/*`20from`20VAXC`203.2`20jpidef.h V`20*/ X************** X***`20225,231 X`20`20`20*`20item,`20we`20better`20not`20try`20and`20use`20it... X`20`20`20*/ X`20`20#ifndef`20JPI$_RIGHTSLIST X!`20#define`20ORIGINAL_no_priv X`20`20#endif X`20`20 X`20`20/* X---`20223,229`20----- X`20`20`20*`20item,`20we`20need`20to`20define`20it`20here. X`20`20`20*/ X`20`20#ifndef`20JPI$_RIGHTSLIST X!`20#define`20JPI$_RIGHTSLIST`20806`20`20/*`20from`20VAXC`203.2`20jpidef.h`20* V/ X`20`20#endif X`20`20 X`20`20/* X************** X***`20232,238 X`20`20`20*`20`20no_priv X`20`20`20* X`20`20`20*`20`20Return`201`20if`20the`20user`20is`20not`20an`20authorised`20ne Vws`20manager`20-`20check`20the X!`20`20*`20`20list`20of`20held`20identifiers X`20`20`20*/ X`20`20 X`20`20int`20no_priv() X---`20230,240`20----- X`20`20`20*`20`20no_priv X`20`20`20* X`20`20`20*`20`20Return`201`20if`20the`20user`20is`20not`20an`20authorised`20ne Vws`20manager`20-`20check`20the X!`20`20*`20`20list`20of`20held`20identifiers`20 X!`20`20* X!`20`20*`20`20(Use`20$GetJPI`20if`20we're`20running`20VMS`205.4`20or`20later; V`20if`20we're X!`20`20*`20`20runing`20an`20older`20version`20of`20VMS,`20use`20$Find_Held) X!`20`20*`20`2031-Aug-1993`20Charles`20Bailey`20`20bailey@genetics.upenn.edu X`20`20`20*/ X`20`20 X`20`20int`20no_priv() X************** X***`20238,244 X`20`20int`20no_priv() X`20`20`7B X`20`20`20`20int`20mgr_id,`20mem_sysprv; X-`20#ifdef`20ORIGINAL_no_priv X`20`20`20`20int`20id`20=`200,`20contxt`20=`200,`20lstatus,`20idindx; X`20`20`20`20unsigned`20int`20holder`5B2`5D; X`20`20#else X---`20240,245`20----- X`20`20int`20no_priv() X`20`20`7B X`20`20`20`20int`20mgr_id,`20mem_sysprv; X`20`20`20`20int`20id`20=`200,`20contxt`20=`200,`20lstatus,`20idindx; X`20`20`20`20unsigned`20int`20holder`5B2`5D; X`20`20`20`20struct`20id_attr`20`7B X************** X***`20241,247 X`20`20#ifdef`20ORIGINAL_no_priv X`20`20`20`20int`20id`20=`200,`20contxt`20=`200,`20lstatus,`20idindx; X`20`20`20`20unsigned`20int`20holder`5B2`5D; X-`20#else X`20`20`20`20struct`20id_attr`20`7B X`20`20`20`20`20`20`20unsigned`20long`20identifier`20; X`20`20`20`20`20`20`20unsigned`20long`20attributes`20; X---`20242,247`20----- X`20`20`20`20int`20mgr_id,`20mem_sysprv; X`20`20`20`20int`20id`20=`200,`20contxt`20=`200,`20lstatus,`20idindx; X`20`20`20`20unsigned`20int`20holder`5B2`5D; X`20`20`20`20struct`20id_attr`20`7B X`20`20`20`20`20`20`20unsigned`20long`20identifier`20; X`20`20`20`20`20`20`20unsigned`20long`20attributes`20; X************** X***`20257,263 X`20`20`20`20`20`20unsigned`20long`20terminator`20; X`20`20`20`20`20`20`7D`20jpi_item_list`20=`20`7Bsizeof`20(held_id_attr),`20JPI$ V_RIGHTSLIST, X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20(vo Vid`20*)`20held_id_attr,`20`26jpi_return_length,`200`7D; X!`20#endif X`20`20`20`20if`20(mgr_priv`20!=`20-1)`20return(mgr_priv); X`20`20`20`20if`20((mem_sysprv`20=`20sysprv_off)`20!=`200)`20sysprv(); X`20`20`20`20if`20(!*mgrid)`20mgr_id`20=`20-1; X---`20257,263`20----- X`20`20`20`20`20`20unsigned`20long`20terminator`20; X`20`20`20`20`20`20`7D`20jpi_item_list`20=`20`7Bsizeof`20(held_id_attr),`20JPI$ V_RIGHTSLIST, X`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20`20(vo Vid`20*)`20held_id_attr,`20`26jpi_return_length,`200`7D; X!`20 X`20`20`20`20if`20(mgr_priv`20!=`20-1)`20return(mgr_priv); X`20`20`20`20if`20((mem_sysprv`20=`20sysprv_off)`20!=`200)`20sysprv(); X`20`20`20`20if`20(!*mgrid)`20mgr_id`20=`20-1; X************** X***`20262,272 X`20`20`20`20if`20((mem_sysprv`20=`20sysprv_off)`20!=`200)`20sysprv(); X`20`20`20`20if`20(!*mgrid)`20mgr_id`20=`20-1; X`20`20`20`20else`20if`20(!(sys$asctoid(c$dsc(mgrid),`26mgr_id,0)`20`26`201)) V`20mgr_id`20=`20-1; X-`20#ifdef`20ORIGINAL_no_priv X-`20`20`20holder`5B0`5D`20=`20(getgid()`20<<`2016)`20`7C`20getuid(); X-`20`20`20holder`5B1`5D`20=`200; X-`20`20`20idindx`20=`200; X-`20#endif X`20`20`20`20mgr_priv`20=`201; X`20`20`20`20/* X`20`20`20`20`20*`20SYS$FIND_HELD`20looks`20up`20the`20RIGHTSLIST`20database`20 Vfor`20identifiers`20held. X---`20262,267`20----- X`20`20`20`20if`20((mem_sysprv`20=`20sysprv_off)`20!=`200)`20sysprv(); X`20`20`20`20if`20(!*mgrid)`20mgr_id`20=`20-1; X`20`20`20`20else`20if`20(!(sys$asctoid(c$dsc(mgrid),`26mgr_id,0)`20`26`201)) V`20mgr_id`20=`20-1; X`20`20`20`20mgr_priv`20=`201; X`20`20 X`20`20`20`20/* X************** X***`20268,273 X`20`20`20`20idindx`20=`200; X`20`20#endif X`20`20`20`20mgr_priv`20=`201; X`20`20`20`20/* X`20`20`20`20`20*`20SYS$FIND_HELD`20looks`20up`20the`20RIGHTSLIST`20database`20 Vfor`20identifiers`20held. X`20`20`20`20`20*`20What`20is`20more`20relevant`20is`20the`20list`20of`20rights V`20identifiers`20currently`20held`20by X---`20263,269`20----- X`20`20`20`20if`20(!*mgrid)`20mgr_id`20=`20-1; X`20`20`20`20else`20if`20(!(sys$asctoid(c$dsc(mgrid),`26mgr_id,0)`20`26`201)) V`20mgr_id`20=`20-1; X`20`20`20`20mgr_priv`20=`201; X+`20 X`20`20`20`20/* X`20`20`20`20`20*`20SYS$FIND_HELD`20looks`20up`20the`20RIGHTSLIST`20database`20 Vfor`20identifiers`20held. X`20`20`20`20`20*`20What`20is`20more`20relevant`20is`20the`20list`20of`20rights V`20identifiers`20currently`20held`20by X************** X***`20274,293 X`20`20`20`20`20*`20the`20process,`20which`20can`20be`20obtained`20using`20the V`20JPI$_RIGHTSLIST`20item`20of`20the X`20`20`20`20`20*`20SYS$GETJPI`20system`20call. X`20`20`20`20`20*/ X!`20#ifdef`20ORIGINAL_no_priv X!`20`20`20while`20((lstatus`20=`20sys$find_held(holder,`26id,0,`26contxt))`20 V`26`201)`20`7B X!`20`20`20`20`20held_ids`5Bidindx++`5D`20=`20id; X!`20`20`20`20`20if`20(id`20==`20mgr_id)`20mgr_priv`20=`200; X!`20`20`20`20`20`7D X!`20`20`20held_ids`5Bidindx`5D`20=`200; X!`20`20`20sys$finish_rdb(`26contxt); X!`20#else X!`20`20`20if`20(sys$getjpiw`20(0,0,0,`26jpi_item_list,0,0,0)`20`26`201)`20`7B V X!`20`20`20`20`20int`20ident_count`20=`20jpi_return_length`20/`20sizeof`20(stru Vct`20id_attr); X!`20`20`20`20`20held_ids`5Bident_count`5D`20=`200; X!`20`20`20`20`20while`20(--ident_count`20>=`200)`20`7B X!`20`20`20`20`20`20`20held_ids`5Bident_count`5D`20=`20held_id_attr`5Bident_cou Vnt`5D.identifier; X!`20`20`20`20`20`20`20if`20(held_ids`5Bident_count`5D`20==`20mgr_id)`20mgr_pri Vv`20=`200; X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X`20`20#endif X---`20270,283`20----- X`20`20`20`20`20*`20the`20process,`20which`20can`20be`20obtained`20using`20the V`20JPI$_RIGHTSLIST`20item`20of`20the X`20`20`20`20`20*`20SYS$GETJPI`20system`20call. X`20`20`20`20`20*/ X!`20`20`20if`20((vms_major`20>=`205)`20`26`26`20(vms_minor`20>=`204))`20`7B X!`20`20`20`20`20if`20(sys$getjpiw`20(0,0,0,`26jpi_item_list,0,0,0)`20`26`201) V`20`7B X!`20`20`20`20`20`20`20int`20ident_count`20=`20jpi_return_length`20/`20sizeof V`20(struct`20id_attr); X!`20`20`20`20`20`20`20held_ids`5Bident_count`5D`20=`200; X!`20`20`20`20`20`20`20while`20(--ident_count`20>=`200)`20`7B X!`20`20`20`20`20`20`20`20`20held_ids`5Bident_count`5D`20=`20held_id_attr`5Bide Vnt_count`5D.identifier; X!`20`20`20`20`20`20`20`20`20if`20(held_ids`5Bident_count`5D`20==`20mgr_id)`20m Vgr_priv`20=`200; X!`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X`20`20`20`20else`20`7B X************** X***`20290,296 X`20`20`20`20`20`20`20`20if`20(held_ids`5Bident_count`5D`20==`20mgr_id)`20mgr_p Vriv`20=`200; X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X!`20#endif X`20`20`20`20if`20(mem_sysprv)`20nosysprv(); X`20`20`20`20return(mgr_priv); X`20`20`7D X---`20280,296`20----- X`20`20`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`20`20`7D X`20`20`20`20`20`20`7D X!`20`20`20else`20`7B X!`20`20`20`20`20holder`5B0`5D`20=`20(getgid()`20<<`2016)`20`7C`20getuid(); X!`20`20`20`20`20holder`5B1`5D`20=`200; X!`20`20`20`20`20idindx`20=`200; X!`20`20`20`20`20while`20((lstatus`20=`20sys$find_held(holder,`26id,0,`26contxt V))`20`26`201)`20`7B X!`20`20`20`20`20`20`20held_ids`5Bidindx++`5D`20=`20id; X!`20`20`20`20`20`20`20if`20(id`20==`20mgr_id)`20mgr_priv`20=`200; X!`20`20`20`20`20`20`20`7D X!`20`20`20`20`20held_ids`5Bidindx`5D`20=`200; X!`20`20`20`20`20sys$finish_rdb(`26contxt); X!`20`20`20`7D X`20`20`20`20if`20(mem_sysprv)`20nosysprv(); X`20`20`20`20return(mgr_priv); X`20`20`7D X***`20patchlist.h;-1 X---`20patchlist.h X************** X***`201,1 X`20`20=+=+=`20End`20=+=+= X---`201,2`20----- X+`20930831_newssite.c!bailey@genetics.upenn.edu X`20`20=+=+=`20End`20=+=+= $ call unpack 930831_NEWSSITE.PATCH;1 - 1578554516 "FORMAT STREAM_LF;CARRIAGE_CONTROL CARRIAGE_RETURN" 14 1 1 $ v=f$verify(v) $ exit