Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/usr.bin/tip



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
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");


Home | Main Index | Thread Index | Old Index