jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.238

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