#! /bin/sh /usr/share/dpatch/dpatch-run ## ## DP: Add linux specific rawio capability allocation to work with kernels > 2.6.8 @DPATCH@ diff -urNad cdrtools-2.01.01~/RULES/os-linux.id cdrtools-2.01.01/RULES/os-linux.id --- cdrtools-2.01.01~/RULES/os-linux.id 2006-03-19 21:12:06.000000000 +0100 +++ cdrtools-2.01.01/RULES/os-linux.id 2006-03-19 21:12:14.997653576 +0100 @@ -22,3 +22,5 @@ ########################################################################### O_ARCH= linux -O_ARCH= -$(O_ARCH) + +LIB_CAP= -lcap diff -urNad cdrtools-2.01.01~/cdrecord/Makefile cdrtools-2.01.01/cdrecord/Makefile --- cdrtools-2.01.01~/cdrecord/Makefile 2006-03-19 21:12:06.000000000 +0100 +++ cdrtools-2.01.01/cdrecord/Makefile 2006-03-19 21:17:02.116004952 +0100 @@ -34,6 +34,7 @@ ../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= -lrscg -lscg $(LIB_VOLMGT) -ledc_ecc -ldeflt -lschily $(SCSILIB) $(LIB_SOCKET) $(LIB_CAP) XMK_FILE= Makefile.man Makefile.dfl ########################################################################### diff -urNad cdrtools-2.01.01~/cdrecord/cdrecord.c cdrtools-2.01.01/cdrecord/cdrecord.c --- cdrtools-2.01.01~/cdrecord/cdrecord.c 2006-03-19 21:12:14.227770616 +0100 +++ cdrtools-2.01.01/cdrecord/cdrecord.c 2006-03-19 21:12:14.999653272 +0100 @@ -60,6 +60,9 @@ #include "defaults.h" #include "movesect.h" +#ifdef __linux__ +#include /* for rawio capability */ +#endif char cdr_version[] = "2.01.01a06"; @@ -247,6 +250,10 @@ LOCAL void set_wrmode __PR((cdr_t *dp, int wmode, int tflags)); LOCAL void linuxcheck __PR((void)); +#ifdef __linux__ +LOCAL int get_cap __PR((cap_value_t cap_array)); +#endif + struct exargs { SCSI *scgp; cdr_t *dp; @@ -542,6 +549,14 @@ #endif comerr("Panic cannot set back effective uid.\n"); } + +#ifdef __linux__ + /* get the rawio capability */ + if (get_cap(CAP_SYS_RAWIO)) + perror("Error: Cannot gain SYS_RAWIO capability." + "Is cdrecord installed SUID root?\n"); +#endif + /* * WARNING: We now are no more able to do any privilleged operation * unless we have been called by root. @@ -1068,6 +1083,12 @@ if (setreuid(-1, getuid()) < 0) comerr("Panic cannot set back effective uid.\n"); } +#ifdef __linux__ + if (get_cap(CAP_SYS_RAWIO)) + perror("Error: Cannot gain SYS_RAWIO capability." + "Is cdrecord installed SUID root?\n"); +#endif + #endif } if ((*dp->cdr_set_speed_dummy)(scgp, dp, &speed) < 0) { @@ -4806,3 +4827,18 @@ #endif #endif } + +#ifdef __linux__ +LOCAL int +get_cap(cap_array) + cap_value_t cap_array; +{ + int ret; + cap_t capa; + 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; +} +#endif