opentechinstitute/luci-commotion — pull request #46 by areynold (2013-11-04 15:26:14+00:00)
Title: If root password is set, require existing password to set new password

Addresses opentechinstitute/commotion-openwrt/issues/29

Luci has Set Password commands in 6 files, only two of which (/usr/lib/lua/luci/model/cbi/admin_system/admin.lua and /usr/lib/lua/luci/controller/admin/system.lua) are found in Commotion.

admin.lua has been rewritten to show a conditional form field if a password has been set. Because admin.lua contains ssh form fields, including a section to upload an ssh key, the root password is required to make ANY changes on that page. If no password exists (as on first boot), the existing password field will not be shown or required.

system.lua contained an action_passwd field that did not seem to be used. That function has been removed.

The command line `passwd` command does not yet require an existing password.

Patches should be submitted to luci.

To test:
1. On first boot, click the "set a password" option in the alert box (not quickstart). You will be prompted for a password as the page loads (all admin pages request a password), but the page itself should only show fields for the new password and confirmation, not an existing password.
2. Set a root password. The change should be successful.
3. Run quickstart.
4. Click the Administration icon at the bottom of the page, then click the System > Administration link. You should see a section requiring the existing root password.
5. Enter the correct password and change the root password. Confirm that the change was successful by logging in via ssh.
6. Enter the correct password and make a change to dropbear. Confirm that the change was successful by viewing /etc/config/dropbear.
7. Enter an incorrect password and make a change to dropbear. Confirm that changes were rejected by viewing /etc/config/dropbear.
8. Enter an incorrect password and change the root password. Confirm that changes were rejected by logging in via ssh.