Skip to contentSkip to conversation

load_policy.c:351:1: error: "MNT_DETACH" redefined

PATCH Justin Mattock 2 participants 5 messages Apr 29, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

I get an error while compiling libselinux
with a simple "make"

load_policy.c:351:1: error: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: error: this is the location of the previous definition
make[1]: *** [load_policy.o] Error 1
make[1]: Leaving directory `/home/name/LFS/SELinux/libselinux-2.0.79/src'
make: *** [all] Error 2

but if I:
make CC="/usr/bin/i686-pc-linux-gnu-gcc-4.4.0" CFLAGS="-march=core2 -mtune=core2 -pipe -O2 -fomit-frame-pointer" CXXFLAGS="${CFLAGS}" MAKEOPTS="{-j3}"
libselinux will compiled with just a:

load_policy.c:351:1: warning: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: warning: this is the location of the previous definition

if I change load_policy.c(to the best of my knowledge) with the attached patch
and then run make normally
libselinux will compile

Signature · 1 line
Justin P. Mattock

libselinux compiles with CCFLAGS set, but a normal "make" results in:

load_policy.c:351:1: error: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: error: this is the location of the previous definition make[1]: *** [load_policy.o] Error 1
make[1]: Leaving directory `/home/name/LFS/SELinux/libselinux-2.0.79/src'
make: *** [all] Error 2

load_policy.c 2009-04-28 22:09:02.000000000 -0700 renamed from load_policy.c 2009-04-28 22:04:40.000000000 -0700 +1 -1
@@ -348,7 +348,7 @@
                fclose(cfg);
                free(buf);
        }
-#define MNT_DETACH 2
+#define MNT_DETACH MNT_DETACH
        if (rc == 0)
                umount2("/proc", MNT_DETACH);
 
#1 lore raw
Quoted 23 lines · Justin Mattock

I get an error while compiling libselinux
with a simple "make"

load_policy.c:351:1: error: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: error: this is the location of the previous definition
make[1]: *** [load_policy.o] Error 1
make[1]: Leaving directory `/home/name/LFS/SELinux/libselinux-2.0.79/src'
make: *** [all] Error 2

but if I:
make CC="/usr/bin/i686-pc-linux-gnu-gcc-4.4.0" CFLAGS="-march=core2 -mtune=core2 -pipe -O2 -fomit-frame-pointer" CXXFLAGS="${CFLAGS}" MAKEOPTS="{-j3}"
libselinux will compiled with just a:

load_policy.c:351:1: warning: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: warning: this is the location of the previous definition

Quoted 4 lines

if I change load_policy.c(to the best of my knowledge) with the attached patch
and then run make normally
libselinux will compile

Your patch doesn't make sense - defining a symbol to itself. If the symbol were always defined in sys/mount.h, one would just remove the duplicate definition from load_policy.c. But it isn't defined in sys/mount.h in any version of glibc that I can see, and thus has to at least be conditionally defined in load_policy.c. Now, you could bracket it with:
#ifndef MNT_DETACH
#define MNT_DETACH 2
#endif

Then it will build correctly with either set of headers. Out of curiosity, where are you obtaining your sys/mount.h from?

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 39 lines · Stephen Smalley
Quoted 23 lines · Justin Mattock

I get an error while compiling libselinux
with a simple "make"

load_policy.c:351:1: error: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: error: this is the location of the previous definition
make[1]: *** [load_policy.o] Error 1
make[1]: Leaving directory `/home/name/LFS/SELinux/libselinux-2.0.79/src'
make: *** [all] Error 2

but if I:
make CC="/usr/bin/i686-pc-linux-gnu-gcc-4.4.0" CFLAGS="-march=core2 -mtune=core2 -pipe -O2 -fomit-frame-pointer" CXXFLAGS="${CFLAGS}" MAKEOPTS="{-j3}"
libselinux will compiled with just a:

load_policy.c:351:1: warning: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: warning: this is the location of the previous definition

Quoted 4 lines

if I change load_policy.c(to the best of my knowledge) with the attached patch
and then run make normally
libselinux will compile

Your patch doesn't make sense - defining a symbol to itself.  If the symbol were always defined in sys/mount.h, one would just remove the duplicate definition from load_policy.c.  But it isn't defined in sys/mount.h in any version of glibc that I can see, and thus has to at least be conditionally defined in load_policy.c.  Now, you could bracket it with:
#ifndef MNT_DETACH
#define MNT_DETACH 2
#endif

Quoted 8 lines

Then it will build correctly with either set of headers. Out of curiosity, where are you obtaining your sys/mount.h from?

--
Stephen Smalley
National Security Agency

yeah I admit it, I frantically looked in sys/mount.h for any kind of hints(which lead to what I had created).

As for what version I have, sounds like these are headers from libc. In that case, it's the latest from:
ftp://sources.redhat.com/pub/glibc/snapshots/ version glibc-2.9-20090427.tar.bz2

As for you're idea: bracketing it, well
this is why you make the big bucks,
and I'm stuck working at MCDonalds
;^)

Signature · 7 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.
#3 lore raw
Quoted 49 lines · Justin Mattock
Quoted 39 lines · Stephen Smalley
Quoted 23 lines · Justin Mattock

I get an error while compiling libselinux
with a simple "make"

load_policy.c:351:1: error: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: error: this is the location of the previous definition
make[1]: *** [load_policy.o] Error 1
make[1]: Leaving directory `/home/name/LFS/SELinux/libselinux-2.0.79/src'
make: *** [all] Error 2

but if I:
make CC="/usr/bin/i686-pc-linux-gnu-gcc-4.4.0" CFLAGS="-march=core2 -mtune=core2 -pipe -O2 -fomit-frame-pointer" CXXFLAGS="${CFLAGS}" MAKEOPTS="{-j3}"
libselinux will compiled with just a:

load_policy.c:351:1: warning: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: warning: this is the location of the previous definition

Quoted 4 lines

if I change load_policy.c(to the best of my knowledge) with the attached patch
and then run make normally
libselinux will compile

Your patch doesn't make sense - defining a symbol to itself. If the symbol were always defined in sys/mount.h, one would just remove the duplicate definition from load_policy.c. But it isn't defined in sys/mount.h in any version of glibc that I can see, and thus has to at least be conditionally defined in load_policy.c. Now, you could bracket it with:
#ifndef MNT_DETACH
#define MNT_DETACH 2
#endif

Quoted 8 lines

Then it will build correctly with either set of headers. Out of curiosity, where are you obtaining your sys/mount.h from?

--
Stephen Smalley
National Security Agency

Quoted 7 lines

yeah I admit it, I frantically looked in sys/mount.h for any kind of hints(which lead to what I had created).

As for what version I have, sounds like these are headers from libc. In that case, it's the latest from:
ftp://sources.redhat.com/pub/glibc/snapshots/ version glibc-2.9-20090427.tar.bz2

I see - the definition was added 5 days ago to the glibc source tree. So, yes, we'll want to wrap the definition of MNT_DETACH as above, but we still need to keep the fallback definition for older glibc and for alternative libc implementations that lack the definition altogether.

Quoted 4 lines

As for you're idea: bracketing it, well
this is why you make the big bucks,
and I'm stuck working at MCDonalds
;^)

Hey, at least you have happy customers.

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.
#4 lore raw
Quoted 68 lines · Stephen Smalley
Quoted 49 lines · Justin Mattock
Quoted 39 lines · Stephen Smalley
Quoted 23 lines · Justin Mattock

I get an error while compiling libselinux
with a simple "make"

load_policy.c:351:1: error: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: error: this is the location of the previous definition
make[1]: *** [load_policy.o] Error 1
make[1]: Leaving directory `/home/name/LFS/SELinux/libselinux-2.0.79/src'
make: *** [all] Error 2

but if I:
make CC="/usr/bin/i686-pc-linux-gnu-gcc-4.4.0" CFLAGS="-march=core2 -mtune=core2 -pipe -O2 -fomit-frame-pointer" CXXFLAGS="${CFLAGS}" MAKEOPTS="{-j3}"
libselinux will compiled with just a:

load_policy.c:351:1: warning: "MNT_DETACH" redefined
In file included from load_policy.c:5:
/usr/include/sys/mount.h:102:1: warning: this is the location of the previous definition

Quoted 4 lines

if I change load_policy.c(to the best of my knowledge) with the attached patch
and then run make normally
libselinux will compile

Your patch doesn't make sense - defining a symbol to itself.  If the symbol were always defined in sys/mount.h, one would just remove the duplicate definition from load_policy.c.  But it isn't defined in sys/mount.h in any version of glibc that I can see, and thus has to at least be conditionally defined in load_policy.c.  Now, you could bracket it with:
#ifndef MNT_DETACH
#define MNT_DETACH 2
#endif

Quoted 8 lines

Then it will build correctly with either set of headers. Out of curiosity, where are you obtaining your sys/mount.h from?

--
Stephen Smalley
National Security Agency

Quoted 7 lines

yeah I admit it, I frantically looked in sys/mount.h for any kind of hints(which lead to what I had created).

As for what version I have, sounds like these are headers from libc. In that case,  it's the latest from:
ftp://sources.redhat.com/pub/glibc/snapshots/ version glibc-2.9-20090427.tar.bz2

I see - the definition was added 5 days ago to the glibc source tree. So, yes, we'll want to wrap the definition of MNT_DETACH as above, but we still need to keep the fallback definition for older glibc and for alternative libc implementations that lack the definition altogether.

Quoted 4 lines

As for you're idea: bracketing it, well
this is why you make the big bucks,
and I'm stuck working at MCDonalds
;^)

Quoted 7 lines

Hey, at least you have happy customers.

--
Stephen Smalley
National Security Agency

I'm just having a little fun!!

Anyways I think the best approach is how
you had handled the fix(rather than what I had done). If need be I can go and try what you had suggested to make sure everything is legit.

Signature · 7 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.