SUBPROJECTS = locate
-TOOLS = killall apply basename chroot date dirname echo env expr false\
- find getopt hostname id jot kill lastcomm logname mktemp nice\
- nohup printenv printf pwd renice script shlock sleep su\
- tee test time true uname users w whereis which who\
- xargs yes
+TOOLS = alias apply basename chroot date dirname echo env expr false\
+ find getopt hostname id jot kill killall lastcomm logname mktemp\
+ nice nohup printenv printf pwd renice script shlock sleep su\
+ tee test time true uname users w whereis which who xargs yes
-OTHERSRCS = PROJECT Makefile.preamble Makefile Makefile.postamble
+OTHERSRCS = PROJECT Makefile.preamble Makefile Makefile.postamble Manpages/*.1
MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
CODE_GEN_STYLE = DYNAMIC
include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Postamble.Common
+
+after_install::
+ $(INSTALL_FILE) $(SRCROOT)/Manpages/*.1 $(DSTROOT)/usr/share/man/man1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.\"
+.\" Copyright (c) 1999 Sheldon Hearn
+.\"
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: src/share/man/man1/builtin.1,v 1.20 2002/07/23 14:38:07 tjr Exp $
+.\"
+.Dd September 1, 1999
+.Dt BUILTIN 1
+.Os
+.Sh NAME
+.Nm builtin ,
+.Nm alias ,
+.Nm alloc ,
+.Nm bg ,
+.Nm bind ,
+.Nm bindkey ,
+.Nm break ,
+.Nm breaksw ,
+.Nm builtins ,
+.Nm case ,
+.Nm cd ,
+.Nm chdir ,
+.Nm command ,
+.Nm complete ,
+.Nm continue ,
+.Nm default ,
+.Nm dirs ,
+.Nm do ,
+.Nm done ,
+.Nm echo ,
+.Nm echotc ,
+.Nm elif ,
+.Nm else ,
+.Nm end ,
+.Nm endif ,
+.Nm endsw ,
+.Nm esac ,
+.Nm eval ,
+.Nm exec ,
+.Nm exit ,
+.Nm export ,
+.Nm false ,
+.Nm fc ,
+.Nm fg ,
+.Nm filetest ,
+.Nm fi ,
+.Nm for ,
+.Nm foreach ,
+.Nm getopts ,
+.Nm glob ,
+.Nm goto ,
+.Nm hash ,
+.Nm hashstat ,
+.Nm history ,
+.Nm hup ,
+.Nm if ,
+.Nm jobid ,
+.Nm jobs ,
+.Nm kill ,
+.Nm limit ,
+.Nm log ,
+.Nm login ,
+.Nm logout ,
+.Nm ls-F ,
+.Nm nice ,
+.Nm nohup ,
+.Nm notify ,
+.Nm onintr ,
+.Nm popd ,
+.Nm printenv ,
+.Nm pushd ,
+.Nm pwd ,
+.Nm read ,
+.Nm readonly ,
+.Nm rehash ,
+.Nm repeat ,
+.Nm sched ,
+.Nm set ,
+.Nm setenv ,
+.Nm settc ,
+.Nm setty ,
+.Nm setvar ,
+.Nm shift ,
+.Nm source ,
+.Nm stop ,
+.Nm suspend ,
+.Nm switch ,
+.Nm telltc ,
+.Nm test ,
+.Nm then ,
+.Nm time ,
+.Nm trap ,
+.Nm true ,
+.Nm type ,
+.Nm ulimit ,
+.Nm umask ,
+.Nm unalias ,
+.Nm uncomplete ,
+.Nm unhash ,
+.Nm unlimit ,
+.Nm unset ,
+.Nm unsetenv ,
+.Nm until ,
+.Nm wait ,
+.Nm where ,
+.Nm which ,
+.Nm while
+.Nd shell builtin commands
+.Sh SYNOPSIS
+.Nm
+.Op Fl options
+.Op Ar args ...
+.Sh DESCRIPTION
+Shell builtin commands are commands that can be executed within the
+running shell's process.
+Note that, in the case of
+.Xr csh 1
+builtin commands, the command is executed in a subshell if it occurs as
+any component of a pipeline except the last.
+.Pp
+If a command specified to the shell contains a slash
+.Dq \&/ ,
+the shell will not execute a builtin command, even if the last component
+of the specified command matches the name of a builtin command.
+Thus, while specifying
+.Dq Ic echo
+causes a builtin command to be executed under shells that support the
+builtin echo command,
+specifying
+.Dq Pa /bin/echo
+or
+.Dq Pa ./echo
+does not.
+.Pp
+While some builtin commands may exist in more than one shell, their
+operation may be different under each shell which supports them.
+Below is a table which lists shell builtin commands, the standard shells
+that support them and whether they exist as standalone utilities.
+.Pp
+Only builtin commands for the
+.Xr csh 1
+and
+.Xr sh 1
+shells are listed here.
+Consult the appropriate manual page for
+details on the operation of any given builtin command under those shells.
+Users of other shells will need to consult the documentation supplied
+with the other shells.
+.Bl -column ".Ic uncomplete" ".Em External" ".Xr csh 1" ".Xr sh 1" -offset indent
+.It Xo
+.Em "Command External" Ta Xr csh 1 Ta Xr sh 1
+.Xc
+.It Ic alias Ta Yes Ta Yes Ta Yes
+.It Ic alloc Ta \&No Ta Yes Ta \&No
+.It Ic bg Ta Yes Ta Yes Ta Yes
+.It Ic bind Ta \&No Ta \&No Ta Yes
+.It Ic bindkey Ta \&No Ta Yes Ta \&No
+.It Ic break Ta \&No Ta Yes Ta \&Yes
+.It Ic breaksw Ta \&No Ta Yes Ta \&No
+.It Ic builtins Ta \&No Ta Yes Ta \&No
+.It Ic case Ta \&No Ta Yes Ta Yes
+.It Ic cd Ta Yes Ta Yes Ta Yes
+.It Ic chdir Ta \&No Ta Yes Ta \&No
+.It Ic command Ta Yes Ta \&No Ta Yes
+.It Ic complete Ta \&No Ta Yes Ta \&No
+.It Ic continue Ta \&No Ta Yes Ta \&Yes
+.It Ic default Ta \&No Ta Yes Ta \&No
+.It Ic dirs Ta \&No Ta Yes Ta \&No
+.It Ic do Ta \&No Ta \&No Ta Yes
+.It Ic done Ta \&No Ta \&No Ta Yes
+.It Ic echo Ta Yes Ta Yes Ta Yes
+.It Ic echotc Ta \&No Ta Yes Ta \&No
+.It Ic elif Ta \&No Ta \&No Ta Yes
+.It Ic else Ta \&No Ta Yes Ta \&Yes
+.It Ic end Ta \&No Ta Yes Ta \&No
+.It Ic endif Ta \&No Ta Yes Ta \&No
+.It Ic endsw Ta \&No Ta Yes Ta \&No
+.It Ic esac Ta \&No Ta \&No Ta Yes
+.It Ic eval Ta \&No Ta Yes Ta Yes
+.It Ic exec Ta \&No Ta Yes Ta Yes
+.It Ic exit Ta \&No Ta Yes Ta Yes
+.It Ic export Ta \&No Ta \&No Ta Yes
+.It Ic false Ta Yes Ta \&No Ta Yes
+.It Ic fc Ta Yes Ta \&No Ta Yes
+.It Ic fg Ta Yes Ta Yes Ta Yes
+.It Ic filetest Ta \&No Ta Yes Ta \&No
+.It Ic fi Ta \&No Ta \&No Ta Yes
+.It Ic for Ta \&No Ta \&No Ta Yes
+.It Ic foreach Ta \&No Ta Yes Ta \&No
+.It Ic getopts Ta Yes Ta \&No Ta Yes
+.It Ic glob Ta \&No Ta Yes Ta \&No
+.It Ic goto Ta \&No Ta Yes Ta \&No
+.It Ic hash Ta \&No Ta \&No Ta Yes
+.It Ic hashstat Ta \&No Ta Yes Ta \&No
+.It Ic history Ta \&No Ta Yes Ta \&No
+.It Ic hup Ta \&No Ta Yes Ta \&No
+.It Ic if Ta \&No Ta Yes Ta \&Yes
+.It Ic jobid Ta \&No Ta \&No Ta Yes
+.It Ic jobs Ta Yes Ta Yes Ta Yes
+.It Ic kill Ta Yes Ta Yes Ta \&No
+.It Ic limit Ta \&No Ta Yes Ta \&No
+.It Ic log Ta \&No Ta Yes Ta \&No
+.It Ic login Ta Yes Ta Yes Ta \&No
+.It Ic logout Ta \&No Ta Yes Ta \&No
+.It Ic ls-F Ta \&No Ta Yes Ta \&No
+.It Ic nice Ta Yes Ta Yes Ta \&No
+.It Ic nohup Ta Yes Ta Yes Ta \&No
+.It Ic notify Ta \&No Ta Yes Ta \&No
+.It Ic onintr Ta \&No Ta Yes Ta \&No
+.It Ic popd Ta \&No Ta Yes Ta \&No
+.It Ic printenv Ta Yes Ta Yes Ta \&No
+.It Ic pushd Ta \&No Ta Yes Ta \&No
+.It Ic pwd Ta Yes Ta \&No Ta Yes
+.It Ic read Ta Yes Ta \&No Ta Yes
+.It Ic readonly Ta \&No Ta \&No Ta Yes
+.It Ic rehash Ta \&No Ta Yes Ta \&No
+.It Ic repeat Ta \&No Ta Yes Ta \&No
+.It Ic sched Ta \&No Ta Yes Ta \&No
+.It Ic set Ta \&No Ta Yes Ta \&Yes
+.It Ic setenv Ta \&No Ta Yes Ta \&No
+.It Ic settc Ta \&No Ta Yes Ta \&No
+.It Ic setty Ta \&No Ta Yes Ta \&No
+.It Ic setvar Ta \&No Ta \&No Ta Yes
+.It Ic shift Ta \&No Ta Yes Ta Yes
+.It Ic source Ta \&No Ta Yes Ta \&No
+.It Ic stop Ta \&No Ta Yes Ta \&No
+.It Ic suspend Ta \&No Ta Yes Ta \&No
+.It Ic switch Ta \&No Ta Yes Ta \&No
+.It Ic telltc Ta \&No Ta Yes Ta \&No
+.It Ic test Ta Yes Ta \&No Ta Yes
+.It Ic then Ta \&No Ta \&No Ta Yes
+.It Ic time Ta Yes Ta Yes Ta \&No
+.It Ic trap Ta \&No Ta \&No Ta Yes
+.It Ic true Ta Yes Ta \&No Ta Yes
+.It Ic type Ta \&No Ta \&No Ta Yes
+.It Ic ulimit Ta \&No Ta \&No Ta Yes
+.It Ic umask Ta Yes Ta Yes Ta Yes
+.It Ic unalias Ta Yes Ta Yes Ta Yes
+.It Ic uncomplete Ta \&No Ta Yes Ta \&No
+.It Ic unhash Ta \&No Ta Yes Ta \&No
+.It Ic unlimit Ta \&No Ta Yes Ta \&No
+.It Ic unset Ta \&No Ta Yes Ta Yes
+.It Ic unsetenv Ta \&No Ta Yes Ta \&No
+.It Ic until Ta \&No Ta \&No Ta Yes
+.It Ic wait Ta Yes Ta Yes Ta Yes
+.It Ic where Ta \&No Ta Yes Ta \&No
+.It Ic which Ta Yes Ta Yes Ta \&No
+.It Ic while Ta \&No Ta Yes Ta \&Yes
+.El
+.Sh SEE ALSO
+.Xr csh 1 ,
+.Xr echo 1 ,
+.Xr false 1 ,
+.Xr kill 1 ,
+.Xr login 1 ,
+.Xr nice 1 ,
+.Xr nohup 1 ,
+.Xr printenv 1 ,
+.Xr pwd 1 ,
+.Xr sh 1 ,
+.Xr test 1 ,
+.Xr time 1 ,
+.Xr true 1 ,
+.Xr which 1
+.Sh HISTORY
+The
+.Nm
+manual page first appeared in
+.Fx 3.4 .
+.Sh AUTHORS
+This manual page was written by
+.An Sheldon Hearn Aq sheldonh@FreeBSD.org .
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+.so man1/builtin.1
FILESTABLE = {
OTHER_SOURCES = (PROJECT, Makefile.preamble, Makefile, Makefile.postamble);
SUBPROJECTS = (
+ alias,
apply,
basename,
chroot,
--- /dev/null
+#
+# Generated by the NeXT Project Builder.
+#
+# NOTE: Do NOT change this file -- Project Builder maintains it.
+#
+# Put all of your customizations in files called Makefile.preamble
+# and Makefile.postamble (both optional), and Makefile will include them.
+#
+
+NAME = alias
+
+PROJECTVERSION = 2.8
+PROJECT_TYPE = Tool
+
+# The following file, alias.c is a dummy c file to make the Makefile work.
+# Do not remove it.
+CFILES = alias.c
+
+OTHERSRCS = Makefile Makefile.preamble Makefile.postamble generic.sh alias.1
+
+MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
+CODE_GEN_STYLE = DYNAMIC
+MAKEFILE = tool.make
+NEXTSTEP_INSTALLDIR = /usr/bin
+LIBS =
+DEBUG_LIBS = $(LIBS)
+PROF_LIBS = $(LIBS)
+
+NEXTSTEP_BUILD_OUTPUT_DIR = /tmp/$(NAME)/Build
+
+#NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc
+NEXTSTEP_OBJCPLUS_COMPILER =
+WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc
+PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc
+NEXTSTEP_JAVA_COMPILER = /usr/bin/javac
+WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe
+PDO_UNIX_JAVA_COMPILER = $(NEXTDEV_BIN)/javac
+
+-include $(MAKEFILEDIR)/platform.make
+
+-include Makefile.preamble
+
+include $(MAKEFILEDIR)/$(MAKEFILE)
+
+-include Makefile.postamble
+
+-include Makefile.dependencies
--- /dev/null
+include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Postamble.Common
+
+after_install::
+ mkdir -p "$(DSTROOT)$(INSTALLDIR)"
+ install -c -m 555 ./generic.sh $(DSTROOT)$(INSTALLDIR)/alias
+
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/bg
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/cd
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/command
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/fc
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/fg
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/getopts
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/hash
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/jobs
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/read
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/type
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/ulimit
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/umask
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/unalias
+ $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/wait
+
+ mkdir -p "$(DSTROOT)/usr/share/man/man1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/bg.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/cd.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/command.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/fc.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/fg.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/getopts.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/hash.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/jobs.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/read.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/type.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/ulimit.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/umask.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/unalias.1"
+ ln -f "$(DSTROOT)/usr/share/man/man1/alias.1" "$(DSTROOT)/usr/share/man/man1/wait.1"
+
+
+
+
--- /dev/null
+include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Preamble.Common
--- /dev/null
+{
+ DYNAMIC_CODE_GEN = YES;
+ FILESTABLE = {
+ FRAMEWORKS = ();
+ H_FILES = ();
+ OTHER_LINKED = ();
+ OTHER_SOURCES = (Makefile, Makefile.preamble, Makefile.postamble alias.1 generic.sh);
+ SUBPROJECTS = ();
+ };
+ LANGUAGE = English;
+ LOCALIZABLE_FILES = {};
+ MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
+ NEXTSTEP_BUILDDIR = "/tmp/$(NAME)/Build";
+ NEXTSTEP_BUILDTOOL = /bin/gnumake;
+ NEXTSTEP_INSTALLDIR = /usr/bin;
+ NEXTSTEP_JAVA_COMPILER = /usr/bin/javac;
+ NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc;
+ PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make;
+ PDO_UNIX_JAVA_COMPILER = "$(NEXTDEV_BIN)/javac";
+ PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc";
+ PROJECTNAME = alias;
+ PROJECTTYPE = Tool;
+ PROJECTVERSION = 2.8;
+ WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make;
+ WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe";
+ WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc";
+}
--- /dev/null
+.so man1/builtin.1
--- /dev/null
+
+/* This file is a dummy file to make the Makefile to work correctly to install
+ the shell scripts. It does not lead to any deliverable. Do not remove this
+ file from this (..../shell_cmds/alias) directory.
+*/
+int main()
+{
+ exit(0);
+}
+
--- /dev/null
+#!/bin/sh
+# $FreeBSD: src/usr.bin/alias/generic.sh,v 1.1 2002/07/16 22:16:03 wollman Exp $
+# This file is in the public domain.
+${0##*/} ${1+"$@"}
PROF_LIBS = $(LIBS)
-
-
NEXTSTEP_BUILD_OUTPUT_DIR = /tmp/$(NAME)/Build
NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc
-include Makefile.postamble
-include Makefile.dependencies
+
+ALL_CFLAGS += -I/System/Library/Frameworks/System.framework/PrivateHeaders
+
.\"
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\"
-.Dd January 20, 1998
+.Dd September 22, 2004
.Dt DATE 1
.Os
.Sh NAME
.Op Fl r Ar seconds
.Op Cm + Ns Ar format
.Nm
-.Ar [[[[[cc]yy]mm]dd]hh]mm[\&.ss]
+.Op Fl u
+.Ar mmddhhmm[[cc]yy]
.Sh DESCRIPTION
.Nm
displays the current date and time when invoked without arguments.
Providing arguments will format the date and time in a user-defined
-way or set the date.
-Only the superuser may set the date.
+way or set the date. Only the superuser may set the date.
.Pp
The options are as follows:
.Bl -tag -width Ds
.Pp
Time changes for Daylight Saving and Standard time and leap seconds
and years are handled automatically.
+.Sh ENVIRONMENT VARIABLES
+The following environment variables affect the execution of
+.Nm
+:
+.Bl -tag -width TZ
+.It Ev TZ
+The timezone to use when displaying dates.
+See
+.Xr environ 7
+for more information.
+.El
+.Sh FILES
+.Bl -tag -width /var/log/messages -compact
+.It Pa /var/log/wtmp
+A record of date resets and time changes.
+.It Pa /var/log/messages
+A record of the user setting the time.
+.El
.Sh EXAMPLES
The command:
.Bd -literal -offset indent
.Pp
The command:
.Bd -literal -offset indent
-date 8506131627
+date 061316271985
.Ed
.Pp
sets the date to
sets the time to
.Li "2:32 PM" ,
without modifying the date.
-.Sh ENVIRONMENT VARIABLES
-The following environment variables affect the execution of
-.Nm
-:
-.Bl -tag -width TZ
-.It Ev TZ
-The timezone to use when displaying dates.
-See
-.Xr environ 7
-for more information.
-.El
-.Sh FILES
-.Bl -tag -width /var/log/messages -compact
-.It Pa /var/log/wtmp
-A record of date resets and time changes.
-.It Pa /var/log/messages
-A record of the user setting the time.
-.El
-.Sh SEE ALSO
-.Xr gettimeofday 2 ,
-.Xr strftime 3 ,
-.Xr utmp 5 ,
-.Xr timed 8
-.Rs
-.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
-.%A R. Gusella
-.%A S. Zatti
-.Re
.Sh DIAGNOSTICS
-Exit status is 0 on success, 1 if unable to set the date, and 2
-if able to set the local date, but unable to set it globally.
+The following exit values are returned:
+ 0 The date was written successfully (either locally or globally)
+ >0 An error occurred.
.Pp
Occasionally, when
.Xr timed 8
-synchronizes the time on many hosts, the setting of a new time value may
-require more than a few seconds.
+synchronizes the time on many hosts, the setting of a new time value
+may require more than a few seconds.
On these occasions,
.Nm
prints:
occurs when the communication
between
.Nm
-and
-timed
-fails.
+and timed fails.
+.Sh LEGACY SYNOPSIS
+.Nm
+.Op Fl nu
+.Op Fl r Ar seconds
+.Op Cm + Ns Ar format
+.Pp
+.Nm " "
+.Ar [[[[[cc]yy]mm]dd]hh]mm[\&.ss]
+.Sh LEGACY DIAGNOSTICS
+.Pp
+When invoked in legacy mode the following exit values are returned:
+ 0 The date was written successfully
+ 1 Unable to set the date
+ 2 Able to set the local date, but unable to set it globally
+.Sh SEE ALSO
+.Xr gettimeofday 2 ,
+.Xr strftime 3 ,
+.Xr compat 5 ,
+.Xr utmp 5 ,
+.Xr timed 8
+.Rs
+.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
+.%A R. Gusella
+.%A S. Zatti
+.Re
.Sh STANDARDS
The
.Nm
-utility is expected to be compatible with
+utility supports the
+.St -susv3 .
+It is also expected to be compatible with
.St -p1003.2 .
#include <unistd.h>
#include <util.h>
+#include "get_compat.h"
+
#include "extern.h"
time_t tval;
-int retval, nflag;
+int nflag;
+int retval = 0;
+int unix2003_std = 0; /* to determine legacy vs std mode */
int main __P((int, char *[]));
static void setthetime __P((const char *));
(void)strftime(buf, sizeof(buf), format, localtime(&tval));
(void)printf("%s\n", buf);
- exit(retval);
- /* NOTREACHED */
+
+ /* if date/time could not be set/notified in the other hosts as
+ determined by netsetval() a return value 2 is set, which is
+ to be propogated back to shell in the legacy mode.
+ */
+ if( unix2003_std )
+ exit(0); /* set/notify time thru NTPD isn't stds */
+ else
+ exit(retval); /* Propogate the error condition set, if any */
}
#define ATOI2(s) ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
setthetime(p)
const char *p;
{
+
struct tm *lt;
struct timeval tv;
const char *dot, *t;
int yearset, len;
+ char tmp1_p[5] = ""; /* to hold ccyy and reformat */
+ char tmp2_p[16] = ""; /* ccyyMMddhhmm.ss is 15 chars */
+
for (t = p, dot = NULL; *t; ++t) {
if (isdigit(*t))
continue;
}
yearset = 0;
+
+ if (compat_mode("bin/date", "unix2003")) /* Determine the STD */
+ unix2003_std = 1;
+ else
+ unix2003_std = 0;
+
switch (strlen(p) - len) {
case 12: /* cc */
+ if(unix2003_std) {
+ /* The last 4 chars are ccyy;
+ reformat it to be in the first */
+ strncpy(tmp1_p, &p[8], 4);
+ tmp1_p[4] = '\0';
+ p[8] = '\0'; /* .ss already processed; so no harm */
+ strcpy(tmp2_p, p);
+ strcpy(p, tmp1_p);
+ strcat(p, tmp2_p);
+ }
+
lt->tm_year = ATOI2(p) * 100 - TM_YEAR_BASE;
yearset = 1;
/* FALLTHROUGH */
case 10: /* yy */
+ if(unix2003_std) {
+ /* The last 2 chars are yy; reformat it to be in the
+ first, only if already not done. */
+ if (tmp1_p[0] == '\0') {
+ strncpy(tmp1_p, &p[8], 2);
+ tmp1_p[2] = '\0';
+ p[8] = '\0'; /* .ss done; so no harm */
+ strcpy(tmp2_p, p);
+ strcpy(p, tmp1_p);
+ strcat(p, tmp2_p);
+ } else
+ ; /* do nothing, already reformatted */
+ }
+
if (yearset) {
lt->tm_year += ATOI2(p);
} else {
{
(void)fprintf(stderr,
"usage: date [-nu] [-r seconds] [+format]\n");
- (void)fprintf(stderr, " date [[[[[cc]yy]mm]dd]hh]mm[.ss]\n");
+ if (unix2003_std)
+ (void)fprintf(stderr, " date [-u] mmddhhmm[[cc]yy]\n");
+ else
+ (void)fprintf(stderr, " date [[[[[cc]yy]mm]dd]hh]mm[.ss]\n");
exit(1);
/* NOTREACHED */
}
usage();
}
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
- (void)setenv(*argv, ++p, 1);
+ (void)putenv(*argv);
if (*argv) {
execvp(*argv, argv);
err(errno == ENOENT ? 127 : 126, "%s", *argv);
DEBUG_LIBS = $(LIBS)
PROF_LIBS = $(LIBS)
-
+NEXTSTEP_PB_CFLAGS = -D__DARWIN_UNIX03=1
NEXTSTEP_BUILD_OUTPUT_DIR = /tmp/$(NAME)/Build
int is_integer __P((struct val *, int64_t *));
int to_integer __P((struct val *));
void to_string __P((struct val *));
+int is_null __P((struct val *));
int is_zero_or_null __P((struct val *));
void nexttoken __P((void));
void error __P((void)) __attribute__((__noreturn__));
i = 0;
neg = (*s == '-');
- if (neg)
+ if (neg) {
s++;
+ /* the optional unary minus *must* be followed by digits to
+ * be considered an integer. A '-' alone is not an integer.
+ */
+ if(!*s)
+ return 0;
+ }
while (*s) {
if (!isdigit(*s))
vp->u.s = tmp;
}
+int is_null(vp)
+ struct val *vp;
+{
+ if ((vp->type != integer) && (*vp->u.s == 0))
+ return 1;
+ return 0;
+}
+
int
is_zero_or_null(vp)
struct val *vp;
if (is_zero_or_null(l)) {
free_value(l);
l = r;
+ if( is_null(r) ) {
+ free_value(r);
+ l = make_int(0);
+ }
} else {
free_value(r);
}
(void) setlocale(LC_ALL, "");
av = argv + 1;
-
+ if (!strcmp(*av, "--"))
+ av++;
nexttoken();
vp = eval0();
if (token != EOI)
error();
-
+ if (vp->type == string && vp->u.s[0])
+ to_integer(vp); /* -0 is not a string */
if (vp->type == integer)
(void)printf("%lld\n", vp->u.i);
else
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include "find.h"
return (plan);
}
+/* addPath - helper function used to build a list of paths that were
+ * specified on the command line that we are allowed to search.
+ */
+static char **addPath(char **array, char *newPath)
+{
+ static int pathCounter = 0;
+
+ if (newPath == NULL) { /* initialize array */
+ if ((array = malloc(sizeof(char *))) == NULL)
+ err(2, "out of memory");
+ array[0] = NULL;
+ }
+ else {
+ array = realloc(array, (++pathCounter + 1) * sizeof(char *));
+ if (array == NULL)
+ err(2, "out of memory");
+ else {
+ array[pathCounter - 1] = newPath;
+ array[pathCounter] = NULL; /* ensure array is null terminated */
+ }
+ }
+ return (array);
+}
+
FTS *tree; /* pointer to top of FTS hierarchy */
/*
register FTSENT *entry;
PLAN *p;
int rval;
+ char **myPaths;
+ int nonSearchableDirFound = 0;
+ int pathIndex;
+ struct stat statInfo;
- tree = fts_open(paths, ftsoptions, (issort ? find_compare : NULL));
+ /* special-case directories specified on command line - explicitly examine
+ * mode bits, to ensure failure if the directory cannot be searched
+ * (whether or not it's empty). UNIX conformance... <sigh>
+ */
+
+ myPaths = addPath(NULL, NULL);
+ for (pathIndex = 0; paths[pathIndex] != NULL; ++pathIndex) {
+ /* retrieve mode bits, and examine "searchable" bit of directories */
+ /* exempt root from POSIX conformance */
+ if (getuid() && (stat(paths[pathIndex], &statInfo) == 0) && ((statInfo.st_mode & S_IFMT) == S_IFDIR)) {
+ if ((statInfo.st_mode & (S_IXUSR + S_IXGRP + S_IXOTH)) != 0) {
+ myPaths = addPath(myPaths, paths[pathIndex]);
+ } else {
+ if (errno != ENAMETOOLONG) { /* if name is too long, just let existing logic handle it */
+ warnx("%s: Permission denied", paths[pathIndex]);
+ nonSearchableDirFound = 1;
+ }
+ }
+ } else {
+ /* not a directory, so add path to array */
+ myPaths = addPath(myPaths, paths[pathIndex]);
+ }
+ }
+ if (myPaths[0] == NULL) { /* were any directories searchable? */
+ free(myPaths);
+ return(nonSearchableDirFound); /* no... */
+ }
+
+ tree = fts_open(myPaths, ftsoptions, (issort ? find_compare : NULL));
if (tree == NULL)
err(1, "ftsopen");
- for (rval = 0; (entry = fts_read(tree)) != NULL;) {
+ for (rval = nonSearchableDirFound; (entry = fts_read(tree)) != NULL;) {
switch (entry->fts_info) {
case FTS_D:
if (isdepth)
}
if (errno)
err(1, "fts_read");
+
+ free (myPaths);
return (rval);
}
{
struct group *gr;
struct passwd *pw;
- int cnt, id, eid, lastid, ngroups;
+ int cnt, id, eid, gid, egid, lastid, ngroups;
gid_t groups[NGROUPS];
const char *fmt;
(void)printf("uid=%u", id);
if ((pw = getpwuid(id)))
(void)printf("(%s)", pw->pw_name);
+ gid = getgid();
+ (void)printf(" gid=%u", gid);
+ if ((gr = getgrgid(gid)))
+ (void)printf("(%s)", gr->gr_name);
if ((eid = geteuid()) != id) {
(void)printf(" euid=%u", eid);
if ((pw = getpwuid(eid)))
(void)printf("(%s)", pw->pw_name);
}
- id = getgid();
- (void)printf(" gid=%u", id);
- if ((gr = getgrgid(id)))
- (void)printf("(%s)", gr->gr_name);
- if ((eid = getegid()) != id) {
- (void)printf(" egid=%u", eid);
- if ((gr = getgrgid(eid)))
+ if ((egid = getegid()) != gid) {
+ (void)printf(" egid=%u", egid);
+ if ((gr = getgrgid(egid)))
(void)printf("(%s)", gr->gr_name);
}
if ((ngroups = getgroups(NGROUPS, groups))) {
TOOLS = bigram code locate
-OTHERSRCS = Makefile Makefile.preamble Makefile.postamble
+OTHERSRCS = Makefile Makefile.preamble Makefile.postamble locate.code.8
MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Postamble.Common
+
+after_install:
+ $(MKDIR) $(DSTROOT)/usr/share/man/man8
+ $(INSTALL_FILE) locate.code.8 $(DSTROOT)/usr/share/man/man8
+ $(LN) $(DSTROOT)/usr/share/man/man8/locate.code.8 \
+ $(DSTROOT)/usr/share/man/man8/locate.bigram.8
--- /dev/null
+.Dd October 15, 2004
+.Dt LOCATE.CODE 8
+.Os Darwin
+.Sh NAME
+.Nm locate.code, locate.bigram
+.Nd sorted list compressor
+.Sh SYNOPSIS
+.Nm locate.code
+.Nm locate.bigram
+.Sh DESCRIPTION
+.Nm locate.code
+and
+.Nm locate.bigram
+are programs used by
+.Xr locate 1
+during the indexing process.
+.Nm locate.code
+and
+.Nm locate.bigram
+should not be run manually.
+.Sh SEE ALSO
+.Xr locate 1 ,
+.Xr locate.updatedb 8
{
int exit_status;
+ if (argc > 1 && !strcmp(argv[1], "--")) {
+ argv++;
+ argc--;
+ }
if (argc < 2)
usage();
-.\" $NetBSD: renice.8,v 1.5 1997/10/19 14:01:33 lukem Exp $
-.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)renice.8 8.1 (Berkeley) 6/9/93
-.\" $NetBSD: renice.8,v 1.5 1997/10/19 14:01:33 lukem Exp $
+.\" @(#)renice.8 8.1 (Berkeley) 6/9/93
+.\" $FreeBSD: src/usr.bin/renice/renice.8,v 1.16 2003/02/26 20:27:24 charnier Exp $
.\"
.Dd June 9, 1993
.Dt RENICE 8
-.Os BSD 4
+.Os
.Sh NAME
.Nm renice
.Nd alter priority of running processes
.Sh SYNOPSIS
.Nm
.Ar priority
-.Oo
-.Op Fl p
-.Ar pid ...
-.Oc
-.Oo
-.Op Fl g
-.Ar pgrp ...
-.Oc
-.Oo
-.Op Fl u
-.Ar user ...
-.Oc
+.Op Oo Fl p Oc Ar pid ...
+.Op Oo Fl g Oc Ar pgrp ...
+.Op Oo Fl u Oc Ar user ...
+.Nm
+.Fl n Ar increment
+.Op Oo Fl p Oc Ar pid ...
+.Op Oo Fl g Oc Ar pgrp ...
+.Op Oo Fl u Oc Ar user ...
.Sh DESCRIPTION
+The
.Nm
-alters the
+utility alters the
scheduling priority of one or more running processes.
The following
.Ar who
parameters are interpreted as process ID's, process group
-ID's, or user names.
+ID's, user ID's or user names.
+The
.Nm Ns 'ing
-a process group causes all processes in the process group
-to have their scheduling priority altered.
+of a process group causes all processes in the process group
+to have their scheduling priority altered.
+The
.Nm Ns 'ing
-a user causes all processes owned by the user to have
+of a user causes all processes owned by the user to have
their scheduling priority altered.
By default, the processes to be affected are specified by
their process ID's.
.Pp
-Options supported by
-.Nm :
-.Bl -tag -width Ds
+The following options are available:
+.Bl -tag -width indent
.It Fl g
-Force
+Force
.Ar who
parameters to be interpreted as process group ID's.
+.It Fl n
+Instead of changing the specified processes to the given priority,
+interpret the following argument as an increment to be applied to
+the current priority of each process.
.It Fl u
Force the
.Ar who
-parameters to be interpreted as user names.
+parameters to be interpreted as user names or user ID's.
.It Fl p
-Resets the
+Reset the
.Ar who
interpretation to be (the default) process ID's.
.El
.Pp
For example,
-.Bd -literal -offset
-renice +1 987 -u daemon root -p 32
-.Ed
+.Pp
+.Dl "renice +1 987 -u daemon root -p 32"
.Pp
would change the priority of process ID's 987 and 32, and
all processes owned by users daemon and root.
.El
.Sh SEE ALSO
.Xr nice 1 ,
+.Xr rtprio 1 ,
.Xr getpriority 2 ,
.Xr setpriority 2
-.Sh BUGS
-Non super-users can not increase scheduling priorities of their own processes,
-even if they were the ones that decreased the priorities in the first place.
+.Sh STANDARDS
+The
+.Nm
+utility conforms to
+.St -p1003.1-2001 .
.Sh HISTORY
The
.Nm
-command appeared in
+utility appeared in
.Bx 4.0 .
+.Sh BUGS
+Non super-users cannot increase scheduling priorities of their own processes,
+even if they were the ones that decreased the priorities in the first place.
-/* $NetBSD: renice.c,v 1.5 1997/10/19 14:01:38 lukem Exp $ */
-
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
+static const char copyright[] =
+"@(#) Copyright (c) 1983, 1989, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
+#if 0
#ifndef lint
-/*static char sccsid[] = "from: @(#)renice.c 8.1 (Berkeley) 6/9/93";*/
-__RCSID("$NetBSD: renice.c,v 1.5 1997/10/19 14:01:38 lukem Exp $");
+static char sccsid[] = "@(#)renice.c 8.1 (Berkeley) 6/9/93";
#endif /* not lint */
+#endif
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <err.h>
+#include <errno.h>
+#include <limits.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-int donice __P((int, int, int));
-int main __P((int, char **));
+static int donice(int, int, int, int);
+static int getnum(const char *, const char *, int *);
+static void usage(void);
/*
* Change the priority (nice) of processes
* running.
*/
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char *argv[])
{
- int which = PRIO_PROCESS;
- int who = 0, prio, errs = 0;
+ struct passwd *pwd;
+ int errs, incr, prio, which, who;
+ int delim;
+ int priflag;
+ errs = 0;
+ incr = 0;
+ which = PRIO_PROCESS;
+ who = 0;
argc--, argv++;
- if (argc < 2) {
- fprintf(stderr, "usage: renice priority [ [ -p ] pids ] ");
- fprintf(stderr, "[ [ -g ] pgrps ] [ [ -u ] users ]\n");
- exit(1);
- }
- prio = atoi(*argv);
- argc--, argv++;
- if (prio > PRIO_MAX)
- prio = PRIO_MAX;
- if (prio < PRIO_MIN)
- prio = PRIO_MIN;
- for (; argc > 0; argc--, argv++) {
+ if (argc < 2)
+ usage();
+ delim = 0;
+ priflag = 0;
+
+ /* incrementing priflag here ensures we only process
+ the single priority arg if it is the very first arg */
+ for (; argc > 0; argc--, argv++, priflag++) {
+ /* once we've seen -- , don't process anymore switches */
+ if (0 == delim) {
+ /* -n must immediately be followed by the incremental
+ priority */
+ if (strcmp(*argv, "-n") == 0) {
+ incr = 1;
+ argc--, argv++;
+ if (getnum("priority", *argv, &prio))
+ return (1);
+ continue;
+ }
if (strcmp(*argv, "-g") == 0) {
which = PRIO_PGRP;
continue;
which = PRIO_PROCESS;
continue;
}
+ if (strcmp(*argv, "--") == 0) {
+ delim = 1;
+ continue;
+ }
+ if (0 == priflag) {
+ /* if very first switch/arg and we've made it to
+ here, this must be the priority */
+ if (getnum("priority", *argv, &prio)) {
+ return(1);
+ }
+ continue;
+ }
+ }
if (which == PRIO_USER) {
- register struct passwd *pwd = getpwnam(*argv);
-
- if (pwd == NULL) {
- warnx("%s: unknown user", *argv);
+ if ((pwd = getpwnam(*argv)) != NULL)
+ who = pwd->pw_uid;
+ else if (getnum("uid", *argv, &who)) {
+ errs++;
+ continue;
+ } else if (who < 0) {
+ warnx("%s: bad value", *argv);
+ errs++;
continue;
}
- who = pwd->pw_uid;
} else {
- who = atoi(*argv);
+ if (getnum("pid", *argv, &who)) {
+ errs++;
+ continue;
+ }
if (who < 0) {
warnx("%s: bad value", *argv);
+ errs++;
continue;
}
}
- errs += donice(which, who, prio);
+ errs += donice(which, who, prio, incr);
}
exit(errs != 0);
}
-int
-donice(which, who, prio)
- int which, who, prio;
+static int
+donice(int which, int who, int prio, int incr)
{
int oldprio;
- extern int errno;
- errno = 0, oldprio = getpriority(which, who);
+ errno = 0;
+ oldprio = getpriority(which, who);
if (oldprio == -1 && errno) {
warn("%d: getpriority", who);
return (1);
}
+ if (incr)
+ prio = oldprio + prio;
+ if (prio > PRIO_MAX)
+ prio = PRIO_MAX;
+ if (prio < PRIO_MIN)
+ prio = PRIO_MIN;
if (setpriority(which, who, prio) < 0) {
warn("%d: setpriority", who);
return (1);
}
- fprintf(stderr, "%d: old priority %d, new priority %d\n", who, oldprio, prio);
return (0);
}
+
+static int
+getnum(const char *com, const char *str, int *val)
+{
+ long v;
+ char *ep;
+
+ errno = 0;
+ v = strtol(str, &ep, 10);
+ if (v < INT_MIN || v > INT_MAX || errno == ERANGE) {
+ warnx("%s argument %s is out of range.", com, str);
+ return (1);
+ }
+ if (ep == str || *ep != '\0' || errno != 0) {
+ warnx("Bad %s argument: %s.", com, str);
+ return (1);
+ }
+
+ *val = (int)v;
+ return (0);
+}
+
+static void
+usage()
+{
+ fprintf(stderr, "%s\n%s\n",
+"usage: renice priority [[-p] pid ...] [[-g] pgrp ...] [[-u] user ...]",
+" renice -n increment [[-p] pid ...] [[-g] pgrp ...] [[-u] user ...]");
+ exit(1);
+}
echo Lock ${lckfile} already held by `cat ${lckfile}`
endif
.Ed
-
.Pp
The examples assume that the filesystem where the lock file is to
be created is writeable by the user, and has space available.
#include <pam/pam_appl.h>
#include <pam/pam_misc.h>
-#include <bsm/libbsm.h>
-#include <bsm/audit_uevents.h>
-
-
#define PAM_END() do { \
int local_ret; \
if (pamh != NULL && creds_set) { \
static int export_pam_environment(void);
static int ok_to_export(const char *);
-void audit_success(struct passwd *pwd);
-void audit_fail(struct passwd *pwd, char *errmsg);
-
extern char **environ;
int
if (user == NULL)
usage();
- if (strlen(user) > MAXLOGNAME - 1) {
- audit_fail(NULL, "username too long");
+ if (strlen(user) > MAXLOGNAME - 1)
errx(1, "username too long");
- }
nargv = malloc(sizeof(char *) * (argc + 4));
- if (nargv == NULL) {
- audit_fail(NULL, "malloc failure");
+ if (nargv == NULL)
errx(1, "malloc failure");
- }
nargv[argc + 3] = NULL;
for (i = argc; i >= optind; i--)
pwd = getpwnam(username);
if (username == NULL || pwd == NULL || pwd->pw_uid != ruid)
pwd = getpwuid(ruid);
- if (pwd == NULL) {
- audit_fail(NULL, "who are you?");
+ if (pwd == NULL)
errx(1, "who are you?");
- }
-
gid = pwd->pw_gid;
username = strdup(pwd->pw_name);
- if (username == NULL) {
- audit_fail(NULL, "strdup failure");
+ if (username == NULL)
err(1, "strdup failure");
- }
if (asme) {
if (pwd->pw_shell != NULL && *pwd->pw_shell != '\0') {
}
}
- pwd = getpwnam(user);
-
/* Do the whole PAM startup thing */
retcode = pam_start("su", user, &conv, &pamh);
if (retcode != PAM_SUCCESS) {
syslog(LOG_ERR, "pam_start: %s", pam_strerror(pamh, retcode));
- audit_fail(pwd, "pam_start error");
errx(1, "pam_start: %s", pam_strerror(pamh, retcode));
}
if (retcode != PAM_SUCCESS) {
syslog(LOG_ERR, "pam_authenticate: %s",
pam_strerror(pamh, retcode));
- audit_fail(pwd, "pam_authenticate error");
errx(1, "Sorry");
}
retcode = pam_get_item(pamh, PAM_USER, (const void **)&p);
if (retcode != PAM_SUCCESS) {
syslog(LOG_ERR, "pam_chauthtok: %s",
pam_strerror(pamh, retcode));
- audit_fail(pwd, "pam_chauthtok error");
errx(1, "Sorry");
}
}
if (retcode != PAM_SUCCESS) {
syslog(LOG_ERR, "pam_acct_mgmt: %s",
pam_strerror(pamh, retcode));
- audit_fail(pwd, "pam_acct_mgmt error");
errx(1, "Sorry");
}
/* get target login information, default to root */
pwd = getpwnam(user);
- if (pwd == NULL) {
- audit_fail(NULL, "unknown login");
+ if (pwd == NULL)
errx(1, "unknown login: %s", user);
- }
/* if asme and non-standard target shell, must be root */
if (asme) {
- if (ruid != 0 && !chshell(pwd->pw_shell)) {
- audit_fail(pwd, "permission denied (shell)");
+ if (ruid != 0 && !chshell(pwd->pw_shell))
errx(1, "permission denied (shell).");
- }
}
else if (pwd->pw_shell && *pwd->pw_shell) {
- shell = pwd->pw_shell;
+ shell = strncpy(shellbuf, pwd->pw_shell, sizeof(shellbuf));
+ shellbuf[sizeof(shellbuf) - 1] = '\0';
iscsh = UNSET;
}
else {
* PAM modules might add supplementary groups in pam_setcred(), so
* initialize them first.
*/
- if( initgroups(user, pwd->pw_gid) ) {
- audit_fail(pwd, "initgroups failed");
+ if( initgroups(user, pwd->pw_gid) )
err(1, "initgroups failed");
- }
retcode = pam_open_session(pamh, 0);
if( retcode != PAM_SUCCESS ) {
PAM_END();
exit(WEXITSTATUS(statusp));
case -1:
- audit_fail(pwd, "fork() error");
err(1, "fork");
PAM_END();
exit(1);
case 0:
- /* audit before we relinquish privileges */
- audit_success(pwd);
if( setgid(pwd->pw_gid) )
err(1, "setgid");
if( setuid(pwd->pw_uid) )
snprintf(buf, sizeof(buf), " on %s", p);
return buf;
}
-
-/*
- * Include the following tokens in the audit record for successful su attempts
- * header
- * subject
- * return
- */
-void audit_success(struct passwd *pwd)
-{
- int aufd;
- token_t *tok;
- auditinfo_t auinfo;
- long au_cond;
- uid_t uid = pwd->pw_uid;
- gid_t gid = pwd->pw_gid;
- pid_t pid = getpid();
-
- /* If we are not auditing, don't cut an audit record; just return */
- if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) {
- fprintf(stderr, "su: Could not determine audit condition\n");
- exit(1);
- }
- if (au_cond == AUC_NOAUDIT)
- return;
-
- if(getaudit(&auinfo) != 0) {
- fprintf(stderr, "su: getaudit failed: %s\n", strerror(errno));
- exit(1);
- }
-
- if((aufd = au_open()) == -1) {
- fprintf(stderr, "su: Audit Error: au_open() failed\n");
- exit(1);
- }
-
- /* record the subject being created */
- if((tok = au_to_subject32(auinfo.ai_auid, geteuid(), getegid(),
- uid, gid, pid, auinfo.ai_asid, &auinfo.ai_termid)) == NULL) {
- fprintf(stderr, "su: Audit Error: au_to_subject32() failed\n");
- exit(1);
- }
- au_write(aufd, tok);
-
- if((tok = au_to_return32(0, 0)) == NULL) {
- fprintf(stderr, "su: Audit Error: au_to_return32() failed\n");
- exit(1);
- }
- au_write(aufd, tok);
-
- if(au_close(aufd, 1, AUE_su) == -1) {
- fprintf(stderr, "su: Audit Error: au_close() failed\n");
- exit(1);
- }
- return;
-}
-
-/*
- * Include the following tokens in the audit record for successful su attempts
- * header
- * subject
- * text
- * return
- */
-void audit_fail(struct passwd *pwd, char *errmsg)
-{
- int aufd;
- token_t *tok;
- auditinfo_t auinfo;
- long au_cond;
- /* If pwd is NULL, the event dont attribute it to any user */
- uid_t uid = pwd ? pwd->pw_uid : -1;
- gid_t gid = pwd ? pwd->pw_gid : -1;
- pid_t pid = getpid();
-
- /* If we are not auditing, don't cut an audit record; just return */
- if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) {
- fprintf(stderr, "su: Could not determine audit condition\n");
- exit(1);
- }
- if (au_cond == AUC_NOAUDIT)
- return;
-
- if(getaudit(&auinfo) != 0) {
- fprintf(stderr, "su: getaudit failed: %s\n", strerror(errno));
- exit(1);
- }
-
- if((aufd = au_open()) == -1) {
- fprintf(stderr, "su: Audit Error: au_open() failed\n");
- exit(1);
- }
-
- /* subject token corresponds to the subject being created */
- if((tok = au_to_subject32(auinfo.ai_auid, geteuid(), getegid(),
- uid, gid, pid, auinfo.ai_asid, &auinfo.ai_termid)) == NULL) {
- fprintf(stderr, "su: Audit Error: au_to_subject32() failed\n");
- exit(1);
- }
- au_write(aufd, tok);
-
- /* the actual error message text */
- if((tok = au_to_text(errmsg)) == NULL) {
- fprintf(stderr, "su: Audit Error: au_to_text() failed\n");
- exit(1);
- }
- au_write(aufd, tok);
-
- if((tok = au_to_return32(1, errno)) == NULL) {
- fprintf(stderr, "su: Audit Error: au_to_return32() failed\n");
- exit(1);
- }
- au_write(aufd, tok);
-
- if(au_close(aufd, 1, AUE_su) == -1) {
- fprintf(stderr, "su: Audit Error: au_close() failed\n");
- exit(1);
- }
- return;
-}
.Nm
utility conforms to
.St -p1003.2-92 .
-
return (0);
if (p1->p_slptime > p2->p_slptime)
return (1);
- /*
- * favor one sleeping in a non-interruptible sleep
- */
- if (p1->p_flag & P_SINTR && (p2->p_flag & P_SINTR) == 0)
- return (1);
- if (p2->p_flag & P_SINTR && (p1->p_flag & P_SINTR) == 0)
- return (0);
return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
}
#include <sys/socket.h>
#include <sys/tty.h>
-#include <machine/cpu.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
-.\" $NetBSD: who.1,v 1.9 1997/10/20 03:20:28 lukem Exp $
-.\"
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" SUCH DAMAGE.
.\"
.\" @(#)who.1 8.2 (Berkeley) 12/30/93
+.\" $FreeBSD: src/usr.bin/who/who.1,v 1.16 2004/07/02 22:22:34 ru Exp $
.\"
-.Dd December 6, 1994
+.Dd May 8, 2002
.Dt WHO 1
.Os
.Sh NAME
.Nm who
-.Nd display who is logged in
+.Nd display who is on the system
.Sh SYNOPSIS
.Nm
-.Op Fl mTuH
-.Op Ar file
-.Nm
-.Ar am i
+.Op Fl HmqsTu
+.Op Cm am I
+.Op Ar file
.Sh DESCRIPTION
-The
+The
.Nm
-utility displays a list of all users currently logged on, showing for
-each user the login name, tty name, the date and time of login, and
-hostname if not local.
-.Pp
-Available options:
+utility displays information about currently logged in users.
+By default, this includes the login name, tty name, date and time of login and
+remote hostname if not local.
.Pp
-.Bl -tag -width file
+The options are as follows:
+.Bl -tag -width indent
+.It Fl H
+Write column headings above the output.
.It Fl m
-Only print information about the current terminal. This is the
-.Tn POSIX
-way of saying
-.Nm
-.Ar am i .
+Show information about the terminal attached to standard input only.
+.It Fl q
+.Dq "Quick mode" :
+List the names and number of logged in users in columns.
+All other command line options are ignored.
+.It Fl s
+Show the name, line and time fields only.
+This is the default.
.It Fl T
-Print a character after the user name indicating the state of the
-terminal line:
-.Sq +
-if the terminal is writable;
-.Sq -
-if it is not;
-and
-.Sq ?
-if a bad line is encountered.
+Indicate whether each user is accepting messages.
+One of the following characters is written:
+.Pp
+.Bl -tag -width 1n -compact
+.It Li +
+User is accepting messages.
+.It Li \&-
+User is not accepting messages.
+.It Li \&?
+An error occurred.
+.El
.It Fl u
-Print the idle time for each user.
-.It Fl H
-Write column headings above the regular output.
-.It Ar \&am I
-Returns the invoker's real user name.
-.It Ar file
+Show idle time for each user in hours and minutes as
+.Ar hh Ns : Ns Ar mm ,
+.Ql \&.
+if the user has been idle less that a minute, and
+.Dq Li old
+if the user has been idle more than 24 hours.
+.It Cm am I
+Equivalent to
+.Fl m .
+.El
+.Pp
By default,
.Nm
gathers information from the file
.Pa /var/run/utmp .
-An alternative
+An alternate
.Ar file
may be specified which is usually
.Pa /var/log/wtmp
.Pa wtmp
was last truncated or
created.
-.El
.Pp
If
.Pa /var/log/wtmp
is being used as the file, the user name may be empty
-or one of the special characters '|', '}' and '~'. Logouts produce
-an output line without any user name. For more information on the
+or one of the special characters '|', '}' and '~'.
+Logouts produce
+an output line without any user name.
+For more information on the
special characters, see
.Xr utmp 5 .
+.Sh ENVIRONMENT
+The
+.Ev COLUMNS , LANG , LC_ALL
+and
+.Ev LC_TIME
+environment variables affect the execution of
+.Nm
+as described in
+.Xr environ 7 .
.Sh FILES
.Bl -tag -width /var/log/wtmp.[0-6] -compact
.It Pa /var/run/utmp
.It Pa /var/log/wtmp
.It Pa /var/log/wtmp.[0-6]
.El
+.Sh DIAGNOSTICS
+.Ex -std
.Sh SEE ALSO
.Xr last 1 ,
-.Xr mesg 1 ,
.Xr users 1 ,
-.Xr getuid 2 ,
+.Xr w 1 ,
.Xr utmp 5
.Sh STANDARDS
The
.Nm
-utility is expected to conform to
-.St -p1003.2-92 .
+utility conforms to
+.St -p1003.1-2001 .
.Sh HISTORY
A
.Nm
-utility appeared in
-.At v6 .
+command appeared in
+.At v1 .
-/* $NetBSD: who.c,v 1.6 1997/10/20 03:20:29 lukem Exp $ */
-
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Michael Fischbein.
+/*-
+ * Copyright (c) 2002 Tim J. Robbins.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
*/
#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT(
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)who.c 8.1 (Berkeley) 6/6/93";
-#endif
-__RCSID("$NetBSD: who.c,v 1.6 1997/10/20 03:20:29 lukem Exp $");
-#endif /* not lint */
+/* commented as FBSDID not needed for Tiger ......
+__FBSDID("$FreeBSD: src/usr.bin/who/who.c,v 1.20 2003/10/26 05:05:48 peter Exp $");
+*/
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <sys/stat.h>
+
#include <err.h>
+#include <errno.h>
+#include <langinfo.h>
+#include <limits.h>
#include <locale.h>
+#include <paths.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <timeconv.h>
#include <unistd.h>
#include <utmp.h>
-void output __P((struct utmp *));
-void output_labels __P((void));
-void who_am_i __P((FILE *));
-FILE *file __P((char *));
-void usage __P((void));
-
-int show_term; /* show term state */
-int show_idle; /* show idle time */
-
-int main __P((int, char **));
+static void heading(void);
+static void process_utmp(FILE *);
+static void process_wtmp(FILE *);
+static void quick(FILE *);
+static void row(struct utmp *);
+static int ttywidth(void);
+static void usage(void);
+static void whoami(FILE *);
+
+static int bflag; /* date & time of last reboot */
+static int dflag; /* dead processes */
+static int Hflag; /* Write column headings */
+static int lflag; /* waiting to login */
+static int mflag; /* Show info about current terminal */
+static int pflag; /* Processes active & spawned by init */
+static int qflag; /* "Quick" mode */
+static int rflag; /* run-level of the init process */
+static int sflag; /* Show name, line, time */
+static int tflag; /* time of change to system clock */
+static int Tflag; /* Show terminal state */
+static int uflag; /* Show idle time */
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char *argv[])
{
- struct utmp usr;
- FILE *ufp;
- int c, only_current_term, show_labels;
+ int ch;
+ const char *file;
+ FILE *fp;
+ FILE *wtmp_fp;
+
+ setlocale(LC_TIME, "");
- setlocale(LC_ALL, "");
+ while ((ch = getopt(argc, argv, "abdHlmpqrstTu")) != -1) {
+ switch (ch) {
- only_current_term = show_term = show_idle = show_labels = 0;
- while ((c = getopt(argc, argv, "mTuH")) != -1) {
- switch (c) {
- case 'm':
- only_current_term = 1;
+ case 'a': /* -b, -d, -l, -p, -r, -t, -T and -u */
+ bflag = dflag = lflag = pflag = 1;
+ rflag = tflag = Tflag = uflag = 1;
+ break;
+ case 'b': /* date & time of last reboot */
+ bflag = 1;
+ break;
+ case 'd': /* dead processes */
+ dflag = 1;
+ break;
+ case 'H': /* Write column headings */
+ Hflag = 1;
+ break;
+ case 'l': /* waiting to login */
+ lflag = 1;
+ break;
+ case 'm': /* Show info about current terminal */
+ mflag = 1;
+ break;
+ case 'p': /* Processes active & spawned by init */
+ pflag = 1;
+ break;
+ case 'q': /* "Quick" mode */
+ qflag = 1;
break;
- case 'T':
- show_term = 1;
+ case 'r': /* run-level of the init process */
+ rflag = 1;
break;
- case 'u':
- show_idle = 1;
+ case 's': /* Show name, line, time */
+ sflag = 1;
break;
- case 'H':
- show_labels = 1;
+ case 't': /* time of change to system clock */
+ tflag = 1;
+ break;
+ case 'T': /* Show terminal state */
+ Tflag = 1;
+ break;
+ case 'u': /* Show idle time */
+ uflag = 1;
break;
default:
usage();
- /* NOTREACHED */
+ /*NOTREACHED*/
}
}
argc -= optind;
argv += optind;
- if (chdir("/dev")) {
- err(1, "cannot change directory to /dev");
- /* NOTREACHED */
+ if (argc >= 2 && strcmp(argv[0], "am") == 0 &&
+ (strcmp(argv[1], "i") == 0 || strcmp(argv[1], "I") == 0)) {
+ /* "who am i" or "who am I", equivalent to -m */
+ mflag = 1;
+ argc -= 2;
+ argv += 2;
}
+ if (argc > 1)
+ usage();
- if (show_labels)
- output_labels();
+ if (*argv != NULL)
+ file = *argv;
+ else
+ file = _PATH_UTMP;
+ if ((fp = fopen(file, "r")) == NULL)
+ err(1, "%s", file);
+
+ if (qflag)
+ quick(fp);
+ else {
+ if (sflag)
+ Tflag = uflag = 0;
+ if (Hflag)
+ heading();
+ if (mflag)
+ whoami(fp);
+ else
+ /* read and process utmp file for relevant options */
+ if( Tflag || uflag || !(bflag || dflag || lflag || pflag || rflag) )
+ process_utmp(fp);
+ }
- switch (argc) {
- case 0: /* who */
- ufp = file(_PATH_UTMP);
+ fclose(fp);
- if (only_current_term) {
- who_am_i(ufp);
- } else {
- /* only entries with both name and line fields */
- while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)
- if (*usr.ut_name && *usr.ut_line)
- output(&usr);
- }
- break;
- case 1: /* who utmp_file */
- ufp = file(*argv);
-
- if (only_current_term) {
- who_am_i(ufp);
- } else {
- /* all entries */
- while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)
- output(&usr);
+ /* read and process wtmp file for relevant options */
+ if (bflag || dflag || lflag || pflag || rflag ) {
+
+ /* Open the wtmp file */
+ if ((wtmp_fp = fopen(_PATH_WTMP, "r")) == NULL)
+ err(1, "%s", _PATH_WTMP);
+ else {
+ process_wtmp(wtmp_fp);
+ fclose(wtmp_fp);
}
- break;
- case 2: /* who am i */
- ufp = file(_PATH_UTMP);
- who_am_i(ufp);
- break;
- default:
- usage();
- /* NOTREACHED */
}
+
exit(0);
}
-void
-who_am_i(ufp)
- FILE *ufp;
+static void
+usage(void)
{
- struct utmp usr;
- struct passwd *pw;
- char *p;
- char *t;
-
- /* search through the utmp and find an entry for this tty */
- if ((p = ttyname(0)) != NULL) {
- /* strip any directory component */
- if ((t = strrchr(p, '/')) != NULL)
- p = t + 1;
- while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)
- if (usr.ut_name && !strcmp(usr.ut_line, p)) {
- output(&usr);
- return;
- }
- /* well, at least we know what the tty is */
- (void)strncpy(usr.ut_line, p, UT_LINESIZE);
- } else
- (void)strcpy(usr.ut_line, "tty??");
-
- pw = getpwuid(getuid());
- (void)strncpy(usr.ut_name, pw ? pw->pw_name : "?", UT_NAMESIZE);
- (void)time(&usr.ut_time);
- *usr.ut_host = '\0';
- output(&usr);
+
+ fprintf(stderr, "usage: who [-abdHlmpqrstTu] [am I] [file]\n");
+ exit(1);
}
-void
-output(up)
- struct utmp *up;
+static void
+heading(void)
{
+
+ printf("%-*s ", UT_NAMESIZE, "NAME");
+ if (Tflag)
+ printf("S ");
+ printf("%-*s ", UT_LINESIZE, "LINE");
+ printf("%-*s ", 12, "TIME");
+ if (uflag)
+ printf("IDLE ");
+ printf("%-*s", UT_HOSTSIZE, "FROM");
+ putchar('\n');
+}
+
+static void
+row(struct utmp *ut)
+{
+ char buf[80], tty[sizeof(_PATH_DEV) + UT_LINESIZE];
struct stat sb;
- char line[sizeof (up->ut_line) + 1];
+ time_t idle, t;
+ static int d_first = -1;
+ struct tm *tm;
char state;
- static time_t now = 0;
- time_t idle;
-
- state = '?';
- idle = 0;
-
- if (show_term || show_idle) {
- if (now == 0)
- time(&now);
-
- strncpy(line, up->ut_line, sizeof (up->ut_line));
- line[sizeof (up->ut_line)] = '\0';
-
- if (stat(line, &sb) == 0) {
- state = (sb.st_mode & 020) ? '+' : '-';
- idle = now - sb.st_atime;
- }
-
- }
-
- (void)printf("%-*.*s ", UT_NAMESIZE, UT_NAMESIZE, up->ut_name);
- if (show_term) {
- (void)printf("%c ", state);
+ if (d_first < 0)
+ d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
+
+ if (Tflag || uflag) {
+ snprintf(tty, sizeof(tty), "%s%.*s", _PATH_DEV,
+ UT_LINESIZE, ut->ut_line);
+ state = '?';
+ idle = 0;
+ if (stat(tty, &sb) == 0) {
+ state = sb.st_mode & (S_IWOTH|S_IWGRP) ?
+ '+' : '-';
+ idle = time(NULL) - sb.st_mtime;
+ }
}
- (void)printf("%-*.*s ", UT_LINESIZE, UT_LINESIZE, up->ut_line);
- (void)printf("%.12s ", ctime(&up->ut_time) + 4);
-
- if (show_idle) {
- if (idle < 60)
- (void)printf(" . ");
- else if (idle < (24 * 60 * 60))
- (void)printf("%02ld:%02ld ",
- (long)(idle / (60 * 60)),
- (long)(idle % (60 * 60)) / 60);
+ printf("%-*.*s ", UT_NAMESIZE, UT_NAMESIZE, ut->ut_name);
+ if (Tflag)
+ printf("%c ", state);
+ printf("%-*.*s ", UT_LINESIZE, UT_LINESIZE, ut->ut_line);
+ t = _time32_to_time(ut->ut_time);
+ tm = localtime(&t);
+ strftime(buf, sizeof(buf), d_first ? "%e %b %R" : "%b %e %R", tm);
+ printf("%-*s ", 12, buf);
+ if (uflag) {
+ if (idle < 60)
+ printf(" . ");
+ else if (idle < 24 * 60 * 60)
+ printf("%02d:%02d ", (int)(idle / 60 / 60),
+ (int)(idle / 60 % 60));
else
- (void)printf(" old ");
+ printf(" old ");
}
-
- if (*up->ut_host)
- printf("\t(%.*s)", UT_HOSTSIZE, up->ut_host);
- (void)putchar('\n');
+ if (*ut->ut_host != '\0')
+ printf("(%.*s)", UT_HOSTSIZE, ut->ut_host);
+ putchar('\n');
+
}
-void
-output_labels()
+static void
+process_utmp(FILE *fp)
{
- (void)printf("%-*.*s ", UT_NAMESIZE, UT_NAMESIZE, "USER");
+ struct utmp ut;
- if (show_term)
- (void)printf("S ");
-
- (void)printf("%-*.*s ", UT_LINESIZE, UT_LINESIZE, "LINE");
- (void)printf("WHEN ");
+ while (fread(&ut, sizeof(ut), 1, fp) == 1)
+ if (*ut.ut_name != '\0') {
+ row(&ut);
+ }
+}
- if (show_idle)
- (void)printf("IDLE ");
-
- (void)printf("\t%.*s", UT_HOSTSIZE, "FROM");
+/* For some options, process the wtmp file to generate output */
+static void
+process_wtmp(FILE *fp)
+{
+ struct utmp ut;
+ struct utmp lboot_ut = { "", "", "", 0 };
+ int num = 0; /* count of user entries */
+
+ while (fread(&ut, sizeof(ut), 1, fp) == 1)
+ if (*ut.ut_name != '\0') {
+ if (bflag && (!strcmp(ut.ut_name, "reboot"))) {
+ memcpy(&lboot_ut, &ut, sizeof(ut));
+ }
+ else
+ num++;
+ };
+
+ if (bflag && (!strcmp(lboot_ut.ut_name, "reboot")))
+ row(&lboot_ut);
+
+ /* run level of the init process is unknown in BSD system. If multi
+ user, then display the highest run level. Else, no-op.
+ */
+ if (rflag && (num > 1))
+ printf(" . run-level 3\n");
+}
+
+static void
+quick(FILE *fp)
+{
+ struct utmp ut;
+ int col, ncols, num;
+
+ ncols = ttywidth();
+ col = num = 0;
+ while (fread(&ut, sizeof(ut), 1, fp) == 1) {
+ if (*ut.ut_name == '\0')
+ continue;
+ printf("%-*.*s", UT_NAMESIZE, UT_NAMESIZE, ut.ut_name);
+ if (++col < ncols / (UT_NAMESIZE + 1))
+ putchar(' ');
+ else {
+ col = 0;
+ putchar('\n');
+ }
+ num++;
+ }
+ if (col != 0)
+ putchar('\n');
- (void)putchar('\n');
+ printf("# users = %d\n", num);
}
-FILE *
-file(name)
- char *name;
+static void
+whoami(FILE *fp)
{
- FILE *ufp;
+ struct utmp ut;
+ struct passwd *pwd;
+ const char *name, *p, *tty;
+
+ if ((tty = ttyname(STDIN_FILENO)) == NULL)
+ tty = "tty??";
+ else if ((p = strrchr(tty, '/')) != NULL)
+ tty = p + 1;
+
+ /* Search utmp for our tty, dump first matching record. */
+ while (fread(&ut, sizeof(ut), 1, fp) == 1)
+ if (*ut.ut_name != '\0' && strncmp(ut.ut_line, tty,
+ UT_LINESIZE) == 0) {
+ row(&ut);
+ return;
+ }
- if (!(ufp = fopen(name, "r"))) {
- err(1, "%s", name);
- /* NOTREACHED */
- }
- return (ufp);
+ /* Not found; fill the utmp structure with the information we have. */
+ memset(&ut, 0, sizeof(ut));
+ if ((pwd = getpwuid(getuid())) != NULL)
+ name = pwd->pw_name;
+ else
+ name = "?";
+ strncpy(ut.ut_name, name, UT_NAMESIZE);
+ strncpy(ut.ut_line, tty, UT_LINESIZE);
+ ut.ut_time = _time_to_time32(time(NULL));
+ row(&ut);
}
-void
-usage()
+static int
+ttywidth(void)
{
- (void)fprintf(stderr, "usage: who [-mTuH] [ file ]\n who am i\n");
- exit(1);
+ struct winsize ws;
+ long width;
+ char *cols, *ep;
+
+ if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') {
+ errno = 0;
+ width = strtol(cols, &ep, 10);
+ if (errno || width <= 0 || width > INT_MAX || ep == cols ||
+ *ep != '\0')
+ warnx("invalid COLUMNS environment variable ignored");
+ else
+ return (width);
+ }
+ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1)
+ return (ws.ws_col);
+
+ return (80);
}