|
Lines 1188-1194
static int protect_dir(const char *path, mode_t mode, int do_mkdir,
Link Here
|
| 1188 |
int dfd = AT_FDCWD; |
1188 |
int dfd = AT_FDCWD; |
| 1189 |
int dfd_next; |
1189 |
int dfd_next; |
| 1190 |
int save_errno; |
1190 |
int save_errno; |
| 1191 |
int flags = O_RDONLY; |
1191 |
int flags = O_RDONLY | O_DIRECTORY; |
| 1192 |
int rv = -1; |
1192 |
int rv = -1; |
| 1193 |
struct stat st; |
1193 |
struct stat st; |
| 1194 |
|
1194 |
|
|
Lines 1242-1263
static int protect_dir(const char *path, mode_t mode, int do_mkdir,
Link Here
|
| 1242 |
rv = openat(dfd, dir, flags); |
1242 |
rv = openat(dfd, dir, flags); |
| 1243 |
} |
1243 |
} |
| 1244 |
|
1244 |
|
| 1245 |
if (rv != -1) { |
|
|
| 1246 |
if (fstat(rv, &st) != 0) { |
| 1247 |
save_errno = errno; |
| 1248 |
close(rv); |
| 1249 |
rv = -1; |
| 1250 |
errno = save_errno; |
| 1251 |
goto error; |
| 1252 |
} |
| 1253 |
if (!S_ISDIR(st.st_mode)) { |
| 1254 |
close(rv); |
| 1255 |
errno = ENOTDIR; |
| 1256 |
rv = -1; |
| 1257 |
goto error; |
| 1258 |
} |
| 1259 |
} |
| 1260 |
|
| 1261 |
if (flags & O_NOFOLLOW) { |
1245 |
if (flags & O_NOFOLLOW) { |
| 1262 |
/* we are inside user-owned dir - protect */ |
1246 |
/* we are inside user-owned dir - protect */ |
| 1263 |
if (protect_mount(rv, p, idata) == -1) { |
1247 |
if (protect_mount(rv, p, idata) == -1) { |
| 1264 |
- |
|
|