Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Mark as cloexec left directories open
Baptiste Daroussin committed 9 years ago
commit 98c70cbf7ba5a066d5f6c0c120822d979e93647d
parent b2f3794
2 files changed +4 -4
modified libpkg/pkg_config.c
@@ -773,7 +773,7 @@ load_repo_files(const char *repodir, pkg_init_flags flags)
	int nents, i, fd;

	pkg_debug(1, "PkgConfig: loading repositories in %s", repodir);
-
	if ((fd = open(repodir, O_DIRECTORY)) == -1)
+
	if ((fd = open(repodir, O_DIRECTORY|O_CLOEXEC)) == -1)
		return;

	nents = scandir(repodir, &ent, configfile, alphasort);
@@ -1433,7 +1433,7 @@ pkg_get_cachedirfd(void)
		 * do not check the value as if we cannot open it means
		 * it has not been created yet
		 */
-
		cachedirfd = open(cachedir, O_DIRECTORY);
+
		cachedirfd = open(cachedir, O_DIRECTORY|O_CLOEXEC);
	}

	return (cachedirfd);
@@ -1450,7 +1450,7 @@ pkg_get_dbdirfd(void)
		 * do not check the value as if we cannot open it means
		 * it has not been created yet
		 */
-
		pkg_dbdirfd = open(dbdir, O_DIRECTORY);
+
		pkg_dbdirfd = open(dbdir, O_DIRECTORY|O_CLOEXEC);
	}

	return (pkg_dbdirfd);
modified src/ssh.c
@@ -69,7 +69,7 @@ exec_ssh(int argc, char **argv __unused)
	if (restricted == NULL)
		restricted = "/";

-
	if ((fd = open(restricted, O_DIRECTORY|O_RDONLY)) < 0) {
+
	if ((fd = open(restricted, O_DIRECTORY|O_RDONLY|O_CLOEXEC)) < 0) {
		warn("Impossible to open the restricted directory");
		return (EX_SOFTWARE);
	}