[llvm-dev] Usage of chmod 400 in lld lit tests causes failures when run by root user

Peter Smith via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 16 10:41:39 PDT 2019


On Tue, 16 Jul 2019 at 18:23, Tom Stellard via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> Hi,
>
> There are 3 lld tests[1] that run the command `chmod 400` or `chmod u-w`
> and then check that lld generates a permission denied error when trying to
> write to the files. These tests fail when run as root,
> because `chmod 400` is not enough to prevent root from writing to files.
> Is there some other way we can tests this, or should we just not support
> running tests as root?
>

A quick search on preventing root from overwriting files brings up
chattr +i to set the immutable bit, however this only works when run
as root so it isn't feasible. Personally I would be happy with not
supporting the test suite running as root, or maybe documenting that
chmod tests will fail.

> A related question I have is how do these tests work on Windows since it doesn't
> have chmod?
>

Could it be related to the sentence "If you would like to run the LLVM
tests you will need Python. Version 2.7 and newer are known to work.
You will need GnuWin32 tools, too."
https://llvm.org/docs/GettingStartedVS.html
It is likely that GnuWin32 tools contain chmod in some form.
Unfortunately I don't have a Windows machine to hand to confirm.

Peter

> Thanks,
> Tom
>
> [1]
>
> ELF/lto/thinlto-emit-imports.ll
> ELF/lto/thinlto-cant-write-index.ll
> COFF/thinlto-emit-imports.ll
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list