summaryrefslogtreecommitdiff
path: root/src/chcon.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-08-22 18:56:06 +0200
committerJim Meyering <meyering@redhat.com>2009-08-25 09:21:00 +0200
commit5e778f7c8d1ecf3d8f11385db013af2ba026e2a5 (patch)
treee460d471f37f0dce1ba06f60f88114d1a65326c4 /src/chcon.c
parent2bc0f3caaafeb240cdcfd050b7ad1fe0ad14addf (diff)
downloadcoreutils-5e778f7c8d1ecf3d8f11385db013af2ba026e2a5.tar.xz
global: convert indentation-TABs to spaces
Transformed via this shell code: t=$'\t' git ls-files \ | grep -vE '(^|/)((GNU)?[Mm]akefile|ChangeLog)|\.(am|mk)$' \ | grep -vE 'tests/pr/|help2man' \ | xargs grep -lE "^ *$t" \ | xargs perl -MText::Tabs -ni -le \ '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
Diffstat (limited to 'src/chcon.c')
-rw-r--r--src/chcon.c322
1 files changed, 161 insertions, 161 deletions
diff --git a/src/chcon.c b/src/chcon.c
index f5b5f22df..266260066 100644
--- a/src/chcon.c
+++ b/src/chcon.c
@@ -97,7 +97,7 @@ compute_context_from_mask (security_context_t context, context_t *ret)
if (!new_context)
{
error (0, errno, _("failed to create security context: %s"),
- quotearg_colon (context));
+ quotearg_colon (context));
return 1;
}
@@ -105,13 +105,13 @@ compute_context_from_mask (security_context_t context, context_t *ret)
do \
{ \
if (specified_ ## comp \
- && context_ ## comp ## _set ((C), specified_ ## comp)) \
+ && context_ ## comp ## _set ((C), specified_ ## comp)) \
{ \
- error (0, errno, \
- _("failed to set %s security context component to %s"), \
- #comp, quote (specified_ ## comp)); \
+ error (0, errno, \
+ _("failed to set %s security context component to %s"), \
+ #comp, quote (specified_ ## comp)); \
ok = false; \
- } \
+ } \
} \
while (0)
@@ -147,35 +147,35 @@ change_file_context (int fd, char const *file)
if (specified_context == NULL)
{
int status = (affect_symlink_referent
- ? getfileconat (fd, file, &file_context)
- : lgetfileconat (fd, file, &file_context));
+ ? getfileconat (fd, file, &file_context)
+ : lgetfileconat (fd, file, &file_context));
if (status < 0 && errno != ENODATA)
- {
- error (0, errno, _("failed to get security context of %s"),
- quote (file));
- return 1;
- }
+ {
+ error (0, errno, _("failed to get security context of %s"),
+ quote (file));
+ return 1;
+ }
/* If the file doesn't have a context, and we're not setting all of
- the context components, there isn't really an obvious default.
- Thus, we just give up. */
+ the context components, there isn't really an obvious default.
+ Thus, we just give up. */
if (file_context == NULL)
- {
- error (0, 0, _("can't apply partial context to unlabeled file %s"),
- quote (file));
- return 1;
- }
+ {
+ error (0, 0, _("can't apply partial context to unlabeled file %s"),
+ quote (file));
+ return 1;
+ }
if (compute_context_from_mask (file_context, &context))
- return 1;
+ return 1;
}
else
{
/* FIXME: this should be done exactly once, in main. */
context = context_new (specified_context);
if (!context)
- abort ();
+ abort ();
}
context_string = context_str (context);
@@ -183,15 +183,15 @@ change_file_context (int fd, char const *file)
if (file_context == NULL || ! STREQ (context_string, file_context))
{
int fail = (affect_symlink_referent
- ? setfileconat (fd, file, context_string)
- : lsetfileconat (fd, file, context_string));
+ ? setfileconat (fd, file, context_string)
+ : lsetfileconat (fd, file, context_string));
if (fail)
- {
- errors = 1;
- error (0, errno, _("failed to change context of %s to %s"),
- quote_n (0, file), quote_n (1, context_string));
- }
+ {
+ errors = 1;
+ error (0, errno, _("failed to change context of %s to %s"),
+ quote_n (0, file), quote_n (1, context_string));
+ }
}
context_free (context);
@@ -216,41 +216,41 @@ process_file (FTS *fts, FTSENT *ent)
{
case FTS_D:
if (recurse)
- {
- if (ROOT_DEV_INO_CHECK (root_dev_ino, ent->fts_statp))
- {
- /* This happens e.g., with "chcon -R --preserve-root ... /"
- and with "chcon -RH --preserve-root ... symlink-to-root". */
- ROOT_DEV_INO_WARN (file_full_name);
- /* Tell fts not to traverse into this hierarchy. */
- fts_set (fts, ent, FTS_SKIP);
- /* Ensure that we do not process "/" on the second visit. */
- ent = fts_read (fts);
- return false;
- }
- return true;
- }
+ {
+ if (ROOT_DEV_INO_CHECK (root_dev_ino, ent->fts_statp))
+ {
+ /* This happens e.g., with "chcon -R --preserve-root ... /"
+ and with "chcon -RH --preserve-root ... symlink-to-root". */
+ ROOT_DEV_INO_WARN (file_full_name);
+ /* Tell fts not to traverse into this hierarchy. */
+ fts_set (fts, ent, FTS_SKIP);
+ /* Ensure that we do not process "/" on the second visit. */
+ ent = fts_read (fts);
+ return false;
+ }
+ return true;
+ }
break;
case FTS_DP:
if (! recurse)
- return true;
+ return true;
break;
case FTS_NS:
/* For a top-level file or directory, this FTS_NS (stat failed)
- indicator is determined at the time of the initial fts_open call.
- With programs like chmod, chown, and chgrp, that modify
- permissions, it is possible that the file in question is
- accessible when control reaches this point. So, if this is
- the first time we've seen the FTS_NS for this file, tell
- fts_read to stat it "again". */
+ indicator is determined at the time of the initial fts_open call.
+ With programs like chmod, chown, and chgrp, that modify
+ permissions, it is possible that the file in question is
+ accessible when control reaches this point. So, if this is
+ the first time we've seen the FTS_NS for this file, tell
+ fts_read to stat it "again". */
if (ent->fts_level == 0 && ent->fts_number == 0)
- {
- ent->fts_number = 1;
- fts_set (fts, ent, FTS_AGAIN);
- return true;
- }
+ {
+ ent->fts_number = 1;
+ fts_set (fts, ent, FTS_AGAIN);
+ return true;
+ }
error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
ok = false;
break;
@@ -262,7 +262,7 @@ process_file (FTS *fts, FTSENT *ent)
case FTS_DNR:
error (0, ent->fts_errno, _("cannot read directory %s"),
- quote (file_full_name));
+ quote (file_full_name));
ok = false;
break;
@@ -280,11 +280,11 @@ process_file (FTS *fts, FTSENT *ent)
if (ok)
{
if (verbose)
- printf (_("changing security context of %s\n"),
- quote (file_full_name));
+ printf (_("changing security context of %s\n"),
+ quote (file_full_name));
if (change_file_context (fts->fts_cwd_fd, file) != 0)
- ok = false;
+ ok = false;
}
if ( ! recurse)
@@ -310,15 +310,15 @@ process_files (char **files, int bit_flags)
ent = fts_read (fts);
if (ent == NULL)
- {
- if (errno != 0)
- {
- /* FIXME: try to give a better message */
- error (0, errno, _("fts_read failed"));
- ok = false;
- }
- break;
- }
+ {
+ if (errno != 0)
+ {
+ /* FIXME: try to give a better message */
+ error (0, errno, _("fts_read failed"));
+ ok = false;
+ }
+ break;
+ }
ok &= process_file (fts, ent);
}
@@ -336,7 +336,7 @@ usage (int status)
{
if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
- program_name);
+ program_name);
else
{
printf (_("\
@@ -344,7 +344,7 @@ Usage: %s [OPTION]... CONTEXT FILE...\n\
or: %s [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...\n\
or: %s [OPTION]... --reference=RFILE FILE...\n\
"),
- program_name, program_name, program_name);
+ program_name, program_name, program_name);
fputs (_("\
Change the security context of each FILE to CONTEXT.\n\
With --reference, change the security context of each FILE to that of RFILE.\n\
@@ -410,97 +410,97 @@ main (int argc, char **argv)
atexit (close_stdout);
while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:", long_options, NULL))
- != -1)
+ != -1)
{
switch (optc)
- {
- case 'H': /* Traverse command-line symlinks-to-directories. */
- bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
- break;
-
- case 'L': /* Traverse all symlinks-to-directories. */
- bit_flags = FTS_LOGICAL;
- break;
-
- case 'P': /* Traverse no symlinks-to-directories. */
- bit_flags = FTS_PHYSICAL;
- break;
-
- case 'h': /* --no-dereference: affect symlinks */
- dereference = 0;
- break;
-
- case DEREFERENCE_OPTION: /* --dereference: affect the referent
- of each symlink */
- dereference = 1;
- break;
-
- case NO_PRESERVE_ROOT:
- preserve_root = false;
- break;
-
- case PRESERVE_ROOT:
- preserve_root = true;
- break;
-
- case REFERENCE_FILE_OPTION:
- reference_file = optarg;
- break;
-
- case 'R':
- recurse = true;
- break;
-
- case 'f':
- /* ignore */
- break;
-
- case 'v':
- verbose = true;
- break;
-
- case 'u':
- specified_user = optarg;
- component_specified = true;
- break;
-
- case 'r':
- specified_role = optarg;
- component_specified = true;
- break;
-
- case 't':
- specified_type = optarg;
- component_specified = true;
- break;
-
- case 'l':
- specified_range = optarg;
- component_specified = true;
- break;
-
- case_GETOPT_HELP_CHAR;
- case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
- default:
- usage (EXIT_FAILURE);
- }
+ {
+ case 'H': /* Traverse command-line symlinks-to-directories. */
+ bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
+ break;
+
+ case 'L': /* Traverse all symlinks-to-directories. */
+ bit_flags = FTS_LOGICAL;
+ break;
+
+ case 'P': /* Traverse no symlinks-to-directories. */
+ bit_flags = FTS_PHYSICAL;
+ break;
+
+ case 'h': /* --no-dereference: affect symlinks */
+ dereference = 0;
+ break;
+
+ case DEREFERENCE_OPTION: /* --dereference: affect the referent
+ of each symlink */
+ dereference = 1;
+ break;
+
+ case NO_PRESERVE_ROOT:
+ preserve_root = false;
+ break;
+
+ case PRESERVE_ROOT:
+ preserve_root = true;
+ break;
+
+ case REFERENCE_FILE_OPTION:
+ reference_file = optarg;
+ break;
+
+ case 'R':
+ recurse = true;
+ break;
+
+ case 'f':
+ /* ignore */
+ break;
+
+ case 'v':
+ verbose = true;
+ break;
+
+ case 'u':
+ specified_user = optarg;
+ component_specified = true;
+ break;
+
+ case 'r':
+ specified_role = optarg;
+ component_specified = true;
+ break;
+
+ case 't':
+ specified_type = optarg;
+ component_specified = true;
+ break;
+
+ case 'l':
+ specified_range = optarg;
+ component_specified = true;
+ break;
+
+ case_GETOPT_HELP_CHAR;
+ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+ default:
+ usage (EXIT_FAILURE);
+ }
}
if (recurse)
{
if (bit_flags == FTS_PHYSICAL)
- {
- if (dereference == 1)
- error (EXIT_FAILURE, 0,
- _("-R --dereference requires either -H or -L"));
- affect_symlink_referent = false;
- }
+ {
+ if (dereference == 1)
+ error (EXIT_FAILURE, 0,
+ _("-R --dereference requires either -H or -L"));
+ affect_symlink_referent = false;
+ }
else
- {
- if (dereference == 0)
- error (EXIT_FAILURE, 0, _("-R -h requires -P"));
- affect_symlink_referent = true;
- }
+ {
+ if (dereference == 0)
+ error (EXIT_FAILURE, 0, _("-R -h requires -P"));
+ affect_symlink_referent = true;
+ }
}
else
{
@@ -511,17 +511,17 @@ main (int argc, char **argv)
if (argc - optind < (reference_file || component_specified ? 1 : 2))
{
if (argc <= optind)
- error (0, 0, _("missing operand"));
+ error (0, 0, _("missing operand"));
else
- error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
+ error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
usage (EXIT_FAILURE);
}
if (reference_file)
{
if (getfilecon (reference_file, &ref_context) < 0)
- error (EXIT_FAILURE, errno, _("failed to get security context of %s"),
- quote (reference_file));
+ error (EXIT_FAILURE, errno, _("failed to get security context of %s"),
+ quote (reference_file));
specified_context = ref_context;
}
@@ -536,8 +536,8 @@ main (int argc, char **argv)
specified_context = argv[optind++];
context = context_new (specified_context);
if (!context)
- error (EXIT_FAILURE, 0, _("invalid context: %s"),
- quotearg_colon (specified_context));
+ error (EXIT_FAILURE, 0, _("invalid context: %s"),
+ quotearg_colon (specified_context));
context_free (context);
}
@@ -552,8 +552,8 @@ main (int argc, char **argv)
static struct dev_ino dev_ino_buf;
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
if (root_dev_ino == NULL)
- error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
- quote ("/"));
+ error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
+ quote ("/"));
}
else
{