Rename group package and defaults to halls

This commit is contained in:
Storm Dragon committed 2026-05-17 22:37:38 -04:00
1 parent 55528b8e62
commit a8ada950d5
26 files changed
+459 -459

No files matched your search

+15 -15
View File
@@ -26,7 +26,7 @@ import (
"golang.org/x/crypto/pbkdf2"
"golang.org/x/term"
"git.stormux.org/storm/skald/group"
"git.stormux.org/storm/skald/hall"
"git.stormux.org/storm/skald/token"
)
@@ -229,11 +229,11 @@ func readConfig(filename string) (configuration, error) {
return config, nil
}
func makePassword(pw string, algorithm string, iterations, length, saltlen, cost int) (group.Password, error) {
func makePassword(pw string, algorithm string, iterations, length, saltlen, cost int) (hall.Password, error) {
salt := make([]byte, saltlen)
_, err := rand.Read(salt)
if err != nil {
return group.Password{}, err
return hall.Password{}, err
}
switch algorithm {
@@ -242,7 +242,7 @@ func makePassword(pw string, algorithm string, iterations, length, saltlen, cost
[]byte(pw), salt, iterations, length, sha256.New,
)
encoded := hex.EncodeToString(key)
return group.Password{
return hall.Password{
Type: "pbkdf2",
Hash: "sha-256",
Key: &encoded,
@@ -254,11 +254,11 @@ func makePassword(pw string, algorithm string, iterations, length, saltlen, cost
[]byte(pw), cost,
)
if err != nil {
return group.Password{}, err
return hall.Password{}, err
}
k := string(key)
return group.Password{
return hall.Password{
Type: "bcrypt",
Key: &k,
}, nil
@@ -269,11 +269,11 @@ func makePassword(pw string, algorithm string, iterations, length, saltlen, cost
"must be the empty string",
)
}
return group.Password{
return hall.Password{
Type: "wildcard",
}, nil
default:
return group.Password{}, errors.New("unknown password type")
return hall.Password{}, errors.New("unknown password type")
}
}
@@ -392,18 +392,18 @@ func initialSetupCmd(cmdname string, args []string) {
defer skaldConfig.Close()
defer skaldctlConfig.Close()
var users map[string]group.UserDescription
var users map[string]hall.UserDescription
if adminPassword != "" {
pw, err := makePassword(adminPassword, "bcrypt", 0, 0, 0, 12)
if err != nil {
log.Fatalf("makePassword: %v", err)
}
perms, err := group.NewPermissions("admin")
perms, err := hall.NewPermissions("admin")
if err != nil {
log.Fatalf("NewPermissions: %v", err)
}
users = map[string]group.UserDescription{
users = map[string]hall.UserDescription{
adminUsername: {
Password: pw,
Permissions: perms,
@@ -411,7 +411,7 @@ func initialSetupCmd(cmdname string, args []string) {
}
}
config := group.Configuration{
config := hall.Configuration{
WritableGroups: true,
Users: users,
}
@@ -963,7 +963,7 @@ func parsePermissions(p string, expand bool) (any, error) {
if !expand {
return p, nil
}
pp, err := group.NewPermissions(p)
pp, err := hall.NewPermissions(p)
if err != nil {
return nil, err
}
@@ -985,7 +985,7 @@ func formatRawPermissions(permissions []string) string {
return fmt.Sprintf("[%s]", perms)
}
func formatPermissions(permissions group.Permissions) string {
func formatPermissions(permissions hall.Permissions) string {
s := permissions.String()
if len(s) > 0 && s[0] != '[' {
return s
@@ -1056,7 +1056,7 @@ func listUsersCmd(cmdname string, args []string) {
fmt.Printf("%-12s (ERROR=%v)\n", user, err)
continue
}
var d group.UserDescription
var d hall.UserDescription
_, err = getJSON(uu, &d)
if err != nil {
fmt.Printf("%-12s (ERROR=%v)\n", user, err)
+3 -3
View File
@@ -4,11 +4,11 @@ import (
"encoding/json"
"testing"
"git.stormux.org/storm/skald/group"
"git.stormux.org/storm/skald/hall"
)
func TestMakePassword(t *testing.T) {
doit := func(pw group.Password) {
doit := func(pw hall.Password) {
ok, _ := pw.Match("secret")
if !ok {
t.Errorf("%v didn't match", pw)
@@ -50,7 +50,7 @@ func TestFormatPermissions(t *testing.T) {
{`[]`, "[]", "[]"},
}
for _, test := range tests {
var p group.Permissions
var p hall.Permissions
err := json.Unmarshal([]byte(test.j), &p)
if err != nil {
t.Errorf("Unmarshal %#v: %v", test.j, err)