mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-30 06:25:25 +03:00
[PATCH] udevd - fix socket path length
It seems that the guys are no longer differ about the right size of the socket address :) The kernel simply takes all bytes until the specified length as the name, so the real length should be enough.
This commit is contained in:
parent
872344c410
commit
1dadabd79b
4
udevd.c
4
udevd.c
@ -360,6 +360,7 @@ int main(int argc, char *argv[])
|
||||
int csock;
|
||||
struct sockaddr_un saddr;
|
||||
struct sockaddr_un caddr;
|
||||
socklen_t addrlen;
|
||||
socklen_t clen;
|
||||
pthread_t cli_tid;
|
||||
pthread_t mgr_msg_tid;
|
||||
@ -379,6 +380,7 @@ int main(int argc, char *argv[])
|
||||
saddr.sun_family = AF_LOCAL;
|
||||
/* use abstract namespace for socket path */
|
||||
strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
|
||||
addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
|
||||
|
||||
ssock = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||
if (ssock == -1) {
|
||||
@ -386,7 +388,7 @@ int main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
retval = bind(ssock, &saddr, sizeof(saddr));
|
||||
retval = bind(ssock, &saddr, addrlen);
|
||||
if (retval < 0) {
|
||||
dbg("bind failed\n");
|
||||
goto exit;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
@ -124,6 +125,7 @@ int main(int argc, char* argv[])
|
||||
struct timespec tspec;
|
||||
int sock;
|
||||
struct sockaddr_un saddr;
|
||||
socklen_t addrlen;
|
||||
|
||||
#ifdef DEBUG
|
||||
init_logging("udevsend");
|
||||
@ -163,9 +165,10 @@ int main(int argc, char* argv[])
|
||||
saddr.sun_family = AF_LOCAL;
|
||||
/* use abstract namespace for socket path */
|
||||
strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
|
||||
addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
|
||||
|
||||
/* try to connect, if it fails start daemon */
|
||||
retval = connect(sock, (struct sockaddr *) &saddr, sizeof(saddr));
|
||||
retval = connect(sock, (struct sockaddr *) &saddr, addrlen);
|
||||
if (retval != -1) {
|
||||
goto send;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user