libostree: Silently ignore EPERM when setting EXT2_IMMUTABLE_FL
In the case of running ostree as non-root on a regular filesystem (not tmpfs which doesn't support immutable), we should just silently do nothing if we encounter EPERM. Cache the result to avoid spam in strace. https://bugzilla.gnome.org/show_bug.cgi?id=728006
This commit is contained in:
parent
24c64d6b4f
commit
e31daf448a
|
|
@ -38,8 +38,9 @@
|
||||||
* Alter the immutable flag of object referred to by @fd; may be a
|
* Alter the immutable flag of object referred to by @fd; may be a
|
||||||
* regular file or a directory.
|
* regular file or a directory.
|
||||||
*
|
*
|
||||||
* If the operation is not supported by the underlying filesystem,
|
* If the operation is not supported by the underlying filesystem, or
|
||||||
* this function will silently do nothing.
|
* we are running without sufficient privileges, this function will
|
||||||
|
* silently do nothing.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
_ostree_linuxfs_fd_alter_immutable_flag (int fd,
|
_ostree_linuxfs_fd_alter_immutable_flag (int fd,
|
||||||
|
|
@ -50,12 +51,18 @@ _ostree_linuxfs_fd_alter_immutable_flag (int fd,
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int r;
|
int r;
|
||||||
|
static gint no_alter_immutable = 0;
|
||||||
|
|
||||||
|
if (g_atomic_int_get (&no_alter_immutable))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
r = ioctl (fd, EXT2_IOC_GETFLAGS, &flags);
|
r = ioctl (fd, EXT2_IOC_GETFLAGS, &flags);
|
||||||
if (r == -1)
|
if (r == -1)
|
||||||
{
|
{
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
if (errsv == EOPNOTSUPP || errsv == ENOTTY)
|
if (errsv == EPERM)
|
||||||
|
g_atomic_int_set (&no_alter_immutable, 1);
|
||||||
|
else if (errsv == EOPNOTSUPP || errsv == ENOTTY)
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +82,9 @@ _ostree_linuxfs_fd_alter_immutable_flag (int fd,
|
||||||
if (r == -1)
|
if (r == -1)
|
||||||
{
|
{
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
if (errsv == EOPNOTSUPP || errsv == ENOTTY)
|
if (errsv == EPERM)
|
||||||
|
g_atomic_int_set (&no_alter_immutable, 1);
|
||||||
|
else if (errsv == EOPNOTSUPP || errsv == ENOTTY)
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue