Mercurial > go > multipass
comparison file/unix_users.go @ 13:da6c493cf08a
Move Unix-specific user auth files into unix_users.go.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Thu, 29 Oct 2015 21:29:27 -0400 |
parents | file/paths.go@c18bc7b9d1d9 |
children |
comparison
equal
deleted
inserted
replaced
12:1c194fa9bbf4 | 13:da6c493cf08a |
---|---|
1 package file | |
2 | |
3 import ( | |
4 "os/user" | |
5 "path" | |
6 ) | |
7 | |
8 const ( | |
9 MultipassFile = ".multipass" | |
10 ) | |
11 | |
12 // ForUser gets the given user's ShadowFile. | |
13 func ForUser(username string) (*ShadowFile, error) { | |
14 u, err := user.Lookup(username) | |
15 if err != nil { | |
16 return nil, err | |
17 } | |
18 return New(path.Join(u.HomeDir, MultipassFile)), nil | |
19 } | |
20 | |
21 // ForMe gets the current user's ShadowFile. | |
22 func ForMe() (*ShadowFile, error) { | |
23 u, err := user.Current() | |
24 if err != nil { | |
25 return nil, err | |
26 } | |
27 return New(path.Join(u.HomeDir, MultipassFile)), nil | |
28 } |