mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
GCredentials: add getter/setter for the Unix process ID
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=687920
This commit is contained in:
parent
602714a8da
commit
8f65536504
@ -2487,6 +2487,7 @@ g_credentials_set_native
|
|||||||
g_credentials_is_same_user
|
g_credentials_is_same_user
|
||||||
g_credentials_get_unix_user
|
g_credentials_get_unix_user
|
||||||
g_credentials_set_unix_user
|
g_credentials_set_unix_user
|
||||||
|
g_credentials_get_unix_pid
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
G_CREDENTIALS
|
G_CREDENTIALS
|
||||||
G_IS_CREDENTIALS
|
G_IS_CREDENTIALS
|
||||||
|
@ -441,6 +441,48 @@ g_credentials_get_unix_user (GCredentials *credentials,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_credentials_get_unix_pid:
|
||||||
|
* @credentials: A #GCredentials
|
||||||
|
* @error: Return location for error or %NULL.
|
||||||
|
*
|
||||||
|
* Tries to get the UNIX process identifier from @credentials. This
|
||||||
|
* method is only available on UNIX platforms.
|
||||||
|
*
|
||||||
|
* This operation can fail if #GCredentials is not supported on the
|
||||||
|
* OS or if the native credentials type does not contain information
|
||||||
|
* about the UNIX process ID.
|
||||||
|
*
|
||||||
|
* Returns: The UNIX process ID, or -1 if @error is set.
|
||||||
|
*
|
||||||
|
* Since: 2.36
|
||||||
|
*/
|
||||||
|
pid_t
|
||||||
|
g_credentials_get_unix_pid (GCredentials *credentials,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
pid_t ret;
|
||||||
|
|
||||||
|
g_return_val_if_fail (G_IS_CREDENTIALS (credentials), -1);
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, -1);
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
ret = credentials->native.pid;
|
||||||
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
|
ret = credentials->native.cmcred_pid;
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
ret = credentials->native.pid;
|
||||||
|
#else
|
||||||
|
ret = -1;
|
||||||
|
g_set_error_literal (error,
|
||||||
|
G_IO_ERROR,
|
||||||
|
G_IO_ERROR_NOT_SUPPORTED,
|
||||||
|
_("GCredentials does not contain a process ID on this OS"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_credentials_set_unix_user:
|
* g_credentials_set_unix_user:
|
||||||
* @credentials: A #GCredentials.
|
* @credentials: A #GCredentials.
|
||||||
@ -488,4 +530,5 @@ g_credentials_set_unix_user (GCredentials *credentials,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* G_OS_UNIX */
|
#endif /* G_OS_UNIX */
|
||||||
|
@ -64,6 +64,9 @@ gboolean g_credentials_is_same_user (GCredentials *credentials,
|
|||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
|
GLIB_AVAILABLE_IN_2_36
|
||||||
|
pid_t g_credentials_get_unix_pid (GCredentials *credentials,
|
||||||
|
GError **error);
|
||||||
uid_t g_credentials_get_unix_user (GCredentials *credentials,
|
uid_t g_credentials_get_unix_user (GCredentials *credentials,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean g_credentials_set_unix_user (GCredentials *credentials,
|
gboolean g_credentials_set_unix_user (GCredentials *credentials,
|
||||||
|
@ -1228,6 +1228,7 @@ g_credentials_get_native
|
|||||||
g_credentials_set_native
|
g_credentials_set_native
|
||||||
g_credentials_is_same_user
|
g_credentials_is_same_user
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
|
g_credentials_get_unix_pid
|
||||||
g_credentials_get_unix_user
|
g_credentials_get_unix_user
|
||||||
g_credentials_set_unix_user
|
g_credentials_set_unix_user
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user