selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Shigorin <mike@altlinux.org>
To: Nicolas Iooss <nicolas.iooss@m4x.org>
Cc: SElinux list <selinux@vger.kernel.org>
Subject: Re: [PATCH] non-gcc-specific exception.sh
Date: Sat, 12 Oct 2019 20:23:57 +0300	[thread overview]
Message-ID: <20191012172357.GB19655@imap.altlinux.org> (raw)
In-Reply-To: <CAJfZ7=kYpc3Y1EHHycGeQSqCoptyNAyEcx4=ZDP=O8NEKJQnyg@mail.gmail.com>

On Sat, Oct 12, 2019 at 06:55:39PM +0200, Nicolas Iooss wrote:
> > Will this one do better?  Looks a bit messy though[1]:
> >
> > gcc -E -I../include -xc ../include/selinux/selinux.h |
> >   awk -F '[ (]' '/^#/{p=0} \
> >     /^# .*selinux\/selinux\.h/{p=1} \
> >     /^extern int/{if(p==1){print $3}}'
> I wanted to spend some time testing different approaches before
> replying. Your awk command works fine, but I am wondering
> whether its complexity is needed at all.

I've considered this approach too but decided to try and mimic
what's done already first, and maybe try the next step afterwards
(albeit "a temporary solution is the most permanent one" is a well
known effect indeed :-).

> For example, why not directly grab the "extern int" lines in
> selinux.h (using sed -n s/.../.../p). This would work well with
> libselinux and avoid using awk for this simple task, but not
> for libsemanage...  or it could, with:
> 
>     cat ../include/semanage/*.h | \
>     sed -n 's/^extern \+int \+\([0-9A-Za-z_]\+\) *(.*$/\1/p'
> 
> Actually, the main reason why it is currently not possible to migrate
> from "gcc -aux-info and awk" to "cat | sed" is caused by the fact that
> the file generated by "gcc -aux-info" adds "extern" before all
> function prototypes. Adding "extern" directly to the prototypes of all
> exported functions in header files seems to be required in order to
> use something else than "gcc -aux-info" to generate the glue code that
> handles exception in Python bindings.

That's another part I'm not strong at, being rather shell/make
sysadmin/maintainer type than a proper C developer; only spotted
the selinuxfs_exists prototype difference, in particular.

> Therefore I suggest the following approach:
> 1. add "extern" to all exported functions in libselinux and
> libsemanage public headers (I can send a patch for this
> tomorrow if you don't want to do this)

I'd be grateful to you as touching code I have no clue about
is something I try to avoid.

> 2. change exception.sh to use something else than "gcc -aux-info"
> to generate the glue code

This is what I can take care of, -E way or through direct parsing.

> 3. add something so that "make test" compares the result of "$CC
> -aux-info" (if $CC is gcc-compatible) with the new way to find
> functions, in order to report differences in the generated glue code.
> This could for example consist in adding some code in exception.sh
> such that "./exception.sh test" performs this check.

I can do that either given your support with review.

> Would this suit you?

Definitely.

> By the way, I found out that libsemanage generates glue code
> for select() and pselect() too, as it does not filter the
> output of "gcc -aux-info". This is a bug that needs to be
> fixed.

~/git/libselinux/libsemanage/src> touch FILTER-OUT-p_select-TOO    

-- 
 ---- WBR, Michael Shigorin / http://altlinux.org
  ------ http://opennet.ru / http://anna-news.info

      reply	other threads:[~2019-10-12 17:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07 13:20 [PATCH] non-gcc-specific exception.sh Michael Shigorin
2019-10-07 16:27 ` Nicolas Iooss
2019-10-07 19:21   ` Michael Shigorin
2019-10-12 16:55     ` Nicolas Iooss
2019-10-12 17:23       ` Michael Shigorin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191012172357.GB19655@imap.altlinux.org \
    --to=mike@altlinux.org \
    --cc=nicolas.iooss@m4x.org \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).