guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Bindings to *at functions & allowing more functions to opera


From: Maxime Devos
Subject: Re: [PATCH] Bindings to *at functions & allowing more functions to operate on ports
Date: Wed, 05 May 2021 12:11:25 +0200
User-agent: Evolution 3.34.2

rob piko schreef op di 04-05-2021 om 18:58 [-0400]:
> Hello Maxime,
> 
> > * Use O_NOFOLLOW to *not* follow the symbolic link.
> >  Patch for adding O_NOFOLLOW to guile:
> 
> According to the man pages for the O_NOFOLLOW:
> 
> > If the trailing component (i.e., basename) of pathname is
> >               a symbolic link, then the open fails, with the error
> >               ELOOP.  Symbolic links in earlier components of the
> >               pathname will still be followed.
> 
> Sounds like O_NOFOLLOW would not fix the issue if the symlink is found in 
> other parts of the pathname outside of the basename?
Indeed! To avoid *all* symlinks, and not only a symlink in the trailing 
component,
you would need to call 'open' with O_NOFOLLOW in a loop.

Something like:
  (let* ((dir (open "/symlinks/acceptable-here" O_RDONLY))
         ;; Symlinks are not followed here.
         (dir* (openat dir "dir" (logior O_RDONLY O_NOFOLLOW)))
         (file (openat dir* "file" (logior O_RDONLY O_NOFOLLOW))))
    (close dir)
    (close dir*)
    file)

It has been a while since I wrote the patch though, maybe the argument
order is a little different.

Greetings,
Maxime.

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]