summaryrefslogtreecommitdiff
path: root/udevtrigger.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-04-02 04:43:25 +0200
committerKay Sievers <kay.sievers@vrfy.org>2008-04-02 04:43:25 +0200
commitc7969cdbcb1f6d39177f6cc2e28597fabe186594 (patch)
tree911ae0237a456f87829aeb689f7e0be8a7b57fb4 /udevtrigger.c
parentc3b145a381090f18c4c5f4149e19183343880ec2 (diff)
also accept real socket files for RUN+="socket:<path>"
Diffstat (limited to 'udevtrigger.c')
-rw-r--r--udevtrigger.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/udevtrigger.c b/udevtrigger.c
index 4e3a8fab2d..e50fd4ee04 100644
--- a/udevtrigger.c
+++ b/udevtrigger.c
@@ -631,12 +631,24 @@ int udevtrigger(int argc, char *argv[], char *envp[])
}
if (sockpath != NULL) {
+ struct stat stats;
+
sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
memset(&saddr, 0x00, sizeof(struct sockaddr_un));
saddr.sun_family = AF_LOCAL;
- /* abstract namespace only */
- strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1);
- saddrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
+ if (sockpath[0] == '@') {
+ /* abstract namespace socket requested */
+ strlcpy(&saddr.sun_path[1], &sockpath[1], sizeof(saddr.sun_path)-1);
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
+ } else if (stat(sockpath, &stats) == 0 && S_ISSOCK(stats.st_mode)) {
+ /* existing socket file */
+ strlcpy(saddr.sun_path, sockpath, sizeof(saddr.sun_path));
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path);
+ } else {
+ /* no socket file, assume abstract namespace socket */
+ strlcpy(&saddr.sun_path[1], sockpath, sizeof(saddr.sun_path)-1);
+ saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
+ }
}
if (failed) {