<title>Subjects</title>
<xi:include href="xml/polkitsubject.xml"/>
<xi:include href="xml/polkitunixprocess.xml"/>
+ <!-- <xi:include href="xml/polkitsmackprocess.xml"/> -->
<xi:include href="xml/polkitunixsession.xml"/>
<xi:include href="xml/polkitsystembusname.xml"/>
</chapter>
POLKIT_UNIX_PROCESS_GET_CLASS
</SECTION>
+<SECTION>
+<File>polkitsmackprocess</FILE>
+PolkitSmackProcess
+polkit_smack_process_get_label
+polkit_smack_process_set_label
+<SUBSECTION Standard>
+PolkitSmackProcessClass
+POLKIT_IS_SMACK_PROCESS
+POLKIT_IS_SMACK_PROCESS_CLASS
+POLKIT_SMACK_PROCESS
+POLKIT_SMACK_PROCESS_CLASS
+POLKIT_SMACK_PROCESS_GET_CLASS
+POLKIT_TYPE_AGENT_REGISTER_FLAGS
+POLKIT_TYPE_AUTHORITY_FEATURES
+POLKIT_TYPE_CHECK_AUTHORIZATION_FLAGS
+POLKIT_TYPE_IMPLICIT_AUTHORIZATION
+POLKIT_TYPE_SMACK_PROCESS
+</SECTION>
+
<SECTION>
<FILE>polkitidentity</FILE>
PolkitIdentity
polkit_unix_netgroup_get_type
polkit_subject_get_type
polkit_unix_process_get_type
+polkit_smack_process_get_type
polkit_unix_session_get_type
polkit_system_bus_name_get_type
polkit_error_get_type
polkiterror.h \
polkitsubject.h \
polkitunixprocess.h \
+ polkitunixprocessprivate.h \
polkitunixsession.h \
polkitsystembusname.h \
polkitidentity.h \
polkiterror.c polkiterror.h \
polkitsubject.c polkitsubject.h \
polkitunixprocess.c polkitunixprocess.h \
+ polkitsmackprocess.c polkitsmackprocess.h \
polkitsystembusname.c polkitsystembusname.h \
polkitidentity.c polkitidentity.h \
polkitunixuser.c polkitunixuser.h \
--- /dev/null
+/*
+ * Copyright (C) 2014 Intel, inc.
+ *
+ * This library 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Michael Leibowitz <michael.leibowitz@intel.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "polkitsmackprocess.h"
+#include "polkitunixprocess.h"
+#include "polkitunixprocessprivate.h"
+#include "polkitsubject.h"
+
+
+struct _PolkitSmackProcess
+{
+ PolkitUnixProcess parent_instance;
+
+ gchar* label;
+};
+
+struct _PolkitSmackProcessClass
+{
+ PolkitUnixProcessClass parent_class;
+};
+
+enum
+{
+ PROP_0,
+ PROP_LABEL
+};
+
+G_DEFINE_TYPE(PolkitSmackProcess, polkit_smack_process, POLKIT_TYPE_UNIX_PROCESS);
+
+static void
+polkit_smack_process_init (PolkitSmackProcess *smack_process)
+{
+ smack_process->label = NULL;
+}
+
+static void
+polkit_smack_process_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ PolkitSmackProcess *smack_process = POLKIT_SMACK_PROCESS (object);
+
+ switch (prop_id)
+ {
+ case PROP_LABEL:
+ g_value_set_string(value, smack_process->label);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+polkit_smack_process_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ PolkitSmackProcess *smack_process = POLKIT_SMACK_PROCESS (object);
+
+ switch (prop_id)
+ {
+ case PROP_LABEL:
+ polkit_smack_process_set_label (smack_process, g_value_get_string (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+polkit_smack_process_class_init (PolkitSmackProcessClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->get_property = polkit_smack_process_get_property;
+ gobject_class->set_property = polkit_smack_process_set_property;
+
+ /**
+ * PolkitSmackProcess:label:
+ *
+ * The label of the process
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_LABEL,
+ g_param_spec_string ("label",
+ "Process label",
+ "The SMACK process label",
+ NULL,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB |
+ G_PARAM_STATIC_NICK));
+}
+
+PolkitSubject *
+polkit_smack_process_new_full (gint pid,
+ guint64 start_time,
+ gint uid,
+ const gchar *label)
+{
+ return POLKIT_SUBJECT (g_object_new (POLKIT_TYPE_SMACK_PROCESS,
+ "pid", pid,
+ "start_time", start_time,
+ "uid", uid,
+ "label", label,
+ NULL));
+}
+
+
+/**
+ * polkit_smack_process_get_label:
+ * @process: A #PolkitSmackProcess.
+ *
+ * Gets the label for @process.
+ *
+ * Returns: The label for @process or NULL if unknown. The returned
+ * string is the caller's responsibility to free.
+ */
+char*
+polkit_smack_process_get_label (PolkitSmackProcess *process)
+{
+ g_return_val_if_fail (POLKIT_IS_SMACK_PROCESS (process), NULL);
+ return g_strdup(process->label);
+}
+
+
+/**
+ * polkit_smack_process_set_label:
+ * @process: A #PolkitSmackProcess
+ * @label: The label to set for the @process or NULL to unset it.
+ *
+ * Sets the label for @process
+ */
+void
+polkit_smack_process_set_label (PolkitSmackProcess *process,
+ const gchar *label)
+{
+ g_return_if_fail (POLKIT_IS_SMACK_PROCESS (process));
+ g_return_if_fail (label == NULL);
+ process->label = g_strdup(label);
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 Intel, Inc.
+ *
+ * This library 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Michael Leibowitz <michael.leibowitz@intel.com>
+ */
+
+#if !defined (_POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H)
+#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef __POLKIT_SMACK_PROCESS_H
+#define __POLKIT_SMACK_PROCESS_H
+
+#include <glib-object.h>
+#include <polkitunixprocessprivate.h>
+#include <polkit/polkittypes.h>
+
+G_BEGIN_DECLS
+
+#define POLKIT_TYPE_SMACK_PROCESS (polkit_smack_process_get_type())
+#define POLKIT_SMACK_PROCESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_TYPE_SMACK_PROCESS, PolkitSmackProcess))
+#define POLKIT_SMACK_PROCESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_TYPE_SMACK_PROCESS, PolkitSmackProcessClass))
+#define POLKIT_SMACK_PROCESS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_TYPE_SMACK_PROCESS, PolkitSmackProcessClass))
+#define POLKIT_IS_SMACK_PROCESS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_TYPE_SMACK_PROCESS))
+#define POLKIT_IS_SMACK_PROCESS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_TYPE_SMACK_PROCESS))
+
+#if 0
+typedef struct _PolkitSmackProcess PolkitSmackProcess;
+#endif
+typedef struct _PolkitSmackProcessClass PolkitSmackProcessClass;
+
+GType polkit_smack_process_get_type (void) G_GNUC_CONST;
+PolkitSubject *polkit_smack_process_new_full (gint pid,
+ guint64 start_time,
+ gint uid,
+ const gchar *label);
+char* polkit_smack_process_get_label (PolkitSmackProcess *process);
+void polkit_smack_process_set_label (PolkitSmackProcess *process,
+ const gchar *label);
+
+
+G_END_DECLS
+
+#endif /* __POLKIT_SMACK_PROCESS_H */
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include "polkitsubject.h"
#include "polkitunixprocess.h"
+#include "polkitsmackprocess.h"
#include "polkitunixsession.h"
#include "polkitsystembusname.h"
#include "polkiterror.h"
}
}
}
+ else if (g_str_has_prefix (str, "smack-process:"))
+ {
+ gint scanned_pid;
+ guint64 scanned_starttime;
+ gint scanned_uid;
+ const char *scanned_label = NULL;
+ if (sscanf (str, "smack-process:%d:%" G_GUINT64_FORMAT ":%d:%as", &scanned_pid, &scanned_starttime, &scanned_uid, &scanned_label) == 4)
+ {
+ subject = polkit_smack_process_new_full (scanned_pid, scanned_starttime, scanned_uid, scanned_label);
+ free ((void*)scanned_label);
+ }
+ }
else if (g_str_has_prefix (str, "unix-session:"))
{
subject = polkit_unix_session_new (str + sizeof "unix-session:" - 1);
g_variant_builder_add (&builder, "{sv}", "uid",
g_variant_new_int32 (polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (subject))));
}
+ else if (POLKIT_IS_SMACK_PROCESS (subject))
+ {
+ /**
+ * @FIXME: this could be dryer
+ */
+ kind = "smack-process";
+ g_variant_builder_add (&builder, "{sv}", "pid",
+ g_variant_new_uint32 (polkit_unix_process_get_pid (POLKIT_UNIX_PROCESS (subject))));
+ g_variant_builder_add (&builder, "{sv}", "start-time",
+ g_variant_new_uint64 (polkit_unix_process_get_start_time (POLKIT_UNIX_PROCESS (subject))));
+ g_variant_builder_add (&builder, "{sv}", "uid",
+ g_variant_new_int32 (polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (subject))));
+ g_variant_builder_add (&builder, "{sv}", "label",
+ g_variant_new_string (polkit_smack_process_get_label (POLKIT_SMACK_PROCESS (subject))));
+
+ }
else if (POLKIT_IS_UNIX_SESSION (subject))
{
kind = "unix-session";
&kind,
&details_gvariant);
- if (g_strcmp0 (kind, "unix-process") == 0)
+ if (g_strcmp0 (kind, "unix-process") == 0 || g_strcmp0 (kind, "smack-process") == 0)
{
GVariant *v;
guint32 pid;
uid = -1;
}
- ret = polkit_unix_process_new_for_owner (pid, start_time, uid);
+ if (g_strcmp0 (kind, "smack-process") == 0)
+ {
+ const gchar *label;
+
+ v = lookup_asv(details_gvariant, "label", G_VARIANT_TYPE_STRING, error);
+
+ if (v == NULL)
+ {
+ g_prefix_error (error, "Error parsing unix-process subject: ");
+ goto out;
+ }
+ label = g_variant_get_string(v, NULL);
+ g_variant_unref(v);
+
+ ret = polkit_smack_process_new_full (pid, start_time, uid, label);
+ }
+ else
+ {
+ ret = polkit_unix_process_new_for_owner (pid, start_time, uid);
+ }
}
else if (g_strcmp0 (kind, "unix-session") == 0)
{
struct _PolkitUnixProcess;
typedef struct _PolkitUnixProcess PolkitUnixProcess;
+struct _PolkitSmackProcess;
+typedef struct _PolkitSmackProcess PolkitSmackProcess;
+
struct _PolkitUnixSession;
typedef struct _PolkitUnixSession PolkitUnixSession;
#include <stdio.h>
#include "polkitunixprocess.h"
+#include "polkitunixprocessprivate.h"
#include "polkitsubject.h"
#include "polkitprivate.h"
#include "polkiterror.h"
* time since the kernel was started) is used.
*/
-/**
- * PolkitUnixProcess:
- *
- * The #PolkitUnixProcess struct should not be accessed directly.
- */
-struct _PolkitUnixProcess
-{
- GObject parent_instance;
-
- gint pid;
- guint64 start_time;
- gint uid;
-};
-
-struct _PolkitUnixProcessClass
-{
- GObjectClass parent_class;
-};
-
enum
{
PROP_0,
--- /dev/null
+/*
+ * Copyright (C) 2014 Intel, inc.
+ *
+ * This library 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Michael Leibowitz <michael.leibowitz@intel.com>
+ */
+
+#ifndef __POLKIT_UNIX_PROCESS_PRIVATE_H
+#define __POLKIT_UNIX_PROCESS_PRIVATE_H
+
+/**
+ * PolkitUnixProcess:
+ *
+ * The #PolkitUnixProcess struct should not be accessed directly.
+ */
+struct _PolkitUnixProcess
+{
+ GObject parent_instance;
+
+ gint pid;
+ guint64 start_time;
+ gint uid;
+};
+
+struct _PolkitUnixProcessClass
+{
+ GObjectClass parent_class;
+};
+
+#endif /* __POLKIT_UNIX_PROCESS_PRIVATE_H */