/* -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- */
//
//  This file is part of the OpenVPN 3 Linux client

//  SPDX-License-Identifier: AGPL-3.0-only
//
//  Copyright (C) 2020 - 2023  OpenVPN Inc <sales@openvpn.net>
//  Copyright (C) 2020 - 2023  David Sommerseth <davids@openvpn.net>
//
//
//  This is a polkit rules file used by openvpn3-service-netcfg
//  (net.openpvn.v3.netcfg D-Bus service) to allow it to modify
//  DNS settings in systemd-resolved (org.freedesktop.resolve1 service)
//

polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.resolve1.set-dns-servers" ||
         action.id == "org.freedesktop.resolve1.set-domains" ||
         action.id == "org.freedesktop.resolve1.set-default-route" ||
         action.id == "org.freedesktop.resolve1.set-dnssec" ||
         action.id == "org.freedesktop.resolve1.set-dns-over-tls" ||
         action.id == "org.freedesktop.resolve1.revert")
        && (subject.user == "@OPENVPN_USERNAME@"))
    {
        return polkit.Result.YES;
    }
});
