| 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 |
|
| 17 |
func init() { |
| 18 |
userImplemented = false |
| 19 |
groupImplemented = false |
| 20 |
groupListImplemented = false |
| 21 |
} |
| 22 |
|
| 23 |
var ( |
| 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 |
|
| 30 |
func 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 |
|
| 49 |
func lookupUser(username string) (*User, error) { |
| 50 |
return nil, syscall.EPLAN9 |
| 51 |
} |
| 52 |
|
| 53 |
func lookupUserId(uid string) (*User, error) { |
| 54 |
return nil, syscall.EPLAN9 |
| 55 |
} |
| 56 |
|
| 57 |
func lookupGroup(groupname string) (*Group, error) { |
| 58 |
return nil, syscall.EPLAN9 |
| 59 |
} |
| 60 |
|
| 61 |
func lookupGroupId(string) (*Group, error) { |
| 62 |
return nil, syscall.EPLAN9 |
| 63 |
} |
| 64 |
|
| 65 |
func listGroups(*User) ([]string, error) { |
| 66 |
return nil, syscall.EPLAN9 |
| 67 |
} |