diff --git a/srcpkgs/musl/files/getconf.1 b/srcpkgs/musl/files/getconf.1 new file mode 100644 index 00000000000..520a688b428 --- /dev/null +++ b/srcpkgs/musl/files/getconf.1 @@ -0,0 +1,94 @@ +.\" $NetBSD: getconf.1,v 1.13 2014/04/13 01:45:34 snj Exp $ +.\" +.\" Copyright (c) 1996 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by J.T. Conklin. +.\" +.\" 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 August 9, 2011 +.Dt GETCONF 1 +.Os +.Sh NAME +.Nm getconf +.Nd get configuration values +.Sh SYNOPSIS +.Nm +.Ar system_var +.Nm +.Fl a +.Nm +.Ar path_var +.Ar pathname +.Nm +.Fl a +.Ar pathname +.Sh DESCRIPTION +The +.Nm +utility writes the current value of a configurable system limit or +option variable to the standard output. +.Pp +The +.Ar system_var +argument specifies the system variable to be queried. +The names of the system variables are from +.Xr sysconf 3 +with the leading +.Dq Li _SC_ +removed. +.Pp +The +.Ar path_var +argument specifies the pathname variable to be queried for the specified +.Ar pathname +argument. +The names of the pathname variables are from +.Xr pathconf 2 +with the leading +.Dq Li _PC_ +removed. +.Pp +When invoked with the option +.Fl a , +.Nm +writes a list of all applicable variables and their values to the +standard output, in the format +.Do +.Va name += +.Va value +.Dc . +.Sh EXIT STATUS +.Ex -std +.Sh SEE ALSO +.Xr pathconf 2 , +.Xr confstr 3 , +.Xr limits 3 , +.Xr sysconf 3 +.Sh STANDARDS +The +.Nm +utility conforms to +.St -p1003.2-92 . diff --git a/srcpkgs/musl/files/getconf.c b/srcpkgs/musl/files/getconf.c new file mode 100644 index 00000000000..c4235242b0e --- /dev/null +++ b/srcpkgs/musl/files/getconf.c @@ -0,0 +1,338 @@ +/*- + * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by J.T. Conklin. + * + * Mostly rewritten to be used in Alpine Linux (with musl c-library) + * by Timo Teräs. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +struct conf_variable { + const char *name; + enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT, UCONSTANT, NUM_TYPES } type; + long value; +}; + +static const struct conf_variable conf_table[] = { +{ "PATH", CONFSTR, _CS_PATH }, + +/* Utility Limit Minimum Values */ +{ "POSIX2_BC_BASE_MAX", CONSTANT, _POSIX2_BC_BASE_MAX }, +{ "POSIX2_BC_DIM_MAX", CONSTANT, _POSIX2_BC_DIM_MAX }, +{ "POSIX2_BC_SCALE_MAX", CONSTANT, _POSIX2_BC_SCALE_MAX }, +{ "POSIX2_BC_STRING_MAX", CONSTANT, _POSIX2_BC_STRING_MAX }, +{ "POSIX2_COLL_WEIGHTS_MAX", CONSTANT, _POSIX2_COLL_WEIGHTS_MAX }, +{ "POSIX2_EXPR_NEST_MAX", CONSTANT, _POSIX2_EXPR_NEST_MAX }, +{ "POSIX2_LINE_MAX", CONSTANT, _POSIX2_LINE_MAX }, +{ "POSIX2_RE_DUP_MAX", CONSTANT, _POSIX2_RE_DUP_MAX }, +{ "POSIX2_VERSION", CONSTANT, _POSIX2_VERSION }, + +/* POSIX.1 Minimum Values */ +{ "_POSIX_AIO_LISTIO_MAX", CONSTANT, _POSIX_AIO_LISTIO_MAX }, +{ "_POSIX_AIO_MAX", CONSTANT, _POSIX_AIO_MAX }, +{ "_POSIX_ARG_MAX", CONSTANT, _POSIX_ARG_MAX }, +{ "_POSIX_CHILD_MAX", CONSTANT, _POSIX_CHILD_MAX }, +{ "_POSIX_LINK_MAX", CONSTANT, _POSIX_LINK_MAX }, +{ "_POSIX_MAX_CANON", CONSTANT, _POSIX_MAX_CANON }, +{ "_POSIX_MAX_INPUT", CONSTANT, _POSIX_MAX_INPUT }, +{ "_POSIX_MQ_OPEN_MAX", CONSTANT, _POSIX_MQ_OPEN_MAX }, +{ "_POSIX_MQ_PRIO_MAX", CONSTANT, _POSIX_MQ_PRIO_MAX }, +{ "_POSIX_NAME_MAX", CONSTANT, _POSIX_NAME_MAX }, +{ "_POSIX_NGROUPS_MAX", CONSTANT, _POSIX_NGROUPS_MAX }, +{ "_POSIX_OPEN_MAX", CONSTANT, _POSIX_OPEN_MAX }, +{ "_POSIX_PATH_MAX", CONSTANT, _POSIX_PATH_MAX }, +{ "_POSIX_PIPE_BUF", CONSTANT, _POSIX_PIPE_BUF }, +{ "_POSIX_SSIZE_MAX", CONSTANT, _POSIX_SSIZE_MAX }, +{ "_POSIX_STREAM_MAX", CONSTANT, _POSIX_STREAM_MAX }, +{ "_POSIX_TZNAME_MAX", CONSTANT, _POSIX_TZNAME_MAX }, + +/* Symbolic Utility Limits */ +{ "BC_BASE_MAX", SYSCONF, _SC_BC_BASE_MAX }, +{ "BC_DIM_MAX", SYSCONF, _SC_BC_DIM_MAX }, +{ "BC_SCALE_MAX", SYSCONF, _SC_BC_SCALE_MAX }, +{ "BC_STRING_MAX", SYSCONF, _SC_BC_STRING_MAX }, +{ "COLL_WEIGHTS_MAX", SYSCONF, _SC_COLL_WEIGHTS_MAX }, +{ "EXPR_NEST_MAX", SYSCONF, _SC_EXPR_NEST_MAX }, +{ "LINE_MAX", SYSCONF, _SC_LINE_MAX }, +{ "RE_DUP_MAX", SYSCONF, _SC_RE_DUP_MAX }, + +/* Optional Facility Configuration Values */ +{ "_POSIX2_C_BIND", SYSCONF, _SC_2_C_BIND }, +{ "POSIX2_C_DEV", SYSCONF, _SC_2_C_DEV }, +{ "POSIX2_CHAR_TERM", SYSCONF, _SC_2_CHAR_TERM }, +{ "POSIX2_FORT_DEV", SYSCONF, _SC_2_FORT_DEV }, +{ "POSIX2_FORT_RUN", SYSCONF, _SC_2_FORT_RUN }, +{ "POSIX2_LOCALEDEF", SYSCONF, _SC_2_LOCALEDEF }, +{ "POSIX2_SW_DEV", SYSCONF, _SC_2_SW_DEV }, +{ "POSIX2_UPE", SYSCONF, _SC_2_UPE }, + +/* POSIX.1 Configurable System Variables */ +{ "AIO_LISTIO_MAX", SYSCONF, _SC_AIO_LISTIO_MAX }, +{ "AIO_MAX", SYSCONF, _SC_AIO_MAX }, +{ "ARG_MAX", SYSCONF, _SC_ARG_MAX }, +{ "CHILD_MAX", SYSCONF, _SC_CHILD_MAX }, +{ "CLK_TCK", SYSCONF, _SC_CLK_TCK }, +{ "MQ_OPEN_MAX", SYSCONF, _SC_MQ_OPEN_MAX }, +{ "MQ_PRIO_MAX", SYSCONF, _SC_MQ_PRIO_MAX }, +{ "NGROUPS_MAX", SYSCONF, _SC_NGROUPS_MAX }, +{ "OPEN_MAX", SYSCONF, _SC_OPEN_MAX }, +{ "STREAM_MAX", SYSCONF, _SC_STREAM_MAX }, +{ "TZNAME_MAX", SYSCONF, _SC_TZNAME_MAX }, +{ "_POSIX_JOB_CONTROL", SYSCONF, _SC_JOB_CONTROL }, +{ "_POSIX_SAVED_IDS", SYSCONF, _SC_SAVED_IDS }, +{ "_POSIX_VERSION", SYSCONF, _SC_VERSION }, + +{ "LINK_MAX", PATHCONF, _PC_LINK_MAX }, +{ "MAX_CANON", PATHCONF, _PC_MAX_CANON }, +{ "MAX_INPUT", PATHCONF, _PC_MAX_INPUT }, +{ "NAME_MAX", PATHCONF, _PC_NAME_MAX }, +{ "PATH_MAX", PATHCONF, _PC_PATH_MAX }, +{ "PIPE_BUF", PATHCONF, _PC_PIPE_BUF }, +{ "_POSIX_CHOWN_RESTRICTED", PATHCONF, _PC_CHOWN_RESTRICTED }, +{ "_POSIX_NO_TRUNC", PATHCONF, _PC_NO_TRUNC }, +{ "_POSIX_VDISABLE", PATHCONF, _PC_VDISABLE }, + +/* POSIX.1b Configurable System Variables */ +{ "PAGESIZE", SYSCONF, _SC_PAGESIZE }, +{ "_POSIX_ASYNCHRONOUS_IO", SYSCONF, _SC_ASYNCHRONOUS_IO }, +{ "_POSIX_FSYNC", SYSCONF, _SC_FSYNC }, +{ "_POSIX_MAPPED_FILES", SYSCONF, _SC_MAPPED_FILES }, +{ "_POSIX_MEMLOCK", SYSCONF, _SC_MEMLOCK }, +{ "_POSIX_MEMLOCK_RANGE", SYSCONF, _SC_MEMLOCK_RANGE }, +{ "_POSIX_MEMORY_PROTECTION", SYSCONF, _SC_MEMORY_PROTECTION }, +{ "_POSIX_MESSAGE_PASSING", SYSCONF, _SC_MESSAGE_PASSING }, +{ "_POSIX_MONOTONIC_CLOCK", SYSCONF, _SC_MONOTONIC_CLOCK }, +{ "_POSIX_PRIORITY_SCHEDULING", SYSCONF, _SC_PRIORITY_SCHEDULING }, +{ "_POSIX_SEMAPHORES", SYSCONF, _SC_SEMAPHORES }, +{ "_POSIX_SHARED_MEMORY_OBJECTS", SYSCONF, _SC_SHARED_MEMORY_OBJECTS }, +{ "_POSIX_SYNCHRONIZED_IO", SYSCONF, _SC_SYNCHRONIZED_IO }, +{ "_POSIX_TIMERS", SYSCONF, _SC_TIMERS }, + +{ "_POSIX_SYNC_IO", PATHCONF, _PC_SYNC_IO }, + +/* POSIX.1c Configurable System Variables */ +{ "LOGIN_NAME_MAX", SYSCONF, _SC_LOGIN_NAME_MAX }, +{ "_POSIX_THREADS", SYSCONF, _SC_THREADS }, + +/* POSIX.1j Configurable System Variables */ +{ "_POSIX_BARRIERS", SYSCONF, _SC_BARRIERS }, +{ "_POSIX_READER_WRITER_LOCKS", SYSCONF, _SC_READER_WRITER_LOCKS }, +{ "_POSIX_SPIN_LOCKS", SYSCONF, _SC_SPIN_LOCKS }, + +/* XPG4.2 Configurable System Variables */ +{ "IOV_MAX", SYSCONF, _SC_IOV_MAX }, +{ "PAGE_SIZE", SYSCONF, _SC_PAGE_SIZE }, +{ "_XOPEN_SHM", SYSCONF, _SC_XOPEN_SHM }, + +/* X/Open CAE Spec. Issue 5 Version 2 Configurable System Variables */ +{ "FILESIZEBITS", PATHCONF, _PC_FILESIZEBITS }, + +/* POSIX.1-2001 XSI Option Group Configurable System Variables */ +{ "ATEXIT_MAX", SYSCONF, _SC_ATEXIT_MAX }, + +/* POSIX.1-2001 TSF Configurable System Variables */ +{ "GETGR_R_SIZE_MAX", SYSCONF, _SC_GETGR_R_SIZE_MAX }, +{ "GETPW_R_SIZE_MAX", SYSCONF, _SC_GETPW_R_SIZE_MAX }, + +/* Commonly provided extensions */ +{ "_PHYS_PAGES", SYSCONF, _SC_PHYS_PAGES }, +{ "_AVPHYS_PAGES", SYSCONF, _SC_AVPHYS_PAGES }, +{ "_NPROCESSORS_CONF", SYSCONF, _SC_NPROCESSORS_CONF }, +{ "_NPROCESSORS_ONLN", SYSCONF, _SC_NPROCESSORS_ONLN }, + +/* Data type related extensions */ +{ "CHAR_BIT", CONSTANT, CHAR_BIT }, +{ "CHAR_MAX", CONSTANT, CHAR_MAX }, +{ "CHAR_MIN", CONSTANT, CHAR_MIN }, +{ "INT_MAX", CONSTANT, INT_MAX }, +{ "INT_MIN", CONSTANT, INT_MIN }, +{ "LONG_BIT", CONSTANT, LONG_BIT }, +{ "LONG_MAX", CONSTANT, LONG_MAX }, +{ "LONG_MIN", CONSTANT, LONG_MIN }, +{ "SCHAR_MAX", CONSTANT, SCHAR_MAX }, +{ "SCHAR_MIN", CONSTANT, SCHAR_MIN }, +{ "SHRT_MAX", CONSTANT, SHRT_MAX }, +{ "SHRT_MIN", CONSTANT, SHRT_MIN }, +{ "SSIZE_MAX", CONSTANT, SSIZE_MAX }, +{ "UCHAR_MAX", UCONSTANT, (long) UCHAR_MAX }, +{ "UINT_MAX", UCONSTANT, (long) UINT_MAX }, +{ "ULONG_MAX", UCONSTANT, (long) ULONG_MAX }, +{ "USHRT_MAX", UCONSTANT, (long) USHRT_MAX }, +{ "WORD_BIT", CONSTANT, WORD_BIT }, + +{ NULL, CONSTANT, 0L } +}; + +static int all = 0; + +static void usage(const char *p) +{ + (void)fprintf(stderr, "Usage: %s system_var\n\t%s -a\n" + "\t%s path_var pathname\n\t%s -a pathname\n", p, p, p, p); + exit(EXIT_FAILURE); +} + +static void print_long(const char *name, long val) +{ + if (all) printf("%s = %ld\n", name, val); + else printf("%ld\n", val); +} + +static void print_ulong(const char *name, unsigned long val) +{ + if (all) printf("%s = %lu\n", name, val); + else printf("%lu\n", val); +} + +static void print_string(const char *name, const char *val) +{ + if (all) printf("%s = %s\n", name, val); + else printf("%s\n", val); +} + +static int print_constant(const struct conf_variable *cp, const char *pathname) +{ + print_long(cp->name, cp->value); + return 0; +} + +static int print_uconstant(const struct conf_variable *cp, const char *pathname) +{ + print_ulong(cp->name, (unsigned long) cp->value); + return 0; +} + +static int print_sysconf(const struct conf_variable *cp, const char *pathname) +{ + long val; + + errno = 0; + if ((val = sysconf((int)cp->value)) == -1) { + if (errno != 0) err(EXIT_FAILURE, "sysconf(%ld)", cp->value); + return -1; + } + print_long(cp->name, val); + return 0; +} + +static int print_confstr(const struct conf_variable *cp, const char *pathname) +{ + size_t len; + char *val; + + errno = 0; + if ((len = confstr((int)cp->value, NULL, 0)) == 0) goto error; + if ((val = malloc(len)) == NULL) err(EXIT_FAILURE, "Can't allocate %zu bytes", len); + errno = 0; + if (confstr((int)cp->value, val, len) == 0) goto error; + print_string(cp->name, val); + free(val); + return 0; +error: + if (errno != EINVAL) err(EXIT_FAILURE, "confstr(%ld)", cp->value); + return -1; +} + +static int print_pathconf(const struct conf_variable *cp, const char *pathname) +{ + long val; + + errno = 0; + if ((val = pathconf(pathname, (int)cp->value)) == -1) { + if (all && errno == EINVAL) return 0; + if (errno != 0) err(EXIT_FAILURE, "pathconf(%s, %ld)", pathname, cp->value); + return -1; + } + print_long(cp->name, val); + return 0; +} + +typedef int (*handler_t)(const struct conf_variable *cp, const char *pathname); +static const handler_t type_handlers[NUM_TYPES] = { + [SYSCONF] = print_sysconf, + [CONFSTR] = print_confstr, + [PATHCONF] = print_pathconf, + [CONSTANT] = print_constant, + [UCONSTANT] = print_uconstant, +}; + +int main(int argc, char **argv) +{ + const char *progname = argv[0]; + const struct conf_variable *cp; + const char *varname, *pathname; + int ch, found = 0; + + (void)setlocale(LC_ALL, ""); + while ((ch = getopt(argc, argv, "a")) != -1) { + switch (ch) { + case 'a': + all = 1; + break; + case '?': + default: + usage(progname); + } + } + argc -= optind; + argv += optind; + + if (!all) { + if (argc == 0) + usage(progname); + varname = argv[0]; + argc--; + argv++; + } else + varname = NULL; + + if (argc > 1) + usage(progname); + pathname = argv[0]; /* may be NULL */ + + for (cp = conf_table; cp->name != NULL; cp++) { + if (!all && strcmp(varname, cp->name) != 0) continue; + if ((cp->type == PATHCONF) == (pathname != NULL)) { + if (type_handlers[cp->type](cp, pathname) < 0) + print_string(cp->name, "undefined"); + found = 1; + } else if (!all) + errx(EXIT_FAILURE, "%s: invalid variable type", cp->name); + } + if (!all && !found) errx(EXIT_FAILURE, "%s: unknown variable", varname); + (void)fflush(stdout); + return ferror(stdout) ? EXIT_FAILURE : EXIT_SUCCESS; +} diff --git a/srcpkgs/musl/files/getent.1 b/srcpkgs/musl/files/getent.1 new file mode 100644 index 00000000000..0e07058e74a --- /dev/null +++ b/srcpkgs/musl/files/getent.1 @@ -0,0 +1,145 @@ +.\" $NetBSD: getent.1,v 1.23 2011/10/11 20:39:40 wiz Exp $ +.\" +.\" Copyright (c) 2004 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Luke Mewburn. +.\" +.\" 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 October 11, 2011 +.Dt GETENT 1 +.Os +.Sh NAME +.Nm getent +.Nd get entries from administrative databases +.Sh SYNOPSIS +.Nm getent +.Ar database +.Op Ar key ... +.Nm getcap +.Ar database +.Op Ar key ... +.Sh DESCRIPTION +The +.Nm +program retrieves and displays entries from the administrative +database specified by +.Ar database , +using the lookup order specified in +.Xr nsswitch.conf 5 . +The display format for a given +.Ar database +is as per the +.Dq traditional +file format for that database. +.Pp +.Ar database +may be one of: +.Bl -column "protocols" "user:passwd:uid:gid:gecos:home_dir:shell" -offset indent -compact +.It Sy Database Ta Sy Display format +.It disktab Ta entry +.It ethers Ta address name +.It gettytab Ta entry +.It group Ta group:passwd:gid:[member[,member]...] +.It hosts Ta address name [alias ...] +.It netgroup Ta (host,user,domain) [...] +.It networks Ta name network [alias ...] +.It passwd Ta user:passwd:uid:gid:gecos:home_dir:shell +.It printcap Ta entry +.It protocols Ta name protocol [alias ...] +.It rpc Ta name number [alias ...] +.It services Ta name port/protocol [alias ...] +.It shells Ta /path/to/shell +.El +.Pp +If one or more +.Ar key +arguments are provided, they will be looked up in +.Ar database +using the appropriate function. +For example, +.Sy passwd +supports a numeric UID or user name; +.Sy hosts +supports an IPv4 address, IPv6 address, or host name; +and +.Sy services +supports a service name, service name/protocol name, numeric port, or +numeric port/protocol name. +.Pp +If no +.Ar key +is provided and +.Ar database +supports enumeration, all entries for +.Ar database +will be retrieved using the appropriate enumeration function and printed. +.Pp +For +.Xr cgetcap 3 +style databases +.Sy ( disktab , +.Sy printcap ) +specifying a key, lists the entry for that key, and specifying more arguments +after the key are used as fields in that key, and only the values of the keys +are returned. +For boolean keys +.Dv true +is returned if the key is found. +If a key is not found, then +.Dv false +is always +returned. +.Sh DIAGNOSTICS +.Nm +exits 0 on success, +1 if there was an error in the command syntax, +2 if one of the specified key names was not found in +.Ar database , +or 3 if there is no support for enumeration on +.Ar database . +.Sh SEE ALSO +.Xr cgetcap 3 , +.Xr disktab 5 , +.Xr ethers 5 , +.Xr gettytab 5 , +.Xr group 5 , +.Xr hosts 5 , +.Xr networks 5 , +.Xr nsswitch.conf 5 , +.Xr passwd 5 , +.Xr printcap 5 , +.Xr protocols 5 , +.Xr rpc 5 , +.Xr services 5 , +.Xr shells 5 +.Sh HISTORY +A +.Nm +command appeared in +.Nx 3.0 . +It was based on the command of the same name in +.Tn Solaris +and +.Tn Linux . diff --git a/srcpkgs/musl/files/getent.c b/srcpkgs/musl/files/getent.c new file mode 100644 index 00000000000..1f97f8f32a6 --- /dev/null +++ b/srcpkgs/musl/files/getent.c @@ -0,0 +1,437 @@ +/*- + * Copyright (c) 2004-2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Luke Mewburn. + * Timo Teräs cleaned up the code for use in Alpine Linux with musl libc. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +enum { + RV_OK = 0, + RV_USAGE = 1, + RV_NOTFOUND = 2, + RV_NOENUM = 3 +}; + +static int usage(const char *); + +static int parsenum(const char *word, unsigned long *result) +{ + unsigned long num; + char *ep; + + if (!isdigit((unsigned char)word[0])) + return 0; + errno = 0; + num = strtoul(word, &ep, 10); + if (num == ULONG_MAX && errno == ERANGE) + return 0; + if (*ep != '\0') + return 0; + *result = num; + return 1; +} + +/* + * printfmtstrings -- + * vprintf(format, ...), + * then the aliases (beginning with prefix, separated by sep), + * then a newline + */ +__attribute__ ((format (printf, 4, 5))) +static void printfmtstrings(char *strings[], const char *prefix, const char *sep, + const char *fmt, ...) +{ + va_list ap; + const char *curpref; + size_t i; + + va_start(ap, fmt); + (void)vprintf(fmt, ap); + va_end(ap); + + curpref = prefix; + for (i = 0; strings[i] != NULL; i++) { + (void)printf("%s%s", curpref, strings[i]); + curpref = sep; + } + (void)printf("\n"); +} + +static int ethers(int argc, char *argv[]) +{ + char hostname[MAXHOSTNAMELEN + 1], *hp; + struct ether_addr ea, *eap; + int i, rv; + + if (argc == 2) { + warnx("Enumeration not supported on ethers"); + return RV_NOENUM; + } + + rv = RV_OK; + for (i = 2; i < argc; i++) { + if ((eap = ether_aton(argv[i])) == NULL) { + eap = &ea; + hp = argv[i]; + if (ether_hostton(hp, eap) != 0) { + rv = RV_NOTFOUND; + break; + } + } else { + hp = hostname; + if (ether_ntohost(hp, eap) != 0) { + rv = RV_NOTFOUND; + break; + } + } + (void)printf("%-17s %s\n", ether_ntoa(eap), hp); + } + return rv; +} + +static void groupprint(const struct group *gr) +{ + printfmtstrings(gr->gr_mem, ":", ",", "%s:%s:%u", + gr->gr_name, gr->gr_passwd, gr->gr_gid); +} + +static int group(int argc, char *argv[]) +{ + struct group *gr; + unsigned long id; + int i, rv; + + rv = RV_OK; + if (argc == 2) { + while ((gr = getgrent()) != NULL) + groupprint(gr); + } else { + for (i = 2; i < argc; i++) { + if (parsenum(argv[i], &id)) + gr = getgrgid((gid_t)id); + else + gr = getgrnam(argv[i]); + if (gr == NULL) { + rv = RV_NOTFOUND; + break; + } + groupprint(gr); + } + } + endgrent(); + return rv; +} + +static void hostsprint(const struct hostent *he) +{ + char buf[INET6_ADDRSTRLEN]; + + if (inet_ntop(he->h_addrtype, he->h_addr, buf, sizeof(buf)) == NULL) + (void)strlcpy(buf, "# unknown", sizeof(buf)); + printfmtstrings(he->h_aliases, " ", " ", "%-16s %s", buf, he->h_name); +} + +static int hosts(int argc, char *argv[]) +{ + struct hostent *he; + char addr[IN6ADDRSZ]; + int i, rv; + + sethostent(1); + rv = RV_OK; + if (argc == 2) { + while ((he = gethostent()) != NULL) + hostsprint(he); + } else { + for (i = 2; i < argc; i++) { + if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0) + he = gethostbyaddr(addr, IN6ADDRSZ, AF_INET6); + else if (inet_pton(AF_INET, argv[i], (void *)addr) > 0) + he = gethostbyaddr(addr, INADDRSZ, AF_INET); + else + he = gethostbyname(argv[i]); + if (he == NULL) { + rv = RV_NOTFOUND; + break; + } + hostsprint(he); + } + } + endhostent(); + return rv; +} + +static void networksprint(const struct netent *ne) +{ + char buf[INET6_ADDRSTRLEN]; + struct in_addr ianet; + + ianet = inet_makeaddr(ne->n_net, 0); + if (inet_ntop(ne->n_addrtype, &ianet, buf, sizeof(buf)) == NULL) + (void)strlcpy(buf, "# unknown", sizeof(buf)); + printfmtstrings(ne->n_aliases, " ", " ", "%-16s %s", ne->n_name, buf); +} + +static int networks(int argc, char *argv[]) +{ + struct netent *ne; + in_addr_t net; + int i, rv; + + setnetent(1); + rv = RV_OK; + if (argc == 2) { + while ((ne = getnetent()) != NULL) + networksprint(ne); + } else { + for (i = 2; i < argc; i++) { + net = inet_network(argv[i]); + if (net != INADDR_NONE) + ne = getnetbyaddr(net, AF_INET); + else + ne = getnetbyname(argv[i]); + if (ne != NULL) { + rv = RV_NOTFOUND; + break; + } + networksprint(ne); + } + } + endnetent(); + return rv; +} + +static void passwdprint(struct passwd *pw) +{ + (void)printf("%s:%s:%u:%u:%s:%s:%s\n", + pw->pw_name, pw->pw_passwd, pw->pw_uid, + pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell); +} + +static int passwd(int argc, char *argv[]) +{ + struct passwd *pw; + unsigned long id; + int i, rv; + + rv = RV_OK; + if (argc == 2) { + while ((pw = getpwent()) != NULL) + passwdprint(pw); + } else { + for (i = 2; i < argc; i++) { + if (parsenum(argv[i], &id)) + pw = getpwuid((uid_t)id); + else + pw = getpwnam(argv[i]); + if (pw == NULL) { + rv = RV_NOTFOUND; + break; + } + passwdprint(pw); + } + } + endpwent(); + return rv; +} + +static void protocolsprint(struct protoent *pe) +{ + printfmtstrings(pe->p_aliases, " ", " ", + "%-16s %5d", pe->p_name, pe->p_proto); +} + +static int protocols(int argc, char *argv[]) +{ + struct protoent *pe; + unsigned long id; + int i, rv; + + setprotoent(1); + rv = RV_OK; + if (argc == 2) { + while ((pe = getprotoent()) != NULL) + protocolsprint(pe); + } else { + for (i = 2; i < argc; i++) { + if (parsenum(argv[i], &id)) + pe = getprotobynumber((int)id); + else + pe = getprotobyname(argv[i]); + if (pe == NULL) { + rv = RV_NOTFOUND; + break; + } + protocolsprint(pe); + } + } + endprotoent(); + return rv; +} + +static void servicesprint(struct servent *se) +{ + printfmtstrings(se->s_aliases, " ", " ", + "%-16s %5d/%s", + se->s_name, ntohs(se->s_port), se->s_proto); + +} + +static int services(int argc, char *argv[]) +{ + struct servent *se; + unsigned long id; + char *proto; + int i, rv; + + setservent(1); + rv = RV_OK; + if (argc == 2) { + while ((se = getservent()) != NULL) + servicesprint(se); + } else { + for (i = 2; i < argc; i++) { + proto = strchr(argv[i], '/'); + if (proto != NULL) + *proto++ = '\0'; + if (parsenum(argv[i], &id)) + se = getservbyport(htons(id), proto); + else + se = getservbyname(argv[i], proto); + if (se == NULL) { + rv = RV_NOTFOUND; + break; + } + servicesprint(se); + } + } + endservent(); + return rv; +} + +static int shells(int argc, char *argv[]) +{ + const char *sh; + int i, rv; + + setusershell(); + rv = RV_OK; + if (argc == 2) { + while ((sh = getusershell()) != NULL) + (void)printf("%s\n", sh); + } else { + for (i = 2; i < argc; i++) { + setusershell(); + while ((sh = getusershell()) != NULL) { + if (strcmp(sh, argv[i]) == 0) { + (void)printf("%s\n", sh); + break; + } + } + if (sh == NULL) { + rv = RV_NOTFOUND; + break; + } + } + } + endusershell(); + return rv; +} + +static struct getentdb { + const char *name; + int (*callback)(int, char *[]); +} databases[] = { + { "ethers", ethers, }, + { "group", group, }, + { "hosts", hosts, }, + { "networks", networks, }, + { "passwd", passwd, }, + { "protocols", protocols, }, + { "services", services, }, + { "shells", shells, }, + + { NULL, NULL, }, +}; + +static int usage(const char *arg0) +{ + struct getentdb *curdb; + size_t i; + + (void)fprintf(stderr, "Usage: %s database [key ...]\n", arg0); + (void)fprintf(stderr, "\tdatabase may be one of:"); + for (i = 0, curdb = databases; curdb->name != NULL; curdb++, i++) { + if (i % 7 == 0) + (void)fputs("\n\t\t", stderr); + (void)fprintf(stderr, "%s%s", i % 7 == 0 ? "" : " ", + curdb->name); + } + (void)fprintf(stderr, "\n"); + exit(RV_USAGE); + /* NOTREACHED */ +} + +int +main(int argc, char *argv[]) +{ + struct getentdb *curdb; + + if (argc < 2) + usage(argv[0]); + for (curdb = databases; curdb->name != NULL; curdb++) + if (strcmp(curdb->name, argv[1]) == 0) + return (*curdb->callback)(argc, argv); + + warn("Unknown database `%s'", argv[1]); + usage(argv[0]); + /* NOTREACHED */ +} diff --git a/srcpkgs/musl/files/ldconfig b/srcpkgs/musl/files/ldconfig new file mode 100644 index 00000000000..ccf7c2aa4d2 --- /dev/null +++ b/srcpkgs/musl/files/ldconfig @@ -0,0 +1,18 @@ +#!/bin/sh +scan_dirs() { + scanelf -qS "$@" | while read SONAME FILE; do + TARGET="${FILE##*/}" + LINK="${FILE%/*}/$SONAME" + case "$FILE" in + /lib/*|/usr/lib/*|/usr/local/lib/*) ;; + *) [ -h "$LINK" -o ! -e "$LINK" ] && ln -sf "$TARGET" "$LINK" + esac + done + return 0 +} +# eat ldconfig options +while getopts "nNvXvf:C:r:" opt; do + : +done +shift $(( $OPTIND - 1 )) +[ $# -gt 0 ] && scan_dirs "$@" diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template index 54f74fe4c50..8238655464d 100644 --- a/srcpkgs/musl/template +++ b/srcpkgs/musl/template @@ -1,7 +1,7 @@ # Template file for 'musl'. pkgname=musl version=1.1.5 -revision=5 +revision=6 build_style=gnu-configure configure_args="--prefix=/usr --disable-gcc-wrapper" conflicts="glibc>=0" @@ -16,14 +16,9 @@ only_for_archs="i686-musl x86_64-musl armv6l-musl armv7l-musl" CFLAGS="-fno-stack-protector" post_build() { - $XBPS_FETCH_CMD http://git.alpinelinux.org/cgit/aports/plain/main/musl/getent.c - $XBPS_FETCH_CMD http://git.alpinelinux.org/cgit/aports/plain/main/musl/getconf.c - $XBPS_FETCH_CMD http://git.alpinelinux.org/cgit/aports/plain/main/musl/ldconfig - - $CC $CFLAGS $LDFLAGS getent.c -o getent - $CC $CFLAGS $LDFLAGS getconf.c -o getconf + $CC $CFLAGS $LDFLAGS ${FILESDIR}/getent.c -o getent + $CC $CFLAGS $LDFLAGS ${FILESDIR}/getconf.c -o getconf } - do_install() { # Move everything to /usr. vmkdir usr/lib @@ -33,7 +28,10 @@ do_install() { # provide ldd vmkdir usr/bin ln -s /usr/lib/libc.so ${DESTDIR}/usr/bin/ldd + # additional utils from Alpine/NetBSD vbin getent + vman ${FILESDIR}/getent.1 vbin getconf - vbin ldconfig + vman ${FILESDIR}/getconf.1 + vbin ${FILESDIR}/ldconfig }