From: Christian Korber Date: Mon, 27 Apr 2026 10:03:27 +0000 (+0200) Subject: luci-app-acl: use setPassword for password change X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=302e3855b0c6c7ab15d23a495376ecb5d7911d6b;p=openwrt-luci.git luci-app-acl: use setPassword for password change Because now `setPassword` handles password creation, it is used in acl. Signed-off-by: Christian Korber --- diff --git a/applications/luci-app-acl/htdocs/luci-static/resources/view/system/acl.js b/applications/luci-app-acl/htdocs/luci-static/resources/view/system/acl.js index 77300d0f0b..4dcad0cc59 100644 --- a/applications/luci-app-acl/htdocs/luci-static/resources/view/system/acl.js +++ b/applications/luci-app-acl/htdocs/luci-static/resources/view/system/acl.js @@ -3,12 +3,20 @@ 'require dom'; 'require fs'; 'require ui'; +'require rpc'; 'require uci'; 'require form'; 'require tools.widgets as widgets'; const aclList = {}; +const callSetPassword = rpc.declare({ + object: 'luci', + method: 'setPassword', + params: [ 'username', 'password', 'oldpassword', 'rpcd' ], + expect: { result: 1 } +}); + function globListToRegExp(section_id, option) { const list = L.toArray(uci.get('rpcd', section_id, option)); const positivePatterns = []; @@ -271,15 +279,12 @@ return view.extend({ }; o.write = function(section_id, value) { const variant = this.map.lookupOption('_variant', section_id)[0]; + const user = this.map.lookupOption('username', section_id)[0].formvalue(section_id); if (variant.formvalue(section_id) == 'crypted' && value.substring(0, 3) != '$1$') - return fs.exec('/usr/sbin/uhttpd', [ '-m', value ]).then(function(res) { - if (res.code == 0 && res.stdout) - uci.set('rpcd', section_id, 'password', res.stdout.trim()); - else - throw new Error(res.stderr); - }).catch(function(err) { - throw new Error(_('Unable to encrypt plaintext password: %s').format(err.message)); + return callSetPassword(user, value, '', true).then(function(success) { + if (!success) + throw new Error('Failed to create password'); }); uci.set('rpcd', section_id, 'password', value); diff --git a/applications/luci-app-acl/root/usr/share/rpcd/acl.d/luci-app-acl.json b/applications/luci-app-acl/root/usr/share/rpcd/acl.d/luci-app-acl.json index 89834af09f..7aa40bfb3c 100644 --- a/applications/luci-app-acl/root/usr/share/rpcd/acl.d/luci-app-acl.json +++ b/applications/luci-app-acl/root/usr/share/rpcd/acl.d/luci-app-acl.json @@ -13,7 +13,10 @@ "uci": [ "rpcd" ] }, "write": { - "uci": [ "rpcd" ] + "uci": [ "rpcd" ], + "ubus": { + "luci": [ "setPassword" ] + } } } }