1 diff -urN openssh-3.7.1p2.org/Makefile.in openssh-3.7.1p2/Makefile.in
2 --- openssh-3.7.1p2.org/Makefile.in 2003-12-26 20:14:52.000000000 +0100
3 +++ openssh-3.7.1p2/Makefile.in 2003-12-26 20:15:15.000000000 +0100
9 +CFLAGS=@CFLAGS@ -DWITH_SELINUX
10 CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@
14 $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
16 sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS)
17 - $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBWRAP) $(LIBPAM) $(LIBS)
18 + $(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBWRAP) $(LIBPAM) $(LIBS) -lselinux
20 scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
21 $(LD) -o $@ scp.o progressmeter.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
22 diff -urN openssh-3.7.1p2.org/session.c openssh-3.7.1p2/session.c
23 --- openssh-3.7.1p2.org/session.c 2003-12-26 20:14:53.000000000 +0100
24 +++ openssh-3.7.1p2/session.c 2003-12-26 20:15:50.000000000 +0100
30 +#include <selinux/get_context_list.h>
31 +#include <selinux/selinux.h>
36 Session *session_new(void);
37 @@ -1295,6 +1300,18 @@
39 if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid)
40 fatal("Failed to set uids to %u.", (u_int) pw->pw_uid);
42 + if (is_selinux_enabled())
44 + security_context_t scontext;
45 + if (get_default_context(pw->pw_name,NULL,&scontext))
46 + fatal("Failed to get default security context for %s.", pw->pw_name);
47 + if (setexeccon(scontext)) {
48 + fatal("Failed to set exec security context %s for %s.", scontext, pw->pw_name);
56 diff -urN openssh-3.7.1p2.org/sshpty.c openssh-3.7.1p2/sshpty.c
57 --- openssh-3.7.1p2.org/sshpty.c 2003-12-26 20:14:53.000000000 +0100
58 +++ openssh-3.7.1p2/sshpty.c 2003-12-26 20:15:14.000000000 +0100
64 +#include <selinux/flask.h>
65 +#include <selinux/get_context_list.h>
66 +#include <selinux/selinux.h>
69 /* Pty allocated with _getpty gets broken if we do I_PUSH:es to it. */
70 #if defined(HAVE__GETPTY) || defined(HAVE_OPENPTY)
73 * Warn but continue if filesystem is read-only and the uids match/
74 * tty is owned by root.
77 + if (is_selinux_enabled()) {
78 + security_context_t new_tty_context=NULL,
79 + user_context=NULL, old_tty_context=NULL;
81 + if (get_default_context(pw->pw_name,NULL,&user_context))
82 + fatal("Failed to get default security context for %s.", pw->pw_name);
84 + if (getfilecon(ttyname, &old_tty_context)<0) {
85 + error("getfilecon(%.100s) failed: %.100s", ttyname,
90 + if ( security_compute_relabel(user_context,old_tty_context,SECCLASS_CHR_FILE,&new_tty_context)!=0) {
91 + error("security_compute_relabel(%.100s) failed: %.100s", ttyname,
96 + if (setfilecon (ttyname, new_tty_context) != 0) {
97 + error("setfilecon(%.100s, %s) failed: %.100s",
98 + ttyname, new_tty_context, strerror(errno));
100 + freecon(new_tty_context);
102 + freecon(old_tty_context);
104 + freecon(user_context);
107 if (stat(ttyname, &st))
108 fatal("stat(%.100s) failed: %.100s", ttyname,
111 ttyname, (u_int)mode, strerror(errno));