/*
 *
 * xpriv.c
 * 
 * for the xradiotrack program, adapted frpm gideon le grange's original
 *
 * this is the code to request iopl and to then relinquish the root 
 * privs. strictly it is not neccesary to give up the root stuff, 
 * but I feel it s more elegant to play it safe 
 * 
*/

#include <unistd.h>
#include <stdio.h>

int get_io_privs(unsigned long baseport)
{
   /* get ioperm for RadioTrack range */
   int err;
   
   err=ioperm(baseport,4,0xFFFF);  /* i could not deduce from 
				    * man page what turn_on must 
				    * be */
   return(err);
}

int give_up_root(void)
{
   /* get the real uid and give up root */
   uid_t uid;
   int err; 
   
   uid=getuid();
   err=seteuid(uid);
   return(err);
}

