[comp.unix.xenix] KERMIT vs HDB UUCP lock files

sralston@sfc.Wichita.NCR.COM (sralston) (11/10/89)

As I promised a few weeks ago, I'm posting a XENIX patch for Kermit
to fix the HoneyDanBer (HDB) UUCP file locking problem.  This patch
was created using the Kermit version 4E(072) sources, which Shabtai
Lerner was kind enough to mail me.  Thank you Shabtai.  Thanks to all
others who responded to me with e-mail on the subject; especially
those who I didn't personally respond back to with 'e-mail thanks'.

At the time I discovered the problem, I was using Kermit version 4D(060)
which is over 3 years old (Apr 86).  The problem is still present in
version 4E(072), dated 24 Jan 89.  You should NOT apply this patch
if you are NOT running the HDB version of UUCP on your XENIX system
(i.e., pre-2.3.x releases of XENIX, I believe).

The problem is that the sources assume you are running XENIX version
2.2.x; i.e. a pre-HDB version of UUCP for XENIX.  As a result, lock
files are created with the Process-ID (of the process running Kermit)
in integer format in the lock file (which is 4 bytes on XENIX/386 and
2 bytes on XENIX/286).  HDB UUCP expects the PID to be written in ASCII
characters, right justified in a field of 10 char's (that's 11
characters total in the lock file, including the LF).

HDB UUCP (on XENIX) does not recognize the [integer format] lock file
created by Kermit as being a valid format, and therefore does not
honor the lock on the line.  A few of us have found this out the
hard way; like Paul Telles in Hawaii who was 3/4 through a 4 Mbyte file
transfer when UUCP polled the line and stomped on his transfer!  :-(

Having said all that, here is the patch file.  It was created using
'diff -c' (context style diff) on a Apollo computer in the bsd4.2
environment.  And NO, unfortunately, I don't have sources to a
[context compatible] version of diff for XENIX or any other **IX
system, although I would be glad to here from anybody who does!  :-) 

To patch the 'ckutio.c' source file:

  1.	Cut out the diff lines (below) and save to a file, preferably
	a file in your kermit source directory.  For this example
	I'll save it to a file called 'kermit.pXHDB'

  2.	Change directory to your kermit source directory:
		'cd kermit_src_dir'

  3.	Run patch, using input from the file just created.
		'patch -p < kermit.pXHDB'
	or	'cat kermit.pXHDB | patch -p'

	If you don't have patch, examine the diff file, and
	add the 11 lines having '+'s (at the beginning of the line)
	to your ckutio.c source file in the appropriate places
	[may be difficult but not impossible; good luck :-) ].

  4.	Re-make wermit and rename to kermit, as usual.
		'make sco386'
	or	'make sco286'

  5.	Check to verify the new version works correctly by running
	[the new] kermit, and issue a command like 'set line /dev/tty1a'.
	Examine the lock file /usr/spool/uucp/LCK..tty1a [from another
	multiscreen :-) ], to verify that it is an ASCII file with
	the PID of the process running kermit.

--------------------------------------------------------------------cut here
Index: ckutio.c
*** ckutio.c	Mon Jul  3 10:09:43 1989
--- kermit.hack/ckutio.c	Thu Nov  9 09:28:03 1989
***************
*** 942,947
  #ifdef ATT3BX
      FILE *lck_fild;
  #endif /* att3bx */
      int lck_fil, l4l;
      int pid_buf = getpid();             /* pid to save in lock file */
  

--- 942,950 -----
  #ifdef ATT3BX
      FILE *lck_fild;
  #endif /* att3bx */
+ #ifdef XENIX		/* fixed for XENIX HDB UUCP - 89/11/09 sralston */
+     FILE *lck_fild;
+ #endif /* xenix */
      int lck_fil, l4l;
      int pid_buf = getpid();             /* pid to save in lock file */
  
***************
*** 959,964
      write (lck_fil, string, 11);
      }
  #else
      write (lck_fil, &pid_buf, sizeof(pid_buf) ); /* uucp expects int in file */
  #endif /* att3bx */
      close (lck_fil);

--- 962,974 -----
      write (lck_fil, string, 11);
      }
  #else
+ #ifdef XENIX		/* fixed for XENIX HDB UUCP - 89/11/09 sralston */
+     {
+     char string[12];
+     sprintf(string,"%10d\n", pid_buf); /* Fixed by JZ */
+     write (lck_fil, string, 11);
+     }
+ #else
      write (lck_fil, &pid_buf, sizeof(pid_buf) ); /* uucp expects int in file */
  #endif /* xenix */
  #endif /* att3bx */
***************
*** 960,965
      }
  #else
      write (lck_fil, &pid_buf, sizeof(pid_buf) ); /* uucp expects int in file */
  #endif /* att3bx */
      close (lck_fil);
      chmod(flfnam,0644);			/* make it readable by uucp */

--- 970,976 -----
      }
  #else
      write (lck_fil, &pid_buf, sizeof(pid_buf) ); /* uucp expects int in file */
+ #endif /* xenix */
  #endif /* att3bx */
      close (lck_fil);
      chmod(flfnam,0644);			/* make it readable by uucp */
--------------------------------------------------------------------cut here

-- 
Steve Ralston       NCR Corp, PPD - Wichita, 3718 N Rock Rd, Wichita, KS 67226
Advanced Product/Process Technologies (ms14)        Voice-Plus:  654-8058
Internet: S.Ralston@Wichita.NCR.COM                 Voice: (316) 636-8058
UUCP: uunet!ncrlnk!ncrwic!s.ralston                   FAX: (316) 636-8889