fix(master-link): Rename RPCD to luci.master_link and flatten JSON output

Hyphens in RPCD filenames break ubus CLI argument parsing. Rename
luci.master-link to luci.master_link and update all references in
the JS view, ACL, and Makefile. Also pipe RPCD method output through
tr -d '\n\t' so ubus receives single-line JSON it can parse.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-03 06:40:41 +01:00
parent c4c829a593
commit 13960d39c3
4 changed files with 23 additions and 23 deletions

View File

@ -23,7 +23,7 @@ define Package/luci-app-master-link/install
$(INSTALL_DATA) ./htdocs/luci-static/resources/view/secubox/master-link.js $(1)/www/luci-static/resources/view/secubox/ $(INSTALL_DATA) ./htdocs/luci-static/resources/view/secubox/master-link.js $(1)/www/luci-static/resources/view/secubox/
$(INSTALL_DIR) $(1)/usr/libexec/rpcd $(INSTALL_DIR) $(1)/usr/libexec/rpcd
$(INSTALL_BIN) ./root/usr/libexec/rpcd/luci.master-link $(1)/usr/libexec/rpcd/ $(INSTALL_BIN) ./root/usr/libexec/rpcd/luci.master_link $(1)/usr/libexec/rpcd/
endef endef
$(eval $(call BuildPackage,luci-app-master-link)) $(eval $(call BuildPackage,luci-app-master-link))

View File

@ -7,36 +7,36 @@
'require uci'; 'require uci';
var callStatus = rpc.declare({ var callStatus = rpc.declare({
object: 'luci.master-link', object: 'luci.master_link',
method: 'status', method: 'status',
expect: { '': {} } expect: { '': {} }
}); });
var callPeers = rpc.declare({ var callPeers = rpc.declare({
object: 'luci.master-link', object: 'luci.master_link',
method: 'peers', method: 'peers',
expect: { '': {} } expect: { '': {} }
}); });
var callTree = rpc.declare({ var callTree = rpc.declare({
object: 'luci.master-link', object: 'luci.master_link',
method: 'tree', method: 'tree',
expect: { '': {} } expect: { '': {} }
}); });
var callTokenGenerate = rpc.declare({ var callTokenGenerate = rpc.declare({
object: 'luci.master-link', object: 'luci.master_link',
method: 'token_generate' method: 'token_generate'
}); });
var callApprove = rpc.declare({ var callApprove = rpc.declare({
object: 'luci.master-link', object: 'luci.master_link',
method: 'approve', method: 'approve',
params: ['fingerprint', 'action', 'reason'] params: ['fingerprint', 'action', 'reason']
}); });
var callTokenCleanup = rpc.declare({ var callTokenCleanup = rpc.declare({
object: 'luci.master-link', object: 'luci.master_link',
method: 'token_cleanup' method: 'token_cleanup'
}); });

View File

@ -9,20 +9,20 @@ case "$1" in
call) call)
case "$2" in case "$2" in
status) status)
. /usr/lib/secubox/master-link.sh 2>/dev/null . /usr/lib/secubox/master-link.sh >/dev/null 2>&1
ml_status ml_status | tr -d '\n\t'
;; ;;
peers) peers)
. /usr/lib/secubox/master-link.sh 2>/dev/null . /usr/lib/secubox/master-link.sh >/dev/null 2>&1
ml_peer_list ml_peer_list | tr -d '\n\t'
;; ;;
tree) tree)
. /usr/lib/secubox/master-link.sh 2>/dev/null . /usr/lib/secubox/master-link.sh >/dev/null 2>&1
ml_tree ml_tree | tr -d '\n\t'
;; ;;
token_generate) token_generate)
. /usr/lib/secubox/master-link.sh 2>/dev/null . /usr/lib/secubox/master-link.sh >/dev/null 2>&1
ml_token_generate ml_token_generate | tr -d '\n\t'
;; ;;
approve) approve)
read -r input read -r input
@ -30,17 +30,17 @@ case "$1" in
action=$(echo "$input" | jsonfilter -e '@.action' 2>/dev/null) action=$(echo "$input" | jsonfilter -e '@.action' 2>/dev/null)
reason=$(echo "$input" | jsonfilter -e '@.reason' 2>/dev/null) reason=$(echo "$input" | jsonfilter -e '@.reason' 2>/dev/null)
. /usr/lib/secubox/master-link.sh 2>/dev/null . /usr/lib/secubox/master-link.sh >/dev/null 2>&1
case "$action" in case "$action" in
approve) approve)
ml_join_approve "$fingerprint" ml_join_approve "$fingerprint" | tr -d '\n\t'
;; ;;
reject) reject)
ml_join_reject "$fingerprint" "$reason" ml_join_reject "$fingerprint" "$reason" | tr -d '\n\t'
;; ;;
promote) promote)
ml_promote_to_submaster "$fingerprint" ml_promote_to_submaster "$fingerprint" | tr -d '\n\t'
;; ;;
*) *)
echo '{"error":"invalid_action"}' echo '{"error":"invalid_action"}'
@ -48,8 +48,8 @@ case "$1" in
esac esac
;; ;;
token_cleanup) token_cleanup)
. /usr/lib/secubox/master-link.sh 2>/dev/null . /usr/lib/secubox/master-link.sh >/dev/null 2>&1
ml_token_cleanup ml_token_cleanup | tr -d '\n\t'
;; ;;
*) *)
echo '{"error":"unknown_method"}' echo '{"error":"unknown_method"}'

View File

@ -8,7 +8,7 @@
}, },
"ubus": { "ubus": {
"file": ["read", "stat"], "file": ["read", "stat"],
"luci.master-link": ["*"] "luci.master_link": ["*"]
}, },
"uci": ["master-link"] "uci": ["master-link"]
}, },
@ -17,7 +17,7 @@
"/etc/config/master-link": ["write"] "/etc/config/master-link": ["write"]
}, },
"ubus": { "ubus": {
"luci.master-link": ["*"] "luci.master_link": ["*"]
}, },
"uci": ["master-link"] "uci": ["master-link"]
} }