To contents Next section

14.1 System

The system module contains some system-specific functions that may or may not be available on your system. Most of these functions do exactly the same thing as their UNIX counterpart. See the UNIX man pages for detailed information about what these functions do on your system.

Please note that these functions are available globally, you do not need to import System to use these functions.

FUNCTION
chroot - change the root directory

SYNTAX
int chroot(string newroot);
int chroot(object(File) obj);

DESCRIPTION
Changes the root directory for this process to the indicated directory.

NOTE
Since this function modifies the directory structure as seen from Pike, you have to modify the environment variables PIKE_MODULE_PATH and PIKE_INCLUDE_PATH to compensate for the new root-directory.

This function only exists on systems that have the chroot(2) system call. The second variant only works on systems that also have the fchroot(2) system call.

FUNCTION
getegid - get the effective group ID

SYNTAX
int getegid();

DESCRIPTION
Get the effective group ID.

SEE ALSO
setuid, getuid, setgid, getgid, seteuid, geteuid and setegid

FUNCTION
geteuid - get the effective user ID

SYNTAX
int geteuid();

DESCRIPTION
Get the effective user ID.

SEE ALSO
setuid, getuid, setgid, getgid, seteuid, setegid and getegid

FUNCTION
getgid - get the group ID

SYNTAX
int getgid();

DESCRIPTION
Get the real group ID.

SEE ALSO
setuid, getuid, setgid, seteuid, geteuid, setegid and getegid

FUNCTION
getgroups - get the supplemental group access list

SYNTAX
array(int) getgroups();

DESCRIPTION
Get the current supplemental group access list for this process.

SEE ALSO
initgroups, setgroups, getgid, setgid, getegid and setegid

FUNCTION
gethostbyaddr - gets information about a host given its address

SYNTAX
array gethostbyaddr(string addr);

DESCRIPTION
Returns an array with information about the specified IP address.

The returned array contains the same information as that returned by gethostbyname().

NOTE
This function only exists on systems that have the gethostbyaddr(2) or similar system call.

SEE ALSO
gethostbyname

FUNCTION
gethostbyname - gets information about a host given its name

SYNTAX
array gethostbyname(string hostname);

DESCRIPTION
Returns an array with information about the specified host.

The array contains three elements:

The first element is the hostname.

The second element is an array(string) of IP numbers for the host.

The third element is an array(string) of aliases for the host.

NOTE
This function only exists on systems that have the gethostbyname(2) or similar system call.

SEE ALSO
gethostbyaddr

FUNCTION
gethostname - get the name of this host

SYNTAX
string gethostname();

DESCRIPTION
Returns a string with the name of the host.

NOTE
This function only exists on systems that have the gethostname(2) or uname(2) system calls.

FUNCTION
getpgrp - get the process group ID

SYNTAX
int getpgrp();
int getpgrp(int pid);

DESCRIPTION
With no arguments or with pid equal to zero, returns the process group ID of this process.

If pid is specified, returns the process group ID of that process.

SEE ALSO
getpid and getppid

FUNCTION
getpid - get the process ID

SYNTAX
int getpid();

DESCRIPTION
Returns the process ID of this process.

SEE ALSO
getppid and getpgrp

FUNCTION
getppid - get the parent process ID

SYNTAX
int getppid();

DESCRIPTION
Returns the process ID of the parent process.

SEE ALSO
getpid and getpgrp

FUNCTION
getuid - get the user ID

SYNTAX
int getuid();

DESCRIPTION
Get the real user ID.

SEE ALSO
setuid, setgid, getgid, seteuid, geteuid, setegid and getegid

FUNCTION
hardlink - create a hardlink

SYNTAX
void hardlink(string from, string to);

DESCRIPTION
Creates a hardlink named to from the file from.

SEE ALSO
symlink, mv and rm

FUNCTION
initgroups - initialize the group access list

SYNTAX
void initgroups(string username, int base_gid);

DESCRIPTION
Initializes the group access list according to the system group database. base_gid is also added to the group access list.

SEE ALSO
setuid, getuid, setgid, getgid, seteuid, geteuid, setegid, getegid, getgroups and setgroups

FUNCTION
openlog - initializes the connection to syslogd

SYNTAX
void openlog(string ident, int options, facility);

DESCRIPTION
Initializes the connection to syslogd.

The ident argument specifies an identifier to tag all log entries with.

options is a bit field specifying the behavior of the message logging. Valid options are:

LOG_PID Log the process ID with each message.
LOG_CONS Write messages to the console if they can't be sent to syslogd.
LOG_NDELAY Open the connection to syslogd now and not later.
LOG_NOWAIT Do not wait for subprocesses talking to syslogd.

facility specifies what subsystem you want to log as. Valid facilities are:

LOG_AUTH Authorization subsystem
LOG_AUTHPRIV
LOG_CRON Crontab subsystem
LOG_DAEMON System daemons
LOG_KERN Kernel subsystem (NOT USABLE)
LOG_LOCAL For local use
LOG_LOCAL[1-7] For local use
LOG_LPR Line printer spooling system
LOG_MAIL Mail subsystem
LOG_NEWS Network news subsystem
LOG_SYSLOG
LOG_USER
LOG_UUCP UUCP subsystem

NOTE
Only available on systems with syslog(3).

BUGS
LOG_NOWAIT should probably always be specified.

SEE ALSO
syslog, closelog and setlogmask

FUNCTION
readlink - read a symbolic link

SYNTAX
string readlink(string linkname);

DESCRIPTION
Returns what the symbolic link linkname points to.

SEE ALSO
symlink

FUNCTION
setegid - set the effective group ID

SYNTAX
void setegid(int uid);

DESCRIPTION
Sets the effective group ID to gid.

SEE ALSO
setuid, getuid, setgid, getgid, seteuid, geteuid and getegid

FUNCTION
seteuid - set the effective user ID

SYNTAX
void seteuid(int uid);

DESCRIPTION
Sets the effective user ID to uid.

SEE ALSO
setuid, getuid, setgid, getgid, geteuid, setegid and getegid

FUNCTION
setgid - set the group ID

SYNTAX
void setgid(int gid);

DESCRIPTION
Sets the real group ID, effective group ID and saved group ID to gid.

SEE ALSO
setuid, getuid, getgid, seteuid, geteuid, setegid and getegid

FUNCTION
setgroups - set the supplemental group access list

SYNTAX
void getgroups(array(int) gids);

DESCRIPTION
Set the supplemental group access list for this process.

SEE ALSO
initgroups, getgroups, getgid, setgid, getegid and setegid

FUNCTION
setuid - set the user ID

SYNTAX
void setuid(int uid);

DESCRIPTION
Sets the real user ID, effective user ID and saved user ID to uid.

SEE ALSO
getuid, setgid, getgid, seteuid, geteuid, setegid and getegid

FUNCTION
symlink - create a symbolic link

SYNTAX
void symlink(string from, string to);

DESCRIPTION
Creates a symbolic link for an original file from with the new name to.

SEE ALSO
hardlink, readlink, mv and rm

FUNCTION
uname - get operating system information

SYNTAX
mapping(string:string) uname();

DESCRIPTION
Returns a mapping describing the operating system.

The mapping contains the following fields:

"sysname": Operating system name
"nodename": "release": "version": "machine": Host name Release of this OS Version number of this OS Machine architecture

NOTE
This function only exists on systems that have the uname(2) system call.


To contents Next section