MCPcopy Create free account
hub / github.com/F-Stack/f-stack / prison_canseemount

Function prison_canseemount

freebsd/kern/kern_jail.c:3186–3219  ·  view source on GitHub ↗

* Determine whether the subject represented by cred can "see" * status of a mount point. * Returns: 0 for permitted, ENOENT otherwise. * XXX: This function should be called cr_canseemount() and should be * placed in kern_prot.c. */

Source from the content-addressed store, hash-verified

3184 * placed in kern_prot.c.
3185 */
3186int
3187prison_canseemount(struct ucred *cred, struct mount *mp)
3188{
3189 struct prison *pr;
3190 struct statfs *sp;
3191 size_t len;
3192
3193 pr = cred->cr_prison;
3194 if (pr->pr_enforce_statfs == 0)
3195 return (0);
3196 if (pr->pr_root->v_mount == mp)
3197 return (0);
3198 if (pr->pr_enforce_statfs == 2)
3199 return (ENOENT);
3200 /*
3201 * If jail's chroot directory is set to "/" we should be able to see
3202 * all mount-points from inside a jail.
3203 * This is ugly check, but this is the only situation when jail's
3204 * directory ends with '/'.
3205 */
3206 if (strcmp(pr->pr_path, "/") == 0)
3207 return (0);
3208 len = strlen(pr->pr_path);
3209 sp = &mp->mnt_stat;
3210 if (strncmp(pr->pr_path, sp->f_mntonname, len) != 0)
3211 return (ENOENT);
3212 /*
3213 * Be sure that we don't have situation where jail's root directory
3214 * is "/some/path" and mount point is "/some/pathpath".
3215 */
3216 if (sp->f_mntonname[len] != '\0' && sp->f_mntonname[len] != '/')
3217 return (ENOENT);
3218 return (0);
3219}
3220
3221void
3222prison_enforce_statfs(struct ucred *cred, struct mount *mp, struct statfs *sp)

Callers 3

prison_enforce_statfsFunction · 0.85
kern_getfsstatFunction · 0.85
kern_fhstatfsFunction · 0.85

Calls 2

strcmpFunction · 0.85
strncmpFunction · 0.85

Tested by

no test coverage detected