Open frederickjh opened 6 years ago
I just took another look at this as I am back working on that jail shell. Turns out that z.sh did not have the excutable permission set. Running:
chmod +x path/to/z.sh
set it and now z works.
It stopped working. Not sure why as the binary is still set to be executable.
I have added the suggested code to my .bashrc
. I added an echo
line at the top of the z.sh
file to make sure it was being source. When I ssh into the computer I see the echo statement text so I see that it is source once upon login.
making z.sh executable is not the way to go. it is never executed, only sourced.
i dunno cpanel internals, my hunch is that jailedshell has some path hijinks and the default value of $_Z_DATA
(~/.z
) might not be acceptable
I don't use a jailshell in my cPanel accounts, but I have had trouble getting straight bash
to work because cPanel's VirtFS does something funny to prevent process substitution from working. I've got a fork of z
that just avoids process substitution (thus). You might download it and see if that's your underlying problem: agkozak/z
@rupa I though that might be the issue too, however I set $_Z_DATA and that didn't make a difference.
_Z_DATA="/home/username/.z-data
I think it has something to do with sourcing it from the .bashrc
. If I source it from the command line after sshing into the server using the same command that is in the .bashrc
, then it works correctly.
@agkozak Thanks for your post, however after trying your fork the results are the same, so I do not think that is the issue.
To be clear here the source in .bashrc
does work to allow jumping with z. It does not record any information about the directories that move to until I source z.sh
directly from the command line.
Here an example run directly after login. Notice how cding into public_html does not add it to z's list at first, but after sourcing z.sh
from the command line it does.
[Thu Mar 07 10:28:24 username@server1234:~ $ z -l
4 /home/username/bin
8 /home/username/example.com
8 /home/username/example.org
8 /home/username/perl5
16 /home/username/example.info
76 /home/username/bin/z
[Thu Mar 07 10:28:26 username@server1234:~ $ cd public_html/
[Thu Mar 07 10:28:31 username@server1234:~/public_html $ z -l
4 /home/username/bin
8 /home/username/example.com
8 /home/username/example.org
8 /home/username/perl5
16 /home/username/example.info
76 /home/username/bin/z
[Thu Mar 07 10:28:34 username@server1234:~/public_html $ cd
[Thu Mar 07 10:33:04 username@server1234:~ $ source bin/z/z.sh
[Thu Mar 07 10:33:17 username@server1234:~ $ z -l
4 /home/username/bin
8 /home/username/example.com
8 /home/username/example.org
8 /home/username/perl5
16 /home/username/example.info
76 /home/username/bin/z
[Thu Mar 07 10:33:23 username@server1234:~ $ cd public_html/
[Thu Mar 07 10:33:44 username@server1234:~/public_html $ z -l
4 /home/username/bin
4 /home/username/public_html
8 /home/username/example.com
8 /home/username/example.org
8 /home/username/perl5
16 /home/username/example.info
76 /home/username/bin/z
[Thu Mar 07 10:33:46 username@server1234:~/public_html $
Loging out and back in we see that jumping with z works, but the list does not change.
[Thu Mar 07 10:44:15 username@server1234:~ $ z -l
4 /home/username/bin
4 /home/username/example.org
8 /home/username/example.com
8 /home/username/perl5
8 /home/username/public_html
16 /home/username/example.info
76 /home/username/bin/z
[Thu Mar 07 10:44:16 username@server1234:~ $ z public
[Thu Mar 07 10:44:31 username@server1234:~/public_html $ z bin
[Thu Mar 07 10:44:46 username@server1234:~/bin $ z perl
[Thu Mar 07 10:44:51 username@server1234:~/perl5 $ z bin
[Thu Mar 07 10:45:01 username@server1234:~/bin $ z -l
4 /home/username/bin
4 /home/username/example.org
8 /home/username/example.com
8 /home/username/perl5
8 /home/username/public_html
16 /home/username/example.info
76 /home/username/bin/z
[Thu Mar 07 10:49:16 username@server1234:~/bin $
I just figured out a solution to this. Not sure if the code can be change to fix this but this should be noted in the documentation if it is not possible to do something in code.
I figured out that the ~/.bashrc
file in Cpanel is sourced by ~/.bash_profile
.
~/.bash_profile
:# Get the aliases and functions
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
I was adding the line from the installation instructions to source z.sh
in .bashrc
. So .bash_profile
was sourcing .bashrc
which was sourcing z.sh
. The chain sourcing seems to be the issue as when I remove the sourcing from .bashrc
and added it to .bash_profile
and now z works correctly.
~/.bash_profile
# Load z so we can jump around. See https://github.com/rupa/z for more details.
if [ -f $HOME/bin/z/z.sh ]; then
source $HOME/bin/z/z.sh
fi
It appears that ~/.bash_profile
sourcing ~/.bashrc
file in Cpanel and else where seems to be standard practice, so maybe sourcing in .bashrc
via .bash_profile
is an effect of the jailedshell.
In any case, if this is something the code cannot get around please add this to the documentation. Thanks for your help with this!
Hi! In a jailedshell the ~/.z file is never created. If I create it no directories are ever added. I have used the same installation method on non-jailedshells and it works.
The jailed shells are created by CPanel, VirtFS - Jailed Shell.
Thanks for looking into this! Frederick