aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2005-02-14* csu/elf-init.c (__libc_csu_fini): Enable if LIBC_NONSHAREDUlrich Drepper5-7/+27
isn't defined. * sysdeps/generic/libc-start.c (LIBC_START_MAIN): Call fini if SHARED isn't defined. * elf/Makefile (tests-static): Add tst-array1-static. ($(objpfx)tst-array1-static.out): New target. * elf/tst-array1-static.c: New file.
2005-02-12* debug/chk_fail.c (__chk_fail): Add a while (1) loop aroundUlrich Drepper3-6/+22
__libc_message to kill GCC warning about noreturn function returning. * elf/rtld.c (dlmain): If LD_TRACE_PRELINKING, clear l_relocated flag before relocating ld.so again. * elf/rtld.c (_dl_start): Set bootstrap_map.l_relocated even for already prelinked ld.so.
2005-02-12(_dl_start): Set bootstrap_map.l_relocated even for already prelinked ld.so.Ulrich Drepper1-1/+1
2005-02-11[BZ #715]cvs/fedora-glibc-20050211T1037Roland McGrath6-7/+56
* Makefile (installed-stubs): New variable. Set to $(inst_includedir)/gnu/stubs.h if $(biarch) is no, or to $(inst_includedir)/gnu/stubs-$(biarch).h if otherwise. [$(biarch) != no] (install-others-nosubdir): Add $(installed-stubs). ($(inst_includedir)/gnu/stubs.h): Use $(installed-stubs) for this rule's target. ($(inst_includedir)/gnu/stubs.h): New target, install from ... * include/stubs-biarch.h: New file. * shlib-versions (i.86-.*-.*): Add WORDSIZE64 line mapping to x86_64. * Makeconfig ($(common-objpfx)soversions.mk): Depend on Makeconfig. Emit defn for variable `biarch'. * include/stub-tag.h: Update comment.
2005-02-11* scripts/soversions.awk: Fix default version set handling.Roland McGrath2-9/+19
2005-02-11[BZ #157]cvs/fedora-glibc-20050211T0853Roland McGrath3-16/+21
* include/libc-symbols.h (stub_warning): Emit a marker section called .gnu.glibc-stub.NAME. * Makerules ($(objpfx)stubs): Depend on object files, not dep files. Use objdump to collect those marker section names. ($(common-objpfx)shlib.lds): Discard .gnu.glibc-stub.* sections.
2005-02-10* Rules (subdir_objs, subdir_stubs): New phony targets.Roland McGrath3-4/+9
* Makefile (+subdir_targets): Add them.
2005-02-10* Makerules ($(common-objpfx)Versions.all): Grok new leading column inRoland McGrath2-2/+6
soversions.i.
2005-02-10* scripts/lib-names.awk: Consider [0-9].* a "number", not just [0-9]+.Roland McGrath2-1/+4
Reported by H.J. Lu <hongjiu.lu@intel.com>.
2005-02-10* scripts/lib-names.awk: Always print WORDSIZE32 section first whenRoland McGrath2-13/+16
doing two.
2005-02-10* sysdeps/powerpc/powerpc32/bits/link.h: Removed.Roland McGrath3-63/+8
* sysdeps/powerpc/powerpc64/bits/link.h: Moved to... * sysdeps/powerpc/bits/link.h: ... here. New file.
2005-02-10[BZ #710]Roland McGrath5-5/+86
2005-02-09 Jakub Jelinek <jakub@redhat.com> [BZ #710] * stdlib/random_r.c (__initstate_r): Save old state. * stdlib/Makefile (tests): Add tst-random2. * stdlib/tst-random2.c: New test. Reported by Peter Bergner <bergner@vnet.ibm.com>. (s390-.*-.*, powerpc.*-.*-.*, sparc.*-.*-.*): Add WORDSIZE64 entries for these mapping back to the above.
2005-02-10* dlfcn/dlfcn.c (init): Put it in .init_array section.Roland McGrath2-3/+13
2005-02-10[BZ #632]Roland McGrath5-40/+150
2005-02-10 Roland McGrath <roland@redhat.com> [BZ #632] * scripts/soversions.awk: Expect cpu, vendor, os as separate variables from command line. Grok shlib-versions lines with WORDSIZE* in second column. Add new leading column to output, DEFAULT for existing output lines. Also emit lines with WORDSIZE* for alternate configurations. * Makeconfig ($(common-objpfx)soversions.i): Pass those variables. ($(common-objpfx)soversions.mk): Grok new column, use only DEFAULT. ($(common-objpfx)gnu/lib-names.stmp): Depend on soversions.i instead of soversions.mk; replace inline shell script with use of ... * scripts/lib-names.awk: New file. If input has non-DEFAULT lines, emit multiple sets of macros under #if. * shlib-versions (x86_64-.*-.*): Add WORDSIZE32 line mapping to i686. (s390x-.*-.*): Likewise for s390. (powerpc64-.*-.*): Likewise for powerpc. (sparc64-.*-.*): Likewise for sparc.
2005-02-10* descr.h (__pthread_find_self, thread_self): Mark as pureRoland McGrath1-0/+5
instead of const.
2005-02-102005-02-09 Daniel Jacobowitz <dan@codesourcery.com>Roland McGrath1-2/+2
* descr.h (__pthread_find_self, thread_self): Mark as pure instead of const.
2005-02-08* elf/dl-load.c (_dl_map_object_from_fd): Fix a typo.cvs/fedora-glibc-20050208T2213Ulrich Drepper1-0/+4
2005-02-08(_dl_map_object_from_fd): Fix a typo.Ulrich Drepper1-1/+1
2005-02-08*** empty log message ***Andreas Schwab1-0/+5
2005-02-08 Andreas Schwab <schwab@suse.de> * sysdeps/m68k/dl-machine.h (elf_machine_rela): Remove use of RESOLVE.
2005-02-08(elf_machine_rela): Remove use of RESOLVE.Andreas Schwab1-7/+0
2005-02-08Really remove it.Ulrich Drepper1-0/+0
2005-02-08* iconvdata/jis0208.h (struct jisx0208_ucs_idx): Move before use.cvs/fedora-glibc-20050208T0948Ulrich Drepper4-12/+21
2005-02-08* sysdeps/sh/dl-machine.h (elf_machine_rela): Remove code usingUlrich Drepper4-12/+39
RESOLVE. 2005-02-07 Ulrich Drepper <drepper@redhat.com> * elf/dl-load.c (_dl_map_object_from_fd): Makre sure registers are set correctly. * sysdeps/unix/sysv/linux/i386/sysdep.h (check_consistency): Define.
2005-02-08(check_consistency): Define.Ulrich Drepper1-0/+23
2005-02-08 * math/math_private.h (__copysign): Define as builtin for gcc 4. ↵Richard Henderson3-12/+29
(__copysignf, __copysignl): Likewise. * sysdeps/alpha/fpu/bits/mathinline.h (copysign): Don't define for gcc 4.0. (copysignf, copysignl, fabsf, fabs): Likewise. (__copysign, __copysignf, __copysignl): Remove. (__fabs, __fabsf): Remove. 2005-01-07 Richard Henderson <rth@redhat.com> * math/math_private.h (__copysign): Define as builtin for gcc 4. (__copysignf, __copysignl): Likewise. * sysdeps/alpha/fpu/bits/mathinline.h (copysign): Don't define for gcc 4.0. (copysignf, copysignl, fabsf, fabs): Likewise. (__copysign, __copysignf, __copysignl): Remove. (__fabs, __fabsf): Remove.
2005-02-07* elf/dl-load.c (open_path): If rtld_search_dirs is in RELRO segment,Ulrich Drepper2-7/+15
avoid writing to it if none of the standard search directories exist.
2005-02-07[BZ #700]Ulrich Drepper3-10/+19
2005-02-07 Steven Munroe <sjmunroe@us.ibm.com> [BZ #700] * sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S (__novec_setcontext, __setcontext): Fix typo so CCR is restored. Load MSR as a doubleword. * sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S (__novec_swapcontext, __swapcontext): Likewise.
2005-02-07* iconv/iconv_prog.c (main): Provide more help in case on an error.Ulrich Drepper2-4/+12
2005-02-07[BZ #677]Ulrich Drepper9-21/+103
* nscd/nscd.c (termination_handler): Avoid segfault if some database is not enabled. * nscd/nscd_getai.c (__nscd_getai): If ai_resp->found == -1, set __nss_not_use_nscd_hosts and return -1. * nscd/nscd_initgroups.c (__nscd_getgrouplist): If initgr_resp->found == -1, set __nss_not_use_nscd_group and return -1. Avoid leaking sockets. 2005-01-28 Andreas Schwab <schwab@suse.de> H.J. Lu <hongjiu.lu@intel.com> [BZ #677] * elf/dl-runtime.c (fixup): Change return type to DL_FIXUP_VALUE_TYPE. Use DL_FIXUP_VALUE_TYPE, DL_FIXUP_MAKE_VALUE and DL_FIXUP_VALUE_CODE_ADDR for relocation values. Use DL_FIXUP_VALUE_ADDR and DL_FIXUP_ADDR_VALUE to store and retrieve relocation values. (profile_fixup): Likewise. * include/link.h (link_map): Use DL_FIXUP_VALUE_TYPE for l_reloc_result. * sysdeps/generic/dl-fptr.h (link_map): Forward declaration. * sysdeps/generic/dl-lookupcfg.h (DL_FIXUP_VALUE_TYPE): New. (DL_FIXUP_MAKE_VALUE): Likewise. (DL_FIXUP_VALUE_CODE_ADDR): Likewise. (DL_FIXUP_VALUE_ADDR): Likewise. (DL_FIXUP_ADDR_VALUE): Likewise. * sysdeps/ia64/dl-lookupcfg.h: Include <dl-fptr.h> for "struct fdesc". (DL_FIXUP_VALUE_TYPE): New. (DL_FIXUP_MAKE_VALUE): Likewise. (DL_FIXUP_VALUE_CODE_ADDR): Likewise. (DL_FIXUP_VALUE_ADDR): Likewise. (DL_FIXUP_ADDR_VALUE): Likewise. * sysdeps/ia64/dl-machine.h (elf_machine_profile_fixup_plt): Removed. (elf_machine_profile_plt): Removed. (elf_machine_fixup_plt): Change return type and type of value parameter to struct fdesc. (elf_machine_plt_value): Likewise. (elf_machine_rela): Use DL_FIXUP_MAKE_VALUE to construct argument for elf_machine_fixup_plt. 2005-02-07 Jakub Jelinek <jakub@redhat.com>
2005-02-07(fixup): Change return type to DL_FIXUP_VALUE_TYPE. Use DL_FIXUP_VALUE_TYPE, ↵Ulrich Drepper1-17/+21
DL_FIXUP_MAKE_VALUE and DL_FIXUP_VALUE_CODE_ADDR for relocation values. Use DL_FIXUP_VALUE_ADDR and DL_FIXUP_ADDR_VALUE to store and retrieve relocation values. (profile_fixup): Likewise.
2005-02-07* nscd/nscd.init (reload): Print Reloading nscd: before and a newlineRoland McGrath6-10/+148
after the status string printed by killproc.
2005-02-07* manual/.cvsignore: Add dir-add.texi.Roland McGrath1-0/+4
2005-02-072004-11-18 Alexandre Oliva <aoliva@redhat.com>Roland McGrath1-1/+1
* manual/.cvsignore: Add dir-add.texi.
2005-02-07 * sysdeps/alpha/dl-machine.h (elf_machine_rela): Use RESOLVE_MAP ↵Richard Henderson2-12/+7
all the time. 2005-02-06 Richard Henderson <rth@redhat.com> * sysdeps/alpha/dl-machine.h (elf_machine_rela): Use RESOLVE_MAP all the time.
2005-02-06* configure.in (sysnames): Append sysdeps/generic for each add-on.Roland McGrath5-2/+28
* configure: Regenerated.
2005-02-02* sysdeps/mach/hurd/tls.h: Include <stdbool.h>Roland McGrath5-5/+27
(dtv_t): Change pointer type to be a struct which also contains information whether the memory pointed to is static TLS or not. * sysdeps/generic/syslog.c (send_flags) [!send_flags]: Define it. * shadow/sgetspent_r.c (FALSE): Macro renamed to ... (FALSEP): ... this. Updated all references. * libio/fmemopen.c: Include <stdint.h>.
2005-02-02Fix typosRoland McGrath1-11/+11
* sysdeps/arm/bits/linkmap.h: ...this. * sysdeps/i386/bits/link.h: Renamed to... * sysdeps/i386/bits/linkmap.h: ...this. * sysdeps/ia64/bits/link.h: Renamed to... * sysdeps/ia64/bits/linkmap.h: ...this. * sysdeps/s390/bits/link.h: Renamed to... * sysdeps/s390/bits/linkmap.h: ...this. * sysdeps/sh/bits/link.h: Renamed to... * sysdeps/sh/bits/linkmap.h: ...this. * sysdeps/x86_64/bits/link.h: Renamed to... * sysdeps/x86_64/bits/linkmap.h: ...this.
2005-01-30Update.Ulrich Drepper3-4/+15
2005-01-30 Ulrich Drepper <drepper@redhat.com> * nscd/nscd_helper.c (get_mapping): Use MSG_NOSIGNAL if available. * nscd/connections.c (send_ro_fd): Likewise.
2005-01-29Update.Ulrich Drepper6-54/+456
2005-01-28 H.J. Lu <hongjiu.lu@intel.com> * elf/tst-auditmod1.c: Add ia64 entries. * sysdeps/generic/ldsodefs.h (La_ia64_regs): New. (La_ia64_retval): New. (audit_ifaces): Add ia64 entries. * sysdeps/ia64/bits/link.h: New file. * sysdeps/ia64/dl-machine.h (elf_machine_runtime_setup): Test for dl_profile non-null. (ARCH_LA_PLTENTER): New. (ARCH_LA_PLTEXIT): New. * sysdeps/ia64/dl-trampoline.S (_dl_runtime_resolve): Allocate only 2 output registers. Allocate stack to save/restore 8 incoming fp registers. Call _dl_fixup instead of fixup. (_dl_runtime_profile): Rewrite.
2005-01-29Update.Ulrich Drepper7-257/+338
* sysdeps/s390/bits/link.h: New file. * sysdeps/s390/s390-32/dl-trampoline.S: New file. * sysdeps/s390/s390-64/dl-trampoline.S: New file. * sysdeps/s390/s390-32/dl-machine.h: Move PLT trampolines to dl-trampoline.S. Use RESOLVE_MAP instead of RESOLVE to protect relocation code. (elf_machine_runtime_setup): Test for dl_profile non-null. (elf_machine_rela): Remove code using RESOLVE. (ARCH_LA_PLTENTER, ARCH_LA_PLTEXIT): New. * sysdeps/s390/s390-64/dl-machine.h: Likewise. * sysdeps/generic/ldsodefs.h (La_s390_32_regs, La_s390_32_retval, La_s390_64_regs, La_s390_64_retval): New. * elf/tst-auditmod1.c: Add s390 entries.
2005-01-29Dynamic linker definitions for s390.Ulrich Drepper1-0/+111
2005-01-28* sysdeps/s390/bits/string.h (strlen, strncpy, strcat, strncat,Roland McGrath1-0/+5
strncat, memchr, strcmp): Add missing memory clobber.
2005-01-282005-01-28 Martin Schwidefsky <schwidefsky@de.ibm.com>Roland McGrath1-7/+7
* sysdeps/s390/bits/string.h (strlen, strncpy, strcat, strncat, strncat, memchr, strcmp): Add missing memory clobber.
2005-01-27Update.Ulrich Drepper2-1/+7
2005-01-27 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/alpha/oldglob.c (__old_globfree): Also copy gl_offs. Patch by Sergey Tikhonov <tsv@solvo.ru>.
2005-01-27(Writing a User Entry): Document behavior of putpwent if user name starts ↵Ulrich Drepper1-0/+3
with + or -.
2005-01-272005-01-25 Roland McGrath <roland@redhat.com>Roland McGrath1-0/+2
* sysdeps/generic/syslog.c [NO_SIGPIPE]: Protect sigpipe_handler decl.
2005-01-27[BZ #558]Ulrich Drepper4-33/+70
Update. 2005-01-27 Paolo Bonzini <bonzini@gnu.org> [BZ #558] * posix/regcomp.c (calc_inveclosure): Return reg_errcode_t. Initialize the node sets in dfa->inveclosures. (analyze): Initialize inveclosures only if it is needed. Check errors from calc_inveclosure. * posix/regex_internal.c (re_dfa_add_node): Do not initialize the inveclosure node set. * posix/regexec.c (re_search_internal): If nmatch includes unused subexpressions, reset them to { rm_so: -1, rm_eo: -1 } here. * posix/regcomp.c (parse_bracket_exp) [!RE_ENABLE_I18N]: Do build a SIMPLE_BRACKET token. * posix/regexec.c (transit_state_mb): Do not examine nodes where ACCEPT_MB is not set.
2005-01-27Update.Ulrich Drepper4-0/+9
2005-01-27 Jakub Jelinek <jakub@redhat.com> * stdlib/tst-fmtmsg.c: Include stdlib.h. * stdio-common/tst-fmemopen2.c: Include string.h. * posix/execvp.c: Include stdbool.h.
2005-01-26[BZ #605, BZ #611]Ulrich Drepper5-537/+554
Update. 2004-12-13 Paolo Bonzini <bonzini@gnu.org> Separate parsing and creation of the NFA. Avoided recursion on the (very unbalanced) parse tree. [BZ #611] * posix/regcomp.c (struct subexp_optimize, analyze_tree, calc_epsdest, re_dfa_add_tree_node, mark_opt_subexp_iter): Removed. (optimize_subexps, duplicate_tree, calc_first, calc_next, mark_opt_subexp): Rewritten. (preorder, postorder, lower_subexps, lower_subexp, link_nfa_nodes, create_token_tree, free_tree, free_token): New. (analyze): Accept a regex_t *. Invoke the passes via the preorder and postorder generic visitors. Do not initialize the fields in the re_dfa_t that represent the transitions. (free_dfa_content): Use free_token. (re_compile_internal): Analyze before UTF-8 optimizations. Do not include optimization of subexpressions. (create_initial_state): Fetch the DFA node index from the first node's bin_tree_t *. (optimize_utf8): Abort on unexpected nodes, including OP_DUP_QUESTION. Return on COMPLEX_BRACKET. (duplicate_node_closure): Fix comment. (duplicate_node): Do not initialize the fields in the re_dfa_t that represent the transitions. (calc_eclosure, calc_inveclosure): Do not handle OP_DELETED_SUBEXP. (create_tree): Remove final argument. All callers adjusted. Rewritten to use create_token_tree. (parse_reg_exp, parse_branch, parse_expression, parse_bracket_exp, build_charclass_op): Use create_tree or create_token_tree instead of re_dfa_add_tree_node. (parse_dup_op): Likewise. Also free the tree using free_tree for "<re>{0}", and lower OP_DUP_QUESTION to OP_ALT: "a?" is equivalent to "a|". Adjust invocation of mark_opt_subexp. (parse_sub_exp): Create a single SUBEXP node. * posix/regex_internal.c (re_dfa_add_node): Remove last parameter, always perform as if it was 1. Do not initialize OPT_SUBEXP and DUPLICATED, and initialize the DFA fields representing the transitions. * posix/regex_internal.h (re_dfa_add_node): Adjust prototype. (re_token_type_t): Move OP_DUP_PLUS and OP_DUP_QUESTION to the tokens section. Add a tree-only code SUBEXP. Remove OP_DELETED_SUBEXP. (bin_tree_t): Include a full re_token_t for TOKEN. Turn FIRST and NEXT into pointers to trees. Remove ECLOSURE. 2004-12-28 Paolo Bonzini <bonzini@gnu.org > [BZ #605] * posix/regcomp.c (parse_bracket_exp): Do not modify DFA nodes that were already created. * posix/regex_internal.c (re_dfa_add_node): Set accept_mb field in the token if needed. (create_ci_newstate, create_cd_newstate): Set accept_mb field from the tokens' field. * posix/regex_internal.h (re_token_t): Add accept_mb field. (ACCEPT_MB_NODE): Removed. * posix/regexec.c (proceed_next_node, transit_states_mb, build_sifted_states, check_arrival_add_next_nodes): Use accept_mb instead of ACCEPT_MB_NODE.
2005-01-26Update.Ulrich Drepper2-3/+7
* debug/chk_fail.c (__chk_fail): Print program name in final message.
t entries from administrative database."); /* Prototype for option handler. */ static error_t parse_option (int key, char *arg, struct argp_state *state); /* Function to print some extra text in the help message. */ static char *more_help (int key, const char *text, void *input); /* Data structure to communicate with argp functions. */ static struct argp argp = { args_options, parse_option, args_doc, doc, NULL, more_help }; /* Additional getaddrinfo flags for IDN encoding. */ static int idn_flags = AI_IDN | AI_CANONIDN; /* Print the version information. */ static void print_version (FILE *stream, struct argp_state *state) { fprintf (stream, "getent %s%s\n", PKGVERSION, VERSION); fprintf (stream, gettext ("\ Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "), "2019"); fprintf (stream, gettext ("Written by %s.\n"), "Thorsten Kukuk"); } /* This is for aliases */ static void print_aliases (struct aliasent *alias) { unsigned int i = 0; printf ("%s: ", alias->alias_name); for (i = strlen (alias->alias_name); i < 14; ++i) fputs_unlocked (" ", stdout); for (i = 0; i < alias->alias_members_len; ++i) printf ("%s%s", alias->alias_members [i], i + 1 == alias->alias_members_len ? "\n" : ", "); } static int aliases_keys (int number, char *key[]) { int result = 0; int i; struct aliasent *alias; if (number == 0) { setaliasent (); while ((alias = getaliasent ()) != NULL) print_aliases (alias); endaliasent (); return result; } for (i = 0; i < number; ++i) { alias = getaliasbyname (key[i]); if (alias == NULL) result = 2; else print_aliases (alias); } return result; } /* This is for ethers */ static int ethers_keys (int number, char *key[]) { int result = 0; int i; if (number == 0) { fprintf (stderr, _("Enumeration not supported on %s\n"), "ethers"); return 3; } for (i = 0; i < number; ++i) { struct ether_addr *ethp, eth; char buffer [1024], *p; ethp = ether_aton (key[i]); if (ethp != NULL) { if (ether_ntohost (buffer, ethp)) { result = 2; continue; } p = buffer; } else { if (ether_hostton (key[i], &eth)) { result = 2; continue; } p = key[i]; ethp = &eth; } printf ("%s %s\n", ether_ntoa (ethp), p); } return result; } /* This is for group */ static void print_group (struct group *grp) { if (putgrent (grp, stdout) != 0) fprintf (stderr, "error writing group entry: %m\n"); } static int group_keys (int number, char *key[]) { int result = 0; int i; struct group *grp; if (number == 0) { setgrent (); while ((grp = getgrent ()) != NULL) print_group (grp); endgrent (); return result; } for (i = 0; i < number; ++i) { errno = 0; char *ep; gid_t arg_gid = strtoul(key[i], &ep, 10); if (errno != EINVAL && *key[i] != '\0' && *ep == '\0') /* Valid numeric gid. */ grp = getgrgid (arg_gid); else grp = getgrnam (key[i]); if (grp == NULL) result = 2; else print_group (grp); } return result; } /* This is for gshadow */ static void print_gshadow (struct sgrp *sg) { if (putsgent (sg, stdout) != 0) fprintf (stderr, "error writing gshadow entry: %m\n"); } static int gshadow_keys (int number, char *key[]) { int result = 0; int i; if (number == 0) { struct sgrp *sg; setsgent (); while ((sg = getsgent ()) != NULL) print_gshadow (sg); endsgent (); return result; } for (i = 0; i < number; ++i) { struct sgrp *sg; sg = getsgnam (key[i]); if (sg == NULL) result = 2; else print_gshadow (sg); } return result; } /* This is for hosts */ static void print_hosts (struct hostent *host) { unsigned int cnt; for (cnt = 0; host->h_addr_list[cnt] != NULL; ++cnt) { char buf[INET6_ADDRSTRLEN]; const char *ip = inet_ntop (host->h_addrtype, host->h_addr_list[cnt], buf, sizeof (buf)); printf ("%-15s %s", ip, host->h_name); unsigned int i; for (i = 0; host->h_aliases[i] != NULL; ++i) { putchar_unlocked (' '); fputs_unlocked (host->h_aliases[i], stdout); } putchar_unlocked ('\n'); } } static int hosts_keys (int number, char *key[]) { int result = 0; int i; struct hostent *host; if (number == 0) { sethostent (0); while ((host = gethostent ()) != NULL) print_hosts (host); endhostent (); return result; } for (i = 0; i < number; ++i) { struct hostent *host = NULL; char addr[IN6ADDRSZ]; if (inet_pton (AF_INET6, key[i], &addr) > 0) host = gethostbyaddr (addr, IN6ADDRSZ, AF_INET6); else if (inet_pton (AF_INET, key[i], &addr) > 0) host = gethostbyaddr (addr, INADDRSZ, AF_INET); else if ((host = gethostbyname2 (key[i], AF_INET6)) == NULL) host = gethostbyname2 (key[i], AF_INET); if (host == NULL) result = 2; else print_hosts (host); } return result; } /* This is for hosts, but using getaddrinfo */ static int ahosts_keys_int (int af, int xflags, int number, char *key[]) { int result = 0; int i; struct hostent *host; if (number == 0) { sethostent (0); while ((host = gethostent ()) != NULL) print_hosts (host); endhostent (); return result; } struct addrinfo hint; memset (&hint, '\0', sizeof (hint)); hint.ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME | idn_flags | xflags); hint.ai_family = af; for (i = 0; i < number; ++i) { struct addrinfo *res; if (getaddrinfo (key[i], NULL, &hint, &res) != 0) result = 2; else { struct addrinfo *runp = res; while (runp != NULL) { char sockbuf[20]; const char *sockstr; if (runp->ai_socktype == SOCK_STREAM) sockstr = "STREAM"; else if (runp->ai_socktype == SOCK_DGRAM) sockstr = "DGRAM"; else if (runp->ai_socktype == SOCK_RAW) sockstr = "RAW"; #ifdef SOCK_SEQPACKET else if (runp->ai_socktype == SOCK_SEQPACKET) sockstr = "SEQPACKET"; #endif #ifdef SOCK_RDM else if (runp->ai_socktype == SOCK_RDM) sockstr = "RDM"; #endif #ifdef SOCK_DCCP else if (runp->ai_socktype == SOCK_DCCP) sockstr = "DCCP"; #endif #ifdef SOCK_PACKET else if (runp->ai_socktype == SOCK_PACKET) sockstr = "PACKET"; #endif else { snprintf (sockbuf, sizeof (sockbuf), "%d", runp->ai_socktype); sockstr = sockbuf; } char buf[INET6_ADDRSTRLEN]; printf ("%-15s %-6s %s\n", inet_ntop (runp->ai_family, runp->ai_family == AF_INET ? (void *) &((struct sockaddr_in *) runp->ai_addr)->sin_addr : (void *) &((struct sockaddr_in6 *) runp->ai_addr)->sin6_addr, buf, sizeof (buf)), sockstr, runp->ai_canonname ?: ""); runp = runp->ai_next; } freeaddrinfo (res); } } return result; } static int ahosts_keys (int number, char *key[]) { return ahosts_keys_int (AF_UNSPEC, 0, number, key); } static int ahostsv4_keys (int number, char *key[]) { return ahosts_keys_int (AF_INET, 0, number, key); } static int ahostsv6_keys (int number, char *key[]) { return ahosts_keys_int (AF_INET6, AI_V4MAPPED, number, key); } /* This is for netgroup */ static int netgroup_keys (int number, char *key[]) { int result = 0; if (number == 0) { fprintf (stderr, _("Enumeration not supported on %s\n"), "netgroup"); return 3; } if (number == 4) { char *host = strcmp (key[1], "*") == 0 ? NULL : key[1]; char *user = strcmp (key[2], "*") == 0 ? NULL : key[2]; char *domain = strcmp (key[3], "*") == 0 ? NULL : key[3]; printf ("%-21s (%s,%s,%s) = %d\n", key[0], host ?: "", user ?: "", domain ?: "", innetgr (key[0], host, user, domain)); } else if (number == 1) { if (!setnetgrent (key[0])) result = 2; else { char *p[3]; printf ("%-21s", key[0]); while (getnetgrent (p, p + 1, p + 2)) printf (" (%s,%s,%s)", p[0] ?: " ", p[1] ?: "", p[2] ?: ""); putchar_unlocked ('\n'); } } endnetgrent (); return result; } #define DYNARRAY_STRUCT gid_list #define DYNARRAY_ELEMENT gid_t #define DYNARRAY_PREFIX gid_list_ #define DYNARRAY_INITIAL_SIZE 10 #include <malloc/dynarray-skeleton.c> /* This is for initgroups */ static int initgroups_keys (int number, char *key[]) { if (number == 0) { fprintf (stderr, _("Enumeration not supported on %s\n"), "initgroups"); return 3; } struct gid_list list; gid_list_init (&list); if (!gid_list_resize (&list, 10)) { fprintf (stderr, _("Could not allocate group list: %m\n")); return 3; } for (int i = 0; i < number; ++i) { int no = gid_list_size (&list); int n; while ((n = getgrouplist (key[i], -1, gid_list_begin (&list), &no)) == -1 && no > gid_list_size (&list)) { if (!gid_list_resize (&list, no)) { fprintf (stderr, _("Could not allocate group list: %m\n")); return 3; } } if (n == -1) { gid_list_free (&list); return 1; } const gid_t *grps = gid_list_begin (&list); printf ("%-21s", key[i]); for (int j = 0; j < n; ++j) if (grps[j] != -1) printf (" %ld", (long int) grps[j]); putchar_unlocked ('\n'); } gid_list_free (&list); return 0; } /* This is for networks */ static void print_networks (struct netent *net) { unsigned int i; struct in_addr ip; ip.s_addr = htonl (net->n_net); printf ("%-21s %s", net->n_name, inet_ntoa (ip)); i = 0; while (net->n_aliases[i] != NULL) { putchar_unlocked (' '); fputs_unlocked (net->n_aliases[i], stdout); ++i; } putchar_unlocked ('\n'); } static int networks_keys (int number, char *key[]) { int result = 0; int i; struct netent *net; if (number == 0) { setnetent (0); while ((net = getnetent ()) != NULL) print_networks (net); endnetent (); return result; } for (i = 0; i < number; ++i) { if (isdigit (key[i][0])) net = getnetbyaddr (ntohl (inet_addr (key[i])), AF_UNSPEC); else net = getnetbyname (key[i]); if (net == NULL) result = 2; else print_networks (net); } return result; } /* Now is all for passwd */ static void print_passwd (struct passwd *pwd) { if (putpwent (pwd, stdout) != 0) fprintf (stderr, "error writing passwd entry: %m\n"); } static int passwd_keys (int number, char *key[]) { int result = 0; int i; struct passwd *pwd; if (number == 0) { setpwent (); while ((pwd = getpwent ()) != NULL) print_passwd (pwd); endpwent (); return result; } for (i = 0; i < number; ++i) { errno = 0; char *ep; uid_t arg_uid = strtoul(key[i], &ep, 10); if (errno != EINVAL && *key[i] != '\0' && *ep == '\0') /* Valid numeric uid. */ pwd = getpwuid (arg_uid); else pwd = getpwnam (key[i]); if (pwd == NULL) result = 2; else print_passwd (pwd); } return result; } /* This is for protocols */ static void print_protocols (struct protoent *proto) { unsigned int i; printf ("%-21s %d", proto->p_name, proto->p_proto); i = 0; while (proto->p_aliases[i] != NULL) { putchar_unlocked (' '); fputs_unlocked (proto->p_aliases[i], stdout); ++i; } putchar_unlocked ('\n'); } static int protocols_keys (int number, char *key[]) { int result = 0; int i; struct protoent *proto; if (number == 0) { setprotoent (0); while ((proto = getprotoent ()) != NULL) print_protocols (proto); endprotoent (); return result; } for (i = 0; i < number; ++i) { if (isdigit (key[i][0])) proto = getprotobynumber (atol (key[i])); else proto = getprotobyname (key[i]); if (proto == NULL) result = 2; else print_protocols (proto); } return result; } #if HAVE_SUNRPC /* Now is all for rpc */ static void print_rpc (struct rpcent *rpc) { int i; printf ("%-15s %d%s", rpc->r_name, rpc->r_number, rpc->r_aliases[0] ? " " : ""); for (i = 0; rpc->r_aliases[i]; ++i) printf (" %s", rpc->r_aliases[i]); putchar_unlocked ('\n'); } static int rpc_keys (int number, char *key[]) { int result = 0; int i; struct rpcent *rpc; if (number == 0) { setrpcent (0); while ((rpc = getrpcent ()) != NULL) print_rpc (rpc); endrpcent (); return result; } for (i = 0; i < number; ++i) { if (isdigit (key[i][0])) rpc = getrpcbynumber (atol (key[i])); else rpc = getrpcbyname (key[i]); if (rpc == NULL) result = 2; else print_rpc (rpc); } return result; } #endif /* for services */ static void print_services (struct servent *serv) { unsigned int i; printf ("%-21s %d/%s", serv->s_name, ntohs (serv->s_port), serv->s_proto); i = 0; while (serv->s_aliases[i] != NULL) { putchar_unlocked (' '); fputs_unlocked (serv->s_aliases[i], stdout); ++i; } putchar_unlocked ('\n'); } static int services_keys (int number, char *key[]) { int result = 0; int i; struct servent *serv; if (!number) { setservent (0); while ((serv = getservent ()) != NULL) print_services (serv); endservent (); return result; } for (i = 0; i < number; ++i) { struct servent *serv; char *proto = strchr (key[i], '/'); if (proto != NULL) *proto++ = '\0'; char *endptr; long port = strtol (key[i], &endptr, 10); if (isdigit (key[i][0]) && *endptr == '\0' && 0 <= port && port <= 65535) serv = getservbyport (htons (port), proto); else serv = getservbyname (key[i], proto); if (serv == NULL) result = 2; else print_services (serv); } return result; } /* This is for shadow */ static void print_shadow (struct spwd *sp) { if (putspent (sp, stdout) != 0) fprintf (stderr, "error writing shadow entry: %m\n"); } static int shadow_keys (int number, char *key[]) { int result = 0; int i; if (number == 0) { struct spwd *sp; setspent (); while ((sp = getspent ()) != NULL) print_shadow (sp); endspent (); return result; } for (i = 0; i < number; ++i) { struct spwd *sp; sp = getspnam (key[i]); if (sp == NULL) result = 2; else print_shadow (sp); } return result; } struct { const char *name; int (*func) (int number, char *key[]); } databases[] = { #define D(name) { #name, name ## _keys }, D(ahosts) D(ahostsv4) D(ahostsv6) D(aliases) D(ethers) D(group) D(gshadow) D(hosts) D(initgroups) D(netgroup) D(networks) D(passwd) D(protocols) #if HAVE_SUNRPC D(rpc) #endif D(services) D(shadow) #undef D { NULL, NULL } }; /* Handle arguments found by argp. */ static error_t parse_option (int key, char *arg, struct argp_state *state) { char *endp; switch (key) { case 's': endp = strchr (arg, ':'); if (endp == NULL) /* No specific database, change them all. */ for (int i = 0; databases[i].name != NULL; ++i) __nss_configure_lookup (databases[i].name, arg); else { int i; for (i = 0; databases[i].name != NULL; ++i) if (strncmp (databases[i].name, arg, endp - arg) == 0) { __nss_configure_lookup (databases[i].name, endp + 1); break; } if (databases[i].name == NULL) error (EXIT_FAILURE, 0, gettext ("Unknown database name")); } break; case 'i': idn_flags = 0; break; default: return ARGP_ERR_UNKNOWN; } return 0; } static char * more_help (int key, const char *text, void *input) { switch (key) { size_t len; char *doc; FILE *fp; case ARGP_KEY_HELP_EXTRA: /* We print some extra information. */ fp = open_memstream (&doc, &len); if (fp != NULL) { fputs_unlocked (_("Supported databases:\n"), fp); for (int i = 0, col = 0; databases[i].name != NULL; ++i) { len = strlen (databases[i].name); if (i != 0) { if (col + len > 72) { col = 0; fputc_unlocked ('\n', fp); } else fputc_unlocked (' ', fp); } fputs_unlocked (databases[i].name, fp); col += len + 1; } fputs ("\n\n", fp); fprintf (fp, gettext ("\ For bug reporting instructions, please see:\n\ %s.\n"), REPORT_BUGS_TO); if (fclose (fp) == 0) return doc; } break; default: break; } return (char *) text; } /* the main function */ int main (int argc, char *argv[]) { /* Debugging support. */ mtrace (); /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); /* Set the text message domain. */ textdomain (PACKAGE); /* Parse and process arguments. */ int remaining; argp_parse (&argp, argc, argv, 0, &remaining, NULL); if ((argc - remaining) < 1) { error (0, 0, gettext ("wrong number of arguments")); argp_help (&argp, stdout, ARGP_HELP_SEE, program_invocation_short_name); return 1; } for (int i = 0; databases[i].name; ++i) if (argv[remaining][0] == databases[i].name[0] && !strcmp (argv[remaining], databases[i].name)) return databases[i].func (argc - remaining - 1, &argv[remaining + 1]); fprintf (stderr, _("Unknown database: %s\n"), argv[remaining]); argp_help (&argp, stdout, ARGP_HELP_SEE, program_invocation_short_name); return 1; }