subroutine kill_user(*) c c NU PRIME TIME FACILITY V 2.0 c Northeastern University Academic Computer Services c 360 Huntington Avenue c Boston, Mass 02115 c c David Bernardo, Author c c This routine deletes a user process manually. All instances c of a given username will be deleted. This would be used in c special circumstances and is not used in normal operations to c delete a process that has exceeded its allowed time. c common /valid/valid_commands,group byte valid_commands(14),killer,loc_space integer*4 e,code,efn,seedpid,ss$_normal,jpibuf(13),ss$_nomoreproc, 1 lib$get_ef,lib$free_ef,sys$getjpi,sys$waitfr,ios,group, 2 no_such_record,record_locked,read_ok,pid(10),ret_code, 3 jpi$_terminal,jpi$_username,jpi$_pid,sys$delprc, 4 pid_l,ttynum_l,username_l,temp_pid,grp_l,grp,jpi$_grp integer*2 cluster_num,count,dummy,def_slice,def_wait,victim, 1 def_threshold,sysgrp,sys_priv_grp,lim_priv_grp,num_logins, 2 cluster_logins character ttynum*7,terminal*4,username*12,victims(10)*12,ans*1, 1 terminals(10)*4,location(10)*20,temp_user*12,loc*20 parameter (jpi$_pid='3190004'x, 1 jpi$_username='202000c'x, 2 jpi$_terminal='31d0007'x, 2 jpi$_grp='3080004'x, 3 ss$_normal=1, 4 ss$_nomoreproc='9a8'x, 5 no_such_record=36, 6 record_locked=52, 7 read_ok=0) c jpibuf(1)=jpi$_terminal jpibuf(2)=%loc(ttynum) jpibuf(3)=%loc(ttynum_l) jpibuf(4)=jpi$_pid jpibuf(5)=%loc(temp_pid) jpibuf(6)=%loc(pid_l) jpibuf(7)=jpi$_username jpibuf(8)=%loc(temp_user) jpibuf(9)=%loc(username_l) jpibuf(10)=jpi$_grp jpibuf(11)=%loc(grp) jpibuf(12)=%loc(grp_l) jpibuf(13)=0 seedpid=-1 count=0 e=1 code=lib$get_ef(efn) if(code.eq.ss$_normal) then c c Open the terminal, permanent cluster and default data bases. c call open_file_read(2,*997) call open_file_read(3,*997) call open_file_read(4,*997) read(4,err=997,end=997)def_slice,def_wait,def_threshold,sysgrp, 1 sys_priv_grp,lim_priv_grp,num_logins,cluster_logins close(unit=4) c c Solicit username of process(es) to be deleted. c print 1 1 format(1x,'Username: ',$) read(5,2,err=30,end=30)username 2 format(a12) call upcase(username) killer=1 if(group.le.lim_priv_grp)killer=1 if(group.le.sys_priv_grp)killer=0 c c Get info on next instance of victim login. c do while (e.ne.ss$_nomoreproc) e=sys$getjpi(%val(efn),%ref(seedpid),,%ref(jpibuf),,,) if(e.eq.ss$_normal) then code=sys$waitfr(%val(efn)) if(username.eq.temp_user)then if(ttynum_l.gt.0)then if(killer.eq.0.or. 1 (killer.eq.1.and.grp.gt.sys_priv_grp))then terminal=ttynum(1:4) loc='Unknown' read(2,key=ttynum(1:4),iostat=ios)terminal,cluster_num unlock(unit=2) if(ios.eq.read_ok)then read(3,key=cluster_num)cluster_num,dummy,dummy,loc endif count=count+1 pid(count)=temp_pid victims(count)=temp_user terminals(count)=terminal location(count)=loc else print*, 1'PTC-KILLUSER No privilege to terminate requested user.' code=lib$free_ef(efn) return 1 endif endif endif endif enddo code=lib$free_ef(efn) close(unit=2) close(unit=3) if(count.eq.0)then print*,'PTC-KILLUSER User is not logged in.' return 1 endif print 5 5 format(/,5x,'Victim',5x,'Terminal',5x,'Location',/) c c Display all instances of user logins, prompt for which one to kill. c do i = 1,count print 10,i,terminals(i),location(i) 10 format(7x,i2,9x,a4,7x,a20) enddo print 15 15 format(/,1x,'Enter Victim number (CR = abort request): ',$) read(5,20,end=30,err=30)victim 20 format(i2) c c if selection valid, kill the user. c if(victim.gt.0.and.victim.le.count)then ret_code=sys$delprc(pid(victim),) if(ret_code.eq.ss$_normal)then loc_space=index(victims(victim),' ') print 25,victims(victim)(1:loc_space),terminals(victim), 1 location(victim) 25 format(/,1x,'PTC-KILLUSER Killed user: ', 1 a,' terminal: ', 2 a4,' cluster: ',a20) return 1 else print*, 'PTC-KILLUSER Error terminating user.' return 1 endif endif endif 30 print *,'PTC-KILLUSER Request aborted.' 997 return 1 end