On Sun, Nov 27, 2016 at 12:31 AM, Hajime Edakawa <hajime.edak...@gmail.com> wrote: > Dear tech, > > I guessed it more better to use fd instead of i. > > Would this be OK? > > Sincerely, tech > Edakawa > > Index: doas.c > =================================================================== > RCS file: /cvs/src/usr.bin/doas/doas.c,v > retrieving revision 1.68 > diff -u -p -u -r1.68 doas.c > --- doas.c 5 Oct 2016 23:28:28 -0000 1.68 > +++ doas.c 27 Nov 2016 08:20:45 -0000 > @@ -256,7 +256,7 @@ main(int argc, char **argv) > uid_t target = 0; > gid_t groups[NGROUPS_MAX + 1]; > int ngroups; > - int i, ch; > + int i, ch, fd; > int sflag = 0; > int nflag = 0; > char cwdpath[PATH_MAX]; > @@ -279,10 +279,10 @@ main(int argc, char **argv) > confpath = optarg; > break; > case 'L': > - i = open("/dev/tty", O_RDWR); > - if (i != -1) > - ioctl(i, TIOCCLRVERAUTH); > - exit(i != -1); > + fd = open("/dev/tty", O_RDWR); > + if (fd != -1) > + ioctl(fd, TIOCCLRVERAUTH); > + exit(fd != -1);
While you're at it, I think this exit status is backwards. Currently `doas -L` exits 0 if the open failed. > case 'u': > if (parseuid(optarg, &target) != 0) > errx(1, "unknown user"); >