Loading...
--- Libc/Libc-320/gen/setlogin.c
+++ Libc/Libc-1044.1.2/gen/setlogin.c
@@ -1,9 +1,7 @@
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
@@ -57,12 +55,25 @@
#include <unistd.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
-extern int _setlogin(const char* name);
+extern int __setlogin(const char* name);
-extern int _logname_valid; /* shared with getlogin() */
+extern pthread_mutex_t __logname_mutex;
+extern char *__logname;
int setlogin(const char* name)
{
- return (_logname_valid = _setlogin(name));
+ pthread_mutex_lock(&__logname_mutex);
+
+ int res = __setlogin(name);
+ if (res == 0 && __logname != NULL) {
+ __logname[0] = 0;
+ }
+
+ pthread_mutex_unlock(&__logname_mutex);
+
+ return res;
}