summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/iochannel.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-07-19 21:48:35 +0000
committerLennart Poettering <lennart@poettering.net>2006-07-19 21:48:35 +0000
commita382492204ad3588c0c837e120e5bc31578df72a (patch)
tree3b9abb372bc4f5882136be2eaa821cc7f137a4b3 /src/pulsecore/iochannel.c
parent340803b30c154ead29795454416592ff9d0e0df2 (diff)
* add new function pa_check_in_group()
* abstract credential APis a little bit by introducing HAVE_CREDS and a structure pa_creds * rework credential authentication * fix module-volume-restore and friends for usage in system-wide instance * remove loopback= argument from moulde-*-protocol-tcp since it is a superset of listen= and usually a bad idea anyway since the user shouldn't load the TCP module at all if he doesn't want remote access * rename a few variables in the jack modules to make sure they don't conflict with symbols defined in the system headers * add server address for system-wide daemons to the default server list for the the client libs * update todo git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1109 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/iochannel.c')
-rw-r--r--src/pulsecore/iochannel.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/pulsecore/iochannel.c b/src/pulsecore/iochannel.c
index 852e960e..b50293bf 100644
--- a/src/pulsecore/iochannel.c
+++ b/src/pulsecore/iochannel.c
@@ -231,7 +231,7 @@ ssize_t pa_iochannel_read(pa_iochannel*io, void*data, size_t l) {
return r;
}
-#ifdef SCM_CREDENTIALS
+#ifdef HAVE_CREDS
int pa_iochannel_creds_supported(pa_iochannel *io) {
struct sockaddr_un sa;
@@ -263,7 +263,7 @@ int pa_iochannel_creds_enable(pa_iochannel *io) {
return 0;
}
-ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l, const struct ucred *ucred) {
+ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l, const pa_creds *ucred) {
ssize_t r;
struct msghdr mh;
struct iovec iov;
@@ -288,10 +288,11 @@ ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l
u = (struct ucred*) CMSG_DATA(cmsg);
- if (ucred)
- *u = *ucred;
- else {
- u->pid = getpid();
+ u->pid = getpid();
+ if (ucred) {
+ u->uid = ucred->uid;
+ u->gid = ucred->gid;
+ } else {
u->uid = getuid();
u->gid = getgid();
}
@@ -313,7 +314,7 @@ ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l
return r;
}
-ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, struct ucred *ucred, int *creds_valid) {
+ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_creds *creds, int *creds_valid) {
ssize_t r;
struct msghdr mh;
struct iovec iov;
@@ -323,7 +324,7 @@ ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, struc
assert(data);
assert(l);
assert(io->ifd >= 0);
- assert(ucred);
+ assert(creds);
assert(creds_valid);
memset(&iov, 0, sizeof(iov));
@@ -349,8 +350,12 @@ ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, struc
for (cmsg = CMSG_FIRSTHDR(&mh); cmsg; cmsg = CMSG_NXTHDR(&mh, cmsg)) {
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDENTIALS) {
+ struct ucred u;
assert(cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred)));
- memcpy(ucred, CMSG_DATA(cmsg), sizeof(struct ucred));
+ memcpy(&u, CMSG_DATA(cmsg), sizeof(struct ucred));
+
+ creds->gid = u.gid;
+ creds->uid = u.uid;
*creds_valid = 1;
break;
}
@@ -362,27 +367,8 @@ ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, struc
return r;
}
-#else /* SCM_CREDENTIALS */
-
-int pa_iochannel_creds_supported(pa_iochannel *io) {
- return 0;
-}
-
-int pa_iochannel_creds_enable(pa_iochannel *io) {
- return -1;
-}
-
-ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l) {
- pa_log_error("pa_iochannel_write_with_creds() not supported.");
- return -1;
-}
-
-ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, struct ucred *ucred, int *creds_valid) {
- pa_log_error("pa_iochannel_read_with_creds() not supported.");
- return -1;
-}
-#endif /* SCM_CREDENTIALS */
+#endif /* HAVE_CREDS */
void pa_iochannel_set_callback(pa_iochannel*io, pa_iochannel_cb_t _callback, void *userdata) {
assert(io);