mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
device: Get sender from invocation instead that during username check
We now can get an invocation-owned sender at any moment with GDBus, so there's no point of getting it as optional return-out value from the username check function.
This commit is contained in:
committed by
Benjamin Berg
parent
9d3f3fcaca
commit
4e7cf47a3d
15
src/device.c
15
src/device.c
@ -454,7 +454,6 @@ static char *
|
|||||||
_fprint_device_check_for_username (FprintDevice *rdev,
|
_fprint_device_check_for_username (FprintDevice *rdev,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
const char *username,
|
const char *username,
|
||||||
char **ret_sender,
|
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(GVariant) ret = NULL;
|
g_autoptr(GVariant) ret = NULL;
|
||||||
@ -498,8 +497,6 @@ _fprint_device_check_for_username (FprintDevice *rdev,
|
|||||||
* own data, this should be followed by PolicyKit checks
|
* own data, this should be followed by PolicyKit checks
|
||||||
* anyway */
|
* anyway */
|
||||||
if (username == NULL || *username == '\0' || g_str_equal (username, user->pw_name)) {
|
if (username == NULL || *username == '\0' || g_str_equal (username, user->pw_name)) {
|
||||||
if (ret_sender != NULL)
|
|
||||||
*ret_sender = g_strdup (sender);
|
|
||||||
return g_strdup (user->pw_name);
|
return g_strdup (user->pw_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,9 +508,6 @@ _fprint_device_check_for_username (FprintDevice *rdev,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret_sender != NULL)
|
|
||||||
*ret_sender = g_strdup (sender);
|
|
||||||
|
|
||||||
return g_strdup (username);
|
return g_strdup (username);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,14 +610,11 @@ static gboolean fprint_device_claim (FprintDBusDevice *dbus_dev,
|
|||||||
|
|
||||||
g_assert_null(priv->session);
|
g_assert_null(priv->session);
|
||||||
|
|
||||||
sender = NULL;
|
|
||||||
user = _fprint_device_check_for_username (rdev,
|
user = _fprint_device_check_for_username (rdev,
|
||||||
invocation,
|
invocation,
|
||||||
username,
|
username,
|
||||||
&sender,
|
|
||||||
&error);
|
&error);
|
||||||
if (user == NULL) {
|
if (user == NULL) {
|
||||||
g_free (sender);
|
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -633,19 +624,19 @@ static gboolean fprint_device_claim (FprintDBusDevice *dbus_dev,
|
|||||||
FPRINTD_DEVICE_ACTION_VERIFY,
|
FPRINTD_DEVICE_ACTION_VERIFY,
|
||||||
FPRINTD_DEVICE_ACTION_ENROLL,
|
FPRINTD_DEVICE_ACTION_ENROLL,
|
||||||
&error)) {
|
&error)) {
|
||||||
g_free (sender);
|
|
||||||
g_free (user);
|
g_free (user);
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sender = g_strdup (g_dbus_method_invocation_get_sender (invocation));
|
||||||
_fprint_device_add_client (rdev, sender);
|
_fprint_device_add_client (rdev, sender);
|
||||||
|
|
||||||
priv->session = g_new0(SessionData, 1);
|
priv->session = g_new0(SessionData, 1);
|
||||||
priv->session->invocation = g_object_ref (invocation);
|
priv->session->invocation = g_object_ref (invocation);
|
||||||
priv->session->username = user;
|
priv->session->username = user;
|
||||||
priv->session->sender = sender;
|
priv->session->sender = g_steal_pointer (&sender);
|
||||||
|
|
||||||
g_debug ("user '%s' claiming the device: %d", priv->session->username, priv->id);
|
g_debug ("user '%s' claiming the device: %d", priv->session->username, priv->id);
|
||||||
|
|
||||||
@ -1324,7 +1315,6 @@ static gboolean fprint_device_list_enrolled_fingers (FprintDBusDevice *dbus_dev,
|
|||||||
user = _fprint_device_check_for_username (rdev,
|
user = _fprint_device_check_for_username (rdev,
|
||||||
invocation,
|
invocation,
|
||||||
username,
|
username,
|
||||||
NULL,
|
|
||||||
&error);
|
&error);
|
||||||
if (user == NULL) {
|
if (user == NULL) {
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
@ -1468,7 +1458,6 @@ static gboolean fprint_device_delete_enrolled_fingers (FprintDBusDevice *dbus_de
|
|||||||
user = _fprint_device_check_for_username (rdev,
|
user = _fprint_device_check_for_username (rdev,
|
||||||
invocation,
|
invocation,
|
||||||
username,
|
username,
|
||||||
NULL,
|
|
||||||
&error);
|
&error);
|
||||||
if (user == NULL) {
|
if (user == NULL) {
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
|
|||||||
Reference in New Issue
Block a user