Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
On systems without utimensat propertly restore the cwd
Baptiste Daroussin committed 10 years ago
commit 5ac8743379532c53d84b900f2688a7717d374018
parent fb6b9d8
1 file changed +4 -0
modified libpkg/pkg_add.c
@@ -200,18 +200,22 @@ set_attrs(int fd, char *path, mode_t perm, uid_t uid, gid_t gid,
	}
#else
	struct timeval tv[2];
+
	char *saved_cwd[MAXPATHLEN];

	tv[0].tv_sec = ats->tv_sec;
	tv[0].tv_usec = ats->tv_nsec / 1000;
	tv[1].tv_sec = mts->tv_sec;
	tv[1].tv_usec = mts->tv_nsec / 1000;

+
	if (getcwd(saved_cwd, sizeof(saved_cwd)) == NULL)
+
		saved_cwd[0] = '\0';
	fchdir(fd);
	if (lutimes(RELATIVE_PATH(path), &tv) == -1) {
		pkg_emit_error("Fail to set time on %s: %s", path,
		    strerror(errno));
		return (EPKG_FATAL);
	}
+
	chdir(saved_cwd);
#endif

	if (getenv("INSTALL_AS_USER") == NULL &&