[Spice-devel] [RFC spice-vdagent 06/18] udscs: add udscs_get_peer_pid()
Jakub Janků
jjanku at redhat.com
Tue Aug 14 18:53:40 UTC 2018
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.
---
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
More information about the Spice-devel
mailing list