[PATCH] Require a "path" parameter for filesystem back ends.

Jim Meyering jim at meyering.net
Mon Sep 27 16:19:53 UTC 2010


Jeff Darcy wrote:
> Subject: [PATCH] Require a "path" parameter for filesystem back ends.
>
> This includes checking for existence of the parameter, doing a chroot/chdir
> in fs_init, and disallowing sneaky "../" escapes.  The path can be relative
> (handy for development) but you shouldn't be able to traverse out of it.

Hi Jeff,

Using chroot would mean that iwhd may be run only by a privileged (root) user.

I suggest to instead open the base/root-to-be directory (better not to
call it "path", since path is often used to refer to a "search path") and
retain the resulting file descriptor.  Then, any FS-relative
operation can use the *at functions like mkdirat, openat, etc.
that are fd-directory-relative.

If you're interested, I'll be happy to work on the alternate patch.

...
>  fs_init (void)
>  {
> +	DPRINTF("changing directory to %s\n",local_path);
> +	if (chroot(local_path) < 0) {
> +		error(0,errno,"chroot failed, unsafe to continue\n");
> +		exit(!0); /* Value doesn't matter, as long as it's not zero. */
> +	}


More information about the iwhd-devel mailing list