git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] tests: A SANITY test prereq for testing if we're root

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 9, 2010, 19:02 UTC
Message-ID
<AANLkTi=68=ffWqmXyMckJuSvbW4Wk9-7JWR-S9nheOEA@mail.gmail.com>
In-Reply-To
<7vd3tr7mkj.fsf@alter.siamese.dyndns.org>
On Mon, Aug 9, 2010 at 16:55, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> + - SANITY
>> +
>> +   Test is not run by root user, and an attempt to write to an
>> +   unwritable file is expected to fail correctly.
>
> As I said in the previous round, I am indeed in favor of having a single
> "running as root---code that expects that the normal UNIXy permission
> based protection to apply, aka 'running in sane environment', will not
> work correctly" prerequisite token, rather than having separate "can I
> expect an unwritable file to be unwritable?"  "can I expect an unreadble
> file to be unreadable?" bits.

I probably shouldn't have used your docs as-is, you're right. It could be explained better.

> The name of the token _might_ be subject to debate (I am fine with
> either SANITY or NOROOT), but the explanation should mention this is
> defined to be a bit more broad than "unWRITABLE", I think.
NOROOT is better I think,.
> "test -w /" is a traditional way to approximately check if you are
> running as root (technically, it only checks if you are running with
> unduly high privilege---your sysadm _could_ have done "chmod 2775 /"
> and made it owned by the admin group).
Initially I wrote it as:
     # test whether the filesystem supports symbolic links
     ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
     rm -f y
    +
    +# test whether we can make read-only files
    +mkdir hla
    +chmod -w hla
    +touch hla/gh >/dev/null 2>&1
    +test -f hla/gh || test_set_prereq SANITY
    +rm -rf hla

But then I saw your old "test -w /" implementation and figured it was good enough without doing all this work on setup. I can submit another patch with that fixup if you like, maybe it'll prevent odd failures on someone's odd system.

Previous: Junio C Hamano
Message 7 of 7 in “tests: A new test prereq for testing chmod -w as root”
  1. tests: A new test prereq for testing chmod -w as rootÆvar Arnfjörð Bjarmason, Aug 4, 2010
  2. Junio C HamanoAug 4, 2010
  3. Ævar Arnfjörð BjarmasonAug 4, 2010
  4. Jonathan NiederAug 4, 2010
  5. tests: A SANITY test prereq for testing if we're rootÆvar Arnfjörð Bjarmason, Aug 6, 2010
  6. Junio C HamanoAug 9, 2010
  7. Ævar Arnfjörð BjarmasonAug 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.