chroot fails if compiled with SELinux support

Bug #237557 reported by peterh
2
Affects Status Importance Assigned to Milestone
openssh (Debian)
Fix Released
Unknown
openssh (Ubuntu)
Fix Released
Medium
Colin Watson

Bug Description

i am using openssh with libpam_chroot to have a chrooted login but
following error message denies access for chrooted uses

sshd[14644]: fatal: ssh_selinux_getctxbyname: ssh_selinux_getctxbyname: security_getenforce() failed

Please include this fix: http://marc.info/?l=openssh-unix-dev&m=120615000019541&w=2

Index: session.c
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh/session.c,v
retrieving revision 1.364
diff -u -p -r1.364 session.c
--- session.c 15 Mar 2008 06:27:58 -0000 1.364
+++ session.c 22 Mar 2008 01:23:48 -0000
@@ -1350,6 +1350,10 @@ do_setusercontext(struct passwd *pw)
 #endif /* HAVE_CYGWIN */
  {

+#ifdef WITH_SELINUX
+ /* Cache selinux status for later use */
+ (void)ssh_selinux_enabled();
+#endif
 #ifdef HAVE_SETPCRED
   if (setpcred(pw->pw_name, (char **)NULL) == -1)
    fatal("Failed to set process credentials");
Index: openbsd-compat/port-linux.c
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh/openbsd-compat/port-linux.c,v
retrieving revision 1.4
diff -u -p -r1.4 port-linux.c
--- openbsd-compat/port-linux.c 27 Jun 2007 22:48:03 -0000 1.4
+++ openbsd-compat/port-linux.c 22 Mar 2008 01:24:06 -0000
@@ -36,7 +36,7 @@
 #include <selinux/get_context_list.h>

 /* Wrapper around is_selinux_enabled() to log its return value once only */
-static int
+int
 ssh_selinux_enabled(void)
 {
  static int enabled = -1;
Index: openbsd-compat/port-linux.h
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh/openbsd-compat/port-linux.h,v
retrieving revision 1.1
diff -u -p -r1.1 port-linux.h
--- openbsd-compat/port-linux.h 22 Apr 2006 11:26:08 -0000 1.1
+++ openbsd-compat/port-linux.h 22 Mar 2008 01:28:06 -0000
@@ -20,6 +20,7 @@
 #define _PORT_LINUX_H

 #ifdef WITH_SELINUX
+int ssh_selinux_enabled(void);
 void ssh_selinux_setup_pty(char *, const char *);
 void ssh_selinux_setup_exec_context(char *);
 #endif

Revision history for this message
Colin Watson (cjwatson) wrote :

This fix is in OpenSSH 4.9p1; I'm aiming to get 5.1p1 into Intrepid shortly.

Changed in openssh:
assignee: nobody → kamion
status: New → Fix Committed
importance: Undecided → Medium
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (10.9 KiB)

This bug was fixed in the package openssh - 1:5.1p1-1ubuntu1

---------------
openssh (1:5.1p1-1ubuntu1) intrepid; urgency=low

  * Resynchronise with Debian. Remaining changes:
    - Add support for registering ConsoleKit sessions on login.
    - Drop openssh-blacklist and openssh-blacklist-extra to Suggests; they
      take up a lot of CD space, and I suspect that rolling them out in
      security updates has covered most affected systems now.

openssh (1:5.1p1-1) unstable; urgency=low

  * New upstream release (closes: #474301). Important changes not previously
    backported to 4.7p1:
    - 4.9/4.9p1 (http://www.openssh.com/txt/release-4.9):
      + Added chroot(2) support for sshd(8), controlled by a new option
        "ChrootDirectory" (closes: #139047, LP: #24777).
      + Linked sftp-server(8) into sshd(8). The internal sftp server is used
        when the command "internal-sftp" is specified in a Subsystem or
        ForceCommand declaration. When used with ChrootDirectory, the
        internal sftp server requires no special configuration of files
        inside the chroot environment.
      + Added a protocol extension method "<email address hidden>" for
        sftp-server(8) to perform POSIX atomic rename() operations; sftp(1)
        prefers this if available (closes: #308561).
      + Removed the fixed limit of 100 file handles in sftp-server(8).
      + ssh(8) will now skip generation of SSH protocol 1 ephemeral server
        keys when in inetd mode and protocol 2 connections are negotiated.
        This speeds up protocol 2 connections to inetd-mode servers that
        also allow Protocol 1.
      + Accept the PermitRootLogin directive in a sshd_config(5) Match
        block. Allows for, e.g. permitting root only from the local network.
      + Reworked sftp(1) argument splitting and escaping to be more
        internally consistent (i.e. between sftp commands) and more
        consistent with sh(1). Please note that this will change the
        interpretation of some quoted strings, especially those with
        embedded backslash escape sequences.
      + Support "Banner=none" in sshd_config(5) to disable sending of a
        pre-login banner (e.g. in a Match block).
      + ssh(1) ProxyCommands are now executed with $SHELL rather than
        /bin/sh.
      + ssh(1)'s ConnectTimeout option is now applied to both the TCP
        connection and the SSH banner exchange (previously it just covered
        the TCP connection). This allows callers of ssh(1) to better detect
        and deal with stuck servers that accept a TCP connection but don't
        progress the protocol, and also makes ConnectTimeout useful for
        connections via a ProxyCommand.
      + scp(1) incorrectly reported "stalled" on slow copies (closes:
        #140828).
      + scp(1) date underflow for timestamps before epoch.
      + ssh(1) used the obsolete SIG DNS RRtype for host keys in DNS,
        instead of the current standard RRSIG.
      + Correctly drain ACKs when a sftp(1) upload write fails midway,
        avoids a fatal() exit from what should be a recoverable condition.
      + Fixed ssh-keygen(1) selective host key hashing (i.e. "ssh...

Changed in openssh:
status: Fix Committed → Fix Released
Changed in openssh (Debian):
status: Unknown → New
Changed in openssh (Debian):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.