summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-08-18 23:44:35 +0000
committerLennart Poettering <lennart@poettering.net>2006-08-18 23:44:35 +0000
commite33abc30894dab740ca2fb2f864161266792ea08 (patch)
tree2bd7133b2eb9a0d2fabd402343d387de15dd61a7
parentc313b23d5f5a8ee1a5510d1cc79b8ba54c217df6 (diff)
activate SHM support on the server side only when new client supports it and when client and server have the same UID.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1277 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r--src/pulsecore/protocol-native.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 506442f5..40a83973 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -961,6 +961,15 @@ static void command_auth(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t
(unsigned long) creds->uid,
(unsigned long) creds->gid,
success);
+
+ if (c->version >= 10 &&
+ pa_mempool_is_shared(c->protocol->core->mempool) &&
+ creds->uid == getuid()) {
+
+ pa_pstream_use_shm(c->pstream, 1);
+ pa_log_info("Enabled SHM for new connection");
+ }
+
}
#endif
@@ -982,7 +991,21 @@ static void command_auth(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t
reply = reply_new(tag);
pa_tagstruct_putu32(reply, PA_PROTOCOL_VERSION);
+
+#ifdef HAVE_CREDS
+{
+ /* SHM support is only enabled after both sides made sure they are the same user. */
+
+ pa_creds ucred;
+
+ ucred.uid = getuid();
+ ucred.gid = getgid();
+
+ pa_pstream_send_tagstruct_with_creds(c->pstream, reply, &ucred);
+}
+#else
pa_pstream_send_tagstruct(c->pstream, reply);
+#endif
}
static void command_set_client_name(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
@@ -2353,8 +2376,6 @@ static void on_connection(PA_GCC_UNUSED pa_socket_server*s, pa_iochannel *io, vo
c->pstream = pa_pstream_new(p->core->mainloop, io, p->core->mempool);
assert(c->pstream);
- pa_pstream_use_shm(c->pstream, 1);
-
pa_pstream_set_recieve_packet_callback(c->pstream, pstream_packet_callback, c);
pa_pstream_set_recieve_memblock_callback(c->pstream, pstream_memblock_callback, c);
pa_pstream_set_die_callback(c->pstream, pstream_die_callback, c);