luci-app-acl: use setPassword for password change
authorChristian Korber <redacted>
Mon, 27 Apr 2026 10:03:27 +0000 (12:03 +0200)
committerPaul Donald <redacted>
Wed, 3 Jun 2026 10:49:07 +0000 (13:49 +0300)
Because now `setPassword` handles password creation,
it is used in acl.

Signed-off-by: Christian Korber <redacted>
applications/luci-app-acl/htdocs/luci-static/resources/view/system/acl.js
applications/luci-app-acl/root/usr/share/rpcd/acl.d/luci-app-acl.json

index 77300d0f0b3625ffabed2313e5e77caa0019d1e2..4dcad0cc59b098b9b8cebcc5045838bf014326f9 100644 (file)
@@ -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);
index 89834af09f62499e8c42c538891e05b099740379..7aa40bfb3c10cd9a2248976000b91b004c9013aa 100644 (file)
                        "uci": [ "rpcd" ]
                },
                "write": {
-                       "uci": [ "rpcd" ]
+                       "uci": [ "rpcd" ],
+                       "ubus": {
+                               "luci": [ "setPassword" ]
+                       }
                }
        }
 }
git clone https://git.99rst.org/PROJECT