[Previous] [Contents] [Index] [Next]

login

Log in

Syntax:

login [-fpq] [-c|u] [-h host] [-t timeout] 
      [username [env1 env2 ...]]

Options:

-c
Use only a QNX 4-compatible encryption.
-f
Skip login authentication (force). This option is used to indicate that proper authentication has already been done and no password is required. If you're root, it allows you to log in as username without a password prompt. You can use this option only if you're logged in as root or you're already logged in as username.
-h host
Specify for login purposes that you're connecting from host.
-p
Preserve the environment. If -p isn't specified, the environment is cleared, and only the following variables are set: SHELL, HOME, LOGNAME, USERNAME (same as LOGNAME), TERM (if set in the caller's environment), and PATH (set to the value defined by _CS_PATH).

The environment variables set in /etc/default/login are set whether or not -p is specified.

-q
Be quiet; disable extra output messages.
-t timeout
Cancel the login if no response is received within timeout number of seconds. A value of 0 (the default) disables the timeout facility.
-u
Use only a UNIX-compatible encryption.

Description:

The login command starts a session associated with a user. It's used when someone either first signs on to the computer, or wishes to log in as another user. If login is invoked without a username, it prompts for one. It always prompts for a password.

The login command verifies the username and password against a password database and, if verified, starts the user session. If either the username or password is unacceptable, login asks again for both.

For compatibility, login checks the password using two encryption methods:

qnx_crypt()
Compatible with QNX 4.
crypt()
Compatible with UNIX (NetBSD, Linux, Solaris).

The check succeeds if either encryption matches the password. The -c and -u options allow slightly more security by allowing only one encryption method.

The login utility sets the user ID and group ID as well as the current working directory, then executes a shell according to specifications found in the password database.

If execution of the shell fails, login prints the message No Shell and exits. The shell is started with a dash (-) prepended to its name as argument 0. This informs the shell to perform its startup routine.

The login utility sets the SHELL, HOME, LOGNAME, USERNAME (same as LOGNAME), TERM (if set in the caller's environment), and PATH (set to the value defined by _CS_PATH) environment variables. For more information on setting PATH, see "Setting PATH and LD_LIBRARY_PATH" in the Configuring Your Environment chapter of the Neutrino User's Guide.

The login utility also updates system accounting information in /var/log/utmp, /var/log/wtmp, and /var/log/lastlog if they already exist.


Note: The login utility doesn't create /var/log/utmp, /var/log/wtmp, and /var/log/lastlog if they don't already exist. These files can quickly become very big, which isn't good on an embedded system with limited resources.

The login utility also sets the environment variables specified in the /etc/default/login file. This file lets you specify which environment variable settings are to be used across login sessions. If a variable isn't set when login is started and this file contains a default for the variable, that default is used. If the file doesn't contain a default for the variable, the variable is cleared by login. If a variable is already set when login is started and -p is specified, it's preserved, even if the /etc/default/login file contains a default for the variable. The -p option allows site-specific environment variables to be passed from the system startup processes down to applications.

You can set environment variables by specifying them on the command line after the username, in the form VARIABLE[=VALUE]. For example:

login thomasf APPLES=RED TOMATOES

adds the following to the new login environment:

APPLES = RED
TOMATOES = 1

Values passed on the command line are always added to the new environment (regardless of the -p flag) and override the existing values. The SHELL, HOME, TERM, LOGNAME, USER values set by login override the command-line values.

You can specify which environment variables are to be preserved when the -p flag isn't specified, by populating an /etc/default/login file with the names of the environment variables you want to save. For example, if /etc/default/login contains:

SYSNAME
TZ
PHOTON

then when you run login without the -p option, the SYSNAME, TZ and PHOTON variables (if they exist) are propagated to the new environment. The values may be overwritten by values on the command line.

You can execute login only from the login shell, or when no session is active; you can't nest login commands.

If you execute login from the login shell, the shell from which it is run is terminated. This is because, by default, login is an alias for exec login.

Files:

/bin/sh
The QNX Neutrino Korn shell command interpreter.
/dev/console
Refers to the system console device.
/dev/log
A FIFO that receives log messages for syslogd.
/dev/tty
Refers to the controlling terminal for the current process.
/etc/group
Defines the known groups for the system.
/etc/default/login
Sets login environment variables.
/etc/passwd
Contains the user database (username, user ID, group ID, full name, home directory, shell).
/etc/shadow
Contains encrypted login password for each userid.
/var/log/utmp
/var/log/wtmp
/var/log/lastlog
Accounting records are appended to these files if they already exist.

See also:

logout, newgrp, passwd, phlogin, sh, su

crypt(), endutent(), getutent(), getutid(), getutline(), pututline(), qnx_crypt(), setutent(), utmpname() in the Library Reference

Logging In, Logging Out, and Shutting Down and Managing User Accounts in the Neutrino User's Guide


[Previous] [Contents] [Index] [Next]