fix: harden the per-user IPC endpoint
This commit is contained in:
15
gtk/main.c
15
gtk/main.c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user