mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-06 14:04:17 -04:00
AB#2046 : Add option to create SSH users for the first coordinator upon initialization (#133)
* Move `file`, `ssh` and `user` packages to internal * Rename `SSHKey` to `(ssh.)UserKey` * Rename KeyValue / Publickey to PublicKey * Rename SSH key file from "debugd" to "ssh-keys" * Add CreateSSHUsers function to Core * Call CreateSSHUsers users on first control-plane node, when defined in config Tests: * Make StubUserCreator add entries to /etc/passwd * Add NewLinuxUserManagerFake for unit tests * Add unit tests & adjust existing ones to changes
This commit is contained in:
parent
5dc2e71d80
commit
68092f27dd
63 changed files with 879 additions and 554 deletions
28
internal/deploy/user/passwd.go
Normal file
28
internal/deploy/user/passwd.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"github.com/spf13/afero"
|
||||
"github.com/willdonnelly/passwd"
|
||||
)
|
||||
|
||||
// An Entry contains all the fields for a specific user. Re-exported to allow other module to only import this passwd module.
|
||||
type Entries map[string]passwd.Entry
|
||||
|
||||
type Passwd struct{}
|
||||
|
||||
// Parse opens the '/etc/passwd' file and parses it into a map from usernames to Entries.
|
||||
func (p Passwd) Parse(fs afero.Fs) (Entries, error) {
|
||||
return p.parseFile(fs, "/etc/passwd")
|
||||
}
|
||||
|
||||
// parseFile opens the file and parses it into a map from usernames to Entries.
|
||||
func (p Passwd) parseFile(fs afero.Fs, path string) (Entries, error) {
|
||||
file, err := fs.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
entries, err := passwd.ParseReader(file)
|
||||
return Entries(entries), err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue