From cc64aee28824dc3db49737c3b510f4d3604ea8f2 Mon Sep 17 00:00:00 2001 From: steering7253 Date: Tue, 5 May 2026 02:34:22 +0000 Subject: use fqdn everywhere --- authorized_keys.sh | 2 +- autopeer_shell.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/authorized_keys.sh b/authorized_keys.sh index b8a016c..6544416 100755 --- a/authorized_keys.sh +++ b/authorized_keys.sh @@ -16,7 +16,7 @@ if [ "$1" = "new" ]; then if getent passwd "$user"; then exit 0 else - echo "[autopeer $(hostname)] New user being created: $user from $key $connection" | socat stdio "$NOTIFY_TO" + echo "[autopeer $(hostname -f)] New user being created: $user from $key $connection" | socat stdio "$NOTIFY_TO" /usr/sbin/adduser --disabled-password --quiet --comment "created at $(date +%s) by $key ${connection//:/_}" --ingroup autopeer "$user" /usr/sbin/adduser "$user" bird ( umask 0077; touch "/var/log/autopeer/$user".{tim,io}; ) diff --git a/autopeer_shell.py b/autopeer_shell.py index 9ec8702..307b04f 100755 --- a/autopeer_shell.py +++ b/autopeer_shell.py @@ -67,10 +67,10 @@ SELECTED_ASN = as_from_user() class AutopeerShell(cmd.Cmd): def preloop(self): self.intro = f'Welcome to the autopeer shell. Type help or ? to list commands.\nSelected AS: {SELECTED_ASN}' - self.prompt = f'{getpass.getuser()}@{socket.gethostname()}:{SELECTED_ASN}> ' + self.prompt = f'{getpass.getuser()}@{socket.getfqdn()}:{SELECTED_ASN}> ' def postcmd(self, stop, line): - self.prompt = f'{getpass.getuser()}@{socket.gethostname()}:{SELECTED_ASN}> ' + self.prompt = f'{getpass.getuser()}@{socket.getfqdn()}:{SELECTED_ASN}> ' return stop def onecmd(self, line): @@ -146,7 +146,7 @@ My Tunnel IPv6LL: {me.ipll} print(f'Error: {name} already exists', file=sys.stderr) return - sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.gethostname()}] Created new peering {name!r} for AS{SELECTED_ASN} by {USER}", text=True) + sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.getfqdn()}] Created new peering {name!r} for AS{SELECTED_ASN} by {USER}", text=True) try: curs = DB.execute( @@ -172,7 +172,7 @@ My Tunnel IPv6LL: {me.ipll} ''' Delete your peering. Note: The deletion will be processed the next time the cronjob runs, at which time the name will become available.''' - sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.gethostname()}] Deleted peering {name!r} for AS{SELECTED_ASN} by {USER}", text=True) + sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.getfqdn()}] Deleted peering {name!r} for AS{SELECTED_ASN} by {USER}", text=True) curs = DB.execute( 'UPDATE peers SET deleted = 1 WHERE name = :name AND asn = :asn AND deleted = 0', dict(name=name, asn=SELECTED_ASN) @@ -269,8 +269,8 @@ if __name__ == '__main__': shell = AutopeerShell() command = os.getenv('SSH_ORIGINAL_COMMAND', '') if len(command): - sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.gethostname()}] {USER} ran {command!r} via {os.getenv('SSH_CONNECTION')}", text=True) + sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.getfqdn()}] {USER} ran {command!r} via {os.getenv('SSH_CONNECTION')}", text=True) shell.onecmd(command) else: - sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.gethostname()}] {USER} logged in via {os.getenv('SSH_CONNECTION')}", text=True) + sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.getfqdn()}] {USER} logged in via {os.getenv('SSH_CONNECTION')}", text=True) shell.cmdloop() -- cgit v1.3.1-10-gc9f91