how to restrict file access below some top directory

From: Matthias Apitz <guru_at_unixarea.de>
Date: Thu, 10 Feb 2022 08:25:26 UTC
Hello,

I want restrict in a C- or Perl-written application the file access to
only files below some top directory, say

	/var/spool/dir/

and not allowing, for example, access to /var/spool/dir/../../../etc/passwd
Ofc, this could be done easy with chroot(2), but this would require root
permision. Any other ideas?

	matthias
-- 
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
"Wenn mich jemand fragt, woher ich komme, sag ich immer: aus dem netteren
Teil von Deutschland." Yvonne in "Die Kinder von Hoy" Grit Lemke, S.244 
"If someone asks me where I come from, I always say: from the nicer one
part of Germany." Yvonne in "Die Kinder von Hoy" Grit Lemke, page 244