aboutsummaryrefslogtreecommitdiffstats
path: root/src/chroot.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot.c')
-rw-r--r--src/chroot.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/chroot.c b/src/chroot.c
index b5738df2f..a763d0354 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -56,12 +56,12 @@ enum
static struct option const long_opts[] =
{
- {"groups", required_argument, NULL, GROUPS},
- {"userspec", required_argument, NULL, USERSPEC},
- {"skip-chdir", no_argument, NULL, SKIP_CHDIR},
+ {"groups", required_argument, nullptr, GROUPS},
+ {"userspec", required_argument, nullptr, USERSPEC},
+ {"skip-chdir", no_argument, nullptr, SKIP_CHDIR},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {NULL, 0, NULL, 0}
+ {nullptr, 0, nullptr, 0}
};
#if ! HAVE_SETGROUPS
@@ -96,19 +96,19 @@ static int
parse_additional_groups (char const *groups, GETGROUPS_T **pgids,
size_t *pn_gids, bool show_errors)
{
- GETGROUPS_T *gids = NULL;
+ GETGROUPS_T *gids = nullptr;
size_t n_gids_allocated = 0;
size_t n_gids = 0;
char *buffer = xstrdup (groups);
char const *tmp;
int ret = 0;
- for (tmp = strtok (buffer, ","); tmp; tmp = strtok (NULL, ","))
+ for (tmp = strtok (buffer, ","); tmp; tmp = strtok (nullptr, ","))
{
struct group *g;
uintmax_t value;
- if (xstrtoumax (tmp, NULL, 10, &value, "") == LONGINT_OK
+ if (xstrtoumax (tmp, nullptr, 10, &value, "") == LONGINT_OK
&& value <= MAXGID)
{
while (isspace (to_uchar (*tmp)))
@@ -117,20 +117,20 @@ parse_additional_groups (char const *groups, GETGROUPS_T **pgids,
{
/* Handle the case where the name is numeric. */
g = getgrnam (tmp);
- if (g != NULL)
+ if (g != nullptr)
value = g->gr_gid;
}
/* Flag that we've got a group from the number. */
- g = (struct group *) (intptr_t) ! NULL;
+ g = (struct group *) (intptr_t) ! nullptr;
}
else
{
g = getgrnam (tmp);
- if (g != NULL)
+ if (g != nullptr)
value = g->gr_gid;
}
- if (g == NULL)
+ if (g == nullptr)
{
ret = -1;
@@ -222,15 +222,15 @@ main (int argc, char **argv)
int c;
/* Input user and groups spec. */
- char *userspec = NULL;
- char const *username = NULL;
- char const *groups = NULL;
+ char *userspec = nullptr;
+ char const *username = nullptr;
+ char const *groups = nullptr;
bool skip_chdir = false;
/* Parsed user and group IDs. */
uid_t uid = -1;
gid_t gid = -1;
- GETGROUPS_T *out_gids = NULL;
+ GETGROUPS_T *out_gids = nullptr;
size_t n_gids = 0;
initialize_main (&argc, &argv);
@@ -242,7 +242,7 @@ main (int argc, char **argv)
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "+", long_opts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "+", long_opts, nullptr)) != -1)
{
switch (c)
{
@@ -300,7 +300,7 @@ main (int argc, char **argv)
Within chroot lookup is the main justification for having
the --user option supported by the chroot command itself. */
if (userspec)
- ignore_value (parse_user_spec (userspec, &uid, &gid, NULL, NULL));
+ ignore_value (parse_user_spec (userspec, &uid, &gid, nullptr, nullptr));
/* If no gid is supplied or looked up, do so now.
Also lookup the username for use with getgroups. */
@@ -339,11 +339,11 @@ main (int argc, char **argv)
{
/* No command. Run an interactive shell. */
char *shell = getenv ("SHELL");
- if (shell == NULL)
+ if (shell == nullptr)
shell = bad_cast ("/bin/sh");
argv[0] = shell;
argv[1] = bad_cast ("-i");
- argv[2] = NULL;
+ argv[2] = nullptr;
}
else
{
@@ -357,7 +357,7 @@ main (int argc, char **argv)
{
bool warn;
char const *err = parse_user_spec_warn (userspec, &uid, &gid,
- NULL, NULL, &warn);
+ nullptr, nullptr, &warn);
if (err)
error (warn ? 0 : EXIT_CANCELED, 0, "%s", (err));
}
@@ -381,7 +381,7 @@ main (int argc, char **argv)
}
GETGROUPS_T *gids = out_gids;
- GETGROUPS_T *in_gids = NULL;
+ GETGROUPS_T *in_gids = nullptr;
if (groups && *groups)
{
if (parse_additional_groups (groups, &in_gids, &n_gids, !n_gids) != 0)