forked from Mirrors/flatpak-builder
flatpak: Add a document-unexport command
This calls org.freedesktop.portal.Documents.Delete to remove an exported file from the document database altogether.tingping/wmclass
parent
52d32da215
commit
528b1f8e29
|
@ -27,6 +27,7 @@ flatpak_SOURCES = \
|
|||
app/flatpak-builtins-build-sign.c \
|
||||
app/flatpak-builtins-repo-update.c \
|
||||
app/flatpak-builtins-document-export.c \
|
||||
app/flatpak-builtins-document-unexport.c \
|
||||
app/flatpak-builtins-document-info.c \
|
||||
$(xdp_dbus_built_sources) \
|
||||
$(NULL)
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright © 2016 Red Hat, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors:
|
||||
* Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "libgsystem.h"
|
||||
#include "libglnx/libglnx.h"
|
||||
#include "document-portal/xdp-dbus.h"
|
||||
|
||||
#include <gio/gunixfdlist.h>
|
||||
|
||||
#include "flatpak-builtins.h"
|
||||
#include "flatpak-utils.h"
|
||||
#include "flatpak-run.h"
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
gboolean
|
||||
flatpak_builtin_document_unexport (int argc, char **argv,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(GDBusConnection) session_bus = NULL;
|
||||
XdpDbusDocuments *documents;
|
||||
const char *file;
|
||||
g_autofree char *doc_id = NULL;
|
||||
|
||||
context = g_option_context_new ("FILE - Unexport a file to apps");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &argc, &argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR,
|
||||
NULL, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (argc < 2)
|
||||
return usage_error (context, "FILE must be specified", error);
|
||||
|
||||
file = argv[1];
|
||||
|
||||
session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
|
||||
if (session_bus == NULL)
|
||||
return FALSE;
|
||||
|
||||
documents = xdp_dbus_documents_proxy_new_sync (session_bus, 0,
|
||||
"org.freedesktop.portal.Documents",
|
||||
"/org/freedesktop/portal/documents",
|
||||
NULL, error);
|
||||
if (documents == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!xdp_dbus_documents_call_lookup_sync (documents, file, &doc_id, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (doc_id, "") == 0)
|
||||
{
|
||||
g_print ("Not exported\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!xdp_dbus_documents_call_delete_sync (documents, doc_id, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_document_unexport (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* FILE */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_file (completion);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -78,6 +78,7 @@ BUILTINPROTO (build_bundle)
|
|||
BUILTINPROTO (build_import)
|
||||
BUILTINPROTO (build_update_repo)
|
||||
BUILTINPROTO (document_export)
|
||||
BUILTINPROTO (document_unexport)
|
||||
BUILTINPROTO (document_info)
|
||||
BUILTINPROTO (override)
|
||||
|
||||
|
|
|
@ -61,11 +61,14 @@ static FlatpakCommand commands[] = {
|
|||
{ "\n Running applications" },
|
||||
{ "run", "Run an application", flatpak_builtin_run, flatpak_complete_run },
|
||||
{ "override", "Override permissions for an application", flatpak_builtin_override, flatpak_complete_override },
|
||||
{ "document-export", "Grant an application access to a specific file", flatpak_builtin_document_export, flatpak_complete_document_export },
|
||||
{ "document-info", "Show information about a specific file", flatpak_builtin_document_info, flatpak_complete_document_info },
|
||||
{ "make-current", "Specify default version to run", flatpak_builtin_make_current_app, flatpak_complete_make_current_app },
|
||||
{ "enter", "Enter the namespace of a running application", flatpak_builtin_enter, flatpak_complete_enter },
|
||||
|
||||
{ "\n Manage file access" },
|
||||
{ "document-export", "Grant an application access to a specific file", flatpak_builtin_document_export, flatpak_complete_document_export },
|
||||
{ "document-unexport", "Revoke access to a specific file", flatpak_builtin_document_unexport, flatpak_complete_document_unexport },
|
||||
{ "document-info", "Show information about a specific file", flatpak_builtin_document_info, flatpak_complete_document_info },
|
||||
|
||||
{ "\n Manage remote repositories" },
|
||||
{ "remote-add", "Add a new remote repository (by URL)", flatpak_builtin_add_remote, flatpak_complete_add_remote },
|
||||
{ "remote-modify", "Modify properties of a configured remote", flatpak_builtin_modify_remote, flatpak_complete_modify_remote },
|
||||
|
|
|
@ -31,6 +31,7 @@ man_MANS = \
|
|||
flatpak-override.1 \
|
||||
flatpak-enter.1 \
|
||||
flatpak-document-export.1 \
|
||||
flatpak-document-unexport.1 \
|
||||
flatpak-document-info.1 \
|
||||
flatpak-build-init.1 \
|
||||
flatpak-build.1 \
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version='1.0'?> <!--*-nxml-*-->
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
|
||||
<refentry id="flatpak-document-unexport">
|
||||
|
||||
<refentryinfo>
|
||||
<title>flatpak document-unexport</title>
|
||||
<productname>flatpak</productname>
|
||||
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Alexander</firstname>
|
||||
<surname>Larsson</surname>
|
||||
<email>alexl@redhat.com</email>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>flatpak document-unexport</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>flatpak-document-unexport</refname>
|
||||
<refpurpose>Stop exporting a file</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>flatpak document-export</command>
|
||||
<arg choice="opt" rep="repeat">OPTION</arg>
|
||||
<arg choice="plain">FILE</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
Removes the document identifies for the file from the
|
||||
document portal. This will make the document unavailable
|
||||
to all sandboxed applications.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
|
||||
<para>The following options are understood:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>-h</option></term>
|
||||
<term><option>--help</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Show help options and exit.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-v</option></term>
|
||||
<term><option>--verbose</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Print debug information during command processing.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--version</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Print version information and exit.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
|
||||
<para>
|
||||
<citerefentry><refentrytitle>flatpak</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>flatpak-document-export</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
Loading…
Reference in New Issue