From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: [patch] udevd - switch socket path to abstract namespace
Date: Thu, 05 Feb 2004 09:19:00 +0000 [thread overview]
Message-ID: <20040205091900.GA2123@vrfy.org> (raw)
In-Reply-To: <20040205010748.GA1247@vrfy.org>
[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]
On Wed, Feb 04, 2004 at 05:37:35PM -0800, Greg KH wrote:
> On Thu, Feb 05, 2004 at 02:07:48AM +0100, Kay Sievers wrote:
> >
> > As Chris Friesen <chris_friesen@sympatico.ca> suggested, here we switch
> > the unix domains socket path to abstract namespace and get rid of the
> > socket file in the filesystem.
> >
> > Hey, this was new to me today. So here a few words:
> > Linux supports a abstract namespace for sockets. We don't need a
> > physical file on the filesystem but only a unique string magically
> > starting with the '\0' character.
> >
> > strace with real file:
> > connect(3, {sa_family=AF_UNIX, path="/udev/.udevd.sock"}, 110)
> >
> > strace with abstract namespace:
> > connect(3, {sa_family=AF_UNIX, path=@udevd}, 110)
>
> That's nice to know.
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.
thanks,
Kay
[-- Attachment #2: 01-socketpathlen.patch --]
[-- Type: text/plain, Size: 1675 bytes --]
===== udevd.c 1.12 vs edited =====
--- 1.12/udevd.c Thu Feb 5 02:42:59 2004
+++ edited/udevd.c Thu Feb 5 09:32:51 2004
@@ -360,6 +360,7 @@
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 @@
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 @@
exit(1);
}
- retval = bind(ssock, &saddr, sizeof(saddr));
+ retval = bind(ssock, &saddr, addrlen);
if (retval < 0) {
dbg("bind failed\n");
goto exit;
===== udevsend.c 1.16 vs edited =====
--- 1.16/udevsend.c Thu Feb 5 02:41:47 2004
+++ edited/udevsend.c Thu Feb 5 09:40:58 2004
@@ -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 @@
struct timespec tspec;
int sock;
struct sockaddr_un saddr;
+ socklen_t addrlen;
#ifdef DEBUG
init_logging("udevsend");
@@ -163,9 +165,10 @@
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 {
next prev parent reply other threads:[~2004-02-05 9:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-05 1:07 [patch] udevd - switch socket path to abstract namespace Kay Sievers
2004-02-05 1:37 ` Greg KH
2004-02-05 9:19 ` Kay Sievers [this message]
2004-02-06 0:11 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040205091900.GA2123@vrfy.org \
--to=kay.sievers@vrfy.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).