Unison Help

- Unison Kernel
- Pthreads
- pthread_create()
- pthread_exit()
- pthread_self()
- pthread_equal()
- pthread_join()
- pthread_detach()
- pthread_setschedparam()
- pthread_getschedparam()
- pthread_attr_init()
- pthread_attr_destroy()
- pthread_attr_setstackaddr()
- pthread_attr_getstackaddr()
- pthread_attr_setstacksize()
- pthread_attr_getstacksize()
- pthread_attr_setschedparam()
- pthread_attr_getschedparam()
- pthread_attr_setdetachstate()
- pthread_attr_getdetachstate()
- pthread_stackinfo()
- pthread_setprio()
- pthread_getprio()
- sched_get_priority_max()
- sched_get_priority_min()
- sched_yield()
- Pthread Cancellation
- Mutex
- Semaphores
- Message Queues
- Conditional Variables
- Barriers
- Timers
- Clocks
- Memory Allocation
- Rendezvous
- Interrupts
- Directory Services
- Miscellaneous
- Pthreads
- Unison I/O Library
- Unison STDIO Library
- STDIO Library Calls
- clearerr()
- dprintf()
- fclose()
- fdopen()
- feof()
- ferror()
- fileno()
- fflush()
- fgetc()
- fgetpos()
- fgets()
- fopen()
- fprintf()
- fputc()
- fputs()
- fread()
- freopen()
- fscanf()
- fseek()
- fseeko()
- fsetpos()
- ftell()
- ftello()
- fwrite()
- getc()
- getc_unlocked()
- getchar()
- getchar_unlocked()
- getdelim()
- getline()
- gets()
- get_stderr_ptr()
- get_stdin_ptr()
- get_stdout_ptr()
- noperprintf()
- perprintf()
- perror()
- posix_compat()
- printf()
- putc()
- putc_unlocked()
- putchar()
- putchar_unlocked()
- puts()
- remove()
- rewind()
- scanf()
- setbuf()
- setvbuf()
- snprintf()
- sprintf()
- sscanf()
- stderr_init()
- stderr_close()
- stdin_init()
- stdin_close()
- stdout_init()
- stdout_close()
- vdprintf()
- vscanf()
- vsscanf()
- vfscanf()
- vprintf()
- vsnprintf()
- vsprintf()
- vfprintf()
- ungetc()
- Do-nothing Stubs
- STDIO Library Calls
- Unison LIBC Library
- Unison I/O Servers
- Graphics, Camera, Video, Audio
- Network Protocols
- TCP and UDP Server - tcpd
- DHCP Client Service - dhcp client
- DHCP Server - dhcpd
- Telnet Server - telnetd
- Tiny FTP Server - tftpd
- Point to Point - pppd
- Network Translation - NAT with PAT
- Firewall
- Tiny HTTP Server - thttpd
- Tiny HTTP Server with TLS
- POP3 Server
- Simple Mail Transfer Protocol Services (SMTP)
- Bootp Protocol
- File Transfer Protocol Server (FTP)
- File Transfer Client Services
- RPC / XDR
- DNS Client
- HTTP/HTTPS Client
- REST Client
- AutoIP Service - autoip client
- mDNS server - mdnsd
- SNTP Client
- SNMP Agent - Snmpd server
- SSL/TLS library
- SSH server
- IP security
- Power Control
- Serial I/O
- System Services
- Universal Serial Bus (USB)
- Wireless
- Remedy Tools for Unison
7.29.4.POSIX Shell and Login Service - posh #
NAME
POSIX Shell Server and Login Services – posh
SYNOPSIS
#include <posh_init.h>
- pthread_create(&poshTid, &poshattr, (void*(*)(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.
For description of fuctions add_user(), delete_user(), check_password(), update_password() see login manpage.
SPECIFIC OPTIONS (Compile time)
Option | Default | Description | Values |
---|---|---|---|
APPLOADER_SUPPORT | 1 | Enables support of apploader in POSH. | Dec: 0 | 1 |
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(); pthread_attr_init(&poshattr); pthread_attr_setstacksize(&poshattr, 1400); poshPriority.sched_priority = 6; 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*(*)(void*))posh, set_posh_tty); if (mystatus != 0) { xprintf("pthread_create = %d\n", errno); } pthread_attr_destroy(&poshattr); pthread_exit(0); return 0; //just to avoid warning }
COMMANDS AND OPTIONS
- help – help listing
- alias [alias_name=”value”] – setup an alias for an expression
- cat – concatenate output
- cd <dir> – change directory to <dir>
- chmod <mode> <dir | file> – change a file’s access control mode
mode – file access mode, for example “rwx”
dir | file – path to the target file to which mode is setting
- cp <src> <dst> – copy a file from <src> path to <dst> path
- exit – exit the posh shell
- ln <src> <dst> – create link to file
src – target path for link
dst – link name (with path)
- logout – logout of posh
- ls [option] – list directory contents
-l – for long list
-d – lists directories, not content
- mkdir <dir> – make a directory specified by <dir>
- mv <src> <dst> – move a file from <src> path to <dst> path
- printenv [env_name] – print all or part of environment
printenv [VARIABLE] or printenv OPTION
If VARIABLE or OPTION not specified, then all present will be printed
- pwd – present working directory
- rm <file> – remove a file
- rmdir – remove a directory
- setenv [env_name=”value”] – set an environment variable
Example: setenv PATH “/d0:/sd/d1:/sd/d1/d2”
- unalias <alias_name> – delete an alias
- useradd <username> <password> – add a user with a password
- userdel <username> – delete a user
- userpasswd <username> <oldpassword> <newpassword> – set (or reset) a user password
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.