Commit 24396dae authored by Aram Hăvărneanu's avatar Aram Hăvărneanu

os/user: small fixes for Solaris

Change-Id: I56149ef6607fb4d9baff9047cb3a47d71cad6fa6
Reviewed-on: https://go-review.googlesource.com/8261Reviewed-by: 's avatarMinux Ma <minux@golang.org>
parent 121489cb
...@@ -17,6 +17,7 @@ import ( ...@@ -17,6 +17,7 @@ import (
) )
/* /*
#cgo solaris CFLAGS: -D_POSIX_PTHREAD_SEMANTICS
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <pwd.h> #include <pwd.h>
...@@ -26,6 +27,11 @@ static int mygetpwuid_r(int uid, struct passwd *pwd, ...@@ -26,6 +27,11 @@ static int mygetpwuid_r(int uid, struct passwd *pwd,
char *buf, size_t buflen, struct passwd **result) { char *buf, size_t buflen, struct passwd **result) {
return getpwuid_r(uid, pwd, buf, buflen, result); return getpwuid_r(uid, pwd, buf, buflen, result);
} }
static int mygetpwnam_r(const char *name, struct passwd *pwd,
char *buf, size_t buflen, struct passwd **result) {
return getpwnam_r(name, pwd, buf, buflen, result);
}
*/ */
import "C" import "C"
...@@ -67,7 +73,11 @@ func lookupUnix(uid int, username string, lookupByName bool) (*User, error) { ...@@ -67,7 +73,11 @@ func lookupUnix(uid int, username string, lookupByName bool) (*User, error) {
if lookupByName { if lookupByName {
nameC := C.CString(username) nameC := C.CString(username)
defer C.free(unsafe.Pointer(nameC)) defer C.free(unsafe.Pointer(nameC))
rv = C.getpwnam_r(nameC, // mygetpwnam_r is a wrapper around getpwnam_r to avoid
// passing a size_t to getpwnam_r, because for unknown
// reasons passing a size_t to getpwnam_r doesn't work on
// Solaris.
rv = C.mygetpwnam_r(nameC,
&pwd, &pwd,
(*C.char)(buf), (*C.char)(buf),
C.size_t(bufSize), C.size_t(bufSize),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment