changeset 899:88d1edcd7cd6

[gaim-migrate @ 909] thanks again to bmiller, this time for doing this check properly. (in my defense i thought about this but was too lazy to implement it) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 13 Sep 2000 23:33:11 +0000
parents a0b3dc2d5d23
children e18815f5a4e9
files src/sound.c
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/sound.c	Wed Sep 13 23:04:38 2000 +0000
+++ b/src/sound.c	Wed Sep 13 23:33:11 2000 +0000
@@ -52,13 +52,23 @@
 {
 	struct stat stat_buf;
 	uid_t user = getuid();
-	gid_t group = getgid(); 
+	gid_t group = getgid(), 
+	      other_groups[32];
+	int i, numgroups;
+
+	if ((numgroups = getgroups (32, other_groups)) == -1)
+	  return 0;
 	if (stat(dev, &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_IWGRP) {
+		if (group == stat_buf.st_gid)
+			return 1;
+		for (i = 0; i < numgroups; i++)
+			if (other_groups[i] == stat_buf.st_gid)
+				return 1;
+	}
 	if (stat_buf.st_mode & S_IWOTH)
 		return 1;
 	return 0;