...

Source file src/os/user/lookup_plan9.go

     1	// Copyright 2013 The Go Authors. All rights reserved.
     2	// Use of this source code is governed by a BSD-style
     3	// license that can be found in the LICENSE file.
     4	
     5	package user
     6	
     7	import (
     8		"fmt"
     9		"io/ioutil"
    10		"os"
    11		"syscall"
    12	)
    13	
    14	// Partial os/user support on Plan 9.
    15	// Supports Current(), but not Lookup()/LookupId().
    16	// The latter two would require parsing /adm/users.
    17	const (
    18		userFile = "/dev/user"
    19	)
    20	
    21	func init() {
    22		groupImplemented = false
    23	}
    24	
    25	func current() (*User, error) {
    26		ubytes, err := ioutil.ReadFile(userFile)
    27		if err != nil {
    28			return nil, fmt.Errorf("user: %s", err)
    29		}
    30	
    31		uname := string(ubytes)
    32	
    33		u := &User{
    34			Uid:      uname,
    35			Gid:      uname,
    36			Username: uname,
    37			Name:     uname,
    38			HomeDir:  os.Getenv("home"),
    39		}
    40	
    41		return u, nil
    42	}
    43	
    44	func lookupUser(username string) (*User, error) {
    45		return nil, syscall.EPLAN9
    46	}
    47	
    48	func lookupUserId(uid string) (*User, error) {
    49		return nil, syscall.EPLAN9
    50	}
    51	
    52	func lookupGroup(groupname string) (*Group, error) {
    53		return nil, syscall.EPLAN9
    54	}
    55	
    56	func lookupGroupId(string) (*Group, error) {
    57		return nil, syscall.EPLAN9
    58	}
    59	
    60	func listGroups(*User) ([]string, error) {
    61		return nil, syscall.EPLAN9
    62	}
    63	

View as plain text