6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
27 */
28
29 /*
30 * pargs examines and prints the arguments (argv), environment (environ),
31 * and auxiliary vector of another process.
32 *
33 * This utility is made more complex because it must run in internationalized
34 * environments. The two key cases for pargs to manage are:
35 *
36 * 1. pargs and target run in the same locale: pargs must respect the
37 * locale, but this case is straightforward. Care is taken to correctly
38 * use wide characters in order to print results properly.
39 *
40 * 2. pargs and target run in different locales: in this case, pargs examines
41 * the string having assumed the victim's locale. Unprintable (but valid)
42 * characters are escaped. Next, iconv(3c) is used to convert between the
43 * target and pargs codeset. Finally, a second pass to escape unprintable
44 * (but valid) characters is made.
45 *
46 * In any case in which characters are encountered which are not valid in
780
781 #define MAX_AT_NAME_LEN 15
782
783 struct aux_id {
784 int aux_type;
785 const char *aux_name;
786 void (*aux_decode)(long, char *, size_t, char *);
787 };
788
789 static struct aux_id aux_arr[] = {
790 { AT_NULL, "AT_NULL", at_null },
791 { AT_IGNORE, "AT_IGNORE", at_null },
792 { AT_EXECFD, "AT_EXECFD", at_null },
793 { AT_PHDR, "AT_PHDR", at_null },
794 { AT_PHENT, "AT_PHENT", at_null },
795 { AT_PHNUM, "AT_PHNUM", at_null },
796 { AT_PAGESZ, "AT_PAGESZ", at_null },
797 { AT_BASE, "AT_BASE", at_null },
798 { AT_FLAGS, "AT_FLAGS", at_null },
799 { AT_ENTRY, "AT_ENTRY", at_null },
800 { AT_SUN_UID, "AT_SUN_UID", at_uid },
801 { AT_SUN_RUID, "AT_SUN_RUID", at_uid },
802 { AT_SUN_GID, "AT_SUN_GID", at_gid },
803 { AT_SUN_RGID, "AT_SUN_RGID", at_gid },
804 { AT_SUN_LDELF, "AT_SUN_LDELF", at_null },
805 { AT_SUN_LDSHDR, "AT_SUN_LDSHDR", at_null },
806 { AT_SUN_LDNAME, "AT_SUN_LDNAME", at_null },
807 { AT_SUN_LPAGESZ, "AT_SUN_LPAGESZ", at_null },
808 { AT_SUN_PLATFORM, "AT_SUN_PLATFORM", at_str },
809 { AT_SUN_EXECNAME, "AT_SUN_EXECNAME", at_str },
810 { AT_SUN_HWCAP, "AT_SUN_HWCAP", at_hwcap },
811 { AT_SUN_HWCAP2, "AT_SUN_HWCAP2", at_hwcap2 },
812 { AT_SUN_IFLUSH, "AT_SUN_IFLUSH", at_null },
813 { AT_SUN_CPU, "AT_SUN_CPU", at_null },
814 { AT_SUN_MMU, "AT_SUN_MMU", at_null },
815 { AT_SUN_LDDATA, "AT_SUN_LDDATA", at_null },
816 { AT_SUN_AUXFLAGS, "AT_SUN_AUXFLAGS", at_flags },
817 { AT_SUN_EMULATOR, "AT_SUN_EMULATOR", at_str },
818 { AT_SUN_BRANDNAME, "AT_SUN_BRANDNAME", at_str },
819 { AT_SUN_BRAND_AUX1, "AT_SUN_BRAND_AUX1", at_null },
820 { AT_SUN_BRAND_AUX2, "AT_SUN_BRAND_AUX2", at_null },
821 { AT_SUN_BRAND_AUX3, "AT_SUN_BRAND_AUX3", at_null }
822 };
823
824 #define N_AT_ENTS (sizeof (aux_arr) / sizeof (struct aux_id))
825
826 /*
827 * Return the aux_id entry for the given aux type; returns NULL if not found.
828 */
829 static struct aux_id *
830 aux_find(int type)
831 {
832 int i;
833
834 for (i = 0; i < N_AT_ENTS; i++) {
835 if (type == aux_arr[i].aux_type)
836 return (&aux_arr[i]);
837 }
838
839 return (NULL);
840 }
841
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright 2016 Joyent, Inc.
27 */
28
29 /*
30 * pargs examines and prints the arguments (argv), environment (environ),
31 * and auxiliary vector of another process.
32 *
33 * This utility is made more complex because it must run in internationalized
34 * environments. The two key cases for pargs to manage are:
35 *
36 * 1. pargs and target run in the same locale: pargs must respect the
37 * locale, but this case is straightforward. Care is taken to correctly
38 * use wide characters in order to print results properly.
39 *
40 * 2. pargs and target run in different locales: in this case, pargs examines
41 * the string having assumed the victim's locale. Unprintable (but valid)
42 * characters are escaped. Next, iconv(3c) is used to convert between the
43 * target and pargs codeset. Finally, a second pass to escape unprintable
44 * (but valid) characters is made.
45 *
46 * In any case in which characters are encountered which are not valid in
780
781 #define MAX_AT_NAME_LEN 15
782
783 struct aux_id {
784 int aux_type;
785 const char *aux_name;
786 void (*aux_decode)(long, char *, size_t, char *);
787 };
788
789 static struct aux_id aux_arr[] = {
790 { AT_NULL, "AT_NULL", at_null },
791 { AT_IGNORE, "AT_IGNORE", at_null },
792 { AT_EXECFD, "AT_EXECFD", at_null },
793 { AT_PHDR, "AT_PHDR", at_null },
794 { AT_PHENT, "AT_PHENT", at_null },
795 { AT_PHNUM, "AT_PHNUM", at_null },
796 { AT_PAGESZ, "AT_PAGESZ", at_null },
797 { AT_BASE, "AT_BASE", at_null },
798 { AT_FLAGS, "AT_FLAGS", at_null },
799 { AT_ENTRY, "AT_ENTRY", at_null },
800 { AT_RANDOM, "AT_RANDOM", at_null },
801 { AT_SUN_UID, "AT_SUN_UID", at_uid },
802 { AT_SUN_RUID, "AT_SUN_RUID", at_uid },
803 { AT_SUN_GID, "AT_SUN_GID", at_gid },
804 { AT_SUN_RGID, "AT_SUN_RGID", at_gid },
805 { AT_SUN_LDELF, "AT_SUN_LDELF", at_null },
806 { AT_SUN_LDSHDR, "AT_SUN_LDSHDR", at_null },
807 { AT_SUN_LDNAME, "AT_SUN_LDNAME", at_null },
808 { AT_SUN_LPAGESZ, "AT_SUN_LPAGESZ", at_null },
809 { AT_SUN_PLATFORM, "AT_SUN_PLATFORM", at_str },
810 { AT_SUN_EXECNAME, "AT_SUN_EXECNAME", at_str },
811 { AT_SUN_HWCAP, "AT_SUN_HWCAP", at_hwcap },
812 { AT_SUN_HWCAP2, "AT_SUN_HWCAP2", at_hwcap2 },
813 { AT_SUN_IFLUSH, "AT_SUN_IFLUSH", at_null },
814 { AT_SUN_CPU, "AT_SUN_CPU", at_null },
815 { AT_SUN_MMU, "AT_SUN_MMU", at_null },
816 { AT_SUN_LDDATA, "AT_SUN_LDDATA", at_null },
817 { AT_SUN_AUXFLAGS, "AT_SUN_AUXFLAGS", at_flags },
818 { AT_SUN_EMULATOR, "AT_SUN_EMULATOR", at_str },
819 { AT_SUN_BRANDNAME, "AT_SUN_BRANDNAME", at_str },
820 { AT_SUN_BRAND_NROOT, "AT_SUN_BRAND_NROOT", at_str },
821 { AT_SUN_BRAND_AUX1, "AT_SUN_BRAND_AUX1", at_null },
822 { AT_SUN_BRAND_AUX2, "AT_SUN_BRAND_AUX2", at_null },
823 { AT_SUN_BRAND_AUX3, "AT_SUN_BRAND_AUX3", at_null },
824 { AT_SUN_BRAND_AUX4, "AT_SUN_BRAND_AUX4", at_null },
825 { AT_SUN_COMMPAGE, "AT_SUN_COMMPAGE", at_null }
826 };
827
828 #define N_AT_ENTS (sizeof (aux_arr) / sizeof (struct aux_id))
829
830 /*
831 * Return the aux_id entry for the given aux type; returns NULL if not found.
832 */
833 static struct aux_id *
834 aux_find(int type)
835 {
836 int i;
837
838 for (i = 0; i < N_AT_ENTS; i++) {
839 if (type == aux_arr[i].aux_type)
840 return (&aux_arr[i]);
841 }
842
843 return (NULL);
844 }
845
|