Lines Matching defs:dir
7 lstat(dir, ..) -> OK, it's a directory
8 // attacker deletes dir, replaces it with symlink to /
9 opendir(dir) -> it actually opens /
11 Most portable solution is to lstat() the dir, chdir() there, then check
23 Another less portable solution is to fchdir(open(dir, O_NOFOLLOW)).
65 unlink_directory_r(const char *dir, enum unlink_directory_flags flags,
74 dir_fd = open(dir, O_RDONLY | O_NOFOLLOW);
78 dir);
84 if (lstat(dir, &st) < 0) {
85 unlink_directory_error(error_r, NULL, ERROR_FORMAT, "lstat", dir);
91 unlink_directory_error(error_r, NULL, "%s is not a directory: %s", dir);
96 unlink_directory_error(error_r, NULL, "%s is a symlink, not a directory: %s", dir);
101 dir_fd = open(dir, O_RDONLY);
103 unlink_directory_error(error_r, NULL, "open(%s, O_RDONLY) failed: %m", dir);
109 unlink_directory_error(error_r, NULL, ERROR_FORMAT, "fstat", dir);
118 unlink_directory_error(error_r, NULL, "%s race condition: directory was just replaced", dir);
124 unlink_directory_error(error, NULL, ERROR_FORMAT, "fchdir", dir);
131 unlink_directory_error(error, NULL, "opendir(.) (in %s) failed: %m", dir);
145 dir);
168 dir);
184 dir);
197 dir);
215 dir,
226 dir);
235 int unlink_directory(const char *dir, enum unlink_directory_flags flags,
258 ret = unlink_directory_r(dir, flags, error_r);
263 "Can't fchdir() back to our original dir %s: %m", dir, orig_dir);
273 if (rmdir(dir) < 0 && errno != ENOENT) {
274 *error_r = t_strdup_printf("rmdir(%s) failed: %m", dir);