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/cmd | |
parent | 1a902ef8628b0dffd6df5442354ab59bb8530962 (diff) | |
download | illumos-gate-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/cmd')
-rw-r--r-- | usr/src/cmd/svc/svccfg/svccfg_libscf.c | 27 |
1 files changed, 27 insertions, 0 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, |