[elbe-devel] [PATCH v2 8/8] commands: add passwd sub-command
Holger Dengler
holger at hdengler.de
Sat Jun 25 23:22:57 CEST 2022
On 24.06.22 13:23, Bastian Germann wrote:
> Am 16.06.22 um 12:10 schrieb Holger Dengler:
>> Add sub-command to hash a plain-text password. The output format is
>> compatible with shadow (5) and can be used in the "passwd_hashed"
>> element in Elbe XMLs.
>>
>> Signed-off-by: Holger Dengler <holger at hdengler.de>
>
> I would prefer a documentation how to generate the password (possibly with a stronger hash on modern systems).
> mkpasswd can be used. Document an example call in the schema or in elbe preprocess's manpage.
> Maybe recommend whois (which contains mkpasswd) on the elbe package.
Ok, I'll drop this patch for the v3.
> If you want to leave that to me, I am okay with that.
Let's see, how far I get with the documentation.
> Thanks for your work on this!
np :)
>
>> ---
>> elbepack/commands/passwd.py | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>> create mode 100644 elbepack/commands/passwd.py
>>
>> diff --git a/elbepack/commands/passwd.py b/elbepack/commands/passwd.py
>> new file mode 100644
>> index 000000000..80322ec04
>> --- /dev/null
>> +++ b/elbepack/commands/passwd.py
>> @@ -0,0 +1,21 @@
>> +# ELBE - Debian Based Embedded Rootfilesystem Builder
>> +# Copyright 2022 Linutronix GmbH
>> +# Author: Holger Dengler <holger at hdengler.de>
>> +#
>> +# SPDX-License-Identifier: GPL-3.0-or-later
>> +
>> +import sys
>> +from optparse import OptionParser
>> +from crypt import crypt, METHOD_SHA512
>> +
>> +
>> +def run_command(argv):
>> + oparser = OptionParser(usage="usage: %prog passwd <plain-text-password>")
>> + (_, args) = oparser.parse_args(argv)
>> +
>> + if len(args) != 1:
>> + print("Wrong number of arguments", file=sys.stderr)
>> + oparser.print_help()
>> + sys.exit(20)
>> +
>> + print('%s' % crypt(args[0], METHOD_SHA512))
--
Gruß,
Holger Dengler
--
holger at hdengler.de
More information about the elbe-devel
mailing list