Subject: Re: CVS commit: src/usr.bin/tip
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Thor Lancelot Simon <tls@NetBSD.org>
List: source-changes
Date: 04/03/2006 05:57:27
--u3/rZRmxL6MmkK24
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Apr 03, 2006 at 12:10:36PM +0900, YAMAMOTO Takashi wrote:
> > > how about pppd, etc?
> > 
> > It would be reasonable to flock the device for those too if that is
> > what you mean.
> > 
> > Perry
> 
> are you going to convert all applications, including 3rd party ones?

I'm certainly not, and I doubt Perry is, but, honestly, using an ancient
file-writing-lock protocol to avoid stomping on other simultaneous
outbound serial port users really doesn't seem like it's worth that
much trouble to support -- in particular, it it certainly not worth
making all serial-port-using applications setuid!

The lock protocol *already* didn't work if one didn't run these
applications setuid; in many cases it just silently failed.

I think the attached should suffice for pppd.  Do you agree?

Thor

--u3/rZRmxL6MmkK24
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pppd.diff"

Index: tty.c
===================================================================
RCS file: /cvsroot/src/dist/pppd/pppd/tty.c,v
retrieving revision 1.2
diff -c -r1.2 tty.c
*** tty.c	20 Feb 2005 10:47:17 -0000	1.2
--- tty.c	3 Apr 2006 05:50:58 -0000
***************
*** 588,593 ****
--- 588,600 ----
  				goto errret;
  		}
  		ttyfd = real_ttyfd;
+ 		if (lockflag) 
+ 			if(flock(ttyfd, (LOCK_EX|LOCK_NB)) != 0) {
+ 				status = EXIT_LOCK_FAILED;
+ 				close(ttyfd);
+ 				goto errret;
+ 			}
+ 
  		if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
  		    || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
  			warn("Couldn't reset non-blocking mode on device: %m");

--u3/rZRmxL6MmkK24--