On Fri, 2009-02-06 at 02:41 -0500, CAI Qian wrote:
> Hi,
> 
> From: Masatake YAMATO <[email protected]>
> Subject: Re: [LTP] [PATCH 2/3] Proc01: Fix for PPC64 and Support 
> SELinux-enabled Environment v2
> Date: Fri, 06 Feb 2009 15:46:58 +0900 (JST)
> 
> >> >> +AC_DEFUN([LTP_CHECK_SELINUX],
> >> >> +[dnl
> >> >> +AC_CHECK_HEADERS(selinux/selinux.h,[
> >> >> +        SELINUX_LIBS="-lselinux"],[
> >> >> +        SELINUX_LIBS=""])
> >> >> +AC_SUBST(SELINUX_LIBS)
> >> > 
> >> > 
> >> > I think checking only the header is not enough to
> >> > say libselinux exists.
> >> > It may be better to check libselinux with AC_CHECK_LIB
> >> > after checking the header file.
> >> > 
> >> 
> >> Sure, but how often does it happen? Distros are usually making sure
> >> headers depend on actual libs packages.
> > 
> > The distribution we are using may be well maintained. 
> > 
> > But I guess there may be broken distributions on the earth.
> > If a user of such broken distributions wants to run ltp on one's
> > system, what happens? Shooting the trouble on such system takes
> > rather longer time.
> > 
> 
> Well, it is probably better to fix the broken distributions instead, but
> since you have already made a patch, it should be fine to check the
> library files as well. 
> 
> > Could you review my patch?
> > 
> > With LTP_CHECK_LIB defined in ltp-common.m4, we can check
> > the existence of libselinux and can define SELINUX_LIBS shell
> > variable easily. LTP_CHECK_SELINUX uses LTP_CHECK_LIB.
> > 
> > I think `lsm_should_work' in proc01.c is not guarded with
> > HAVE_SELINUX_SELINUX_H. Do you afraid the binary size?
> > 
> > 
> > Signed-off-by: Masatake YAMATO <[email protected]>
> > 
> > 
> > 
> > --- m4/ltp-common.m4        1970-01-01 09:00:00.000000000 +0900
> > +++ m4/ltp-common.m4        2009-02-06 15:35:23.000000000 +0900
> > @@ -0,0 +1,35 @@
> > +dnl
> > +dnl Copyright (c) Red Hat Inc., 2009
> > +dnl
> > +dnl This program is free software;  you can redistribute it and/or
> > +dnl modify it under the terms of the GNU General Public License as
> > +dnl published by the Free Software Foundation; either version 2 of
> > +dnl the License, or (at your option) any later version.
> > +dnl
> > +dnl This program is distributed in the hope that it will be useful,
> > +dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
> > +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> > +dnl the GNU General Public License for more details.
> > +dnl
> > +dnl You should have received a copy of the GNU General Public License
> > +dnl along with this program;  if not, write to the Free Software
> > +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> > +dnl USA
> > +dnl
> > +dnl Author: Masatake YAMATO <[email protected]>
> > +dnl
> > +
> > +# LTP_CHECK_LIB(/LIBRARY/,/FUNCTIONS/,[/OTHER-LIBRARIES/])
> > +# --------------------------------------------------
> > +# LTP_CHECK_LIB works like AC_CHECK_LIB.
> > +# But it is customized for LTP.
> > +#
> > +# 1. LIBS is not updated even if /FUNCTION/ is found in /LIBRARY/.
> > +# 2. Instead of LIBS, /LIBRARY/_LIBS is set.
> > +# 3. LIBS_/LIBRARY/ is passed to AC_SUBST.
> > +#
> > +AC_DEFUN([LTP_CHECK_LIB],LIBRARY_LIBS
> > +[AH_TEMPLATE(AS_TR_CPP([HAVE_LIB$1]),
> > +[Define to 1 if you have the `$1' library (-l$1).])
> > +AC_CHECK_LIB($1,$2,[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1)) 
> > AS_TR_CPP([$1_LIBS])="-l$1 $3"],,$3)
> > +AC_SUBST(AS_TR_CPP([$1_LIBS]))])
> > 
> > Index: m4/ltp-selinux.m4
> > ===================================================================
> > RCS file: /cvsroot/ltp/ltp/m4/ltp-selinux.m4,v
> > retrieving revision 1.1
> > diff -u -u -r1.1 ltp-selinux.m4
> > --- m4/ltp-selinux.m4       5 Feb 2009 11:18:58 -0000       1.1
> > +++ m4/ltp-selinux.m4       6 Feb 2009 06:38:21 -0000
> > @@ -22,8 +22,6 @@
> >  dnl
> >  AC_DEFUN([LTP_CHECK_SELINUX],
> >  [dnl
> > -AC_CHECK_HEADERS(selinux/selinux.h,[
> > -        SELINUX_LIBS="-lselinux"],[
> > -        SELINUX_LIBS=""])
> > -AC_SUBST(SELINUX_LIBS)
> > +AC_CHECK_HEADERS(selinux/selinux.h)
> > +LTP_CHECK_LIB(selinux,is_selinux_enabled)
> >  ])
> > Index: testcases/kernel/fs/proc/proc01.c
> > ===================================================================
> > RCS file: /cvsroot/ltp/ltp/testcases/kernel/fs/proc/proc01.c,v
> > retrieving revision 1.13
> > diff -u -u -r1.13 proc01.c
> > --- testcases/kernel/fs/proc/proc01.c       5 Feb 2009 11:20:49 -0000       
> > 1.13
> > +++ testcases/kernel/fs/proc/proc01.c       6 Feb 2009 06:38:22 -0000
> > @@ -107,19 +107,12 @@
> >  
> >  /* If a particular LSM is enabled, it is expected that some entries can
> >     be read successfully. */
> > -#ifdef HAVE_SELINUX_SELINUX_H
> >  const char lsm_should_work[][PATH_MAX] =
> >    {
> >      "/proc/self/attr/*",
> >      "/proc/self/task/[0-9]*/attr/*",
> >      ""
> >    };
> > -#else
> > -const char lsm_should_work[][PATH_MAX] =
> > -  {
> > -    ""
> > -  };
> > -#endif
> >  
> 
> No, the above #ifdef statement is intended to make things easier for
> other LSMs to add their specific entries there. The empty
> lsm_should_work in the case that none of LSMs is found just to avoid a
> compilation warning when the code is walking the array below,
> 
>   if (is_lsm_enabled())
>     {
>       for (i = 0; lsm_should_work[i][0] != '\0'; i++)
>         {
>           if (!strcmp(obj, lsm_should_work[i])
>               || !fnmatch(lsm_should_work[i], obj, FNM_PATHNAME))
>             return 0;
>         }
>     }
> 
> >  /* Known files that does not honor O_NONBLOCK, so they will hang
> >     the test while being read. */
> > @@ -132,7 +125,7 @@
> >  /* Check if a particular LSM is enabled. */
> >  int is_lsm_enabled(void)
> >  {
> > -#ifdef HAVE_SELINUX_SELINUX_H
> > +#if defined(HAVE_SELINUX_SELINUX_H) && defined(HAVE_LIBSELINUX)
> 
> Is it possible to combine those two macros together if both headers and
> libraries are detected? I can't think of any use case that you want to
> try them separately.

Yamato,

Kindly address Cai“s concerns in another patch.

Regards--
Subrata

> 
> CAI Qian
> 
> >    return is_selinux_enabled();
> >  #else
> >    return 0;
> 
> ------------------------------------------------------------------------------
> Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
> software. With Adobe AIR, Ajax developers can use existing skills and code to
> build responsive, highly engaging applications that combine the power of local
> resources and data with the reach of the web. Download the Adobe AIR SDK and
> Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
> _______________________________________________
> Ltp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ltp-list


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to