Unix Programming - Linux capabilities set compilation errors

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2004 > Linux capabilities set compilation errors





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Linux capabilities set compilation errors
Karthik

2004-06-26, 10:10 am

Hi ppl,

I am trying to use the linux capabilities set in my program. The
compilation gives me an error with regards to the header files included
by the distribution.

A sample compilation session errors are:
----------
# make init
cc -c -Wall -O2 -D_GNU_SOURCE init.c
In file included from /usr/include/linux/vfs.h:4,
from /usr/include/linux/fs.h:13,
from /usr/include/linux/capability.h:17,
from init.c:51:
/usr/include/asm/statfs.h:20: parse error before "__kernel_fsid_t"
/usr/include/asm/statfs.h:23: parse error before '}' token
In file included from init.c:51:
/usr/include/linux/capability.h:33: parse error before "__u32"
/usr/include/linux/capability.h:35: parse error before '}' token
/usr/include/linux/capability.h:38: parse error before "__u32"
/usr/include/linux/capability.h:40: parse error before "inheritable"
init.c: In function `init_main':
init.c:2306: parse error before "header"
init.c:2305: warning: unused variable `head'
make: *** [init.o] Error 1
#
----------

The lines in questions from the init.c files are:

---------
51: #include <linux/capability.h>
.......
.......
2305: cap_user_header_t header;
2306: cap_user_data_t data;
---------

If i comment out the above 3 lines from the program the program compiles
just fine. The same set of declaration are being used in
/usr/src/`uname-r`/kernel/capability.c file. All the error messages are
related to the header files. I have tested this on Mandrake 10 and
Slackware 9.0. Both the distros give exactly the same error message.

Has anybody else faced similar problems ?


TIA
Karthik

Juha Laiho

2004-06-26, 10:10 am

Karthik <karthik@nospam.com> said:
>I am trying to use the linux capabilities set in my program. The
>compilation gives me an error with regards to the header files included
>by the distribution.


You shouldn't (typically) be using <linux/*.h> header files directly in
user-space programs (they're mostly for writing kernel code).

Is <sys/capability.h> perhaps what you're looking for?
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
Karthik

2004-06-26, 10:10 am

Juha Laiho wrote:
>
> You shouldn't (typically) be using <linux/*.h> header files directly in
> user-space programs (they're mostly for writing kernel code).
>
> Is <sys/capability.h> perhaps what you're looking for?


The file sys/capability.h is not present on my system, instead the file
linux/capability.h was present. Thats the reason i was using that file.

If there is a place from where i could download and install those
headers it would be helpful. I was not able to find anything appropriate.

Thanks

Karthik

Igmar Palsenberg

2004-06-26, 10:10 am

Karthik wrote:
> Juha Laiho wrote:
>
>
>
> The file sys/capability.h is not present on my system, instead the file
> linux/capability.h was present. Thats the reason i was using that file.


linux/capability is header file for kernelspace. It is not usuable in
userspace.

You need libcap from
ftp://ftp.kernel.org/pub/linux/libs...ivs/kernel-2.2/

which privides a sys/capability.h



Igmar
Karthik

2004-06-26, 10:11 am

Igmar Palsenberg wrote:
>
>
> linux/capability is header file for kernelspace. It is not usuable in
> userspace.
>
> You need libcap from
> ftp://ftp.kernel.org/pub/linux/libs...ivs/kernel-2.2/
>
> which privides a sys/capability.h
>
>
>
> Igmar


I downloaded the kernel-2.4 version and installed it on my system. Even
then the errors wont go away as the file sys/capability.h includes
linux/capability.h internally ;).

I am stuck at the same point again.

Thanks

Karthik

Igmar Palsenberg

2004-06-26, 10:11 am

Karthik wrote:

> I downloaded the kernel-2.4 version and installed it on my system. Even
> then the errors wont go away as the file sys/capability.h includes
> linux/capability.h internally ;).


Then your includes are broken. I've also got libcap (and headers) on
this system, and

#include <sys/capability.h>

int main(int argc, char **argv)
{
cap_t x;

x = cap_get_fd(0);

return 0;
}

works. You DO have kernel headers file on your system that match your
kernel ? (and where /usr/include/linux/ is either from your libc, or a
linux to the kernel sources include dir)



Igmar
Karthik

2004-06-26, 11:25 pm

Igmar Palsenberg wrote:
> Karthik wrote:
>
>
>
> Then your includes are broken. I've also got libcap (and headers) on
> this system, and
>
> #include <sys/capability.h>
>
> int main(int argc, char **argv)
> {
> cap_t x;
>
> x = cap_get_fd(0);
>
> return 0;
> }
>
> works. You DO have kernel headers file on your system that match your
> kernel ? (and where /usr/include/linux/ is either from your libc, or a
> linux to the kernel sources include dir)
>
>
>
> Igmar


The above program did not compile for me. SO i guess i have my includes
messed up. This is a Slackware 9.0 installation and i did'nt install the
sources at that time, so i am not sure what header files i have under
/usr/include/linux

I will download a different 2.4.x kernel and recompile it and install
the header files. Is there any special way to install these header files
or just copy them over from /usr/src/linux-xxx/include/linux to
/usr/include/

Is the above a safe way of doing it ?

TIA

karthik

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com