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

Shortcuts that are symlinks are dereferenced #59

Open
Cigaes opened this issue Oct 5, 2021 · 3 comments
Open

Shortcuts that are symlinks are dereferenced #59

Cigaes opened this issue Oct 5, 2021 · 3 comments

Comments

@Cigaes
Copy link

Cigaes commented Oct 5, 2021

Problem description

When a shortcut is a symlink, it is shown it is own name in the list to create the widget, but then the actual shortcut uses the target of the symlink.

Steps to reproduce

  1. Create .shortcuts/host1 with basically ssh $0.
  2. ln -s host1 host2
  3. Browse to add a widget, select host2 in the list.
  4. Use the new widget.

Expected behavior

I would expect a widget named host2 that ssh me to host2. Instead, I get a widget named host1 that ssh me to host1.

Additional information

  • Termux application version: 0.117
  • Termux:Widget version: 0.13.0
  • Android OS version: 7.1.1

It used to work with Termux:Widget 0.12. I had to re-create all widgets after recently upgrading to 0.13.

@ghost
Copy link

ghost commented Oct 5, 2021

Intended behavior (canonical paths), please check the answer at #57 (comment).

@ghost ghost closed this as completed Oct 5, 2021
@Cigaes
Copy link
Author

Cigaes commented Oct 5, 2021

I have read the discussion for this issue and the ChangeLog for v0.13, and neither address the exact issue I am pointing. Are you sure this is not an unintentional change that is a side effect of an intentional one?

At the very least, the fact that the shortcut appears with its source name in the list but is created with the target name is inconsistent and misleading and needs to be fixed.

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Oct 5, 2021

Sorry, that's my fault. I forgot to add the symlink target patch even though it came in my mind. That is likely the issue. Will try fixing it soon.

https://github.com/termux/termux-app/blob/v0.117/app/src/main/java/com/termux/app/RunCommandService.java#L179

https://github.com/termux/termux-widget/blob/v0.13.0/app/src/main/java/com/termux/widget/TermuxWidgetProvider.java#L228

The name needs to be generated from absolute path too instead of canonical

https://github.com/termux/termux-widget/blob/v0.13.0/app/src/main/java/com/termux/widget/TermuxCreateShortcutActivity.java#L126

agnostic-apollo added a commit to fabian-thomas/termux-widget that referenced this issue Oct 29, 2022
…ctions to `ShortcutFile` and change shortcut path behaviour

The `ShortcutFile` will now store the path instead of the file object

This commit will also now pass absolute path of shortcuts when creating intents for shortcuts and widgets instead of canonical path. This will allow path expansion to be done during execution instead of at creation and if underlying symlink destination changes, new destination will be executed. There will still be a security check during execution to check if shortcut is under allowed directories. The shortcut label will now also be generated from absolute path instead of canonical path as mentioned in termux#59

Co-authored-by: Fabian Thomas <fabian@fabianthomas.de>
Co-authored-by: agnostic-apollo <agnosticapollo@gmail.com>
agnostic-apollo added a commit to fabian-thomas/termux-widget that referenced this issue Oct 30, 2022
…ctions to `ShortcutFile` and change shortcut path behaviour

The `ShortcutFile` will now store the path instead of the file object

This commit will also now pass absolute path of shortcuts when creating intents for shortcuts and widgets instead of canonical path. This will allow path expansion to be done during execution instead of at creation and if underlying symlink destination changes, new destination will be executed. There will still be a security check during execution to check if shortcut is under allowed directories. The shortcut label will now also be generated from absolute path instead of canonical path as mentioned in termux#59

Co-authored-by: Fabian Thomas <fabian@fabianthomas.de>
Co-authored-by: agnostic-apollo <agnosticapollo@gmail.com>
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