From b877e47f88a401dbef6fff48940d38855c01fcbc Mon Sep 17 00:00:00 2001 From: Alexander Pyhalov Date: Thu, 6 Feb 2020 13:02:44 +0300 Subject: 12316 hald_runner dies getting SIGPIPE Reviewed by: Toomas Soome Approved by: Dan McDonald --- usr/src/cmd/hal/hald/solaris/devinfo_storage.c | 9 ++------- usr/src/cmd/hal/tools/hal-storage-mount.c | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'usr/src/cmd') diff --git a/usr/src/cmd/hal/hald/solaris/devinfo_storage.c b/usr/src/cmd/hal/hald/solaris/devinfo_storage.c index bfe027ad25..d1fea0c577 100644 --- a/usr/src/cmd/hal/hald/solaris/devinfo_storage.c +++ b/usr/src/cmd/hal/hald/solaris/devinfo_storage.c @@ -1522,19 +1522,17 @@ devinfo_storage_mnttab_event (HalDevice *hal_volume) /* cleanup if was mounted by us */ if (hal_util_is_mounted_by_hald (mount_point)) { - char *cleanup_stdin; char *extra_env[2]; HAL_INFO (("Cleaning up '%s'", mount_point)); extra_env[0] = g_strdup_printf ("HALD_CLEANUP=%s", mount_point); extra_env[1] = NULL; - cleanup_stdin = "\n"; hald_runner_run_method (d, "hal-storage-cleanup-mountpoint", extra_env, - cleanup_stdin, TRUE, + "", TRUE, 0, devinfo_storage_cleanup_mountpoint_cb, g_strdup (mount_point), NULL); @@ -1577,7 +1575,6 @@ static void devinfo_volume_force_unmount (HalDevice *d, void *end_token) { const char *mount_point; - char *unmount_stdin; char *extra_env[2]; extra_env[0] = "HAL_METHOD_INVOKED_BY_UID=0"; extra_env[1] = NULL; @@ -1591,12 +1588,10 @@ devinfo_volume_force_unmount (HalDevice *d, void *end_token) HAL_INFO (("devinfo_volume_force_unmount for udi='%s'", hal_device_get_udi (d))); - unmount_stdin = "\n"; - hald_runner_run_method (d, "hal-storage-unmount", extra_env, - unmount_stdin, TRUE, + "", TRUE, 0, devinfo_volume_force_unmount_cb, end_token, NULL); diff --git a/usr/src/cmd/hal/tools/hal-storage-mount.c b/usr/src/cmd/hal/tools/hal-storage-mount.c index 5622123274..5e687bea9e 100644 --- a/usr/src/cmd/hal/tools/hal-storage-mount.c +++ b/usr/src/cmd/hal/tools/hal-storage-mount.c @@ -228,7 +228,7 @@ canonicalize_filename (gchar *filename) static char * resolve_symlink (const char *file) { - GError *error; + GError *error = NULL; char *dir; char *link; char *f; -- cgit v1.2.3 From f3a525d949e26238340eb8c1f6fdcfff91fc7e65 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 20 Feb 2020 05:27:25 -0800 Subject: 12328 FNMPERIOD makes little sense for find -path Reviewed by: Andy Fiddaman Approved by: Robert Mustacchi --- usr/src/cmd/find/find.c | 6 ++- usr/src/man/man1/find.1 | 20 ++----- usr/src/pkg/manifests/system-test-utiltest.mf | 2 + usr/src/test/util-tests/tests/Makefile | 2 +- usr/src/test/util-tests/tests/find/Makefile | 41 ++++++++++++++ usr/src/test/util-tests/tests/find/findtest.ksh | 72 +++++++++++++++++++++++++ 6 files changed, 125 insertions(+), 18 deletions(-) create mode 100644 usr/src/test/util-tests/tests/find/Makefile create mode 100644 usr/src/test/util-tests/tests/find/findtest.ksh (limited to 'usr/src/cmd') diff --git a/usr/src/cmd/find/find.c b/usr/src/cmd/find/find.c index 5b5811ea6a..8860e9b711 100644 --- a/usr/src/cmd/find/find.c +++ b/usr/src/cmd/find/find.c @@ -22,6 +22,7 @@ * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2013 Andrew Stormont. All rights reserved. + * Copyright 2020 Joyent, Inc. */ @@ -1027,9 +1028,12 @@ execute(const char *name, const struct stat *statb, int type, struct FTW *state) * /usr/bin/find will not pattern match a leading * '.' in a filename, unless '.' is explicitly * specified. + * + * The legacy behavior makes no sense for PATH. */ #ifndef XPG4 - fnmflags |= FNM_PERIOD; + if (np->action == NAME || np->action == INAME) + fnmflags |= FNM_PERIOD; #endif val = !fnmatch(np->first.cp, diff --git a/usr/src/man/man1/find.1 b/usr/src/man/man1/find.1 index 47f3870d12..d393a3197d 100644 --- a/usr/src/man/man1/find.1 +++ b/usr/src/man/man1/find.1 @@ -45,12 +45,12 @@ .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved .\" Copyright 2011 Nexenta Systems, Inc. All rights reserved. .\" Copyright (c) 2013 Andrew Stormont. All rights reserved. +.\" Copyright 2020 Joyent, Inc. .\" -.TH FIND 1 "Sep 5, 2011" +.TH FIND 1 "Feb 20, 2020" .SH NAME find \- find files .SH SYNOPSIS -.LP .nf \fB/usr/bin/find\fR [\fB-E\fR] [\fB-H\fR | \fB-L\fR] \fIpath\fR... \fIexpression\fR .fi @@ -61,7 +61,6 @@ find \- find files .fi .SH DESCRIPTION -.LP The \fBfind\fR utility recursively descends the directory hierarchy for each \fIpath\fR seeking files that match a Boolean \fIexpression\fR written in the primaries specified below. @@ -75,7 +74,6 @@ by the application exceeds \fIPATH_MAX\fR requirements). \fBfind\fR detects infinite loops; that is, entering a previously visited directory that is an ancestor of the last file encountered. .SH OPTIONS -.LP The following options are supported: .sp .ne 2 @@ -117,7 +115,6 @@ Specifying more than one of the mutually-exclusive options \fB-H\fR and \fB-L\fR is not considered an error. The last option specified determines the behavior of the utility. .SH OPERANDS -.LP The following operands are supported: .sp .ne 2 @@ -169,7 +166,6 @@ less than \fIn\fR .RE .SS "Expressions" -.LP Valid expressions are: .sp .ne 2 @@ -549,7 +545,8 @@ question mark first, and is executed only if the response is affirmative. \fB\fB-path\fR\fR .ad .RS 17n -Like \fB-name\fR, but matches the entire file path and not just basename. +Like \fB-name\fR, but matches the entire file path and not just basename, and +without any special treatment of leading periods. .RE .sp @@ -717,7 +714,6 @@ True if the file has extended attributes. .RE .SS "Complex Expressions" -.LP The primaries can be combined using the following operators (in order of decreasing precedence): .sp @@ -783,11 +779,9 @@ The \fB-user\fR, \fB-group\fR, and \fB-newer\fR primaries each evaluate their respective arguments only once. Invocation of \fIcommand\fR specified by \fB-exec\fR or \fB-ok\fR does not affect subsequent primaries on the same file. .SH USAGE -.LP See \fBlargefile\fR(5) for the description of the behavior of \fBfind\fR when encountering files greater than or equal to 2 Gbyte (2^31 bytes). .SH EXAMPLES -.LP \fBExample 1 \fRWriting Out the Hierarchy Directory .sp .LP @@ -957,7 +951,6 @@ example% \fBfind . -xattr\fR .sp .SH ENVIRONMENT VARIABLES -.LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBfind\fR: \fBLANG\fR, \fBLC_ALL\fR, \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. @@ -982,7 +975,6 @@ in \fBLC_CTYPE\fR determines the locale for interpretation of sequences of bytes of text data a characters, the behavior of character classes used in the expression defined for the \fByesexpr\fR. See \fBlocale\fR(5). .SH EXIT STATUS -.LP The following exit values are returned: .sp .ne 2 @@ -1030,7 +1022,6 @@ File that registers distributed file system packages .RE .SH ATTRIBUTES -.LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -1049,13 +1040,11 @@ Standard See \fBstandards\fR(5). .TE .SH SEE ALSO -.LP \fBchmod\fR(1), \fBcpio\fR(1), \fBsh\fR(1), \fBtest\fR(1), \fBls\fR(1B), \fBacl\fR(5), \fBregex\fR(5), \fBstat\fR(2), \fBumask\fR(2), \fBattributes\fR(5), \fBenviron\fR(5), \fBfsattr\fR(5), \fBlargefile\fR(5), \fBlocale\fR(5), \fBstandards\fR(5) .SH WARNINGS -.LP The following options are obsolete and will not be supported in future releases: .sp @@ -1079,7 +1068,6 @@ format (5120-byte records). .RE .SH NOTES -.LP When using \fBfind\fR to determine files modified within a range of time, use the \fB-mtime\fR argument \fBbefore\fR the \fB-print\fR argument. Otherwise, \fBfind\fR gives all files. diff --git a/usr/src/pkg/manifests/system-test-utiltest.mf b/usr/src/pkg/manifests/system-test-utiltest.mf index 7ebc02a0b1..848daeac78 100644 --- a/usr/src/pkg/manifests/system-test-utiltest.mf +++ b/usr/src/pkg/manifests/system-test-utiltest.mf @@ -55,6 +55,7 @@ dir path=opt/util-tests/tests/files/make_a/a dir path=opt/util-tests/tests/files/make_a/b dir path=opt/util-tests/tests/files/make_a/c dir path=opt/util-tests/tests/files/make_l +dir path=opt/util-tests/tests/find dir path=opt/util-tests/tests/libcustr dir path=opt/util-tests/tests/libnvpair_json dir path=opt/util-tests/tests/libsff @@ -1421,6 +1422,7 @@ file path=opt/util-tests/tests/files/test5 mode=0444 file path=opt/util-tests/tests/files/test6 mode=0444 file path=opt/util-tests/tests/files/test7 mode=0444 file path=opt/util-tests/tests/files/testnl mode=0444 +file path=opt/util-tests/tests/find/findtest mode=0555 file path=opt/util-tests/tests/grep_test mode=0555 file path=opt/util-tests/tests/iconv_test mode=0555 file path=opt/util-tests/tests/libcustr/custr_remove mode=0555 diff --git a/usr/src/test/util-tests/tests/Makefile b/usr/src/test/util-tests/tests/Makefile index 35fd953518..6ccf391395 100644 --- a/usr/src/test/util-tests/tests/Makefile +++ b/usr/src/test/util-tests/tests/Makefile @@ -20,6 +20,6 @@ SUBDIRS = date dis dladm iconv libnvpair_json libsff printf xargs grep_xpg4 SUBDIRS += demangle mergeq workq chown ctf smbios libjedec awk make sleep -SUBDIRS += libcustr +SUBDIRS += libcustr find include $(SRC)/test/Makefile.com diff --git a/usr/src/test/util-tests/tests/find/Makefile b/usr/src/test/util-tests/tests/find/Makefile new file mode 100644 index 0000000000..66e2bab009 --- /dev/null +++ b/usr/src/test/util-tests/tests/find/Makefile @@ -0,0 +1,41 @@ +# +# 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 2020 Joyent, Inc. +# + +include $(SRC)/cmd/Makefile.cmd +include $(SRC)/test/Makefile.com + +ROOTOPTPKG = $(ROOT)/opt/util-tests/tests/find +PROG = findtest + +ROOTPROG = $(PROG:%=$(ROOTOPTPKG)/%) + +all: + +install: $(ROOTPROG) + +clobber: clean + +clean: + +$(CMDS): $(TESTDIR) + +$(ROOTOPTPKG): + $(INS.dir) + +$(ROOTOPTPKG)/%: %.ksh $(ROOTOPTPKG) + $(INS.rename) + +$(ROOTOPTPKG)/%: % $(ROOTOPTPKG) + $(INS.file) diff --git a/usr/src/test/util-tests/tests/find/findtest.ksh b/usr/src/test/util-tests/tests/find/findtest.ksh new file mode 100644 index 0000000000..9e321fb664 --- /dev/null +++ b/usr/src/test/util-tests/tests/find/findtest.ksh @@ -0,0 +1,72 @@ +#!/bin/ksh +# +# 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 2020 Joyent, Inc. +# + +# +# Clearly, grossly incomplete. +# + +export LC_ALL=C.UTF-8 + +set -o pipefail +unalias -a + +find_prog=/usr/bin/find +find_prog_xpg4=/usr/xpg4/bin/find +find_dir="$(mktemp -d -p /tmp/)" +find_exit=0 + +testfind() +{ + exp=$1 + shift + cmd="$@" + + echo "TEST: $cmd" + + out=$(eval $cmd | tr '\n' ',') + + [[ "$exp" = "$out" ]] || { + echo "TEST FAILED: $cmd" >&2 + echo "expected: $exp" >&2 + echo "got: $out" >&2 + find_exit=1 + } +} + +mkdir -p $find_dir/1 +mkdir -p $find_dir/.2 +touch $find_dir/.2/1 +touch $find_dir/.2/c + +testfind "$find_dir/1,$find_dir/.2/1," \ + $find_prog $find_dir -name \"1\" +testfind "$find_dir/1,$find_dir/.2/1," \ + $find_prog $find_dir -path \"*1\" + +cd $find_dir + +testfind "" $find_prog . -name \"*2\" +testfind "./.2," $find_prog_xpg4 . -name \"*2\" +testfind "./.2," $find_prog . -name \".*2\" +testfind "./.2," $find_prog_xpg4 . -name \".*2\" +testfind "./1,./.2/1," $find_prog . -path \"*1\" +testfind "./.2," $find_prog . -path \"*2\" +testfind "./.2,./.2/1,./.2/c," $find_prog . -path \"*2*\" + +cd - +rm -rf $find_dir + +exit $find_exit -- cgit v1.2.3 From 5cbb72a848d670186cc8a950e564d70c7208f889 Mon Sep 17 00:00:00 2001 From: Jason King Date: Wed, 26 Feb 2020 15:24:12 -0600 Subject: OS-7880 Add encryption support to fs-joyent (#250) Reviewed by: Dan McDonald Reviewed by: Mike Gerdts Approved by: Mike Gerdts --- usr/src/cmd/svc/milestone/fs-joyent | 32 ++++++++++++++++++++++++++++---- usr/src/cmd/svc/milestone/joyent-fs.xml | 8 ++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) (limited to 'usr/src/cmd') diff --git a/usr/src/cmd/svc/milestone/fs-joyent b/usr/src/cmd/svc/milestone/fs-joyent index 9082f22e46..f8b4ffb53d 100755 --- a/usr/src/cmd/svc/milestone/fs-joyent +++ b/usr/src/cmd/svc/milestone/fs-joyent @@ -11,7 +11,7 @@ # # -# Copyright (c) 2018, Joyent, Inc. +# Copyright 2020 Joyent, Inc. # set -o xtrace @@ -70,6 +70,24 @@ function mount_zfs echo ${output} 1>&2 } +function unlock_pool +{ + local pool=$1 + + # If the key is already loaded, don't bother trying again + local keystatus="$(zfs get -Hpo value keystatus $pool)" + if [[ "$keystatus" == "available" ]]; then + return + fi + + kbmadm unlock $pool && return + + echo "Failed to unlock $pool; recovery may be required" | \ + tee -a /dev/console >&2 + + exit $SMF_EXIT_ERR_FATAL +} + /bin/bootparams | grep "^noimport=true" >/dev/null if [ $? -ne 0 ]; then # If the zpool doesn't exist, then there's nothing to mount. @@ -87,11 +105,17 @@ if [ $? -ne 0 ]; then for pool in $pools; do zpool import -f $pool - # Due to early, failed attempts to support the filesystem_limits - # feature we now need to ensure the dependent feature is enabled. - zpool set feature@extensible_dataset=enabled $pool + + is_encr="$(zfs get -Hpo value encryption $pool)" + + [[ "$is_encr" != "off" ]] && unlock_pool $pool + + # Due to early, failed attempts to support the filesystem_limits + # feature we now need to ensure the dependent feature is enabled. + zpool set feature@extensible_dataset=enabled $pool if [[ -f /$pool/.system_pool ]]; then SYS_ZPOOL=$pool + [[ "$is_encr" != "off" ]] && kbmadm set-syspool $pool fi done diff --git a/usr/src/cmd/svc/milestone/joyent-fs.xml b/usr/src/cmd/svc/milestone/joyent-fs.xml index 3d004e8d33..f21eae27d8 100644 --- a/usr/src/cmd/svc/milestone/joyent-fs.xml +++ b/usr/src/cmd/svc/milestone/joyent-fs.xml @@ -44,6 +44,14 @@ + + + +