Module Name: src Committed By: christos Date: Sat Sep 17 01:52:29 UTC 2011
Modified Files: src/lib/libc/gen: utmpx.c Log Message: Never invoke utmp_update() recursively if we are root. Instead close the read-only file so it can be opened later. It can happen when a setuid program utmp_update, seteuid(ruid) -> getutxent() -> seteuid(0) -> pututxent() To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libc/gen/utmpx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/gen/utmpx.c diff -u src/lib/libc/gen/utmpx.c:1.26 src/lib/libc/gen/utmpx.c:1.27 --- src/lib/libc/gen/utmpx.c:1.26 Sat Jan 10 21:46:27 2009 +++ src/lib/libc/gen/utmpx.c Fri Sep 16 21:52:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: utmpx.c,v 1.26 2009/01/11 02:46:27 christos Exp $ */ +/* $NetBSD: utmpx.c,v 1.27 2011/09/17 01:52:29 christos Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: utmpx.c,v 1.26 2009/01/11 02:46:27 christos Exp $"); +__RCSID("$NetBSD: utmpx.c,v 1.27 2011/09/17 01:52:29 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -247,9 +247,15 @@ if (utx == NULL) return NULL; - if (strcmp(_PATH_UTMPX, utfile) == 0) - if ((fp != NULL && readonly) || (fp == NULL && geteuid() != 0)) - return utmp_update(utx); + if (strcmp(_PATH_UTMPX, utfile) == 0) { + if (geteuid() == 0) { + if (fp != NULL && readonly) + endutxent(); + } else { + if (fp == NULL || readonly) + return utmp_update(utx); + } + } (void)memcpy(&temp, utx, sizeof(temp));