Files
login/modemmenu.conf.sample
T
Claude da20bbd4ae LDAP groups, AD password changes, the time warning, the last callers
- LDAP groups for the items' groups =: with [ldap] group_base, a group
  is an entry there that group_filter finds (groupOfNames,
  groupOfUniqueNames and posixGroup by default), searched as
  search_bind_dn or as the caller; each answer kept for the call.
- [ldap] password_change = ad: mode = passwd changes an Active
  Directory password (unicodePwd's old value deleted, the new one
  added, quoted UTF-16LE), AD having no Password Modify.
- time_warning (2m) before the time limit, time_warning_message is
  written on the line in the middle of a running selection, unless the
  item says time_warning = no (the sample's PPP does).
- mode = callers: the last callers (time, user, rate; no caller ID),
  each login recorded in state_dir/callers (the latest 200) when there
  is such an item.
- The sample's end has items to copy: ZMODEM uploads (rz -b -R -E),
  a Kermit server (kermit -Y -x), lynx -anonymous, mutt, tin, irssi,
  Gopher and the last callers; it loads with all of them on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RvtV8Dg9kqRaakbTEfyH3f
2026-10-15 19:51:33 +00:00

421 lines
16 KiB
Plaintext

;
; modemmenu.conf - the login and menu of a dial-up line
;
; app_dmodem runs it on the caller's line (dmodem.conf):
;
; [menu]
; mode = exec
; command = exec /usr/local/bin/modemmenu -config /etc/asterisk/modemmenu.conf
;
; or one modemmenu -serve serves every call on a unix socket ([server]):
;
; [menu]
; mode = unix
; path = /run/modemmenu/modemmenu.sock
; header = yes
;
; Values may be "quoted" to keep spaces at their ends; \r \n \t \e and \xHH
; are those bytes in the texts of [general] and [menu] and in send.
; Comments start with ; or #, on a line of their own or after a value
; (after a space: "key = P ; PPP"); \; and \# are the characters.
;
; The selection gets the session as {placeholders} in its command, send,
; run_as and the rlogin fields, and as MODEM_* in its environment. In a
; command a placeholder is a quoted shell word already: write {user}, not
; "{user}" (or "$MODEM_USER" from the environment).
;
; {user} MODEM_USER the user name the caller logged in with
; {password} MODEM_PASSWORD their password (pass_password = no: empty
; and not in the environment)
; {auth} MODEM_AUTH the backend that accepted it: file, ldap, sql
; {dialed} MODEM_DIALED the number the caller dialed
; {callerid} MODEM_CALLERID the caller's number
; {baud} MODEM_BAUD the connect rate towards the caller, bit/s
; {rate} MODEM_RATE both rates, tx/rx bit/s (app_dmodem's)
; {tx_rate} MODEM_TX_RATE to the caller
; {rx_rate} MODEM_RX_RATE from the caller
; {date} MODEM_DATE the date of the connection, 2006-01-02
; {time} MODEM_TIME its time, 15:04:05 (local)
; {datetime} MODEM_DATETIME both, RFC 3339 with the zone
; {epoch} MODEM_EPOCH seconds since 1970
; {channel} MODEM_CHANNEL the Asterisk channel
; {profile} MODEM_PROFILE the dmodem.conf profile
; {selection} MODEM_SELECTION the [item ...] chosen
;
; The rate, dialed number and caller ID come from app_dmodem's DMODEM_RATE,
; DMODEM_DIALED and DMODEM_CALLERID, or -rate, -dialed and -callerid.
[general]
; syslog (auth facility), a file, or none. Never the line: stderr is the
; caller's screen
log = syslog
; the backends, asked in this order: file, ldap, sql, system (PAM). A
; backend that does not know the user passes to the next; a wrong password
; stops there
auth = file
banner = "\r\nWelcome to D-Modem.\r\n"
;banner_file = /etc/asterisk/modemmenu.banner
login_prompt = "\r\nlogin: "
password_prompt = "Password: "
welcome = "\r\nHello {user}, connected at {baud} bit/s on {date} {time}.\r\n"
; the message of the day, after the welcome and before the menu: motd,
; then the file (read at each login), {placeholders} in both
;motd = "\r\nThe line is down for maintenance on Sunday.\r\n"
;motd_file = /etc/motd
goodbye = "\r\nGoodbye.\r\n"
; the echo of each password character, or none
password_echo = *
; logins before the call is hung up, seconds after a wrong one
attempts = 3
fail_delay = 3
; seconds to log in, to choose in the menu
login_timeout = 90
idle_timeout = 300
; user names taken (others are refused without asking a backend)
user_pattern = ^[A-Za-z0-9][A-Za-z0-9._@-]{0,63}$
; time limits (0: none), from the login: a call, and a user's calls in a
; day (kept in state_dir/usage). A selection is hung up at the limit.
; {time_left} (whole minutes) shows what is left, e.g. in [menu] prompt
time_limit = 0
daily_limit = 0
state_dir = /var/lib/modemmenu
; this long before the limit, the message is written on the line in the
; middle of a running selection (not one with time_warning = no); 0: none
time_warning = 2m
time_warning_message = "\r\n\r\n*** {time_left} minute(s) left in this call ***\r\n"
; groups of users for the items' groups = (members of system groups count
; too, for logins by auth = system)
[groups]
sysops = alice
;dialup = alice bob carol
; a guest account: its name at the login prompt, no password; it sees only
; the items with guest = yes, for time_limit at most
[guest]
enabled = no
name = guest
time_limit = 15m
; new accounts: the name at the login prompt starts a signup, which adds
; user:bcrypt to the users file (auth must have file). pending = yes locks
; the account (user:!hash) until the sysop removes the !
[signup]
enabled = no
name = new
pending = yes
min_password = 8
;file = /etc/asterisk/modemmenu.users
;message = "\r\nNew account. Choose a user name and a password.\r\n"
; caller ID: numbers or patterns (* and ? as in file names; anonymous: no
; caller ID). With allow, only those numbers; deny refuses some
[callerid]
;allow = 555* 1800*
;deny = 1900* 5550000
anonymous = yes
deny_message = "\r\nThis line does not take your call.\r\n"
; a number of its own: deny = yes refuses it; user = logs it in as that
; user without a password (caller ID can be forged: only where the network
; vouches for it); item = starts that item at once after the login
;[number 5551234]
;user = alice
;item = ppp
; users in a text file: user:hash, # comments. hash: bcrypt ($2b$...,
; modemmenu -hash makes one), {SHA256}hex, {SHA512}hex, {SSHA256}base64,
; {SSHA512}base64 or {PLAIN}text (hash = plain: the rest of the line, as is)
[file]
path = /etc/asterisk/modemmenu.users
hash = auto
; LDAP: a bind as the user. Either bind_dn with {user} in it, or a search
; for the user's entry (search_base, search_filter) as search_bind_dn, then
; a bind as the entry found. Restrict who may log in in the filter, e.g.
; (&(uid={user})(memberOf=cn=dialup,ou=groups,dc=example,dc=com))
[ldap]
url = ldaps://ldap.example.com
;url = ldap://ldap.example.com:389
;starttls = yes
;ca_file = /etc/ssl/certs/example-ca.pem
;insecure_skip_verify = no
timeout = 10
;bind_dn = uid={user},ou=people,dc=example,dc=com
search_base = ou=people,dc=example,dc=com
search_filter = (&(objectClass=posixAccount)(uid={user}))
;search_bind_dn = cn=modem,ou=services,dc=example,dc=com
;search_bind_password = secret
; groups for the items' groups = (no group_base: LDAP has none): a group
; is an entry under group_base that group_filter finds, {group} the item's
; group, {dn} the caller's entry, {user} their name; searched as
; search_bind_dn, else as the caller
;group_base = ou=groups,dc=example,dc=com
;group_filter = (&(cn={group})(|(member={dn})(uniqueMember={dn})(memberUid={user})))
; how mode = passwd changes a password: exop (Password Modify, RFC 3062;
; OpenLDAP, 389 DS and most), or ad (Active Directory's unicodePwd, over
; ldaps:// or starttls only)
;password_change = exop
; system: the accounts of this machine, by PAM: the auth and account stacks
; of pam_service (modemmenu.pam.sample as /etc/pam.d/modemmenu), so local
; accounts, sssd, Kerberos, whatever PAM is set up for. Needs a build with
; PAM (make finds libpam's headers), and root for pam_unix. Accounts with
; a uid below min_uid are not let in, nor root unless allow_root; with
; groups, only their members
[system]
pam_service = modemmenu
min_uid = 1000
allow_root = no
;groups = dialup
; SQL: query gets args (user, password, in that order of placeholders) and
; returns one column: the stored password, checked as hash says (auto: by
; its prefix as in [file]; or bcrypt, sha256, sha512, plain). hash = none:
; any row means the login is right (the query checks the password itself)
[sql]
; mysql (or mariadb), postgres, sqlite
driver = mysql
dsn = modem:secret@tcp(127.0.0.1:3306)/bbs
query = SELECT password FROM users WHERE username = ? AND enabled = 1
args = user
hash = auto
; mode = passwd items: update_query sets the password, with update_args
; (user, password, old_password, in the order of its placeholders);
; update_hash = bcrypt stores a bcrypt hash, none the password as typed
; (for a query that hashes it). Without update_query, SQL passwords
; cannot be changed from the menu
update_query = UPDATE users SET password = ? WHERE username = ?
update_args = password user
update_hash = bcrypt
;driver = postgres
;dsn = postgres://modem:secret@127.0.0.1/bbs?sslmode=disable
;query = SELECT 1 FROM users WHERE username = $1 AND password = crypt($2, password)
;args = user password
;hash = none
;update_query = UPDATE users SET password = crypt($1, gen_salt('bf')) WHERE username = $2
;update_args = password user
;update_hash = none
;driver = sqlite
;dsn = /var/lib/asterisk/users.db
;query = SELECT password FROM users WHERE username = ?
; modemmenu -serve: one modemmenu for all calls, on a unix socket (or
; tcp:host:port). Each connection gets a session of its own on a new pty,
; as app_dmodem's mode = exec would give it
[server]
listen = /run/modemmenu/modemmenu.sock
; the socket's permissions: who may connect (app_dmodem: Asterisk's group)
socket_mode = 0660
;socket_group = asterisk
; the call's details come first on each connection, NAME=value lines and an
; empty line: app_dmodem's header = yes (DMODEM_*), or a menu item's
; header = yes (MODEM_*). no: the caller's bytes from the start
header = yes
header_timeout = 10
; yes: a header with MODEM_USER (another modemmenu's item, header = yes)
; logs the caller in without asking again. Only for a socket that nothing
; but trusted menus can connect to
trust_user = no
; connections at once; more are told the lines are busy
max_sessions = 32
; The auth socket: the BBS's other logins (telnet, SSH, the web) ask the
; backends above for a user's password through it, so that it is the same
; one. Answered by -serve, or by -authd alone. Who may ask: socket_mode
; and socket_group, and allow_users (the peer's user)
;[authd]
;listen = /run/modemmenu/auth.sock
;socket_mode = 0660
;socket_group = bbs
;allow_users = bbs
; requests at once
;max_clients = 16
[menu]
title = "\r\nMain menu\r\n"
prompt = "\r\nSelection: "
; the items in order (default: every [item ...] in file order)
items = bbs ppp shell passwd
; the caller types a choice and Enter: an item's key, its name or one of
; its aliases, in any case (P, p, ppp). ? shows the menu again. What hangs
; up (the first one is shown in the menu):
hangup = G goodbye bye logoff
; yes: one key selects at once, without Enter (one-character keys only)
hotkeys = no
; An item:
; key = B its key in the menu, one or more characters
; (default: its name's first letter)
; aliases = ... more words that select it (its name always does)
; label = ... its line in the menu
; mode = exec a program on the line: command (by /bin/sh -c)
; passwd built in: the caller changes their password
; (min_password = 8 characters)
; callers built in: the last callers (count = 10), the time,
; user and rate of each login (state_dir/callers,
; the latest 200; kept only with such an item)
; tcp a TCP server, raw: host, port; send is sent first
; unix a server on a unix socket, raw: path; send too
; (tcp, telnet and rlogin take a path as well, for
; their protocol on a unix socket)
; telnet a telnet server: host, port (23), terminal (ANSI)
; rlogin an rlogin server: host, port (513), and
; rlogin_client_user ({password}), rlogin_server_user
; ({user}), rlogin_terminal (ansi/{baud})
; run_as = {user} exec as this system user (modemmenu must be root)
; tty = raw the line as app_dmodem has it; sane: cooked, echo,
; CR to LF, for programs that want a terminal
; pass_password = yes the password in {password} and MODEM_PASSWORD
; session_file = no yes: the session as JSON in a 0600 file, its path
; in MODEM_SESSION_FILE (removed after)
; after = hangup when the item ends: hang up, or back to the menu
; connect_timeout = 10 seconds to reach a server
; header = no tcp, unix, telnet, rlogin: yes sends the session
; first, MODEM_* NAME=value lines and an empty line
; (the password only with pass_password), for
; modemmenu -serve or any program that reads it
;
; Who sees an item (all that are set must pass; the others neither see nor
; can choose it):
; users = alice bob these users ...
; groups = sysops ... or members of these groups ([groups], or the
; system's for auth = system)
; min_baud = 9600 the connect rate at least this (unknown: no)
; callerids = 555* the caller ID matching one of these
; guest = no yes: guests see it too
; A BBS by rlogin: Synchronet and Mystic log the caller in with the user
; name as the server user and the password as the client user
[item bbs]
key = B
label = Bulletin board
mode = rlogin
host = 127.0.0.1
port = 513
rlogin_client_user = {password}
rlogin_server_user = {user}
rlogin_terminal = ansi/{baud}
after = menu
; or a BBS that reads its login from the line:
;mode = tcp
;port = 2323
;send = "{user}\r{password}\r"
; PPP: pppd on the line. The caller is logged in already: noauth, and
; ipparam hands the user to /etc/ppp/ip-up (as $6), which also sees MODEM_*
[item ppp]
key = P
aliases = dialup net
min_baud = 9600
label = PPP (dial-up networking)
; no time warning in the middle of PPP's frames
time_warning = no
mode = exec
command = exec /usr/sbin/pppd nodetach noauth local lock passive 192.168.77.1:192.168.77.2 ms-dns 192.168.77.1 ipparam {user}
; the caller's password changed where their account is: the users file,
; SQL (update_query), LDAP (Password Modify, as the user) or the system
; (PAM's password stack). after = menu by default
[item passwd]
key = PW
label = Change your password
mode = passwd
min_password = 8
; a shell of the caller's account (modemmenu runs as root for run_as)
[item shell]
key = S
label = Shell
groups = sysops
mode = exec
run_as = {user}
tty = sane
pass_password = no
command = exec "$SHELL" -l
after = menu
; another menu: a modemmenu -serve with trust_user, which takes the caller
; as logged in here
;[item more]
;key = M
;label = More services
;mode = unix
;path = /run/modemmenu/more.sock
;header = yes
;after = menu
; More items, to copy into items = above. Each needs its program installed;
; run_as = {user} (modemmenu as root) keeps callers in their own accounts.
; who called last
;[item callers]
;key = LC
;label = Last callers
;mode = callers
;count = 10
; files by ZMODEM (lrzsz): rz receives what the caller's terminal sends,
; binary, restricted to the directory, renaming rather than overwriting
;[item upload]
;key = U
;label = Upload a file (ZMODEM)
;run_as = {user}
;command = cd "$HOME/uploads" && exec rz -b -R -E
;after = menu
; files by Kermit (C-Kermit): a Kermit server in the caller's files; their
; terminal's Kermit GETs and SENDs, then FINISH returns to the menu
;[item kermit]
;key = K
;label = Kermit file server
;run_as = {user}
;tty = sane
;command = cd "$HOME" && exec kermit -Y -x
;after = menu
; the web as text: lynx with the anonymous account's restrictions (no
; shell, no saving files); w3m is the other choice
;[item web]
;key = W
;label = The web (lynx)
;run_as = {user}
;tty = sane
;command = exec lynx -anonymous https://example.org/
;after = menu
; mail and news in the caller's account
;[item mail]
;key = M
;label = Mail
;groups = dialup
;run_as = {user}
;tty = sane
;pass_password = no
;command = exec mutt
;after = menu
;[item news]
;key = N
;label = Usenet news
;run_as = {user}
;tty = sane
;command = exec tin -r
;after = menu
; chat among callers on your own IRC server
;[item chat]
;key = C
;label = Chat (IRC)
;run_as = {user}
;tty = sane
;command = exec irssi -c 127.0.0.1 -n {user}
;after = menu
; Gopher: quick even at 2400 bit/s
;[item gopher]
;key = GO
;label = Gopherspace
;run_as = {user}
;tty = sane
;command = exec lynx -anonymous gopher://gopher.floodgap.com/
;after = menu