summaryrefslogtreecommitdiffstats
path: root/debian/patches/replace-radsecret.patch
blob: 616f6ea70284e11ab0864c834cd0ea43031ecb7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Description: replace radsecret with a Bash variant
 This avoids adding two perl dependencies which are in Universe, and trigger a
 component mismatch in Ubuntu.
 .
 This patch is 3 changes put together:
 https://github.com/FreeRADIUS/freeradius-server/commit/b77c4e295a55451efea4ff44029a2551c855386c
 https://github.com/FreeRADIUS/freeradius-server/commit/3d568a74ed566089062ecca635bf0e89a1895346
 And replacing random with urandom as commented in https://github.com/FreeRADIUS/freeradius-server/pull/5375#issuecomment-2233818142
 .
 Discussion in https://github.com/FreeRADIUS/freeradius-server/pull/5375
Origin: upstream, https://github.com/FreeRADIUS/freeradius-server/commit/b77c4e295a55451efea4ff44029a2551c855386c and others, see description
Bug-Debian: https://bugs.debian.org/1076458
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/freeradius/+bug/2073269
Last-Update: 2024-07-17

Index: freeradius/src/main/radsecret
===================================================================
--- freeradius.orig/src/main/radsecret	2024-07-17 14:41:42.151818906 -0300
+++ freeradius/src/main/radsecret	2024-07-17 14:42:04.490103653 -0300
@@ -1,7 +1,14 @@
-#!/usr/bin/env perl
+#!/bin/sh
 #
 #  A tool which generates strong shared secrets.
 #
-use Convert::Base32;
-use Crypt::URandom();
-print join('-', unpack("(A4)*", lc encode_base32(Crypt::URandom::urandom(12)))), "\n";
+openssl rand -base64 12 2>/dev/null && exit 0
+
+(dd if=/dev/urandom bs=1 count=12 2>/dev/null | base64 2>/dev/null) && exit 0
+
+(dd if=/dev/urandom bs=1 count=12 2>/dev/null | base32 2>/dev/null) && exit 0
+
+(dd if=/dev/urandom bs=1 count=12 2>/dev/null | hexdump -ve '/1 "%02x"';echo) && exit 0
+
+echo "Failed finding 'openssl', 'base64', 'base32', or 'hexdump' tools".
+exit 1