Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1578233
 поиск   регистрация   авторизация 
 
Группа :: Архивирование/Создание CD
Пакет: cdrtools

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: cdrtools-2.01a37-skipcheck_priv.patch


--- cdrtools-2.01a37/cdrecord/cdrecord.c.skipcheck_priv	2004-12-14 00:00:12 +0300
+++ cdrtools-2.01a37/cdrecord/cdrecord.c	2005-01-05 12:24:06 +0300
@@ -242,7 +242,7 @@
 LOCAL	void	print_wrmodes	__PR((cdr_t *dp));
 LOCAL	BOOL	check_wrmode	__PR((cdr_t *dp, int wmode, int tflags));
 LOCAL	void	set_wrmode	__PR((cdr_t *dp, int wmode, int tflags));
-LOCAL	void	linuxcheck	__PR((void));
+LOCAL	BOOL	linuxcheck	__PR((void));
 
 struct exargs {
 	SCSI	*scgp;
@@ -465,8 +465,10 @@
 	}
 	/*
 	 * XXX Below this point we do not need root privilleges anymore.
+	 *
+	 * XXX Skip this on Linux kernel >= 2.6.9
 	 */
-	if (geteuid() != getuid()) {	/* AIX does not like to do this */
+	if (geteuid() != getuid() && !linuxcheck()) {	/* AIX does not like to do this */
 					/* If we are not root		*/
 #ifdef	HAVE_SETREUID
 		if (setreuid(-1, getuid()) < 0)
@@ -982,8 +984,10 @@
 		 * Note that we need to find a more general way that works
 		 * even on OS that do not support getreuid() which is *BSD
 		 * and SUSv3 only.
+		 *
+		 * XXX Skip this on Linux kernel >= 2.6.9
 		 */
-		if (oeuid != getuid()) {
+		if (oeuid != getuid() && !linuxcheck()) {
 			if (setreuid(-1, oeuid) < 0)
 				errmsg("Could set back effective uid.\n");
 		}
@@ -1000,8 +1004,10 @@
 #if defined(USE_POSIX_PRIORITY_SCHEDULING) && defined(HAVE_SETREUID)
 		/*
 		 * XXX Below this point we never need root privilleges anymore.
+		 *
+		 * XXX Skip this on Linux kernel >= 2.6.9
 		 */
-		if (geteuid() != getuid()) {	/* AIX does not like to do this */
+		if (geteuid() != getuid() && !linuxcheck()) {	/* AIX does not like to do this */
 						/* If we are not root		*/
 			if (setreuid(-1, getuid()) < 0)
 				comerr("Panic cannot set back effective uid.\n");
@@ -4619,3 +4625,37 @@
 	}
 	dsp->ds_wrmode = WM_NONE;
 }
+/*
+ * Kludge for checking linux kernel version
+ * enabling this hack only for >= 2.6.9 kernel
+ *
+ */
+#if    defined(linux) || defined(__linux) || defined(__linux__)
+#ifdef HAVE_UNAME
+#include <sys/utsname.h>
+#endif
+#endif
+
+LOCAL BOOL
+linuxcheck()
+{
+#if    defined(linux) || defined(__linux) || defined(__linux__)
+#ifdef HAVE_UNAME
+	static struct utsname un;
+	int a=0, b=0, c=0, n;
+
+	uname(&un);
+	n=sscanf(un.release, "%d.%d.%d", &a, &b, &c);
+	if (n == 3) {
+		if (a == 2 && b == 6 && c >= 9 ) { 
+			errmsgno(EX_BAD,
+			"Warning: Linux kernel version is %d.%d.%d\n", a, b, c);
+			errmsgno(EX_BAD,
+			"Enabling compatibility hack!\n");
+			return (TRUE);
+		}
+	}
+#endif
+	return (FALSE);
+#endif
+}
 
design & coding: Vladimir Lettiev aka crux © 2004-2005