mirror of
https://github.com/D-Modem/login.git
synced 2026-11-28 12:28:07 -08:00
Merge pull request #24 from D-Modem/claude/project-thread-62wuhs
Remove the modemmenu fallbacks and the modemmenu-socket option
This commit is contained in:
9 files changed
+19
-80
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)")
|
||||
|
||||
+14
-16
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+1
-10
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user