Bug 987554 - ssh cannot create controlmaster socket when running as confined user
Summary: ssh cannot create controlmaster socket when running as confined user
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 19
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-07-23 16:03 UTC by Michael S.
Modified: 2017-06-29 20:27 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-10-21 16:11:55 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Michael S. 2013-07-23 16:03:27 UTC
To speed up connexion, I am using ssh connexion multiplexing. However, after setting it up, i doscvered that selinux block that :

type=AVC msg=audit(1374595077.699:4935): avc:  denied  { create } for  pid=5793 comm="ssh" name="misc.example.com:22.wFfLJBMez5wphcDh" scontext=staff_u:staff_r:ssh_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:user_home_t:s0 tclass=sock_file

My settings are ( in ~/.ssh/config ) :

Host git.corp.example.com gitolite.corp.example.com
    ControlMaster auto
    ControlPath /home/misc/tmp/%r@%h:%p


$ ls -lZd ~/tmp/
drwxrwxr-x. misc misc unconfined_u:object_r:user_home_t:s0 /home/misc/tmp/

Comment 1 Michael S. 2013-07-23 18:43:12 UTC
So in fact, there is 3 operations, as seen by running in permissive mode  :

type=AVC msg=audit(1374604682.020:5133): avc:  denied  { create } for  pid=13572 comm="ssh" name="misc.example.com:22.sWlPsweTDbYJoss6" scontext=staff_u:staff_r:ssh_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:user_home_t:s0 tclass=sock_file
type=AVC msg=audit(1374604682.020:5134): avc:  denied  { link } for  pid=13572 comm="ssh" name="misc.example.com:22.sWlPsweTDbYJoss6" dev="dm-3" ino=3422336 scontext=staff_u:staff_r:ssh_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:user_home_t:s0 tclass=sock_file
type=AVC msg=audit(1374604682.020:5135): avc:  denied  { unlink } for  pid=13572 comm="ssh" name="misc.example.com:22.sWlPsweTDbYJoss6" dev="dm-3" ino=3422336 scontext=staff_u:staff_r:ssh_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:user_home_t:s0 tclass=sock_file

Comment 2 Miroslav Grepl 2013-07-24 12:11:37 UTC
What is the default value for ControlPath?

Comment 3 Daniel Walsh 2013-07-24 14:57:15 UTC
Seems like we should have a transition for this, although it would be nice if the socket was put into a subdir like .cache/ssh/  Or /run/user/UID/ssh

Comment 4 Daniel Walsh 2013-07-24 15:10:32 UTC
e506a4253b8b80ec6e0e59d5e3be4709aeba45ef fixes this in git.

Comment 5 Michael S. 2013-07-24 20:39:54 UTC
There is no default for Controlpath. And I would indeed recommend to place the controlSocket in a protected directory, since it can be used to connect to a remote server without password ( in fact, that's quite tricky because using controlpath even put no log on remote server )

Comment 6 Petr Lautrbach 2013-07-25 15:01:52 UTC
As stated, there's no default value for ControlPath and ssh won't prepare a multiplexing if ControlPath is not set. So it's up to an user to set and place the control socket to the right place. Also the control socekt is created using umask(0177) so it should be accesibble only to the owner.

Comment 7 Daniel Walsh 2013-07-25 21:08:59 UTC
Is this a case where we should give an example location like ~/.ssh/ControlSocket.

Comment 8 Enrico Scholz 2013-10-15 18:01:14 UTC
home directory is a bad choice because it is usually on NFS shares and '~/.ssh/%r@%h:%p' will cause conflicts when running ssh on different hosts.  You might add the local hostname %l to avoid this conflict but this can make the resulting path name too long.

A place below $XDG_RUNTIME_DIR would be an excellent place but unfortunately, ControlPath does not expand shell variables and the uid must be hardcoded.

Comment 9 Miroslav Grepl 2013-10-21 16:11:55 UTC
We have rules for HOMEDIR.

Petr,
should we make a note in sshd_config how Dan wrote?

Comment 10 Brian J. Murrell 2017-06-29 20:27:58 UTC
So what dir should the control socket go into so that it does not run afoul of selinux?


Note You need to log in before you can comment on or make changes to this bug.