SubProjects = alias apply basename chroot date dirname echo env expr false \
find getopt hostname id jot kill killall lastcomm locate logname mktemp \
- nice nohup path_helper printenv printf pwd renice script shlock sleep \
+ nice nohup path_helper printenv printf pwd renice script seq shlock sleep \
tee test time true uname users w whereis which who xargs yes
ifeq ($(Embedded),NO)
.Xr sh 1
shells are listed here.
Consult a shell's manual page for
-details on the operation its builtin commands.
+details on the operation of its builtin commands.
Beware that the
.Xr sh 1
manual page, at least, calls some of these commands
MANPAGES = alias.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = apply.c
MANPAGES = apply.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = basename.c
MANPAGES = basename.1 dirname.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = chroot.c
MANPAGES = chroot.8
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = date.c netdate.c vary.c
MANPAGES = date.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
if (*argv && **argv == '+')
format = *argv + 1;
+#ifdef __APPLE__
+ /* 7999711 */
+ struct tm *ltp = localtime(&tval);
+ if (ltp == NULL) {
+ err(1, "localtime");
+ }
+ lt = *ltp;
+#else
lt = *localtime(&tval);
+#endif
badv = vary_apply(v, <);
if (badv) {
fprintf(stderr, "%s: Cannot apply date adjustment\n",
CFILES = dirname.c
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = echo.c
MANPAGES = echo.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
CFILES = env.c
MANPAGES = env.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = expr.c
MANPAGES = expr.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__DARWIN_UNIX03=1
Extra_LD_Flags = -dead_strip
CFILES = false.c
MANPAGES = false.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
YFILES = getdate.y
MANPAGES = find.1
-Extra_CC_Flags = -Wall -Werror -mdynamic-no-pic \
+Extra_CC_Flags = -Wall -Werror \
-D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
exec_f f_size;
exec_f f_type;
exec_f f_user;
+#ifdef __APPLE__
+exec_f f_xattr;
+exec_f f_xattrname;
+#endif /* __APPLE__ */
extern int ftsoptions, isdeprecated, isdepth, isoutput, issort, isxargs;
extern int mindepth, maxdepth;
.\" SUCH DAMAGE.
.\"
.\" @(#)find.1 8.7 (Berkeley) 5/9/95
-.\" $FreeBSD: src/usr.bin/find/find.1,v 1.86 2008/03/03 08:32:58 ru Exp $
+.\" $FreeBSD: src/usr.bin/find/find.1,v 1.87 2009/09/20 16:47:56 jilles Exp $
.\"
.Dd February 24, 2008
.Dt FIND 1
Please refer to the
.Ic -atime
primary description for information on supported time units.
-.\" .It Ic -acl
-.\" May be used in conjunction with other primaries to locate
-.\" files with extended ACLs.
-.\" See
-.\" .Xr acl 3
-.\" for more information.
+.It Ic -acl
+May be used in conjunction with other primaries to locate
+files with extended ACLs.
+See
+.Xr acl 3
+for more information.
.It Ic -amin Ar n
True if the difference between the file last access time and the time
.Nm
.Dq Pa \&.
for security reasons.
Depth-first traversal processing is implied by this option.
+Following symlinks is incompatible with this option.
.It Ic -depth
Always true;
same as the
The same thing as
.Ic -path ,
for GNU find compatibility.
+.It Ic -xattr
+True if the file has any extended attributes.
+.It Ic -xattrname Ar name
+True if the file has an extended attribute with the specified
+.Ar name .
.El
.Pp
All primaries which take a numeric argument allow the number to be
Use the
.Xr echo 1
command to print out a list of all the files.
-.It Li "find -L /usr/ports/packages -type l -delete"
+.It Li "find -L /usr/ports/packages -type l -exec rm -- {} +"
Delete all broken symbolic links in
.Pa /usr/ports/packages .
.It Li "find /usr/src -name CVS -prune -o -depth +6 -print"
.Xr which 1 ,
.Xr xargs 1 ,
.Xr stat 2 ,
-.\" .Xr acl 3 ,
+.Xr acl 3 ,
.Xr fts 3 ,
.Xr getgrent 3 ,
.Xr getpwent 3 ,
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/find/find.c,v 1.18 2006/05/14 20:23:00 krion Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/find/find.c,v 1.20 2009/12/13 03:14:06 delphij Exp $");
#include <sys/types.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/find/function.c,v 1.60 2008/02/24 00:01:06 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/find/function.c,v 1.63 2009/09/04 20:01:16 trasz Exp $");
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <sys/timeb.h>
+#ifdef __APPLE__
+#include <sys/xattr.h>
+#endif /* __APPLE__ */
#include <dirent.h>
#include <err.h>
return new;
}
-#ifndef __APPLE__
/*
* -acl function --
*
* Show files with EXTENDED ACL attributes.
*/
+#ifdef __APPLE__
int
f_acl(PLAN *plan __unused, FTSENT *entry)
{
- int match, entries;
+ acl_t facl;
+ int match;
acl_entry_t ae;
+
+ match = 0;
+ if ((facl = acl_get_link_np(entry->fts_accpath, ACL_TYPE_EXTENDED)) != NULL) {
+ if (acl_get_entry(facl, ACL_FIRST_ENTRY, &ae) == 0) {
+ match = 1;
+ }
+ acl_free(facl);
+ }
+ return match;
+}
+#else /* !__APPLE__ */
+int
+f_acl(PLAN *plan __unused, FTSENT *entry)
+{
acl_t facl;
+ acl_type_t acl_type;
+ int acl_supported = 0, ret, trivial;
if (S_ISLNK(entry->fts_statp->st_mode))
return 0;
- if ((match = pathconf(entry->fts_accpath, _PC_ACL_EXTENDED)) <= 0) {
- if (match < 0 && errno != EINVAL)
- warn("%s", entry->fts_accpath);
- else
- return 0;
+ ret = pathconf(entry->fts_accpath, _PC_ACL_NFS4);
+ if (ret > 0) {
+ acl_supported = 1;
+ acl_type = ACL_TYPE_NFS4;
+ } else if (ret < 0 && errno != EINVAL) {
+ warn("%s", entry->fts_accpath);
+ return (0);
}
- match = 0;
- if ((facl = acl_get_file(entry->fts_accpath,ACL_TYPE_ACCESS)) != NULL) {
- if (acl_get_entry(facl, ACL_FIRST_ENTRY, &ae) == 1) {
- /*
- * POSIX.1e requires that ACLs of type ACL_TYPE_ACCESS
- * must have at least three entries (owner, group,
- * other).
- */
- entries = 1;
- while (acl_get_entry(facl, ACL_NEXT_ENTRY, &ae) == 1) {
- if (++entries > 3) {
- match = 1;
- break;
- }
- }
+ if (acl_supported == 0) {
+ ret = pathconf(entry->fts_accpath, _PC_ACL_EXTENDED);
+ if (ret > 0) {
+ acl_supported = 1;
+ acl_type = ACL_TYPE_ACCESS;
+ } else if (ret < 0 && errno != EINVAL) {
+ warn("%s", entry->fts_accpath);
+ return (0);
}
- acl_free(facl);
- } else
+ }
+ if (acl_supported == 0)
+ return (0);
+
+ facl = acl_get_file(entry->fts_accpath, acl_type);
+ if (facl == NULL) {
warn("%s", entry->fts_accpath);
- return match;
+ return (0);
+ }
+ ret = acl_is_trivial_np(facl, &trivial);
+ acl_free(facl);
+ if (ret) {
+ warn("%s", entry->fts_accpath);
+ acl_free(facl);
+ return (0);
+ }
+ if (trivial)
+ return (0);
+ return (1);
}
+#endif /* __APPLE__ */
PLAN *
c_acl(OPTION *option, char ***argvp __unused)
{
+#ifndef __APPLE__
ftsoptions &= ~FTS_NOSTAT;
+#endif /* !__APPLE__ */
return (palloc(option));
}
-#endif /* !__APPLE__ */
+
+#ifdef __APPLE__
+int
+f_xattr(PLAN *plan __unused, FTSENT *entry)
+{
+ ssize_t xattr;
+ int match;
+
+ match = 0;
+ xattr = listxattr(entry->fts_accpath, NULL, 0, XATTR_NOFOLLOW);
+ if (xattr > 0) {
+ match = 1;
+ }
+ return match;
+}
+
+int
+f_xattrname(PLAN *plan, FTSENT *entry)
+{
+ ssize_t xattr;
+ int match;
+
+ match = 0;
+ xattr = getxattr(entry->fts_accpath, plan->c_data, NULL, 0, 0, XATTR_NOFOLLOW);
+ if (xattr > 0) {
+ match = 1;
+ }
+ return match;
+}
+#endif /* __APPLE__ */
/*
* -delete functions --
/* sanity check */
if (isdepth == 0 || /* depth off */
- (ftsoptions & FTS_NOSTAT) || /* not stat()ing */
- !(ftsoptions & FTS_PHYSICAL) || /* physical off */
- (ftsoptions & FTS_LOGICAL)) /* or finally, logical on */
+ (ftsoptions & FTS_NOSTAT)) /* not stat()ing */
errx(1, "-delete: insecure options got turned on");
+ if (!(ftsoptions & FTS_PHYSICAL) || /* physical off */
+ (ftsoptions & FTS_LOGICAL)) /* or finally, logical on */
+ errx(1, "-delete: forbidden when symlinks are followed");
+
/* Potentially unsafe - do not accept relative paths whatsoever */
if (strchr(entry->fts_accpath, '/') != NULL)
errx(1, "-delete: %s: relative path potentially not safe",
if ((entry->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(entry->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) &&
geteuid() == 0)
- chflags(entry->fts_accpath,
+ lchflags(entry->fts_accpath,
entry->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE));
/* rmdir directories, unlink everything else */
{
ftsoptions &= ~FTS_NOSTAT; /* no optimise */
- ftsoptions |= FTS_PHYSICAL; /* disable -follow */
- ftsoptions &= ~FTS_LOGICAL; /* disable -follow */
isoutput = 1; /* possible output */
isdepth = 1; /* -depth implied */
if (plan->flags & F_LINK) {
name = fn;
- if (readlink(entry->fts_path, fn, sizeof(fn)) == -1)
+ if (readlink(entry->fts_accpath, fn, sizeof(fn)) == -1)
return 0;
} else if (entry->fts_namelen == 0) {
name = basename(entry->fts_path);
/* SUPPRESS 288 on yyerrlab *//* Label unused */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/find/getdate.y,v 1.4 2005/08/25 13:44:02 roberto Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/find/getdate.y,v 1.6 2009/12/13 03:14:06 delphij Exp $");
#include <stdio.h>
#include <ctype.h>
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/find/ls.c,v 1.17 2004/01/20 09:27:03 des Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/find/ls.c,v 1.19 2009/12/13 03:14:06 delphij Exp $");
#include <sys/param.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
+
#ifdef __APPLE__
-/* definition from utmp.h */
-#define UT_NAMESIZE 8
+#undef MAXLOGNAME
+#define MAXLOGNAME 17
#endif /* __APPLE__ */
#include "find.h"
(void)printf("%6lu %8"PRId64" ", (u_long) sb->st_ino, sb->st_blocks);
(void)strmode(sb->st_mode, modep);
-#ifdef __APPLE__
- (void)printf("%s %3u %-*s %-*s ", modep, sb->st_nlink, UT_NAMESIZE,
- user_from_uid(sb->st_uid, 0), UT_NAMESIZE,
-#else /* !__APPLE__ */
(void)printf("%s %3u %-*s %-*s ", modep, sb->st_nlink, MAXLOGNAME - 1,
user_from_uid(sb->st_uid, 0), MAXLOGNAME - 1,
-#endif /* __APPLE__ */
group_from_gid(sb->st_gid, 0));
if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode))
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/find/main.c,v 1.16 2008/03/03 08:32:58 ru Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/find/main.c,v 1.18 2009/12/13 03:14:06 delphij Exp $");
#include <sys/types.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/find/misc.c,v 1.8 2005/04/02 07:44:12 tjr Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/find/misc.c,v 1.10 2009/12/13 03:14:06 delphij Exp $");
#include <sys/types.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/find/option.c,v 1.26 2008/02/23 16:29:04 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/find/option.c,v 1.28 2009/12/13 03:14:06 delphij Exp $");
#include <sys/types.h>
#include <sys/stat.h>
{ "-Bnewer", c_newer, f_newer, F_TIME_B },
{ "-Btime", c_Xtime, f_Xtime, F_TIME_B },
{ "-a", c_and, NULL, 0 },
-#ifndef __APPLE__
{ "-acl", c_acl, f_acl, 0 },
-#endif /* !__APPLE__ */
{ "-amin", c_Xmin, f_Xmin, F_TIME_A },
{ "-and", c_and, NULL, 0 },
{ "-anewer", c_newer, f_newer, F_TIME_A },
{ "-uid", c_user, f_user, 0 },
{ "-user", c_user, f_user, 0 },
{ "-wholename", c_name, f_path, 0 },
+#ifdef __APPLE__
+ { "-xattr", c_simple, f_xattr, 0 },
+ { "-xattrname", c_name, f_xattrname, 0 },
+#endif /* __APPLE__ */
{ "-xdev", c_xdev, f_always_true, 0 },
// -xtype
};
CFILES = getopt.c
MANPAGES = getopt.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = hostname.c
MANPAGES = hostname.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic -D__FBSDID=__RCSID
+Extra_CC_Flags = -Wall -D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = id.c
MANPAGES = groups.1 id.1 whoami.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__FBSDID=__RCSID -DUSE_BSM_AUDIT \
-Wno-error
Extra_LD_Flags = -dead_strip
void
auditid(void)
{
- auditinfo_t auditinfo;
+ auditinfo_addr_t auditinfo;
- if (getaudit(&auditinfo) < 0)
+ if (getaudit_addr(&auditinfo, sizeof(auditinfo)) < 0)
err(1, "getaudit");
printf("auid=%d\n", auditinfo.ai_auid);
printf("mask.success=0x%08x\n", auditinfo.ai_mask.am_success);
printf("mask.failure=0x%08x\n", auditinfo.ai_mask.am_failure);
- printf("termid.port=0x%08x\n", auditinfo.ai_termid.port);
+ printf("termid.port=0x%08x\n", auditinfo.ai_termid.at_port);
printf("asid=%d\n", auditinfo.ai_asid);
}
#endif
CFILES = jot.c
MANPAGES = jot.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic -D__FBSDID=__RCSID
+Extra_CC_Flags = -Wall -D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
.\" SUCH DAMAGE.
.\"
.\" @(#)jot.1 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD: src/usr.bin/jot/jot.1,v 1.23 2006/11/06 15:11:50 dds Exp $
+.\" $FreeBSD: src/usr.bin/jot/jot.1,v 1.24 2010/02/20 00:16:44 delphij Exp $
.\"
-.Dd November 6, 2006
+.Dd February 19, 2010
.Dt JOT 1
.Os
.Sh NAME
.Xr ed 1 ,
.Xr expand 1 ,
.Xr rs 1 ,
+.Xr seq 1 ,
.Xr yes 1 ,
.Xr arc4random 3 ,
.Xr printf 3 ,
#endif
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/jot/jot.c,v 1.37 2006/12/09 15:23:20 delphij Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/jot/jot.c,v 1.40 2009/12/13 03:14:06 delphij Exp $");
/*
* jot - print sequential or random data
int ch;
int mask = 0;
int n = 0;
- double begin;
+ double begin = BEGIN_DEF;
double divisor;
- double ender;
- double s;
+ double ender = ENDER_DEF;
+ double s = STEP_DEF;
double x, y;
long i;
- long reps;
+ long reps = REPS_DEF;
while ((ch = getopt(argc, argv, "b:cnp:rs:w:")) != -1)
switch (ch) {
CFILES = kill.c
MANPAGES = kill.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = killall.c
MANPAGES = killall.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
#include <getopt.h>
#define OPTIONS ("c:dej:lmst:u:vz")
+#ifdef __APPLE__
+#include <TargetConditionals.h>
+#endif
+
static void __dead2
usage(void)
{
/* i = 1, skip program name */
for (i = 1; i < *argc; i++) {
- /* Stop if we encounter either a non-option or -- */
- if (*argv[i] != '-' || strcmp(argv[i], "--") == 0)
+ /* Stop kludging if we encounter -- */
+ if (strcmp(argv[i], "--") == 0)
kludge = 0;
ptr = argv[i] + 1;
- if (kludge && strchr(OPTIONS, *ptr) == NULL) {
+ /* Only process arguments that start with - and do not look like an existing option. */
+ if (kludge && *argv[i] == '-' && *ptr && strchr(OPTIONS, *ptr) == NULL) {
if (isalpha(*ptr)) {
if (strcmp(ptr, "help") == 0)
usage();
continue;
mib[0] = CTL_KERN;
+#if defined(__APPLE__) && TARGET_OS_EMBEDDED
+ mib[1] = KERN_PROCARGS2;
+#else
mib[1] = KERN_PROCARGS;
+#endif
mib[2] = thispid;
syssize = (size_t)argmax;
CFILES = lastcomm.c
MANPAGES = lastcomm.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
-.\" $NetBSD: lastcomm.1,v 1.7 1997/10/19 03:47:52 lukem Exp $
+.\" $NetBSD: lastcomm.1,v 1.11 2006/12/22 08:00:20 ad Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\" 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
+.\" 3. 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.
.\"
.\"
.\" @(#)lastcomm.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd June 6, 1993
+.Dd December 22, 2006
.Dt LASTCOMM 1
-.Os BSD 3
+.Os
.Sh NAME
.Nm lastcomm
.Nd show last commands executed in reverse order
The elapsed time of the process.
.El
.Pp
-The flags are encoded as follows: ``S'' indicates the command was
-executed by the super-user, ``F'' indicates the command ran after
+The flags are encoded as follows:
+.Dq S
+indicates the command was
+executed by the super-user,
+.Dq F
+indicates the command ran after
a fork, but without a following
-.Xr exec ,
-``C'' indicates the command was run in PDP-11 compatibility mode
+.Xr exec 3 ,
+.Dq C
+indicates the command was run in PDP-11 compatibility mode
(VAX only),
-``D'' indicates the command terminated with the generation of a
+.Dq D
+indicates the command terminated with the generation of a
.Pa core
-file, and ``X'' indicates the command was terminated with a signal.
+file, and
+.Dq X
+indicates the command was terminated with a signal.
.Sh FILES
.Bl -tag -width /var/account/acct -compact
.It Pa /var/account/acct
-/* $NetBSD: lastcomm.c,v 1.14 1998/04/02 10:22:03 kleink Exp $ */
+/* $NetBSD: lastcomm.c,v 1.21 2009/04/12 13:08:31 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
* 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
+ * 3. 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.
*
#include <sys/cdefs.h>
#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993\
+ The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)lastcomm.c 8.2 (Berkeley) 4/29/95";
#endif
-__RCSID("$NetBSD: lastcomm.c,v 1.14 1998/04/02 10:22:03 kleink Exp $");
+__RCSID("$NetBSD: lastcomm.c,v 1.21 2009/04/12 13:08:31 lukem Exp $");
#endif /* not lint */
#include <sys/param.h>
#define UT_LINESIZE 8
#include "pathnames.h"
-time_t expand __P((u_int));
-char *flagbits __P((int));
-char *getdev __P((dev_t));
-int main __P((int, char **));
-int requested __P((char *[], struct acct *));
-void usage __P((void));
+static time_t expand(u_int);
+static char *flagbits(int);
+static const char *getdev(dev_t);
+static int requested(char *[], struct acct *);
+static void usage(void) __dead;
+
+int main(int, char **);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
char *p;
struct acct ab;
time_t t;
double delta;
int ch;
- char *acctfile;
+ const char *acctfile = _PATH_ACCT;
+
+ setprogname(argv[0]);
- acctfile = _PATH_ACCT;
while ((ch = getopt(argc, argv, "f:")) != -1)
switch((char)ch) {
case 'f':
size = sb.st_size - sb.st_size % sizeof(struct acct);
/* Check if any records to display. */
- if (size < sizeof(struct acct))
+ if (size < (off_t)sizeof(struct acct))
exit(0);
/*
} else
for (p = &ab.ac_comm[0];
p < &ab.ac_comm[fldsiz(acct, ac_comm)] && *p; ++p)
- if (!isprint(*p))
+ if (!isprint((unsigned char)*p))
*p = '?';
if (!*argv || requested(argv, &ab)) {
t / (double)AHZ, ctime(&ab.ac_btime));
delta = expand(ab.ac_etime) / (double)AHZ;
printf(" (%1.0f:%02.0f:%05.2f)\n",
- delta / SECSPERHOUR,
- fmod(delta, SECSPERHOUR) / SECSPERMIN,
+ floor(delta / SECSPERHOUR),
+ floor(fmod(delta, SECSPERHOUR) / SECSPERMIN),
fmod(delta, SECSPERMIN));
}
/* are we at the beginning of the file yet? */
exit(0);
}
-time_t
-expand(t)
- u_int t;
+static time_t
+expand(u_int t)
{
time_t nt;
return (nt);
}
-char *
-flagbits(f)
- int f;
+static char *
+flagbits(int f)
{
static char flags[20] = "-";
char *p;
return (flags);
}
-int
-requested(argv, acp)
- char *argv[];
- struct acct *acp;
+static int
+requested(char *argv[], struct acct *acp)
{
do {
if (!strcmp(user_from_uid(acp->ac_uid, 0), *argv))
return (0);
}
-char *
-getdev(dev)
- dev_t dev;
+static const char *
+getdev(dev_t dev)
{
static dev_t lastdev = (dev_t)-1;
- static char *lastname;
+ static const char *lastname;
if (dev == NODEV) /* Special case. */
return ("__");
return (lastname);
}
-void
-usage()
+static void
+usage(void)
{
(void)fprintf(stderr,
- "lastcomm [ -f file ] [command ...] [user ...] [tty ...]\n");
+ "Usage: %s [ -f file ] [command ...] [user ...] [tty ...]\n",
+ getprogname());
exit(1);
}
-/* $NetBSD: pathnames.h,v 1.3 1994/12/22 01:07:05 jtc Exp $ */
+/* $NetBSD: pathnames.h,v 1.4 2003/08/07 11:14:18 agc Exp $ */
/*
* Copyright (c) 1989, 1993
* 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
+ * 3. 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.
*
CFILES = locate.bigram.c
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-I../locate
Extra_LD_Flags = -dead_strip
CFILES = locate.code.c
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-I../locate
Extra_LD_Flags = -dead_strip
concatdb.sh mklocatedb.sh updatedb.sh
LAUNCHD_PLISTS = com.apple.locate.plist
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
$(LN) $(DSTROOT)/usr/share/man/man8/locate.updatedb.8 $(DSTROOT)/usr/share/man/man8/locate.mklocatedb.8
$(INSTALL_DIRECTORY) $(DSTROOT)/private/etc
$(INSTALL_FILE) locate.rc $(DSTROOT)/private/etc
+ plutil -convert binary1 "$(DSTROOT)/System/Library/LaunchDaemons/$(LAUNCHD_PLISTS)"
CFILES = logname.c
MANPAGES = logname.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = machine.c
MANPAGES = machine.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = mktemp.c
MANPAGES = mktemp.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = nice.c
MANPAGES = nice.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = nohup.c
MANPAGES = nohup.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
#include <unistd.h>
#ifdef __APPLE__
+#include <TargetConditionals.h>
#include <vproc.h>
#include <vproc_priv.h>
#endif
(void)signal(SIGHUP, SIG_IGN);
-#ifdef __APPLE__
+#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
if (_vprocmgr_detach_from_console(0) != NULL)
err(EXIT_MISC, "can't detach from console");
#endif
CFILES = path_helper.c
MANPAGES = path_helper.8
-Extra_CC_Flags = -Wall -Werror -mdynamic-no-pic
+Extra_CC_Flags = -Wall -Werror
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = printenv.c
MANPAGES = printenv.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = printf.c
MANPAGES = printf.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = pwd.c
MANPAGES = pwd.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
CFILES = renice.c
MANPAGES = renice.8
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
.El
.Sh SEE ALSO
.Xr nice 1 ,
-.Xr rtprio 1 ,
.Xr getpriority 2 ,
.Xr setpriority 2
.Sh STANDARDS
CFILES = script.c
MANPAGES = script.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
--- /dev/null
+Project = seq
+Install_Dir = /usr/bin
+
+CFILES = seq.c
+MANPAGES = seq.1
+
+Extra_CC_Flags = -Wall -D__FBSDID=__RCSID
+Extra_LD_Flags = -dead_strip
+
+include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
--- /dev/null
+.\" $NetBSD: seq.1,v 1.6 2008/11/26 15:03:47 ginsbach Exp $
+.\"
+.\" Copyright (c) 2005 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Brian Ginsbach.
+.\"
+.\" 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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/usr.bin/seq/seq.1,v 1.1 2010/02/19 23:54:12 delphij Exp $
+.\"
+.Dd February 19, 2010
+.Dt SEQ 1
+.Os
+.Sh NAME
+.Nm seq
+.Nd print sequences of numbers
+.Sh SYNOPSIS
+.Nm
+.Op Fl w
+.Op Fl f Ar format
+.Op Fl s Ar string
+.Op Fl t Ar string
+.Op Ar first Op Ar incr
+.Ar last
+.Sh DESCRIPTION
+The
+.Nm
+utility prints a sequence of numbers, one per line
+.Pq default ,
+from
+.Ar first
+.Pq default 1 ,
+to near
+.Ar last
+as possible, in increments of
+.Ar incr
+.Pq default 1 .
+When
+.Ar first
+is larger than
+.Ar last
+the default
+.Ar incr
+is -1.
+.Pp
+All numbers are interpreted as floating point.
+.Pp
+Normally integer values are printed as decimal integers.
+.Pp
+The
+.Nm
+utility accepts the following options:
+.Bl -tag -width Ar
+.It Fl f Ar format
+Use a
+.Xr printf 3
+style
+.Ar format
+to print each number.
+Only the
+.Cm E ,
+.Cm e ,
+.Cm f ,
+.Cm G ,
+.Cm g ,
+and
+.Cm %
+conversion characters are valid, along with any optional
+flags and an optional numeric minimum field width or precision.
+The
+.Ar format
+can contain character escape sequences in backslash notation as
+defined in
+.St -ansiC .
+The default is
+.Cm %g .
+.It Fl s Ar string
+Use
+.Ar string
+to separate numbers.
+The
+.Ar string
+can contain character escape sequences in backslash notation as
+defined in
+.St -ansiC .
+The default is
+.Cm \en .
+.It Fl t Ar string
+Use
+.Ar string
+to terminate sequence of numbers.
+The
+.Ar string
+can contain character escape sequences in backslash notation as
+defined in
+.St -ansiC .
+This option is useful when the default separator
+does not contain a
+.Cm \en .
+.It Fl w
+Equalize the widths of all numbers by padding with zeros as necessary.
+This option has no effect with the
+.Fl f
+option.
+If any sequence numbers will be printed in exponential notation,
+the default conversion is changed to
+.Cm %e .
+.El
+.Pp
+The
+.Nm
+utility exits 0 on success and non-zero if an error occurs.
+.Sh EXAMPLES
+.Bd -literal -offset indent
+# seq 1 3
+1
+2
+3
+
+# seq 3 1
+3
+2
+1
+
+# seq -w 0 .05 .1
+0.00
+0.05
+0.10
+.Ed
+.Sh SEE ALSO
+.Xr jot 1 ,
+.Xr printf 1 ,
+.Xr printf 3
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Tn "Plan 9 from Bell Labs" .
+A
+.Nm
+command appeared in
+.Nx 3.0 ,
+and ported to
+.Fx 9.0 .
+This command was based on the command of the same name in
+.Tn "Plan 9 from Bell Labs"
+and the
+.Tn GNU
+core utilities.
+The
+.Tn GNU
+.Nm
+command first appeared in the 1.13 shell utilities release.
+.Sh BUGS
+The
+.Fl w
+option does not handle the transition from pure floating point
+to exponent representation very well.
+The
+.Nm
+command is not bug for bug compatible with the
+.Tn "Plan 9 from Bell Labs"
+or
+.Tn GNU
+versions of
+.Nm .
--- /dev/null
+/* $NetBSD: seq.c,v 1.5 2008/07/21 14:19:26 lukem Exp $ */
+/*
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Brian Ginsbach.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/usr.bin/seq/seq.c,v 1.2 2010/02/20 01:23:15 delphij Exp $");
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <math.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define ZERO '0'
+#define SPACE ' '
+
+#define MAX(a, b) (((a) < (b))? (b) : (a))
+#define ISSIGN(c) ((int)(c) == '-' || (int)(c) == '+')
+#define ISEXP(c) ((int)(c) == 'e' || (int)(c) == 'E')
+#define ISODIGIT(c) ((int)(c) >= '0' && (int)(c) <= '7')
+
+/* Globals */
+
+const char *decimal_point = "."; /* default */
+char default_format[] = { "%g" }; /* default */
+
+/* Prototypes */
+
+double e_atof(const char *);
+
+int decimal_places(const char *);
+int main(int, char *[]);
+int numeric(const char *);
+int valid_format(const char *);
+
+char *generate_format(double, double, double, int, char);
+char *unescape(char *);
+
+/*
+ * The seq command will print out a numeric sequence from 1, the default,
+ * to a user specified upper limit by 1. The lower bound and increment
+ * maybe indicated by the user on the command line. The sequence can
+ * be either whole, the default, or decimal numbers.
+ */
+int
+main(int argc, char *argv[])
+{
+ int c = 0, errflg = 0;
+ int equalize = 0;
+ double first = 1.0;
+ double last = 0.0;
+ double incr = 0.0;
+ struct lconv *locale;
+ char *fmt = NULL;
+ const char *sep = "\n";
+ const char *term = NULL;
+ char pad = ZERO;
+
+ /* Determine the locale's decimal point. */
+ locale = localeconv();
+ if (locale && locale->decimal_point && locale->decimal_point[0] != '\0')
+ decimal_point = locale->decimal_point;
+
+ /*
+ * Process options, but handle negative numbers separately
+ * least they trip up getopt(3).
+ */
+ while ((optind < argc) && !numeric(argv[optind]) &&
+ (c = getopt(argc, argv, "f:hs:t:w")) != -1) {
+
+ switch (c) {
+ case 'f': /* format (plan9) */
+ fmt = optarg;
+ equalize = 0;
+ break;
+ case 's': /* separator (GNU) */
+ sep = unescape(optarg);
+ break;
+ case 't': /* terminator (new) */
+ term = unescape(optarg);
+ break;
+ case 'w': /* equal width (plan9) */
+ if (!fmt)
+ if (equalize++)
+ pad = SPACE;
+ break;
+ case 'h': /* help (GNU) */
+ default:
+ errflg++;
+ break;
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+ if (argc < 1 || argc > 3)
+ errflg++;
+
+ if (errflg) {
+ fprintf(stderr,
+ "usage: %s [-w] [-f format] [-s string] [-t string] [first [incr]] last\n",
+ getprogname());
+ exit(1);
+ }
+
+ last = e_atof(argv[argc - 1]);
+
+ if (argc > 1)
+ first = e_atof(argv[0]);
+
+ if (argc > 2) {
+ incr = e_atof(argv[1]);
+ /* Plan 9/GNU don't do zero */
+ if (incr == 0.0)
+ errx(1, "zero %screment", (first < last)? "in" : "de");
+ }
+
+ /* default is one for Plan 9/GNU work alike */
+ if (incr == 0.0)
+ incr = (first < last) ? 1.0 : -1.0;
+
+ if (incr <= 0.0 && first < last)
+ errx(1, "needs positive increment");
+
+ if (incr >= 0.0 && first > last)
+ errx(1, "needs negative decrement");
+
+ if (fmt != NULL) {
+ if (!valid_format(fmt))
+ errx(1, "invalid format string: `%s'", fmt);
+ fmt = unescape(fmt);
+ /*
+ * XXX to be bug for bug compatible with Plan 9 add a
+ * newline if none found at the end of the format string.
+ */
+ } else
+ fmt = generate_format(first, incr, last, equalize, pad);
+
+ if (incr > 0) {
+ for (; first <= last; first += incr) {
+ printf(fmt, first);
+ fputs(sep, stdout);
+ }
+ } else {
+ for (; first >= last; first += incr) {
+ printf(fmt, first);
+ fputs(sep, stdout);
+ }
+ }
+ if (term != NULL)
+ fputs(term, stdout);
+
+ return (0);
+}
+
+/*
+ * numeric - verify that string is numeric
+ */
+int
+numeric(const char *s)
+{
+ int seen_decimal_pt, decimal_pt_len;
+
+ /* skip any sign */
+ if (ISSIGN((unsigned char)*s))
+ s++;
+
+ seen_decimal_pt = 0;
+ decimal_pt_len = strlen(decimal_point);
+ while (*s) {
+ if (!isdigit((unsigned char)*s)) {
+ if (!seen_decimal_pt &&
+ strncmp(s, decimal_point, decimal_pt_len) == 0) {
+ s += decimal_pt_len;
+ seen_decimal_pt = 1;
+ continue;
+ }
+ if (ISEXP((unsigned char)*s)) {
+ s++;
+ if (ISSIGN((unsigned char)*s) ||
+ isdigit((unsigned char)*s)) {
+ s++;
+ continue;
+ }
+ }
+ break;
+ }
+ s++;
+ }
+ return (*s == '\0');
+}
+
+/*
+ * valid_format - validate user specified format string
+ */
+int
+valid_format(const char *fmt)
+{
+ int conversions = 0;
+
+ while (*fmt != '\0') {
+ /* scan for conversions */
+ if (*fmt != '\0' && *fmt != '%') {
+ do {
+ fmt++;
+ } while (*fmt != '\0' && *fmt != '%');
+ }
+ /* scan a conversion */
+ if (*fmt != '\0') {
+ do {
+ fmt++;
+
+ /* ok %% */
+ if (*fmt == '%') {
+ fmt++;
+ break;
+ }
+ /* valid conversions */
+ if (strchr("eEfgG", *fmt) &&
+ conversions++ < 1) {
+ fmt++;
+ break;
+ }
+ /* flags, width and precsision */
+ if (isdigit((unsigned char)*fmt) ||
+ strchr("+- 0#.", *fmt))
+ continue;
+
+ /* oops! bad conversion format! */
+ return (0);
+ } while (*fmt != '\0');
+ }
+ }
+
+ return (conversions <= 1);
+}
+
+/*
+ * unescape - handle C escapes in a string
+ */
+char *
+unescape(char *orig)
+{
+ char c, *cp, *new = orig;
+ int i;
+
+ for (cp = orig; (*orig = *cp); cp++, orig++) {
+ if (*cp != '\\')
+ continue;
+
+ switch (*++cp) {
+ case 'a': /* alert (bell) */
+ *orig = '\a';
+ continue;
+ case 'b': /* backspace */
+ *orig = '\b';
+ continue;
+ case 'e': /* escape */
+ *orig = '\e';
+ continue;
+ case 'f': /* formfeed */
+ *orig = '\f';
+ continue;
+ case 'n': /* newline */
+ *orig = '\n';
+ continue;
+ case 'r': /* carriage return */
+ *orig = '\r';
+ continue;
+ case 't': /* horizontal tab */
+ *orig = '\t';
+ continue;
+ case 'v': /* vertical tab */
+ *orig = '\v';
+ continue;
+ case '\\': /* backslash */
+ *orig = '\\';
+ continue;
+ case '\'': /* single quote */
+ *orig = '\'';
+ continue;
+ case '\"': /* double quote */
+ *orig = '"';
+ continue;
+ case '0':
+ case '1':
+ case '2':
+ case '3': /* octal */
+ case '4':
+ case '5':
+ case '6':
+ case '7': /* number */
+ for (i = 0, c = 0;
+ ISODIGIT((unsigned char)*cp) && i < 3;
+ i++, cp++) {
+ c <<= 3;
+ c |= (*cp - '0');
+ }
+ *orig = c;
+ --cp;
+ continue;
+ case 'x': /* hexidecimal number */
+ cp++; /* skip 'x' */
+ for (i = 0, c = 0;
+ isxdigit((unsigned char)*cp) && i < 2;
+ i++, cp++) {
+ c <<= 4;
+ if (isdigit((unsigned char)*cp))
+ c |= (*cp - '0');
+ else
+ c |= ((toupper((unsigned char)*cp) -
+ 'A') + 10);
+ }
+ *orig = c;
+ --cp;
+ continue;
+ default:
+ --cp;
+ break;
+ }
+ }
+
+ return (new);
+}
+
+/*
+ * e_atof - convert an ASCII string to a double
+ * exit if string is not a valid double, or if converted value would
+ * cause overflow or underflow
+ */
+double
+e_atof(const char *num)
+{
+ char *endp;
+ double dbl;
+
+ errno = 0;
+ dbl = strtod(num, &endp);
+
+ if (errno == ERANGE)
+ /* under or overflow */
+ err(2, "%s", num);
+ else if (*endp != '\0')
+ /* "junk" left in number */
+ errx(2, "invalid floating point argument: %s", num);
+
+ /* zero shall have no sign */
+ if (dbl == -0.0)
+ dbl = 0;
+ return (dbl);
+}
+
+/*
+ * decimal_places - count decimal places in a number (string)
+ */
+int
+decimal_places(const char *number)
+{
+ int places = 0;
+ char *dp;
+
+ /* look for a decimal point */
+ if ((dp = strstr(number, decimal_point))) {
+ dp += strlen(decimal_point);
+
+ while (isdigit((unsigned char)*dp++))
+ places++;
+ }
+ return (places);
+}
+
+/*
+ * generate_format - create a format string
+ *
+ * XXX to be bug for bug compatable with Plan9 and GNU return "%g"
+ * when "%g" prints as "%e" (this way no width adjustments are made)
+ */
+char *
+generate_format(double first, double incr, double last, int equalize, char pad)
+{
+ static char buf[256];
+ char cc = '\0';
+ int precision, width1, width2, places;
+
+ if (equalize == 0)
+ return (default_format);
+
+ /* figure out "last" value printed */
+ if (first > last)
+ last = first - incr * floor((first - last) / incr);
+ else
+ last = first + incr * floor((last - first) / incr);
+
+ sprintf(buf, "%g", incr);
+ if (strchr(buf, 'e'))
+ cc = 'e';
+ precision = decimal_places(buf);
+
+ width1 = sprintf(buf, "%g", first);
+ if (strchr(buf, 'e'))
+ cc = 'e';
+ if ((places = decimal_places(buf)))
+ width1 -= (places + strlen(decimal_point));
+
+ precision = MAX(places, precision);
+
+ width2 = sprintf(buf, "%g", last);
+ if (strchr(buf, 'e'))
+ cc = 'e';
+ if ((places = decimal_places(buf)))
+ width2 -= (places + strlen(decimal_point));
+
+ if (precision) {
+ sprintf(buf, "%%%c%d.%d%c", pad,
+ MAX(width1, width2) + (int) strlen(decimal_point) +
+ precision, precision, (cc) ? cc : 'f');
+ } else {
+ sprintf(buf, "%%%c%d%c", pad, MAX(width1, width2),
+ (cc) ? cc : 'g');
+ }
+
+ return (buf);
+}
CFILES = shlock.c
MANPAGES = shlock.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
-.\" $NetBSD: shlock.1,v 1.2 1997/10/19 23:08:43 lukem Exp $
+.\" $NetBSD: shlock.1,v 1.11 2008/04/30 13:11:01 martin Exp $
+.\"
+.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Erik E. Fair.
+.\"
+.\" 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
.\"
.Dd June 29, 1997
.Dt SHLOCK 1
.Nd create or verify a lock file for shell scripts
.Sh SYNOPSIS
.Nm
+.Op Fl du
+.Op Fl p Ar PID
.Fl f
.Ar lockfile
-.Op Fl p Ar PID
-.Op Fl u
-.Op Fl v
.Sh DESCRIPTION
The
.Nm
will exit with a non-zero exit code.
If invalid,
.Nm
-will remove the lock file, and
+will remove the lock file, and
create a new one.
.Pp
.Nm
uses the
-.Xr rename 2
+.Xr link 2
system call to make the final target lock file, which is an atomic
operation (i.e. "dot locking", so named for this mechanism's original
use for locking system mailboxes).
holds the lock.
.Pp
The
+.Fl d
+option causes
+.Nm
+to be verbose about what it is doing.
+.Pp
+The
.Fl f
argument with
.Ar lockfile
.Nm
to read and write the PID as a binary pid_t, instead of as ASCII,
to be compatible with the locks created by UUCP.
-.Pp
-The
-.Fl v
-option causes
-.Nm
-to be verbose about what it is doing.
-.Sh RETURN VALUES
+.Sh EXIT STATUS
A zero exit code indicates a valid lock file.
.Sh EXAMPLES
.Ss BOURNE SHELL
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.
+The examples assume that the file system where the lock file is to
+be created is writable by the user, and has space available.
.Sh HISTORY
.Nm
was written for the first Network News Transfer Protocol (NNTP)
software distribution, released in March 1986.
The algorithm was suggested by Peter Honeyman,
from work he did on HoneyDanBer UUCP.
-.Sh AUTHOR
-Erik E. Fair <fair@clock.org>
+.Sh AUTHORS
+.An Erik E. Fair Aq fair@clock.org
.Sh BUGS
-Does not work on NFS or other network filesystem on different
+Does not work on NFS or other network file system on different
systems because the disparate systems have disjoint PID spaces.
.Pp
Cannot handle the case where a lock file was not deleted, the
-/* $NetBSD: shlock.c,v 1.3 1998/01/09 08:06:11 perry Exp $ */
+/* $NetBSD: shlock.c,v 1.10 2008/04/28 20:24:14 martin Exp $ */
+
+/*-
+ * Copyright (c) 2006 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Erik E. Fair.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
/*
** Program to produce reliable locks for shell scripts.
** Erik E. Fair <fair@clock.org>, May 20, 1997
*/
+#include <sys/cdefs.h>
+
+#ifndef lint
+__RCSID("$NetBSD: shlock.c,v 1.10 2008/04/28 20:24:14 martin Exp $");
+#endif
+
#include <sys/types.h>
#include <sys/file.h>
#include <fcntl.h> /* Needed on hpux */
int Debug = FALSE;
char *Pname;
-char *USAGE = "%s: USAGE: shlock -f file -p pid [-d][-u]\n";
-char *E_unlk = "%s: unlink(%s): %s\n";
-char *E_open = "%s: open(%s): %s\n";
+const char USAGE[] = "%s: USAGE: %s [-du] [-p PID] -f file\n";
+const char E_unlk[] = "%s: unlink(%s): %s\n";
+const char E_open[] = "%s: open(%s): %s\n";
#define dprintf if (Debug) printf
** (and wasn't that sufficient?)
*/
-#ifdef __STDC__
/* the following is in case you need to make the prototypes go away. */
-#define _P(x) x
-
-char *xtmpfile _P((char *, pid_t, int));
-int p_exists _P((pid_t));
-int cklock _P((char *, int));
-int mklock _P((char *, pid_t, int));
-void bad_usage _P((void));
-int main _P((int, char **));
-#endif /* __STDC__ */
+char *xtmpfile(char *, pid_t, int);
+int p_exists(pid_t);
+int cklock(char *, int);
+int mklock(char *, pid_t, int);
+void bad_usage(void);
+int main(int, char **);
/*
** Create a temporary file, all ready to lock with.
** which might not be in the same filesystem.
*/
char *
-xtmpfile(file, pid, uucpstyle)
-char *file;
-pid_t pid;
-int uucpstyle;
+xtmpfile(char *file, pid_t pid, int uucpstyle)
{
int fd;
int len;
char *cp, buf[BUFSIZ];
static char tempname[BUFSIZ];
- sprintf(buf, "shlock%d", getpid());
+ sprintf(buf, "shlock%ld", (u_long)getpid());
if ((cp = strrchr(strcpy(tempname, file), '/')) != (char *)NULL) {
*++cp = '\0';
(void) strcat(tempname, buf);
(void) strcpy(tempname, buf);
dprintf("%s: temporary filename: %s\n", Pname, tempname);
- sprintf(buf, "%d\n", pid);
+ sprintf(buf, "%ld\n", (u_long)pid);
len = strlen(buf);
openloop:
if ((fd = open(tempname, O_RDWR|O_CREAT|O_EXCL, 0644)) < 0) {
(write(fd, &pid, sizeof(pid)) != sizeof(pid)) :
(write(fd, buf, len) < 0))
{
- fprintf(stderr, "%s: write(%s,%d): %s\n",
- Pname, tempname, pid, strerror(errno));
+ fprintf(stderr, "%s: write(%s,%ld): %s\n",
+ Pname, tempname, (u_long)pid, strerror(errno));
(void) close(fd);
if (unlink(tempname) < 0) {
fprintf(stderr, E_unlk,
** Send null signal to find out.
*/
int
-p_exists(pid)
-pid_t pid;
+p_exists(pid_t pid)
{
- dprintf("%s: process %d is ", Pname, pid);
+ dprintf("%s: process %ld is ", Pname, (u_long)pid);
if (pid <= 0) {
dprintf("invalid\n");
return(FALSE);
**
*/
int
-cklock(file, uucpstyle)
-char *file;
-int uucpstyle;
+cklock(char *file, int uucpstyle)
{
int fd = open(file, O_RDONLY);
ssize_t len;
}
int
-mklock(file, pid, uucpstyle)
-char *file;
-pid_t pid;
-int uucpstyle;
+mklock(char *file, pid_t pid, int uucpstyle)
{
char *tmp;
int retcode = FALSE;
- dprintf("%s: trying lock <%s> for process %d\n", Pname, file, pid);
+ dprintf("%s: trying lock <%s> for process %ld\n", Pname, file,
+ (u_long)pid);
if ((tmp = xtmpfile(file, pid, uucpstyle)) == (char *)NULL)
return(FALSE);
}
void
-bad_usage()
+bad_usage(void)
{
- fprintf(stderr, USAGE, Pname);
+ fprintf(stderr, USAGE, Pname, Pname);
exit(LOCK_FAIL);
}
int
-main(ac, av)
-int ac;
-char *av[];
+main(int ac, char **av)
{
int x;
char *file = (char *)NULL;
}
break;
default:
- fprintf(stderr, USAGE, Pname);
- exit(LOCK_FAIL);
+ bad_usage();
}
}
}
CFILES = sleep.c
MANPAGES = sleep.1
-Extra_CC_Flags = -Wall -Werror -mdynamic-no-pic
+Extra_CC_Flags = -Wall -Werror
Extra_CC_Flags += -D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
CFILES = su.c
MANPAGES = su.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic -D__FBSDID=__RCSID
+Extra_CC_Flags = -Wall -D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip -lpam -lbsm
+Extra_LD_Flags += -framework Security
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/su/su.c,v 1.87 2007/10/18 11:05:30 davidxu Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/su/su.c,v 1.91 2009/12/13 03:14:06 delphij Exp $");
#include <sys/param.h>
#include <sys/time.h>
#include <security/pam_appl.h>
#include <security/openpam.h>
+#ifdef __APPLE__
+#include <Security/AuthSession.h>
+#endif /* __APPLE__ */
+
#define PAM_END() do { \
int local_ret; \
if (pamh != NULL) { \
#endif /* !__APPLE__ */
char *username, *class, shellbuf[MAXPATHLEN];
const char *p, *user, *shell, *mytty, **nargv;
+ const void *v;
struct sigaction sa, sa_int, sa_quit, sa_pipe;
int temp, fds[2];
#ifdef USE_BSM_AUDIT
if (strlen(user) > MAXLOGNAME - 1) {
#ifdef USE_BSM_AUDIT
if (audit_submit(AUE_su, auid,
- 1, EPERM, "username too long: '%s'", user))
+ EPERM, 1, "username too long: '%s'", user))
errx(1, "Permission denied");
#endif
errx(1, "username too long");
pwd = getpwuid(ruid);
if (pwd == NULL) {
#ifdef USE_BSM_AUDIT
- if (audit_submit(AUE_su, auid, 1, EPERM,
+ if (audit_submit(AUE_su, auid, EPERM, 1,
"unable to determine invoking subject: '%s'", username))
errx(1, "Permission denied");
#endif
retcode = pam_authenticate(pamh, 0);
if (retcode != PAM_SUCCESS) {
#ifdef USE_BSM_AUDIT
- if (audit_submit(AUE_su, auid, 1, EPERM, "bad su %s to %s on %s",
+ if (audit_submit(AUE_su, auid, EPERM, 1, "bad su %s to %s on %s",
username, user, mytty))
errx(1, "Permission denied");
#endif
if (audit_submit(AUE_su, auid, 0, 0, "successful authentication"))
errx(1, "Permission denied");
#endif
- retcode = pam_get_item(pamh, PAM_USER, (const void **)&p);
+ retcode = pam_get_item(pamh, PAM_USER, &v);
if (retcode == PAM_SUCCESS)
- user = p;
+ user = v;
else
syslog(LOG_ERR, "pam_get_item(PAM_USER): %s",
pam_strerror(pamh, retcode));
pwd = getpwnam(user);
if (pwd == NULL) {
#ifdef USE_BSM_AUDIT
- if (audit_submit(AUE_su, auid, 1, EPERM,
+ if (audit_submit(AUE_su, auid, EPERM, 1,
"unknown subject: %s", user))
errx(1, "Permission denied");
#endif
aerr = pam_strerror(pamh, retcode);
if (aerr == NULL)
aerr = "Unknown PAM error";
- if (audit_submit(AUE_su, auid, 1, EPERM,
+ if (audit_submit(AUE_su, auid, EPERM, 1,
"pam_chauthtok: %s", aerr))
errx(1, "Permission denied");
#endif
}
if (retcode != PAM_SUCCESS) {
#ifdef USE_BSM_AUDIT
- if (audit_submit(AUE_su, auid, 1, EPERM, "pam_acct_mgmt: %s",
+ if (audit_submit(AUE_su, auid, EPERM, 1, "pam_acct_mgmt: %s",
pam_strerror(pamh, retcode)))
errx(1, "Permission denied");
#endif
else {
if (ruid != 0) {
#ifdef USE_BSM_AUDIT
- if (audit_submit(AUE_su, auid, 1, EPERM,
+ if (audit_submit(AUE_su, auid, EPERM, 1,
"only root may use -c"))
errx(1, "Permission denied");
#endif
err(1, "setusercontext");
#endif /* __APPLE__ */
+#ifdef __APPLE__
+ /* 8530846 */
+ if (asthem) {
+ retcode = SessionCreate(0, 0);
+ if (retcode != noErr) {
+ syslog(LOG_ERR, "SessionCreate: %d", retcode);
+ errx(1, "failed to create session.");
+ }
+ }
+#endif /* __APPLE__ */
+
retcode = pam_setcred(pamh, PAM_ESTABLISH_CRED);
if (retcode != PAM_SUCCESS) {
syslog(LOG_ERR, "pam_setcred: %s",
CFILES = tee.c
MANPAGES = tee.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = test.c
MANPAGES = test.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = time.c
MANPAGES = time.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = true.c
MANPAGES = true.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = uname.c
MANPAGES = uname.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
.Sh SEE ALSO
.Xr hostname 1 ,
.Xr machine 1 ,
+.Xr sw_vers 1 ,
.Xr uname 3
.Sh STANDARDS
The
CFILES = users.c
MANPAGES = users.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
Embedded=$(shell tconf --test TARGET_OS_EMBEDDED)
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-no-cpp-precomp -Wno-error -DHAVE_KVM=0 -DHAVE_UTMPX=1
Extra_LD_Flags = -dead_strip
ifeq ($(Embedded),NO)
CFILES = whereis.c
MANPAGES = whereis.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
.\"
.Dd April 27, 1995
.Dt WHEREIS 1
-.Os BSD 3
+.Os
.Sh NAME
.Nm whereis
.Nd locate programs
.Dq user.cs_path
string.
.Sh SEE ALSO
+.Xr find 1 ,
+.Xr locate 1 ,
+.Xr man 1 ,
+.Xr which 1 ,
.Xr sysctl 8
.Sh COMPATIBILITY
The historic flags and arguments for the
CFILES = which.c
MANPAGES = which.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
CFILES = who.c utmpentry.c
MANPAGES = who.1
-Extra_CC_Flags = -Wall -Werror -mdynamic-no-pic
+Extra_CC_Flags = -Wall -Werror
Extra_CC_Flags += -DSUPPORT_UTMPX -D_UTMPX_COMPAT
Extra_LD_Flags = -dead_strip
CFILES = xargs.c strnsubst.c
MANPAGES = xargs.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Wall \
-D__FBSDID=__RCSID
Extra_LD_Flags = -dead_strip
static int count, insingle, indouble, oflag, pflag, tflag, Rflag, rval, zflag;
static int cnt, Iflag, jfound, Lflag, wasquoted, xflag;
static int curprocs, maxprocs;
+static size_t pad9314053;
static volatile int childerr;
nargs = 5000;
if ((arg_max = sysconf(_SC_ARG_MAX)) == -1)
errx(1, "sysconf(_SC_ARG_MAX) failed");
- nline = arg_max - 4 * 1024;
+ nline = arg_max - MAXPATHLEN; /* for argv[0] from execvp() */
+ pad9314053 = sizeof(char *); /* reserve for string area rounding */
while (*ep != NULL) {
/* 1 byte for each '\0' */
nline -= strlen(*ep++) + 1 + sizeof(*ep);
}
+ nline -= pad9314053;
maxprocs = 1;
while ((ch = getopt(argc, argv, "0E:I:J:L:n:oP:pR:s:tx")) != -1)
switch(ch) {
break;
case 's':
nline = atoi(optarg);
+ pad9314053 = 0; /* assume the -s value is valid */
break;
case 't':
tflag = 1;
* arguments.
*/
if (*argv == NULL)
- cnt = strlen(*bxp++ = echo);
+ cnt = strlen(*bxp++ = echo) + pad9314053;
else {
do {
if (Jflag && strcmp(*argv, replstr) == 0) {
jfound = 1;
argv++;
for (avj = argv; *avj; avj++)
- cnt += strlen(*avj) + 1;
+ cnt += strlen(*avj) + 1 + pad9314053;
break;
}
- cnt += strlen(*bxp++ = *argv) + 1;
+ cnt += strlen(*bxp++ = *argv) + 1 + pad9314053;
} while (*++argv != NULL);
}
* of input lines, as specified by -L is the same as
* maxing out on arguments.
*/
- if (xp == endxp || p > ebp || ch == EOF ||
+ if (xp == endxp || p + (count * pad9314053) > ebp || ch == EOF ||
(Lflag <= count && xflag) || foundeof) {
- if (xflag && xp != endxp && p > ebp)
+ if (xflag && xp != endxp && p + (count * pad9314053) > ebp)
errx(1, "insufficient space for arguments");
if (jfound) {
for (avj = argv; *avj; avj++)
CFILES = yes.c
MANPAGES = yes.1
-Extra_CC_Flags = -Wall -mdynamic-no-pic
+Extra_CC_Flags = -Wall
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make