summaryrefslogblamecommitdiffstats
path: root/patches/source/vim/patches/7.4.238
blob: bec9098419685dd4ffa1bd7192659a71cba9fe37 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
























































































































































































































































































































































































































































































































                                                                                                              
To: vim_dev@googlegroups.com
Subject: Patch 7.4.238
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.238
Problem:    Vim does not support the smack library.
Solution:   Add smack support (Jose Bollo)
Files:	    src/config.h.in, src/configure.in, src/fileio.c, src/memfile.c,
	    src/os_unix.c, src/undo.c, src/auto/configure


*** ../vim-7.4.237/src/config.h.in	2014-02-23 22:52:33.364764715 +0100
--- src/config.h.in	2014-04-02 13:37:41.095910851 +0200
***************
*** 191,196 ****
--- 191,197 ----
  #undef HAVE_SIGSETJMP
  #undef HAVE_SIGSTACK
  #undef HAVE_SIGVEC
+ #undef HAVE_SMACK
  #undef HAVE_STRCASECMP
  #undef HAVE_STRERROR
  #undef HAVE_STRFTIME
*** ../vim-7.4.237/src/configure.in	2014-03-27 18:51:06.604760919 +0100
--- src/configure.in	2014-04-02 13:49:36.955901004 +0200
***************
*** 387,406 ****
  AC_SUBST(QUOTESED)
  
  
! dnl Link with -lselinux for SELinux stuff; if not found
! AC_MSG_CHECKING(--disable-selinux argument)
! AC_ARG_ENABLE(selinux,
! 	[  --disable-selinux	  Don't check for SELinux support.],
! 	, enable_selinux="yes")
! if test "$enable_selinux" = "yes"; then
    AC_MSG_RESULT(no)
!   AC_CHECK_LIB(selinux, is_selinux_enabled,
! 	  [LIBS="$LIBS -lselinux"
! 	   AC_DEFINE(HAVE_SELINUX)])
  else
     AC_MSG_RESULT(yes)
  fi
  
  dnl Check user requested features.
  
  AC_MSG_CHECKING(--with-features argument)
--- 387,427 ----
  AC_SUBST(QUOTESED)
  
  
! dnl Link with -lsmack for Smack stuff; if not found
! AC_MSG_CHECKING(--disable-smack argument)
! AC_ARG_ENABLE(smack,
! 	[  --disable-smack	  Do not check for Smack support.],
! 	, enable_smack="yes")
! if test "$enable_smack" = "yes"; then
!   AC_CHECK_HEADER([linux/xattr.h], true, enable_smack="no")
! fi
! if test "$enable_smack" = "yes"; then
    AC_MSG_RESULT(no)
!   AC_CHECK_LIB(attr, llistxattr,
! 	  [LIBS="$LIBS -lattr"
! 	   found_smack="yes"
! 	   AC_DEFINE(HAVE_SMACK)])
  else
     AC_MSG_RESULT(yes)
  fi
  
+ dnl When smack was found don't search for SELinux
+ if test "x$found_smack" = "x"; then
+   dnl Link with -lselinux for SELinux stuff; if not found
+   AC_MSG_CHECKING(--disable-selinux argument)
+   AC_ARG_ENABLE(selinux,
+ 	  [  --disable-selinux	  Do not check for SELinux support.],
+ 	  , enable_selinux="yes")
+   if test "$enable_selinux" = "yes"; then
+     AC_MSG_RESULT(no)
+     AC_CHECK_LIB(selinux, is_selinux_enabled,
+ 	    [LIBS="$LIBS -lselinux"
+ 	     AC_DEFINE(HAVE_SELINUX)])
+   else
+      AC_MSG_RESULT(yes)
+   fi
+ fi
+ 
  dnl Check user requested features.
  
  AC_MSG_CHECKING(--with-features argument)
*** ../vim-7.4.237/src/fileio.c	2014-03-12 16:51:35.056792541 +0100
--- src/fileio.c	2014-04-02 13:39:28.983909367 +0200
***************
*** 4030,4036 ****
  						)
  			    mch_setperm(backup,
  					  (perm & 0707) | ((perm & 07) << 3));
! # ifdef HAVE_SELINUX
  			mch_copy_sec(fname, backup);
  # endif
  #endif
--- 4030,4036 ----
  						)
  			    mch_setperm(backup,
  					  (perm & 0707) | ((perm & 07) << 3));
! # if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
  			mch_copy_sec(fname, backup);
  # endif
  #endif
***************
*** 4069,4075 ****
  #ifdef HAVE_ACL
  			mch_set_acl(backup, acl);
  #endif
! #ifdef HAVE_SELINUX
  			mch_copy_sec(fname, backup);
  #endif
  			break;
--- 4069,4075 ----
  #ifdef HAVE_ACL
  			mch_set_acl(backup, acl);
  #endif
! #if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
  			mch_copy_sec(fname, backup);
  #endif
  			break;
***************
*** 4718,4724 ****
      }
  #endif
  
! #ifdef HAVE_SELINUX
      /* Probably need to set the security context. */
      if (!backup_copy)
  	mch_copy_sec(backup, wfname);
--- 4718,4724 ----
      }
  #endif
  
! #if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
      /* Probably need to set the security context. */
      if (!backup_copy)
  	mch_copy_sec(backup, wfname);
***************
*** 6707,6713 ****
      mch_set_acl(to, acl);
      mch_free_acl(acl);
  #endif
! #ifdef HAVE_SELINUX
      mch_copy_sec(from, to);
  #endif
      if (errmsg != NULL)
--- 6707,6713 ----
      mch_set_acl(to, acl);
      mch_free_acl(acl);
  #endif
! #if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
      mch_copy_sec(from, to);
  #endif
      if (errmsg != NULL)
*** ../vim-7.4.237/src/memfile.c	2013-05-23 22:22:22.000000000 +0200
--- src/memfile.c	2014-04-02 13:37:41.103910851 +0200
***************
*** 1358,1364 ****
  	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
  	    fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
  #endif
! #ifdef HAVE_SELINUX
  	mch_copy_sec(fname, mfp->mf_fname);
  #endif
  	mch_hide(mfp->mf_fname);    /* try setting the 'hidden' flag */
--- 1358,1364 ----
  	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
  	    fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
  #endif
! #if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
  	mch_copy_sec(fname, mfp->mf_fname);
  #endif
  	mch_hide(mfp->mf_fname);    /* try setting the 'hidden' flag */
*** ../vim-7.4.237/src/os_unix.c	2014-04-01 21:00:45.436733663 +0200
--- src/os_unix.c	2014-04-02 13:58:55.427893322 +0200
***************
*** 46,51 ****
--- 46,59 ----
  static int selinux_enabled = -1;
  #endif
  
+ #ifdef HAVE_SMACK
+ # include <attr/xattr.h>
+ # include <linux/xattr.h>
+ # ifndef SMACK_LABEL_LEN
+ #  define SMACK_LABEL_LEN 1024
+ # endif
+ #endif
+ 
  /*
   * Use this prototype for select, some include files have a wrong prototype
   */
***************
*** 2798,2803 ****
--- 2806,2895 ----
  }
  #endif /* HAVE_SELINUX */
  
+ #if defined(HAVE_SMACK) && !defined(PROTO)
+ /*
+  * Copy security info from "from_file" to "to_file".
+  */
+     void
+ mch_copy_sec(from_file, to_file)
+     char_u	*from_file;
+     char_u	*to_file;
+ {
+     static const char const *smack_copied_attributes[] =
+ 	{
+ 	    XATTR_NAME_SMACK,
+ 	    XATTR_NAME_SMACKEXEC,
+ 	    XATTR_NAME_SMACKMMAP
+ 	};
+ 
+     char	buffer[SMACK_LABEL_LEN];
+     const char	*name;
+     int		index;
+     int		ret;
+     ssize_t	size;
+ 
+     if (from_file == NULL)
+ 	return;
+ 
+     for (index = 0 ; index < (int)(sizeof(smack_copied_attributes)
+ 			      / sizeof(smack_copied_attributes)[0]) ; index++)
+     {
+ 	/* get the name of the attribute to copy */
+ 	name = smack_copied_attributes[index];
+ 
+ 	/* get the value of the attribute in buffer */
+ 	size = getxattr((char*)from_file, name, buffer, sizeof(buffer));
+ 	if (size >= 0)
+ 	{
+ 	    /* copy the attribute value of buffer */
+ 	    ret = setxattr((char*)to_file, name, buffer, (size_t)size, 0);
+ 	    if (ret < 0)
+ 	    {
+ 		MSG_PUTS(_("Could not set security context "));
+ 		MSG_PUTS(name);
+ 		MSG_PUTS(_(" for "));
+ 		msg_outtrans(to_file);
+ 		msg_putchar('\n');
+ 	    }
+ 	}
+ 	else
+ 	{
+ 	    /* what reason of not having the attribute value? */
+ 	    switch (errno)
+ 	    {
+ 		case ENOTSUP:
+ 		    /* extended attributes aren't supported or enabled */
+ 		    /* should a message be echoed? not sure... */
+ 		    return; /* leave because it isn't usefull to continue */
+ 
+ 		case ERANGE:
+ 		default:
+ 		    /* no enough size OR unexpected error */
+ 		    MSG_PUTS(_("Could not get security context "));
+ 		    MSG_PUTS(name);
+ 		    MSG_PUTS(_(" for "));
+ 		    msg_outtrans(from_file);
+ 		    MSG_PUTS(_(". Removing it!\n"));
+ 		    /* FALLTHROUGH to remove the attribute */
+ 
+ 		case ENODATA:
+ 		    /* no attribute of this name */
+ 		    ret = removexattr((char*)to_file, name);
+ 		    if (ret < 0 && errno != ENODATA)
+ 		    {
+ 			MSG_PUTS(_("Could not remove security context "));
+ 			MSG_PUTS(name);
+ 			MSG_PUTS(_(" for "));
+ 			msg_outtrans(to_file);
+ 			msg_putchar('\n');
+ 		    }
+ 		    break;
+ 	    }
+ 	}
+     }
+ }
+ #endif /* HAVE_SMACK */
+ 
  /*
   * Return a pointer to the ACL of file "fname" in allocated memory.
   * Return NULL if the ACL is not available for whatever reason.
*** ../vim-7.4.237/src/undo.c	2014-03-23 15:12:29.943264337 +0100
--- src/undo.c	2014-04-02 13:42:15.387907078 +0200
***************
*** 1455,1461 ****
  # endif
         )
  	mch_setperm(file_name, (perm & 0707) | ((perm & 07) << 3));
! # ifdef HAVE_SELINUX
      if (buf->b_ffname != NULL)
  	mch_copy_sec(buf->b_ffname, file_name);
  # endif
--- 1455,1461 ----
  # endif
         )
  	mch_setperm(file_name, (perm & 0707) | ((perm & 07) << 3));
! # if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
      if (buf->b_ffname != NULL)
  	mch_copy_sec(buf->b_ffname, file_name);
  # endif
*** ../vim-7.4.237/src/auto/configure	2014-03-27 18:51:06.612760919 +0100
--- src/auto/configure	2014-04-02 13:50:11.375900531 +0200
***************
*** 782,787 ****
--- 782,788 ----
  with_view_name
  with_global_runtime
  with_modified_by
+ enable_smack
  enable_selinux
  with_features
  with_compiledby
***************
*** 1453,1459 ****
    --enable-fail-if-missing    Fail if dependencies on additional features
       specified on the command line are missing.
    --disable-darwin        Disable Darwin (Mac OS X) support.
!   --disable-selinux	  Don't check for SELinux support.
    --disable-xsmp          Disable XSMP session management
    --disable-xsmp-interact Disable XSMP interaction
    --enable-luainterp=OPTS     Include Lua interpreter.  default=no OPTS=no/yes/dynamic
--- 1454,1461 ----
    --enable-fail-if-missing    Fail if dependencies on additional features
       specified on the command line are missing.
    --disable-darwin        Disable Darwin (Mac OS X) support.
!   --disable-smack	  Do not check for Smack support.
!   --disable-selinux	  Do not check for SELinux support.
    --disable-xsmp          Disable XSMP session management
    --disable-xsmp-interact Disable XSMP interaction
    --enable-luainterp=OPTS     Include Lua interpreter.  default=no OPTS=no/yes/dynamic
***************
*** 4588,4606 ****
  
  
  
! { $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-selinux argument" >&5
  $as_echo_n "checking --disable-selinux argument... " >&6; }
! # Check whether --enable-selinux was given.
  if test "${enable_selinux+set}" = set; then :
    enableval=$enable_selinux;
  else
    enable_selinux="yes"
  fi
  
! if test "$enable_selinux" = "yes"; then
!   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
  $as_echo "no" >&6; }
!   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for is_selinux_enabled in -lselinux" >&5
  $as_echo_n "checking for is_selinux_enabled in -lselinux... " >&6; }
  if ${ac_cv_lib_selinux_is_selinux_enabled+:} false; then :
    $as_echo_n "(cached) " >&6
--- 4590,4679 ----
  
  
  
! { $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-smack argument" >&5
! $as_echo_n "checking --disable-smack argument... " >&6; }
! # Check whether --enable-smack was given.
! if test "${enable_smack+set}" = set; then :
!   enableval=$enable_smack;
! else
!   enable_smack="yes"
! fi
! 
! if test "$enable_smack" = "yes"; then
!   ac_fn_c_check_header_mongrel "$LINENO" "linux/xattr.h" "ac_cv_header_linux_xattr_h" "$ac_includes_default"
! if test "x$ac_cv_header_linux_xattr_h" = xyes; then :
!   true
! else
!   enable_smack="no"
! fi
! 
! 
! fi
! if test "$enable_smack" = "yes"; then
!   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
! $as_echo "no" >&6; }
!   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for llistxattr in -lattr" >&5
! $as_echo_n "checking for llistxattr in -lattr... " >&6; }
! if ${ac_cv_lib_attr_llistxattr+:} false; then :
!   $as_echo_n "(cached) " >&6
! else
!   ac_check_lib_save_LIBS=$LIBS
! LIBS="-lattr  $LIBS"
! cat confdefs.h - <<_ACEOF >conftest.$ac_ext
! /* end confdefs.h.  */
! 
! /* Override any GCC internal prototype to avoid an error.
!    Use char because int might match the return type of a GCC
!    builtin and then its argument prototype would still apply.  */
! #ifdef __cplusplus
! extern "C"
! #endif
! char llistxattr ();
! int
! main ()
! {
! return llistxattr ();
!   ;
!   return 0;
! }
! _ACEOF
! if ac_fn_c_try_link "$LINENO"; then :
!   ac_cv_lib_attr_llistxattr=yes
! else
!   ac_cv_lib_attr_llistxattr=no
! fi
! rm -f core conftest.err conftest.$ac_objext \
!     conftest$ac_exeext conftest.$ac_ext
! LIBS=$ac_check_lib_save_LIBS
! fi
! { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_attr_llistxattr" >&5
! $as_echo "$ac_cv_lib_attr_llistxattr" >&6; }
! if test "x$ac_cv_lib_attr_llistxattr" = xyes; then :
!   LIBS="$LIBS -lattr"
! 	   found_smack="yes"
! 	   $as_echo "#define HAVE_SMACK 1" >>confdefs.h
! 
! fi
! 
! else
!    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
! $as_echo "yes" >&6; }
! fi
! 
! if test "x$found_smack" = "x"; then
!     { $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-selinux argument" >&5
  $as_echo_n "checking --disable-selinux argument... " >&6; }
!   # Check whether --enable-selinux was given.
  if test "${enable_selinux+set}" = set; then :
    enableval=$enable_selinux;
  else
    enable_selinux="yes"
  fi
  
!   if test "$enable_selinux" = "yes"; then
!     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
  $as_echo "no" >&6; }
!     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for is_selinux_enabled in -lselinux" >&5
  $as_echo_n "checking for is_selinux_enabled in -lselinux... " >&6; }
  if ${ac_cv_lib_selinux_is_selinux_enabled+:} false; then :
    $as_echo_n "(cached) " >&6
***************
*** 4638,4650 ****
  $as_echo "$ac_cv_lib_selinux_is_selinux_enabled" >&6; }
  if test "x$ac_cv_lib_selinux_is_selinux_enabled" = xyes; then :
    LIBS="$LIBS -lselinux"
! 	   $as_echo "#define HAVE_SELINUX 1" >>confdefs.h
  
  fi
  
! else
!    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
  $as_echo "yes" >&6; }
  fi
  
  
--- 4711,4724 ----
  $as_echo "$ac_cv_lib_selinux_is_selinux_enabled" >&6; }
  if test "x$ac_cv_lib_selinux_is_selinux_enabled" = xyes; then :
    LIBS="$LIBS -lselinux"
! 	     $as_echo "#define HAVE_SELINUX 1" >>confdefs.h
  
  fi
  
!   else
!      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
  $as_echo "yes" >&6; }
+   fi
  fi
  
  
*** ../vim-7.4.237/src/version.c	2014-04-02 12:12:04.163981514 +0200
--- src/version.c	2014-04-02 13:38:22.511910282 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     238,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
25. You believe nothing looks sexier than a man in boxer shorts illuminated
    only by a 17" inch svga monitor.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///