diff options
author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1996-03-24 09:27:20 +0000 |
---|---|---|
committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1996-03-24 09:27:20 +0000 |
commit | a7939d5aa6165c8480f314087f43e0ca0ed1d6eb (patch) | |
tree | 311eca7b6f7193f9965050bf7389fef52058f550 /libexec/talkd/process.c | |
parent | 110dbd1072fbc99e7ac739cc5addd367ab4dd8da (diff) | |
download | src-a7939d5aa6165c8480f314087f43e0ca0ed1d6eb.tar.gz src-a7939d5aa6165c8480f314087f43e0ca0ed1d6eb.zip |
Here is a patch to talkd which makes it send the request to the tty with
the lowest idle time.
Submitted by: loodvrij@gridpoint.com (Bruce J. Keeler)
Notes
Notes:
svn path=/head/; revision=14783
Diffstat (limited to 'libexec/talkd/process.c')
-rw-r--r-- | libexec/talkd/process.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libexec/talkd/process.c b/libexec/talkd/process.c index a83492bf09e8..fce70c652711 100644 --- a/libexec/talkd/process.c +++ b/libexec/talkd/process.c @@ -190,6 +190,7 @@ find_user(name, tty) int status; FILE *fd; struct stat statb; + time_t best = 0; char line[sizeof(ubuf.ut_line) + 1]; char ftty[sizeof(_PATH_DEV) - 1 + sizeof(line)]; @@ -204,17 +205,21 @@ find_user(name, tty) if (SCMPN(ubuf.ut_name, name) == 0) { strncpy(line, ubuf.ut_line, sizeof(ubuf.ut_line)); line[sizeof(ubuf.ut_line)] = '\0'; - if (*tty == '\0') { - status = PERMISSION_DENIED; + if (*tty == '\0' || best != 0) { + if (best == 0) + status = PERMISSION_DENIED; /* no particular tty was requested */ (void) strcpy(ftty + sizeof(_PATH_DEV) - 1, line); if (stat(ftty, &statb) == 0) { if (!(statb.st_mode & 020)) continue; - (void) strcpy(tty, line); - status = SUCCESS; - break; + if (statb.st_atime > best) { + best = statb.st_atime; + (void) strcpy(tty, line); + status = SUCCESS; + continue; + } } } if (strcmp(line, tty) == 0) { |