From: Todd C. Miller Date: Tue, 15 Mar 2011 19:51:44 +0000 (-0400) Subject: For legacy utmp, strip the /dev/ prefix before trying to determine X-Git-Tag: SUDO_1_8_1~96^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07968755aa07a548a4609c6084122279008c90f6;p=sudo For legacy utmp, strip the /dev/ prefix before trying to determine slot since the ttys file does not include the /dev/ prefix. --- 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;