Mercurial > pidgin.yaz
changeset 63:12894b62d206
[gaim-migrate @ 73]
Added check to make sure we really can open /dev/audio
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 27 Mar 2000 03:16:21 +0000 |
parents | 03b65653798b |
children | b1d7336cba85 |
files | src/sound.c |
diffstat | 1 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/sound.c Mon Mar 27 01:09:13 2000 +0000 +++ b/src/sound.c Mon Mar 27 03:16:21 2000 +0000 @@ -27,6 +27,9 @@ #include <fcntl.h> #include <sys/wait.h> #include <sys/signal.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> #ifdef ESD_SOUND #include <esd.h> @@ -56,9 +59,18 @@ static int can_play_audio() { - /* FIXME check for write access and such. */ - return 1; - + struct stat *stat_buf; + uid_t user = getuid(); + gid_t group = getgid(); + if (stat("/dev/audio", stat_buf)) + return 0; + if (user == stat_buf->st_uid && stat_buf->st_mode & S_IWUSR) + return 1; + if (group == stat_buf->st_gid && stat_buf->st_mode & S_IWGRP) + return 1; + if (stat_buf->st_mode & S_IWOTH) + return 1; + return 0; }