[Spice-devel] [RFC spice-vdagent 06/18] udscs: add udscs_get_peer_pid()
Victor Toso
victortoso at redhat.com
Tue Aug 28 06:40:15 UTC 2018
Hi,
On Tue, Aug 14, 2018 at 08:53:40PM +0200, Jakub Janků wrote:
> udscs_get_peer_cred() is currently used only in
> vdagentd.c to obtain PID, so let's drop udscs_get_peer_cred()
> and add udscs_get_peer_pid() instead.
Acked-by: Victor Toso <victortoso at redhat.com>
Pushed: https://gitlab.freedesktop.org/spice/linux/vd_agent/commit/359cceda914b37
Cheers,
Victor
> ---
> src/udscs.c | 6 +++---
> src/udscs.h | 4 ++--
> src/vdagentd/vdagentd.c | 2 +-
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/udscs.c b/src/udscs.c
> index c439f23..a77da99 100644
> --- a/src/udscs.c
> +++ b/src/udscs.c
> @@ -490,9 +490,9 @@ void udscs_destroy_server(struct udscs_server *server)
> free(server);
> }
>
> -struct ucred udscs_get_peer_cred(struct udscs_connection *conn)
> +int udscs_get_peer_pid(struct udscs_connection *conn)
> {
> - return conn->peer_cred;
> + return (int)conn->peer_cred.pid;
> }
>
> static void udscs_server_accept(struct udscs_server *server) {
> @@ -541,7 +541,7 @@ static void udscs_server_accept(struct udscs_server *server) {
>
> if (server->debug)
> syslog(LOG_DEBUG, "new client accepted: %p, pid: %d",
> - new_conn, (int)new_conn->peer_cred.pid);
> + new_conn, udscs_get_peer_pid(new_conn));
>
> if (server->connect_callback)
> server->connect_callback(new_conn);
> diff --git a/src/udscs.h b/src/udscs.h
> index 48ecf90..4f47b7f 100644
> --- a/src/udscs.h
> +++ b/src/udscs.h
> @@ -171,8 +171,8 @@ int udscs_server_fill_fds(struct udscs_server *server, fd_set *readfds,
> void udscs_server_handle_fds(struct udscs_server *server, fd_set *readfds,
> fd_set *writefds);
>
> -/* Returns the peer's user credentials. */
> -struct ucred udscs_get_peer_cred(struct udscs_connection *conn);
> +/* Returns the peer's PID. */
> +int udscs_get_peer_pid(struct udscs_connection *conn);
>
> #endif
>
> diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c
> index 8abc63c..53d5516 100644
> --- a/src/vdagentd/vdagentd.c
> +++ b/src/vdagentd/vdagentd.c
> @@ -885,7 +885,7 @@ static void agent_connect(struct udscs_connection *conn)
> }
>
> if (session_info) {
> - uint32_t pid = udscs_get_peer_cred(conn).pid;
> + uint32_t pid = udscs_get_peer_pid(conn);
> agent_data->session = session_info_session_for_pid(session_info, pid);
> }
>
> --
> 2.17.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180828/4a1a65ed/attachment.sig>
More information about the Spice-devel
mailing list