`$XAUTHORITY` appears from 'nowhere' on su+tmux











up vote
4
down vote

favorite
1












When I switched from su+bash to su+tmux+zsh I noticed that I get the $XAUTHORITY variable defined as /root/.xauthXXXXXX where XXXXXX are 6 random alphanumeric characters. With the previous configuration, X worked with root flawlessly, but now I need to copy ~username/.Xauthority to $XAUTHORITY.



The variable is defined nowhere; I checked .zshrc, /etc/profile*, /etc/profile.d/* etc.



# env
TERM=screen
SHELL=/usr/bin/tmux
USER=toor
TMUX=/tmp//tmux-0/default,6495,3
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PWD=/root
SHLVL=2
HOME=/root
LOGNAME=toor
DISPLAY=:0.0
XAUTHORITY=/root/.xauthUSzLl4
COLORTERM=gnome-terminal
_=/bin/env
OLDPWD=/root
EDITOR=vim
vcs_info_msg_0_=
vcs_info_msg_1_=

% echo $XAUTHORITY
/home/mpiechotka/.Xauthority
% su
password:
# echo $XAUTHORITY
/root/.xauthUSzLl4
# ls $XAUTHORITY
ls: cannot access /root/.xauthUSzLl4: No such file or directory
# cat .tmux.conf
set -g default-command /bin/zsh
set -g default-shell /bin/zsh


su is aliased to su - toor and it opens tmux as shell. toor is an alias of root with different shell.



I just discovered that it appears on normal su as well. It did not do that some time ago.



set-environment did not work.



xhost +localhost did not work, but xhost + (disabling all control) DID work.










share|improve this question
























  • Could you be more specific about when you are executing what?
    – gvkv
    Sep 20 '10 at 20:42










  • It's too bad my theory didn't pan out but if you fix it, please post your solution.
    – gvkv
    Sep 22 '10 at 2:50










  • @Gilles: No. I didn't.
    – Maciej Piechotka
    Jan 18 '11 at 19:55















up vote
4
down vote

favorite
1












When I switched from su+bash to su+tmux+zsh I noticed that I get the $XAUTHORITY variable defined as /root/.xauthXXXXXX where XXXXXX are 6 random alphanumeric characters. With the previous configuration, X worked with root flawlessly, but now I need to copy ~username/.Xauthority to $XAUTHORITY.



The variable is defined nowhere; I checked .zshrc, /etc/profile*, /etc/profile.d/* etc.



# env
TERM=screen
SHELL=/usr/bin/tmux
USER=toor
TMUX=/tmp//tmux-0/default,6495,3
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PWD=/root
SHLVL=2
HOME=/root
LOGNAME=toor
DISPLAY=:0.0
XAUTHORITY=/root/.xauthUSzLl4
COLORTERM=gnome-terminal
_=/bin/env
OLDPWD=/root
EDITOR=vim
vcs_info_msg_0_=
vcs_info_msg_1_=

% echo $XAUTHORITY
/home/mpiechotka/.Xauthority
% su
password:
# echo $XAUTHORITY
/root/.xauthUSzLl4
# ls $XAUTHORITY
ls: cannot access /root/.xauthUSzLl4: No such file or directory
# cat .tmux.conf
set -g default-command /bin/zsh
set -g default-shell /bin/zsh


su is aliased to su - toor and it opens tmux as shell. toor is an alias of root with different shell.



I just discovered that it appears on normal su as well. It did not do that some time ago.



set-environment did not work.



xhost +localhost did not work, but xhost + (disabling all control) DID work.










share|improve this question
























  • Could you be more specific about when you are executing what?
    – gvkv
    Sep 20 '10 at 20:42










  • It's too bad my theory didn't pan out but if you fix it, please post your solution.
    – gvkv
    Sep 22 '10 at 2:50










  • @Gilles: No. I didn't.
    – Maciej Piechotka
    Jan 18 '11 at 19:55













up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





When I switched from su+bash to su+tmux+zsh I noticed that I get the $XAUTHORITY variable defined as /root/.xauthXXXXXX where XXXXXX are 6 random alphanumeric characters. With the previous configuration, X worked with root flawlessly, but now I need to copy ~username/.Xauthority to $XAUTHORITY.



The variable is defined nowhere; I checked .zshrc, /etc/profile*, /etc/profile.d/* etc.



# env
TERM=screen
SHELL=/usr/bin/tmux
USER=toor
TMUX=/tmp//tmux-0/default,6495,3
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PWD=/root
SHLVL=2
HOME=/root
LOGNAME=toor
DISPLAY=:0.0
XAUTHORITY=/root/.xauthUSzLl4
COLORTERM=gnome-terminal
_=/bin/env
OLDPWD=/root
EDITOR=vim
vcs_info_msg_0_=
vcs_info_msg_1_=

% echo $XAUTHORITY
/home/mpiechotka/.Xauthority
% su
password:
# echo $XAUTHORITY
/root/.xauthUSzLl4
# ls $XAUTHORITY
ls: cannot access /root/.xauthUSzLl4: No such file or directory
# cat .tmux.conf
set -g default-command /bin/zsh
set -g default-shell /bin/zsh


su is aliased to su - toor and it opens tmux as shell. toor is an alias of root with different shell.



I just discovered that it appears on normal su as well. It did not do that some time ago.



set-environment did not work.



xhost +localhost did not work, but xhost + (disabling all control) DID work.










share|improve this question















When I switched from su+bash to su+tmux+zsh I noticed that I get the $XAUTHORITY variable defined as /root/.xauthXXXXXX where XXXXXX are 6 random alphanumeric characters. With the previous configuration, X worked with root flawlessly, but now I need to copy ~username/.Xauthority to $XAUTHORITY.



The variable is defined nowhere; I checked .zshrc, /etc/profile*, /etc/profile.d/* etc.



# env
TERM=screen
SHELL=/usr/bin/tmux
USER=toor
TMUX=/tmp//tmux-0/default,6495,3
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PWD=/root
SHLVL=2
HOME=/root
LOGNAME=toor
DISPLAY=:0.0
XAUTHORITY=/root/.xauthUSzLl4
COLORTERM=gnome-terminal
_=/bin/env
OLDPWD=/root
EDITOR=vim
vcs_info_msg_0_=
vcs_info_msg_1_=

% echo $XAUTHORITY
/home/mpiechotka/.Xauthority
% su
password:
# echo $XAUTHORITY
/root/.xauthUSzLl4
# ls $XAUTHORITY
ls: cannot access /root/.xauthUSzLl4: No such file or directory
# cat .tmux.conf
set -g default-command /bin/zsh
set -g default-shell /bin/zsh


su is aliased to su - toor and it opens tmux as shell. toor is an alias of root with different shell.



I just discovered that it appears on normal su as well. It did not do that some time ago.



set-environment did not work.



xhost +localhost did not work, but xhost + (disabling all control) DID work.







shell login tmux variable su






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Rui F Ribeiro

38.2k1475123




38.2k1475123










asked Sep 20 '10 at 13:13









Maciej Piechotka

11.1k64276




11.1k64276












  • Could you be more specific about when you are executing what?
    – gvkv
    Sep 20 '10 at 20:42










  • It's too bad my theory didn't pan out but if you fix it, please post your solution.
    – gvkv
    Sep 22 '10 at 2:50










  • @Gilles: No. I didn't.
    – Maciej Piechotka
    Jan 18 '11 at 19:55


















  • Could you be more specific about when you are executing what?
    – gvkv
    Sep 20 '10 at 20:42










  • It's too bad my theory didn't pan out but if you fix it, please post your solution.
    – gvkv
    Sep 22 '10 at 2:50










  • @Gilles: No. I didn't.
    – Maciej Piechotka
    Jan 18 '11 at 19:55
















Could you be more specific about when you are executing what?
– gvkv
Sep 20 '10 at 20:42




Could you be more specific about when you are executing what?
– gvkv
Sep 20 '10 at 20:42












It's too bad my theory didn't pan out but if you fix it, please post your solution.
– gvkv
Sep 22 '10 at 2:50




It's too bad my theory didn't pan out but if you fix it, please post your solution.
– gvkv
Sep 22 '10 at 2:50












@Gilles: No. I didn't.
– Maciej Piechotka
Jan 18 '11 at 19:55




@Gilles: No. I didn't.
– Maciej Piechotka
Jan 18 '11 at 19:55










3 Answers
3






active

oldest

votes

















up vote
1
down vote













Here's what I think is happening.



When you're using su and bash, the su-session inherits the environment with the exception of USER, HOME and SHELL, thus XAUTHORITY still points to ~username/.Xauthority and everything is fine. However (from the man page), when the tmux server is started:




... tmux copies the environment into the global
environment; in addition, each session has a session environment. When a
window is created, the session and global environments are merged with
the session environment overriding any variable present in both.




and I suspect (without knowing invocation details) that when you switch credentials, su tries to find .Xauthority in /root and since it can't find one when you need to run an X app, it creates one. I can think of a couple ways you can try to fix this:




  1. Invoke su by using su -. This will copy over the real user's evironment

  2. Add set-environment <name> <value> to your tmux config.


Unfortunately, I can't test this since I recently switched over to i3 (which is awesome) and I don't have a spare machine.






share|improve this answer























  • Except that I'm invoking su by su -. Also echo "$XAUTHORITY" shows there is no ~. I'll try set-enviroment.
    – Maciej Piechotka
    Sep 20 '10 at 21:47










  • Actually I meant ~ as a shorthand to (what I presumed) was your home directory. I've edited.
    – gvkv
    Sep 20 '10 at 23:26






  • 1




    no, i3 is i3, awesome is awesome =P .
    – Kent Fredric
    Feb 15 '11 at 9:40


















up vote
0
down vote













This could be due to a misconfigured pam_xauth PAM module. It is supposed to copy your keys to a temporary file when you run su. The behavior you describe is consistent with pam_xauth creating the temporary file but somehow not copying the keys (perhaps because you have a ~/.xauth/export or a /root/.xauth/import).






share|improve this answer





















  • I don't have neither of those but xauth is loaded in su session (i.e. it is in /etc/pam.d/su).
    – Maciej Piechotka
    Nov 18 '10 at 0:19


















up vote
0
down vote













It happened to me but this time with $COLORTERM variable.



If you start tmux on a terminal emulator that has, for instance, COLORTERM=terminus and after that you start another tmux session even on another terminal client that normally would have COLORTERM=gnome-terminal, this new session will crossover and inherit COLORTERM=terminus.



These assertions are enough to conclude that, unfortunately, tmux sessions are not isolated from each other, even if you're using different terminal emulators.



Your su sub shell is probably inheriting $XAUTHORITY from another tmux session, more specifically the very first tmux session created.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f2269%2fxauthority-appears-from-nowhere-on-sutmux%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Here's what I think is happening.



    When you're using su and bash, the su-session inherits the environment with the exception of USER, HOME and SHELL, thus XAUTHORITY still points to ~username/.Xauthority and everything is fine. However (from the man page), when the tmux server is started:




    ... tmux copies the environment into the global
    environment; in addition, each session has a session environment. When a
    window is created, the session and global environments are merged with
    the session environment overriding any variable present in both.




    and I suspect (without knowing invocation details) that when you switch credentials, su tries to find .Xauthority in /root and since it can't find one when you need to run an X app, it creates one. I can think of a couple ways you can try to fix this:




    1. Invoke su by using su -. This will copy over the real user's evironment

    2. Add set-environment <name> <value> to your tmux config.


    Unfortunately, I can't test this since I recently switched over to i3 (which is awesome) and I don't have a spare machine.






    share|improve this answer























    • Except that I'm invoking su by su -. Also echo "$XAUTHORITY" shows there is no ~. I'll try set-enviroment.
      – Maciej Piechotka
      Sep 20 '10 at 21:47










    • Actually I meant ~ as a shorthand to (what I presumed) was your home directory. I've edited.
      – gvkv
      Sep 20 '10 at 23:26






    • 1




      no, i3 is i3, awesome is awesome =P .
      – Kent Fredric
      Feb 15 '11 at 9:40















    up vote
    1
    down vote













    Here's what I think is happening.



    When you're using su and bash, the su-session inherits the environment with the exception of USER, HOME and SHELL, thus XAUTHORITY still points to ~username/.Xauthority and everything is fine. However (from the man page), when the tmux server is started:




    ... tmux copies the environment into the global
    environment; in addition, each session has a session environment. When a
    window is created, the session and global environments are merged with
    the session environment overriding any variable present in both.




    and I suspect (without knowing invocation details) that when you switch credentials, su tries to find .Xauthority in /root and since it can't find one when you need to run an X app, it creates one. I can think of a couple ways you can try to fix this:




    1. Invoke su by using su -. This will copy over the real user's evironment

    2. Add set-environment <name> <value> to your tmux config.


    Unfortunately, I can't test this since I recently switched over to i3 (which is awesome) and I don't have a spare machine.






    share|improve this answer























    • Except that I'm invoking su by su -. Also echo "$XAUTHORITY" shows there is no ~. I'll try set-enviroment.
      – Maciej Piechotka
      Sep 20 '10 at 21:47










    • Actually I meant ~ as a shorthand to (what I presumed) was your home directory. I've edited.
      – gvkv
      Sep 20 '10 at 23:26






    • 1




      no, i3 is i3, awesome is awesome =P .
      – Kent Fredric
      Feb 15 '11 at 9:40













    up vote
    1
    down vote










    up vote
    1
    down vote









    Here's what I think is happening.



    When you're using su and bash, the su-session inherits the environment with the exception of USER, HOME and SHELL, thus XAUTHORITY still points to ~username/.Xauthority and everything is fine. However (from the man page), when the tmux server is started:




    ... tmux copies the environment into the global
    environment; in addition, each session has a session environment. When a
    window is created, the session and global environments are merged with
    the session environment overriding any variable present in both.




    and I suspect (without knowing invocation details) that when you switch credentials, su tries to find .Xauthority in /root and since it can't find one when you need to run an X app, it creates one. I can think of a couple ways you can try to fix this:




    1. Invoke su by using su -. This will copy over the real user's evironment

    2. Add set-environment <name> <value> to your tmux config.


    Unfortunately, I can't test this since I recently switched over to i3 (which is awesome) and I don't have a spare machine.






    share|improve this answer














    Here's what I think is happening.



    When you're using su and bash, the su-session inherits the environment with the exception of USER, HOME and SHELL, thus XAUTHORITY still points to ~username/.Xauthority and everything is fine. However (from the man page), when the tmux server is started:




    ... tmux copies the environment into the global
    environment; in addition, each session has a session environment. When a
    window is created, the session and global environments are merged with
    the session environment overriding any variable present in both.




    and I suspect (without knowing invocation details) that when you switch credentials, su tries to find .Xauthority in /root and since it can't find one when you need to run an X app, it creates one. I can think of a couple ways you can try to fix this:




    1. Invoke su by using su -. This will copy over the real user's evironment

    2. Add set-environment <name> <value> to your tmux config.


    Unfortunately, I can't test this since I recently switched over to i3 (which is awesome) and I don't have a spare machine.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 20 '10 at 23:27

























    answered Sep 20 '10 at 21:42









    gvkv

    2,2851816




    2,2851816












    • Except that I'm invoking su by su -. Also echo "$XAUTHORITY" shows there is no ~. I'll try set-enviroment.
      – Maciej Piechotka
      Sep 20 '10 at 21:47










    • Actually I meant ~ as a shorthand to (what I presumed) was your home directory. I've edited.
      – gvkv
      Sep 20 '10 at 23:26






    • 1




      no, i3 is i3, awesome is awesome =P .
      – Kent Fredric
      Feb 15 '11 at 9:40


















    • Except that I'm invoking su by su -. Also echo "$XAUTHORITY" shows there is no ~. I'll try set-enviroment.
      – Maciej Piechotka
      Sep 20 '10 at 21:47










    • Actually I meant ~ as a shorthand to (what I presumed) was your home directory. I've edited.
      – gvkv
      Sep 20 '10 at 23:26






    • 1




      no, i3 is i3, awesome is awesome =P .
      – Kent Fredric
      Feb 15 '11 at 9:40
















    Except that I'm invoking su by su -. Also echo "$XAUTHORITY" shows there is no ~. I'll try set-enviroment.
    – Maciej Piechotka
    Sep 20 '10 at 21:47




    Except that I'm invoking su by su -. Also echo "$XAUTHORITY" shows there is no ~. I'll try set-enviroment.
    – Maciej Piechotka
    Sep 20 '10 at 21:47












    Actually I meant ~ as a shorthand to (what I presumed) was your home directory. I've edited.
    – gvkv
    Sep 20 '10 at 23:26




    Actually I meant ~ as a shorthand to (what I presumed) was your home directory. I've edited.
    – gvkv
    Sep 20 '10 at 23:26




    1




    1




    no, i3 is i3, awesome is awesome =P .
    – Kent Fredric
    Feb 15 '11 at 9:40




    no, i3 is i3, awesome is awesome =P .
    – Kent Fredric
    Feb 15 '11 at 9:40












    up vote
    0
    down vote













    This could be due to a misconfigured pam_xauth PAM module. It is supposed to copy your keys to a temporary file when you run su. The behavior you describe is consistent with pam_xauth creating the temporary file but somehow not copying the keys (perhaps because you have a ~/.xauth/export or a /root/.xauth/import).






    share|improve this answer





















    • I don't have neither of those but xauth is loaded in su session (i.e. it is in /etc/pam.d/su).
      – Maciej Piechotka
      Nov 18 '10 at 0:19















    up vote
    0
    down vote













    This could be due to a misconfigured pam_xauth PAM module. It is supposed to copy your keys to a temporary file when you run su. The behavior you describe is consistent with pam_xauth creating the temporary file but somehow not copying the keys (perhaps because you have a ~/.xauth/export or a /root/.xauth/import).






    share|improve this answer





















    • I don't have neither of those but xauth is loaded in su session (i.e. it is in /etc/pam.d/su).
      – Maciej Piechotka
      Nov 18 '10 at 0:19













    up vote
    0
    down vote










    up vote
    0
    down vote









    This could be due to a misconfigured pam_xauth PAM module. It is supposed to copy your keys to a temporary file when you run su. The behavior you describe is consistent with pam_xauth creating the temporary file but somehow not copying the keys (perhaps because you have a ~/.xauth/export or a /root/.xauth/import).






    share|improve this answer












    This could be due to a misconfigured pam_xauth PAM module. It is supposed to copy your keys to a temporary file when you run su. The behavior you describe is consistent with pam_xauth creating the temporary file but somehow not copying the keys (perhaps because you have a ~/.xauth/export or a /root/.xauth/import).







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 17 '10 at 23:06









    Gilles

    521k12610401570




    521k12610401570












    • I don't have neither of those but xauth is loaded in su session (i.e. it is in /etc/pam.d/su).
      – Maciej Piechotka
      Nov 18 '10 at 0:19


















    • I don't have neither of those but xauth is loaded in su session (i.e. it is in /etc/pam.d/su).
      – Maciej Piechotka
      Nov 18 '10 at 0:19
















    I don't have neither of those but xauth is loaded in su session (i.e. it is in /etc/pam.d/su).
    – Maciej Piechotka
    Nov 18 '10 at 0:19




    I don't have neither of those but xauth is loaded in su session (i.e. it is in /etc/pam.d/su).
    – Maciej Piechotka
    Nov 18 '10 at 0:19










    up vote
    0
    down vote













    It happened to me but this time with $COLORTERM variable.



    If you start tmux on a terminal emulator that has, for instance, COLORTERM=terminus and after that you start another tmux session even on another terminal client that normally would have COLORTERM=gnome-terminal, this new session will crossover and inherit COLORTERM=terminus.



    These assertions are enough to conclude that, unfortunately, tmux sessions are not isolated from each other, even if you're using different terminal emulators.



    Your su sub shell is probably inheriting $XAUTHORITY from another tmux session, more specifically the very first tmux session created.






    share|improve this answer

























      up vote
      0
      down vote













      It happened to me but this time with $COLORTERM variable.



      If you start tmux on a terminal emulator that has, for instance, COLORTERM=terminus and after that you start another tmux session even on another terminal client that normally would have COLORTERM=gnome-terminal, this new session will crossover and inherit COLORTERM=terminus.



      These assertions are enough to conclude that, unfortunately, tmux sessions are not isolated from each other, even if you're using different terminal emulators.



      Your su sub shell is probably inheriting $XAUTHORITY from another tmux session, more specifically the very first tmux session created.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        It happened to me but this time with $COLORTERM variable.



        If you start tmux on a terminal emulator that has, for instance, COLORTERM=terminus and after that you start another tmux session even on another terminal client that normally would have COLORTERM=gnome-terminal, this new session will crossover and inherit COLORTERM=terminus.



        These assertions are enough to conclude that, unfortunately, tmux sessions are not isolated from each other, even if you're using different terminal emulators.



        Your su sub shell is probably inheriting $XAUTHORITY from another tmux session, more specifically the very first tmux session created.






        share|improve this answer












        It happened to me but this time with $COLORTERM variable.



        If you start tmux on a terminal emulator that has, for instance, COLORTERM=terminus and after that you start another tmux session even on another terminal client that normally would have COLORTERM=gnome-terminal, this new session will crossover and inherit COLORTERM=terminus.



        These assertions are enough to conclude that, unfortunately, tmux sessions are not isolated from each other, even if you're using different terminal emulators.



        Your su sub shell is probably inheriting $XAUTHORITY from another tmux session, more specifically the very first tmux session created.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 5 '14 at 7:59









        marcio

        188117




        188117






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f2269%2fxauthority-appears-from-nowhere-on-sutmux%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt