Thor Simon
2010-06-25 02:55:51 UTC
Can anyone tell me why, exactly, we shouldn't remove bound AF_LOCAL
sockets from the filesystem on last close? The following test program
produces "second socket bind failed" on every system I've tested it on,
and seems to cover the only possible use case for this "feature"...
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <err.h>
#include <sysexits.h>
main()
{
int s = socket(PF_LOCAL, SOCK_DGRAM, 0);
struct sockaddr_un sun;
sun.sun_family = AF_UNIX;
sun.sun_len = sizeof(sun);
strlcpy(sun.sun_path, "/tmp/testdir/skt", sizeof(sun.sun_path));
mkdir("/tmp/testdir", 0700);
if (bind(s, (struct sockaddr *)&sun, sun.sun_len)) {
err(EX_OSERR, "first socket bind failed");
}
close(s);
s = socket(PF_LOCAL, SOCK_DGRAM, 0);
chmod("/tmp/testdir", 0500);
if (bind(s, (struct sockaddr *)&sun, sun.sun_len)) {
err(EX_NOPERM, "second socket bind failed");
}
}
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
sockets from the filesystem on last close? The following test program
produces "second socket bind failed" on every system I've tested it on,
and seems to cover the only possible use case for this "feature"...
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <err.h>
#include <sysexits.h>
main()
{
int s = socket(PF_LOCAL, SOCK_DGRAM, 0);
struct sockaddr_un sun;
sun.sun_family = AF_UNIX;
sun.sun_len = sizeof(sun);
strlcpy(sun.sun_path, "/tmp/testdir/skt", sizeof(sun.sun_path));
mkdir("/tmp/testdir", 0700);
if (bind(s, (struct sockaddr *)&sun, sun.sun_len)) {
err(EX_OSERR, "first socket bind failed");
}
close(s);
s = socket(PF_LOCAL, SOCK_DGRAM, 0);
chmod("/tmp/testdir", 0500);
if (bind(s, (struct sockaddr *)&sun, sun.sun_len)) {
err(EX_NOPERM, "second socket bind failed");
}
}
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de