You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem description
Widget shortcuts which are symlinks to a file in ~/.termux/ have $0 set to the symlink destination path under ~/.termux/ where $0 should really be the symlink itself.
I copied ssh-argv0 into ~/.termux/ssh-argv0, then symlinked to it from ~/.shortcuts/desktop and ~/.shortcuts/server expecting to then hit the button and SSH directly to my desktop/server accordingly, but instead I get the "This script should not be run like this, see ssh-argv0(1) for details" error that is expected when run directly as ssh-argv0.
This, to me, is a clear & useful usecase for doing so as I don't really want to have to create separate wrapper scripts for each system I want to SSH in to, which is my main use for that widget anyway.
Steps to reproduce
Create a script at ~/.termux/foo which contents:
#!/data/data/com.termux/files/usr/bin/bash
echo "I've been run as $0"
Symlink to it from ~/.shortcuts/bar
ln -s ~/.termux/foo ~/.shortcuts/bar
Refresh the shortcuts widget
Launch bar from the shortcuts widget
The newly opened terminal should then say "I've been run as foo"
It should say "I've been run as bar"
An alternate $TERMUX_WIDGET_ARGV0 or similar would be acceptable to me, but I don't imagine any security issues with using $0 correctly.
Additional information
Termux application version: 0.118.0
Termux:Widget application version: 0.13.0
Android OS version: 12
LineageOS version: 19-20221015-NIGHTLY-alioth
Device model: Xiaomi POCO F3 "alioth" M2012K11AG
My findings
I suspect this could be "fixed" by removing .getAbsolutePath() from TermuxWidgetService.java#L59 but I'm not at all familiar with Java/Dalvik and/or Android coding so am not at all confident in making or testing that change myself.
I don't imagine this would bring in any security vulnerabilities as it will continue to check the absolute path of the symlink before displaying it in the widget.
Theoretically there could be an issue if the symlink is updated and someone hits the widget button before the widget is refreshed, but that's already an issue anyway since the symlink's destination script could be updated in the same way.
The text was updated successfully, but these errors were encountered:
Problem description
Widget shortcuts which are symlinks to a file in ~/.termux/ have $0 set to the symlink destination path under ~/.termux/ where $0 should really be the symlink itself.
I copied ssh-argv0 into
~/.termux/ssh-argv0
, then symlinked to it from~/.shortcuts/desktop
and~/.shortcuts/server
expecting to then hit the button and SSH directly to my desktop/server accordingly, but instead I get the "This script should not be run like this, see ssh-argv0(1) for details" error that is expected when run directly asssh-argv0
.This, to me, is a clear & useful usecase for doing so as I don't really want to have to create separate wrapper scripts for each system I want to SSH in to, which is my main use for that widget anyway.
Steps to reproduce
~/.termux/foo
which contents:~/.shortcuts/bar
bar
from the shortcuts widgetAn alternate
$TERMUX_WIDGET_ARGV0
or similar would be acceptable to me, but I don't imagine any security issues with using $0 correctly.Additional information
My findings
I suspect this could be "fixed" by removing
.getAbsolutePath()
from TermuxWidgetService.java#L59 but I'm not at all familiar with Java/Dalvik and/or Android coding so am not at all confident in making or testing that change myself.I don't imagine this would bring in any security vulnerabilities as it will continue to check the absolute path of the symlink before displaying it in the widget.
Theoretically there could be an issue if the symlink is updated and someone hits the widget button before the widget is refreshed, but that's already an issue anyway since the symlink's destination script could be updated in the same way.
The text was updated successfully, but these errors were encountered: