Bug 674108

Summary: autojump don't work well with root user
Product: [Fedora] Fedora Reporter: Sergio Basto <sergio>
Component: autojumpAssignee: Thibault North <thibault.north>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 14CC: joelthelion, thibault.north
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-30 19:44:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Sergio Basto 2011-01-31 17:00:38 UTC
Description of problem:
when I do su - 
and work as root , configuring servers, services etc  
autojump don't keep many paths  

Version-Release number of selected component (if applicable):
autojump-14-2.fc14.noarch

How reproducible:
su - 

cd /etc/httpd/
jumpstat

2.0:    /root/rpmbuild
11.0:   /root/rpmbuild/SPECS

doesn't appear /etc/httpd/
  
Actual results:
doesn't appear /etc/httpd/

Expected results:
should appear

Additional info:
great tool autojump tks!

Comment 1 Thibault North 2011-01-31 17:33:24 UTC
Hi,
Thanks for your report.

Have you actually run autojump ? Without that, it will not store your paths. Its history is user-dependant, and using "su -" will identify you as root.

Try:
su -
autojump


cd /etc/httpd/
jumpstat

It will appear in the list.

Comment 2 Sergio Basto 2011-01-31 19:13:00 UTC
no,

su -
root@segulix:~#autojump
/root/rpmbuild/SPECS
root@segulix:~#cd /etc/httpd/
root@segulix:/etc/httpd13#jumpstat 
2.0:    /root/rpmbuild
11.0:   /root/rpmbuild/SPECS
Total key weight: 13. Number of stored paths: 2

Comment 3 Sergio Basto 2011-03-13 06:50:20 UTC
continue ...

If I do cd on a screen, the paths are saved and showed by jumpstat (autojump works)
for example:
screen
cd /etc/httpd
jumpstat
1.0:    /etc/httpd
(...)
exit 
(exit the screen)
jumpstat
1.0:    /etc/httpd 
(still there !)
but cd to elsewhere is not saved in jumpstat
(as root) 
cd /var/lib/mysql/
jumpstat 
no mysql appears

Comment 4 Joël Schaerer 2011-03-13 22:18:37 UTC
(autojump author here)

Hi Sergio,

First, a little background:

Autojump works on a per-user basis, and the root user is not the same user as you. Therefore, the root user and your user have different databases. Also, if you want autojump to work properly as root, you need to source the autojump files in the root's bashrc as well.

With the symptoms you're describing, my guess would be that the autojump files are not properly sourced when you do "su -", but get sourced when you run screen. Does your /root/.bashrc source /etc/profile?

It would also be useful if you could post the output of the `env` command after you issue the "su -" command.

I hope we can fix this together!

Comment 5 Sergio Basto 2011-03-14 00:08:53 UTC
Hi, thanks for support , I found the problem but not the solution ,
After "su - " 
env | grep PROM
PROMPT_COMMAND=printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"

while all others cases : 
env | grep PROM
PROMPT_COMMAND=echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007" ; { [[ "$AUTOJUMP_HOME" == "$HOME" ]] && (autojump -a "$(pwd -P)"&)>/dev/null 2>>${AUTOJUMP_DATA_DIR}/autojump_errors;} 2>/dev/null

if I do as root: 
export PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; $AUTOJUMP"

I fix the autojump, seems something change PROMPT_COMMAND after run /etc/profile.d/autojump.bash 

I will investigate .. , yes I have I own PROMPT_COMMAND !

Thanks, at least now, I know how workaround the problem.

Comment 6 Joël Schaerer 2011-03-14 09:20:09 UTC
There you go! Autojump is careful not to overwrite your PROMPT_COMMAND, you have to be careful not to overwrite autojump's :)

Comment 7 Sergio Basto 2011-04-30 02:12:10 UTC
(In reply to comment #6)
> There you go! Autojump is careful not to overwrite your PROMPT_COMMAND, you
> have to be careful not to overwrite autojump's :)

but if I clean my custom PROMPT_COMMAND , the issue still exist !

are you sure 
after su - 

echo $PROMPT_COMMAND  

autojump stuff doesn't disappears ?  

in kde , with a konsole ? 

anyway, as work around I add after my custom prompt :
export PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; $AUTOJUMP"

Comment 8 Joël Schaerer 2011-04-30 14:06:55 UTC
I think you need to source /etc/profile.d/autojump.bash in /root/.bashrc.

Root and your users are two separate users, and as such, you have to install autojump for both. Does that make sense to you?

Comment 9 Sergio Basto 2011-04-30 19:44:22 UTC
Hi, 
this bug is fixed with commit on setup package ( now is setup-2.8.28-1.fc14.noarch ) 

http://git.fedorahosted.org/git/?p=setup.git;a=commit;h=3f59843e8a1ccf06859e3948ae78026032ed0464 

http://git.fedorahosted.org/git/?p=setup.git;a=blobdiff;f=bashrc;h=4a4ab1932fd4123211f87713f7673070312e9f01;hp=1d0dc1b44223d28662627e333baa47a663c70603;hb=3f59843e8a1ccf06859e3948ae78026032ed0464;hpb=742af4c8a96467bf37c58357f0aa70e93faaafb6

so this is a dup of 
https://bugzilla.redhat.com/show_bug.cgi?id=691425


if you do a su - , with any user with the code before April 12,  $PROMPT_COMMAND will be override , and autojump will not work correctly .

*** This bug has been marked as a duplicate of bug 691425 ***