Home Directory Determination for RSX-11M[+] Joseph S. Sventek Computer Science & Mathematics Department Lawrence Berkeley Laboratory Berkeley, CA 94720 A common notion in most multi-user operating systems which support permanent file systems is that of a user's home directory. This home directory, which is the default area of a disk (or disks) where the user's file are kept, can be used to keep user-specific information in known files. RSX-11M[+], as well as other DEC operating systems, exploits this fact by permitting the user to create a login.cmd file, with commands for the indirect command file processor to execute whenever the user logs into the system. Other possible uses for the home directory include user-specific initialization files for screen editors, mail systems, teleconferencing systems, etc. For the home directory concept to be useful, it must be easy for utilities to determine the home directory for the current user. RSX-11M[+] presents a problem in this respect, since no conscious attempt is made to supply this information to the user. The purpose of this note is to provide a means for programs to determine the home directory unambiguously and easily. For RSX-11M[+], two pieces of information are necessary to construct the home directory: the device specification and the UIC on that device. When logging in, HELLO creates a logical device assignment for the pseudo-device SY:, causing it to point to the disk on which the user's UIC resides. This device assignment is performed with the /LOGIN switch to prevent the user from deassigning it. At any point in time, SY: points to the default device for file specifications. In order to permit the user to find the home directory, it is necessary to create another pseudo-device logical device assignment for each user. The correction file for HELLO which appears in the appendix causes the command ASN SY:=HO:/LOGIN to be executed upon the successful assignment of SY: before the terminal is marked as non-privileged. Thus, HO: always points to the home disk. -1- Home Directory Determination There are actually three UIC's of importance in the environment of a running task: 1. The default UIC to use if the UIC is omitted from a file specification. This information is kept in the field U.UIC of the TI: UCB and also in the H.DUIC field of each task header. 2. The protection UIC, which is used to determine whether a user can access a file. This information is kept in the H.CUIC field of each task header. 3. The login UIC, which represents the user's login user identification code. This information is kept in the the field U.LUIC of the TI: UCB. If this was the actual situation, then the determination of the home UIC would be straightforward. Unfortunately, when a privileged user performs a SET /UIC=[g,m] command, the system replaces the contents of U.LUIC in the terminal UCB, in addition to changing the contents of U.UIC. If INSTALL always used the U.LUIC field to initialize the H.CUIC field when installing an image, this would make sense. BUT, INS only uses the U.LUIC field if the user is non-privileged, filling in the H.CUIC field for privileged users from the U.UIC field. Thus one can see a discrepancy in the way the U.LUIC field is used. Since the U.LUIC field is not used by INSTALL for privileged users, one can apply the patch to SPROVFDT which appears in the appendix. This patch simply eliminates the update of the U.LUIC field for privileged users when performing a SET /UIC command. Thus, the U.LUIC field of the terminal UCB always contains the login UIC. This patch, which was taken from a set of patches by Greg Thompson, does not impact the performance of any RSX utilities. Although one would expect that this patch would solve the problem, such is not the case. The executive code which performs the GTSK$ directive returns the contents of the H.CUIC header field as the last word of the buffer, not the U.LUIC field of the TI: UCB. Fortunately, since GTSK$ is an optional directive, none of the DEC utilities use it. Therefore, the patch for DRGTK which appears in the appendix causes the appropriate information to be returned to the user. The author's system has been running successfully with these patches for RSX-11M v.3.2.e since 10/1/81. Utilities exploiting the home directory concept which have been implemented include a mail system, a teleconferencing system and user-dependent editor initialization files. -2- Home Directory Determination The appendix contains the correction files for the following source modules: [11,10]DRGTK.MAC [12,10]HELLO.MAC [12,10]SPROVFDT.MAC A similar correction to [12,10]SPROV.MAC may be made if the full-duplex terminal driver is not in use. The correction to HELLO has three separate audit trails: 1. JSS000 - causes STOP bit synchronization to be used for the SPWN of ASN if S$$TOP is defined. This supercedes the Digital-supplied correction from auto-patch, RA300. 2. JSS001 - causes @LB:[1,2]SYSLOGIN.CMD to be invoked instead of the user's LOGIN.CMD file. This correction may be left out with no impact on the home directory situation. A sample SYSLOGIN.CMD file is included in the appendix for those wishing to try this feature. 3. JSS002 - the corrections necessary to cause the assignment of the HO: pseudo-device. Finally, a FORTRAN-callable subroutine which returns the home directory specification to the user as a 0-byte terminated string is included. Note that it will only work if the patches described in this letter are applied. -3- Appendix DRGTK.COR OU:DRGTK.MAC;2/AU:72./-BF=IN:[11,10]DRGTK.MAC;1 \ -24 ; ; Joseph S. Sventek, 01-Oct-81 ; ; JS001 -- return U.LUIC in protection word if M$$MUP % -32,,/; JS001/ .MCALL UCBDF$ UCBDF$ ; DEFINE UCB OFFSETS -130,,/; JS001/ .IF DF M$$MUP MOV T.UCB(R5),R0 ; GET TI: UCB ADDRESS MOV U.LUIC(R0),(R3) ; COPY LOGIN UIC .IFF -132,,/; JS001/ .ENDC / SPROVFDT.COR SPROVFDT.MAC;2/AU/-BF=[12,10]SPROVFDT.MAC;1 \ -2,2 .IDENT /03.9A/ -89 ; GAT001 DON'T CHANGE U.LUIC ON SET /UIC ; % -830,834,/;GAT001/ 36$: ; REF LABEL / HELLO.COR OU:HELLO.MAC;2/-BF/AU:72.=IN:[12,10]HELLO.MAC;1 \ -2,4 .IDENT /02.1/ ; -4- Appendix ; COPYRIGHT (C) 1976, 1978,1979 -24,24 ; VERSION: 02.1 -96 ; JSS000 12-DEC-79 DO STOP/WAIT CORRECTLY ; ; JSS001 10-JAN-80 Hello spawns @lb:[1,2]syslogin.cmd to perform system- ; dependent login processing. The last thing such a ; command file should perform is to invoke the user's ; login file. ; ; JSS002 01-OCT-81 perform ASN SY:=HO:/LOGIN % -102,102,/;JSS000/ .MCALL SPWN$ .IF DF S$$TOP .MCALL STSE$ .IFF .MCALL WTSE$ .ENDC -118,,/;JSS002/ HOME: .ASCII %ASN SY:=HO:/LOGIN% HOMLEN=.-HOME -122,122,/;JSS000/ .IF DF S$$TOP EFNDPB: STSE$ EFN1 .IFF EFNDPB: WTSE$ EFN1 .ENDC -246,247,/; JSS001/ .WORD 8. ; .WORD HELP ; -285,290,/; JSS001/ FILNAM: .ASCII /LOGIN.TXT/ ; HELP: .ASCII /HELP.HLP/ ; ; ; THE FOLLOWING FOUR LINES MUST BE KEPT IN ORDER ; LOGINC: .ASCII /@/ ; START OF INDIRECT COMMAND LINE DEVNAM: .ASCII /LB0:/ ; DEVICE FOR [1,2]HELP.TXT AND LOGIN.TXT DIRNAM: .ASCII /[1,2]/ LOGINN: .ASCIZ /SYSLOGIN.CMD/<15> ; ; ; THE PRECEDING FOUR LINES MUST BE KEPT IN ORDER ; SYSLOG: .ASCIZ /@SYSLOGIN.CMD/ ; TELL USER STARTING SYSTEM LOGIN FILE -415,416,/; JSS001/ -751,751,/;JSS000/ DIR$ #EFNDPB ; WAIT UNTIL ASSIGN COMPLETES -752,752,/;JSS002/ MOV #HOME,SPWDPB+S.PWCA ; ADDRESS OF ASN SY:=HO:/LOGIN -5- Appendix MOV #HOMLEN,SPWDPB+S.PWCL ; LENGTH OF SAME DIR$ #SPWDPB ; SPAWN COMMAND BCS 170$ ; IF FAILED, FORGET IT DIR$ #EFNDPB ; WAIT FOR IT BR 170$ ; CONTINUE ON -841,841,/; JSS001/ MOV #HLPDSP,R2 ; DATA SET POINTER MOV #12.,10(R2) ; 12 CHARACTERS IN SYSLOGIN.CMD MOV #LOGINN,12(R2) ; SYSLOGIN.CMD NOT HELP.HLP -849,849,/; JSS001/ MOV #SYSLOG,R0 ; SET COMMAND ADDRESS / HOMDIR.MAC .title homdir - return home directory spec to user ;+ ; subroutine homdir(buf) ; ; the home directory spec is returned to the user as a 0-byte ; terminated string in buf ; ; this routine depends upon the corrections to DRGTK, SPROVFDT ; and HELLO published in the multi-tasker ;- ap=%5 buf=2 .mcall gtsk$s .psect $r.rod,con,ro,rel,lcl,d device: .asciz "HO:" .even .psect $r.roi,con,ro,rel,lcl,i .enabl lsb homdir:: sub #32.,sp ; space for GTSK buffer mov sp,r0 ; address of buffer gtsk$s r0 ; get task parameters mov g.tsdu(r0),r3 ; UIC to format add #32.,sp ; restore stack mov buf(ap),r2 ; address of user's buffer mov #device,r1 ; source buffer 10$: movb (r1)+,(r2)+ ; copy character to buffer bne 10$ ; if not null, go again tstb -(r2) ; back up one byte clr r4 ; no leading zeroes, separators jsr pc,.ppasc ; format UIC into buffer clrb (r2) ; null terminate string return -6- Appendix .end SYSLOGIN.CMD .ENABLE SUBSTITUTION .ENABLE QUIET .; .; put site-specific startup commands in here .; for example, if you use the Software Tools mail system, .; install POSTMN as ...ITM (for is there mail?) in the tools startup .; then place the command .; ITM .; here, to notify the user whether he has mail or not .; .DISABLE QUIET .TESTFILE SY0:''LOGIN.CMD .IF NE 1 .GOTO DONE @SY0:''LOGIN.CMD .DONE: -7-