Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add CLOEXEC where needed
Baptiste Daroussin committed 9 years ago
commit b2f3794b655275785764633d4aba1ba2ae882ad4
parent bda7542
6 files changed +8 -8
modified libpkg/clean_cache.c
@@ -46,7 +46,7 @@ rm_rf(int basefd, const char *path)
		while (*path == '/')
			path++;

-
		dirfd = openat(basefd, path, O_DIRECTORY);
+
		dirfd = openat(basefd, path, O_DIRECTORY|O_CLOEXEC);
		if (dirfd == -1) {
			pkg_emit_errno("openat", path);
			return;
modified libpkg/pkg_add.c
@@ -227,7 +227,7 @@ set_attrs(int fd, char *path, mode_t perm, uid_t uid, gid_t gid,
	tv[1].tv_sec = mts->tv_sec;
	tv[1].tv_usec = mts->tv_nsec / 1000;

-
	fdcwd = open(".", O_DIRECTORY);
+
	fdcwd = open(".", O_DIRECTORY|O_CLOEXEC);
	fchdir(fd);

	if (lutimes(RELATIVE_PATH(path), tv) == -1) {
modified libpkg/pkg_config.c
@@ -852,7 +852,7 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags)

	k = NULL;
	o = NULL;
-
	if (rootfd == -1 && (rootfd = open("/", O_DIRECTORY|O_RDONLY)) < 0) {
+
	if (rootfd == -1 && (rootfd = open("/", O_DIRECTORY|O_RDONLY|O_CLOEXEC)) < 0) {
		pkg_emit_error("Impossible to open /");
		return (EPKG_FATAL);
	}
@@ -1413,7 +1413,7 @@ pkg_set_rootdir(const char *rootdir) {
	if (rootfd != -1)
		close(rootfd);

-
	if ((rootfd = open(rootdir, O_DIRECTORY|O_RDONLY)) < 0) {
+
	if ((rootfd = open(rootdir, O_DIRECTORY|O_RDONLY|O_CLOEXEC)) < 0) {
		pkg_emit_error("Impossible to open %s", rootdir);
		return (EPKG_FATAL);
	}
modified libpkg/pkg_create.c
@@ -338,7 +338,7 @@ pkg_create_staged(const char *outdir, pkg_formats format, const char *rootdir,

	pkg_debug(1, "Creating package from stage directory: '%s'", rootdir);

-
	if ((mfd = open(md_dir, O_DIRECTORY)) == -1) {
+
	if ((mfd = open(md_dir, O_DIRECTORY|O_CLOEXEC)) == -1) {
		pkg_emit_errno("open", md_dir);
		goto cleanup;
	}
modified src/clean.c
@@ -234,7 +234,7 @@ recursive_analysis(int fd, struct pkgdb *db, const char *dir,
		snprintf(path, sizeof(path), "%s/%s", dir, ent->d_name);
		if (ent->d_type == DT_DIR) {
			nbfiles++;
-
			newfd = openat(fd, ent->d_name, O_DIRECTORY, 0);
+
			newfd = openat(fd, ent->d_name, O_DIRECTORY|O_CLOEXEC, 0);
			if (newfd == -1) {
				warnx("Impossible to open the directory %s",
				    path);
@@ -339,7 +339,7 @@ exec_clean(int argc, char **argv)
	argv += optind;

	cachedir = pkg_object_string(pkg_config_get("PKG_CACHEDIR"));
-
	cachefd = open(cachedir, O_DIRECTORY);
+
	cachefd = open(cachedir, O_DIRECTORY|O_CLOEXEC);
	if (cachefd == -1) {
		warn("Impossible to open %s", cachedir);
		return (EX_IOERR);
modified src/register.c
@@ -237,7 +237,7 @@ exec_register(int argc, char **argv)
		}

	} else {
-
		mdirfd = open(mdir, O_DIRECTORY);
+
		mdirfd = open(mdir, O_DIRECTORY|O_CLOEXEC);
		if (mdirfd == -1) {
			warn("Unable to open the manifest directory '%s'\n",
			    mdir);