Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
- Fix for default mtree style
- Update libelf
- Importing libexecinfo
- Resynchronize GCC, mpc, gmp, mpfr
- build.sh: Replace params with show-params.
This has been done as the make target has been renamed in the same
way, while a new target named params has been added. This new
target generates a file containing all the parameters, instead of
printing it on the console.
- Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
get getservbyport() out of the inner loop
Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.73 2012/04/07 16:44:39 christos Exp $
|
||||
# $NetBSD: Makefile,v 1.75 2013/06/20 20:42:30 christos Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/4/93
|
||||
|
||||
USE_SHLIBDIR= yes
|
||||
@@ -11,11 +11,11 @@ WARNS?= 5
|
||||
LIB= util
|
||||
CPPFLAGS+=-DLIBC_SCCS -I${.CURDIR}
|
||||
LINTFLAGS+=-w
|
||||
.if !defined(__MINIX)
|
||||
SRCS+= efun.c getbootfile.c getlabelsector.c getmaxpartitions.c \
|
||||
getfsspecname.c getmntopts.c getrawpartition.c getdiskrawname.c \
|
||||
disklabel_dkcksum.c disklabel_scan.c \
|
||||
if_media.c \
|
||||
SRCS+= efun.c \
|
||||
\
|
||||
getfsspecname.c getmntopts.c \
|
||||
\
|
||||
\
|
||||
login.c loginx.c login_cap.c login_tty.c logout.c logoutx.c \
|
||||
logwtmp.c logwtmpx.c opendisk.c parsedate.y \
|
||||
passwd.c pw_scan.c pidfile.c pidlock.c pty.c \
|
||||
@@ -23,37 +23,16 @@ SRCS+= efun.c getbootfile.c getlabelsector.c getmaxpartitions.c \
|
||||
secure_path.c sockaddr_snprintf.c stat_flags.c \
|
||||
strpct.c ttyaction.c ttymsg.c
|
||||
|
||||
MAN= efun.3 getbootfile.3 getfstypename.3 getlabelsector.3 \
|
||||
getmaxpartitions.3 getmntopts.3 getrawpartition.3 \
|
||||
getdiskrawname.3 getfsspecname.3 \
|
||||
MAN= efun.3 \
|
||||
getmntopts.3 \
|
||||
getfsspecname.3 \
|
||||
login.3 login_cap.3 loginx.3 \
|
||||
disklabel_dkcksum.3 disklabel_scan.3 \
|
||||
opendisk.3 openpty.3 parsedate.3 pidfile.3 pidlock.3 \
|
||||
proc_compare.3 pw_getconf.3 pw_init.3 pw_lock.3 secure_path.3 \
|
||||
pw_getconf.3 pw_init.3 pw_lock.3 secure_path.3 \
|
||||
raise_default_signal.3 \
|
||||
snprintb.3 sockaddr_snprintf.3 stat_flags.3 strpct.3 ttyaction.3 \
|
||||
ttymsg.3 util.3
|
||||
|
||||
.else
|
||||
SRCS+= efun.c \
|
||||
getmntopts.c sockaddr_snprintf.c\
|
||||
login.c loginx.c login_cap.c login_tty.c logout.c logoutx.c \
|
||||
logwtmp.c logwtmpx.c opendisk.c \
|
||||
passwd.c pw_scan.c pidfile.c pidlock.c pty.c \
|
||||
raise_default_signal.c \
|
||||
secure_path.c stat_flags.c \
|
||||
strpct.c ttyaction.c ttymsg.c \
|
||||
|
||||
MAN= efun.3 \
|
||||
getmntopts.3 \
|
||||
login.3 login_cap.3 loginx.3 \
|
||||
opendisk.3 openpty.3 pidfile.3 pidlock.3 \
|
||||
pw_getconf.3 pw_init.3 pw_lock.3 secure_path.3 \
|
||||
raise_default_signal.3 \
|
||||
snprintb.3 stat_flags.3 strpct.3 ttyaction.3 \
|
||||
util.3
|
||||
.endif
|
||||
|
||||
YPREFIX=__pd
|
||||
.PATH: ${NETBSDSRCDIR}/lib/libc/gen
|
||||
|
||||
@@ -74,6 +53,7 @@ MLINKS+=login_cap.3 login_getcapnum.3
|
||||
MLINKS+=login_cap.3 login_getcapsize.3
|
||||
MLINKS+=login_cap.3 login_getcapstr.3
|
||||
MLINKS+=login_cap.3 login_getcaptime.3
|
||||
MLINKS+=login_cap.3 login_getpwclass.3
|
||||
MLINKS+=login_cap.3 login_close.3
|
||||
MLINKS+=login_cap.3 setclasscontext.3
|
||||
MLINKS+=login_cap.3 setusercontext.3
|
||||
@@ -107,9 +87,7 @@ MLINKS+=efun.3 evasprintf.3
|
||||
MLINKS+=stat_flags.3 string_to_flags.3
|
||||
MLINKS+=stat_flags.3 flags_to_string.3
|
||||
MLINKS+=snprintb.3 snprintb_m.3
|
||||
.if !defined(__MINIX)
|
||||
MLINKS+=util.3 libutil.3
|
||||
MLINKS+=strpct.3 strspct.3
|
||||
.endif
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: compat_loginx.c,v 1.2 2009/01/11 02:57:18 christos Exp $ */
|
||||
/* $NetBSD: compat_loginx.c,v 1.3 2012/11/04 13:08:56 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: compat_loginx.c,v 1.2 2009/01/11 02:57:18 christos Exp $");
|
||||
__RCSID("$NetBSD: compat_loginx.c,v 1.3 2012/11/04 13:08:56 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -44,12 +44,10 @@ __RCSID("$NetBSD: compat_loginx.c,v 1.2 2009/01/11 02:57:18 christos Exp $");
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
#include <compat/util.h>
|
||||
#include <utmp.h>
|
||||
#include <compat/include/utmp.h>
|
||||
#include <utmpx.h>
|
||||
#include <compat/include/utmpx.h>
|
||||
#include <util.h>
|
||||
#include <compat/util.h>
|
||||
|
||||
__warn_references(loginx,
|
||||
"warning: reference to compatibility loginx(); include <util.h> to generate correct reference")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: util.h,v 1.2 2009/01/11 02:57:18 christos Exp $ */
|
||||
/* $NetBSD: util.h,v 1.3 2012/11/04 13:08:57 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995
|
||||
@@ -34,10 +34,15 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <compat/include/pwd.h>
|
||||
#include <compat/include/utmp.h>
|
||||
#include <compat/include/utmpx.h>
|
||||
#include <machine/ansi.h>
|
||||
#include <sys/inttypes.h>
|
||||
#include <sys/ansi.h>
|
||||
|
||||
struct utmp50;
|
||||
struct utmpx50;
|
||||
struct passwd50;
|
||||
struct utmp;
|
||||
struct utmpx;
|
||||
struct passwd;
|
||||
|
||||
void login(const struct utmp50 *);
|
||||
void loginx(const struct utmpx50 *);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: efun.c,v 1.6 2008/04/28 20:23:02 martin Exp $ */
|
||||
/* $NetBSD: efun.c,v 1.8 2012/12/30 17:37:13 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifdef __RCSID
|
||||
__RCSID("$NetBSD: efun.c,v 1.6 2008/04/28 20:23:02 martin Exp $");
|
||||
__RCSID("$NetBSD: efun.c,v 1.8 2012/12/30 17:37:13 dholland Exp $");
|
||||
#endif
|
||||
|
||||
#include <err.h>
|
||||
@@ -104,7 +104,7 @@ void *
|
||||
emalloc(size_t n)
|
||||
{
|
||||
void *p = malloc(n);
|
||||
if (p == NULL)
|
||||
if (p == NULL && n != 0)
|
||||
(*efunc)(1, "Cannot allocate %zu bytes", n);
|
||||
return p;
|
||||
}
|
||||
@@ -113,8 +113,8 @@ void *
|
||||
ecalloc(size_t n, size_t s)
|
||||
{
|
||||
void *p = calloc(n, s);
|
||||
if (p == NULL)
|
||||
(*efunc)(1, "Cannot allocate %zu bytes", n);
|
||||
if (p == NULL && n != 0 && s != 0)
|
||||
(*efunc)(1, "Cannot allocate %zu blocks of size %zu", n, s);
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ void *
|
||||
erealloc(void *p, size_t n)
|
||||
{
|
||||
void *q = realloc(p, n);
|
||||
if (q == NULL)
|
||||
if (q == NULL && n != 0)
|
||||
(*efunc)(1, "Cannot re-allocate %zu bytes", n);
|
||||
return q;
|
||||
}
|
||||
|
||||
61
lib/libutil/getbyteorder.3
Normal file
61
lib/libutil/getbyteorder.3
Normal file
@@ -0,0 +1,61 @@
|
||||
.\" $NetBSD: getbyteorder.3,v 1.3 2013/07/22 12:36:57 njoly Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Jason R. Thorpe.
|
||||
.\"
|
||||
.\" 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 May 1, 2013
|
||||
.Dt GETBYTEORDER 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm getbyteorder
|
||||
.Nd get the current byte order
|
||||
.Sh LIBRARY
|
||||
.Lb libutil
|
||||
.Sh SYNOPSIS
|
||||
.In util.h
|
||||
.In sys/endian.h
|
||||
.Ft int
|
||||
.Fn getbyteorder void
|
||||
.Sh DESCRIPTION
|
||||
.Fn getbyteorder
|
||||
returns
|
||||
.Dv LITTLE_ENDIAN ,
|
||||
.Dv BIG_ENDIAN ,
|
||||
or \-1 in case of an error, setting the global
|
||||
.Va errno
|
||||
variable.
|
||||
The possible values for
|
||||
.Va errno
|
||||
are the same as in
|
||||
.Xr sysctl 3 .
|
||||
.Sh SEE ALSO
|
||||
.Xr sysctl 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Fn getbyteorder
|
||||
function call appeared in
|
||||
.Nx 7.0 .
|
||||
54
lib/libutil/getbyteorder.c
Normal file
54
lib/libutil/getbyteorder.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* $NetBSD: getbyteorder.c,v 1.1 2013/05/02 07:17:10 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: getbyteorder.c,v 1.1 2013/05/02 07:17:10 matt Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <util.h>
|
||||
|
||||
int
|
||||
getbyteorder(void)
|
||||
{
|
||||
int byteorder, mib[2];
|
||||
size_t varlen;
|
||||
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_BYTEORDER;
|
||||
varlen = sizeof(byteorder);
|
||||
if (sysctl(mib, 2, &byteorder, &varlen, NULL, (size_t)0) < 0)
|
||||
return (-1);
|
||||
|
||||
return (byteorder);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getfsspecname.c,v 1.3 2012/04/08 20:56:12 christos Exp $ */
|
||||
/* $NetBSD: getfsspecname.c,v 1.4 2013/01/01 18:32:17 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
@@ -29,9 +29,10 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: getfsspecname.c,v 1.3 2012/04/08 20:56:12 christos Exp $");
|
||||
__RCSID("$NetBSD: getfsspecname.c,v 1.4 2013/01/01 18:32:17 dsl Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/disk.h>
|
||||
|
||||
@@ -45,7 +46,9 @@ __RCSID("$NetBSD: getfsspecname.c,v 1.3 2012/04/08 20:56:12 christos Exp $");
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#if !defined(__minix)
|
||||
#define COMPAT_DKWEDGE /* To be removed */
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
const char *
|
||||
getfsspecname(char *buf, size_t bufsiz, const char *name)
|
||||
|
||||
@@ -68,7 +68,3 @@ login(const struct utmp *ut)
|
||||
(void)close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__minix) && defined(__weak_alias)
|
||||
__weak_alias(login, __login50)
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: login_cap.3,v 1.18 2010/05/05 22:05:31 wiz Exp $
|
||||
.\" $NetBSD: login_cap.3,v 1.21 2013/06/23 08:38:41 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1996,1997 Berkeley Software Design, Inc. All rights reserved.
|
||||
.\"
|
||||
@@ -32,7 +32,7 @@
|
||||
.\"
|
||||
.\" BSDI login_cap.3,v 1.4 1997/11/07 16:22:27 jch Exp
|
||||
.\"
|
||||
.Dd October 6, 2007
|
||||
.Dd June 20, 2013
|
||||
.Dt LOGIN_CAP 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -42,6 +42,7 @@
|
||||
.Nm login_getcapsize ,
|
||||
.Nm login_getcapstr ,
|
||||
.Nm login_getcaptime ,
|
||||
.Nm login_getpwclass ,
|
||||
.Nm login_close ,
|
||||
.Nm setclasscontext ,
|
||||
.Nm setusercontext
|
||||
@@ -63,6 +64,8 @@
|
||||
.Fn login_getcapstr "login_cap_t *lc" "const char *cap" "char *def" "char *err"
|
||||
.Ft quad_t
|
||||
.Fn login_getcaptime "login_cap_t *lc" "const char *cap" "quad_t def" "quad_t err"
|
||||
.Ft login_cap_t *
|
||||
.Fn login_getpwclass "struct passwd *pwd"
|
||||
.Ft void
|
||||
.Fn login_close "login_cap_t *lc"
|
||||
.Ft int
|
||||
@@ -96,6 +99,11 @@ structure is no longer needed, it should be freed by the
|
||||
.Fn login_close
|
||||
function.
|
||||
.Pp
|
||||
The
|
||||
.Fn login_getpwclass
|
||||
function is equivalent to:
|
||||
.Dl login_getclass(pwd\ ? pwd->pw_class\ : NULL)
|
||||
.Pp
|
||||
Once
|
||||
.Ar lc
|
||||
has been returned by
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: login_cap.c,v 1.30 2012/04/07 16:16:34 christos Exp $ */
|
||||
/* $NetBSD: login_cap.c,v 1.31 2013/06/29 04:52:55 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995,1997 Berkeley Software Design, Inc. All rights reserved.
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: login_cap.c,v 1.30 2012/04/07 16:16:34 christos Exp $");
|
||||
__RCSID("$NetBSD: login_cap.c,v 1.31 2013/06/29 04:52:55 yamt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -417,11 +417,12 @@ static struct {
|
||||
{ RLIMIT_FSIZE, R_CSIZE, "filesize", },
|
||||
{ RLIMIT_DATA, R_CSIZE, "datasize", },
|
||||
{ RLIMIT_STACK, R_CSIZE, "stacksize", },
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
{ RLIMIT_RSS, R_CSIZE, "memoryuse", },
|
||||
{ RLIMIT_MEMLOCK, R_CSIZE, "memorylocked", },
|
||||
{ RLIMIT_NPROC, R_CNUMB, "maxproc", },
|
||||
#endif
|
||||
{ RLIMIT_NTHR, R_CNUMB, "maxthread", },
|
||||
#endif /* !defined(__minix) */
|
||||
{ RLIMIT_NOFILE, R_CNUMB, "openfiles", },
|
||||
{ RLIMIT_CORE, R_CSIZE, "coredumpsize", },
|
||||
#ifdef RLIMIT_SBSIZE
|
||||
@@ -476,13 +477,13 @@ gsetrl(login_cap_t *lc, int what, const char *name, int type)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (setrlimit(what, &rl)) {
|
||||
syslog(LOG_ERR, "%s: setting resource limit %s: %m",
|
||||
lc->lc_class, name);
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
#undef RCUR
|
||||
#undef RMAX
|
||||
return (0);
|
||||
@@ -697,7 +698,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags)
|
||||
}
|
||||
errno = 0;
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (flags & LOGIN_SETLOGIN)
|
||||
if (setlogin(pwd->pw_name) == -1) {
|
||||
syslog(LOG_ERR, "setlogin(%s) failure: %m",
|
||||
@@ -705,7 +706,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags)
|
||||
login_close(flc);
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
if (flags & LOGIN_SETUSER)
|
||||
if (setuid(uid) == -1) {
|
||||
@@ -993,8 +994,3 @@ multiply(u_quad_t n1, u_quad_t n2)
|
||||
|
||||
return (m);
|
||||
}
|
||||
|
||||
#if defined(__minix) && defined(__weak_alias)
|
||||
__weak_alias(login_getpwclass, __login_getpwclass50)
|
||||
__weak_alias(setusercontext, __setusercontext50)
|
||||
#endif
|
||||
|
||||
@@ -53,10 +53,8 @@ login_tty(int fd)
|
||||
_DIAGASSERT(fd != -1);
|
||||
|
||||
(void) setsid();
|
||||
#ifdef TIOCSCTTY
|
||||
if (ioctl(fd, TIOCSCTTY, NULL) == -1)
|
||||
return (-1);
|
||||
#endif
|
||||
(void) dup2(fd, STDIN_FILENO);
|
||||
(void) dup2(fd, STDOUT_FILENO);
|
||||
(void) dup2(fd, STDERR_FILENO);
|
||||
|
||||
@@ -52,7 +52,3 @@ loginx(const struct utmpx *ut)
|
||||
(void)pututxline(ut);
|
||||
(void)updwtmpx(_PATH_WTMPX, ut);
|
||||
}
|
||||
|
||||
#if defined(__minix) && defined(__weak_alias)
|
||||
__weak_alias(loginx, __loginx50)
|
||||
#endif
|
||||
|
||||
@@ -48,19 +48,19 @@ static int
|
||||
__opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked,
|
||||
int (*ofn)(const char *, int, ...))
|
||||
{
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
int f, rawpart;
|
||||
#else
|
||||
int f;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
#ifdef __minix
|
||||
#if defined(__minix)
|
||||
/*
|
||||
* MINIX does not have the cooked/raw distinction. Do not prepend 'r'
|
||||
* to the device name when generating a full path.
|
||||
*/
|
||||
iscooked = 1;
|
||||
#endif
|
||||
#endif /* defined(__minix) */
|
||||
|
||||
if (buf == NULL) {
|
||||
errno = EFAULT;
|
||||
@@ -73,22 +73,22 @@ __opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked,
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
rawpart = getrawpartition();
|
||||
if (rawpart < 0)
|
||||
return (-1); /* sysctl(3) in getrawpartition sets errno */
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
f = ofn(buf, flags, 0);
|
||||
if (f != -1 || errno != ENOENT)
|
||||
return (f);
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
snprintf(buf, buflen, "%s%c", path, 'a' + rawpart);
|
||||
f = ofn(buf, flags, 0);
|
||||
if (f != -1 || errno != ENOENT)
|
||||
return (f);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
if (strchr(path, '/') != NULL)
|
||||
return (-1);
|
||||
@@ -98,11 +98,11 @@ __opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked,
|
||||
if (f != -1 || errno != ENOENT)
|
||||
return (f);
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
snprintf(buf, buflen, "%s%s%s%c", _PATH_DEV, iscooked ? "" : "r", path,
|
||||
'a' + rawpart);
|
||||
f = ofn(buf, flags, 0);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
return (f);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: parsedate.3,v 1.11 2012/04/06 11:36:04 wiz Exp $
|
||||
.\" $NetBSD: parsedate.3,v 1.12 2013/01/19 15:28:25 apb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -27,7 +27,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd December 20, 2010
|
||||
.Dd January 19, 2013
|
||||
.Dt PARSEDATE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -241,8 +241,20 @@ Tue Apr 20 03:06:49 UTC 1993
|
||||
returns the number of seconds passed since the Epoch, or
|
||||
.Dv \-1
|
||||
if the date could not be parsed properly.
|
||||
A non-error result of
|
||||
.Dv \-1
|
||||
can be distinguished from an error by setting
|
||||
.Va errno
|
||||
to
|
||||
.Dv 0
|
||||
before calling
|
||||
.Fn parsedate ,
|
||||
and checking the value of
|
||||
.Va errno
|
||||
afterwards.
|
||||
.Sh SEE ALSO
|
||||
.Xr date 1 ,
|
||||
.Xr errno 2 ,
|
||||
.Xr eeprom 8
|
||||
.Sh HISTORY
|
||||
The parser used in
|
||||
|
||||
@@ -12,8 +12,14 @@
|
||||
/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */
|
||||
/* SUPPRESS 288 on yyerrlab *//* Label unused */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifdef __RCSID
|
||||
__RCSID("$NetBSD: parsedate.y,v 1.16 2013/06/12 01:46:07 yamt Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <util.h>
|
||||
@@ -148,8 +154,8 @@ cvsstamp: tUNUMBER '.' tUNUMBER '.' tUNUMBER '.' tUNUMBER '.' tUNUMBER '.' tUNUM
|
||||
}
|
||||
;
|
||||
|
||||
epochdate: AT_SIGN tUNUMBER {
|
||||
time_t when = $2;
|
||||
epochdate: AT_SIGN at_number {
|
||||
time_t when = $<Number>2;
|
||||
struct tm tmbuf;
|
||||
if (gmtime_r(&when, &tmbuf) != NULL) {
|
||||
param->yyYear = tmbuf.tm_year + 1900;
|
||||
@@ -173,6 +179,8 @@ epochdate: AT_SIGN tUNUMBER {
|
||||
}
|
||||
;
|
||||
|
||||
at_number : tUNUMBER | tSNUMBER ;
|
||||
|
||||
time : tUNUMBER tMERIDIAN {
|
||||
param->yyHour = $1;
|
||||
param->yyMinutes = 0;
|
||||
@@ -367,7 +375,7 @@ o_merid : /* NULL */ {
|
||||
%%
|
||||
|
||||
/* Month and day table. */
|
||||
static const TABLE const MonthDayTable[] = {
|
||||
static const TABLE MonthDayTable[] = {
|
||||
{ "january", tMONTH, 1 },
|
||||
{ "february", tMONTH, 2 },
|
||||
{ "march", tMONTH, 3 },
|
||||
@@ -396,7 +404,7 @@ static const TABLE const MonthDayTable[] = {
|
||||
};
|
||||
|
||||
/* Time units table. */
|
||||
static const TABLE const UnitsTable[] = {
|
||||
static const TABLE UnitsTable[] = {
|
||||
{ "year", tMONTH_UNIT, 12 },
|
||||
{ "month", tMONTH_UNIT, 1 },
|
||||
{ "fortnight", tMINUTE_UNIT, 14 * 24 * 60 },
|
||||
@@ -411,7 +419,7 @@ static const TABLE const UnitsTable[] = {
|
||||
};
|
||||
|
||||
/* Assorted relative-time words. */
|
||||
static const TABLE const OtherTable[] = {
|
||||
static const TABLE OtherTable[] = {
|
||||
{ "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 },
|
||||
{ "yesterday", tMINUTE_UNIT, -1 * 24 * 60 },
|
||||
{ "today", tMINUTE_UNIT, 0 },
|
||||
@@ -449,7 +457,7 @@ static const TABLE const OtherTable[] = {
|
||||
|
||||
/* The timezone table. */
|
||||
/* Some of these are commented out because a time_t can't store a float. */
|
||||
static const TABLE const TimezoneTable[] = {
|
||||
static const TABLE TimezoneTable[] = {
|
||||
{ "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
|
||||
{ "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */
|
||||
{ "utc", tZONE, HOUR( 0) },
|
||||
@@ -533,7 +541,7 @@ static const TABLE const TimezoneTable[] = {
|
||||
};
|
||||
|
||||
/* Military timezone table. */
|
||||
static const TABLE const MilitaryTable[] = {
|
||||
static const TABLE MilitaryTable[] = {
|
||||
{ "a", tZONE, HOUR( 1) },
|
||||
{ "b", tZONE, HOUR( 2) },
|
||||
{ "c", tZONE, HOUR( 3) },
|
||||
@@ -585,12 +593,13 @@ Convert(
|
||||
time_t Hours, /* Hour of day [0-24] */
|
||||
time_t Minutes, /* Minute of hour [0-59] */
|
||||
time_t Seconds, /* Second of minute [0-60] */
|
||||
time_t Timezone, /* Timezone as seconds west of UTC */
|
||||
time_t Timezone, /* Timezone as minutes east of UTC */
|
||||
MERIDIAN Meridian, /* Hours are am/pm/24 hour clock */
|
||||
DSTMODE DSTmode /* DST on/off/maybe */
|
||||
)
|
||||
{
|
||||
struct tm tm;
|
||||
struct tm tm = {.tm_sec = 0};
|
||||
time_t result;
|
||||
|
||||
/* XXX Y2K */
|
||||
if (Year < 0)
|
||||
@@ -611,9 +620,11 @@ Convert(
|
||||
case DSToff: tm.tm_isdst = 0; break;
|
||||
default: tm.tm_isdst = -1; break;
|
||||
}
|
||||
tm.tm_gmtoff = -Timezone;
|
||||
|
||||
return mktime(&tm);
|
||||
/* We rely on mktime_z(NULL, ...) working in UTC, not in local time. */
|
||||
result = mktime_z(NULL, &tm);
|
||||
result += Timezone * 60;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -880,6 +891,10 @@ parsedate(const char *p, const time_t *now, const int *zone)
|
||||
time_t Start;
|
||||
time_t tod, rm;
|
||||
struct dateinfo param;
|
||||
int saved_errno;
|
||||
|
||||
saved_errno = errno;
|
||||
errno = 0;
|
||||
|
||||
if (now == NULL || zone == NULL) {
|
||||
now = &nowt;
|
||||
@@ -924,14 +939,16 @@ parsedate(const char *p, const time_t *now, const int *zone)
|
||||
param.yyHaveZone = 0;
|
||||
|
||||
if (yyparse(¶m, &p) || param.yyHaveTime > 1 || param.yyHaveZone > 1 ||
|
||||
param.yyHaveDate > 1 || param.yyHaveDay > 1)
|
||||
param.yyHaveDate > 1 || param.yyHaveDay > 1) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (param.yyHaveDate || param.yyHaveTime || param.yyHaveDay) {
|
||||
Start = Convert(param.yyMonth, param.yyDay, param.yyYear, param.yyHour,
|
||||
param.yyMinutes, param.yySeconds, param.yyTimezone,
|
||||
param.yyMeridian, param.yyDSTmode);
|
||||
if (Start == -1)
|
||||
if (Start == -1 && errno != 0)
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
@@ -942,7 +959,7 @@ parsedate(const char *p, const time_t *now, const int *zone)
|
||||
|
||||
Start += param.yyRelSeconds;
|
||||
rm = RelativeMonth(Start, param.yyRelMonth, param.yyTimezone);
|
||||
if (rm == -1)
|
||||
if (rm == -1 && errno != 0)
|
||||
return -1;
|
||||
Start += rm;
|
||||
|
||||
@@ -951,6 +968,8 @@ parsedate(const char *p, const time_t *now, const int *zone)
|
||||
Start += tod;
|
||||
}
|
||||
|
||||
if (errno == 0)
|
||||
errno = saved_errno;
|
||||
return Start;
|
||||
}
|
||||
|
||||
@@ -959,21 +978,21 @@ parsedate(const char *p, const time_t *now, const int *zone)
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
main(ac, av)
|
||||
int ac;
|
||||
char *av[];
|
||||
main(int ac, char *av[])
|
||||
{
|
||||
char buff[128];
|
||||
time_t d;
|
||||
|
||||
(void)printf("Enter date, or blank line to exit.\n\t> ");
|
||||
(void)fflush(stdout);
|
||||
while (gets(buff) && buff[0]) {
|
||||
while (fgets(buff, sizeof(buff), stdin) && buff[0] != '\n') {
|
||||
errno = 0;
|
||||
d = parsedate(buff, NULL, NULL);
|
||||
if (d == -1)
|
||||
(void)printf("Bad format - couldn't convert.\n");
|
||||
if (d == -1 && errno != 0)
|
||||
(void)printf("Bad format - couldn't convert: %s\n",
|
||||
strerror(errno));
|
||||
else
|
||||
(void)printf("%s", ctime(&d));
|
||||
(void)printf("%jd\t%s", (intmax_t)d, ctime(&d));
|
||||
(void)printf("\t> ");
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ pw_cont(int sig)
|
||||
void
|
||||
pw_init(void)
|
||||
{
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
struct rlimit rlim;
|
||||
|
||||
/* Unlimited resource limits. */
|
||||
@@ -221,7 +221,7 @@ pw_init(void)
|
||||
/* Don't drop core (not really necessary, but GP's). */
|
||||
rlim.rlim_cur = rlim.rlim_max = 0;
|
||||
(void)setrlimit(RLIMIT_CORE, &rlim);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
/* Turn off signals. */
|
||||
(void)signal(SIGALRM, SIG_IGN);
|
||||
@@ -661,9 +661,3 @@ pw_getpwconf(char *data, size_t max, const struct passwd *pwd,
|
||||
pw_getconf(data, max, "default", option);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__minix) && defined(__weak_alias)
|
||||
__weak_alias(pw_copy, __pw_copy50)
|
||||
__weak_alias(pw_copyx, __pw_copyx50)
|
||||
__weak_alias(pw_getpwconf, __pw_getpwconf50)
|
||||
#endif
|
||||
|
||||
@@ -77,7 +77,7 @@ openpty(int *amaster, int *aslave, char *name, struct termios *term,
|
||||
/* term may be NULL */
|
||||
/* winp may be NULL */
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if ((master = open("/dev/ptm", O_RDWR)) != -1) {
|
||||
struct ptmget pt;
|
||||
if (ioctl(master, TIOCPTMGET, &pt) != -1) {
|
||||
@@ -89,7 +89,7 @@ openpty(int *amaster, int *aslave, char *name, struct termios *term,
|
||||
}
|
||||
(void)close(master);
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
(void)getgrnam_r("tty", &grs, grbuf, sizeof(grbuf), &grp);
|
||||
if (grp != NULL) {
|
||||
@@ -105,7 +105,11 @@ openpty(int *amaster, int *aslave, char *name, struct termios *term,
|
||||
for (cp = cp2 = TTY_OLD_SUFFIX TTY_NEW_SUFFIX; *cp2; cp2++) {
|
||||
line[5] = 'p';
|
||||
line[9] = *cp2;
|
||||
#ifdef __minix
|
||||
if ((master = open(line, O_RDWR | O_NOCTTY, 0)) == -1) {
|
||||
#else
|
||||
if ((master = open(line, O_RDWR, 0)) == -1) {
|
||||
#endif
|
||||
if (errno != ENOENT)
|
||||
continue; /* busy */
|
||||
if ((size_t)(cp2 - cp + 1) < sizeof(TTY_OLD_SUFFIX))
|
||||
@@ -117,13 +121,17 @@ openpty(int *amaster, int *aslave, char *name, struct termios *term,
|
||||
linep = line;
|
||||
if (chown(line, getuid(), ttygid) == 0 &&
|
||||
chmod(line, mode) == 0 &&
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
revoke(line) == 0 &&
|
||||
#endif /* !defined(__minix) */
|
||||
#ifdef __minix
|
||||
(slave = open(line, O_RDWR | O_NOCTTY, 0)) != -1) {
|
||||
#else
|
||||
(slave = open(line, O_RDWR, 0)) != -1) {
|
||||
#endif
|
||||
(slave = open(line, O_RDWR | O_NOCTTY, 0)) != -1) {
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
gotit:
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
*amaster = master;
|
||||
*aslave = slave;
|
||||
if (name)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# $NetBSD: shlib_version,v 1.51 2012/04/07 16:44:39 christos Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
# MINIX Keep lower than NETBSD until we are ABI compatible
|
||||
major=0
|
||||
minor=0
|
||||
major=7
|
||||
minor=21
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: snprintb.3,v 1.14 2009/05/13 02:50:32 pgoyette Exp $
|
||||
.\" $NetBSD: snprintb.3,v 1.16 2013/08/07 23:22:28 pgoyette Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -225,14 +225,14 @@ total number of bytes.
|
||||
Two examples of the old formatting style:
|
||||
.Bd -literal -offset indent
|
||||
snprintb(buf, buflen, "\e10\e2BITTWO\e1BITONE", 3)
|
||||
\(rA "3\*[Lt]BITTWO,BITONE\*[Gt]"
|
||||
\(rA "03<BITTWO,BITONE>"
|
||||
|
||||
snprintb(buf, buflen,
|
||||
"\e20\ex10NOTBOOT\ex0fFPP\ex0eSDVMA\ex0cVIDEO"
|
||||
"\ex0bLORES\ex0aFPA\ex09DIAG\ex07CACHE"
|
||||
"\ex06IOCACHE\ex05LOOPBACK\ex04DBGCACHE",
|
||||
"\e20\ex10NOTBOOT\ex0f" "FPP\ex0eSDVMA\ex0cVIDEO"
|
||||
"\ex0bLORES\ex0a" "FPA\ex09" "DIAG\ex07" "CACHE"
|
||||
"\ex06IOCACHE\ex05LOOPBACK\ex04" "DBGCACHE",
|
||||
0xe860)
|
||||
\(rA "e860\*[Lt]NOTBOOT,FPP,SDVMA,VIDEO,CACHE,IOCACHE\*[Gt]"
|
||||
\(rA "0xe860<NOTBOOT,FPP,SDVMA,VIDEO,CACHE,IOCACHE>"
|
||||
.Ed
|
||||
.Pp
|
||||
An example of the new formatting style:
|
||||
@@ -242,7 +242,17 @@ snprintb(buf, buflen,
|
||||
"f\ex10\e4BURST\e0=\e4FOUR\e0=\exfSIXTEEN\e0"
|
||||
"b\ex1fMSB\e0\e0",
|
||||
0x800f0701)
|
||||
\(rA "800f0701\*[Lt]LSB,NIBBLE2=0,BURST=f=SIXTEEN,MSB\*[Gt]"
|
||||
\(rA "0x800f0701<LSB,NIBBLE2=0x0,BURST=0xf=SIXTEEN,MSB>"
|
||||
.Ed
|
||||
.Pp
|
||||
An example using snprintb_m:
|
||||
.Bd -literal -offset indent
|
||||
snprintb_m(buf, buflen,
|
||||
"\e177\e020b\e0LSB\e0b\e1_BITONE\e0f\e4\e4NIBBLE2\e0"
|
||||
"f\ex10\e4BURST\e0=\e4FOUR\e0=\exfSIXTEEN\e0"
|
||||
"b\ex1fMSB\e0\e0",
|
||||
0x800f0701, 34)
|
||||
\(rA "0x800f0701<LSB,NIBBLE2=0x0>\e00x800f0701<BURST=0xf=SIXTEEN,MSB>\e0"
|
||||
.Ed
|
||||
.Sh ERRORS
|
||||
.Fn snprintb
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: sockaddr_snprintf.3,v 1.7 2009/04/11 16:13:49 joerg Exp $
|
||||
.\" $NetBSD: sockaddr_snprintf.3,v 1.8 2013/06/07 17:23:26 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -27,7 +27,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd April 9, 2005
|
||||
.Dd June 7, 2013
|
||||
.Dt SOCKADDR_SNPRINTF 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -109,6 +109,10 @@ this is the hostname associated with the address.
|
||||
For all other address families, it is the same as the
|
||||
.Dq a
|
||||
format.
|
||||
.It D
|
||||
Debugging output:
|
||||
For all addresses, print all their fields as
|
||||
.Dq field_name=value .
|
||||
.It f
|
||||
The numeric value of the family of the address is printed.
|
||||
.It l
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sockaddr_snprintf.c,v 1.9 2008/04/28 20:23:03 martin Exp $ */
|
||||
/* $NetBSD: sockaddr_snprintf.c,v 1.10 2013/06/07 17:23:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.9 2008/04/28 20:23:03 martin Exp $");
|
||||
__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.10 2013/06/07 17:23:26 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -38,7 +38,7 @@ __RCSID("$NetBSD: sockaddr_snprintf.c,v 1.9 2008/04/28 20:23:03 martin Exp $");
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
#include <netatalk/at.h>
|
||||
#include <net/if_dl.h>
|
||||
#endif
|
||||
@@ -46,32 +46,96 @@ __RCSID("$NetBSD: sockaddr_snprintf.c,v 1.9 2008/04/28 20:23:03 martin Exp $");
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <util.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#if !defined(__minix)
|
||||
static int
|
||||
debug_at(char *str, size_t len, const struct sockaddr_at *sat)
|
||||
{
|
||||
return snprintf(str, len, "sat_len=%u, sat_family=%u, sat_port=%u, "
|
||||
"sat_addr.s_net=%u, sat_addr.s_node=%u, "
|
||||
"sat_range.r_netrange.nr_phase=%u, "
|
||||
"sat_range.r_netrange.nr_firstnet=%u, "
|
||||
"sat_range.r_netrange.nr_lastnet=%u",
|
||||
sat->sat_len, sat->sat_family, sat->sat_port,
|
||||
sat->sat_addr.s_net, sat->sat_addr.s_node,
|
||||
sat->sat_range.r_netrange.nr_phase,
|
||||
sat->sat_range.r_netrange.nr_firstnet,
|
||||
sat->sat_range.r_netrange.nr_lastnet);
|
||||
}
|
||||
|
||||
static int
|
||||
debug_in(char *str, size_t len, const struct sockaddr_in *sin)
|
||||
{
|
||||
return snprintf(str, len, "sin_len=%u, sin_family=%u, sin_port=%u, "
|
||||
"sin_addr.s_addr=%08x",
|
||||
sin->sin_len, sin->sin_family, sin->sin_port,
|
||||
sin->sin_addr.s_addr);
|
||||
}
|
||||
|
||||
static int
|
||||
debug_in6(char *str, size_t len, const struct sockaddr_in6 *sin6)
|
||||
{
|
||||
const uint8_t *s = sin6->sin6_addr.s6_addr;
|
||||
|
||||
return snprintf(str, len, "sin6_len=%u, sin6_family=%u, sin6_port=%u, "
|
||||
"sin6_flowinfo=%u, "
|
||||
"sin6_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:"
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x, sin6_scope_id=%u",
|
||||
sin6->sin6_len, sin6->sin6_family, sin6->sin6_port,
|
||||
sin6->sin6_flowinfo, s[0x0], s[0x1], s[0x2], s[0x3], s[0x4], s[0x5],
|
||||
s[0x6], s[0x7], s[0x8], s[0x9], s[0xa], s[0xb], s[0xc], s[0xd],
|
||||
s[0xe], s[0xf], sin6->sin6_scope_id);
|
||||
}
|
||||
|
||||
static int
|
||||
debug_un(char *str, size_t len, const struct sockaddr_un *sun)
|
||||
{
|
||||
return snprintf(str, len, "sun_len=%u, sun_family=%u, sun_path=%*s",
|
||||
sun->sun_len, sun->sun_family, (int)sizeof(sun->sun_path),
|
||||
sun->sun_path);
|
||||
}
|
||||
|
||||
static int
|
||||
debug_dl(char *str, size_t len, const struct sockaddr_dl *sdl)
|
||||
{
|
||||
const uint8_t *s = (const void *)sdl->sdl_data;
|
||||
|
||||
return snprintf(str, len, "sdl_len=%u, sdl_family=%u, sdl_index=%u, "
|
||||
"sdl_type=%u, sdl_nlen=%u, sdl_alen=%u, sdl_slen=%u, sdl_data="
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
sdl->sdl_len, sdl->sdl_family, sdl->sdl_index,
|
||||
sdl->sdl_type, sdl->sdl_nlen, sdl->sdl_alen, sdl->sdl_slen,
|
||||
s[0x0], s[0x1], s[0x2], s[0x3], s[0x4], s[0x5],
|
||||
s[0x6], s[0x7], s[0x8], s[0x9], s[0xa], s[0xb]);
|
||||
}
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
int
|
||||
sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
const struct sockaddr * const sa)
|
||||
{
|
||||
const void *a = NULL;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
char abuf[1024], nbuf[1024], *addr = NULL, *w = NULL;
|
||||
#else
|
||||
char abuf[1024], nbuf[1024], *addr = NULL;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
char Abuf[1024], pbuf[32], *name = NULL, *port = NULL;
|
||||
char *ebuf = &sbuf[len - 1], *buf = sbuf;
|
||||
const char *ptr, *s;
|
||||
int p = -1;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
const struct sockaddr_at *sat = NULL;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
const struct sockaddr_in *sin4 = NULL;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
const struct sockaddr_in6 *sin6 = NULL;
|
||||
const struct sockaddr_un *sun = NULL;
|
||||
const struct sockaddr_dl *sdl = NULL;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
int na = 1;
|
||||
|
||||
#define ADDC(c) do { if (buf < ebuf) *buf++ = c; else buf++; } \
|
||||
@@ -84,7 +148,7 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
switch (sa->sa_family) {
|
||||
case AF_UNSPEC:
|
||||
goto done;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
case AF_APPLETALK:
|
||||
sat = ((const struct sockaddr_at *)(const void *)sa);
|
||||
p = ntohs(sat->sat_port);
|
||||
@@ -96,13 +160,13 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
sun = ((const struct sockaddr_un *)(const void *)sa);
|
||||
(void)strlcpy(addr = abuf, sun->sun_path, SUN_LEN(sun));
|
||||
break;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
case AF_INET:
|
||||
sin4 = ((const struct sockaddr_in *)(const void *)sa);
|
||||
p = ntohs(sin4->sin_port);
|
||||
a = &sin4->sin_addr;
|
||||
break;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
case AF_INET6:
|
||||
sin6 = ((const struct sockaddr_in6 *)(const void *)sa);
|
||||
p = ntohs(sin6->sin6_port);
|
||||
@@ -116,7 +180,7 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
addr = w;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
default:
|
||||
errno = EAFNOSUPPORT;
|
||||
return -1;
|
||||
@@ -125,11 +189,11 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
if (addr == abuf)
|
||||
name = addr;
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (a && getnameinfo(sa, (socklen_t)sa->sa_len, addr = abuf,
|
||||
#else
|
||||
if (a && getnameinfo(sa, (socklen_t)len, addr = abuf,
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
(unsigned int)sizeof(abuf), NULL, 0,
|
||||
NI_NUMERICHOST|NI_NUMERICSERV) != 0)
|
||||
return -1;
|
||||
@@ -159,11 +223,11 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
ADDS(nbuf);
|
||||
break;
|
||||
case 'l':
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
(void)snprintf(nbuf, sizeof(nbuf), "%d", sa->sa_len);
|
||||
#else
|
||||
(void)snprintf(nbuf, sizeof(nbuf), "%d", len);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
ADDS(nbuf);
|
||||
break;
|
||||
case 'A':
|
||||
@@ -172,11 +236,11 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
else if (!a)
|
||||
ADDNA();
|
||||
else {
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
getnameinfo(sa, (socklen_t)sa->sa_len,
|
||||
#else
|
||||
getnameinfo(sa, (socklen_t)len,
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
name = Abuf,
|
||||
(unsigned int)sizeof(nbuf), NULL, 0, 0);
|
||||
ADDS(name);
|
||||
@@ -188,17 +252,17 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
else if (p == -1)
|
||||
ADDNA();
|
||||
else {
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
getnameinfo(sa, (socklen_t)sa->sa_len, NULL, 0,
|
||||
#else
|
||||
getnameinfo(sa, (socklen_t)len, NULL, 0,
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
port = pbuf,
|
||||
(unsigned int)sizeof(pbuf), 0);
|
||||
ADDS(port);
|
||||
}
|
||||
break;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
case 'I':
|
||||
if (sdl && addr != abuf) {
|
||||
ADDS(abuf);
|
||||
@@ -238,7 +302,29 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
|
||||
ADDNA();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 'D':
|
||||
switch (sa->sa_family) {
|
||||
case AF_APPLETALK:
|
||||
debug_at(nbuf, sizeof(nbuf), sat);
|
||||
break;
|
||||
case AF_LOCAL:
|
||||
debug_un(nbuf, sizeof(nbuf), sun);
|
||||
break;
|
||||
case AF_INET:
|
||||
debug_in(nbuf, sizeof(nbuf), sin4);
|
||||
break;
|
||||
case AF_INET6:
|
||||
debug_in6(nbuf, sizeof(nbuf), sin6);
|
||||
break;
|
||||
case AF_LINK:
|
||||
debug_dl(nbuf, sizeof(nbuf), sdl);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
ADDS(nbuf);
|
||||
break;
|
||||
#endif /* !defined(__minix) */
|
||||
default:
|
||||
ADDC('%');
|
||||
if (na == 0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: stat_flags.3,v 1.7 2011/08/06 11:28:24 jruoho Exp $
|
||||
.\" $NetBSD: stat_flags.3,v 1.8 2012/09/19 23:22:56 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -27,7 +27,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd August 6, 2011
|
||||
.Dd September 20, 2012
|
||||
.Dt STAT_FLAGS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -41,7 +41,7 @@
|
||||
.Ft char *
|
||||
.Fn flags_to_string "u_long flags" "const char *def"
|
||||
.Ft int
|
||||
.Fn string_to_flags "char **stringp" "u_long *setp" "u_long clrp"
|
||||
.Fn string_to_flags "char **stringp" "u_long *setp" "u_long *clrp"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn flags_to_string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: strpct.3,v 1.4 2012/01/07 18:40:55 christos Exp $
|
||||
.\" $NetBSD: strpct.3,v 1.5 2013/07/20 21:39:57 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -96,4 +96,4 @@ and
|
||||
appeared separately in libutil for
|
||||
.Nx 6.0 .
|
||||
.Sh AUTHORS
|
||||
.An Erik E. Fair Aq fair@netbsd.org
|
||||
.An Erik E. Fair Aq Mt fair@netbsd.org
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: ttymsg.3,v 1.11 2008/04/30 13:10:52 martin Exp $
|
||||
.\" $NetBSD: ttymsg.3,v 1.13 2013/01/16 06:44:27 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -24,7 +24,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd June 29, 1997
|
||||
.Dd January 15, 2013
|
||||
.Dt TTYMSG 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -58,3 +58,11 @@ Various "normal" errors are
|
||||
ignored (exclusive-use, lack of permission, etc.).
|
||||
.Sh SEE ALSO
|
||||
.Xr writev 2
|
||||
.Sh BUGS
|
||||
.Nm
|
||||
could grow some flags and a username/uid who is the expected owner
|
||||
of the tty.
|
||||
If the flags say so then the owner should be checked against the tty
|
||||
owner, and the message should not be sent if there is a mismatch.
|
||||
Also another flag could say check against group writable, and don't
|
||||
send a message.
|
||||
|
||||
Reference in New Issue
Block a user