Unverified Commit ba5a6f19 authored by Robert Hensing's avatar Robert Hensing Committed by GitHub
Browse files

Merge pull request #312516 from Stunkymonkey/nixos-swap-umask

nixos/swap: prefer 'umask' over 'chmod'
parents b0498a19 615d19be
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -275,7 +275,6 @@ in
                    chattr +C "$DEVICE" 2>/dev/null || true

                    dd if=/dev/zero of="$DEVICE" bs=1M count=${toString sw.size}
                    chmod 0600 ${sw.device}
                    ${optionalString (!sw.randomEncryption.enable) "mkswap ${sw.realDevice}"}
                  fi
                ''}
@@ -292,9 +291,12 @@ in

            unitConfig.RequiresMountsFor = [ "${dirOf sw.device}" ];
            unitConfig.DefaultDependencies = false; # needed to prevent a cycle
            serviceConfig.Type = "oneshot";
            serviceConfig.RemainAfterExit = sw.randomEncryption.enable;
            serviceConfig.ExecStop = optionalString sw.randomEncryption.enable "${pkgs.cryptsetup}/bin/cryptsetup luksClose ${sw.deviceName}";
            serviceConfig = {
              Type = "oneshot";
              RemainAfterExit = sw.randomEncryption.enable;
              UMask = "0177";
              ExecStop = optionalString sw.randomEncryption.enable "${pkgs.cryptsetup}/bin/cryptsetup luksClose ${sw.deviceName}";
            };
            restartIfChanged = false;
          };