Skip to content

Commit 6baf090

Browse files
committed
linux: check for def->linux
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent 1653cad commit 6baf090

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libcrun/linux.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,9 @@ create_missing_devs (libcrun_container_t *container, bool binds, libcrun_error_t
17541754
dev_fds = get_private_data (container)->dev_fds;
17551755
get_private_data (container)->dev_fds = NULL;
17561756

1757+
if (! def->linux)
1758+
return 0;
1759+
17571760
devfd = openat (get_private_data (container)->rootfsfd, "dev", O_CLOEXEC | O_PATH | O_DIRECTORY);
17581761
if (UNLIKELY (devfd < 0))
17591762
return crun_make_error (err, errno, "open `/dev` directory in `%s`", rootfs);
@@ -1839,6 +1842,9 @@ do_masked_and_readonly_paths (libcrun_container_t *container, libcrun_error_t *e
18391842
int ret;
18401843
runtime_spec_schema_config_schema *def = container->container_def;
18411844

1845+
if (! def->linux)
1846+
return 0;
1847+
18421848
for (i = 0; i < def->linux->masked_paths_len; i++)
18431849
{
18441850
ret = do_masked_or_readonly_path (container, def->linux->masked_paths[i], false, false, err);
@@ -2689,7 +2695,7 @@ libcrun_set_mounts (struct container_entrypoint_s *entrypoint_args, libcrun_cont
26892695
if (rootfs == NULL || def->mounts == NULL)
26902696
return 0;
26912697

2692-
if (def->linux->rootfs_propagation)
2698+
if (def->linux && def->linux->rootfs_propagation)
26932699
rootfs_propagation = get_mount_flags (def->linux->rootfs_propagation, 0, NULL, NULL, NULL, NULL);
26942700

26952701
if ((rootfs_propagation & ALL_PROPAGATIONS_NO_REC) == 0)
@@ -3130,6 +3136,9 @@ libcrun_set_usernamespace (libcrun_container_t *container, pid_t pid, libcrun_er
31303136
if ((get_private_data (container)->unshare_flags & CLONE_NEWUSER) == 0)
31313137
return 0;
31323138

3139+
if (! def->linux)
3140+
return 0;
3141+
31333142
if (def->linux->uid_mappings_len)
31343143
{
31353144
ret = format_mount_mappings (&uid_map, def->linux->uid_mappings, def->linux->uid_mappings_len, &uid_map_len, err);

0 commit comments

Comments
 (0)