What's new

Strange behaviour of script "app_base_link.sh"

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Quadcore

Occasional Visitor
I am an owner of RT-AC86U router with last stable release of RMerlin (384.4.2).
I've an external USB3 HDD with two partitions, first one with NTFS fs, second one with EXT3 fs.
I've installed the Entware packages (32bit) with the newest script and I've installed the same packages I had with my previous router (RT-AC56U) - with my previous router I had firmware Tomato.
The strange behavior is whenever the USB HDD is mounted. Even if in Entware installation I've used commands "chmod" and "chown" to give the proper permissions to some folders/files, after EXT3 partition mounting I've discovered that ALL folders and files have cancelled all my previous "chmod/chown" commands.
This is caused by script "app_base_link.sh", placed in folder "/usr/sbin". This is the code that cancels all my previous "chmod/chown" commands on folders/files - lines 63-78:
Code:
APPS_MOUNTED_TYPE=`mount |grep "/dev/$APPS_DEV on " |awk '{print $5}'`
if [ "$APPS_MOUNTED_TYPE" != "vfat" ] && [ "$APPS_MOUNTED_TYPE" != "tfat" ]; then
    if [ "$APP_FS_TYPE" != "fuseblk" ] ; then
        chmod -R 777 $APPS_INSTALL_PATH
    fi
    user_account=`nvram get http_username`
    if [ -z "$user_account" ]; then
        user_account="admin"
    fi
    if [ "$APP_FS_TYPE" != "fuseblk" ] ; then
        chown -R "$user_account":root $APPS_INSTALL_PATH
    fi
    rm -rf $APP_LINK_DIR
    ln -sf $APPS_INSTALL_PATH $APP_LINK_DIR
    exit 0
fi
The issue is inside the "if" condition, the code uses "chmod -R 777" starting at root of the Entware's installation path. The same job is done with command "chown", using "admin:root" for all folders/files.
Logically the Entware partition is not of type "fuseblk", it is "ext3", so the "if" condition is always true.
I kindly ask to @RMerlin if it is possible to remove the two lines "chmod" and "chown", leaving the rest of the code, in order to keep the current "chmod/chown" status of all folders/files of Entware installation. Thanks.

Code is here "https://github.com/RMerl/asuswrt-me.../src/router/rom/apps_scripts/app_base_link.sh" and also on ASUSWRT gpl code "asuswrt\release\src\router\rom\apps_scripts".
 
I imagine the reason for this behaviour is because Asuswrt (perhaps unlike Tomato) is essentially a single-user OS. Everything is expected to be owned and run by the root (usually called "admin") account.

That's why there is no useradd, userdel, usermod, groupadd, groupdel, etc.
 
I kindly ask to @RMerlin if it is possible to remove the two lines "chmod" and "chown", leaving the rest of the code, in order to keep the current "chmod/chown" status of all folders/files of Entware installation.

Those scripts are used by Download Master, so I don't want to touch them. My advice if you need to customize your environment would be to uninstall Download Master, and setup Entware instead.
 
Those scripts are used by Download Master, so I don't want to touch them. My advice if you need to customize your environment would be to uninstall Download Master, and setup Entware instead.

This is the same code I've rewritten to solve my problem:

Code:
APPS_MOUNTED_TYPE=`mount |grep "/dev/$APPS_DEV on " |awk '{print $5}'`
if [ "$APPS_MOUNTED_TYPE" != "vfat" ] && [ "$APPS_MOUNTED_TYPE" != "tfat" ]; then
        user_account=`nvram get http_username`
        if [ -z "$user_account" ]; then
                user_account="admin"
        fi
        usbdisablechmod=`nvram get usbmount_disable_chmod`
        if [ -z "$usbdisablechmod" ]; then
                usbdisablechmod="0"
        fi
        if [ "$APP_FS_TYPE" != "fuseblk" ] ; then
           if [ "$usbdisablechmod" == "0" ]; then
        chmod -R 777 $APPS_INSTALL_PATH
        chown -R "$user_account":root $APPS_INSTALL_PATH
           fi
        fi
    rm -rf $APP_LINK_DIR
    ln -sf $APPS_INSTALL_PATH $APP_LINK_DIR
        exit 0
fi

Value of nvram key "usbmount_disable_chmod"

unset -> run as before
set == "0" -> run as before
set != "0" -> doesn't execute chmod/chown
 
Last edited:

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Top