fix: harden the per-user IPC endpoint

This commit is contained in:
2026-08-12 16:08:23 +09:00
parent 4120f90736
commit 432df3730c
9 changed files with 96 additions and 46 deletions

View File

@@ -2,8 +2,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <gtk/gtk.h>
#include "ipc.h"
@@ -27,20 +25,9 @@ static GType imtype;
static void
srvconnect(Im *im)
{
struct sockaddr_un addr;
if(im->fd >= 0)
return;
im->fd = socket(AF_UNIX, SOCK_STREAM, 0);
if(im->fd < 0)
return;
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path), IPCPATH, getuid());
if(connect(im->fd, (struct sockaddr*)&addr, sizeof(addr)) < 0){
close(im->fd);
im->fd = -1;
}
im->fd = ipcconnect();
}
static void