[aklug] Re: terminal types and curses programming

From: Christopher Howard <choward@indicium.us>
Date: Sat Jan 24 2009 - 21:39:37 AKST

On Sat, 24 Jan 2009, Shane R. Spencer wrote:

>
> Understanding the terminal files themselves will be your path to
> enlightenment. Sorry, watching I'm watching a horrible monk movie at the
> moment.
>

Darn. Well, I guess I'll have to do my homework.

> Either way, I have a question for you. Is your program something a newb
> would use or something geared more toward an experienced user? Does
> failing to acquire a curses session leave anything like database
> information or building of a file in an inconsistent or hard to recover
> state?
>
> It's great to have good error handling, but experienced users know that
> when you're missing a TERM variable lots of stuff fails to work. And
> the generic curses error message seems to work fine. It's a shame when
> libraries like libncurses assume responsibility for exiting a program on
> behalf of the main function otherwise you could easily do error handling
> based on the result code of the function causing the issue. Grr, right?

My program is a curses-based program launcher:
http://indicium.us/cgi-bin/pages/get?view=minmenu. It is meant to be
useful to anyone working in a *nix console environment.

Its purpose is to make a menu of programs available to the user in a
attractive and convenient. For most people, the TERM issue doesn't matter.

However, someone had suggested to me that the program would be a nifty way
for some companies to allow untrusted users to have access to some
programs inside a shell account, without actually having full access to
the shell. (The program can be called by the profile, so that it is the
first thing that opens when a users logs in via ssh.)

I think this could work. The issue is (as I have verified through
testing), is that if a user simply sets his TERM variable to something
nonsensical before logging in, the program will die and the user will have
immediate access to the shell. (Which is not what the company wanted.)

I thought it would be useful if there was a security option in the program
so that, if the terminal knew it couldn't initialize, instead of just
dying, it would display a message and then lock up. That would force the
user to kill his terminal and log back in.

> Shane, Out.

Somebody else mentioned setupterm: I think I've got the idea but I'm not
sure. Would this work?:

  int errret;
  if(setupterm((char *)0, 1, &errret) == ERR) {
    /* do something, maybe depending on the value of errret */
  }

This seems to make sense, from what I read in the man page.

-- 
Christopher Howard
http://indicium.us
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sat Jan 24 21:45:39 2009

This archive was generated by hypermail 2.1.8 : Sat Jan 24 2009 - 21:45:39 AKST