Index: head/lib/libc/amd64/sys/Makefile.inc =================================================================== --- head/lib/libc/amd64/sys/Makefile.inc +++ head/lib/libc/amd64/sys/Makefile.inc @@ -9,7 +9,7 @@ amd64_set_gsbase.c MDASM= vfork.S brk.S cerror.S exect.S getcontext.S \ - sbrk.S setlogin.S + sbrk.S # Don't generate default code for these syscalls: NOASM+= vfork.o Index: head/lib/libc/amd64/sys/setlogin.S =================================================================== --- head/lib/libc/amd64/sys/setlogin.S +++ head/lib/libc/amd64/sys/setlogin.S @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)setlogin.s 5.2 (Berkeley) 4/12/91" -#endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -.globl CNAME(_logname_valid) /* in _getlogin() */ - - WEAK_REFERENCE(__sys_setlogin, _setlogin) - WEAK_REFERENCE(__sys_setlogin, setlogin) -ENTRY(__sys_setlogin) - mov $SYS_setlogin,%rax - KERNCALL - jb HIDENAME(cerror) - movl $0,CNAME(_logname_valid)(%rip) - ret /* setlogin(name) */ -END(__sys_setlogin) - - .section .note.GNU-stack,"",%progbits Index: head/lib/libc/gen/getlogin.c =================================================================== --- head/lib/libc/gen/getlogin.c +++ head/lib/libc/gen/getlogin.c @@ -47,62 +47,33 @@ #include "libc_private.h" -#define THREAD_LOCK() if (__isthreaded) _pthread_mutex_lock(&logname_mutex) -#define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&logname_mutex) - extern int _getlogin(char *, int); -int _logname_valid __hidden; /* known to setlogin() */ -static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER; - -static char * -getlogin_basic(int *status) -{ - static char logname[MAXLOGNAME]; - - if (_logname_valid == 0) { - if (_getlogin(logname, sizeof(logname)) < 0) { - *status = errno; - return (NULL); - } - _logname_valid = 1; - } - *status = 0; - return (*logname ? logname : NULL); -} - char * getlogin(void) { - char *result; - int status; + static char logname[MAXLOGNAME]; - THREAD_LOCK(); - result = getlogin_basic(&status); - THREAD_UNLOCK(); - return (result); + if (_getlogin(logname, sizeof(logname)) < 0) + return (NULL); + return (logname[0] != '\0' ? logname : NULL); } int getlogin_r(char *logname, int namelen) { - char *result; + char tmpname[MAXLOGNAME]; int len; - int status; if (namelen < 1) return (ERANGE); logname[0] = '\0'; - THREAD_LOCK(); - result = getlogin_basic(&status); - if (status == 0 && result != NULL) { - len = strlen(result) + 1; - if (len > namelen) - status = ERANGE; - else - strncpy(logname, result, len); - } - THREAD_UNLOCK(); - return (status); + if (_getlogin(tmpname, sizeof(tmpname)) < 0) + return (errno); + len = strlen(tmpname) + 1; + if (len > namelen) + return (ERANGE); + strlcpy(logname, tmpname, len); + return (0); } Index: head/lib/libc/i386/sys/Makefile.inc =================================================================== --- head/lib/libc/i386/sys/Makefile.inc +++ head/lib/libc/i386/sys/Makefile.inc @@ -8,7 +8,7 @@ i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S \ - sbrk.S setlogin.S syscall.S + sbrk.S syscall.S NOASM+= vfork.o Index: head/lib/libc/i386/sys/setlogin.S =================================================================== --- head/lib/libc/i386/sys/setlogin.S +++ head/lib/libc/i386/sys/setlogin.S @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)setlogin.s 5.2 (Berkeley) 4/12/91" -#endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - -.globl CNAME(_logname_valid) /* in _getlogin() */ - -SYSCALL(setlogin) - PIC_PROLOGUE - movl $0,PIC_GOTOFF(CNAME(_logname_valid)) - PIC_EPILOGUE - ret /* setlogin(name) */ -END(__sys_setlogin) - - .section .note.GNU-stack,"",%progbits Index: head/lib/libc/powerpc/sys/Makefile.inc =================================================================== --- head/lib/libc/powerpc/sys/Makefile.inc +++ head/lib/libc/powerpc/sys/Makefile.inc @@ -1,3 +1,3 @@ # $FreeBSD$ -MDASM+= brk.S cerror.S exect.S sbrk.S setlogin.S +MDASM+= brk.S cerror.S exect.S sbrk.S Index: head/lib/libc/powerpc/sys/setlogin.S =================================================================== --- head/lib/libc/powerpc/sys/setlogin.S +++ head/lib/libc/powerpc/sys/setlogin.S @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 2002 Peter Grehan. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/* $NetBSD: setlogin.S,v 1.3 1998/11/24 11:14:57 tsubai Exp $ */ - -#include -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - - .globl CNAME(_logname_valid) /* in _getlogin() */ - -SYSCALL(setlogin) -#ifdef PIC - mflr %r10 - bl _GLOBAL_OFFSET_TABLE_@local-4 - mflr %r4 - lwz %r4,CNAME(_logname_valid)@got(%r4) - li %r5,%r0 - stw %r5,0(%r4) - mtlr %r10 -#else - lis %r4,CNAME(_logname_valid)@ha - li %r5,0 - stw %r5,CNAME(_logname_valid)@l(%r4) -#endif - blr - - .section .note.GNU-stack,"",%progbits Index: head/lib/libc/powerpc64/sys/Makefile.inc =================================================================== --- head/lib/libc/powerpc64/sys/Makefile.inc +++ head/lib/libc/powerpc64/sys/Makefile.inc @@ -1,3 +1,3 @@ # $FreeBSD$ -MDASM+= brk.S cerror.S exect.S sbrk.S setlogin.S +MDASM+= brk.S cerror.S exect.S sbrk.S Index: head/lib/libc/powerpc64/sys/setlogin.S =================================================================== --- head/lib/libc/powerpc64/sys/setlogin.S +++ head/lib/libc/powerpc64/sys/setlogin.S @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2002 Peter Grehan. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/* $NetBSD: setlogin.S,v 1.3 1998/11/24 11:14:57 tsubai Exp $ */ - -#include -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - - .globl CNAME(_logname_valid) /* in _getlogin() */ - -SYSCALL(setlogin) - addis %r4,%r2,CNAME(_logname_valid)@toc@ha - li %r5,0 - stw %r5,CNAME(_logname_valid)@toc@l(%r4) - blr - - .section .note.GNU-stack,"",%progbits Index: head/lib/libc/sparc64/sys/Makefile.inc =================================================================== --- head/lib/libc/sparc64/sys/Makefile.inc +++ head/lib/libc/sparc64/sys/Makefile.inc @@ -12,4 +12,4 @@ CFLAGS+= -I${LIBC_SRCTOP}/sparc64/fpu -MDASM+= brk.S cerror.S exect.S sbrk.S setlogin.S sigaction1.S +MDASM+= brk.S cerror.S exect.S sbrk.S sigaction1.S Index: head/lib/libc/sparc64/sys/setlogin.S =================================================================== --- head/lib/libc/sparc64/sys/setlogin.S +++ head/lib/libc/sparc64/sys/setlogin.S @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: setlogin.s,v 1.1 91/07/06 13:06:00 torek Exp - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .asciz "@(#)setlogin.s 8.1 (Berkeley) 6/4/93" -#if 0 - RCSID("$NetBSD: setlogin.S,v 1.3 2000/07/21 03:14:15 eeh Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD$"); - -#include "SYS.h" - - .globl CNAME(_logname_valid) /* in _getlogin() */ - -_SYSENTRY(setlogin) - _SYSCALL(setlogin) - PIC_PROLOGUE(%o3, %o2) - SET(CNAME(_logname_valid), %o2, %o3) - retl - stw %g0, [%o3] -_SYSEND(setlogin)