Skip to content

Commit

Permalink
nixos/nextcloud: Do not run sudo if not needed
Browse files Browse the repository at this point in the history
Only use sudo if we are currently not running as the nextcloud user.
This is problematic when occ is called from a systemd service with
NoNewPrivileges=true
  • Loading branch information
dasJ authored and Lassulus committed Dec 7, 2019
1 parent 8582e5a commit d21f5cf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nixos/modules/services/web-apps/nextcloud.nix
Expand Up @@ -31,8 +31,12 @@ let
occ = pkgs.writeScriptBin "nextcloud-occ" ''
#! ${pkgs.stdenv.shell}
cd ${pkgs.nextcloud}
exec /run/wrappers/bin/sudo -u nextcloud \
NEXTCLOUD_CONFIG_DIR="${cfg.home}/config" \
sudo=exec
if [[ "$USER" != nextcloud ]]; then
sudo='exec /run/wrappers/bin/sudo -u nextcloud --preserve-env=NEXTCLOUD_CONFIG_DIR'
fi
export NEXTCLOUD_CONFIG_DIR="${cfg.home}/config"
$sudo \
${phpPackage}/bin/php \
-c ${pkgs.writeText "php.ini" phpOptionsStr}\
occ $*
Expand Down Expand Up @@ -420,6 +424,7 @@ in {
nextcloud-update-plugins = mkIf cfg.autoUpdateApps.enable {
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = "${occ}/bin/nextcloud-occ app:update --all";
serviceConfig.User = "nextcloud";
startAt = cfg.autoUpdateApps.startAt;
};
};
Expand Down

0 comments on commit d21f5cf

Please sign in to comment.