~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/os/user/lookup_unix.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
 
5
 
// +build darwin freebsd linux
 
5
// +build darwin freebsd linux netbsd openbsd
6
6
// +build cgo
7
7
 
8
8
package user
29
29
*/
30
30
import "C"
31
31
 
32
 
// Current returns the current user. 
33
 
func Current() (*User, error) {
34
 
        return lookup(syscall.Getuid(), "", false)
35
 
}
36
 
 
37
 
// Lookup looks up a user by username. If the user cannot be found,
38
 
// the returned error is of type UnknownUserError.
39
 
func Lookup(username string) (*User, error) {
40
 
        return lookup(-1, username, true)
41
 
}
42
 
 
43
 
// LookupId looks up a user by userid. If the user cannot be found,
44
 
// the returned error is of type UnknownUserIdError.
45
 
func LookupId(uid string) (*User, error) {
 
32
func current() (*User, error) {
 
33
        return lookupUnix(syscall.Getuid(), "", false)
 
34
}
 
35
 
 
36
func lookup(username string) (*User, error) {
 
37
        return lookupUnix(-1, username, true)
 
38
}
 
39
 
 
40
func lookupId(uid string) (*User, error) {
46
41
        i, e := strconv.Atoi(uid)
47
42
        if e != nil {
48
43
                return nil, e
49
44
        }
50
 
        return lookup(i, "", false)
 
45
        return lookupUnix(i, "", false)
51
46
}
52
47
 
53
 
func lookup(uid int, username string, lookupByName bool) (*User, error) {
 
48
func lookupUnix(uid int, username string, lookupByName bool) (*User, error) {
54
49
        var pwd C.struct_passwd
55
50
        var result *C.struct_passwd
56
51