| 1 |
#! /bin/sh /usr/share/dpatch/dpatch-run
|
| 2 |
##
|
| 3 |
## DP: Add linux specific rawio capability allocation to work with kernels > 2.6.8
|
| 4 |
|
| 5 |
@DPATCH@
|
| 6 |
diff -urNad cdrtools-2.01.01~/RULES/os-linux.id cdrtools-2.01.01/RULES/os-linux.id
|
| 7 |
--- cdrtools-2.01.01~/RULES/os-linux.id 2006-03-19 21:12:06.000000000 +0100
|
| 8 |
+++ cdrtools-2.01.01/RULES/os-linux.id 2006-03-19 21:12:14.997653576 +0100
|
| 9 |
@@ -22,3 +22,5 @@
|
| 10 |
###########################################################################
|
| 11 |
O_ARCH= linux
|
| 12 |
-O_ARCH= -$(O_ARCH)
|
| 13 |
+
|
| 14 |
+LIB_CAP= -lcap
|
| 15 |
diff -urNad cdrtools-2.01.01~/cdrecord/Makefile cdrtools-2.01.01/cdrecord/Makefile
|
| 16 |
--- cdrtools-2.01.01~/cdrecord/Makefile 2006-03-19 21:12:06.000000000 +0100
|
| 17 |
+++ cdrtools-2.01.01/cdrecord/Makefile 2006-03-19 21:17:02.116004952 +0100
|
| 18 |
@@ -34,6 +34,7 @@
|
| 19 |
../include/scg/scsireg.h ../include/scg/scsitransp.h
|
| 20 |
#LIBS= -lschily $(LIB_SOCKET)
|
| 21 |
LIBS= -lrscg -lscg $(LIB_VOLMGT) -ledc_ecc -ldeflt -lschily $(SCSILIB) $(LIB_SOCKET)
|
| 22 |
+LIBS= -lrscg -lscg $(LIB_VOLMGT) -ledc_ecc -ldeflt -lschily $(SCSILIB) $(LIB_SOCKET) $(LIB_CAP)
|
| 23 |
XMK_FILE= Makefile.man Makefile.dfl
|
| 24 |
|
| 25 |
###########################################################################
|
| 26 |
diff -urNad cdrtools-2.01.01~/cdrecord/cdrecord.c cdrtools-2.01.01/cdrecord/cdrecord.c
|
| 27 |
--- cdrtools-2.01.01~/cdrecord/cdrecord.c 2006-03-19 21:12:14.227770616 +0100
|
| 28 |
+++ cdrtools-2.01.01/cdrecord/cdrecord.c 2006-03-19 21:12:14.999653272 +0100
|
| 29 |
@@ -60,6 +60,9 @@
|
| 30 |
#include "defaults.h"
|
| 31 |
#include "movesect.h"
|
| 32 |
|
| 33 |
+#ifdef __linux__
|
| 34 |
+#include <sys/capability.h> /* for rawio capability */
|
| 35 |
+#endif
|
| 36 |
|
| 37 |
char cdr_version[] = "2.01.01a06";
|
| 38 |
|
| 39 |
@@ -247,6 +250,10 @@
|
| 40 |
LOCAL void set_wrmode __PR((cdr_t *dp, int wmode, int tflags));
|
| 41 |
LOCAL void linuxcheck __PR((void));
|
| 42 |
|
| 43 |
+#ifdef __linux__
|
| 44 |
+LOCAL int get_cap __PR((cap_value_t cap_array));
|
| 45 |
+#endif
|
| 46 |
+
|
| 47 |
struct exargs {
|
| 48 |
SCSI *scgp;
|
| 49 |
cdr_t *dp;
|
| 50 |
@@ -542,6 +549,14 @@
|
| 51 |
#endif
|
| 52 |
comerr("Panic cannot set back effective uid.\n");
|
| 53 |
}
|
| 54 |
+
|
| 55 |
+#ifdef __linux__
|
| 56 |
+ /* get the rawio capability */
|
| 57 |
+ if (get_cap(CAP_SYS_RAWIO))
|
| 58 |
+ perror("Error: Cannot gain SYS_RAWIO capability."
|
| 59 |
+ "Is cdrecord installed SUID root?\n");
|
| 60 |
+#endif
|
| 61 |
+
|
| 62 |
/*
|
| 63 |
* WARNING: We now are no more able to do any privilleged operation
|
| 64 |
* unless we have been called by root.
|
| 65 |
@@ -1068,6 +1083,12 @@
|
| 66 |
if (setreuid(-1, getuid()) < 0)
|
| 67 |
comerr("Panic cannot set back effective uid.\n");
|
| 68 |
}
|
| 69 |
+#ifdef __linux__
|
| 70 |
+ if (get_cap(CAP_SYS_RAWIO))
|
| 71 |
+ perror("Error: Cannot gain SYS_RAWIO capability."
|
| 72 |
+ "Is cdrecord installed SUID root?\n");
|
| 73 |
+#endif
|
| 74 |
+
|
| 75 |
#endif
|
| 76 |
}
|
| 77 |
if ((*dp->cdr_set_speed_dummy)(scgp, dp, &speed) < 0) {
|
| 78 |
@@ -4806,3 +4827,18 @@
|
| 79 |
#endif
|
| 80 |
#endif
|
| 81 |
}
|
| 82 |
+
|
| 83 |
+#ifdef __linux__
|
| 84 |
+LOCAL int
|
| 85 |
+get_cap(cap_array)
|
| 86 |
+ cap_value_t cap_array;
|
| 87 |
+{
|
| 88 |
+ int ret;
|
| 89 |
+ cap_t capa;
|
| 90 |
+ capa = cap_get_proc();
|
| 91 |
+ cap_set_flag(capa, CAP_EFFECTIVE, 1, &cap_array, CAP_SET);
|
| 92 |
+ ret = cap_set_proc(capa);
|
| 93 |
+ cap_free(capa);
|
| 94 |
+ return ret;
|
| 95 |
+}
|
| 96 |
+#endif
|