Sophie

Sophie

distrib > Mandriva > 2009.1 > x86_64 > by-pkgid > ab2173dee9acec0882077681534bc924 > files > 38

pulseaudio-0.9.15-2.1mdv2009.1.src.rpm


http://git.0pointer.de/?p=pulseaudio.git;a=patch;h=d3efa43d85ac132c6a5a416a2b6f2115f5d577ee

diff -Naurp pulseaudio-0.9.15/configure.ac pulseaudio-0.9.15.oden/configure.ac
--- pulseaudio-0.9.15/configure.ac	2010-03-19 05:56:13.000000000 -0400
+++ pulseaudio-0.9.15.oden/configure.ac	2010-03-19 05:55:47.000000000 -0400
@@ -409,7 +409,7 @@ AC_CHECK_FUNCS([lrintf strtof])
 AC_FUNC_FORK
 AC_FUNC_GETGROUPS
 AC_FUNC_SELECT_ARGTYPES
-AC_CHECK_FUNCS([chmod chown clock_gettime getaddrinfo getgrgid_r getgrnam_r \
+AC_CHECK_FUNCS([chmod chown fstat fchown fchmod clock_gettime getaddrinfo getgrgid_r getgrnam_r \
     getpwnam_r getpwuid_r gettimeofday getuid inet_ntop inet_pton mlock nanosleep \
     pipe posix_fadvise posix_madvise posix_memalign setpgid setsid shm_open \
     sigaction sleep sysconf pthread_setaffinity_np])
diff -Naurp pulseaudio-0.9.15/src/pulsecore/core-util.c pulseaudio-0.9.15.oden/src/pulsecore/core-util.c
--- pulseaudio-0.9.15/src/pulsecore/core-util.c	2009-04-13 17:11:32.000000000 -0400
+++ pulseaudio-0.9.15.oden/src/pulsecore/core-util.c	2010-03-19 05:55:06.000000000 -0400
@@ -178,7 +178,7 @@ void pa_make_fd_cloexec(int fd) {
 /** Creates a directory securely */
 int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
     struct stat st;
-    int r, saved_errno;
+    int r, saved_errno, fd;
 
     pa_assert(dir);
 
@@ -196,16 +196,45 @@ int pa_make_secure_dir(const char* dir, 
     if (r < 0 && errno != EEXIST)
         return -1;
 
-#ifdef HAVE_CHOWN
+#ifdef HAVE_FSTAT
+    if ((fd = open(dir,
+#ifdef O_CLOEXEC
+                   O_CLOEXEC|
+#endif
+#ifdef O_NOCTTY
+                   O_NOCTTY|
+#endif
+#ifdef O_NOFOLLOW
+                   O_NOFOLLOW|
+#endif
+                   O_RDONLY)) < 0)
+        goto fail;
+
+    if (fstat(fd, &st) < 0) {
+        pa_assert_se(pa_close(fd) >= 0);
+        goto fail;
+    }
+
+    if (!S_ISDIR(st.st_mode)) {
+        pa_assert_se(pa_close(fd) >= 0);
+        errno = EEXIST;
+        goto fail;
+    }
+
+#ifdef HAVE_FCHOWN
     if (uid == (uid_t)-1)
         uid = getuid();
     if (gid == (gid_t)-1)
         gid = getgid();
-    (void) chown(dir, uid, gid);
+    (void) fchown(fd, uid, gid);
+#endif
+
+#ifdef HAVE_FCHMOD
+    (void) fchmod(fd, m);
 #endif
 
-#ifdef HAVE_CHMOD
-    chmod(dir, m);
+    pa_assert_se(pa_close(fd) >= 0);
+
 #endif
 
 #ifdef HAVE_LSTAT