[elbe-devel] [PATCH v2 8/8] commands: add passwd sub-command

Bastian Germann bage at linutronix.de
Fri Jun 24 13:23:17 CEST 2022


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.

If you want to leave that to me, I am okay with that.
Thanks for your work on this!

> ---
>   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))


More information about the elbe-devel mailing list