Skip to content

Commit

Permalink
Implemented MAINUSER_NOPASSWORD
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotte committed Aug 27, 2024
1 parent 5a6536d commit 1793624
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ Moreover, if you need to run commands after the LXDE startup, you can create lau

List of supported **environment variables**:

| Variable | Required | Description |
| --------------- | ------------------------ | ----------------------------------------------------------------------------------------------- |
| `RESOLUTION` | No (default: 1920x1080) | Screen resolution |
| `MAINUSER_NAME` | No (default: mainuser) | Name of the main user. If set to `root`, no user will be created and the main user will be root |
| `MAINUSER_PASS` | No (default: `mainuser`) | Password of the main user (if `MAINUSER_NAME != root`) |
| `VNC_PASS` | No (default: none) | Password for the VNC server |
| `VNC_PORT` | No (default: 5901) | TCP port of the VNC server |
| `NOVNC_PORT` | No (default: 6901) | TCP port of the noVNC webserver |
| Variable | Required | Description |
| --------------------- | ------------------------ | ----------------------------------------------------------------------------------------------- |
| `RESOLUTION` | No (default: 1920x1080) | Screen resolution |
| `MAINUSER_NAME` | No (default: mainuser) | Name of the main user. If set to `root`, no user will be created and the main user will be root |
| `MAINUSER_PASS` | No (default: `mainuser`) | Password of the main user (if `MAINUSER_NAME != root`) |
| `MAINUSER_NOPASSWORD` | No (default: `false`) | Whether or not the main user should be allowed to `sudo` without password |
| `VNC_PASS` | No (default: none) | Password for the VNC server |
| `VNC_PORT` | No (default: 5901) | TCP port of the VNC server |
| `NOVNC_PORT` | No (default: 6901) | TCP port of the noVNC webserver |

## Development

Expand Down
7 changes: 7 additions & 0 deletions build/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resolution=${RESOLUTION:-1920x1080}
mainuser_name=${MAINUSER_NAME:-mainuser}
mainuser_pass=${MAINUSER_PASS:-mainuser}
unset MAINUSER_PASS
mainuser_nopassword=${MAINUSER_NOPASSWORD:-false}

vnc_pass=${VNC_PASS:-}
unset VNC_PASS
Expand Down Expand Up @@ -46,6 +47,12 @@ else
echo "Setting the user's password"
echo "$mainuser_name:$mainuser_pass" | chpasswd
fi

if [ "$mainuser_nopassword" = true ]; then
echo "Enabling sudo without password for user $mainuser_name"
install -m440 <(echo "$mainuser_name ALL=(ALL) NOPASSWD: ALL") \
"/etc/sudoers.d/$mainuser_name-nopassword"
fi
fi

##################### SUPERVISORD CONFIG MAIN REPLACEMENTS #####################
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ services:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
MAINUSER_NOPASSWORD: "true"
VNC_PASS: mainuser
1 change: 1 addition & 0 deletions example/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
- data:/data
environment:
MAINUSER_PASS: mypassword
MAINUSER_NOPASSWORD: "true"
VNC_PASS: mypassword

volumes:
Expand Down
3 changes: 0 additions & 3 deletions example/remote/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ bash helpers/shellinabox.sh

echo 'Performing basic mainuser setup'

install -m440 <(echo 'mainuser ALL=(ALL) NOPASSWD: ALL') \
/etc/sudoers.d/mainuser-nopassword

install -d -omainuser -gmainuser -m700 ~mainuser/.ssh

install -omainuser -gmainuser -m600 authorized-keys-mainuser.txt \
Expand Down

0 comments on commit 1793624

Please sign in to comment.