Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "defguard-client",
"private": false,
"version": "1.6.3",
"version": "1.6.4",
"type": "module",
"scripts": {
"dev": "npm-run-all --parallel vite typesafe-i18n",
Expand Down
39 changes: 33 additions & 6 deletions resources-linux/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,43 @@ set -e
GROUP_NAME="defguard"
SERVICE_NAME="defguard-service"

# Get the name of user who is installing the client
get_installing_user() {
# Method 1: Check standard environment variables when installing with CLI
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
INSTALLING_USER="$SUDO_USER"
elif [ -n "$USER" ] && [ "$USER" != "root" ]; then
INSTALLING_USER="$USER"
fi
if [ -n "$INSTALLING_USER" ]; then
echo "$INSTALLING_USER"
return 0
fi

# Method 2: Check loginctl for latest session
SESSION_ID=$(loginctl show-seat seat0 -p ActiveSession --value)
username=$(loginctl show-session "$SESSION_ID" -p Name --value)
Comment on lines +21 to +22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's correct to rely on seat0 being the one running the installation, but I don't know much about multi-seat environments so I could be wrong. Maybe it's better to do something like loginctl show-session $(cat /proc/self/sessionid) -p Name --value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not very familiar with multi-seat setups, but my understanding is that in typical workstation situation it's always the default seat0 since each seat corresponds to a set of hardware (keyboard, mouse etc).
There would be more than one in for example some thin-client setup, which we don't explicitly support.

I did run some tests on Ubuntu 22/24, Debian 12/13 and Fedora and this approach seems to work.

if [ -n "$username" ]; then
echo "$username"
return 0
fi

return 1
}

case "$1" in
1|configure)
# Create the group if it doesn't exist
if ! getent group "$GROUP_NAME" >/dev/null; then
groupadd --system "$GROUP_NAME"
echo "Created group $GROUP_NAME"
else
echo "Group $GROUP_NAME exists already."
fi

# Determine target user
TARGET_USER=""
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
TARGET_USER="$SUDO_USER"
elif [ -n "$USER" ] && [ "$USER" != "root" ]; then
TARGET_USER="$USER"
fi
TARGET_USER=$(get_installing_user)
echo "Installation triggered by user $TARGET_USER"

# Add user to group if we found a valid target
if [ -n "$TARGET_USER" ]; then
Expand All @@ -40,10 +62,14 @@ case "$1" in
exit 1
fi
fi
else
echo "User $TARGET_USER is not a valid target. Not adding the user to group $GROUP_NAME"
fi

# Handle systemd service
if [ -d /run/systemd/system ]; then
echo "Updating systemd service $SERVICE_NAME"

# Reload systemd to recognize new service file
systemctl daemon-reload

Expand All @@ -58,6 +84,7 @@ case "$1" in
abort-upgrade|abort-remove|abort-deconfigure)
# On failed operations, ensure service is running if it should be
if [ -d /run/systemd/system ]; then
echo "Restarting systemd service $SERVICE_NAME"
systemctl daemon-reload
if systemctl is-enabled "$SERVICE_NAME" >/dev/null 2>&1; then
systemctl start "$SERVICE_NAME" || true
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ edition = "2021"
homepage = "https://github.com/DefGuard/client"
license-file = "../LICENSE.md"
rust-version = "1.85"
version = "1.6.3"
version = "1.6.4"

[package]
name = "defguard-client"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"productName": "Defguard",
"mainBinaryName": "defguard-client",
"identifier": "net.defguard",
"version": "1.6.3",
"version": "1.6.4",
"app": {
"security": {
"capabilities": [
Expand Down
4 changes: 2 additions & 2 deletions swift/extension/VPNExtension.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 1.6.3;
MARKETING_VERSION = 1.6.4;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -417,7 +417,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 1.6.3;
MARKETING_VERSION = 1.6.4;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = net.defguard.VPNExtension;
Expand Down
Loading