Skip to content

Conversation

@donald
Copy link
Contributor

If we don't have the permissions to remove BUILD_TMPDIR (which is quite
likely, when we switch from a test build with a personal user to one
via tools/build.sh with the build user), the current code would ignore
the fact, that the directory can't be removed and continue with a
nonempty directory, possible running into permission problems later.

We could just change

chmod ... && rm -r ...

to

( chmod ... ; rm -r ... )

and the shell would terminate when chmod fails due to permissions.
However, the error message of chmod is different than that of rm:

buczek@afk:~$ chmod u+w /root
chmod: changing permissions of ‘/root’: Operation not permitted
buczek@afk:~$ ls /root/
ls: cannot open directory /root/: Permission denied

I think "Permission denied" is a bit clearer than "Operation not
permitted".

Ignore errors form chmod and try rm in any case, which either
succeeds or aborts the script with an appropriate error message.

If we don't have the permissions to remove BUILD_TMPDIR (which is quite
likely, when we switch from a test build with a personal user to one
via tools/build.sh with the build user), the current code would ignore
the fact, that the directory can't be removed and continue with a
nonempty directory, possible running into permission problems later.

We could just change

   chmod ... && rm -r ...

to

   ( chmod ... ; rm -r ... )

and the shell would terminate when chmod fails due to permissions.
However, the error message of chmod is different than that of rm:

    buczek@afk:~$ chmod u+w /root
    chmod: changing permissions of ‘/root’: Operation not permitted
    buczek@afk:~$ ls /root/
    ls: cannot open directory /root/: Permission denied

I think "Permission denied" is a bit clearer than "Operation not
permitted".

Ignore errors form `chmod` and try `rm` in any case, which either
succeeds or aborts the script with an appropriate error message. Remove
-c flag from chmod because we are not really interested if something has
been changed or not.
Sign in to join this conversation on GitHub.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant