summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/ctfdump/ctfdump.c80
-rw-r--r--usr/src/cmd/dis/dis_target.c29
-rw-r--r--usr/src/cmd/getent/Makefile1
-rw-r--r--usr/src/cmd/getent/dogetnetgr.c71
-rw-r--r--usr/src/cmd/getent/getent.c5
-rw-r--r--usr/src/cmd/getent/getent.h2
-rw-r--r--usr/src/cmd/netfiles/nsswitch.ad2
-rw-r--r--usr/src/cmd/netfiles/nsswitch.conf2
-rw-r--r--usr/src/cmd/netfiles/nsswitch.dns5
-rw-r--r--usr/src/cmd/netfiles/nsswitch.files3
-rw-r--r--usr/src/cmd/netfiles/nsswitch.ldap3
-rw-r--r--usr/src/cmd/netfiles/nsswitch.nis3
-rw-r--r--usr/src/cmd/ucodeadm/ucodeadm.c16
-rw-r--r--usr/src/cmd/zfs/zfs_main.c3
14 files changed, 192 insertions, 33 deletions
diff --git a/usr/src/cmd/ctfdump/ctfdump.c b/usr/src/cmd/ctfdump/ctfdump.c
index a2e668d266..d54b50c6e7 100644
--- a/usr/src/cmd/ctfdump/ctfdump.c
+++ b/usr/src/cmd/ctfdump/ctfdump.c
@@ -121,7 +121,7 @@ ctfdump_printf(ctfdump_arg_t arg, const char *fmt, ...)
va_end(ap);
}
-static void
+static void __NORETURN
ctfdump_fatal(const char *fmt, ...)
{
va_list ap;
@@ -987,8 +987,82 @@ ctfsrc_function(ctf_idname_t *idn)
static int
idname_compare(const void *lhs, const void *rhs)
{
- return (strcmp(((ctf_idname_t *)lhs)->ci_name,
- ((ctf_idname_t *)rhs)->ci_name));
+ int ret;
+ char lname[MAX_NAMELEN] = {0};
+ char rname[MAX_NAMELEN] = {0};
+ const ctf_idname_t *l = lhs;
+ const ctf_idname_t *r = rhs;
+ uint_t arity = 0;
+
+ if ((ret = strcmp(l->ci_name, r->ci_name)) != 0)
+ return (ret);
+
+ /* If the names match, try arity */
+ if (l->ci_funcinfo.ctc_argc < r->ci_funcinfo.ctc_argc)
+ return (-1);
+ else if (l->ci_funcinfo.ctc_argc > r->ci_funcinfo.ctc_argc)
+ return (1);
+ else
+ arity = l->ci_funcinfo.ctc_argc;
+
+ /* If arity doesn't help, try return type */
+ (void) strlcpy(lname, "unknown_t", sizeof (lname));
+ (void) strlcpy(rname, "unknown_t", sizeof (rname));
+ (void) ctf_type_name(g_fp, l->ci_funcinfo.ctc_return, lname,
+ sizeof (lname));
+ (void) ctf_type_name(g_fp, r->ci_funcinfo.ctc_return, rname,
+ sizeof (rname));
+
+ if ((ret = strcmp(lname, rname)) != 0)
+ return (ret);
+
+ /* if return type doesn't help, try parameter types */
+ if (arity == 0)
+ return (0);
+
+ ctf_id_t *largs = calloc(arity, sizeof (ctf_id_t));
+ ctf_id_t *rargs = calloc(arity, sizeof (ctf_id_t));
+
+ if ((largs == NULL) || (rargs == NULL)) {
+ free(rargs);
+ free(largs);
+ ctfdump_fatal("failed to alloc argument ids for sorting: "
+ " %s\n", strerror(errno));
+ }
+
+ if (ctf_func_args(g_fp, l->ci_symidx, arity, largs) == CTF_ERR) {
+ free(rargs);
+ free(largs);
+ ctfdump_fatal("failed to get arguments for function "
+ "%s: %s\n", l->ci_name,
+ ctf_errmsg(ctf_errno(g_fp)));
+ }
+
+ if (ctf_func_args(g_fp, r->ci_symidx, arity, rargs) == CTF_ERR) {
+ free(rargs);
+ free(largs);
+ ctfdump_fatal("failed to get arguments for function "
+ "%s: %s\n", r->ci_name,
+ ctf_errmsg(ctf_errno(g_fp)));
+ }
+
+ for (uint_t i = 0; i < arity; i++) {
+ (void) strlcpy(lname, "unknown_t", sizeof (lname));
+ (void) ctf_type_name(g_fp, largs[i], lname, sizeof (lname));
+
+ (void) strlcpy(rname, "unknown_t", sizeof (rname));
+ (void) ctf_type_name(g_fp, rargs[i], rname, sizeof (rname));
+
+ if ((ret = strcmp(lname, rname)) != 0) {
+ free(rargs);
+ free(largs);
+ return (ret);
+ }
+ }
+
+ free(rargs);
+ free(largs);
+ return (0);
}
static void
diff --git a/usr/src/cmd/dis/dis_target.c b/usr/src/cmd/dis/dis_target.c
index 37ab5cc3bc..ec280628b9 100644
--- a/usr/src/cmd/dis/dis_target.c
+++ b/usr/src/cmd/dis/dis_target.c
@@ -68,7 +68,7 @@ typedef struct sym_entry {
* mess up symbol resolution (which uses the virtual address).
*/
typedef struct dis_shnmap {
- const char *dm_name; /* name of section */
+ const char *dm_name; /* name of section */
uint64_t dm_start; /* virtual address of section */
size_t dm_length; /* address length */
boolean_t dm_mapped; /* did we assign the mapping */
@@ -157,6 +157,8 @@ sym_compare(const void *a, const void *b)
const sym_entry_t *symb = b;
const char *aname = syma->se_name;
const char *bname = symb->se_name;
+ size_t alen;
+ size_t blen;
if (syma->se_sym.st_value < symb->se_sym.st_value)
return (-1);
@@ -179,9 +181,9 @@ sym_compare(const void *a, const void *b)
* For symbols with the same address and type, we sort them according to
* a hierarchy:
*
- * 1. weak symbols (common name)
- * 2. global symbols (external name)
- * 3. local symbols
+ * 1. weak symbols (common name)
+ * 2. global symbols (external name)
+ * 3. local symbols
*/
if (GELF_ST_BIND(syma->se_sym.st_info) !=
GELF_ST_BIND(symb->se_sym.st_info)) {
@@ -224,10 +226,23 @@ sym_compare(const void *a, const void *b)
return (1);
/*
- * We really do have two identical symbols for some reason. Just report
- * them as equal, and to the lucky one go the spoils.
+ * We really do have two identical symbols, choose the one with the
+ * shortest name if we can, heuristically taking it to be the most
+ * representative.
*/
- return (0);
+ alen = strlen(syma->se_name);
+ blen = strlen(symb->se_name);
+
+ if (alen < blen)
+ return (-1);
+ else if (alen > blen)
+ return (1);
+
+ /*
+ * If all else fails, compare the names, so that we give a stable
+ * sort
+ */
+ return (strcmp(syma->se_name, symb->se_name));
}
/*
diff --git a/usr/src/cmd/getent/Makefile b/usr/src/cmd/getent/Makefile
index c68e2d91fe..174cb40fbb 100644
--- a/usr/src/cmd/getent/Makefile
+++ b/usr/src/cmd/getent/Makefile
@@ -38,6 +38,7 @@ OBJECTS= \
dogethost.o \
dogetipnodes.o \
dogetnet.o \
+ dogetnetgr.o \
dogetnetmask.o \
dogetprofattr.o \
dogetproject.o \
diff --git a/usr/src/cmd/getent/dogetnetgr.c b/usr/src/cmd/getent/dogetnetgr.c
new file mode 100644
index 0000000000..7addef787b
--- /dev/null
+++ b/usr/src/cmd/getent/dogetnetgr.c
@@ -0,0 +1,71 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2021 Planets Communications B.V.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <netdb.h>
+#include <string.h>
+#include "getent.h"
+
+int
+dogetnetgr(const char **list)
+{
+ uint_t cnt;
+ char *host, *user, *dom;
+ const char *host_filter, *user_filter, *dom_filter;
+ int rc = EXC_SUCCESS;
+
+ if (list == NULL || *list == NULL)
+ return (EXC_ENUM_NOT_SUPPORTED);
+
+ /*
+ * Count the arguments given.
+ */
+ cnt = 0;
+ while (list[cnt] != NULL)
+ cnt++;
+
+ switch (cnt) {
+ case 1:
+ if (setnetgrent(list[0]) != 0)
+ return (EXC_ERROR);
+ printf("%s", list[0]);
+ while (getnetgrent(&host, &user, &dom) != 0) {
+ printf(" (%s,%s,%s)",
+ (host) ? host : "",
+ (user) ? user : "",
+ (dom) ? dom : "");
+ }
+ printf("\n");
+ break;
+ case 4:
+ host_filter = (strcmp(list[1], "*") == 0) ? NULL : list[1];
+ user_filter = (strcmp(list[2], "*") == 0) ? NULL : list[2];
+ dom_filter = (strcmp(list[3], "*") == 0) ? NULL : list[3];
+ printf("%-21s (%s,%s,%s) = %d\n", list[0],
+ (host_filter) ? host_filter : "",
+ (user_filter) ? user_filter : "",
+ (dom_filter) ? dom_filter : "",
+ innetgr(list[0], host_filter, user_filter, dom_filter));
+ break;
+ default:
+ rc = EXC_SYNTAX;
+ break;
+ }
+
+ return (rc);
+}
diff --git a/usr/src/cmd/getent/getent.c b/usr/src/cmd/getent/getent.c
index 782034d956..ea15e1dd9b 100644
--- a/usr/src/cmd/getent/getent.c
+++ b/usr/src/cmd/getent/getent.c
@@ -56,6 +56,7 @@ static struct table t[] = {
{ "exec_attr", dogetexecattr },
{ "prof_attr", dogetprofattr },
{ "user_attr", dogetuserattr },
+ { "netgroup", dogetnetgr },
{ NULL, NULL }
};
@@ -89,6 +90,10 @@ main(int argc, const char **argv)
(void) fprintf(stderr,
gettext("Syntax error\n"));
break;
+ case EXC_ERROR:
+ (void) fprintf(stderr,
+ gettext("Internal error\n"));
+ break;
case EXC_ENUM_NOT_SUPPORTED:
(void) fprintf(stderr,
gettext("Enumeration not supported on %s\n"), argv[1]);
diff --git a/usr/src/cmd/getent/getent.h b/usr/src/cmd/getent/getent.h
index 99b5cac075..6d5f6ed74a 100644
--- a/usr/src/cmd/getent/getent.h
+++ b/usr/src/cmd/getent/getent.h
@@ -40,6 +40,7 @@ extern "C" {
#define EXC_SYNTAX 1
#define EXC_NAME_NOT_FOUND 2
#define EXC_ENUM_NOT_SUPPORTED 3
+#define EXC_ERROR 4
extern int dogetpw(const char **);
extern int dogetsp(const char **);
@@ -56,6 +57,7 @@ extern int dogetauthattr(const char **);
extern int dogetexecattr(const char **);
extern int dogetprofattr(const char **);
extern int dogetuserattr(const char **);
+extern int dogetnetgr(const char **);
#ifdef __cplusplus
}
diff --git a/usr/src/cmd/netfiles/nsswitch.ad b/usr/src/cmd/netfiles/nsswitch.ad
index e869c6bd32..bec5c72c2d 100644
--- a/usr/src/cmd/netfiles/nsswitch.ad
+++ b/usr/src/cmd/netfiles/nsswitch.ad
@@ -61,8 +61,6 @@ ethers: files
netmasks: files
bootparams: files
publickey: files
-# At present there isn't a 'files' backend for netgroup; the system will
-# figure it out pretty quickly, and won't use netgroups at all.
netgroup: files
automount: files
aliases: files
diff --git a/usr/src/cmd/netfiles/nsswitch.conf b/usr/src/cmd/netfiles/nsswitch.conf
index 166e5e0ca3..573b3107af 100644
--- a/usr/src/cmd/netfiles/nsswitch.conf
+++ b/usr/src/cmd/netfiles/nsswitch.conf
@@ -38,8 +38,6 @@ ethers: files
netmasks: files
bootparams: files
publickey: files
-# At present there isn't a 'files' backend for netgroup; the system will
-# figure it out pretty quickly, and won't use netgroups at all.
netgroup: files
automount: files
aliases: files
diff --git a/usr/src/cmd/netfiles/nsswitch.dns b/usr/src/cmd/netfiles/nsswitch.dns
index ff4bafcc0c..cb58c3bc0a 100644
--- a/usr/src/cmd/netfiles/nsswitch.dns
+++ b/usr/src/cmd/netfiles/nsswitch.dns
@@ -21,7 +21,6 @@
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-#ident "%Z%%M% %I% %E% SMI"
#
# /etc/nsswitch.dns:
@@ -39,7 +38,7 @@ passwd: files
group: files
# You must also set up the /etc/resolv.conf file for DNS name
-# server lookup. See resolv.conf(4). For lookup via mdns
+# server lookup. See resolv.conf(4). For lookup via mdns
# svc:/network/dns/multicast:default must also be enabled. See mdnsd(1M)
hosts: files dns mdns
@@ -54,8 +53,6 @@ ethers: files
netmasks: files
bootparams: files
publickey: files
-# At present there isn't a 'files' backend for netgroup; the system will
-# figure it out pretty quickly, and won't use netgroups at all.
netgroup: files
automount: files
aliases: files
diff --git a/usr/src/cmd/netfiles/nsswitch.files b/usr/src/cmd/netfiles/nsswitch.files
index da48bed918..f847a442f6 100644
--- a/usr/src/cmd/netfiles/nsswitch.files
+++ b/usr/src/cmd/netfiles/nsswitch.files
@@ -20,7 +20,6 @@
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
#
# /etc/nsswitch.files:
@@ -42,8 +41,6 @@ ethers: files
netmasks: files
bootparams: files
publickey: files
-# At present there isn't a 'files' backend for netgroup; the system will
-# figure it out pretty quickly, and won't use netgroups at all.
netgroup: files
automount: files
aliases: files
diff --git a/usr/src/cmd/netfiles/nsswitch.ldap b/usr/src/cmd/netfiles/nsswitch.ldap
index ccf75b4962..abf28da3d1 100644
--- a/usr/src/cmd/netfiles/nsswitch.ldap
+++ b/usr/src/cmd/netfiles/nsswitch.ldap
@@ -36,7 +36,6 @@
passwd: files ldap
group: files ldap
-# consult /etc "files" only if ldap is down.
hosts: files ldap
# Note that IPv4 addresses are searched for in all of the ipnodes databases
@@ -51,7 +50,7 @@ netmasks: files ldap
bootparams: files ldap
publickey: files ldap
-netgroup: ldap
+netgroup: files ldap
automount: files ldap
aliases: files ldap
diff --git a/usr/src/cmd/netfiles/nsswitch.nis b/usr/src/cmd/netfiles/nsswitch.nis
index 064fdc40d9..9d31c9ac4d 100644
--- a/usr/src/cmd/netfiles/nsswitch.nis
+++ b/usr/src/cmd/netfiles/nsswitch.nis
@@ -36,7 +36,6 @@
passwd: files nis
group: files nis
-# consult /etc "files" only if nis is down.
hosts: files nis
# Note that IPv4 addresses are searched for in all of the ipnodes databases
@@ -51,7 +50,7 @@ netmasks: files nis
bootparams: files nis
publickey: files nis
-netgroup: nis
+netgroup: files nis
automount: files nis
aliases: files nis
diff --git a/usr/src/cmd/ucodeadm/ucodeadm.c b/usr/src/cmd/ucodeadm/ucodeadm.c
index 18d0162b82..65f61facea 100644
--- a/usr/src/cmd/ucodeadm/ucodeadm.c
+++ b/usr/src/cmd/ucodeadm/ucodeadm.c
@@ -387,11 +387,10 @@ ucode_gen_files_intel(uint8_t *buf, int size, char *path)
dprintf("proc_flags = %x, platid = %x, name = %s\n",
uhp->uh_proc_flags, platid, name);
- if (ucode_should_update_intel(name, uhp->uh_rev) != 0) {
-
+ if (ucode_should_update_intel(name,
+ uhp->uh_rev) != 0) {
/* Remove the existing one first */
(void) unlink(name);
-
if (link(firstname, name) == -1) {
ucode_perror(name, EM_SYS);
return (EM_SYS);
@@ -422,12 +421,15 @@ ucode_gen_files_intel(uint8_t *buf, int size, char *path)
continue;
(void) snprintf(name, PATH_MAX,
- "%s/%08X-%02X", path, extp->uet_ext_sig[i],
- id);
+ "%s/%08X-%02X", path,
+ uesp->ues_signature, id);
- if (ucode_should_update_intel(name, uhp->uh_rev)
- != 0) {
+ dprintf("extsig: proc_flags = %x, "
+ "platid = %x, name = %s\n",
+ uesp->ues_proc_flags, id, name);
+ if (ucode_should_update_intel(name,
+ uhp->uh_rev) != 0) {
/* Remove the existing one first */
(void) unlink(name);
if (link(firstname, name) == -1) {
diff --git a/usr/src/cmd/zfs/zfs_main.c b/usr/src/cmd/zfs/zfs_main.c
index c8c7c525ba..69a9af8ea7 100644
--- a/usr/src/cmd/zfs/zfs_main.c
+++ b/usr/src/cmd/zfs/zfs_main.c
@@ -30,6 +30,7 @@
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
* Copyright 2016 Nexenta Systems, Inc.
* Copyright (c) 2018 Datto Inc.
+ * Copyright 2021 RackTop Systems, Inc.
*/
#include <assert.h>
@@ -6142,7 +6143,7 @@ zfs_do_holds(int argc, char **argv)
/*
* 1. collect holds data, set format options
*/
- ret = zfs_for_each(argc, argv, flags, types, NULL, NULL, limit,
+ ret = zfs_for_each(1, &argv[i], flags, types, NULL, NULL, limit,
holds_callback, &cb);
if (ret != 0)
++errors;