re PR go/59430 (os/user FAILs on Solaris)

PR go/59430
os/user: Use POSIX functions on Solaris.

From-SVN: r206412
This commit is contained in:
Ian Lance Taylor 2014-01-08 01:08:29 +00:00
parent 2da4a7611b
commit 747639c28f
5 changed files with 50 additions and 10 deletions

View File

@ -1465,10 +1465,17 @@ go_os_signal_files = \
go/os/signal/signal.go \
go/os/signal/signal_unix.go
if LIBGO_IS_SOLARIS
os_user_decls_file = go/os/user/decls_solaris.go
else
os_user_decls_file = go/os/user/decls_unix.go
endif
go_os_user_files = \
go/os/user/user.go \
go/os/user/lookup.go \
go/os/user/lookup_unix.go
go/os/user/lookup_unix.go \
go/os/user/user.go \
$(os_user_decls_file)
go_path_filepath_files = \
go/path/filepath/match.go \

View File

@ -1670,10 +1670,13 @@ go_os_signal_files = \
go/os/signal/signal.go \
go/os/signal/signal_unix.go
@LIBGO_IS_SOLARIS_FALSE@os_user_decls_file = go/os/user/decls_unix.go
@LIBGO_IS_SOLARIS_TRUE@os_user_decls_file = go/os/user/decls_solaris.go
go_os_user_files = \
go/os/user/user.go \
go/os/user/lookup.go \
go/os/user/lookup_unix.go
go/os/user/lookup_unix.go \
go/os/user/user.go \
$(os_user_decls_file)
go_path_filepath_files = \
go/path/filepath/match.go \

View File

@ -0,0 +1,18 @@
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build solaris
// +build cgo
package user
import "syscall"
// Declarations for the libc functions on Solaris.
//extern __posix_getpwnam_r
func libc_getpwnam_r(name *byte, pwd *syscall.Passwd, buf *byte, buflen syscall.Size_t, result **syscall.Passwd) int
//extern __posix_getpwuid_r
func libc_getpwuid_r(uid syscall.Uid_t, pwd *syscall.Passwd, buf *byte, buflen syscall.Size_t, result **syscall.Passwd) int

View File

@ -0,0 +1,18 @@
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin dragonfly freebsd linux netbsd openbsd
// +build cgo
package user
import "syscall"
// Declarations for the libc functions on most Unix systems.
//extern getpwnam_r
func libc_getpwnam_r(name *byte, pwd *syscall.Passwd, buf *byte, buflen syscall.Size_t, result **syscall.Passwd) int
//extern getpwuid_r
func libc_getpwuid_r(uid syscall.Uid_t, pwd *syscall.Passwd, buf *byte, buflen syscall.Size_t, result **syscall.Passwd) int

View File

@ -27,12 +27,6 @@ static int mygetpwuid_r(int uid, struct passwd *pwd,
}
*/
//extern getpwnam_r
func libc_getpwnam_r(name *byte, pwd *syscall.Passwd, buf *byte, buflen syscall.Size_t, result **syscall.Passwd) int
//extern getpwuid_r
func libc_getpwuid_r(uid syscall.Uid_t, pwd *syscall.Passwd, buf *byte, buflen syscall.Size_t, result **syscall.Passwd) int
// bytePtrToString takes a NUL-terminated array of bytes and convert
// it to a Go string.
func bytePtrToString(p *byte) string {