diff options
author | Keith M Wesolowski <wesolows@foobazco.org> | 2012-12-26 04:51:51 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2015-02-20 15:57:22 -0800 |
commit | bfce16ba853698e8a82133cf3ddb3ff143d14289 (patch) | |
tree | fb15e9734f60f3778f481fd2c87b06b36ad4f89c /usr/src | |
parent | 1a902ef8628b0dffd6df5442354ab59bb8530962 (diff) | |
download | illumos-joyent-bfce16ba853698e8a82133cf3ddb3ff143d14289.tar.gz |
5627 svccfg export should accept instance FMRIs
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/svc/svccfg/svccfg_libscf.c | 27 | ||||
-rw-r--r-- | usr/src/man/man1m/svccfg.1m | 23 |
2 files changed, 33 insertions, 17 deletions
diff --git a/usr/src/cmd/svc/svccfg/svccfg_libscf.c b/usr/src/cmd/svc/svccfg/svccfg_libscf.c index b43dedbd81..5a96e5eac4 100644 --- a/usr/src/cmd/svc/svccfg/svccfg_libscf.c +++ b/usr/src/cmd/svc/svccfg/svccfg_libscf.c @@ -10630,6 +10630,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(); @@ -10638,6 +10642,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..cbb1a7ef29 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] @@ -23,7 +24,6 @@ svccfg \- import, export, and modify service configurations .fi .SH DESCRIPTION -.sp .LP The \fBsvccfg\fR command manipulates data in the service configuration repository. \fBsvccfg\fR can be invoked interactively, with an individual @@ -36,7 +36,6 @@ effect for that service until the next time the service instance is refreshed. See the \fBrefresh\fR subcommand on the \fBsvcadm\fR(1M) man page for more details. .SH OPTIONS -.sp .LP The following options are supported: .sp @@ -71,7 +70,6 @@ Verbose. .RE .SH SUBCOMMANDS -.sp .LP Subcommands are divided into the categories specified in the subsections that follow. @@ -123,7 +121,6 @@ Abbreviated forms of \fIFMRI\fRs are unstable, and should not be used in scripts or other permanent tools. If a pattern matches more than one instance or service, an error message is printed and no action is taken. .SS "General Subcommands" -.sp .ne 2 .na \fB\fBend\fR\fR @@ -188,7 +185,6 @@ Turns off verbose mode. .RE .SS "Service Profile Subcommands" -.sp .ne 2 .na \fB\fBapply\fR [\fB-n\fR] \fIfile\fR\fR @@ -224,7 +220,6 @@ a file. .RE .SS "Service Manifest Subcommands" -.sp .ne 2 .na \fB\fBarchive\fR [\fB-a\fR]\fR @@ -261,9 +256,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 @@ -357,7 +354,6 @@ See \fBsmf_template\fR(5) for a description of templates. .RE .SS "Entity Selection, Modification, and Navigation Subcommands" -.sp .LP An "entity" refers to a scope, service, or service instance. .sp @@ -425,7 +421,6 @@ The parent of the current selection becomes the current selection. .RE .SS "Property Inspection and Modification Subcommands" -.sp .ne 2 .na \fB\fBaddpg\fR \fIname\fR \fItype\fR [\fIflags\fR]\fR @@ -636,7 +631,6 @@ modify properties. .RE .SS "Snapshot Navigation and Selection Subcommands" -.sp .ne 2 .na \fB\fBlistsnap\fR\fR @@ -673,7 +667,6 @@ read-only. .RE .SS "Instance Subcommands" -.sp .ne 2 .na \fB\fBrefresh\fR\fR @@ -794,7 +787,6 @@ ttymon/label astring console .sp .SH ENVIRONMENTAL VARIABLES -.sp .ne 2 .na \fBEDITOR\fR @@ -806,7 +798,6 @@ editor is \fBvi\fR(1). .RE .SH EXIT STATUS -.sp .LP The following exit values are returned: .sp @@ -841,7 +832,6 @@ Invalid command line options were specified. .RE .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -861,7 +851,6 @@ Interface Stability See below. The interactive output is Uncommitted. The invocation and non-interactive output are Committed. .SH SEE ALSO -.sp .LP \fBsvcprop\fR(1), \fBsvcs\fR(1), \fBsvcadm\fR(1M), \fBsvc.configd\fR(1M), \fBlibscf\fR(3LIB), \fBlibumem\fR(3LIB), \fBscf_service_add_pg\fR(3SCF), |