mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
Merge pull request #65 from D-Modem/claude/project-thread-62wuhs
Stop reading [modemmenu], the old name of [dmodem-login]
This commit is contained in:
8 files changed
+21
-53
No files matched your search
+1
-1
@@ -372,7 +372,7 @@ address = 127.0.0.1:2513
|
||||
; dmodem-login's auth socket ([authd] there): the accounts dmodem-login logs in
|
||||
; (no password here) log in by telnet, SSH, the web ... with their
|
||||
; dmodem-login password, asked of dmodem-login's backends. See
|
||||
; docs/wiki/Modem-Callers.md. [modemmenu], its old name, is read too
|
||||
; docs/wiki/Modem-Callers.md.
|
||||
;[dmodem-login]
|
||||
;auth_socket = /run/dmodem-login/auth.sock
|
||||
; a user dmodem-login knows and the BBS does not gets an account at their
|
||||
|
||||
@@ -220,7 +220,7 @@ There may be any number of these, each with its own NAME.
|
||||
|
||||
## `[dmodem-login]`
|
||||
|
||||
dmodem-login's auth socket ([authd] there): the accounts dmodem-login logs in (no password here) log in by telnet, SSH, the web ... with their dmodem-login password, asked of dmodem-login's backends. See docs/wiki/Modem-Callers.md. [modemmenu], its old name, is read too.
|
||||
dmodem-login's auth socket ([authd] there): the accounts dmodem-login logs in (no password here) log in by telnet, SSH, the web ... with their dmodem-login password, asked of dmodem-login's backends. See docs/wiki/Modem-Callers.md.
|
||||
|
||||
| key | default | live | what it does |
|
||||
|---|---|---|---|
|
||||
|
||||
@@ -133,8 +133,8 @@ auth_socket = /run/dmodem-login/auth.sock
|
||||
| `timeout` | `15` | seconds for the answer of dmodem-login (the answer for an incorrect password comes after its `fail_delay`) |
|
||||
|
||||
The old name of dmodem-login is modemmenu, and the old name of this
|
||||
section is `[modemmenu]`. The BBS still reads `[modemmenu]`. Do not use
|
||||
`[modemmenu]` and `[dmodem-login]` in the same file.
|
||||
section is `[modemmenu]`. The BBS does not read `[modemmenu]`. If your
|
||||
file has `[modemmenu]`, change its name to `[dmodem-login]`.
|
||||
|
||||
The BBS asks dmodem-login only about accounts that dmodem-login created
|
||||
(external accounts with no BBS password). An account with its own BBS
|
||||
|
||||
@@ -331,16 +331,9 @@ func (k *Kind) free(key string) bool {
|
||||
|
||||
// Kind is a kind of section (nil: none such).
|
||||
func (c *Catalog) Kind(name string) *Kind {
|
||||
if alias, ok := oldKinds[name]; ok {
|
||||
name = alias
|
||||
}
|
||||
return c.byName[name]
|
||||
}
|
||||
|
||||
// oldKinds are the old names of kinds of sections, still read: the
|
||||
// catalog gives the current kind's keys and help for them
|
||||
var oldKinds = map[string]string{"modemmenu": "dmodem-login"}
|
||||
|
||||
// Key is a key of a kind of section: one of the sample's, or one of the
|
||||
// sysop's own (a menu's item); nil if it is neither.
|
||||
func (c *Catalog) Key(kind, key string) *Key {
|
||||
|
||||
@@ -91,10 +91,8 @@ var labels = map[string]string{
|
||||
"chan.dir": "Image boards' files", "fido.dir": "FidoNet's packets",
|
||||
"general.user": "Run as user", "general.group": "and group",
|
||||
"dmodem-login.auth_socket": "dmodem-login's auth socket", "dmodem-login.create_users": "Make accounts it knows",
|
||||
"dmodem-login.timeout": "Its answer within (s)",
|
||||
"modemmenu.auth_socket": "dmodem-login's auth socket", "modemmenu.create_users": "Make accounts it knows",
|
||||
"modemmenu.timeout": "Its answer within (s)",
|
||||
"backup.dir": "Backup directory", "backup.at": "Daily at (HH:MM)", "backup.keep": "Backups kept",
|
||||
"dmodem-login.timeout": "Its answer within (s)",
|
||||
"backup.dir": "Backup directory", "backup.at": "Daily at (HH:MM)", "backup.keep": "Backups kept",
|
||||
"backup.files": "With the files",
|
||||
}
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ func (e *Editor) connectionsMenu() page {
|
||||
out = append(out, heading("Line speeds (telnet, SSH and web callers)"))
|
||||
out = append(out, e.fields(g, "line_speeds", "line_speed", "line_speed_ask")...)
|
||||
out = append(out, heading("Passwords by dmodem-login (its auth socket)"))
|
||||
out = append(out, e.fields(e.loginSec(), "auth_socket", "create_users", "timeout")...)
|
||||
out = append(out, e.fields(sec("dmodem-login"), "auth_socket", "create_users", "timeout")...)
|
||||
out = append(out, heading("Caller ID and where callers are"))
|
||||
out = append(out, e.fields(g, "phone_country", "geoip", "geoip_credit", "geoip_credit_url",
|
||||
"geoip_users", "geoip_prefill")...)
|
||||
@@ -628,12 +628,3 @@ func (e *Editor) fidoPage() page {
|
||||
return out
|
||||
}}
|
||||
}
|
||||
|
||||
// loginSec is [dmodem-login], or [modemmenu] (its old name) in a file
|
||||
// that has only that one, so that the setup edits the section in use.
|
||||
func (e *Editor) loginSec() confedit.Section {
|
||||
if old := sec("modemmenu"); e.doc.Has(old) && !e.doc.Has(sec("dmodem-login")) {
|
||||
return old
|
||||
}
|
||||
return sec("dmodem-login")
|
||||
}
|
||||
@@ -228,16 +228,8 @@ func load(cf *config.File) (*Config, error) {
|
||||
if err := c.backupSection(cf.Get("backup", "")); err != nil {
|
||||
return nil, fmt.Errorf("[backup] %w", err)
|
||||
}
|
||||
// [modemmenu]: the old name of [dmodem-login], still read
|
||||
login, loginName := cf.Get("dmodem-login", ""), "dmodem-login"
|
||||
if old := cf.Get("modemmenu", ""); old != nil {
|
||||
if login != nil {
|
||||
return nil, fmt.Errorf("[modemmenu] and [dmodem-login]: one only ([modemmenu] is the old name)")
|
||||
}
|
||||
login, loginName = old, "modemmenu"
|
||||
}
|
||||
if err := c.loginSection(login); err != nil {
|
||||
return nil, fmt.Errorf("[%s] %w", loginName, err)
|
||||
if err := c.loginSection(cf.Get("dmodem-login", "")); err != nil {
|
||||
return nil, fmt.Errorf("[dmodem-login] %w", err)
|
||||
}
|
||||
for _, sec := range cf.All("event") {
|
||||
e, err := c.event(sec)
|
||||
@@ -282,7 +274,7 @@ func load(cf *config.File) (*Config, error) {
|
||||
}
|
||||
for _, s := range cf.Sections {
|
||||
switch s.Kind {
|
||||
case "general", "security", "acme", "backup", "dmodem-login", "modemmenu", "event", "listen", "ftp", "news", "nntp", "peer", "qwknet", "fido", "binkp", "link", "door", "finger", "gopher", "gemini", "time", "ntp", "nts", "ptp", "dns", "dnsrecord", "irc", "oscar", "aol", "msn", "marvel", "ymsg", "mrc", "irclink", "ircpeer", "menu", "strings", "http", "level", "chan",
|
||||
case "general", "security", "acme", "backup", "dmodem-login", "event", "listen", "ftp", "news", "nntp", "peer", "qwknet", "fido", "binkp", "link", "door", "finger", "gopher", "gemini", "time", "ntp", "nts", "ptp", "dns", "dnsrecord", "irc", "oscar", "aol", "msn", "marvel", "ymsg", "mrc", "irclink", "ircpeer", "menu", "strings", "http", "level", "chan",
|
||||
"feeds", "feed", "weather", "quotes",
|
||||
"mail", "smarthost", "pop3", "imap", "smtp", "mx", "lmtp":
|
||||
default:
|
||||
@@ -472,7 +464,7 @@ type MenuAuth struct {
|
||||
Timeout time.Duration // for its answer
|
||||
}
|
||||
|
||||
// loginSection reads [dmodem-login] (or [modemmenu], its old name).
|
||||
// loginSection reads [dmodem-login].
|
||||
func (c *Config) loginSection(sec *config.Section) error {
|
||||
if sec == nil {
|
||||
return nil
|
||||
|
||||
@@ -5,25 +5,19 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestLoginSection: [dmodem-login], and [modemmenu], its old name, read
|
||||
// the same; both at once is an error.
|
||||
// TestLoginSection: [dmodem-login] is read; [modemmenu], its old name,
|
||||
// is an unknown section.
|
||||
func TestLoginSection(t *testing.T) {
|
||||
const listen = "[listen telnet]\ntype = telnet\naddress = :2300\n"
|
||||
for _, name := range []string{"dmodem-login", "modemmenu"} {
|
||||
c, err := Parse([]byte(listen + "[" + name + "]\nauth_socket = /run/dmodem-login/auth.sock\ntimeout = 5\n"))
|
||||
if err != nil {
|
||||
t.Fatalf("[%s]: %v", name, err)
|
||||
}
|
||||
if c.MenuAuth == nil || c.MenuAuth.Socket != "/run/dmodem-login/auth.sock" || c.MenuAuth.Timeout.Seconds() != 5 {
|
||||
t.Errorf("[%s]: %+v", name, c.MenuAuth)
|
||||
}
|
||||
c, err := Parse([]byte(listen + "[dmodem-login]\nauth_socket = /run/dmodem-login/auth.sock\ntimeout = 5\n"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err := Parse([]byte(listen + "[modemmenu]\nauth_socket = /a\n[dmodem-login]\nauth_socket = /b\n"))
|
||||
if err == nil || !strings.Contains(err.Error(), "one only") {
|
||||
t.Errorf("both: %v", err)
|
||||
if c.MenuAuth == nil || c.MenuAuth.Socket != "/run/dmodem-login/auth.sock" || c.MenuAuth.Timeout.Seconds() != 5 {
|
||||
t.Errorf("%+v", c.MenuAuth)
|
||||
}
|
||||
_, err = Parse([]byte(listen + "[modemmenu]\nauth_socket = relative\n"))
|
||||
if err == nil || !strings.Contains(err.Error(), "[modemmenu]") {
|
||||
t.Errorf("an error in the old section names it: %v", err)
|
||||
_, err = Parse([]byte(listen + "[modemmenu]\nauth_socket = /run/dmodem-login/auth.sock\n"))
|
||||
if err == nil || !strings.Contains(err.Error(), "unknown section [modemmenu]") {
|
||||
t.Errorf("[modemmenu]: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user