From nobody Thu Feb 10 08:25:26 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E0C9419A7FC0 for ; Thu, 10 Feb 2022 08:25:36 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from ms-10.1blu.de (ms-10.1blu.de [178.254.4.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4JvVDw1XPQz4XhB for ; Thu, 10 Feb 2022 08:25:36 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from [188.174.61.147] (helo=pureos) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI4lb-00065r-W2 for freebsd-hackers@freebsd.org; Thu, 10 Feb 2022 09:25:28 +0100 Date: Thu, 10 Feb 2022 09:25:26 +0100 From: Matthias Apitz To: freebsd-hackers@freebsd.org Subject: how to restrict file access below some top directory Message-ID: Reply-To: Matthias Apitz Mail-Followup-To: freebsd-hackers@freebsd.org List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Operating-System: FreeBSD 13.0-CURRENT r368166 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.61.147 X-Rspamd-Queue-Id: 4JvVDw1XPQz4XhB X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of guru@unixarea.de has no SPF policy when checking 178.254.4.101) smtp.mailfrom=guru@unixarea.de X-Spamd-Result: default: False [1.28 / 15.00]; HAS_REPLYTO(0.00)[guru@unixarea.de]; RCVD_VIA_SMTP_AUTH(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; HAS_XOIP(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; ARC_NA(0.00)[]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_SPAM_SHORT(0.22)[0.217]; NEURAL_SPAM_LONG(0.66)[0.661]; DMARC_NA(0.00)[unixarea.de]; NEURAL_HAM_MEDIUM(-1.00)[-0.997]; MLMMJ_DEST(0.00)[freebsd-hackers]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:42730, ipnet:178.254.0.0/19, country:DE]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[188.174.61.147:received] X-ThisMailContainsUnwantedMimeParts: N 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