diff mbox

libgo patch committed: Use Entersyscall in os/user

Message ID mcrfw9zdabm.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor June 13, 2012, 5:56 a.m. UTC
This patch to libgo uses Entersyscall and Exitsyscall as appropriate in
os/user.  This is necessary if the lookup uses something like LDAP.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian
diff mbox

Patch

diff -r 3f26ed600514 libgo/go/os/user/lookup_unix.go
--- a/libgo/go/os/user/lookup_unix.go	Tue Jun 12 21:46:14 2012 -0700
+++ b/libgo/go/os/user/lookup_unix.go	Tue Jun 12 22:54:06 2012 -0700
@@ -73,11 +73,14 @@ 
 	const bufSize = 1024
 	buf := make([]byte, bufSize)
 	if lookupByName {
-		rv := libc_getpwnam_r(syscall.StringBytePtr(username),
+		p := syscall.StringBytePtr(username)
+		syscall.Entersyscall()
+		rv := libc_getpwnam_r(p,
 			&pwd,
 			&buf[0],
 			bufSize,
 			&result)
+		syscall.Exitsyscall()
 		if rv != 0 {
 			return nil, fmt.Errorf("user: lookup username %s: %s", username, syscall.GetErrno())
 		}
@@ -85,11 +88,13 @@ 
 			return nil, UnknownUserError(username)
 		}
 	} else {
+		syscall.Entersyscall()
 		rv := libc_getpwuid_r(syscall.Uid_t(uid),
 			&pwd,
 			&buf[0],
 			bufSize,
 			&result)
+		syscall.Exitsyscall()
 		if rv != 0 {
 			return nil, fmt.Errorf("user: lookup userid %d: %s", uid, syscall.GetErrno())
 		}