From ebd0305a58a21d5900efed459ddec0e49d4fe6eb Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Tue, 2 Mar 2010 07:45:20 +0000 Subject: [PATCH] talk - unbreak for unix98 ptys * Unbreak talk, which relied on seeing old-style ptys. When I introduced the unix98 ptys. * This assumption would not work anymore, since the last slash is not the slash after /dev, but rather the one after /dev/pts. Later opening 0 instead of pts/0 would give an error. Reported-by: Peter Avalos, Matt Dillon --- usr.bin/write/write.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usr.bin/write/write.c b/usr.bin/write/write.c index ce98cec48e..fb2daac7f4 100644 --- a/usr.bin/write/write.c +++ b/usr.bin/write/write.c @@ -67,7 +67,6 @@ static int utmp_chk(const char *, const char *); int main(int argc, char **argv) { - char *cp; time_t atime; uid_t myuid; int msgsok, mymsgok, myttyfd; @@ -86,8 +85,8 @@ main(int argc, char **argv) errx(1, "can't find your tty"); if (!(mytty = ttyname(myttyfd))) errx(1, "can't find your tty's name"); - if ((cp = strrchr(mytty, '/'))) - mytty = cp + 1; + if (!strncmp(mytty, _PATH_DEV, strlen(_PATH_DEV))) + mytty += strlen(_PATH_DEV); if (term_chk(mytty, &mymsgok, &atime, 1)) exit(1); if (!mymsgok) -- 2.11.4.GIT