Sunday, March 28, 2021

Re: cgit about-filter in chroot (httpd + slowcgi)

On 2021-03-28 18:56, Omar Polo wrote:
>> Thanks Omar, I like this approach! I'm pretty green to C so this is
>> what I have (which doesn't work):
>>
>> #include <unistd.h>
>> int main(void) {
>> execl("/bin/lowdown", NULL);
>> }
>>
>> There is no HTML render but at least no errors, but cgit expects the
>> resulting HTML printed to STDOUT, so I wonder whether this requires a
>> return?
>
> Assuming that the shell script you posted actually works yes, that
> snippet (with a small tweak[0]) should work. Make sure it's statically
> linked.
>
> For reference, here's how I would do it
>
> $ cat <<EOF > my-cgit-filter.c
> #include <unistd.h>
>
> int
> main(void)
> {
> execl("/bin/lowdown", "lowdown", NULL);
> return 1;
> }
> EOF
> $ cc my-cgit-filter.c -o my-cgit-filter.c -static
> $ # check that it's actually statically linked
> $ ldd my-cgit-filter
> my-cgit-filter:
> Start End Type Open Ref GrpRef Name
> 000005196d856000 000005196d87b000 dlib 1 0 0
> /tmp/my-cgit-filter
>
> [0]: if you compile your snippet, clang should warning about a missing
> sentinel, something along the lines of
>
> > warning: not enough variable arguments in 'execl' declaration to
> fit a
> > sentinel [-Wsentinel]
> > execl("/bin/lowdown", NULL);
>
> which should suggest the use of
> > execl("/bin/lowdown", "lowdown", NULL);

Thank you so much Omar! Making the sentinel change solved it :)

No comments:

Post a Comment