Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Lawrence D'Oliveiro Newsgroups: comp.lang.c Subject: Re: encapsulating directory operations Date: Tue, 10 Jun 2025 23:33:08 -0000 (UTC) Organization: A noiseless patient Spider Lines: 29 Message-ID: <102afbk$1icjg$1@dont-email.me> References: <100h650$23r5l$1@dont-email.me> <100hase$24odp$1@dont-email.me> <101e738$vrrm$1@raubtier-asyl.eternal-september.org> <101ft3d$1feqh$2@dont-email.me> <101gq6l$1rdgj$1@raubtier-asyl.eternal-september.org> <101h0an$1tkqk$1@dont-email.me> <101jk7i$34erh$1@raubtier-asyl.eternal-september.org> <101lg4j$3j9qp$9@dont-email.me> <102975r$17td9$1@raubtier-asyl.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 11 Jun 2025 01:33:09 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e01886590aeeac956483c220d4079c0a"; logging-data="1651312"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8O7H0aA4KmViPw53L4z+O" User-Agent: Pan/0.162 (Pokrosvk) Cancel-Lock: sha1:hq8LuJF0YK5XME5dvVQKCapw4TE= On Tue, 10 Jun 2025 14:07:40 +0200, Bonita Montero wrote: > Am 03.06.2025 um 02:37 schrieb Lawrence D'Oliveiro: >> >> On Mon, 2 Jun 2025 09:35:24 +0200, Bonita Montero wrote: >> >>> Am 01.06.2025 um 09:43 schrieb Lawrence D'Oliveiro: >>> >>>> On Sun, 1 Jun 2025 07:58:54 +0200, Bonita Montero wrote: >>> >>>>> Sth. like this: >>>>> >>>>> for( directory_entry const &de : recursive_directory_iterator( "\ \", >>>>> directory_options::follow_directory_symlink ) ) >>>>> cout << de.path() << endl; >>> >>>> You need the dirfd functions to avoid certain potential security >>>> holes on operations with symlinks. >>> >>> Which security holes ? >> >> TOCTOU. > > That's unavoidable with directory-operations. No it isn’t. That’s why we have the fd-based calls in recent POSIX, and in Linux. That plugs the holes, and makes it possible to implement privileged file-access software like Samba securely.