1
Goal: Add selinux support to cppw
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.
10
Depends on 401_cppw_src.dpatch
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
17
#include <sys/types.h>
21
+#include <selinux/selinux.h>
23
#include "prototypes.h"
27
filenewname = filenew;
29
if (access(file, F_OK)) cppwexit(file, 1, 1);
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;
36
+ if (getfilecon (file, &passwd_context) < 0) {
37
+ cppwexit (_("Couldn't get file context"), errno, 1);
39
+ ret = setfscreatecon (passwd_context);
40
+ freecon (passwd_context);
42
+ cppwexit (_("setfscreatecon () failed"), errno, 1);
46
if (!file_lock()) cppwexit("Couldn't lock file", errno, 5);
54
+ /* unset the fscreatecon */
55
+ if (is_selinux_enabled ()) {
56
+ if (setfscreatecon (NULL)) {
57
+ cppwexit (_("setfscreatecon() failed"), errno, 1);