Add readlink to lighty.c.* library functions
Currently I use external lua modules like
posix only to have a readlink function.
I use the readlink function to resolve latest-softlinks to redirect the user to the current version of a download.
Please add readlink to the lighty.c in
mod_magnet to avoid loading external modules only for one missing function.
- Status changed from New to Need Feedback
symlinks are a *nix and POSIX feature, though not necessarily portable to Windows which inconsistently implements partial concepts in various versions of Windows.
You're asking for
readlink() but not
Also, note that
lighty.c.stat() uses the lighttpd stat_cache (which can be configured to use inotify), and the lighttpd stat cache does not use
lstat() except if configured to block symlinks (not recommended). Were lighttpd mod_magnet to provide direct interfaces to libc funcs (and uncached), that might suggest a
lighty.libc.* namespace. In that case, what is the advantage to having lighttpd mod_magnet provide this versus lua
While lighttpd mod_magnet could provide a
lighty.libc.* namespace, you could write a small lua C module to do the same if for some reason you wanted to avoid the full
Besides convenience, would you share the reasons behind this request? Is
posix too large for your target memory use? Are there other reasons? Is there a performance hit? lighttpd caches lua scripts and you might look into requiring those modules in ways that does not re-execute those modules upon every request. lua provides multiple ways to include other code.
I'm definitly asking for
Windows does not support softlinks, but there is no need for readlink if I cannot create them, it can be excluded for Windows builds.
I didn't observe any performance issues, this is not what this ticket is about.The main reason for this request is to avoid loading external modules if possible, especially if only one function is used:
- more dependencies (maintenance, update, security issues)
- bigger images
- reduce SBOM
The history behind this is:
I used the the posix module to use
readlink. After updating to Debian 12, the script failed, because lighttpd was updated to use lua version 5.4, but the Debian lua-posix package did not provide a 5.4 version module. I switch to lfs and changed the code. After looking in the
lighty.libc.* I got the impression, that
readlink is missing in the list file operations related functions: if you provide
readdir, why not
Writing an own module creates maintenance and update issues as well, I see no difference using lfs or posix module.
This is a feature request, I did not provide a patch (maybe this made it easier for you), I can live with being rejected.
Thanks for the info. I'll think over the feature request.
Some of my comments above were aimed at documenting that the
lighty.c.* interfaces are for lighttpd C internals, not directly libc functions. e.g.
lighty.c.time() is cached inside lighttpd, not a call to libc and a system call; and
lighty.c.stat() uses the lighttpd internal stat_cache.
if you provide
readdir, why not
As I recall, I added
readdir() when writing lua implementations of lighttpd C modules (e.g. mod_dirlisting) as examples or starting points for custom lua scripts, and I see a comment in the mod_magnet code about
readdir() not being a part of lua io liolib.c.
readlink() is separate, as are
symlink(). I have no intention of reimplementing all of libc or
posix, but will consider the feature request.
The lfs module supports
readlink() and supports making symlinks and hard links, too. The lfs module also supports some Windows equivalents/approximations.
I do not think that I want to duplicate such efforts into lighttpd mod_magnet, but will ruminate on it a bit further before deciding.
Also available in: Atom