From 07968755aa07a548a4609c6084122279008c90f6 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 15 Mar 2011 15:51:44 -0400 Subject: [PATCH] For legacy utmp, strip the /dev/ prefix before trying to determine slot since the ttys file does not include the /dev/ prefix. --- src/utmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utmp.c b/src/utmp.c index f557703ce..e5b334d79 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -259,6 +259,10 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd) int slot, rval = FALSE; FILE *fp; + /* Strip off /dev/ prefix from line as needed. */ + if (strncmp(to_line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) + to_line += sizeof(_PATH_DEV) - 1; + /* Find slot for new entry. */ slot = utmp_slot(to_line, ttyfd); if (slot <= 0) @@ -267,9 +271,6 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd) if ((fp = fopen(_PATH_UTMP, "r+")) == NULL) goto done; - /* Strip off /dev/ prefix from line as needed. */ - if (strncmp(to_line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) - to_line += sizeof(_PATH_DEV) - 1; if (from_line != NULL) { if (strncmp(from_line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) from_line += sizeof(_PATH_DEV) - 1; -- 2.40.0