Re: Unable to set root password with clear text using preseed/early_command
Thanks for the tip.
I’m not sure if escaping is the issue. I tried directly specifying the password:
debconf-set passwd/root-password passwd1234
debconf-set passwd/root-password-again passwd1234
Still got prompted.
I tried to debug it with
d-i preseed/early_command string \
set -x; \
. /usr/share/debconf/confmodule; \
db_set passwd/root-password passwd1234; \
db_set passwd/root-password-again passwd1234; \
db_input critical passwd/root-password
And the syslog shows RET='value set’ for db_set passwd/root-password, and RET='question will be asked’ for db_input critical passwd/root-password.
It seems the password type is somehow specially handled and could’t be set this way? But very strange that it works when specifying "d-i passwd/root-password password …” in preseed to set it. I’m still unable to locate the code that does the special handling for password type.
> On Feb 16, 2022, at 6:01 AM, Geert Stappers <stappers@stappers.nl> wrote:
>
> On Tue, Feb 15, 2022 at 08:08:08PM +0800, Glen Huang wrote:
>> Hi,
>>
>> I want to set the root password to a random string. this is the preseed I use:
>>
>> d-i preseed/early_command string \
>> pw="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 24)"; \
>> debconf-set passwd/root-password "$pw"; \
>> debconf-set passwd/root-password-again "$pw"
>>
>> However, the installer still prompts me for the root password.
>>
>> Setting the crypted password works though:
>>
>> d-i preseed/early_command string \
>> debconf-set passwd/root-password-crypted '<crypted-string>'
>>
>> Directly setting the password also works:
>>
>> d-i passwd/root-password password r00tme
>> d-i passwd/root-password-again password r00tme
>>
>> From https://sources.debian.org/src/user-setup/1.88/user-setup-ask/#L36,
>> it seems the installer will ask for the root password if
>> root-password-crypted is empty or !. My guess is that in the direct
>> version, somehow root-password-crypted gets a corresponding value when
>> only root-password and root-password-again are set, but I couldn't
>> find the code responsible for that.
>>
>> I'd be grateful if anyone could shed some light.
>>
>
> Completely UNtested, a.k.a. sharing a thought:
>
> d-i preseed/early_command string \
> tr -dc A-Za-z0-9 </dev/urandom | head -c 24 > /tmp/pw ; \
> cat /tmp/pw | debconf-set passwd/root-password - ; \
> cat /tmp/pw | debconf-set passwd/root-password-again -
>
>
> Groeten
> Geert Stappers
> Not knowing how much of the early_command_string gets into log file.
> --
> Silence is hard to parse
>
Reply to: