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

unable to open symlinks with relative paths #68

Closed
elgarfo opened this issue Jul 3, 2018 · 5 comments
Closed

unable to open symlinks with relative paths #68

elgarfo opened this issue Jul 3, 2018 · 5 comments
Labels

Comments

@elgarfo
Copy link

elgarfo commented Jul 3, 2018

cmdline: rmate -P 30698 /etc/apache2/sites-enabled/my.awesome.site-ssl.conf

actual result:

unable to cd to ../sites-available/my.awesome.site-ssl.conf directory
/usr/local/bin/rmate: line 300: /my.awesome.site-ssl.conf: No such file or directory
cat: /my.awesome.site-ssl.conf: No such file or directory

expected result:
rmate opening and sending the real file the symlink points to

additional info:
symlink points to "../sites-available/my.awesome.site-ssl.conf"

@elgarfo
Copy link
Author

elgarfo commented Jul 3, 2018

works for me (on debian 8):
adding "-f" to the command line switches for readlink (from the man pages: https://linux.die.net/man/1/readlink)

diff --git a/bin/rmate b/bin/rmate
index 7c04097..025b3b3 100755
--- a/bin/rmate
+++ b/bin/rmate
@@ -138,7 +138,7 @@ function canonicalize {
     local dir=$(dirpath "$filepath")
     
     if [ -L "$filepath" ]; then
-        relativepath=$(cd "$dir" || { echo "unable to cd to $dir" 1>&2; exit; } ; readlink "$(basename "$filepath")")
+        relativepath=$(cd "$dir" || { echo "unable to cd to $dir" 1>&2; exit; } ; readlink -f "$(basename "$filepath")")
         result=$(dirpath "$relativepath")/$(basename "$relativepath")
     else
         result=$(basename "$filepath")

@aurora
Copy link
Owner

aurora commented Jul 3, 2018

Hi, the problem is, that -f is not available on some systems (eg.: macOS). But i'll have a look into the issue.

@hadisfr
Copy link
Contributor

hadisfr commented Aug 15, 2018

Take a look at here and here please. Perhaps we can use uname or $OSTYPE to determine OS type (as mentioned here) and use readlink -f or realpath based on it.

@duzun
Copy link

duzun commented Aug 15, 2018

I've made a small C program and compile it when realpath is not available in the system, on first invocation.
Here is the realpath folder with the code.

@aurora aurora added the bug label Sep 3, 2018
aurora added a commit that referenced this issue Apr 8, 2019
@aurora
Copy link
Owner

aurora commented Apr 8, 2019

This is now fixed in master branch. Thanks all for suggestions and help.

@aurora aurora closed this as completed Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants