|
Lines 1408-1413
Link Here
|
| 1408 |
const char *cp; |
1408 |
const char *cp; |
| 1409 |
char component[MAXPATHLEN]; |
1409 |
char component[MAXPATHLEN]; |
| 1410 |
struct stat st; |
1410 |
struct stat st; |
|
|
1411 |
int last; |
| 1411 |
|
1412 |
|
| 1412 |
if (*path != '/') |
1413 |
if (*path != '/') |
| 1413 |
fatal("chroot path does not begin at root"); |
1414 |
fatal("chroot path does not begin at root"); |
|
Lines 1419-1425
Link Here
|
| 1419 |
* root-owned directory with strict permissions. |
1420 |
* root-owned directory with strict permissions. |
| 1420 |
*/ |
1421 |
*/ |
| 1421 |
for (cp = path; cp != NULL;) { |
1422 |
for (cp = path; cp != NULL;) { |
| 1422 |
if ((cp = strchr(cp, '/')) == NULL) |
1423 |
if (((last = ((cp = strchr(cp, '/')) == NULL)))) |
| 1423 |
strlcpy(component, path, sizeof(component)); |
1424 |
strlcpy(component, path, sizeof(component)); |
| 1424 |
else { |
1425 |
else { |
| 1425 |
cp++; |
1426 |
cp++; |
|
Lines 1432-1438
Link Here
|
| 1432 |
if (stat(component, &st) != 0) |
1433 |
if (stat(component, &st) != 0) |
| 1433 |
fatal("%s: stat(\"%s\"): %s", __func__, |
1434 |
fatal("%s: stat(\"%s\"): %s", __func__, |
| 1434 |
component, strerror(errno)); |
1435 |
component, strerror(errno)); |
| 1435 |
if (st.st_uid != 0 || (st.st_mode & 022) != 0) |
1436 |
if ((st.st_uid != 0 || (st.st_mode & 022) != 0) && !(last && st.st_uid == uid)) |
| 1436 |
fatal("bad ownership or modes for chroot " |
1437 |
fatal("bad ownership or modes for chroot " |
| 1437 |
"directory %s\"%s\"", |
1438 |
"directory %s\"%s\"", |
| 1438 |
cp == NULL ? "" : "component ", component); |
1439 |
cp == NULL ? "" : "component ", component); |