forked from external/yambar
commit
43de7c8da8
8 changed files with 20 additions and 26 deletions
|
@ -34,6 +34,9 @@
|
|||
* i3: fixed “missing workspace indicator” (_err: modules/i3.c:94:
|
||||
workspace reply/event without 'name' and/or 'output', and/or 'focus'
|
||||
properties_).
|
||||
* Slow/laggy behavior when quickly spawning many `on-click` handlers,
|
||||
e.g. when handling mouse wheel events
|
||||
(https://codeberg.org/dnkl/yambar/issues/169).
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
@ -621,7 +621,7 @@ run(struct module *mod)
|
|||
if (!i3_get_socket_address(&addr))
|
||||
return 1;
|
||||
|
||||
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
int sock = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
if (sock == -1) {
|
||||
LOG_ERRNO("failed to create UNIX socket");
|
||||
return 1;
|
||||
|
|
|
@ -223,7 +223,7 @@ wait_for_socket_create(const struct module *mod)
|
|||
struct stat st;
|
||||
if (stat(m->host, &st) == 0 && S_ISSOCK(st.st_mode)) {
|
||||
|
||||
int s = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
int s = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
|
||||
struct sockaddr_un addr = {.sun_family = AF_UNIX};
|
||||
strncpy(addr.sun_path, m->host, sizeof(addr.sun_path) - 1);
|
||||
|
|
|
@ -167,7 +167,7 @@ nl_pid_value(void)
|
|||
static int
|
||||
netlink_connect_rt(void)
|
||||
{
|
||||
int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||
int sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
|
||||
if (sock == -1) {
|
||||
LOG_ERRNO("failed to create netlink socket");
|
||||
return -1;
|
||||
|
@ -191,7 +191,7 @@ netlink_connect_rt(void)
|
|||
static int
|
||||
netlink_connect_genl(void)
|
||||
{
|
||||
int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
|
||||
int sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_GENERIC);
|
||||
if (sock == -1) {
|
||||
LOG_ERRNO("failed to create netlink socket");
|
||||
return -1;
|
||||
|
|
|
@ -164,11 +164,17 @@ content(struct module *mod)
|
|||
static void
|
||||
find_mount_points(const char *dev_path, mount_point_list_t *mount_points)
|
||||
{
|
||||
FILE *f = fopen("/proc/self/mountinfo", "r");
|
||||
assert(f != NULL);
|
||||
int fd = open("/proc/self/mountinfo", O_RDONLY | O_CLOEXEC);
|
||||
FILE *f = fd >= 0 ? fdopen(fd, "r") : NULL;
|
||||
|
||||
if (fd < 0 || f == NULL) {
|
||||
LOG_ERRNO("failed to open /proc/self/mountinfo");
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
char line[4096];
|
||||
|
||||
while (fgets(line, sizeof(line), f) != NULL) {
|
||||
char *dev = NULL, *path = NULL;
|
||||
|
||||
|
@ -641,7 +647,7 @@ run(struct module *mod)
|
|||
|
||||
/* To be able to poll() mountinfo for changes, to detect
|
||||
* mount/unmount operations */
|
||||
int mount_info_fd = open("/proc/self/mountinfo", O_RDONLY);
|
||||
int mount_info_fd = open("/proc/self/mountinfo", O_RDONLY | O_CLOEXEC);
|
||||
|
||||
int ret = 1;
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ execute_script(struct module *mod)
|
|||
|
||||
/* Stdout redirection pipe */
|
||||
int comm_pipe[2];
|
||||
if (pipe(comm_pipe) < 0) {
|
||||
if (pipe2(comm_pipe, O_CLOEXEC) < 0) {
|
||||
LOG_ERRNO("failed to create stdin/stdout redirection pipe");
|
||||
close(exec_pipe[0]);
|
||||
close(exec_pipe[1]);
|
||||
|
@ -444,7 +444,7 @@ execute_script(struct module *mod)
|
|||
close(comm_pipe[0]);
|
||||
|
||||
/* Re-direct stdin/stdout */
|
||||
int dev_null = open("/dev/null", O_RDONLY);
|
||||
int dev_null = open("/dev/null", O_RDONLY | O_CLOEXEC);
|
||||
if (dev_null < 0)
|
||||
goto fail;
|
||||
|
||||
|
@ -458,16 +458,6 @@ execute_script(struct module *mod)
|
|||
close(comm_pipe[1]);
|
||||
comm_pipe[1] = -1;
|
||||
|
||||
/* Close *all* other FDs */
|
||||
for (int i = STDERR_FILENO + 1; i < 65536; i++) {
|
||||
if (i == exec_pipe[1]) {
|
||||
/* Needed for error reporting. Automatically closed
|
||||
* when execvp() succeeds */
|
||||
continue;
|
||||
}
|
||||
close(i);
|
||||
}
|
||||
|
||||
execvp(m->path, argv);
|
||||
|
||||
fail:
|
||||
|
|
|
@ -267,7 +267,7 @@ run(struct module *mod)
|
|||
if (!i3_get_socket_address(&addr))
|
||||
return 1;
|
||||
|
||||
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
int sock = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
if (sock == -1) {
|
||||
LOG_ERRNO("failed to create UNIX socket");
|
||||
return 1;
|
||||
|
|
|
@ -277,11 +277,6 @@ exposable_default_on_mouse(struct exposable *exposable, struct bar *bar,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
/* Close *all* other FDs (e.g. script modules' FDs) */
|
||||
for (int i = STDERR_FILENO + 1; i < 65536; i++)
|
||||
if (i != pipe_fds[1])
|
||||
close(i);
|
||||
|
||||
execvp(argv[0], argv);
|
||||
|
||||
fail:
|
||||
|
|
Loading…
Add table
Reference in a new issue