diff -ru in.talkd/process.c in.talkd.new/process.c --- in.talkd/process.c 2006-11-18 00:01:36.000000000 +0100 +++ in.talkd.new/process.c 2006-11-27 22:37:42.064504000 +0100 @@ -185,6 +185,8 @@ struct utmpx *ubuf; int tfd; char dev[MAXPATHLEN]; + struct stat stbuf; + int problem = NOT_HERE; setutxent(); /* reset the utmpx file */ @@ -207,15 +209,23 @@ closelog(); continue; } - (void) close(tfd); if (*tty == '\0') { /* * No particular tty was requested. */ + if (fstat(tfd, &stbuf) < 0 || + (stbuf.st_mode&020) == 0) { + (void) close(tfd); + problem = PERMISSION_DENIED; + continue; + } + (void) close(tfd); (void) strlcpy(tty, ubuf->ut_line, TTY_SIZE); endutxent(); /* close the utmpx file */ return (SUCCESS); - } else if (strcmp(ubuf->ut_line, tty) == 0) { + } + (void) close(tfd); + if (strcmp(ubuf->ut_line, tty) == 0) { endutxent(); /* close the utmpx file */ return (SUCCESS); } @@ -223,5 +233,5 @@ } endutxent(); /* close the utmpx file */ - return (NOT_HERE); + return (problem); }