Skip to content

Commit

Permalink
update servers upon group operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Ban committed Sep 11, 2021
1 parent c487fc2 commit 440f7ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func ReadConfig() *config {
C.home, _ = os.UserHomeDir()
b, err := os.ReadFile(C.home + "/.ssh/.sshman")
if err != nil {
C.persistent = true // testing doesn't have this where we just create the config
fmt.Println("No configuration file ~/.ssh/.sshman, creating one")
return &C
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/groupsServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ $ ./sshman groups server serveralias group1 group2
email := args[0]
groups := args[1:]
if host, ok := cfg.Hosts[args[0]]; ok {
oldgroups := host.GetGroups()
host.SetGroups(groups)
cfg.Hosts[args[0]] = host
host.UpdateGroups(cfg, oldgroups)
cfg.Write()
fmt.Printf("Groups for %s edited: %v\n", email, host.GetGroups())
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/groupsUser.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ $ ./sshman groups user [email protected] group1 group2
groups := args[1:]
key, user := cfg.GetUserByEmail(email)
if user != nil {
oldGroups := user.GetGroups()
user.SetGroups(groups)
cfg.Users[key] = *user
user.UpdateGroups(cfg, oldGroups)
cfg.Write()
fmt.Printf("Groups for %s edited: %v\n", email, groups)
}
Expand Down

0 comments on commit 440f7ea

Please sign in to comment.