Skip to content
Myr

Yet more O_CLOEXEC

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 1b8ef56 · Browse files · 3 files+13 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+13 added−13 removed

  • other:+13 added−13 removed

3 files+13 added−13 removed

modified:config.c+2 added-2 removed
738 unmodified lines
739 free(_include_path);740 return false;741 }742743 FILE *include = fopen(include_path, "r");743 FILE *include = fopen(include_path, "re");744745 if (include == NULL) {746 LOG_CONTEXTUAL_ERRNO("failed to open");747 free(_include_path);
926 unmodified lines
1674 conf->terminal = xstrjoin(terminal, " -e");1675 }16761677 if (conf_path != NULL) {1678 int fd = open(conf_path, O_RDONLY);1678 int fd = open(conf_path, O_RDONLY | O_CLOEXEC);1679 if (fd < 0) {1680 LOG_ERRNO("%s: failed to open", conf_path);1681 goto out;1682 }
63 unmodified lines
modified:icon.c+2 added-2 removed
628 unmodified lines
629 break;630 }631632 int dir_fd = openat(633 xdg_dir->fd, theme_relative_path, O_RDONLY | O_DIRECTORY);633 xdg_dir->fd, theme_relative_path, O_RDONLY | O_DIRECTORY | O_CLOEXEC);634 if (dir_fd < 0)635 continue;636637 tll_foreach(icons, icon_it) {
89 unmodified lines
727 tll_foreach(icons, icon_it) {728 const struct icon_data *icon = &icon_it->item;729730 tll_foreach(*xdg_dirs, it) {731 int pixmaps_fd = openat(it->item.fd, "pixmaps", O_RDONLY);731 int pixmaps_fd = openat(it->item.fd, "pixmaps", O_RDONLY | O_CLOEXEC);732 if (pixmaps_fd < 0)733 continue;734735 size_t len = icon->file_name_len;
45 unmodified lines
modified:xdg.c+9 added-9 removed
88 unmodified lines
89 bool filter_desktops, char_list_t *desktops,90 const struct locale_variants *lc_messages,91 application_llist_t *applications)92{93 FILE *f = fdopen(fd, "r");93 FILE *f = fdopen(fd, "re");94 if (f == NULL)95 return;9697 bool is_desktop_entry = false;
447 unmodified lines
545 continue;546 }547548 if (S_ISDIR(st.st_mode)) {549 int dir_fd = openat(base_fd, e->d_name, O_RDONLY);549 int dir_fd = openat(base_fd, e->d_name, O_RDONLY | O_CLOEXEC);550 if (dir_fd == -1) {551 LOG_ERRNO("%s: failed to open", e->d_name);552 continue;553 }
14 unmodified lines
568 if (strcmp(&e->d_name[name_len - desktop_len], ".desktop") != 0)569 continue;570571 //LOG_DBG("%s", e->d_name);572 int fd = openat(base_fd, e->d_name, O_RDONLY);572 int fd = openat(base_fd, e->d_name, O_RDONLY | O_CLOEXEC);573 if (fd == -1)574 LOG_WARN("%s: failed to open: %s", e->d_name, strerror(errno));575 else {576 const char *file_basename = strrchr(e->d_name, '/');
64 unmodified lines
641 tll_foreach(dirs, it) {642 char path[strlen(it->item.path) + 1 + strlen("applications") + 1];643 sprintf(path, "%s/applications", it->item.path);644645 int fd = open(path, O_RDONLY);645 int fd = open(path, O_RDONLY | O_CLOEXEC);646 if (fd != -1) {647 scan_dir(fd, terminal, include_actions, filter_desktop, desktops, &apps, NULL);648 close(fd);649 }
79 unmodified lines
729730 const char *xdg_data_home = getenv("XDG_DATA_HOME");731 const char *home;732 if (xdg_data_home != NULL && xdg_data_home[0] != '\0') {733 int fd = open(xdg_data_home, O_RDONLY | O_DIRECTORY);733 int fd = open(xdg_data_home, O_RDONLY | O_DIRECTORY | O_CLOEXEC);734 if (fd >= 0) {735 struct xdg_data_dir d = {.fd = fd, .path = xstrdup(xdg_data_home)};736 tll_push_back(ret, d);737 }738 } else if ((home = getenv("HOME")) != NULL && home[0] != '\0') {739 char *path = xstrjoin(home, "/.local/share");740 int fd = open(path, O_RDONLY | O_DIRECTORY);740 int fd = open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC);741 if (fd >= 0) {742 struct xdg_data_dir d = {.fd = fd, .path = path};743 tll_push_back(ret, d);744 } else
10 unmodified lines
755 for (const char *tok = strtok_r(copy, ":", &ctx);756 tok != NULL;757 tok = strtok_r(NULL, ":", &ctx))758 {759 int fd = open(tok, O_RDONLY | O_DIRECTORY);759 int fd = open(tok, O_RDONLY | O_DIRECTORY | O_CLOEXEC);760 if (fd >= 0) {761 struct xdg_data_dir d = {.fd = fd, .path = xstrdup(tok)};762 tll_push_back(ret, d);763 }764 }765766 free(copy);767 } else {768 int fd1 = open("/usr/local/share", O_RDONLY | O_DIRECTORY);769 int fd2 = open("/usr/share", O_RDONLY | O_DIRECTORY);768 int fd1 = open("/usr/local/share", O_RDONLY | O_DIRECTORY | O_CLOEXEC);769 int fd2 = open("/usr/share", O_RDONLY | O_DIRECTORY | O_CLOEXEC);770771 if (fd1 >= 0) {772 struct xdg_data_dir d = {.fd = fd1, .path = xstrdup("/usr/local/share")};773 tll_push_back(ret, d);
37 unmodified lines