[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pseudo terminals



While I was porting JOVE to MiNT I encountered a problem concerning PTYs. This
is from my README file:

- shell commands (ESC-x shell) from within JOVE DO work - but:
  - JOVE has to open a pseudo tty for this.
    In the current implementation of MiNT (I am using 4.14.7) a pty can only
    be created by root as some entries have to be written to locations that
    are only writable by root: /pipe, /dev (KGMD environment).
  - so you might consider JOVE running SUID root.
    Shell commands do work now! But all files written will belong to root
    now. Presumably that's not what you want to have.
    Besides, you CAN start a bourne shell but you CAN'T start a csh(tcsh). For
    starting a csh(tcsh), both the effective and the real user must be same
    (or something like this). Of course this could be enforced inside the
    program but I didn't include such a hack in my port because I think:
    JOVE SHOULD NOT BE RUN AS SUID ROOT!

/dev and /pipe both have the permissions 777. But I was not able to create
anything there as a nomal user. I can't beleive that only root should be able
to work with PTYs.

Maybe there is a workaround for this? Ok, the code I used to create a PTY is
not very long so here it is:

for (s = "pqrs"; ptyfd<0; s++) {
	if (*s == '\0')
		... error message and exit ...
	for (t = "0123456789abcdef"; *t; t++) {
		struct stat statbuf;

		swritef(ttybuf, sizeof(ttybuf), "u:\\pipe\\tty%c%c", *s, *t);
		if( stat(ttybuf, &statbuf) == 0 )
			continue;
		if( (ptyfd=Fcreate(ttybuf, FA_SYSTEM|FA_HIDDEN)) < 0 )
			... error message and exit ...
		strcpy(masterttybuf, ttybuf);
		swritef(ttybuf, sizeof(ttybuf), "u:\\dev\\tty%c%c", *s, *t);
		ret = Fsymlink(masterttybuf, ttybuf);
		if( ret < 0 )
			... error message and exit ...
		break;
	}
}



And before I forget:

- I had to compile JOVE with the internal codepage for ISO-8859-1 as MiNT does
  not yet support a "locale" other than "C" (at least in the Mintlibs, the
  function setlocale is only defined for the "C" locale).
  MiNT developers: Is someone working on this?


Hans