Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/talkd utmpx support
details: https://anonhg.NetBSD.org/src/rev/83660211decc
branches: trunk
changeset: 535489:83660211decc
user: christos <christos%NetBSD.org@localhost>
date: Tue Aug 20 13:56:50 2002 +0000
description:
utmpx support
diffstat:
libexec/talkd/Makefile | 7 +++++--
libexec/talkd/process.c | 33 +++++++++++++--------------------
2 files changed, 18 insertions(+), 22 deletions(-)
diffs (111 lines):
diff -r 8a611bf4cda3 -r 83660211decc libexec/talkd/Makefile
--- a/libexec/talkd/Makefile Tue Aug 20 13:55:58 2002 +0000
+++ b/libexec/talkd/Makefile Tue Aug 20 13:56:50 2002 +0000
@@ -1,10 +1,13 @@
-# $NetBSD: Makefile,v 1.8 1997/10/08 09:07:37 mrg Exp $
+# $NetBSD: Makefile,v 1.9 2002/08/20 13:56:50 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
PROG= ntalkd
-SRCS= talkd.c announce.c process.c table.c print.c
+SRCS= talkd.c announce.c process.c table.c print.c utmpentry.c
MAN= talkd.8
DPADD+=${LIBUTIL}
LDADD+=-lutil
+.PATH.c: ${.CURDIR}/../../usr.bin/who
+CPPFLAGS+=-I${.CURDIR}/../../usr.bin/who -DSUPPORT_UTMPX -DSUPPORT_UTMP
+
.include <bsd.prog.mk>
diff -r 8a611bf4cda3 -r 83660211decc libexec/talkd/process.c
--- a/libexec/talkd/process.c Tue Aug 20 13:55:58 2002 +0000
+++ b/libexec/talkd/process.c Tue Aug 20 13:56:50 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process.c,v 1.6 1998/07/04 19:31:05 mrg Exp $ */
+/* $NetBSD: process.c,v 1.7 2002/08/20 13:56:50 christos Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)process.c 8.2 (Berkeley) 11/16/93";
#else
-__RCSID("$NetBSD: process.c,v 1.6 1998/07/04 19:31:05 mrg Exp $");
+__RCSID("$NetBSD: process.c,v 1.7 2002/08/20 13:56:50 christos Exp $");
#endif
#endif /* not lint */
@@ -64,10 +64,11 @@
#include <stdio.h>
#include <string.h>
#include <paths.h>
-#include <utmp.h>
#include "extern.h"
+#include "utmpentry.h"
+
void
process_request(mp, rp)
CTL_MSG *mp;
@@ -189,35 +190,28 @@
find_user(name, tty)
char *name, *tty;
{
- struct utmp ubuf;
int status;
- FILE *fd;
struct stat statb;
- char line[sizeof(ubuf.ut_line) + 1];
- char ftty[sizeof(_PATH_DEV) - 1 + sizeof(line)];
+ struct utmpentry *ep;
+ char ftty[sizeof(_PATH_DEV) + sizeof(ep->line)];
time_t atime = 0;
int anytty = 0;
- if ((fd = fopen(_PATH_UTMP, "r")) == NULL) {
- fprintf(stderr, "talkd: can't read %s.\n", _PATH_UTMP);
- return (FAILED);
- }
-#define SCMPN(a, b) strncmp(a, b, sizeof (a))
+ (void)getutentries(NULL, &ep);
+
status = NOT_HERE;
(void) strcpy(ftty, _PATH_DEV);
if (*tty == '\0')
anytty = 1;
- while (fread((char *) &ubuf, sizeof ubuf, 1, fd) == 1) {
- if (SCMPN(ubuf.ut_name, name) != 0)
+ for (; ep; ep = ep->next) {
+ if (strcmp(ep->name, name) != 0)
continue;
- (void)strncpy(line, ubuf.ut_line, sizeof(ubuf.ut_line));
- line[sizeof(ubuf.ut_line)] = '\0';
if (anytty) {
/* no particular tty was requested */
/* XXX strcpy is safe */
- (void)strcpy(ftty + sizeof(_PATH_DEV) - 1, line);
+ (void)strcpy(ftty + sizeof(_PATH_DEV) - 1, ep->line);
if (stat(ftty, &statb) == 0) {
if (!(statb.st_mode & S_IWGRP)) {
if (status != SUCCESS)
@@ -226,15 +220,14 @@
}
if (statb.st_atime > atime) {
atime = statb.st_atime;
- (void)strcpy(tty, line);
+ (void)strcpy(tty, ep->line);
status = SUCCESS;
}
}
- } else if (strcmp(line, tty) == 0) {
+ } else if (strcmp(ep->line, tty) == 0) {
status = SUCCESS;
break;
}
}
- (void)fclose(fd);
return (status);
}
Home |
Main Index |
Thread Index |
Old Index