summaryrefslogtreecommitdiff
path: root/lib/set-permissions.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2018-06-25 21:45:23 +0200
committerBruno Haible <bruno@clisp.org>2018-06-25 21:45:23 +0200
commitd7cf3b8d27f6b7ccbcdcdd9d18d7e12208795e3d (patch)
tree382e97c6a19bbd00c4257093416a97b9619a3119 /lib/set-permissions.c
parentfcdf335e093e245e384874254ec897c97430ccf2 (diff)
downloadgnulib-d7cf3b8d27f6b7ccbcdcdd9d18d7e12208795e3d.tar.gz
Continue to use spaces for indentation, not tabs.
Diffstat (limited to 'lib/set-permissions.c')
-rw-r--r--lib/set-permissions.c254
1 files changed, 127 insertions, 127 deletions
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index 4b7371c9b4..d42335aa50 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -229,14 +229,14 @@ set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod)
if (ret < 0 && errno != EINVAL && errno != ENOTSUP)
{
if (errno == ENOSYS)
- {
- *must_chmod = true;
- return 0;
- }
+ {
+ *must_chmod = true;
+ return 0;
+ }
return -1;
}
if (ret == 0)
- return 0;
+ return 0;
}
# endif
@@ -256,18 +256,18 @@ set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod)
if (desc != -1)
ret = facl (desc, SETACL,
- sizeof (entries) / sizeof (aclent_t), entries);
+ sizeof (entries) / sizeof (aclent_t), entries);
else
ret = acl (name, SETACL,
- sizeof (entries) / sizeof (aclent_t), entries);
+ sizeof (entries) / sizeof (aclent_t), entries);
if (ret < 0)
{
- if (errno == ENOSYS || errno == EOPNOTSUPP)
- {
- *must_chmod = true;
- return 0;
- }
- return -1;
+ if (errno == ENOSYS || errno == EOPNOTSUPP)
+ {
+ *must_chmod = true;
+ return 0;
+ }
+ return -1;
}
return 0;
}
@@ -483,7 +483,7 @@ context_acl_from_mode (struct permission_context *ctx)
static int
set_acls (struct permission_context *ctx, const char *name, int desc,
- int from_mode, bool *must_chmod, bool *acls_set)
+ int from_mode, bool *must_chmod, bool *acls_set)
{
int ret = 0;
@@ -503,43 +503,43 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
if (! ctx->acls_not_supported)
{
if (ret == 0 && from_mode)
- {
- if (ctx->acl)
- acl_free (ctx->acl);
- ctx->acl = acl_from_mode (ctx->mode);
- if (ctx->acl == NULL)
- ret = -1;
- }
+ {
+ if (ctx->acl)
+ acl_free (ctx->acl);
+ ctx->acl = acl_from_mode (ctx->mode);
+ if (ctx->acl == NULL)
+ ret = -1;
+ }
if (ret == 0 && ctx->acl)
- {
- if (HAVE_ACL_SET_FD && desc != -1)
- ret = acl_set_fd (desc, ctx->acl);
- else
- ret = acl_set_file (name, ACL_TYPE_ACCESS, ctx->acl);
- if (ret != 0)
- {
- if (! acl_errno_valid (errno))
- {
- ctx->acls_not_supported = true;
- if (from_mode || acl_access_nontrivial (ctx->acl) == 0)
- ret = 0;
- }
- }
- else
- {
- *acls_set = true;
- if (S_ISDIR(ctx->mode))
- {
- if (! from_mode && ctx->default_acl &&
- acl_default_nontrivial (ctx->default_acl))
- ret = acl_set_file (name, ACL_TYPE_DEFAULT,
- ctx->default_acl);
- else
- ret = acl_delete_def_file (name);
- }
- }
- }
+ {
+ if (HAVE_ACL_SET_FD && desc != -1)
+ ret = acl_set_fd (desc, ctx->acl);
+ else
+ ret = acl_set_file (name, ACL_TYPE_ACCESS, ctx->acl);
+ if (ret != 0)
+ {
+ if (! acl_errno_valid (errno))
+ {
+ ctx->acls_not_supported = true;
+ if (from_mode || acl_access_nontrivial (ctx->acl) == 0)
+ ret = 0;
+ }
+ }
+ else
+ {
+ *acls_set = true;
+ if (S_ISDIR(ctx->mode))
+ {
+ if (! from_mode && ctx->default_acl &&
+ acl_default_nontrivial (ctx->default_acl))
+ ret = acl_set_file (name, ACL_TYPE_DEFAULT,
+ ctx->default_acl);
+ else
+ ret = acl_delete_def_file (name);
+ }
+ }
+ }
}
# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */
@@ -573,38 +573,38 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
/* Remove ACLs if the file has ACLs. */
if (HAVE_ACL_GET_FD && desc != -1)
- acl = acl_get_fd (desc);
+ acl = acl_get_fd (desc);
else
- acl = acl_get_file (name, ACL_TYPE_EXTENDED);
+ acl = acl_get_file (name, ACL_TYPE_EXTENDED);
if (acl)
- {
- acl_free (acl);
-
- acl = acl_init (0);
- if (acl)
- {
- if (HAVE_ACL_SET_FD && desc != -1)
- ret = acl_set_fd (desc, acl);
- else
- ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl);
- acl_free (acl);
- }
- else
- ret = -1;
- }
+ {
+ acl_free (acl);
+
+ acl = acl_init (0);
+ if (acl)
+ {
+ if (HAVE_ACL_SET_FD && desc != -1)
+ ret = acl_set_fd (desc, acl);
+ else
+ ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl);
+ acl_free (acl);
+ }
+ else
+ ret = -1;
+ }
}
else
{
if (HAVE_ACL_SET_FD && desc != -1)
- ret = acl_set_fd (desc, ctx->acl);
+ ret = acl_set_fd (desc, ctx->acl);
else
- ret = acl_set_file (name, ACL_TYPE_EXTENDED, ctx->acl);
+ ret = acl_set_file (name, ACL_TYPE_EXTENDED, ctx->acl);
if (ret != 0)
- {
- if (! acl_errno_valid (errno)
- && ! acl_extended_nontrivial (ctx->acl))
- ret = 0;
- }
+ {
+ if (! acl_errno_valid (errno)
+ && ! acl_extended_nontrivial (ctx->acl))
+ ret = 0;
+ }
}
*acls_set = true;
@@ -626,34 +626,34 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
if (ret == 0 && ctx->count)
{
if (desc != -1)
- ret = facl (desc, SETACL, ctx->count, ctx->entries);
+ ret = facl (desc, SETACL, ctx->count, ctx->entries);
else
- ret = acl (name, SETACL, ctx->count, ctx->entries);
+ ret = acl (name, SETACL, ctx->count, ctx->entries);
if (ret < 0)
- {
- if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
- && acl_nontrivial (ctx->count, ctx->entries) == 0)
- ret = 0;
- }
+ {
+ if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
+ && acl_nontrivial (ctx->count, ctx->entries) == 0)
+ ret = 0;
+ }
else
- *acls_set = true;
+ *acls_set = true;
}
# ifdef ACE_GETACL
if (ret == 0 && ctx->ace_count)
{
if (desc != -1)
- ret = facl (desc, ACE_SETACL, ctx->ace_count, ctx->ace_entries);
+ ret = facl (desc, ACE_SETACL, ctx->ace_count, ctx->ace_entries);
else
- ret = acl (name, ACE_SETACL, ctx->ace_count, ctx->ace_entries);
+ ret = acl (name, ACE_SETACL, ctx->ace_count, ctx->ace_entries);
if (ret < 0)
- {
- if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP)
- && acl_ace_nontrivial (ctx->ace_count, ctx->ace_entries) == 0)
- ret = 0;
- }
+ {
+ if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP)
+ && acl_ace_nontrivial (ctx->ace_count, ctx->ace_entries) == 0)
+ ret = 0;
+ }
else
- *acls_set = true;
+ *acls_set = true;
}
# endif
@@ -665,17 +665,17 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
if (ret == 0 && ctx->count > 0)
{
if (desc != -1)
- ret = fsetacl (desc, ctx->count, ctx->entries);
+ ret = fsetacl (desc, ctx->count, ctx->entries);
else
- ret = setacl (name, ctx->count, ctx->entries);
+ ret = setacl (name, ctx->count, ctx->entries);
if (ret < 0)
- {
- if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
- && (from_mode || !acl_nontrivial (ctx->count, ctx->entries)))
- ret = 0;
- }
+ {
+ if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
+ && (from_mode || !acl_nontrivial (ctx->count, ctx->entries)))
+ ret = 0;
+ }
else
- *acls_set = true;
+ *acls_set = true;
}
# if HAVE_ACLV_H
@@ -686,13 +686,13 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
{
ret = acl ((char *) name, ACL_SET, ctx->aclv_count, ctx->aclv_entries);
if (ret < 0)
- {
- if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
- && (from_mode || !aclv_nontrivial (ctx->aclv_count, ctx->aclv_entries)))
- ret = 0;
- }
+ {
+ if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
+ && (from_mode || !aclv_nontrivial (ctx->aclv_count, ctx->aclv_entries)))
+ ret = 0;
+ }
else
- *acls_set = true;
+ *acls_set = true;
}
# endif
@@ -711,16 +711,16 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
if (ret == 0 && ctx->have_u)
{
if (desc != -1)
- ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len);
+ ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len);
else
- ret = chacl ((char *) name, &ctx->u.a, ctx->u.a.acl_len);
+ ret = chacl ((char *) name, &ctx->u.a, ctx->u.a.acl_len);
if (ret < 0)
- {
- if (errno == ENOSYS && from_mode)
- ret = 0;
- }
+ {
+ if (errno == ENOSYS && from_mode)
+ ret = 0;
+ }
else
- *acls_set = true;
+ *acls_set = true;
}
# elif HAVE_ACLSORT /* NonStop Kernel */
@@ -732,12 +732,12 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
{
ret = acl ((char *) name, ACL_SET, ctx->count, ctx->entries);
if (ret != 0)
- {
- if (!acl_nontrivial (ctx->count, ctx->entries))
- ret = 0;
- }
+ {
+ if (!acl_nontrivial (ctx->count, ctx->entries))
+ ret = 0;
+ }
else
- *acls_set = true;
+ *acls_set = true;
}
# else /* No ACLs */
@@ -805,7 +805,7 @@ set_permissions (struct permission_context *ctx, const char *name, int desc)
{
ret = chmod_or_fchmod (name, desc, ctx->mode);
if (ret != 0)
- return -1;
+ return -1;
}
#if USE_ACL
@@ -815,18 +815,18 @@ set_permissions (struct permission_context *ctx, const char *name, int desc)
int saved_errno = ret ? errno : 0;
/* If we can't set an acl which we expect to be able to set, try setting
- the permissions to ctx->mode. Due to possible inherited permissions,
- we cannot simply chmod. */
+ the permissions to ctx->mode. Due to possible inherited permissions,
+ we cannot simply chmod. */
ret = set_acls (ctx, name, desc, true, &must_chmod, &acls_set);
if (! acls_set)
- must_chmod = true;
+ must_chmod = true;
if (saved_errno)
- {
- errno = saved_errno;
- ret = -1;
- }
+ {
+ errno = saved_errno;
+ ret = -1;
+ }
}
#endif
@@ -837,10 +837,10 @@ set_permissions (struct permission_context *ctx, const char *name, int desc)
ret = chmod_or_fchmod (name, desc, ctx->mode);
if (saved_errno)
- {
- errno = saved_errno;
- ret = -1;
- }
+ {
+ errno = saved_errno;
+ ret = -1;
+ }
}
return ret;