--- cdrtools-2.01a37/cdrecord/cdrecord.c.skipcheck_priv 2004-12-13 14:45:02 +0300 +++ cdrtools-2.01a37/cdrecord/cdrecord.c 2004-12-13 14:52:03 +0300 @@ -242,7 +242,7 @@ LOCAL void print_drflags __PR((cdr_t *dp 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 @@ main(ac, av) } /* * 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 @@ if (lverbose > 2) * 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 (lverbose > 2) #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,34 @@ set_wrmode(dp, wmode, tflags) } 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 +#endif +#endif + +LOCAL BOOL +linuxcheck() +{ +#if defined(linux) || defined(__linux) || defined(__linux__) +#ifdef HAVE_UNAME + struct utsname un; + if (uname(&un) >= 0) { + if ((un.release[0] == '2' && un.release[1] == '.') && + (un.release[2] == '6' && un.release[3] >= 9)) { + errmsgno(EX_BAD, + "Warning: Running on Linux-%s\n", un.release); + errmsgno(EX_BAD, + "Enabling compatability hack!\n"); + return (TRUE); + } + } +#endif + return (FALSE); +#endif +}