Skip to content

Commit 841bae5

Browse files
committed
Fix permission error in HyperOS
1 parent 90c644a commit 841bae5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

module/webroot/js/common.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function updateModuleInformation () {
4040

4141
export async function getModuleActiveState () {
4242
try {
43-
const { stdout: file_exists } = await exec(`ls "/dev/.tcp_module_log_cleared"`);
43+
const { stdout: file_exists } = await exec(`su -c 'ls /dev/.tcp_module_log_cleared'`);
4444
return file_exists != "" ? true: false;
4545
}catch (error) {
4646
console.error('Error updating module state:', error);
@@ -62,7 +62,7 @@ export async function get_active_iface () {
6262

6363
export async function get_active_algorithm () {
6464
try {
65-
const { stdout: active_algo } = await exec(`cat /proc/sys/net/ipv4/tcp_congestion_control`);
65+
const { stdout: active_algo } = await exec(`su -c "cat /proc/sys/net/ipv4/tcp_congestion_control"`);
6666
return active_algo.trim()
6767
} catch (error) {
6868
console.error('Error fetching active interface: ', error);
@@ -90,7 +90,7 @@ export async function get_wifi_calling_state() {
9090

9191
try {
9292
// Run dumpsys and save to file
93-
await exec(`dumpsys activity service SystemUIService > "${DUMPSYS_TMP_FILE}" 2>/dev/null`);
93+
await exec(`su -c 'dumpsys activity service SystemUIService > "${DUMPSYS_TMP_FILE}" 2>/dev/null'`);
9494

9595
// Check for VoWiFi pattern
9696
const { stdout: returnCode } = await exec(`

module/webroot/js/settings.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { fetchIsConfigFile } from './common.js';
55

66
async function getSelectedAlgorithm(prefix) {
77
try {
8-
const { stdout: algo } = await exec(`ls ${router_state.moduleInformation.moduleDir}/${prefix}_* 2>/dev/null | xargs -n 1 basename | head -n1 | awk -F_ '{print $NF}'`);
8+
const { stdout: algo } = await exec(`su -c "ls ${router_state.moduleInformation.moduleDir}/${prefix}_* 2>/dev/null | xargs -n 1 basename | head -n1 | awk -F_ '{print $NF}'"`);
99
switch(prefix)
1010
{
1111
case "wlan":
@@ -58,7 +58,7 @@ const fetchAvailableAlgorithms = async (force = false) => {
5858
try {
5959
if(router_state.available_algorithms.length == 0 || force)
6060
{
61-
const { stdout: output } = await exec('cat /proc/sys/net/ipv4/tcp_available_congestion_control');
61+
const { stdout: output } = await exec('su -c cat /proc/sys/net/ipv4/tcp_available_congestion_control');
6262
if (output) {
6363
// Split by whitespace and convert each into an object
6464
router_state.available_algorithms = output.trim().split(/\s+/).map(algo => algo);
@@ -107,18 +107,18 @@ export async function initSettings() {
107107

108108
try
109109
{
110-
await exec(`rm -f ${router_state.moduleInformation.moduleDir}/wlan_*`);
111-
await exec(`rm -f ${router_state.moduleInformation.moduleDir}/rmnet_data_*`);
112-
await exec(`rm -f ${router_state.moduleInformation.moduleDir}/kill_connections`);
113-
await exec(`rm -f ${router_state.moduleInformation.moduleDir}/initcwnd_initrwnd`);
110+
await exec(`su -c rm -f ${router_state.moduleInformation.moduleDir}/wlan_*`);
111+
await exec(`su -c rm -f ${router_state.moduleInformation.moduleDir}/rmnet_data_*`);
112+
await exec(`su -c rm -f ${router_state.moduleInformation.moduleDir}/kill_connections`);
113+
await exec(`su -c rm -f ${router_state.moduleInformation.moduleDir}/initcwnd_initrwnd`);
114114

115-
await exec(`touch ${router_state.moduleInformation.moduleDir}/wlan_${settings.wifiAlgorithm} && chmod 644 ${router_state.moduleInformation.moduleDir}/wlan_${settings.wifiAlgorithm}`);
116-
await exec(`touch ${router_state.moduleInformation.moduleDir}/rmnet_data_${settings.cellularAlgorithm} && chmod 644 ${router_state.moduleInformation.moduleDir}/rmnet_data_${settings.cellularAlgorithm}`);
115+
await exec(`su -c touch ${router_state.moduleInformation.moduleDir}/wlan_${settings.wifiAlgorithm} && chmod 644 ${router_state.moduleInformation.moduleDir}/wlan_${settings.wifiAlgorithm}`);
116+
await exec(`su -c touch ${router_state.moduleInformation.moduleDir}/rmnet_data_${settings.cellularAlgorithm} && chmod 644 ${router_state.moduleInformation.moduleDir}/rmnet_data_${settings.cellularAlgorithm}`);
117117
if(settings.killOnChange)
118-
await exec(`touch ${router_state.moduleInformation.moduleDir}/kill_connections && chmod 644 ${router_state.moduleInformation.moduleDir}/kill_connections`);
118+
await exec(`su -c "touch ${router_state.moduleInformation.moduleDir}/kill_connections && chmod 644 ${router_state.moduleInformation.moduleDir}/kill_connections"`);
119119

120120
if(settings.setInitcwndInitrwndOnChange)
121-
await exec(`touch ${router_state.moduleInformation.moduleDir}/initcwnd_initrwnd && chmod 644 ${router_state.moduleInformation.moduleDir}/initcwnd_initrwnd`);
121+
await exec(`su -c "touch ${router_state.moduleInformation.moduleDir}/initcwnd_initrwnd && chmod 644 ${router_state.moduleInformation.moduleDir}/initcwnd_initrwnd"`);
122122

123123
console.log('Applied settings:', settings);
124124

@@ -146,7 +146,7 @@ export async function initSettings() {
146146
var res = await applySettings();
147147
if(res == 0)
148148
{
149-
const { errno: output } = await exec(`touch ${router_state.moduleInformation.moduleDir}/force_apply && chmod 644 ${router_state.moduleInformation.moduleDir}/force_apply`);
149+
const { errno: output } = await exec(`su -c "touch ${router_state.moduleInformation.moduleDir}/force_apply && chmod 644 ${router_state.moduleInformation.moduleDir}/force_apply"`);
150150
if(output == 0)
151151
toast("Wait for 5s to reflect changes!");
152152
}

0 commit comments

Comments
 (0)