]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/spawn-polkit-agent.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / shared / spawn-polkit-agent.h
index b91d20f1200eec40933bc0977e870c325d9bc4cd..9f26fa10a7fa2f0b53c9f961ae846f243f29b8a6 100644 (file)
@@ -1,7 +1,5 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foospawnpolkitagenthfoo
-#define foospawnpolkitagenthfoo
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
 
 /***
   This file is part of systemd.
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include "bus-util.h"
+
 int polkit_agent_open(void);
 void polkit_agent_close(void);
 
-#endif
+static inline void polkit_agent_open_if_enabled(
+                BusTransport transport,
+                bool ask_password) {
+
+        /* Open the polkit agent as a child process if necessary */
+
+        if (transport != BUS_TRANSPORT_LOCAL)
+                return;
+
+        if (!ask_password)
+                return;
+
+        polkit_agent_open();
+}