Skip to content

Commit 28cf9ab

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 6f444e0 commit 28cf9ab

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
@@ -57,6 +57,8 @@ def add_common_args(parser):
5757
help="Directory where the build-dependency RPMs will be taken from.")
5858
group.add_argument('--no-update', action='store_true',
5959
help='do not run "yum update" on container start, use it as it was at build time')
60+
group.add_argument('--no-network', action='store_true',
61+
help='disable all networking support in the build environment')
6062

6163
def add_container_args(parser):
6264
group = parser.add_argument_group("container arguments")
@@ -212,6 +214,11 @@ def container(args):
212214
docker_args += ["-e", "DISABLEREPO=%s" % args.disablerepo]
213215
if args.no_update:
214216
docker_args += ["-e", "NOUPDATE=1"]
217+
if args.no_network:
218+
docker_args += ["--network", "none"]
219+
220+
if args.no_network and not args.no_update:
221+
print("WARNING: network disabled but --no-update not passed", file=sys.stderr)
215222

216223
# container args
217224
if args.volume:
@@ -248,6 +255,9 @@ def container(args):
248255
# action-specific
249256
match args.action:
250257
case 'build':
258+
if args.no_network and not args.local_repo:
259+
print("WARNING: network disabled but --local-repo not passed", file=sys.stderr)
260+
251261
build_dir = os.path.abspath(args.source_dir)
252262
if args.define:
253263
docker_args += ["-e", "RPMBUILD_DEFINE=%s" % args.define]

0 commit comments

Comments
 (0)