Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > 21f13155242f3dc81c4414a9b60319f5 > files > 10

cdrecord-2.01.01-0.a11.2.2mdv2007.0.src.rpm

--- cdrtools-2.01.01/cdrecord/cdrecord.c.rawio	2006-01-26 17:55:26.000000000 +0100
+++ cdrtools-2.01.01/cdrecord/cdrecord.c	2006-01-26 17:55:26.000000000 +0100
@@ -51,6 +51,7 @@
 #include <scg/scsitransp.h>
 #include <scg/scgcmd.h>		/* XXX fuer read_buffer */
 #include "scsi_scan.h"
+#include <sys/capability.h> 	/* for raw_io capability */
 
 #include "auheader.h"
 #include "cdrecord.h"
@@ -244,6 +245,7 @@
 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	int	get_cap		__PR((cap_value_t cap_array));
 
 struct exargs {
 	SCSI	*scgp;
@@ -468,6 +470,9 @@
 			printf("Waiting for data on stdin...\n");
 		wait_input();
 	}
+	/* get the rawio capability */
+	if (get_cap(CAP_SYS_RAWIO))
+	    perror("WARNING ! Cannot gain SYS_RAWIO capability ! \n");
 
 	/*
 	 * Call scg_remote() to force loading the remote SCSI transport library
@@ -530,6 +535,10 @@
 	scgp->cap->c_bsize = DATA_SEC_SIZE;
 
 
+	/* get the rawio capability */
+	if (get_cap(CAP_SYS_RAWIO))
+	    perror("WARNING ! Cannot gain SYS_RAWIO capability ! \n");
+
 	if ((flags & F_MSINFO) == 0 || lverbose) {
 		char	*vers;
 		char	*auth;
@@ -972,6 +981,11 @@
 	if (flags & F_PRATIP) {
 		comexit(0);
 	}
+
+	/* get the rawio capability */
+	if (get_cap(CAP_SYS_RAWIO))
+	    perror("WARNING ! Cannot gain SYS_RAWIO capability ! \n");
+
 	/*
 	 * The next actions should depend on the disk type.
 	 */
@@ -2928,6 +2942,10 @@
 			if (lverbose > 0 && i == 1)
 				printf("pregap1: %ld\n", trackp[1].pregapsize);
 		}
+		/* get the rawio capability */
+		if (get_cap(CAP_SYS_RAWIO))
+			perror("WARNING ! Cannot gain SYS_RAWIO capability ! \n");
+
 #endif
 		/*
 		 * tracksecks is total numbers of sectors in track (starting from
@@ -3687,6 +3705,9 @@
 			if ((*flagsp & F_MULTI) != 0)
 				trackp[0].tracktype |= TOCF_MULTI;
 		}
+		/* get the rawio capability */
+		if (get_cap(CAP_SYS_RAWIO))
+			perror("WARNING ! Cannot gain SYS_RAWIO capability ! \n");
 
 		flags = trackp[0].flags;
 
@@ -4912,3 +4933,16 @@
 #endif
 }
 
+LOCAL int
+get_cap(cap_array)
+    cap_value_t cap_array;
+{
+        int ret;
+        cap_t capa;
+        if (geteuid() != 0) return 0;
+        capa = cap_get_proc();
+        cap_set_flag(capa, CAP_EFFECTIVE,  1, &cap_array, CAP_SET);
+        ret = cap_set_proc(capa);
+        cap_free(capa);
+        return ret; 
+}
--- cdrtools-2.01.01/cdrecord/Makefile.rawio	2006-01-26 17:55:48.000000000 +0100
+++ cdrtools-2.01.01/cdrecord/Makefile	2006-01-26 17:56:00.000000000 +0100
@@ -33,7 +33,7 @@
 		../include/scg/scgio.h ../include/scg/scsidefs.h \
 		../include/scg/scsireg.h ../include/scg/scsitransp.h
 #LIBS=		-lschily $(LIB_SOCKET)
-LIBS=		-lrscg -lscg $(LIB_VOLMGT) -ledc_ecc -ldeflt -lschily $(SCSILIB) $(LIB_SOCKET)
+LIBS=		-lcap -lrscg -lscg $(LIB_VOLMGT) -ledc_ecc -ldeflt -lschily $(SCSILIB) $(LIB_SOCKET)
 XMK_FILE=	Makefile.man Makefile.dfl
 
 ###########################################################################