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  	"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  	userImplemented = false
    22  	groupImplemented = false
    23  	groupListImplemented = false
    24  }
    25  
    26  func current() (*User, error) {
    27  	ubytes, err := os.ReadFile(userFile)
    28  	if err != nil {
    29  		return nil, fmt.Errorf("user: %s", err)
    30  	}
    31  
    32  	uname := string(ubytes)
    33  
    34  	u := &User{
    35  		Uid:      uname,
    36  		Gid:      uname,
    37  		Username: uname,
    38  		Name:     uname,
    39  		HomeDir:  os.Getenv("home"),
    40  	}
    41  
    42  	return u, nil
    43  }
    44  
    45  func lookupUser(username string) (*User, error) {
    46  	return nil, syscall.EPLAN9
    47  }
    48  
    49  func lookupUserId(uid string) (*User, error) {
    50  	return nil, syscall.EPLAN9
    51  }
    52  
    53  func lookupGroup(groupname string) (*Group, error) {
    54  	return nil, syscall.EPLAN9
    55  }
    56  
    57  func lookupGroupId(string) (*Group, error) {
    58  	return nil, syscall.EPLAN9
    59  }
    60  
    61  func listGroups(*User) ([]string, error) {
    62  	return nil, syscall.EPLAN9
    63  }
    64  

View as plain text