summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/cmd/svc/svccfg/svccfg_libscf.c27
-rw-r--r--usr/src/man/man1m/svccfg.1m9
2 files changed, 33 insertions, 3 deletions
diff --git a/usr/src/cmd/svc/svccfg/svccfg_libscf.c b/usr/src/cmd/svc/svccfg/svccfg_libscf.c
index fa9966b971..ab1cd71ab2 100644
--- a/usr/src/cmd/svc/svccfg/svccfg_libscf.c
+++ b/usr/src/cmd/svc/svccfg/svccfg_libscf.c
@@ -10868,6 +10868,10 @@ int
lscf_service_export(char *fmri, const char *filename, int flags)
{
struct export_args args;
+ char *fmridup;
+ const char *scope, *svc, *inst;
+ size_t cblen = 3 * max_scf_name_len;
+ char *canonbuf = alloca(cblen);
int ret, err;
lscf_prep_hndl();
@@ -10876,6 +10880,29 @@ lscf_service_export(char *fmri, const char *filename, int flags)
args.filename = filename;
args.flags = flags;
+ /*
+ * If some poor user has passed an exact instance FMRI, of the sort
+ * one might cut and paste from svcs(1) or an error message, warn
+ * and chop off the instance instead of failing.
+ */
+ fmridup = alloca(strlen(fmri) + 1);
+ (void) strcpy(fmridup, fmri);
+ if (strncmp(fmridup, SCF_FMRI_SVC_PREFIX,
+ sizeof (SCF_FMRI_SVC_PREFIX) -1) == 0 &&
+ scf_parse_svc_fmri(fmridup, &scope, &svc, &inst, NULL, NULL) == 0 &&
+ inst != NULL) {
+ (void) strlcpy(canonbuf, "svc:/", cblen);
+ if (strcmp(scope, SCF_FMRI_LOCAL_SCOPE) != 0) {
+ (void) strlcat(canonbuf, "/", cblen);
+ (void) strlcat(canonbuf, scope, cblen);
+ }
+ (void) strlcat(canonbuf, svc, cblen);
+ fmri = canonbuf;
+
+ warn(gettext("Only services may be exported; ignoring "
+ "instance portion of argument.\n"));
+ }
+
err = 0;
if ((ret = scf_walk_fmri(g_hndl, 1, (char **)&fmri,
SCF_WALK_SERVICE | SCF_WALK_NOINSTANCE, export_callback,
diff --git a/usr/src/man/man1m/svccfg.1m b/usr/src/man/man1m/svccfg.1m
index 972967267b..c2e2cf28cd 100644
--- a/usr/src/man/man1m/svccfg.1m
+++ b/usr/src/man/man1m/svccfg.1m
@@ -1,5 +1,6 @@
'\" te
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright 2012, Joyent, Inc. All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
@@ -261,9 +262,11 @@ Without the \fB-a\fR option, property groups containing protected information
\fB-a\fR option is specified, all values will be archived. An error results if
there are insufficient privileges to read these values.
.sp
-Note that \fBexport\fR requires a service FMRI. If you specify an instance
-(including an abbreviation, such as \fBapache2\fR or \fBsendmail\fR, that
-specifies an instance), the command fails.
+Note that \fBexport\fR requires a service FMRI. To ease the use of arguments
+cut and pasted from other command output, if you specify a complete
+instance FMRI, the entire corresponding service including all instances
+is exported and a warning is issued. If you specify an abbreviation, such as
+\fBapache2\fR or \fBsendmail\fR, that specifies an instance, the command fails.
.RE
.sp