Skip to contentSkip to conversation

'make policy' issues

DISCUSSION Eric Laganowski 5 participants 16 messages Oct 21, 2009 – Nov 16, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hello,

I was trying to build selinux userspace tools on my custom linux build. Everything went fine until I attempted to compile reference policy. Could you please help me in understanding what went wrong here.

refpolicy-2.20090730

$ make policy
Compiling refpolicy policy.24
/usr/bin/checkpolicy policy.conf -o policy.24
/usr/bin/checkpolicy:  loading policy configuration from policy.conf
policy/modules/kernel/corenetwork.te":1715:ERROR 'syntax error' at token ':' on line 9122:
allow corenet_unconfined_type node_type:node *;

checkpolicy: error(s) encountered while parsing configuration
make: *** [policy.24] Error 1

Packages:

checkpolicy-2.0.19
libselinux-2.0.85
libsemanage-2.0.33
libsepol-2.0.37
policycoreutils-2.0.69
sepolgen-1.0.17

$ yacc -V
yacc - 1.9 20090221
$ flex -V
flex 2.5.35

-Eric

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 28 lines · Eric Laganowski

Hello,

I was trying to build selinux userspace tools on my custom linux build.
Everything went fine until I attempted to compile reference policy. Could you please help me in understanding what went wrong here.

refpolicy-2.20090730

$ make policy
Compiling refpolicy policy.24
/usr/bin/checkpolicy policy.conf -o policy.24
/usr/bin/checkpolicy:  loading policy configuration from policy.conf
policy/modules/kernel/corenetwork.te":1715:ERROR 'syntax error' at token ':' on line 9122:
allow corenet_unconfined_type node_type:node *;

checkpolicy: error(s) encountered while parsing configuration
make: *** [policy.24] Error 1

Packages:

checkpolicy-2.0.19
libselinux-2.0.85
libsemanage-2.0.33
libsepol-2.0.37
policycoreutils-2.0.69
sepolgen-1.0.17

Quoted 4 lines
$ yacc -V
yacc - 1.9 20090221
$ flex -V
flex 2.5.35

Sounds similar to:
http://marc.info/?l=selinux&m=117076095205821&w=2

which was an upstream flex problem. However, I also see that you are using yacc rather than bison? Default for building checkpolicy is bison -y, which could be relevant.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 36 lines · Stephen Smalley
Quoted 28 lines · Eric Laganowski

Hello,

I was trying to build selinux userspace tools on my custom linux build.
Everything went fine until I attempted to compile reference policy. Could you please help me in understanding what went wrong here.

refpolicy-2.20090730

$ make policy
Compiling refpolicy policy.24
/usr/bin/checkpolicy policy.conf -o policy.24
/usr/bin/checkpolicy:  loading policy configuration from policy.conf
policy/modules/kernel/corenetwork.te":1715:ERROR 'syntax error' at token ':' on line 9122:
allow corenet_unconfined_type node_type:node *;

checkpolicy: error(s) encountered while parsing configuration
make: *** [policy.24] Error 1

Packages:

checkpolicy-2.0.19
libselinux-2.0.85
libsemanage-2.0.33
libsepol-2.0.37
policycoreutils-2.0.69
sepolgen-1.0.17

Quoted 5 lines
$ yacc -V
yacc - 1.9 20090221
$ flex -V
flex 2.5.35
Quoted 6 lines

Sounds similar to:
http://marc.info/?l=selinux&m=117076095205821&w=2

which was an upstream flex problem. However, I also see that you are using yacc rather than bison? Default for building checkpolicy is bison -y, which could be relevant.

Re bison/yacc: I tried both, byacc and 'bison -y'
Re flex: What is the requirement for flex from selinux perspective? Is it known what build of flex is "known good"?

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 40 lines · Eric Laganowski
Quoted 39 lines · Stephen Smalley
Quoted 28 lines · Eric Laganowski

Hello,

I was trying to build selinux userspace tools on my custom linux build.
Everything went fine until I attempted to compile reference policy. Could you please help me in understanding what went wrong here.

refpolicy-2.20090730

$ make policy
Compiling refpolicy policy.24
/usr/bin/checkpolicy policy.conf -o policy.24
/usr/bin/checkpolicy:  loading policy configuration from policy.conf
policy/modules/kernel/corenetwork.te":1715:ERROR 'syntax error' at token ':' on line 9122:
allow corenet_unconfined_type node_type:node *;

checkpolicy: error(s) encountered while parsing configuration
make: *** [policy.24] Error 1

Packages:

checkpolicy-2.0.19
libselinux-2.0.85
libsemanage-2.0.33
libsepol-2.0.37
policycoreutils-2.0.69
sepolgen-1.0.17

Quoted 5 lines
$ yacc -V
yacc - 1.9 20090221
$ flex -V
flex 2.5.35

Sounds similar to:
http://marc.info/?l=selinux&m=117076095205821&w=2

Quoted 6 lines
Quoted 3 lines

which was an upstream flex problem. However, I also see that you are using yacc rather than bison? Default for building checkpolicy is bison -y, which could be relevant.

Re bison/yacc: I tried both, byacc and 'bison -y'
Re flex: What is the requirement for flex from selinux perspective? Is it known what build of flex is "known good"?

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

flex -V here also shows 2.5.35. But there are three patches in the Fedora package. Attached.

Signature · 2 lines
Stephen Smalley
National Security Agency
flex.skl +1 -0
diff -urNp flex-2.5.35.orig/flex.skl flex-2.5.35/flex.skl
@@ -217,6 +217,7 @@ m4preproc_include(`flexint.h')
 /* begin standard C++ headers. */
 #include <iostream> 
 #include <errno.h>
+#include <cstdio>
 #include <cstdlib>
 #include <cstring>
 /* end standard C++ headers. */
skel.c +1 -0
diff -urNp flex-2.5.35.orig/skel.c flex-2.5.35/skel.c
@@ -284,6 +284,7 @@ const char *skel[] = {
   "/* begin standard C++ headers. */",
   "#include <iostream> ",
   "#include <errno.h>",
+  "#include <cstdio>",
   "#include <cstdlib>",
   "#include <cstring>",
   "/* end standard C++ headers. */",
scan.c +1 -1
diff -u flex-2.5.35/scan.c flex-2.5.35/scan.c
@@ -2096,7 +2096,7 @@
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
flex.skl +1 -1
diff -u flex-2.5.35/flex.skl flex-2.5.35/flex.skl
@@ -1075,7 +1075,7 @@
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
 %endif
 %if-c++-only C++ definition
 #define ECHO LexerOutput( yytext, yyleng )
skel.c +1 -1
diff -u flex-2.5.35/skel.c flex-2.5.35/skel.c
@@ -1142,7 +1142,7 @@
   "/* This used to be an fputs(), but since the string might contain NUL's,",
   " * we now use fwrite().",
   " */",
-  "#define ECHO fwrite( yytext, yyleng, 1, yyout )",
+  "#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)",
   "%endif",
   "%if-c++-only C++ definition",
   "#define ECHO LexerOutput( yytext, yyleng )",
gen.c renamed from gen.c-orig +1 -1
@@ -1890,7 +1890,7 @@
 			outn ("\tif ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \\");
 			outn ("\t\t{ \\");
 			outn ("\t\tint c = '*'; \\");
-			outn ("\t\tint n; \\");
+			outn ("\t\tunsigned n; \\");
 			outn ("\t\tfor ( n = 0; n < max_size && \\");
 			outn ("\t\t\t     (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\");
 			outn ("\t\t\tbuf[n] = (char) c; \\");
#4 lore raw
Quoted 60 lines · Stephen Smalley
Quoted 42 lines · Eric Laganowski
Quoted 40 lines · Stephen Smalley
Quoted 28 lines · Eric Laganowski

Hello,

I was trying to build selinux userspace tools on my custom linux build.
Everything went fine until I attempted to compile reference policy. Could you please help me in understanding what went wrong here.

refpolicy-2.20090730

$ make policy
Compiling refpolicy policy.24
/usr/bin/checkpolicy policy.conf -o policy.24
/usr/bin/checkpolicy:  loading policy configuration from policy.conf
policy/modules/kernel/corenetwork.te":1715:ERROR 'syntax error' at token ':' on line 9122:
allow corenet_unconfined_type node_type:node *;

checkpolicy: error(s) encountered while parsing configuration
make: *** [policy.24] Error 1

Packages:

checkpolicy-2.0.19
libselinux-2.0.85
libsemanage-2.0.33
libsepol-2.0.37
policycoreutils-2.0.69
sepolgen-1.0.17

Quoted 6 lines
$ yacc -V
yacc - 1.9 20090221
$ flex -V
flex 2.5.35

Sounds similar to:
http://marc.info/?l=selinux&m=117076095205821&w=2

Quoted 8 lines
Quoted 4 lines

which was an upstream flex problem. However, I also see that you are using yacc rather than bison? Default for building checkpolicy is bison -y, which could be relevant.

Re bison/yacc: I tried both, byacc and 'bison -y'
Re flex: What is the requirement for flex from selinux perspective? Is it known what build of flex is "known good"?

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

Quoted 4 lines

flex -V here also shows 2.5.35. But there are three patches in the Fedora package. Attached.

Thanks for the patch, been hitting something similar to this with checkpolicy(used git clean -fx to fix)

Justin P. Mattock

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#5 lore raw
In reply to Stephen Smalley
Quoted 14 lines · Stephen Smalley
Quoted 5 lines · Eric Laganowski

Stephen Smalley wrote:

Re bison/yacc: I tried both, byacc and 'bison -y'
Re flex: What is the requirement for flex from selinux perspective? Is it known what build of flex is "known good"?

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

Quoted 2 lines

flex -V here also shows 2.5.35. But there are three patches in the Fedora package. Attached.

Debian currently carries 13 (though 3 of them need to be
squashed together) patches against 2.5.35. I can make them available if there is interest.

manoj

Signature · 7 lines
Manoj Srivastava <[email protected]> <http://www.golden-gryphon.com/>  
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw
Quoted 15 lines · Manoj Srivastava
Quoted 9 lines · Stephen Smalley
Quoted 2 lines

Re flex: What is the requirement for flex from selinux perspective? Is it known what build of flex is "known good"?

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

Quoted 3 lines

flex -V here also shows 2.5.35. But there are three patches in the Fedora package. Attached.

Quoted 6 lines

Debian currently carries 13 (though 3 of them need to be
squashed together) patches against 2.5.35. I can make them available if there is interest.

manoj

Yes please. Patches would be welcome.

-Eric

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#7 lore raw
Quoted 17 lines · Eric Laganowski
Quoted 16 lines · Manoj Srivastava
Quoted 13 lines · Stephen Smalley
Quoted 3 lines

Re flex: What is the requirement for flex from selinux perspective? Is it known what build of flex is "known good"?

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

flex -V here also shows 2.5.35. But there are three patches in the Fedora package. Attached.

Quoted 7 lines
Quoted 6 lines

Debian currently carries 13 (though 3 of them need to be
squashed together) patches against 2.5.35. I can make them available if there is interest.

manoj

Yes please. Patches would be welcome.

Did you try the three patches that I attached to my email for flex?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#8 lore raw
Quoted 6 lines · Stephen Smalley
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Debian currently carries 13 (though 3 of them need to be
squashed together) patches against 2.5.35. I can make them available if there is interest.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

manoj

Yes please. Patches would be welcome.

Did you try the three patches that I attached to my email for flex?

Yes I did: applied patches and rebuilt checkpolicy-2.0.19, which did not resolve the issue.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#9 lore raw
Quoted 10 lines · Eric Laganowski
Quoted 9 lines · Stephen Smalley
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines

Debian currently carries 13 (though 3 of them need to be
squashed together) patches against 2.5.35. I can make them available if there is interest.

manoj

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Yes please. Patches would be welcome.

Did you try the three patches that I attached to my email for flex?

Yes I did: applied patches and rebuilt checkpolicy-2.0.19, which did not resolve the issue.

Curious. gcc -v?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#10 lore raw
Quoted 18 lines · Stephen Smalley
Quoted 16 lines · Eric Laganowski
Quoted 14 lines · Stephen Smalley
Quoted 14 lines
Quoted 11 lines
Quoted 3 lines

Debian currently carries 13 (though 3 of them need to be
squashed together) patches against 2.5.35. I can make them available if there is interest.

manoj

Yes please. Patches would be welcome.

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines

Did you try the three patches that I attached to my email for flex?

Yes I did: applied patches and rebuilt checkpolicy-2.0.19, which did not resolve the issue.

Curious. gcc -v?

$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.4.1/configure --prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-c99 --enable-long-long --enable-clocale=gnu --enable-languages=c,c++ --disable-multilib --disable-libstdcxx-pch
Thread model: posix
gcc version 4.4.1 (GCC for Cross-LFS 4.4.1.20090722)

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#11 lore raw
In reply to Stephen Smalley
Quoted 6 lines · Stephen Smalley

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

Just for reference, Gentoo only has the gcc44 one in portage (plus two others that seem unrelated), and it build the refpolicy fine here.

--Mike

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#12 lore raw
Quoted 9 lines · Mike Edenfield
Quoted 6 lines · Stephen Smalley

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

Quoted 9 lines

Just for reference, Gentoo only has the gcc44 one in portage (plus two others that seem unrelated), and it build the refpolicy fine here.

--Mike

Signature · 3 lines
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.

just looking at the Makefile there is some
stuff in there pointing to xmldtd,etc..
In the case like me(LFS) xmldtd was built
but gtkdoc was not. Wondering if one needs to
build the doc generating tools to not hit any
odd things.

Justin P. Mattock

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#13 lore raw

after adding most of the patches, and
using flex from git, still getting an error from checkpolicy. Now after searching
I ran into this:
http://aur.archlinux.org/packages.php?ID=13202
and sure enough after downgrading flex
the policy went through as it should.
(as for what/where? not sure, especially after adding most if not all patches to the latest flex).

Signature · 6 lines
Justin P. Mattock

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#14 lore raw
In reply to Eric Laganowski
Quoted 17 lines · Eric Laganowski
Quoted 16 lines · Manoj Srivastava
Quoted 13 lines · Stephen Smalley
Quoted 3 lines

Re flex: What is the requirement for flex from selinux perspective? Is it known what build of flex is "known good"?

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

flex -V here also shows 2.5.35. But there are three patches in the Fedora package. Attached.

Quoted 7 lines
Quoted 6 lines

Debian currently carries 13 (though 3 of them need to be
squashed together) patches against 2.5.35. I can make them available if there is interest.

manoj

Yes please. Patches would be welcome.

ok. I have put all the patches at:
http://www.golden-gryphon.com/software/misc/flex-patches/

If you want to browse the git repository and see which topic
branches these patches come from, you may browse the repo at:
http://git.debian.org/?p=users/srivasta/debian/flex.git

The upstream sources are in the upstream branch, and the various
topic--[!old]foo branches are feature branches, and master is the integration branch that Debian packages are built from.

I hope this helps.

manoj

Signature · 7 lines
Manoj Srivastava <[email protected]> <http://www.golden-gryphon.com/>  
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#15 lore raw
Quoted 40 lines · Manoj Srivastava
Quoted 20 lines · Eric Laganowski
Quoted 18 lines · Manoj Srivastava
Quoted 15 lines · Stephen Smalley
Quoted 4 lines

Re flex: What is the requirement for flex from selinux perspective? Is it known what build of flex is "known good"?

My impression is that one of the patches carried by the distributions for flex is needed for checkpolicy to work, but no one has ever fully investigated the precise dependency - people just grab the Fedora srpm and apply those patches to flex, and then rebuild checkpolicy and it works. I haven't seen any complaints from Debian or Gentoo so I presume that they also carry the same patches for flex.

flex -V here also shows 2.5.35. But there are three patches in the Fedora package. Attached.

Quoted 9 lines
Quoted 7 lines

Debian currently carries 13 (though 3 of them need to be
squashed together) patches against 2.5.35. I can make them available if there is interest.

manoj

Yes please. Patches would be welcome.

ok. I have put all the patches at:
http://www.golden-gryphon.com/software/misc/flex-patches/

If you want to browse the git repository and see which topic
branches these patches come from, you may browse the repo at:
http://git.debian.org/?p=users/srivasta/debian/flex.git

Quoted 8 lines

The upstream sources are in the upstream branch, and the various
topic--[!old]foo branches are feature branches, and master is the integration branch that Debian packages are built from.

I hope this helps.

manoj

Cool, thanks for those.
not sure if I'm hitting the same issue,
but I am hitting something.
from checkpolicy crapping out to not being able to install mcs/mls, only standard(but only on the first go of it) leading me to believe that I'm missing something during my build with some of the required packages.(system is an LFS build, things like this are the norm).

Justin P. Mattock

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.