Don't (unnecessarily) parse wtmp, force ID0logout() to DTRT instead.
This commit is contained in:
parent
d5152f15d2
commit
6d6b73fcc1
@ -214,7 +214,7 @@ ID0login(struct utmp *ut)
|
||||
}
|
||||
|
||||
void
|
||||
ID0logout(const char *device)
|
||||
ID0logout(const char *device, int nologout)
|
||||
{
|
||||
struct utmp ut;
|
||||
|
||||
@ -222,7 +222,7 @@ ID0logout(const char *device)
|
||||
ut.ut_line[sizeof ut.ut_line - 1] = '\0';
|
||||
|
||||
ID0set0();
|
||||
if (logout(ut.ut_line)) {
|
||||
if (nologout || logout(ut.ut_line)) {
|
||||
log_Printf(LogID0, "logout(\"%s\")\n", ut.ut_line);
|
||||
logwtmp(ut.ut_line, "", "");
|
||||
log_Printf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut.ut_line);
|
||||
|
@ -41,7 +41,7 @@ extern int ID0uu_lock(const char *);
|
||||
extern int ID0uu_lock_txfr(const char *, pid_t);
|
||||
extern int ID0uu_unlock(const char *);
|
||||
extern void ID0login(struct utmp *);
|
||||
extern void ID0logout(const char *);
|
||||
extern void ID0logout(const char *, int);
|
||||
extern int ID0bind_un(int, const struct sockaddr_un *);
|
||||
extern int ID0connect_un(int, const struct sockaddr_un *);
|
||||
extern int ID0kill(pid_t, int);
|
||||
|
@ -313,45 +313,11 @@ physical_Close(struct physical *p)
|
||||
physical_StopDeviceTimer(p);
|
||||
if (p->Utmp) {
|
||||
if (p->handler && (p->handler->type == TCP_DEVICE ||
|
||||
p->handler->type == UDP_DEVICE)) {
|
||||
/*
|
||||
* We've got to do more than logout() does here... we need to identify
|
||||
* the entry that we made at login time....
|
||||
*/
|
||||
struct utmp ut, want;
|
||||
char *colon;
|
||||
int fd;
|
||||
|
||||
strncpy(want.ut_line, PPPOTCPLINE, sizeof want.ut_line);
|
||||
strncpy(want.ut_host, p->name.base, sizeof want.ut_host);
|
||||
colon = memchr(want.ut_host, ':', sizeof want.ut_host);
|
||||
if (colon)
|
||||
*colon = '\0';
|
||||
|
||||
if ((fd = ID0open(_PATH_WTMP, O_RDWR, 0)) >= 0) {
|
||||
lseek(fd, -(off_t)sizeof(struct utmp), L_XTND);
|
||||
while (read(fd, &ut, sizeof(struct utmp)) == sizeof(struct utmp)) {
|
||||
if (*ut.ut_name &&
|
||||
!memcmp(ut.ut_line, want.ut_line, sizeof ut.ut_line) &&
|
||||
!memcmp(ut.ut_host, want.ut_host, sizeof ut.ut_host) &&
|
||||
p->Utmp == ut.ut_time) {
|
||||
memset(ut.ut_name, '\0', sizeof ut.ut_name);
|
||||
memset(ut.ut_host, '\0', sizeof ut.ut_name);
|
||||
time(&ut.ut_time);
|
||||
lseek(fd, 0, L_XTND);
|
||||
write(fd, &ut, sizeof ut);
|
||||
*want.ut_line = '\0';
|
||||
break;
|
||||
}
|
||||
lseek(fd, -((off_t)sizeof(struct utmp) << 1), L_INCR);
|
||||
}
|
||||
close(fd);
|
||||
if (*want.ut_line)
|
||||
log_Printf(LogWARN, "Cannot locate %s/%.*s in %s\n", PPPOTCPLINE,
|
||||
(int)(sizeof want.ut_host), want.ut_host, _PATH_WTMP);
|
||||
}
|
||||
} else
|
||||
ID0logout(p->name.base);
|
||||
p->handler->type == UDP_DEVICE))
|
||||
/* Careful - we logged in on line ``ppp'' with IP as our host */
|
||||
ID0logout(PPPOTCPLINE, 1);
|
||||
else
|
||||
ID0logout(p->name.base, 0);
|
||||
p->Utmp = 0;
|
||||
}
|
||||
newsid = tcgetpgrp(p->fd) == getpgrp();
|
||||
|
Loading…
x
Reference in New Issue
Block a user