Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Handle `$mountpoint == /` better

Aperta
#220 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
shell

Direzione di ricerca

Esamina lo script try intorno alle righe 104 e 156, quindi riproduci il fallimento con il test hide_flag.sh quando il punto di mount è /. Traccia il modo in cui il percorso root viene mappato sotto hidedir e determina la disposizione prevista delle directory intermedie. Il lavoro è completato quando il test passa senza rendere hidedir non scrivibile e i percorsi generati mantengono il mapping previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

There exists an edge case when creating the contents of hidedir:

https://github.com/binpash/try/blob/619b0a20cf0e3f38d78f9a3b2d1680c848d2f860/try#L156

The $(stat -c %a "$mountpoint") command gets the permissions of $mountpoint as an octal triplet (e.g. 755) which is then passed as the permissions to create the folder for that directory under hidedir. I encountered this edge case when running the test suite, in particular hide_flag.sh, because it attempts to operate with a mountpoint set to /, which on my system has permissions of 555. The problem here is twofold:

  • This line attempts to create .../hidedir// which simplifies .../hidedir itself
  • It therefore sets the permissions on hidedir, not on the mountpoint underneath it, to 555, which doesn't allow writing anything into it.

A quick fix is to simply append $SANDBOX_DIR/hidedir to the list of pre-created directories earlier in the workflow:

https://github.com/binpash/try/blob/619b0a20cf0e3f38d78f9a3b2d1680c848d2f860/try#L104

This creates hidedir with write permissions, so later operations succeed and the test passes. But I'm not sure whether this is the right approach, because it's not clear to me that having .../hidedir/bin, .../hidedir/etc, and so on is correct. It looks like the code expects the contents of hidedir to be whatever was in $DIRS_AND_MOUNTS (here /) and instead we're putting /'s child files and folders directly into it without the expected intermediate level. So applying the quick fix I found lets the test suite pass, but if that's just masking the problem of not handling / properly, then it will take a more involved approach than I understand how to write right now.

For reference here is the log of the failing test.

Running hide_flag.sh...                                     FAIL (3)
=======
STDOUT:
=======
=======

=======
STDERR:
=======
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//boot’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//dev’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//etc’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//home’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//lost+found’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//mnt’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//opt’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//proc’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//root’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//run’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//srv’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//sys’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//tmp’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//usr’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//var’: Permission denied
mkdir: cannot create directory ‘/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//tmp’: Permission denied
touch: cannot touch '/tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//tmp/tmp.mXz83rZUkL/hidden_file': No such file or directory
setfattr: /tmp/tmp.nX5htJY95A.try-1782959338286/hidedir//tmp/tmp.mXz83rZUkL/hidden_file: No such file or directory
try: could not create whiteout for hidden path '/tmp/tmp.mXz83rZUkL/hidden_file'
=======

and here are the permissions:

%stat -c '%a %n' /tmp/tmp.nX5htJY95A.try-1782959338286/*
600 /tmp/tmp.nX5htJY95A.try-1782959338286/exclude
600 /tmp/tmp.nX5htJY95A.try-1782959338286/hide
555 /tmp/tmp.nX5htJY95A.try-1782959338286/hidedir
600 /tmp/tmp.nX5htJY95A.try-1782959338286/include
644 /tmp/tmp.nX5htJY95A.try-1782959338286/mounts
644 /tmp/tmp.nX5htJY95A.try-1782959338286/mounts.updated
755 /tmp/tmp.nX5htJY95A.try-1782959338286/temproot
755 /tmp/tmp.nX5htJY95A.try-1782959338286/upperdir
755 /tmp/tmp.nX5htJY95A.try-1782959338286/workdir
Lingua principale
Shell
Stelle
5.5k
Fork
81
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di binpash/try

Tutte le issue di binpash/try

Issue simili

Altre issue su Shell/Bash

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.