NAME

POSIX Shell Server and Login Services - posh

SYNOPSIS

#include <posh_init.h>

pthread_create(&poshTid, &poshattr, (void *)(&posh), set_posh_tty);
int posh(void *ptr_posh_init)
int add_user( char *user, char * pswd )
int delete_user( char *user)
int check_password( char *user, char * pswd )
int update_password( char *user, char * oldpswd, char * pswd )

DESCRIPTION

The posh server provides a shell for user interaction via telnet or serial file I/O. Typically, when initialized, it allows users to query files, examine the file structure, create new files and look at the content of files. It is a minimal implementation for memory reasons. It does not support scripting of any kind and only supports a minimal set of commands.

The posh server inputs characters and outputs results of command requests. The first command request is a login request. Unlike many implementations, the login support is contained within posh - it does not have a separate thread for this purpose. The .login file is specified at posh creation time in the initialization structure.

The initialization structure also specifies the mount points for two file systems. These mount points are important to avoid attempts to list non-existent files. Setup these mount points at creation time for proper operation.

The final elements of the initalization structure are the input and output streams. These two are specified as files. The structure is shown below.

The login services are provided by the posh server library. These login services allow users to identify users and passwords, update users and passwords and create new password files. These functions are usable when posh is included in the system.

RETURN VALUES

All login functions return 0 on success, -2 on a missing user if the password is being updated and -1 on all other conditions like missing login file or failed user - password.

ERRORS

All errors are handled by the return values.

EXAMPLE

Posh initialization structure.

struct set_posh
{
    char *stdinstring;          // set the input stream
    char *stdoutstring;         // set output stream
    char *mountpoint;           // set first file mount point
    char *mountpoint2;          // set second file mount point
    char *loginfile;
};

This partial example shows the creation and registration of the posh server. After creation, posh may be accessed via the serial port setup for input and output.

THREAD Main(void *arg)
{
        int mystatus;

        pthread_t poshTid;
        pthread_attr_t poshattr;
        struct sched_param poshPriority;
        struct set_posh *set_posh_tty;

        xprintf("Start Main\n");

        posix_compat("", "/dev/ttyS0", "/dev/ttyS0");

        printf("Start tty, fsys with posix_compat\n");

        // insert posh here and see what we get...

        // first fill the files so we can play
    filetest();

        mystatus = pthread_attr_init(&poshattr);
        mystatus = pthread_attr_setstacksize(&poshattr, 1400);
        poshPriority.sched_priority = 6;
        mystatus = pthread_attr_setschedparam(&poshattr, &poshPriority);

        if( (set_posh_tty = malloc(sizeof(struct set_posh)))==NULL)
        {
            xprintf("posh create - no memory\n");
            pthread_exit(0);
        }
        set_posh_tty->stdinstring = "/dev/ttyS0";
        set_posh_tty->stdoutstring = "/dev/ttyS0";
        set_posh_tty->mountpoint = "/dev/rd/d1";
        set_posh_tty->mountpoint2 = NULL;
        set_posh_tty->loginfile = "/dev/rd/d1/.login";

        mystatus = pthread_create(&poshTid, &poshattr, (void *)(&posh), set_posh_tty);

        pthread_exit(0);
}

COMMANDS AND OPTIONS

NOTES

There is a demo available for the Unison and DSPnano posh server which is found in installdir/demos and a second demo available with the telnet server which uses posh for command interpretation.

SEE ALSO

telnetd




< Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2011 >