Skip to content

Commit ead3369

Browse files
committed
Add --no-network option
Completely disables network inside the container, making sure we fully control the supply chain. Signed-off-by: Yann Dirson <[email protected]>
1 parent 9a83bbc commit ead3369

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/xcp_ng_dev/cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def add_common_args(parser):
5656
'If both --enablerepo and --disablerepo are set, --disablerepo will be applied first')
5757
group.add_argument('--no-update', action='store_true',
5858
help='do not run "yum update" on container start, use it as it was at build time')
59+
group.add_argument('--no-network', action='store_true',
60+
help='disable all networking support in the build environment')
5961

6062
def add_container_args(parser):
6163
group = parser.add_argument_group("container arguments")
@@ -196,6 +198,11 @@ def container(args):
196198
docker_args += ["-e", "DISABLEREPO=%s" % args.disablerepo]
197199
if args.no_update:
198200
docker_args += ["-e", "NOUPDATE=1"]
201+
if args.no_network:
202+
docker_args += ["--network", "none"]
203+
204+
if args.no_network and not args.no_update:
205+
print("WARNING: network disabled but --no-update not passed", file=sys.stderr)
199206

200207
# container args
201208
if args.volume:
@@ -228,6 +235,9 @@ def container(args):
228235
# action-specific
229236
match args.action:
230237
case 'build':
238+
if args.no_network and not args.builddep_dir:
239+
print("WARNING: network disabled but --builddep-dir not passed", file=sys.stderr)
240+
231241
build_dir = os.path.abspath(args.source_dir)
232242
if args.define:
233243
docker_args += ["-e", "RPMBUILD_DEFINE=%s" % args.define]

0 commit comments

Comments
 (0)