diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0e77b5..181c88c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,13 +126,7 @@ jobs: - name: bbs against this login working-directory: bbs - # a bbs that still imports the old module path (github.com/D-Modem/menu) - # is moved to the new one first run: | - if grep -q 'github.com/D-Modem/menu ' go.mod; then - grep -rl 'github.com/D-Modem/menu' --include='*.go' . | xargs -r sed -i 's#github.com/D-Modem/menu#github.com/D-Modem/login#g' - go mod edit -droprequire github.com/D-Modem/menu - fi go mod edit -replace github.com/D-Modem/login=../login go mod tidy diff --git a/cmd/dmodem-login/access.go b/cmd/dmodem-login/access.go index 0080bac..97d398c 100644 --- a/cmd/dmodem-login/access.go +++ b/cmd/dmodem-login/access.go @@ -105,7 +105,7 @@ func loadAccess(c *config.File, s *settings) error { if s.limits.dailyLimit, err = g.Duration("daily_limit", 0); err != nil { return err } - s.limits.stateDir = g.Get("state_dir", config.Legacy("/var/lib/dmodem-login", "/var/lib/modemmenu")) + s.limits.stateDir = g.Get("state_dir", "/var/lib/dmodem-login") if s.limits.warnings, err = g.Durations("time_warning", "2m"); err != nil { return err } @@ -136,7 +136,7 @@ func loadAccess(c *config.File, s *settings) error { return err } s.signup.name = su.Get("name", "new") - s.signup.file = su.Get("file", c.Section("file").Get("path", config.Legacy("/etc/asterisk/dmodem-login.users", "/etc/asterisk/modemmenu.users"))) + s.signup.file = su.Get("file", c.Section("file").Get("path", "/etc/asterisk/dmodem-login.users")) if s.signup.pending, err = su.Bool("pending", true); err != nil { return err } diff --git a/cmd/dmodem-login/main.go b/cmd/dmodem-login/main.go index 44580cc..529216d 100644 --- a/cmd/dmodem-login/main.go +++ b/cmd/dmodem-login/main.go @@ -41,9 +41,7 @@ func logf(format string, args ...any) { logger.Printf(format, args...) } // main: the flags; then -hash, -check, -authd, -ldapd or -serve, or a call on // stdin and stdout func main() { - // an install from before the rename: modemmenu.conf - defConfig := config.Legacy("/etc/asterisk/dmodem-login.conf", "/etc/asterisk/modemmenu.conf") - config := flag.String("config", defConfig, "the configuration `file`") + config := flag.String("config", "/etc/asterisk/dmodem-login.conf", "the configuration `file`") rate := flag.String("rate", os.Getenv("DMODEM_RATE"), "the connect `rate`, tx/rx bit/s (default $DMODEM_RATE)") dialed := flag.String("dialed", os.Getenv("DMODEM_DIALED"), "the dialed `number` (default $DMODEM_DIALED)") callerID := flag.String("callerid", os.Getenv("DMODEM_CALLERID"), "the caller's `number` (default $DMODEM_CALLERID)") diff --git a/docs/rename.md b/docs/rename.md index e3f16cd..6986cdf 100644 --- a/docs/rename.md +++ b/docs/rename.md @@ -22,24 +22,22 @@ is D-Modem/menu. Its new name is | `MODEMMENU_*` (environment) | `DMODEM_LOGIN_*` | | nftables table `modemmenu_dialup` | `dmodem_login_dialup` | -## What continues to operate - -You can install the new version on an old installation. These items -continue to operate: - -- The pppd plugin also accepts the `modemmenu-socket` option. -- If `-config` is not given and `/etc/asterisk/dmodem-login.conf` is not - there, dmodem-login reads `/etc/asterisk/modemmenu.conf`. -- If `[file] path` is not given and `/etc/asterisk/dmodem-login.users` is - not there, dmodem-login reads `/etc/asterisk/modemmenu.users`. The - sign-up uses the same file. -- If `state_dir` is not given and `/var/lib/dmodem-login` is not there, - dmodem-login uses `/var/lib/modemmenu`. -- If `pam_service` is not given and `/etc/pam.d/dmodem-login` is not - there, dmodem-login uses the PAM service `modemmenu`. - ## What you must change +dmodem-login does not read the old names. On an old installation, do +these steps before you start the new version. + +- Rename `/etc/asterisk/modemmenu.conf` to + `/etc/asterisk/dmodem-login.conf`, or give the old path with `-config`. +- Rename `/etc/asterisk/modemmenu.users` to + `/etc/asterisk/dmodem-login.users`, or give the old path in + `[file] path`. +- Rename `/var/lib/modemmenu` to `/var/lib/dmodem-login`, or give the + old path in `state_dir`. +- Rename `/etc/pam.d/modemmenu` to `/etc/pam.d/dmodem-login`, or set + `pam_service = modemmenu`. +- In each pppd option file, change the `modemmenu-socket` option to + `dmodem-login-socket`. - The program is now `/usr/local/bin/dmodem-login`. Change each `app_dmodem` profile that starts `/usr/local/bin/modemmenu`, and each pppd option file that loads `modemmenu.so`. Then delete the old diff --git a/internal/auth/file.go b/internal/auth/file.go index d5cae66..3cd7e8d 100644 --- a/internal/auth/file.go +++ b/internal/auth/file.go @@ -24,7 +24,7 @@ type File struct { // NewFile: the [file] backend, its users file checked to exist func NewFile(s *config.Section) (Authenticator, error) { a := &File{ - path: s.Get("path", config.Legacy("/etc/asterisk/dmodem-login.users", "/etc/asterisk/modemmenu.users")), + path: s.Get("path", "/etc/asterisk/dmodem-login.users"), scheme: strings.ToLower(s.Get("hash", "auto")), } if _, err := os.Stat(a.path); err != nil { diff --git a/internal/auth/system.go b/internal/auth/system.go index a248e39..960b489 100644 --- a/internal/auth/system.go +++ b/internal/auth/system.go @@ -37,7 +37,7 @@ type Account struct { func NewSystem(s *config.Section) (Authenticator, error) { var err error a := &System{ - service: s.Get("pam_service", pamService()), + service: s.Get("pam_service", "dmodem-login"), groups: config.Fields(s.Get("groups", "")), lookup: LookupNSS, inGroups: InGroupsNSS, @@ -92,12 +92,3 @@ func (a *System) allowed(acct *Account) error { } return nil } - -// pamService: dmodem-login, or modemmenu (the old name) when only its -// /etc/pam.d file is there -func pamService() string { - if config.Legacy("/etc/pam.d/dmodem-login", "/etc/pam.d/modemmenu") == "/etc/pam.d/modemmenu" { - return "modemmenu" - } - return "dmodem-login" -} diff --git a/internal/config/config.go b/internal/config/config.go index 0d63ce7..6b8f103 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -243,15 +243,3 @@ func Fields(s string) []string { return r == ',' || r == ' ' || r == '\t' }) } - -// Legacy: path, or old when path is not there and old is: the default -// paths of modemmenu, the old name of dmodem-login, still used by an -// install from before the rename -func Legacy(path, old string) string { - if _, err := os.Stat(path); err != nil && os.IsNotExist(err) { - if _, err := os.Stat(old); err == nil { - return old - } - } - return path -} diff --git a/internal/config/legacy_test.go b/internal/config/legacy_test.go deleted file mode 100644 index d11ceb9..0000000 --- a/internal/config/legacy_test.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2026 D-Modem Authors -// SPDX-License-Identifier: AGPL-3.0-only - -package config - -import ( - "os" - "path/filepath" - "testing" -) - -// TestLegacy: the new path, unless only the old one (modemmenu's) is there -func TestLegacy(t *testing.T) { - dir := t.TempDir() - nw, old := filepath.Join(dir, "dmodem-login.conf"), filepath.Join(dir, "modemmenu.conf") - if got := Legacy(nw, old); got != nw { - t.Errorf("neither: %s", got) - } - os.WriteFile(old, nil, 0o600) - if got := Legacy(nw, old); got != old { - t.Errorf("old only: %s", got) - } - os.WriteFile(nw, nil, 0o600) - if got := Legacy(nw, old); got != nw { - t.Errorf("both: %s", got) - } -} diff --git a/pppd/dmodem-login.c b/pppd/dmodem-login.c index c0fd68a..de22ca9 100644 --- a/pppd/dmodem-login.c +++ b/pppd/dmodem-login.c @@ -34,9 +34,6 @@ static int logged_in; static option_t options[] = { { .name = "dmodem-login-socket", .type = o_string, .addr = &sock_path, .description = "dmodem-login's auth socket (default: $DMODEM_LOGIN_AUTH_SOCKET)" }, - /* the old name, from before modemmenu was dmodem-login */ - { .name = "modemmenu-socket", .type = o_string, .addr = &sock_path, - .description = "the same as dmodem-login-socket" }, { .name = NULL } };