[pulseaudio-commits] r1277 - /trunk/src/pulsecore/protocol-native.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Fri Aug 18 16:44:37 PDT 2006
Author: lennart
Date: Sat Aug 19 01:44:35 2006
New Revision: 1277
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1277&root=pulseaudio&view=rev
Log:
activate SHM support on the server side only when new client supports it and when client and server have the same UID.
Modified:
trunk/src/pulsecore/protocol-native.c
Modified: trunk/src/pulsecore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/protocol-native.c?rev=1277&root=pulseaudio&r1=1276&r2=1277&view=diff
==============================================================================
--- trunk/src/pulsecore/protocol-native.c (original)
+++ trunk/src/pulsecore/protocol-native.c Sat Aug 19 01:44:35 2006
@@ -961,6 +961,15 @@
(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 @@
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 @@
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);
More information about the pulseaudio-commits
mailing list