Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget shortcut symlinks have the wrong $0 #90

Closed
mijofa opened this issue Oct 23, 2022 · 1 comment
Closed

Widget shortcut symlinks have the wrong $0 #90

mijofa opened this issue Oct 23, 2022 · 1 comment

Comments

@mijofa
Copy link

mijofa commented Oct 23, 2022

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

  1. Create a script at ~/.termux/foo which contents:
    #!/data/data/com.termux/files/usr/bin/bash
    echo "I've been run as $0"
    
  2. Symlink to it from ~/.shortcuts/bar
    ln -s ~/.termux/foo ~/.shortcuts/bar
    
  3. Refresh the shortcuts widget
  4. 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.

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Oct 24, 2022

Duplicate of #59

Damn, its been a year. Will be fixed in some changes I am gonna push soon for a new release.

@agnostic-apollo agnostic-apollo closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants