[SOLVED] bash not following symlinks relative to symlink location
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
bash not following symlinks relative to symlink location
it appears that bash is following this symlink relative to its current working directory rather than relative to the symlink location as the system normally does. has anyone seen this before? could some other error you know of be doing this? any idea what is really going on?
Code:
lt1a/phil/2 /home/phil 72> head /root/.go_setup/go
#!/bin/bash
#-------.-------.-------.-------.-------.-------.-------.-------.-------.-------
# start the console setup
#-------.-------.-------.-------.-------.-------.-------.-------.-------.-------
err(){ echo "$@" 1>&2;exit 1;}
u=$(exec whoami)
cd || err "failed to change to home directory for user '$u'"
#-------.-------.-------.-------.-------.-------.-------.-------.-------.-------
lt1a/phil/2 /home/phil 73> ls --full-time /root/.go_setup/go
lrwxrwxrwx 1 root root 10 2022-07-01 19:18:31.422185490 -0400 /root/.go_setup/go -> start.bash
lt1a/phil/2 /home/phil 74> ls --full-time /root/.go_setup/start.bash
-r--r--r-- 1 root root 4680 2022-07-01 19:23:24.849542960 -0400 /root/.go_setup/start.bash
lt1a/phil/2 /home/phil 75> sha256 /root/.go_setup/go /root/.go_setup/start.bash
efad88927727fa605263c3ae942a39ab5483698aa09c2290c4b50d5326a107e8 /root/.go_setup/go
efad88927727fa605263c3ae942a39ab5483698aa09c2290c4b50d5326a107e8 /root/.go_setup/start.bash
lt1a/phil/2 /home/phil 76> bash /root/.go_setup/go
/bin/bash: /root/start.bash: No such file or directory
lt1a/phil/2 /home/phil 77>
note: the bash script and symlink referring to it are in directory "/root/.go_setup" while this is being run by user "phil".
There are a LOT of questions that your post leaves unanswered. but I note that file is not writable by anyone, and belongs to root. I would not expect phil (or any other users) to be able to update that file. I suspect you will find folder permssion problems as well.
indeed the file is not writable by anyone other than root. the file will ultimately run a post-boot system setup that only root can do. think of it as a custom local init script. i may end up running it that way when finished. as for answering a LOT of questions, i can't even think of what those might be. once i know such a question, i will have a hint where to look for where the trouble might be. i would think that if bash even tries to do its own symlink following, there would be major issues all over, so i am certain it has to be my mistake. but when it looks like something else on the face of the results, that's what makes finding the problem so hard to start.
By any chance does that script reference itself, perhaps by some manipulation of "$0"? Try adding a "set -x" as the second line of the script and see if it starts to run at all.
it is not finished, yet. it will be doing my personal customized setup, like multiple users and starting various workspaces and windows in each user. once it is finished running, i just start using my laptop. i don't need to go around clicking on stuff to start things (like clocks) that i normally leave running continuously.
i already have a setup script. V1 is too disorded. V2 is to be a cleaner rewrite.
it appears that bash is following this symlink relative to its current working directory rather than relative to the symlink location as the system normally does. has anyone seen this before? could some other error you know of be doing this? any idea what is really going on?
Code:
lt1a/phil/2 /home/phil 73> ls /root/.go_setup/go
lrwxrwxrwx 1 root root 10 /root/.go_setup/go -> start.bash
lt1a/phil/2 /home/phil 74> ls /root/.go_setup/start.bash
-r--r--r-- 1 root root 4680 /root/.go_setup/start.bash
lt1a/phil/2 /home/phil 76> bash /root/.go_setup/go
/bin/bash: /root/start.bash: No such file or directory
lt1a/phil/2 /home/phil 77>
Your post is extremely noisy, contains a lot of completely irrelevant info. That make it really hard to follow.
From the other hand this information is not enough to answer, the solution may depend on the content of those files.
You may try to use: bash -xv /root/.go_setup/go to see what's going on.
i found the problem in my own code. there was a place the path was missing from in the script that was being run by bash. the sequence of messages looked like it came from bash. well, it did; another instance of bash. there was no output between bash runs so messages could not be distinguished.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.