简体   繁体   English

bash中的Windows兼容密码

[英]Windows compatible passwords in bash

I have a script that takes windows compatible passwords and uses them to create an account for the user on the computer with that as their system password. 我有一个脚本,该脚本采用Windows兼容密码,并使用它们为计算机上的用户创建一个帐户,并将其作为系统密码。

I have run into an issue where if I escape them and pass it to create the account it is taken literally. 我遇到了一个问题,即如果我逃脱了他们并通过它来创建帐户,它将按字面意义处理。 Single ' and double " quotes are allowed in windows. Windows中允许使用单引号和双引号。

Example user enters hello'world escaped as hello\\'world and stored in the database as hello\\'world. 示例用户输入hello'world,转为hello \\'world,并以hello \\'world的形式存储在数据库中。 user inputs hello'world login. 用户输入hello'world登录。 Computer expects hello\\'world as the correct password, user can not login. 计算机期望hello \\'world为正确的密码,用户无法登录。

Adding code: 添加代码:

echo "somepass" | sudo -S /Applications/Setup\ user.app/Contents/Resources/nugget "Joe User" "juser" "ju$er'Pa$$".345"

Essentially the account for the user is created, another admin account has to be used and the password set from the gui where ju$er'Pa$$".345 is entered and from there the user can login fine. 从本质上讲,已经为用户创建了帐户,必须使用另一个管理员帐户,并从gui设置密码,在该gui中输入ju $ er'Pa $$“。345,然后用户可以从该帐户登录。

Does this do what you want? 这是您想要的吗? (Obviously you need a safe method to retrieve the password, either from read input or by reading from a file handle or pipe). (显然,您需要一种安全的方法,可以通过read输入或通过读取文件句柄或管道来检索密码)。

neech@nicolaw.uk:~ $ read -r password ; printf '%q\n' "$password"
ju$er'Pa$$".345
ju\$er\'Pa\$\$\".345
neech@nicolaw.uk:~ $

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM