dell / iDRAC-Redfish-Scripting

Python and PowerShell scripting for Dell EMC PowerEdge iDRAC REST API with DMTF Redfish
GNU General Public License v2.0
598 stars 276 forks source link

a problem if "$" included in password. #216

Closed kiraway-dev closed 2 years ago

kiraway-dev commented 2 years ago

This has been tested with InsertEjectVirtualMediaREDFISH.py script. If password has "$" char, NFS and CIFS authentication will be failed.

texroemer commented 2 years ago

Hi @kiraway-dev

NFS doesn't support auth, only CIFS, HTTP and HTTPS.

For CIFS, this should work with dollar sign in password string, can you share what iDRAC version you're using? I just tested on 5.10.10 and no issues. I tried with passwords Test$123, Test123$ and $Test123, no issues.

C:\Python39>InsertEjectVirtualMediaREDFISH.py -ip 192.168.0.120 -u root -p calvin --action insert --device cd --uri //192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso --username cifs_user --password $Test123

Thanks Tex

kiraway-dev commented 2 years ago

Hello @texroemer

iDRAC Version is "5.10.00.00" Here is result of test.

user1 / ABC$P@ssw0rd -- failed

python InsertEjectVirtualMediaREDFISH.py -ip 10.10.10.19 -u root -p calvin --action insert --device cd --username user1 --password ABC$P@ssw0rd --uri //192.168.2.245/d/iso/centos/CentOS-8.4-x86_64-20210716-dvd1.iso

user1 / P@ssw0rd -- successed

python InsertEjectVirtualMediaREDFISH.py -ip 10.10.10.19 -u root -p calvin --action insert --device cd --username user1 --password P@ssw0rd --uri //192.168.2.245/d/iso/centos/CentOS-8.4-x86_64-20210716-dvd1.iso

texroemer commented 2 years ago

Hi @kiraway-dev

Just noticed you're using a Linux system to run the python script. When passing in dollar sign for any argument value, you have to escape the dollar sign with a backslash (this is linux behavior).

Example of failing and then escape the dollar sign, passes.

[root@SCPexport nfs]# python3 InsertEjectVirtualMediaREDFISH.py -ip 192.168.0.120 -u root -p calvin --action insert --device cd --uri //192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso --username cifs_user --password ABC$P@ssw0rd

- INFO, insert(attached) "CD" virtual media device "//192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso"

- FAIL, POST command InsertMedia action failed, detailed error message: b'{"error":{"@Message.ExtendedInfo":[{"Message":"Unable to mount remote share //192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso.","MessageArgs":["//192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso"],"MessageArgs@odata.count":1,"MessageId":"IDRAC.2.5.RAC0720","RelatedProperties":["#/Image"],"RelatedProperties@odata.count":1,"Resolution":"Retry the operation.","Severity":"Informational"}],"code":"Base.1.8.GeneralError","message":"A general error has occurred. See ExtendedInfo for more information"}}'

[root@SCPexport nfs]# python3 InsertEjectVirtualMediaREDFISH.py -ip 192.168.0.120 -u root -p calvin --action insert --device cd --uri //192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso --username cifs_user --password ABC\$P@ssw0rd

- INFO, insert(attached) "CD" virtual media device "//192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso"

- PASS, POST command passed to successfully insert(attached) CD media, status code 204 returned
kiraway-dev commented 2 years ago

Hi @kiraway-dev

Just noticed you're using a Linux system to run the python script. When passing in dollar sign for any argument value, you have to escape the dollar sign with a backslash (this is linux behavior).

Example of failing and then escape the dollar sign, passes.

[root@SCPexport nfs]# python3 InsertEjectVirtualMediaREDFISH.py -ip 192.168.0.120 -u root -p calvin --action insert --device cd --uri //192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso --username cifs_user --password ABC$P@ssw0rd

- INFO, insert(attached) "CD" virtual media device "//192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso"

- FAIL, POST command InsertMedia action failed, detailed error message: b'{"error":{"@Message.ExtendedInfo":[{"Message":"Unable to mount remote share //192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso.","MessageArgs":["//192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso"],"MessageArgs@odata.count":1,"MessageId":"IDRAC.2.5.RAC0720","RelatedProperties":["#/Image"],"RelatedProperties@odata.count":1,"Resolution":"Retry the operation.","Severity":"Informational"}],"code":"Base.1.8.GeneralError","message":"A general error has occurred. See ExtendedInfo for more information"}}'

[root@SCPexport nfs]# python3 InsertEjectVirtualMediaREDFISH.py -ip 192.168.0.120 -u root -p calvin --action insert --device cd --uri //192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso --username cifs_user --password ABC\$P@ssw0rd

- INFO, insert(attached) "CD" virtual media device "//192.168.0.130/cifs_share_vm/VMware-VMvisor-Installer-7-A01.iso"

- PASS, POST command passed to successfully insert(attached) CD media, status code 204 returned

What do you think about adding a password check function to automatically insert escape characters?

texroemer commented 2 years ago

Linux behavior in general will read dollar sign and immediately try to convert the value as a string formatter before Python code even receives the value. To use dollar sign in an argument value, you have to escape it in Linux. If using Windows to run Python script, you don't need to escape the dollar sign.

kiraway-dev commented 2 years ago

OK. I got it. Thank you.