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 5package user 6 7import ( 8 "fmt" 9 "os" 10 "syscall" 11) 12 13// Partial os/user support on Plan 9. 14// Supports Current(), but not Lookup()/LookupId(). 15// The latter two would require parsing /adm/users. 16 17func init() { 18 userImplemented = false 19 groupImplemented = false 20 groupListImplemented = false 21} 22 23var ( 24 // unused variables (in this implementation) 25 // modified during test to exercise code paths in the cgo implementation. 26 userBuffer = 0 27 groupBuffer = 0 28) 29 30func current() (*User, error) { 31 ubytes, err := os.ReadFile("/dev/user") 32 if err != nil { 33 return nil, fmt.Errorf("user: %s", err) 34 } 35 36 uname := string(ubytes) 37 38 u := &User{ 39 Uid: uname, 40 Gid: uname, 41 Username: uname, 42 Name: uname, 43 HomeDir: os.Getenv("home"), 44 } 45 46 return u, nil 47} 48 49func lookupUser(username string) (*User, error) { 50 return nil, syscall.EPLAN9 51} 52 53func lookupUserId(uid string) (*User, error) { 54 return nil, syscall.EPLAN9 55} 56 57func lookupGroup(groupname string) (*Group, error) { 58 return nil, syscall.EPLAN9 59} 60 61func lookupGroupId(string) (*Group, error) { 62 return nil, syscall.EPLAN9 63} 64 65func listGroups(*User) ([]string, error) { 66 return nil, syscall.EPLAN9 67} 68