Skip to content

Commit

Permalink
Set random hostname (inspired by flatpak)
Browse files Browse the repository at this point in the history
  • Loading branch information
hartwork committed Mar 4, 2023
1 parent e64cd32 commit b2ab0eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ So what is shared with the application by default then?

- `${DISPLAY}`
- `${HOME}`
- `${HOSTNAME}` (with random 12-hex-digits value)
- `${PATH}` (with known-unavailable entries removed)
- `${TERM}`
- `${USER}`
Expand Down
10 changes: 10 additions & 0 deletions sandwine/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import glob
import logging
import os
import random
import shlex
import shutil
import signal
Expand Down Expand Up @@ -303,6 +304,10 @@ class MountTask:
required: bool = True


def random_hostname():
return ''.join(hex(random.randint(0, 15))[2:] for _ in range(12))


def create_bwrap_argv(config):
my_home = os.path.realpath(os.path.expanduser('~'))
mount_tasks = [
Expand All @@ -328,6 +333,11 @@ def create_bwrap_argv(config):
argv.add('bwrap')
argv.add('--new-session')

# Hostname
hostname = random_hostname()
env_tasks['HOSTNAME'] = hostname
argv.add('--hostname', hostname)

# Networking
if config.network:
unshare_args += ['--share-net']
Expand Down

0 comments on commit b2ab0eb

Please sign in to comment.