aboutsummaryrefslogtreecommitdiffstats
path: root/src/install.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/install.c')
-rw-r--r--src/install.c83
1 files changed, 42 insertions, 41 deletions
diff --git a/src/install.c b/src/install.c
index 272dfcb8f..73a3d1f0a 100644
--- a/src/install.c
+++ b/src/install.c
@@ -62,14 +62,14 @@ static bool use_default_selinux_context = true;
# define endpwent() ((void) 0)
#endif
-/* The user name that will own the files, or NULL to make the owner
+/* The user name that will own the files, or nullptr to make the owner
the current user ID. */
static char *owner_name;
/* The user ID corresponding to 'owner_name'. */
static uid_t owner_id;
-/* The group name that will own the files, or NULL to make the group
+/* The group name that will own the files, or nullptr to make the group
the current group ID. */
static char *group_name;
@@ -114,25 +114,25 @@ enum
static struct option const long_options[] =
{
- {"backup", optional_argument, NULL, 'b'},
- {"compare", no_argument, NULL, 'C'},
+ {"backup", optional_argument, nullptr, 'b'},
+ {"compare", no_argument, nullptr, 'C'},
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
- {"debug", no_argument, NULL, DEBUG_OPTION},
- {"directory", no_argument, NULL, 'd'},
- {"group", required_argument, NULL, 'g'},
- {"mode", required_argument, NULL, 'm'},
- {"no-target-directory", no_argument, NULL, 'T'},
- {"owner", required_argument, NULL, 'o'},
- {"preserve-timestamps", no_argument, NULL, 'p'},
- {"preserve-context", no_argument, NULL, PRESERVE_CONTEXT_OPTION},
- {"strip", no_argument, NULL, 's'},
- {"strip-program", required_argument, NULL, STRIP_PROGRAM_OPTION},
- {"suffix", required_argument, NULL, 'S'},
- {"target-directory", required_argument, NULL, 't'},
- {"verbose", no_argument, NULL, 'v'},
+ {"debug", no_argument, nullptr, DEBUG_OPTION},
+ {"directory", no_argument, nullptr, 'd'},
+ {"group", required_argument, nullptr, 'g'},
+ {"mode", required_argument, nullptr, 'm'},
+ {"no-target-directory", no_argument, nullptr, 'T'},
+ {"owner", required_argument, nullptr, 'o'},
+ {"preserve-timestamps", no_argument, nullptr, 'p'},
+ {"preserve-context", no_argument, nullptr, PRESERVE_CONTEXT_OPTION},
+ {"strip", no_argument, nullptr, 's'},
+ {"strip-program", required_argument, nullptr, STRIP_PROGRAM_OPTION},
+ {"suffix", required_argument, nullptr, 'S'},
+ {"target-directory", required_argument, nullptr, 't'},
+ {"verbose", no_argument, nullptr, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {NULL, 0, NULL, 0}
+ {nullptr, 0, nullptr, 0}
};
/* Compare content of opened files using file descriptors A_FD and B_FD. Return
@@ -216,8 +216,8 @@ need_copy (char const *src_name, char const *dest_name,
/* compare SELinux context if preserving */
if (selinux_enabled && x->preserve_security_context)
{
- char *file_scontext = NULL;
- char *to_scontext = NULL;
+ char *file_scontext = nullptr;
+ char *to_scontext = nullptr;
bool scontext_match;
if (getfilecon (src_name, &file_scontext) == -1)
@@ -295,11 +295,11 @@ cp_option_init (struct cp_options *x)
x->update = false;
x->require_preserve_context = false; /* Not used by install currently. */
x->preserve_security_context = false; /* Whether to copy context from src. */
- x->set_security_context = NULL; /* Whether to set sys default context. */
+ x->set_security_context = nullptr; /* Whether to set sys default context. */
x->preserve_xattr = false;
x->verbose = false;
- x->dest_info = NULL;
- x->src_info = NULL;
+ x->dest_info = nullptr;
+ x->src_info = nullptr;
}
static struct selabel_handle *
@@ -310,7 +310,7 @@ get_labeling_handle (void)
if (!initialized)
{
initialized = true;
- hnd = selabel_open (SELABEL_CTX_FILE, NULL, 0);
+ hnd = selabel_open (SELABEL_CTX_FILE, nullptr, 0);
if (!hnd)
error (0, errno, _("warning: security labeling handle failed"));
}
@@ -325,7 +325,7 @@ static void
setdefaultfilecon (char const *file)
{
struct stat st;
- char *scontext = NULL;
+ char *scontext = nullptr;
if (selinux_enabled != 1)
{
@@ -428,7 +428,7 @@ copy_file (char const *from, char const *to,
However, since !x->recursive, the call to "copy" will fail if FROM
is a directory. */
- return copy (from, to, to_dirfd, to_relname, 0, x, &copy_into_self, NULL);
+ return copy (from, to, to_dirfd, to_relname, 0, x, &copy_into_self, nullptr);
}
/* Set the attributes of file or directory NAME aka DIRFD+RELNAME.
@@ -505,8 +505,8 @@ strip (char const *name)
{
char const *safe_name = name;
if (name && *name == '-')
- safe_name = file_name_concat (".", name, NULL);
- execlp (strip_program, strip_program, safe_name, NULL);
+ safe_name = file_name_concat (".", name, nullptr);
+ execlp (strip_program, strip_program, safe_name, nullptr);
die (EXIT_FAILURE, errno, _("cannot run %s"), quoteaf (strip_program));
}
default: /* Parent. */
@@ -532,10 +532,10 @@ get_ids (void)
if (owner_name)
{
pw = getpwnam (owner_name);
- if (pw == NULL)
+ if (pw == nullptr)
{
uintmax_t tmp;
- if (xstrtoumax (owner_name, NULL, 0, &tmp, "") != LONGINT_OK
+ if (xstrtoumax (owner_name, nullptr, 0, &tmp, "") != LONGINT_OK
|| UID_T_MAX < tmp)
die (EXIT_FAILURE, 0, _("invalid user %s"),
quote (owner_name));
@@ -551,10 +551,10 @@ get_ids (void)
if (group_name)
{
gr = getgrnam (group_name);
- if (gr == NULL)
+ if (gr == nullptr)
{
uintmax_t tmp;
- if (xstrtoumax (group_name, NULL, 0, &tmp, "") != LONGINT_OK
+ if (xstrtoumax (group_name, nullptr, 0, &tmp, "") != LONGINT_OK
|| GID_T_MAX < tmp)
die (EXIT_FAILURE, 0, _("invalid group %s"),
quote (group_name));
@@ -777,18 +777,18 @@ main (int argc, char **argv)
{
int optc;
int exit_status = EXIT_SUCCESS;
- char const *specified_mode = NULL;
+ char const *specified_mode = nullptr;
bool make_backups = false;
- char const *backup_suffix = NULL;
- char *version_control_string = NULL;
+ char const *backup_suffix = nullptr;
+ char *version_control_string = nullptr;
bool mkdir_and_install = false;
struct cp_options x;
- char const *target_directory = NULL;
+ char const *target_directory = nullptr;
bool no_target_directory = false;
int n_files;
char **file;
bool strip_program_specified = false;
- char const *scontext = NULL;
+ char const *scontext = nullptr;
/* set iff kernel has extra selinux system calls */
selinux_enabled = (0 < is_selinux_enabled ());
@@ -802,14 +802,15 @@ main (int argc, char **argv)
cp_option_init (&x);
- owner_name = NULL;
- group_name = NULL;
+ owner_name = nullptr;
+ group_name = nullptr;
strip_files = false;
dir_arg = false;
umask (0);
while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z", long_options,
- NULL)) != -1)
+ nullptr))
+ != -1)
{
switch (optc)
{
@@ -989,7 +990,7 @@ main (int argc, char **argv)
struct mode_change *change = mode_compile (specified_mode);
if (!change)
die (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
- mode = mode_adjust (0, false, 0, change, NULL);
+ mode = mode_adjust (0, false, 0, change, nullptr);
dir_mode = mode_adjust (0, true, 0, change, &dir_mode_bits);
free (change);
}