Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen Never invoke utmp_update() recursively if we ar...
details: https://anonhg.NetBSD.org/src/rev/2f6a7fbedc79
branches: trunk
changeset: 769654:2f6a7fbedc79
user: christos <christos%NetBSD.org@localhost>
date: Sat Sep 17 01:52:29 2011 +0000
description:
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()
diffstat:
lib/libc/gen/utmpx.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diffs (37 lines):
diff -r a1a3cc359fd8 -r 2f6a7fbedc79 lib/libc/gen/utmpx.c
--- a/lib/libc/gen/utmpx.c Sat Sep 17 01:50:54 2011 +0000
+++ b/lib/libc/gen/utmpx.c Sat Sep 17 01:52:29 2011 +0000
@@ -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));
Home |
Main Index |
Thread Index |
Old Index