github.com/geraldss/go/src@v0.0.0-20210511222824-ac7d0ebfc235/os/user/lookup_plan9.go (about) 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 "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 const ( 17 userFile = "/dev/user" 18 ) 19 20 func init() { 21 groupImplemented = false 22 } 23 24 func current() (*User, error) { 25 ubytes, err := os.ReadFile(userFile) 26 if err != nil { 27 return nil, fmt.Errorf("user: %s", err) 28 } 29 30 uname := string(ubytes) 31 32 u := &User{ 33 Uid: uname, 34 Gid: uname, 35 Username: uname, 36 Name: uname, 37 HomeDir: os.Getenv("home"), 38 } 39 40 return u, nil 41 } 42 43 func lookupUser(username string) (*User, error) { 44 return nil, syscall.EPLAN9 45 } 46 47 func lookupUserId(uid string) (*User, error) { 48 return nil, syscall.EPLAN9 49 } 50 51 func lookupGroup(groupname string) (*Group, error) { 52 return nil, syscall.EPLAN9 53 } 54 55 func lookupGroupId(string) (*Group, error) { 56 return nil, syscall.EPLAN9 57 } 58 59 func listGroups(*User) ([]string, error) { 60 return nil, syscall.EPLAN9 61 }