ipq_read error
Hello!
I'm using libipq's ipq_read function in a program to read packets that were queued to userspace by a kernel module.
When I run the program as root everything is fine. ipq_read gets all the queued messages. If the program is run with user privileges ipq_read fails. ipq_get_msgerr(buf) returns 1 and ipq_errstr returns "Unknown error".
In the program I do the following:
[left out]
int status;
unsigned char buf[2048];
struct ipq_handle *h;
h = ipq_create_handle(0, PF_INET);
if (!h)
die(h);
status = ipq_set_mode(h, IPQ_COPY_PACKET, BUFSIZE); if (status < 0)
die(h);
status = ipq_read(h, buf, BUFSIZE, 0);printf("Received packet!\n");
if (status < 0)
die(h);
printf("Alive!\n");
switch (ipq_message_type(buf)) {
case NLMSG_ERROR:
fprintf(stderr, "Received error message %d\n",
ipq_get_msgerr(buf));
break;[left out]
Does ipq_read really needs root privileges or are there other solutions? Any help on this is appreciated.
Cheers
Peter
Signature · 2 lines
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko! Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
Hi,
Quoted 6 lines · Le jeudi 27 octobre 2005 à 12:08 +0200, [email protected] a écrit :
Hello!
I'm using libipq's
ipq_readfunction in a program to read packets that were queued to userspace by a kernel module.
Doesipq_readreally needs root privileges or are there other solutions? Any help on this is appreciated.
As the program is directly talking to the kernel, you need to be root to be able to access libipq.
A standard solution is to switch to a given user as soon as you do not need anymore root privileges.
BR,
Signature · 3 lines
Éric Leblond, [email protected] Téléphone : 01 44 89 46 40, Fax : 01 44 89 45 01 INL, http://www.inl.fr