Files
login/samples/dmodem-login-useradd.sample
Claude 9d5cdfa76e Signup: make the new account in each login backend
A signup made the account in the users file only. Now it makes the
account in each backend of [general] auth that is set up to make
accounts: the users file, SQL ([sql] insert_query), LDAP ([ldap] add_dn,
added as add_bind_dn, the password set by Password Modify or unicodePwd
for AD) and system accounts ([system] create_command, with a useradd
sample script). [signup] backends limits the list.

Before the account is made, each backend checks that the name is free.
If one backend fails, the accounts already made are taken back
(delete_query, entry delete, remove_command). With pending = yes, each
backend must lock the account, or dmodem-login does not start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRfuh3h6uNuHtaugux
2026-11-24 16:56:35 +00:00

28 lines
897 B
Bash
Executable File

#!/bin/sh
# Copyright (C) 2026 D-Modem Authors
# SPDX-License-Identifier: AGPL-3.0-only
#
# dmodem-login-useradd USER PENDING: makes the system account of a
# signup. [system] create_command runs it:
#
# create_command = /usr/local/sbin/dmodem-login-useradd {user} {pending}
# remove_command = userdel -r {user}
#
# The password comes on the standard input. PENDING = yes locks the
# account until the sysop unlocks it (usermod -U USER). Change GROUP and
# SHELL for your system. dmodem-login must run as root for useradd.
set -eu
user=$1
pending=$2
GROUP=${GROUP:-dialup}
SHELL_=${SHELL_:-/usr/sbin/nologin}
IFS= read -r password
getent group "$GROUP" >/dev/null || groupadd "$GROUP"
useradd --create-home --shell "$SHELL_" --gid "$GROUP" \
--comment "dmodem-login signup" "$user"
printf '%s:%s\n' "$user" "$password" | chpasswd
if [ "$pending" = yes ]; then
usermod --lock "$user"
fi