LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Closed Thread
  Search this Thread
Old 08-17-2006, 02:32 PM   #1
arvind.ayyangar
LQ Newbie
 
Registered: Aug 2006
Posts: 17

Rep: Reputation: 0
Question hacking the /org/freedesktop/hal/udev_event socket


hi ppl,

i am trying to hack hal and recieve the data that is sent by udev to hal thru sockets.... the code i ave written is at the end...
the problem is that i never recieve any data on polling event though i should be recieving ( and i know that udev has written data on the socket). is there any care i need to take while hacking sockets used by system daemon?



void osspec_init()
{
int/* udev_socket,*/on=1;
struct sockaddr_un saddr;
GIOChannel *udev_channel;
socklen_t addrlen;
memset(&saddr,0x00,sizeof(saddr));

saddr.sun_family=AF_LOCAL;
strcpy(&saddr.sun_path[1],"/org/freedesktop/hal/udev_event");
addrlen=offsetof(struct sockaddr_un,sun_path) + strlen(saddr.sun_path + 1);

udev_socket=socket(AF_LOCAL,SOCK_DGRAM,0);
if(udev_socket<0){
printf("Error creating socket");
exit(0);
}
printf("\nSocket created..");
if((bind(udev_socket,(struct sockaddr *) &saddr,addrlen))<0){
printf("\nError binding socket..");
exit(1);
}
/* enable receiving of the sender credentials */
setsockopt(udev_socket, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
listen(udev_socket,5);
}

int main()
{
char buf[1024];
int data;
struct msghdr smsg;
struct iovec iov;
struct sockaddr *client_addr;
struct ucred *cred;
char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
osspec_init();
memset(buf,0x0,sizeof(buf));
memset(&smsg,0x0,sizeof(struct msghdr)) ;
iov.iov_base=&buf;
iov.iov_len=sizeof(buf);
smsg.msg_iov = &iov;
smsg.msg_iovlen = 1;
smsg.msg_control = cred_msg;
smsg.msg_controllen = sizeof (cred_msg);


while(1){
accept(udev_socket,client_addr,(socklen_t*)sizeof(client_addr));
data=recvmsg(udev_socket,&smsg,0);
if(data>0)
printf("\nMessage recieved: %s",smsg.msg_iov->iov_base);

}
close(udev_socket);

}


maybe there is a small mistake in the code, but i am unable to debug it? Sorry for the same..
 
Old 08-17-2006, 04:19 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Continue here
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
freedesktop.org down? Brent74 Linux - Software 6 06-19-2017 06:29 PM
Freedesktop.org grassmunk Slackware 3 06-18-2004 09:20 AM
Xserver (freedesktop.org) SciYro Linux - Software 0 02-27-2004 04:17 AM
freedesktop.org on slackware uglyugly Slackware 3 02-18-2004 03:54 AM
dri.freedesktop.org vladilinsky Linux - Software 1 02-14-2004 12:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration