1.1 --- a/usr/src/cmd/svc/svcadm/svcadm.c Fri Jan 28 14:19:52 2011 -0800
1.2 +++ b/usr/src/cmd/svc/svcadm/svcadm.c Fri Feb 11 13:41:27 2011 -0800
1.3 @@ -24,6 +24,10 @@
1.4 */
1.5
1.6 /*
1.7 + * Copyright (c) 2011, Joyent, Inc. All rights reserved.
1.8 + */
1.9 +
1.10 +/*
1.11 * svcadm - request adminstrative actions for service instances
1.12 */
1.13
1.14 @@ -44,6 +48,7 @@
1.15 #include <procfs.h>
1.16 #include <assert.h>
1.17 #include <errno.h>
1.18 +#include <zone.h>
1.19
1.20 #ifndef TEXT_DOMAIN
1.21 #define TEXT_DOMAIN "SUNW_OST_OSCMD"
1.22 @@ -140,7 +145,7 @@
1.23 usage()
1.24 {
1.25 (void) fprintf(stderr, gettext(
1.26 - "Usage: %1$s [-v] [cmd [args ... ]]\n\n"
1.27 + "Usage: %1$s [-v] [-z zone] [cmd [args ... ]]\n\n"
1.28 "\t%1$s enable [-rst] <service> ...\t- enable and online service(s)\n"
1.29 "\t%1$s disable [-st] <service> ...\t- disable and offline service(s)\n"
1.30 "\t%1$s restart <service> ...\t\t- restart specified service(s)\n"
1.31 @@ -2099,16 +2104,40 @@
1.32 if (h == NULL)
1.33 scfdie();
1.34
1.35 + while ((o = getopt(argc, argv, "vz:")) != -1) {
1.36 + switch (o) {
1.37 + case 'v':
1.38 + verbose = 1;
1.39 + break;
1.40 +
1.41 + case 'z': {
1.42 + scf_value_t *zone;
1.43 +
1.44 + if (getzoneid() != GLOBAL_ZONEID)
1.45 + uu_die(gettext("svcadm -z may only be used "
1.46 + "from the global zone\n"));
1.47 +
1.48 + if ((zone = scf_value_create(h)) == NULL)
1.49 + scfdie();
1.50 +
1.51 + if (scf_value_set_astring(zone, optarg) != SCF_SUCCESS)
1.52 + scfdie();
1.53 +
1.54 + if (scf_handle_decorate(h, "zone", zone) != SCF_SUCCESS)
1.55 + uu_die(gettext("invalid zone '%s'\n"), optarg);
1.56 +
1.57 + scf_value_destroy(zone);
1.58 + break;
1.59 + }
1.60 +
1.61 + default:
1.62 + usage();
1.63 + }
1.64 + }
1.65 +
1.66 if (scf_handle_bind(h) == -1)
1.67 uu_die(gettext("Couldn't bind to svc.configd.\n"));
1.68
1.69 - while ((o = getopt(argc, argv, "v")) != -1) {
1.70 - if (o == 'v')
1.71 - verbose = 1;
1.72 - else
1.73 - usage();
1.74 - }
1.75 -
1.76 if (optind >= argc)
1.77 usage();
1.78
2.1 --- a/usr/src/cmd/svc/svcprop/svcprop.c Fri Jan 28 14:19:52 2011 -0800
2.2 +++ b/usr/src/cmd/svc/svcprop/svcprop.c Fri Feb 11 13:41:27 2011 -0800
2.3 @@ -24,7 +24,9 @@
2.4 * Use is subject to license terms.
2.5 */
2.6
2.7 -#pragma ident "%Z%%M% %I% %E% SMI"
2.8 +/*
2.9 + * Copyright (c) 2011, Joyent, Inc. All rights reserved.
2.10 + */
2.11
2.12 /*
2.13 * svcprop - report service configuration properties
2.14 @@ -41,6 +43,7 @@
2.15 #include <unistd.h>
2.16 #include <strings.h>
2.17 #include <assert.h>
2.18 +#include <zone.h>
2.19
2.20 #ifndef TEXT_DOMAIN
2.21 #define TEXT_DOMAIN "SUNW_OST_OSCMD"
2.22 @@ -140,10 +143,10 @@
2.23 usage()
2.24 {
2.25 (void) fprintf(stderr, gettext("Usage: %1$s [-fqtv] "
2.26 - "[-C | -c | -s snapshot] "
2.27 + "[-C | -c | -s snapshot] [-z zone] "
2.28 "[-p [name/]name]... \n"
2.29 " {FMRI | pattern}...\n"
2.30 - " %1$s -w [-fqtv] [-p [name/]name] "
2.31 + " %1$s -w [-fqtv] [-z zone] [-p [name/]name] "
2.32 "{FMRI | pattern}\n"), uu_getpname());
2.33 exit(UU_EXIT_USAGE);
2.34 }
2.35 @@ -1012,7 +1015,11 @@
2.36
2.37 prop_list = uu_list_create(prop_pool, NULL, 0);
2.38
2.39 - while ((c = getopt(argc, argv, "Ccfp:qs:tvw")) != -1) {
2.40 + hndl = scf_handle_create(SCF_VERSION);
2.41 + if (hndl == NULL)
2.42 + scfdie();
2.43 +
2.44 + while ((c = getopt(argc, argv, "Ccfp:qs:tvwz:")) != -1) {
2.45 switch (c) {
2.46 case 'C':
2.47 if (cflag || sflag || wait)
2.48 @@ -1064,6 +1071,27 @@
2.49 wait = 1;
2.50 break;
2.51
2.52 + case 'z': {
2.53 + scf_value_t *zone;
2.54 + scf_handle_t *h = hndl;
2.55 +
2.56 + if (getzoneid() != GLOBAL_ZONEID)
2.57 + uu_die(gettext("svcprop -z may only be used "
2.58 + "from the global zone\n"));
2.59 +
2.60 + if ((zone = scf_value_create(h)) == NULL)
2.61 + scfdie();
2.62 +
2.63 + if (scf_value_set_astring(zone, optarg) != SCF_SUCCESS)
2.64 + scfdie();
2.65 +
2.66 + if (scf_handle_decorate(h, "zone", zone) != SCF_SUCCESS)
2.67 + uu_die(gettext("invalid zone '%s'\n"), optarg);
2.68 +
2.69 + scf_value_destroy(zone);
2.70 + break;
2.71 + }
2.72 +
2.73 case '?':
2.74 switch (optopt) {
2.75 case 'p':
2.76 @@ -1090,9 +1118,6 @@
2.77 max_scf_fmri_length == -1)
2.78 scfdie();
2.79
2.80 - hndl = scf_handle_create(SCF_VERSION);
2.81 - if (hndl == NULL)
2.82 - scfdie();
2.83 if (scf_handle_bind(hndl) == -1)
2.84 die(gettext("Could not connect to configuration repository: "
2.85 "%s.\n"), scf_strerror(scf_error()));
3.1 --- a/usr/src/man/man1/svcprop.1 Fri Jan 28 14:19:52 2011 -0800
3.2 +++ b/usr/src/man/man1/svcprop.1 Fri Feb 11 13:41:27 2011 -0800
3.3 @@ -9,13 +9,14 @@
3.4 .SH SYNOPSIS
3.5 .LP
3.6 .nf
3.7 -\fBsvcprop\fR [\fB-fqtv\fR] [\fB-C\fR | \fB-c\fR | \fB-s\fR \fIsnapshot\fR] [\fB-p\fR [\fIname\fR/]\fIname\fR]...
3.8 +\fBsvcprop\fR [\fB-fqtv\fR] [\fB-C\fR | \fB-c\fR | \fB-s\fR \fIsnapshot\fR]
3.9 + [\fB-z\fR \fIzone\fR] [\fB-p\fR [\fIname\fR/]\fIname\fR]...
3.10 {\fIFMRI\fR | \fIpattern\fR}...
3.11 .fi
3.12
3.13 .LP
3.14 .nf
3.15 -\fBsvcprop\fR \fB-w\fR [\fB-fqtv\fR] [\fB-p\fR [\fIname\fR/]\fIname\fR] {\fIFMRI\fR | \fIpattern\fR}
3.16 +\fBsvcprop\fR \fB-w\fR [\fB-fqtv\fR] [\fB-z\fR \fIzone\fR] [\fB-p\fR [\fIname\fR/]\fIname\fR] {\fIFMRI\fR | \fIpattern\fR}
3.17 .fi
3.18
3.19 .SH DESCRIPTION
3.20 @@ -186,6 +187,17 @@
3.21 message is printed and no action is taken. The -C option is implied.
3.22 .RE
3.23
3.24 +.sp
3.25 +.ne 2
3.26 +.mk
3.27 +.na
3.28 +\fB-z\fR \fIzone\fR
3.29 +.ad
3.30 +.RS 14n
3.31 +.rt
3.32 +Uses properties from the service or instance in the specified \fIzone\fR.
3.33 +This option is only applicable from the global zone, see \fBzones\fR(5).
3.34 +
3.35 .SH OPERANDS
3.36 .sp
3.37 .LP
3.38 @@ -426,4 +438,5 @@
3.39 .LP
3.40 \fBsvcs\fR(1), \fBinetd\fR(1M), \fBsvcadm\fR(1M), \fBsvccfg\fR(1M),
3.41 \fBsvc.startd\fR(1M), \fBservice_bundle\fR(4), \fBattributes\fR(5),
3.42 -\fBfnmatch\fR(5), \fBsmf\fR(5), \fBsmf_method\fR(5), \fBsmf_security\fR(5)
3.43 +\fBfnmatch\fR(5), \fBsmf\fR(5), \fBsmf_method\fR(5), \fBsmf_security\fR(5),
3.44 +\fBzones\fR(5)
4.1 --- a/usr/src/man/man1m/svcadm.1m Fri Jan 28 14:19:52 2011 -0800
4.2 +++ b/usr/src/man/man1m/svcadm.1m Fri Feb 11 13:41:27 2011 -0800
4.3 @@ -9,32 +9,32 @@
4.4 .SH SYNOPSIS
4.5 .LP
4.6 .nf
4.7 -\fB/usr/sbin/svcadm\fR [\fB-v\fR] enable [\fB-rst\fR] {\fIFMRI\fR | \fIpattern\fR}...
4.8 +\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] enable [\fB-rst\fR] {\fIFMRI\fR | \fIpattern\fR}...
4.9 .fi
4.10
4.11 .LP
4.12 .nf
4.13 -\fB/usr/sbin/svcadm\fR [\fB-v\fR] disable [\fB-st\fR] {\fIFMRI\fR | \fIpattern\fR}...
4.14 +\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] disable [\fB-st\fR] {\fIFMRI\fR | \fIpattern\fR}...
4.15 .fi
4.16
4.17 .LP
4.18 .nf
4.19 -\fB/usr/sbin/svcadm\fR [\fB-v\fR] restart {\fIFMRI\fR | \fIpattern\fR}...
4.20 +\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] restart {\fIFMRI\fR | \fIpattern\fR}...
4.21 .fi
4.22
4.23 .LP
4.24 .nf
4.25 -\fB/usr/sbin/svcadm\fR [\fB-v\fR] refresh {\fIFMRI\fR | \fIpattern\fR}...
4.26 +\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] refresh {\fIFMRI\fR | \fIpattern\fR}...
4.27 .fi
4.28
4.29 .LP
4.30 .nf
4.31 -\fB/usr/sbin/svcadm\fR [\fB-v\fR] clear {\fIFMRI\fR | \fIpattern\fR}...
4.32 +\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] clear {\fIFMRI\fR | \fIpattern\fR}...
4.33 .fi
4.34
4.35 .LP
4.36 .nf
4.37 -\fB/usr/sbin/svcadm\fR [\fB-v\fR] mark [\fB-It\fR] \fIinstance_state\fR
4.38 +\fB/usr/sbin/svcadm\fR [\fB-v\fR] [\fB-z\fR \fIzone\fR] mark [\fB-It\fR] \fIinstance_state\fR
4.39 {\fIFMRI\fR | \fIpattern\fR}...
4.40 .fi
4.41
4.42 @@ -60,11 +60,23 @@
4.43 .na
4.44 \fB\fB-v\fR\fR
4.45 .ad
4.46 -.RS 6n
4.47 +.RS 20n
4.48 .rt
4.49 Print actions verbosely to standard output.
4.50 .RE
4.51
4.52 +.sp
4.53 +.ne 2
4.54 +.mk
4.55 +.na
4.56 +\fB-z\fR \fIzone\fR
4.57 +.ad
4.58 +.RS 20n
4.59 +.rt
4.60 +Administer services in the specified zone. This option is only applicable
4.61 +from the global zone, see \fBzones\fR(5).
4.62 +.RE
4.63 +
4.64 .SH SUBCOMMANDS
4.65 .SS "Common Operations"
4.66 .sp
4.67 @@ -520,7 +532,7 @@
4.68 .LP
4.69 \fBsvcprop\fR(1), \fBsvcs\fR(1), \fBinetd\fR(1M), \fBinit\fR(1M),
4.70 \fBsvccfg\fR(1M), \fBsvc.startd\fR(1M), \fBlibscf\fR(3LIB), \fBcontract\fR(4),
4.71 -\fBattributes\fR(5), \fBsmf\fR(5), \fBsmf_security\fR(5)
4.72 +\fBattributes\fR(5), \fBsmf\fR(5), \fBsmf_security\fR(5), \fBzones\fR(5)
4.73 .SH NOTES
4.74 .sp
4.75 .LP