我注意到passwd
实用程序不支持-s/--stdin
Debian 上的允许从标准输入读取密码的选项。使用此选项,您可以执行一些操作,例如echo mypassword | passwd -s mylogin
从脚本为特定登录设置密码。
我只是想尝试一下,但发现在 Ubuntu 或基于 Ubuntu 的 Debian 上都无法实现。它会打印错误,提示“无法识别选项”。
因此我去了 Debian 源代码中的passwd包(它在这里https://salsa.debian.org/debian/shadow/-/tree/master/debian?ref_type=heads)并试图找到删除该选项的补丁,因为在passwd
实用程序的原始源代码中该选项仍然存在(https://salsa.debian.org/debian/shadow/-/blob/master/src/passwd.c?ref_type=heads#L166)。
我在存储库中找不到补丁,它似乎不在那里。有人能帮我找到它吗?我不知道用于修补原始源代码的工作流程,但我希望补丁在那里,因为有一个包含补丁的文件夹(https://salsa.debian.org/debian/shadow/-/tree/master/debian/patches/debian?ref_type=heads)。
谢谢。
所以我终于找到了“问题”在哪里。多年来我一直认为这个
-s/--stdin
选项是实用程序的一部分(我对 Linux 的理解还很新)。passwd
实际上,根据 github 上的上游信息(https://github.com/shadow-maint/shadow/commit/49001ca846d1e2894b4719d66889ab7e1b4b698a),它是今年(2024 年)实现的。
Debian 12 代号为 bookworm passwd 的软件包是基于较旧的源代码构建的(分支 4.13 https://salsa.debian.org/debian/shadow/-/blob/upstream/4.13+dfsg1/src/passwd.c?ref_type=tags)。我只检查了 master 分支,其中已经包含了更改。
没关系,至少我学到了一些新东西。