]> git.pld-linux.org Git - packages/openssh.git/blob - openssh-selinux.patch
- 3.8
[packages/openssh.git] / openssh-selinux.patch
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
4 @@ -40,7 +40,7 @@
5  
6  CC=@CC@
7  LD=@LD@
8 -CFLAGS=@CFLAGS@
9 +CFLAGS=@CFLAGS@ -DWITH_SELINUX
10  CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@
11  LIBS=@LIBS@
12  LIBPAM=@LIBPAM@
13 @@ -134,7 +134,7 @@
14         $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
15  
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
19  
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
25 @@ -62,6 +62,11 @@
26  #include "ssh-gss.h"
27  #endif
28  
29 +#ifdef WITH_SELINUX
30 +#include <selinux/get_context_list.h>
31 +#include <selinux/selinux.h>
32 +#endif
33 +
34  /* func */
35  
36  Session *session_new(void);
37 @@ -1295,6 +1300,18 @@
38  #endif
39         if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid)
40                 fatal("Failed to set uids to %u.", (u_int) pw->pw_uid);
41 +#ifdef WITH_SELINUX
42 +       if (is_selinux_enabled())
43 +         {
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);
49 +           }
50 +           freecon(scontext);
51 +         }
52 +#endif
53  }
54  
55  static void
56 --- openssh-3.8p1/sshpty.c.orig 2004-01-21 07:07:17.000000000 +0100
57 +++ openssh-3.8p1/sshpty.c      2004-02-25 21:19:57.000000000 +0100
58 @@ -22,6 +22,12 @@
59  #include "log.h"
60  #include "misc.h"
61  
62 +#ifdef WITH_SELINUX
63 +#include <selinux/flask.h>
64 +#include <selinux/get_context_list.h>
65 +#include <selinux/selinux.h>
66 +#endif
67 +
68  #ifdef HAVE_PTY_H
69  # include <pty.h>
70  #endif
71 @@ -196,6 +202,37 @@
72          * Warn but continue if filesystem is read-only and the uids match/
73          * tty is owned by root.
74          */
75 +#ifdef WITH_SELINUX
76 +       if (is_selinux_enabled()) {
77 +         security_context_t      new_tty_context=NULL,
78 +           user_context=NULL, old_tty_context=NULL; 
79 +
80 +         if (get_default_context(pw->pw_name,NULL,&user_context))
81 +             fatal("Failed to get default security context for %s.", pw->pw_name);
82 +
83 +         if (getfilecon(ttyname, &old_tty_context)<0) {
84 +           error("getfilecon(%.100s) failed: %.100s", ttyname,
85 +                 strerror(errno));
86 +         }
87 +         else 
88 +           {
89 +             if ( security_compute_relabel(user_context,old_tty_context,SECCLASS_CHR_FILE,&new_tty_context)!=0) {
90 +               error("security_compute_relabel(%.100s) failed: %.100s", ttyname,
91 +                     strerror(errno));
92 +             } 
93 +             else 
94 +               {
95 +                 if (setfilecon (ttyname, new_tty_context) != 0) {
96 +                   error("setfilecon(%.100s, %s) failed: %.100s",
97 +                         ttyname, new_tty_context, strerror(errno));
98 +                 }
99 +                 freecon(new_tty_context);
100 +               }
101 +             freecon(old_tty_context);
102 +           }
103 +         freecon(user_context);
104 +       }
105 +#endif
106         if (stat(ttyname, &st))
107                 fatal("stat(%.100s) failed: %.100s", ttyname,
108                     strerror(errno));
109 @@ -225,4 +262,5 @@
110                                     ttyname, (u_int)mode, strerror(errno));
111                 }
112         }
113 +
114  }
This page took 0.906548 seconds and 4 git commands to generate.