[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
New MiNT functions (was: Re: Security stuff)
On Thu, 11 Sep 1997, Konrad M.Kokoszkiewicz wrote:
> The four thing is to add two new system calls to manage cookie jar and
> read GEMDOS veriables. Additionally, though it doesn't touch security,
> I think it might be nice to add a system call which would allow to get
> the full MiNT version number, i.e. together with the patchlevel code. As I
> now think about it, it may return a longword with four binary coded
> informations:
>
> - high byte of high word: major version number
> - low byte of high word: minor version number
> - high byte of low word: patchlevel number
> - low byte of low word: beta code (-1 = beta)
Back from holidays, I want to know you I'm still working on these functions
in MiNT kernel (only little time to finish it :-) ):
#define Tgettimeofday(tvp, tzp) \
trap_1_wll(0x155, (long)(tvp), (long)(tzp))
#define Tsettimeofday(tvp, tzp) \
trap_1_wll(0x156, (long)(tvp), (long)(tzp))
#define Tadjtime(delta, olddelta) \
trap_1_wll(0x157, (long)(delta), (long)(olddelta))
When I wrote about this cause of the new library, I made some proposal
for a MiNT-system call
Ssystem(long function, void * ptr);
That coud be used for a lot of MiNT specific things like reading system
variables, cookies, etc. and if called by root changing those.
Currently my experimental MiNT kernel includes some file like the following:
/* @(#)ssystem.c mint/freemint
* $Id$
* by jerry g geiger
* - jerry@zedat.fu-berlin.de or jerry@merlin.abacus.de
*
*
*
Ssystem(('GC'<< 16)|addr, void *pvalue)
GC, GS, GL
returns Sysvar-addr's value in pvalue: char, short, long
Ssystem(GETCOOKIE, struct Coookie *cookiep)
Ssystem(SETCOOKIE, struct Coookie *cookiep)
needs euid root; if exists change cookie
Ssystem(SETCLOCK, struct timeval *tvp);
also SETICLOCK,SETMCLOCK,SETTCLOCK
needs euid root, if ptr == NULL use current time
Ssystem(GetCLOCKT, clock_t *pvalue);
if pvalue return clock_t in there
Ssystem(OSVERSION, long *pvalue);
returns MiNT version MAJ<<24|MIN<<16|PatchLev<<8|ident
ident: 'f' for Freemint, ....
Ssystem(OSDATE, long *pvalue);
returns MiNT-compile-Date
*/
#include "time.h"
extern long set_clock(int which, struct timeval *tvp); /* see time.c */
static long get_cookie(struct Coookie *cookiep);
long s_system ARGS_ON_STACK (long mode , void *ptr)
{
int smode, isroot; /* check euid(1), ruid(2) */
switch(mode) {
case GetCLOCKT:
if(prt)
*(unsigned long *)ptr = *((unsigned long *)0x004ba); break;
case SETCLOCK:
case SETCILOCK:
case SETCMLOCK:
case SETCTLOCK:
if(!isroot)
return(EACCDN);
return(set_clock(mode&0x0f, (struct timeval *)ptr));
break;
case GETCOOKIE:
return(get_cookie((long *)ptr);
break;
case SETCOOKIE:
if(!isroot)
return(EACCDN);
return(set_cookie((long *)ptr);
default:
smode = (mode & 0xffff0000)>>16;
if(smode && !prt)
return(-1);
switch(smode) {
/* get variables */
case 'GC':
*(char *)ptr = *((char *)(mode&0xffff)); break;
case 'GS':
*(short *)ptr = *((short *)(mode&0xfffe)); break;
case 'GL':
*(long *)ptr = *((long *)(mode&0xfffe)); break;
case 'SS':
if(isroot != 2) return(EACCDN);
*((short *)(mode&0xfffe)) = *(short *)ptr; break;
case 'SL':
if(isroot != 2) return(EACCDN);
*((long *)(mode&0xfffe)) = *(long *)ptr; break;
default:
return(EINVFN);
}
}
return(0);
}
/* eof ssystem.c */
Ceterum censeo all BIOS and XBIOS system-calls should be reserved for root.
jerry
jerry@merlin.abacus.de jerry@zedat.fu-berlin.de