~xnox/ubuntu/quantal/shadow/clear-locks

« back to all changes in this revision

Viewing changes to debian/patches/402_cppw_selinux

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2009-05-05 09:45:21 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505094521-wpk2wn3q7957tlah
Tags: 1:4.1.3.1-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Ubuntu specific:
    + debian/login.defs: use SHA512 by default for password crypt routine.
  - debian/patches/stdout-encrypted-password.patch: chpasswd can report
    password hashes on stdout (debian bug 505640).
  - debian/login.pam: Enable SELinux support (debian bug 527106).
  - debian/securetty.linux: support Freescale MX-series (debian bug 527095).
* Add debian/patches/300_lastlog_failure: fixed upstream (debian bug 524873).
* Drop debian/patches/593_omit_lastchange_field_if_clock_is_misset: fixed
  upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Goal: Add selinux support to cppw
 
2
 
 
3
Fix:
 
4
 
 
5
Status wrt upstream: cppw is not available upstream.
 
6
                     The patch was made based on the
 
7
                     302_vim_selinux_support patch. It needs to be
 
8
                     reviewed by an SE-Linux aware person.
 
9
 
 
10
Depends on 401_cppw_src.dpatch
 
11
 
 
12
Index: shadow-4.1.2/src/cppw.c
 
13
===================================================================
 
14
--- shadow-4.1.2.orig/src/cppw.c        2008-09-12 01:22:46.328002759 +0200
 
15
+++ shadow-4.1.2/src/cppw.c     2008-09-12 01:34:43.212006991 +0200
 
16
@@ -34,6 +34,9 @@
 
17
 #include <sys/types.h>
 
18
 #include <signal.h>
 
19
 #include <utime.h>
 
20
+#ifdef WITH_SELINUX
 
21
+#include <selinux/selinux.h>
 
22
+#endif
 
23
 #include "prototypes.h"
 
24
 #include "pwio.h"
 
25
 #include "shadowio.h"
 
26
@@ -114,6 +117,22 @@
 
27
   filenewname = filenew;
 
28
   
 
29
   if (access(file, F_OK)) cppwexit(file, 1, 1);
 
30
+#ifdef WITH_SELINUX
 
31
+  /* if SE Linux is enabled then set the context of all new files
 
32
+     to be the context of the file we are editing */
 
33
+  if (is_selinux_enabled ()) {
 
34
+    security_context_t passwd_context=NULL;
 
35
+    int ret = 0;
 
36
+    if (getfilecon (file, &passwd_context) < 0) {
 
37
+      cppwexit (_("Couldn't get file context"), errno, 1);
 
38
+    }
 
39
+    ret = setfscreatecon (passwd_context);
 
40
+    freecon (passwd_context);
 
41
+    if (0 != ret) {
 
42
+      cppwexit (_("setfscreatecon () failed"), errno, 1);
 
43
+    }
 
44
+  }
 
45
+#endif
 
46
   if (!file_lock()) cppwexit("Couldn't lock file", errno, 5);
 
47
   filelocked = 1;
 
48
 
 
49
@@ -134,6 +153,15 @@
 
50
     cppwexit(0,0,1);
 
51
   }
 
52
 
 
53
+#ifdef WITH_SELINUX
 
54
+  /* unset the fscreatecon */
 
55
+  if (is_selinux_enabled ()) {
 
56
+    if (setfscreatecon (NULL)) {
 
57
+      cppwexit (_("setfscreatecon() failed"), errno, 1);
 
58
+    }
 
59
+  }
 
60
+#endif
 
61
+
 
62
   (*file_unlock)();
 
63
 }
 
64