15723 - Teach AI to use new SMF based System Configuration framework for configuring user and root accounts
15410 - The installer delivered SMF manifests should be relocated to /lib/svc/manifest
13737 - Automated Installer needs support for setting terminal type from AI manifest
--- a/usr/src/Targetdirs Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/Targetdirs Tue Jul 06 09:11:29 2010 +0200
@@ -39,19 +39,17 @@
/mnt/misc \
/sbin \
/usr \
- /usr/share \
- /var \
- /var/svc \
- /var/svc/manifest \
- /var/svc/manifest/application \
- /var/svc/manifest/system \
- /var/svc/manifest/system/device \
- /var/svc/manifest/system/filesystem \
- /var/svc/manifest/system/install
+ /usr/share
ROOT.BIN= \
/lib \
/lib/svc \
+ /lib/svc/manifest \
+ /lib/svc/manifest/application \
+ /lib/svc/manifest/system \
+ /lib/svc/manifest/system/device \
+ /lib/svc/manifest/system/filesystem \
+ /lib/svc/manifest/system/install \
/lib/svc/method \
/lib/svc/share \
/usr/bin \
--- a/usr/src/cmd/Makefile Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/cmd/Makefile Tue Jul 06 09:11:29 2010 +0200
@@ -29,7 +29,8 @@
include $(SRC)/Makefile.master
-SUBDIRS= auto-install gui-install gui-aux installadm rbac slim-install
+SUBDIRS= auto-install gui-install gui-aux installadm rbac slim-install \
+ system-config
PYTHONSUBDIRS= ai-webserver beadm distro_const text-install
TOOLSSUBDIRS= install-tools
--- a/usr/src/cmd/Makefile.cmd Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/cmd/Makefile.cmd Tue Jul 06 09:11:29 2010 +0200
@@ -29,11 +29,11 @@
# Definitions of common installation directories
ROOTADMINBIN = $(ROOT)/usr/snadm/bin
ROOTEXECATTR = $(ROOT)/etc/security/exec_attr.d
+ROOTLIBSVCMANIFEST = $(ROOT)/lib/svc/manifest
ROOTLIBSVCMETHOD = $(ROOT)/lib/svc/method
ROOTLIBSVCSHARE = $(ROOT)/lib/svc/share
-ROOTMANIFEST = $(ROOTVAR)/svc/manifest
-ROOTMANAPP = $(ROOTMANIFEST)/application
-ROOTMANSYS = $(ROOTMANIFEST)/system
+ROOTMANAPP = $(ROOTLIBSVCMANIFEST)/application
+ROOTMANSYS = $(ROOTLIBSVCMANIFEST)/system
ROOTMANSYSFIL = $(ROOTMANSYS)/filesystem
ROOTMANSYSSVC = $(ROOTMANSYS)/svc
ROOTMANSYSINS = $(ROOTMANSYS)/install
--- a/usr/src/cmd/Makefile.targ Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/cmd/Makefile.targ Tue Jul 06 09:11:29 2010 +0200
@@ -35,7 +35,7 @@
$(ROOTEXECATTR)/%: exec_attr.%
$(INS.rename)
-$(ROOTMANIFEST)/%: %
+$(ROOTLIBSVCMANIFEST)/%: %
$(INS.file)
$(ROOTPROFATTR):
--- a/usr/src/cmd/auto-install/auto_install.c Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/cmd/auto-install/auto_install.c Tue Jul 06 09:11:29 2010 +0200
@@ -119,7 +119,6 @@
char buf[MAXPATHLEN + 1] = "";
va_start(ap, fmt);
- /*LINTED*/
(void) vsnprintf(buf, MAXPATHLEN+1, fmt, ap);
(void) ls_write_dbg_message("AI", dbg_lvl, buf);
va_end(ap);
@@ -136,7 +135,6 @@
char buf[MAXPATHLEN + 1] = "";
va_start(ap, fmt);
- /*LINTED*/
(void) vsnprintf(buf, MAXPATHLEN+1, fmt, ap);
(void) ls_write_log_message("AI", buf);
va_end(ap);
@@ -280,6 +278,18 @@
}
if (strstr(buf, SC_MANIFEST_BEGIN_MARKER) != NULL) {
writing_sc_manifest = B_TRUE;
+
+ /*
+ * XML is pretty strict about format of XML prolog.
+ * It is optional, but if present, no leading comments
+ * or whitespace characters are allowed.
+ * Assure this by replacing the whole first line
+ * of SC manifest with following string:
+ * "<?xml version='1.0'?>\n"
+ */
+ fputs(SC_MANIFEST_BEGIN_MARKER, scfp);
+ fputs("\n", scfp);
+ continue;
}
if (writing_ai_manifest) {
if (strstr(buf, AI_MANIFEST_END_MARKER) != NULL) {
@@ -1002,82 +1012,6 @@
goto error_ret;
}
- /* encrypted root password must be present, or error */
- if (asp.rootpass == NULL) {
- auto_log_print(gettext(
- "No root password was provided in the SC manifest. "
- "Installation will not proceed.\n"));
- goto error_ret;
- }
- if (nvlist_add_string(install_attr, OM_ATTR_ROOT_PASSWORD,
- asp.rootpass) != 0) {
- auto_log_print(gettext("Setting of OM_ATTR_ROOT_PASSWORD"
- " failed\n"));
- goto error_ret;
- }
-
- /*
- * username, userpass - treated as optional here. Valid cases:
- * username != NULL, password != NULL
- * username != NULL, password == NULL
- * username == NULL, password == NULL
- *
- */
-
- if (asp.username != NULL) {
- /*
- * Add user name. Could be user wants no password set.
- */
- if (nvlist_add_string(install_attr, OM_ATTR_LOGIN_NAME,
- asp.username) != 0) {
- auto_log_print(gettext(
- "Setting of OM_ATTR_LOGIN_NAME failed\n"));
- goto error_ret;
- }
- if (asp.userpass != NULL) {
- if (nvlist_add_string(install_attr,
- OM_ATTR_USER_PASSWORD, asp.userpass) != 0) {
- auto_log_print(gettext("Setting "
- "of OM_ATTR_USER_PASSWORD failed\n"));
- goto error_ret;
- }
- } else {
- /*
- * Let user know password was not supplied. This
- * is not a failure, simply a warning. It will be set
- * later in the install to an empty string.
- */
- char *errmsg = gettext("The username is specified "
- "without a corresponding password "
- "in the SC manifest. User will be created "
- "without a password. (keyword, 'userpass')\n");
-
- auto_log_print(errmsg);
- auto_debug_print(AUTO_DBGLVL_WARN, errmsg);
- }
- } else if (asp.userpass != NULL) {
- /*
- * Let user know that password without user definition
- * is invalid. Return error.
- */
- char *errmsg = gettext("The password is specified "
- "without a corresponding username in the "
- "SC manifest. (keyword, 'username')\n");
-
- auto_log_print(errmsg);
- auto_debug_print(AUTO_DBGLVL_ERR, errmsg);
- goto error_ret;
- }
-
- /* user's display name - see gcos-field in passwd(4) */
- if (asp.userdesc != NULL &&
- nvlist_add_string(install_attr, OM_ATTR_USER_NAME,
- asp.userdesc) != 0) {
- auto_log_print(gettext("Setting of OM_ATTR_USER_NAME"
- " failed\n"));
- goto error_ret;
- }
-
/*
* if no hostname provided in SC manifest, use "opensolaris"
*/
--- a/usr/src/cmd/auto-install/auto_install.h Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/cmd/auto-install/auto_install.h Tue Jul 06 09:11:29 2010 +0200
@@ -63,9 +63,6 @@
#define SC_MANIFEST_BEGIN_MARKER "<?xml version='1.0'?>"
#define SC_MANIFEST_END_MARKER "</service_bundle>"
#define SC_PROPVAL_MARKER "<propval"
-#define AUTO_PROPERTY_USERNAME "username"
-#define AUTO_PROPERTY_USERPASS "userpass"
-#define AUTO_PROPERTY_USERDESC "description"
#define AUTO_PROPERTY_ROOTPASS "rootpass"
#define AUTO_PROPERTY_TIMEZONE "timezone"
#define AUTO_PROPERTY_HOSTNAME "hostname"
@@ -73,6 +70,7 @@
#define KEYWORD_SIZE 256
#define VALUE_SIZE 256
#define AUTO_MAX_ACTION_LEN 32 /* delete, create, preserve... */
+#define MAX_SHELLCMD_LEN 2048
/*
* File that lists which packages need to be installed
@@ -88,6 +86,9 @@
#define AI_MANIFEST_SCHEMA "/tmp/ai_manifest.rng"
#define SC_MANIFEST_FILE "/tmp/sc_manifest.xml"
+/* Script for converting legacy System Configuration manifest to new format */
+#define SC_CONVERSION_SCRIPT "/usr/lib/install/sc_conv.ksh"
+
#define TEXT_DOMAIN "SUNW_INSTALL_AUTOINSTALL"
#define CONVERT_UNITS_TO_TEXT(units) \
@@ -345,10 +346,6 @@
} auto_dump_device_info;
typedef struct {
- char *username;
- char *userpass;
- char *userdesc;
- char *rootpass;
char *timezone;
char *hostname;
} auto_sc_params;
--- a/usr/src/cmd/auto-install/auto_parse.c Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/cmd/auto-install/auto_parse.c Tue Jul 06 09:11:29 2010 +0200
@@ -40,6 +40,44 @@
static char *manifest_filename;
/*
+ * Function to execute shell commands in a thread-safe manner. Output from
+ * stdout is captured in install log file.
+ *
+ * Parameters:
+ * cmd - the command to execute
+ *
+ * Return:
+ * -1 if popen() failed, otherwise exit code returned by command
+ *
+ * Status:
+ * private
+ */
+static int
+ai_exec_cmd(char *cmd)
+{
+ FILE *p;
+ char buf[MAX_SHELLCMD_LEN];
+
+ auto_debug_print(AUTO_DBGLVL_INFO, "exec cmd: %s\n", cmd);
+
+ if ((p = popen(cmd, "r")) == NULL) {
+ auto_debug_print(AUTO_DBGLVL_ERR,
+ "Could not execute following command: %s.\n", cmd);
+
+ return (-1);
+ }
+
+ /*
+ * capture stdout for debugging purposes
+ */
+
+ while (fgets(buf, sizeof (buf), p) != NULL)
+ auto_debug_print(AUTO_DBGLVL_ERR, " %s", buf);
+
+ return (WEXITSTATUS(pclose(p)));
+}
+
+/*
* Dump errors found during syntactic validation of AI manifest -
* capture stdout and stderr of xmllint(1M) called with following parameters:
*
@@ -52,10 +90,8 @@
static int
dump_ai_manifest_errors(char *manifest, char *schema)
{
- FILE *p;
char *cmd;
size_t cmd_ln;
- char buf[MAXPATHLEN];
int ret;
/* calculate size of command string - account for string terminator */
@@ -74,20 +110,7 @@
(void) snprintf(cmd, cmd_ln,
"/usr/bin/xmllint --noout --relaxng %s %s 2>&1", schema, manifest);
- auto_debug_print(AUTO_DBGLVL_INFO, "exec cmd: %s\n", cmd);
-
- if ((p = popen(cmd, "r")) == NULL) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "Could not execute following command: %s\n", cmd);
-
- free(cmd);
- return (-1);
- }
-
- while (fgets(buf, sizeof (buf), p) != NULL)
- auto_debug_print(AUTO_DBGLVL_ERR, " %s", buf);
-
- ret = WEXITSTATUS(pclose(p));
+ ret = ai_exec_cmd(cmd);
/*
* The validation is expected to fail - command returns
@@ -1177,16 +1200,7 @@
token = strtok(str, " ");
while ((token = strtok(NULL, " ")) != NULL) {
- if (strstr(token, AUTO_PROPERTY_USERNAME) != NULL) {
- strlcpy(keyword, AUTO_PROPERTY_USERNAME, KEYWORD_SIZE);
- break;
- } else if (strstr(token, AUTO_PROPERTY_USERPASS) != NULL) {
- strlcpy(keyword, AUTO_PROPERTY_USERPASS, KEYWORD_SIZE);
- break;
- } else if (strstr(token, AUTO_PROPERTY_USERDESC) != NULL) {
- strlcpy(keyword, AUTO_PROPERTY_USERDESC, KEYWORD_SIZE);
- break;
- } else if (strstr(token, AUTO_PROPERTY_ROOTPASS) != NULL) {
+ if (strstr(token, AUTO_PROPERTY_ROOTPASS) != NULL) {
strlcpy(keyword, AUTO_PROPERTY_ROOTPASS, KEYWORD_SIZE);
break;
} else if (strstr(token, AUTO_PROPERTY_TIMEZONE) != NULL) {
@@ -1198,9 +1212,15 @@
}
}
+ /*
+ * Tolerate unrecognized SMF properties, they might belong to SMF
+ * services which will process those properties later during first boot.
+ */
+
if (*keyword == '\0') {
- return (AUTO_INSTALL_FAILURE);
+ return (AUTO_INSTALL_SUCCESS);
}
+
while ((token = strtok(NULL, " ")) != NULL) {
char *pkeyword_value, *pbeg, *pend;
@@ -1224,15 +1244,6 @@
return (AUTO_INSTALL_FAILURE);
*pend = '\0';
if (strlcpy(value, ++pbeg, VALUE_SIZE) >= VALUE_SIZE) {
- if (strcmp(keyword, AUTO_PROPERTY_ROOTPASS) == 0 ||
- strcmp(keyword, AUTO_PROPERTY_USERPASS) == 0) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "A password (%s) in the SC manifest is "
- "too long (>%d bytes). Shorten password "
- "and retry installation.\n",
- keyword, VALUE_SIZE);
- return (AUTO_INSTALL_FAILURE);
- }
auto_debug_print(AUTO_DBGLVL_ERR,
"SC manifest value for %s is too long (>%d bytes) "
"and will be truncated to |%s|\n",
@@ -1251,11 +1262,13 @@
int
auto_parse_sc_manifest(char *profile_file, auto_sc_params *sp)
{
- FILE *profile_fp;
- char line[BUFSIZ];
- char keyword[KEYWORD_SIZE];
- char value[VALUE_SIZE];
- int ret;
+ FILE *profile_fp;
+ char line[BUFSIZ];
+ char keyword[KEYWORD_SIZE];
+ char value[VALUE_SIZE];
+ int ret;
+ boolean_t is_legacy_sc_manifest = B_FALSE;
+ char cmd[MAX_SHELLCMD_LEN];
profile_fp = fopen(profile_file, "r");
if (profile_fp == NULL) {
@@ -1276,6 +1289,15 @@
" manifest\n", keyword);
return (AUTO_INSTALL_FAILURE);
+ } else if (keyword[0] == '\0') {
+ /*
+ * Tolerate unrecognized SMF properties, they
+ * might belong to SMF services which will
+ * process those properties later during
+ * first boot.
+ */
+
+ continue;
}
/*
@@ -1304,31 +1326,73 @@
return (AUTO_INSTALL_FAILURE);
}
-
- if (strcmp(keyword, AUTO_PROPERTY_USERNAME) == 0) {
- sp->username = strdup(value);
- } else if (strcmp(keyword,
- AUTO_PROPERTY_USERDESC) == 0) {
- sp->userdesc = strdup(value);
- } else if (strcmp(keyword,
- AUTO_PROPERTY_USERPASS) == 0) {
- sp->userpass = strdup(value);
- } else if (strcmp(keyword,
+ if (strcmp(keyword,
AUTO_PROPERTY_ROOTPASS) == 0) {
- sp->rootpass = strdup(value);
+ is_legacy_sc_manifest = B_TRUE;
} else if (strcmp(keyword,
AUTO_PROPERTY_TIMEZONE) == 0) {
sp->timezone = strdup(value);
} else if (strcmp(keyword,
AUTO_PROPERTY_HOSTNAME) == 0) {
sp->hostname = strdup(value);
- } else
+ } else {
auto_debug_print(AUTO_DBGLVL_ERR,
"unrecognized SC manifest keyword "
"%s ignored\n", keyword);
+ }
}
}
fclose(profile_fp);
+
+ /*
+ * If System Configuration has legacy format, convert it to new format
+ */
+ if (is_legacy_sc_manifest) {
+ auto_log_print(gettext(
+ "Legacy System Configuration manifest provided, an attempt"
+ " will be made to convert it to the latest format.\n"));
+ auto_log_print(gettext(
+ "Please be aware that support for the legacy format can be "
+ "removed at any time without prior notice.\n"));
+ auto_log_print(gettext(
+ "Thus it is strongly recommended that the latest format "
+ "of the System Configuration manifest be used.\n"));
+
+ /* Create copy of legacy manifest for purposes of conversion */
+ (void) snprintf(cmd, sizeof (cmd),
+ "/usr/bin/cp %s %s.legacy 2>&1 1>/dev/null",
+ profile_file, profile_file);
+
+ ret = ai_exec_cmd(cmd);
+
+ if (ret != 0) {
+ auto_debug_print(AUTO_DBGLVL_ERR,
+ "Could not create a copy of the legacy System"
+ " Configuration manifest, err=%d.\n", ret);
+
+ return (AUTO_INSTALL_FAILURE);
+ }
+
+ /* Now convert SC manifest */
+ (void) snprintf(cmd, sizeof (cmd),
+ SC_CONVERSION_SCRIPT" %s.legacy %s 2>&1 1>/dev/null",
+ profile_file, profile_file);
+
+ ret = ai_exec_cmd(cmd);
+
+ if (ret != 0) {
+ auto_debug_print(AUTO_DBGLVL_ERR,
+ "Could not convert the legacy System Configuration"
+ " manifest to the new format, err=%d.\n", ret);
+
+ return (AUTO_INSTALL_FAILURE);
+ }
+ } else {
+ auto_log_print(gettext(
+ "Detected the latest format of System Configuration"
+ " manifest.\n"));
+ }
+
return (AUTO_INSTALL_SUCCESS);
}
--- a/usr/src/cmd/auto-install/default.xml Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/cmd/auto-install/default.xml Tue Jul 06 09:11:29 2010 +0200
@@ -79,19 +79,44 @@
<sc_embedded_manifest name = "AI">
<!-- <?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
- <service_bundle type="profile" name="name">
- <service name="ai_properties" version="1" type="service">
+ <service_bundle type="profile" name="system configuration">
+ <service name="system/install/config" version="1" type="service">
<instance name="default" enabled="true">
- <property_group name="ai" type="application">
- <propval name="username" type="astring" value="jack"/>
- <propval name="userpass" type="astring" value="9Nd/cwBcNWFZg"/>
+ <property_group name="user_account" type="application">
+ <propval name="login" type="astring" value="jack"/>
+ <propval name="password" type="astring" value="9Nd/cwBcNWFZg"/>
<propval name="description" type="astring" value="default_user"/>
- <propval name="rootpass" type="astring" value="$5$VgppCOxA$ycFmYW4ObRRHhtsGEygDdexk5bugqgSiaSR9niNCouC"/>
- <propval name="timezone" type="astring" value="US/Pacific"/>
+ <propval name="shell" type="astring" value="/usr/bin/bash"/>
+ <propval name="uid" type='count' value='101'/>
+ <propval name="gid" type='count' value='10'/>
+ <propval name="type" type="astring" value="normal"/>
+ <propval name="roles" type="astring" value="root"/>
+ </property_group>
+
+ <property_group name="root_account" type="application">
+ <propval name="password" type="astring" value="$5$VgppCOxA$ycFmYW4ObRRHhtsGEygDdexk5bugqgSiaSR9niNCouC"/>
+ <propval name="type" type="astring" value="role"/>
+ </property_group>
+
+ <property_group name="other_sc_params" type="application">
+ <propval name="timezone" type="astring" value="GMT"/>
+ <propval name="hostname" type="astring" value="opensolaris"/>
</property_group>
</instance>
- </service>
+ </service>
+
+ <service name="system/console-login" version="1" type="service">
+ <property_group name="ttymon" type="application">
+ <propval name="terminal_type" type="astring" value="sun"/>
+ </property_group>
+ </service>
+
+ <service name="network/physical" version="1" type="service">
+ <instance name="nwam" enabled="true"/>
+ <instance name="default" enabled="false"/>
+ </service>
</service_bundle>
-->
</sc_embedded_manifest>
</ai_criteria_manifest>
+
--- a/usr/src/cmd/slim-install/finish/install-finish Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/cmd/slim-install/finish/install-finish Tue Jul 06 09:11:29 2010 +0200
@@ -181,15 +181,11 @@
SA.append(ICTO.setup_dev_namespace())
SA.append(ICTO.create_sparc_boot_menu())
SA.append(ICTO.copy_sparc_bootlst())
- SA.append(ICTO.smf_correct_sys_profile())
SA.append(ICTO.add_sysidtool_sys_unconfig())
SA.append(ICTO.configure_nwam())
- SA.append(ICTO.enable_nwam_ai())
SA.append(ICTO.set_flush_content_cache_false())
- SA.append(ICTO.set_root_password(ROOT_PW))
- SA.append(ICTO.create_new_user(NU_GOS, NU_LOGIN, NU_PW,
- NU_GID, NU_UID))
- SA.append(ICTO.set_homedir_map(NU_LOGIN))
+ SA.append(ICTO.apply_sysconfig_profile())
+ SA.append(ICTO.smf_correct_sys_profile())
SA.append(ICTO.update_boot_archive())
else:
# Invoke the required ICT for non-SPARC platform
@@ -211,16 +207,12 @@
SA.append(ICTO.enable_happy_face_boot())
SA.append(ICTO.setup_dev_namespace())
SA.append(ICTO.copy_splash_xpm())
- SA.append(ICTO.smf_correct_sys_profile())
SA.append(ICTO.add_sysidtool_sys_unconfig())
SA.append(ICTO.configure_nwam())
- SA.append(ICTO.enable_nwam_ai())
SA.append(ICTO.set_flush_content_cache_false())
- SA.append(ICTO.set_root_password(ROOT_PW))
- SA.append(ICTO.create_new_user(NU_GOS, NU_LOGIN, NU_PW,
- NU_GID, NU_UID))
- SA.append(ICTO.set_homedir_map(NU_LOGIN))
SA.append(ICTO.copy_capability_file())
+ SA.append(ICTO.apply_sysconfig_profile())
+ SA.append(ICTO.smf_correct_sys_profile())
SA.append(ICTO.update_boot_archive())
else:
@@ -261,17 +253,17 @@
SA.append(ICTO.smf_correct_sys_profile())
SA.append(ICTO.add_sysidtool_sys_unconfig())
if textinstall_exists():
- pkg_remove_list = ['SUNWslim-utils', 'pkg:/system/install/text-install']
+ PKG_REMOVE_LIST = ['SUNWslim-utils', 'pkg:/system/install/text-install']
else:
# GUI installer
- pkg_remove_list = ['SUNWslim-utils', 'SUNWgui-install']
+ PKG_REMOVE_LIST = ['SUNWslim-utils', 'SUNWgui-install']
if NO_NETWORK:
SA.append(ICTO.do_not_configure_network())
else:
SA.append(ICTO.enable_nwam())
SA.append(ICTO.remove_livecd_environment())
- SA.append(ICTO.remove_specific_packages(pkg_remove_list))
+ SA.append(ICTO.remove_specific_packages(PKG_REMOVE_LIST))
SA.append(ICTO.set_flush_content_cache_false())
SA.append(ICTO.set_root_password(ROOT_PW))
SA.append(ICTO.create_new_user(NU_GOS, NU_LOGIN, NU_PW, NU_GID, NU_UID))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/system-config/Makefile Tue Jul 06 09:11:29 2010 +0200
@@ -0,0 +1,47 @@
+#
+# CDDL HEADER START
+#
+# 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]
+#
+# CDDL HEADER END
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+include ../Makefile.cmd
+
+all:= TARGET= all
+clean:= TARGET= clean
+clobber:= TARGET= clobber
+install:= TARGET= install
+
+SUBDIRS= svc tools
+
+install: $(SUBDIRS)
+
+install_h:
+
+clean: $(SUBDIRS)
+
+clobber: clean
+
+$(SUBDIRS): FRC
+ cd $@; pwd; echo $(TARGET); $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/system-config/svc/Makefile Tue Jul 06 09:11:29 2010 +0200
@@ -0,0 +1,46 @@
+#
+# CDDL HEADER START
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+SYSINSMANIFESTSRC= system-config.xml
+
+SVCMETHODSRC= svc-system-config
+
+include $(SRC)/cmd/Makefile.cmd
+
+FILEMODE= 444
+
+SYSINSMANIFESTS= $(SYSINSMANIFESTSRC:%=$(ROOTMANSYSINS)/%)
+
+SVCMETHODS= $(SVCMETHODSRC:%=$(ROOTLIBSVCMETHOD)/%)
+$(SVCMETHODS) := FILEMODE= 0555
+
+all:
+
+install: all $(ROOTLIBSVCMETHOD) $(SVCMETHODS) $(SYSINSMANIFESTS)
+
+install_h:
+
+clobber clean:
+
+include $(SRC)/cmd/Makefile.targ
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/system-config/svc/svc-system-config Tue Jul 06 09:11:29 2010 +0200
@@ -0,0 +1,807 @@
+#!/bin/ksh
+#
+# CDDL HEADER START
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+. /lib/svc/share/smf_include.sh
+
+#
+# Establish PATH for non-built in commands
+#
+export PATH=/usr/bin:/usr/sbin
+
+# load builtin commands
+builtin chmod
+builtin chown
+builtin cp
+builtin grep
+builtin rm
+builtin rmdir
+
+ETC_SHADOW=/etc/shadow
+TMP_SHADOW=/tmp/shadow.$$
+
+# site profile
+SITE_PROFILE=/etc/svc/profile/site.xml
+
+# property group definitions
+PG_USER_ACCOUNT="user_account"
+PG_ROOT_ACCOUNT="root_account"
+
+# directory containing initial user profile files
+ETC_SKEL=/etc/skel
+# initial user profile files
+DOT_PROFILE=".profile"
+DOT_BASHRC=".bashrc"
+INITIAL_DOT_PROFILE="$ETC_SKEL/$DOT_PROFILE"
+INITIAL_DOT_BASHRC="$ETC_SKEL/$DOT_BASHRC"
+
+# user account properties
+# login name
+PROP_USER_LOGIN="$PG_USER_ACCOUNT/login"
+# password
+PROP_USER_PASSWORD="$PG_USER_ACCOUNT/password"
+# description (usually user's full name)
+PROP_USER_DESCRIPTION="$PG_USER_ACCOUNT/description"
+# full pathname of the program used as the user's shell on login
+PROP_USER_SHELL="$PG_USER_ACCOUNT/shell"
+# UID
+PROP_USER_UID="$PG_USER_ACCOUNT/uid"
+# GID
+PROP_USER_GID="$PG_USER_ACCOUNT/gid"
+# type (role, normal) - see user_attr(4)
+PROP_USER_TYPE="$PG_USER_ACCOUNT/type"
+# profiles
+PROP_USER_PROFILES="$PG_USER_ACCOUNT/profiles"
+# roles
+PROP_USER_ROLES="$PG_USER_ACCOUNT/roles"
+# expiration date for a login
+PROP_USER_EXPIRE="$PG_USER_ACCOUNT/expire"
+# name of home directory ZFS dataset
+PROP_USER_HOME_ZFS_FS="$PG_USER_ACCOUNT/home_zfs_dataset"
+# home directory mountpoint
+PROP_USER_HOME_MOUNTPOINT="$PG_USER_ACCOUNT/home_mountpoint"
+
+# root account properties
+# password
+PROP_ROOT_PASSWORD="$PG_ROOT_ACCOUNT/password"
+# type (e.g. role) - see user_attr(4)
+PROP_ROOT_TYPE="$PG_ROOT_ACCOUNT/type"
+# expiration date for a login
+PROP_ROOT_EXPIRE="$PG_ROOT_ACCOUNT/expire"
+
+# default value for unconfigured properties
+SMF_UNCONFIGURED_VALUE=""
+
+#
+# get_smf_prop()
+#
+# Description:
+# Retrieve value of SMF property.
+# For 'astring' type of property, take care of removing quoting backslashes,
+# since according to svcprop(1) man page, shell metacharacters
+# (';', '&', '(', ')', '|', '^', '<', '>', newline, space, tab, backslash,
+# '"', single-quote, '`') are quoted by backslashes (\).
+#
+# Parameters:
+# $1 - SMF property name
+#
+# Returns:
+# 0 - property was configured in SC manifest
+# 1 - property was not configured in SC manifest
+#
+get_smf_prop()
+{
+ typeset prop_name="$1"
+ typeset prop_value
+ typeset prop_type
+
+ #
+ # If property is not set for service instance (which means it was not
+ # defined in SC manifest), return with 'unconfigured' value.
+ #
+ svcprop -Cq -p "$prop_name" $SMF_FMRI
+ if (( $? != 0 )) ; then
+ print -u1 $SMF_UNCONFIGURED_VALUE
+ return 1
+ fi
+
+ #
+ # retrieve property.
+ #
+ prop_value=$(svcprop -p "$prop_name" $SMF_FMRI)
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to obtain value of <$prop_name> property" \
+ "which is suspicious, defaulting to" \
+ "<$SMF_UNCONFIGURED_VALUE>."
+
+ print -u1 $SMF_UNCONFIGURED_VALUE
+ return 1
+ fi
+
+ # for 'astring' type, remove backslashes from quoted metacharacters
+ prop_type=$(svccfg -s $SMF_FMRI listprop "$prop_name" |
+ nawk '{ print $2 }')
+
+ if [[ $prop_type == "astring" ]] ; then
+ prop_value=$(print $prop_value | sed -e 's/\\\(.\)/\1/g')
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed when trying to remove '\' from" \
+ "<$prop_name> property, defaulting to" \
+ "<$SMF_UNCONFIGURED_VALUE>."
+
+ print -u1 $SMF_UNCONFIGURED_VALUE
+ return 1
+ fi
+
+ #
+ # Since according to svcprop(1) man page empty ASCII string
+ # value is presented as a pair of double quotes (""), we need
+ # to check for this combination and replace it
+ # with empty string.
+ #
+ [[ "$prop_value" == "\"\"" ]] && prop_value=""
+ fi
+
+ print -u1 "$prop_value"
+ return 0
+}
+
+#
+# set_password()
+#
+# Description:
+# configure password by modifying shadow(4) file
+#
+# Parameters:
+# $1 - login name
+# $2 - encrypted password
+#
+# Returns:
+# aborts with $SMF_EXIT_ERR_FATAL in case of failure
+#
+set_password()
+{
+ typeset user=$1
+ typeset pass=$2
+
+ # create temporary file
+ cp $ETC_SHADOW $TMP_SHADOW
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to create temporary file $TMP_SHADOW," \
+ "aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ #
+ # read shadow(4) file and set field 'password' to desired value
+ # for matching login name
+ #
+ # format of shadow(4):
+ # username:password:lastchg:min:max:warn:inactive:expire:flag
+ #
+
+ nawk -F: '{
+ if ( $1 == login )
+ printf "%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
+ $1, passwd, $3, $4, $5, $6, $7, $8, $9
+ else
+ print
+ }' passwd="$pass" login="$user" $TMP_SHADOW > $ETC_SHADOW
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to set password in $ETC_SHADOW, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ # remove temporary file
+ rm -f $TMP_SHADOW
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to remove temporary file $TMP_SHADOW," \
+ "aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+}
+
+#
+# configure_account_type()
+#
+# Description:
+# set 'type' of user account - needs to be done separately, since
+# useradd -K type=<type> is not supported - see useradd(1M) man page
+#
+# Parameters:
+# $1 - login
+# $2 - account type
+#
+# Returns:
+# aborts with $SMF_EXIT_ERR_FATAL in case of failure
+#
+configure_account_type()
+{
+ typeset account="$1"
+ typeset type="$2"
+
+ usermod -K type="$type" "$account"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to configure <$account> account as type" \
+ "<$type>, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+}
+
+#
+# set_expiration_date()
+#
+# Description:
+# sets expiration date for account, if SMF property is set to "0" (zero)
+# user is forced to change the password at next login
+#
+# Parameters:
+# $1 - login
+# $2 - expiration date
+#
+# Returns:
+# aborts with $SMF_EXIT_ERR_FATAL in case of failure
+#
+set_expiration_date()
+{
+ typeset account="$1"
+ typeset expire="$2"
+
+ if [[ "$expire" == "0" ]] ; then
+ print -u1 " User will be prompted to change password for"\
+ "account <$account> at the next login."
+
+ passwd -f "$account"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Calling passwd(1) -f failed for user" \
+ "<$account>, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ else
+ usermod -e "$expire" "$account"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to set expiration date to" \
+ "<$expire> for account <$account>, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ fi
+}
+
+#
+# create_initial_user_profile()
+#
+# Description:
+# Creates initial user's profile by copying .profile and .bashrc
+# (in case bash is used as user's shell) from /etc/skel/ directory
+#
+# Parameters:
+# $1 - account
+# $2 - home directory
+# $3 - shell
+#
+# Returns:
+# aborts with $SMF_EXIT_ERR_FATAL in case of failure
+#
+create_initial_user_profile()
+{
+ typeset account="$1"
+ typeset home_dir="$2"
+ typeset user_shell="$3"
+
+ cp "$INITIAL_DOT_PROFILE" "${home_dir}/"
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to copy $INITIAL_DOT_PROFILE to" \
+ "${home_dir}/, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ chmod 0644 "$home_dir/$DOT_PROFILE"
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to change permissions to 0644" \
+ "for ${home_dir}/$DOT_PROFILE, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ if [[ "$user_shell" == ~(E)bash$ ]] ; then
+ print -u1 " bash(1) selected as a shell for <$account>" \
+ "account, copying initial bash profile" \
+ "$INITIAL_DOT_BASHRC to home directory."
+
+ cp "$INITIAL_DOT_BASHRC" "${home_dir}/"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to copy $INITIAL_DOT_BASHRC to" \
+ "${home_dir}/, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ chmod 0644 "$home_dir/$DOT_BASHRC"
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to change permissions to 0644" \
+ "for ${home_dir}/$DOT_BASRC, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ fi
+
+ #
+ # set correct ownership for files and home directory
+ #
+
+ chown -R $account:$gid "$home_dir"
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to set ownership to $account:$gid for" \
+ "${home_dir} directory and user files, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+}
+
+#
+# create_user_account()
+#
+# Description:
+# creates user account
+#
+# Returns:
+# aborts with $SMF_EXIT_ERR_FATAL in case of failure
+#
+create_user_account()
+{
+ typeset login_name
+ typeset uid
+ typeset gid
+ typeset shell
+ typeset roles
+ typeset home_zfs_fs
+ typeset home_mntpoint
+ typeset desc
+ typeset profiles
+ typeset account_type
+ typeset password
+ typeset expire
+
+ # CLI options for useradd(1M)
+ typeset useradd_opt=""
+
+ #
+ # User account can't be created if login is not provided.
+ # Do not treat it as fatal error, just log it
+ #
+ login_name=$(get_smf_prop $PROP_USER_LOGIN)
+ if [[ -z "$login_name" ]]; then
+ print -u1 " Login name not provided, user account" \
+ "will not be created."
+ return
+ fi
+
+ #
+ # If user account already exists, do not proceed with the
+ # configuration. Only creating user account from scratch
+ # is supported. Thus messing with existing configuration could
+ # produce undetermined results.
+ #
+ grep "^${login_name}:" $ETC_SHADOW
+ if (( $? == 0 )) ; then
+ print -u1 " Login <$login_name> already exists, skipping" \
+ "user account configuration."
+
+ return
+ fi
+
+ # get UID. If not provided, let useradd(1M) fill in the default
+ uid=$(get_smf_prop $PROP_USER_UID)
+ (( $? == 0 )) && useradd_opt="$useradd_opt -u $uid"
+
+ # get GID. If not provided, use 10 (staff) as a default
+ gid=$(get_smf_prop $PROP_USER_GID)
+ (( $? != 0 )) && gid=10
+ useradd_opt="$useradd_opt -g $gid"
+
+ # get user's shell. If not provided, let useradd(1M) fill in the default
+ shell=$(get_smf_prop $PROP_USER_SHELL)
+ [[ -n "$shell" ]] &&
+ useradd_opt="$useradd_opt -s $shell"
+
+ # get list of comma separated roles
+ roles=$(get_smf_prop $PROP_USER_ROLES)
+ [[ -n "$roles" ]] &&
+ useradd_opt="$useradd_opt -R $roles"
+
+ #
+ # get name of home directory ZFS dataset
+ # If not provided, use <root_pool>/export/home/<login_name>
+ # as a default.
+ #
+ home_zfs_fs=$(get_smf_prop $PROP_USER_HOME_ZFS_FS)
+ [[ -z "$home_zfs_fs" ]] &&
+ home_zfs_fs="rpool/export/home/$login_name"
+
+ #
+ # get home directory mountpoint
+ #
+ home_mntpoint=$(get_smf_prop $PROP_USER_HOME_MOUNTPOINT)
+
+ #
+ # Configure ZFS dataset for user's home directory
+ # If running in non-global zone, ZFS dataset was created in global zone
+ # and delegated to non-global zone
+ #
+ print -u1 " Creating user home directory on <$home_zfs_fs> ZFS" \
+ "dataset."
+
+ #
+ # Check if ZFS dataset exists. If it does not, take appropriate action
+ # taking running environment into account:
+ # global zone: create ZFS dataset
+ # non-global zone: inform user and abort
+ #
+ zfs list "$home_zfs_fs" > /dev/null 2>&1
+
+ if (( $? != 0 )) ; then
+ if smf_is_globalzone; then
+ #
+ # set also mountpoint if provided, otherwise let zfs
+ # inherit the mountpoint from parent dataset
+ #
+ if [[ -n "$home_mntpoint" ]] ; then
+ zfs create -o mountpoint="$home_mntpoint" \
+ "$home_zfs_fs"
+ else
+ zfs create "$home_zfs_fs"
+ fi
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to create ZFS dataset" \
+ "<$home_zfs_fs>, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ else
+ print -u2 "ZFS dataset <$home_zfs_fs> does not exist."
+ print -u2 "Please create it in global zone and" \
+ "delegate it to the non-global zone."
+ print -u2 "See zonecfg(1M) and zfs(1M) commands" \
+ "for more details."
+ print -u2 "Aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ else
+ #
+ # If ZFS mountpoint is not explicitly configured, go with
+ # existing ZFS mountpoint. If ZFS dataset has mountpoint set
+ # to 'legacy' (which is the case for ZFS datasets delegated
+ # to non-global zones), use '/export/home/$login_name' as
+ # a default mountpoint.
+ #
+ if [[ -z "$home_mntpoint" ]] ; then
+ zfs_mntpoint=$(zfs get -H mountpoint $home_zfs_fs |
+ nawk '{ print $3 }')
+
+ if (( $? != 0 )) ; then
+ home_mntpoint="/export/home/$login_name"
+
+ print -u1 " Could not determine mountpoint" \
+ "for ZFS dataset <$home_zfs_fs>," \
+ "<$home_mntpoint> will be used."
+ elif [[ "$zfs_mntpoint" == "legacy" ]] ; then
+ home_mntpoint="/export/home/$login_name"
+
+ print -u1 " ZFS dataset <$home_zfs_fs>," \
+ "uses legacy mountpoint, it will be set" \
+ "to <$home_mntpoint> instead."
+ fi
+ fi
+
+ if [[ -n "$home_mntpoint" ]] ; then
+ print -u1 " ZFS dataset <$home_zfs_fs> exists, only" \
+ "ZFS mountpoint will be set to <$home_mntpoint>."
+
+ zfs set mountpoint="$home_mntpoint" "$home_zfs_fs"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to set mountpoint to" \
+ "<$home_mntpoint> for ZFS dataset" \
+ "<$home_zfs_fs>, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ fi
+
+ # if in global zone, make sure existing ZFS dataset is mounted
+ if smf_is_globalzone; then
+ zfs mount "$home_zfs_fs"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Could not mount ZFS dataset" \
+ "<$home_zfs_fs>, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ fi
+ fi
+
+ #
+ # now when ZFS dataset has been configured, use its mountpoint
+ # as user's home directory
+ #
+
+ home_mntpoint=$(zfs get -H mountpoint $home_zfs_fs |
+ nawk '{ print $3 }')
+
+ if (( $? != 0 )) ; then
+ print -u2 "Could not determine mountpoint for ZFS dataset" \
+ "<$home_zfs_fs>, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ print -u1 " Home mountpoint: $home_mntpoint"
+
+ # set permissions to 0755 for home directory
+ chmod 0755 "$home_mntpoint"
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to change permissions to 0755 for" \
+ "${home_mntpoint} directory, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ # create user account by means of useradd(1M)
+ print -u1 " Calling useradd(1M) to create user account."
+ print -u1 " cmd: useradd $useradd_opt -d $home_mntpoint $login_name"
+
+ useradd $useradd_opt -d "$home_mntpoint" $login_name
+ typeset -i ret=$?
+
+ if [[ $ret != 0 ]] ; then
+ printf "useradd(1M) failed to create user account, ret=%d," \
+ "aborting.\n" $ret
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ # set description for user account (usually full user name)
+ desc=$(get_smf_prop $PROP_USER_DESCRIPTION)
+ if [[ -n "$desc" ]] ; then
+ print -u1 " Setting description to <$desc> for account" \
+ "<$login_name>."
+
+ usermod -c "$desc" "$login_name"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to set description to <$desc> for" \
+ "<$login_name> account, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ fi
+
+ # assign profiles to user account
+ profiles=$(get_smf_prop $PROP_USER_PROFILES)
+ if [[ -n "$profiles" ]] ; then
+ print -u1 " Assigning profiles <$profiles> to user account" \
+ "<$login_name>."
+
+ usermod -P "$profiles" "$login_name"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to assign profiles <$profiles> to" \
+ "<$login_name> account, aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ fi
+
+ # set type of user account
+ account_type=$(get_smf_prop $PROP_USER_TYPE)
+ if [[ -n "$account_type" ]] ; then
+ print -u1 " Configuring <$login_name> account as type" \
+ "<$account_type>."
+
+ configure_account_type "$login_name" "$account_type"
+ fi
+
+ # if provided, set password for created user
+ password=$(get_smf_prop $PROP_USER_PASSWORD)
+ if (( $? == 0 )); then
+ print -u1 " Setting password for user <$login_name>."
+ set_password "$login_name" "$password"
+ fi
+
+ #
+ # configure expiration date
+ #
+ # if required, forces the user to change password at the next login by
+ # expiring the password
+ #
+ expire=$(get_smf_prop $PROP_USER_EXPIRE)
+ if [[ -n "$expire" ]] ; then
+ print -u1 " Setting expire date to <$expire> for user" \
+ "<$login_name>."
+
+ set_expiration_date "$login_name" "$expire"
+ fi
+
+ #
+ # Create initial user's profile by copying .profile and .bashrc
+ # (in case bash is used as user's shell) from /etc/skel/ directory
+ #
+ create_initial_user_profile "$login_name" "$home_mntpoint" "$shell"
+
+ #
+ # Now unmount the ZFS dataset and remove mountpoint.
+ # svc:/system/filesystem/local:default SMF service will later in the
+ # boot process take care of mounting all ZFS datasets and creating
+ # mountpoints in required order.
+ #
+ print -u1 " Unmounting <$home_zfs_fs> home directory ZFS dataset."
+ zfs unmount "$home_zfs_fs"
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to unmount <$home_zfs_fs> ZFS dataset," \
+ "aborting."
+
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ #
+ # do not check return code from rmdir - we know it might fail
+ # due to the fact that some of subdirectories might not be empty
+ #
+ print -u1 " Removing <$home_mntpoint> home directory ZFS mountpoint."
+ rmdir -ps $home_mntpoint
+}
+
+#
+# configure_root_account()
+#
+# Description:
+# configures root account
+#
+# Returns:
+# aborts with $SMF_EXIT_ERR_FATAL in case of failure
+#
+configure_root_account()
+{
+ typeset password
+ typeset account_type
+ typeset expire
+
+ # password
+ password=$(get_smf_prop $PROP_ROOT_PASSWORD)
+ if (( $? == 0 )); then
+ print -u1 " Setting root password."
+ set_password root "$password"
+ fi
+
+ # configure account type (e.g. role)
+ # set type of user account
+ account_type=$(get_smf_prop $PROP_ROOT_TYPE)
+ if [[ -n "$account_type" ]] ; then
+ print -u1 " Configuring root account as type <$account_type>."
+ configure_account_type root "$account_type"
+ fi
+
+ # set expiration date
+ expire=$(get_smf_prop $PROP_ROOT_EXPIRE)
+ if [[ -n "$expire" ]] ; then
+ print -u1 " Setting expire date to <$expire> for root."
+ set_expiration_date root "$expire"
+ fi
+}
+
+#
+# remove_pg()
+#
+# Description:
+# removes property group from service specified by $SMF_FMRI
+#
+# Parameters:
+# $1 - property group
+#
+# Returns:
+# aborts with $SMF_EXIT_ERR_FATAL in case of failure
+#
+remove_pg()
+{
+ typeset pg=$1
+
+ print -u1 " Removing property group <$pg>."
+ svccfg -s $SMF_FMRI delpg $pg
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to remove <$pg> property group, aborting."
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+}
+
+## Main ##
+
+# check if root account is to be configured
+svcprop -C -q -p $PG_ROOT_ACCOUNT $SMF_FMRI
+(( $? == 0 )) && configure_root=true || configure_root=false
+
+# check if user account is to be configured
+svcprop -C -q -p $PG_USER_ACCOUNT $SMF_FMRI
+(( $? == 0 )) && configure_user=true || configure_user=false
+
+# configure root acount
+if $configure_root; then
+ print -u1 "Configuring root account."
+
+ configure_root_account
+
+ remove_pg $PG_ROOT_ACCOUNT
+
+ print -u1 "root account successfully configured."
+fi
+
+# configure user acount
+if $configure_user; then
+ print -u1 "Configuring user account."
+
+ create_user_account
+
+ remove_pg $PG_USER_ACCOUNT
+
+ print -u1 "User account successfully configured."
+fi
+
+#
+# remove site.xml link pointing to System Configuration profile.
+# This is workaround for the fact that the profile is applied during
+# both Early as well as Late Manifest Import process. We need to assure
+# that the profile is applied only once, so that configuration process
+# is not run twice during first boot.
+#
+
+if [[ -L "$SITE_PROFILE" ]] ; then
+ rm "$SITE_PROFILE"
+
+ if (( $? != 0 )) ; then
+ print -u2 "Failed to remove $SITE_PROFILE link, aborting."
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+
+ print -u1 "System successfully configured."
+fi
+
+exit $SMF_EXIT_OK
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/system-config/svc/system-config.xml Tue Jul 06 09:11:29 2010 +0200
@@ -0,0 +1,128 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+ CDDL HEADER START
+
+ 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]
+
+ CDDL HEADER END
+
+ Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+ NOTE: This service manifest is not editable; its contents will
+ be overwritten by package or patch operations, including
+ operating system upgrade. Make customizations in a different
+ file.
+-->
+<service_bundle type='manifest' name='system/install:system-config'>
+
+<service
+ name='system/install/config'
+ type='service'
+ version='1'>
+
+ <create_default_instance enabled='false'/>
+
+ <single_instance/>
+
+ <dependency name='fs'
+ grouping='require_all'
+ restart_on='none'
+ type='service'>
+ <service_fmri
+ value='svc:/system/filesystem/root:default' />
+ </dependency>
+
+ <dependent
+ name='installconfig_sysconfig'
+ grouping='optional_all'
+ restart_on='none'>
+ <service_fmri value='svc:/milestone/sysconfig' />
+ </dependent>
+
+ <dependent
+ name='installconfig_manifest_import'
+ grouping='optional_all'
+ restart_on='none'>
+ <service_fmri value='svc:/system/manifest-import:default' />
+ </dependent>
+
+ <exec_method
+ type='method'
+ name='start'
+ exec='/lib/svc/method/svc-system-config'
+ timeout_seconds='0' />
+
+ <exec_method
+ type='method'
+ name='stop'
+ exec=':true'
+ timeout_seconds='0' />
+
+ <exec_method
+ type='method'
+ name='refresh'
+ exec=':true'
+ timeout_seconds='0' />
+
+ <property_group name='startd' type='framework'>
+ <propval name='duration' type='astring'
+ value='transient' />
+ </property_group>
+
+ <!-- The following property group is used only at install
+ time to configure an initial user account -->
+ <property_group name='user_account' type='application'>
+ <stability value='Evolving'/>
+ <propval name='read_authorization' type='astring'
+ value='solaris.smf.read.system-config' />
+ <propval name='login' type='astring' value=''/>
+ <propval name='password' type='astring' value=''/>
+ <propval name='description' type='astring' value=''/>
+ <propval name='shell' type='astring' value=''/>
+ <propval name='uid' type='count' value='0'/>
+ <propval name='gid' type='count' value='0'/>
+ <propval name='profiles' type='astring' value=''/>
+ <propval name='roles' type='astring' value=''/>
+ <propval name='type' type='astring' value=''/>
+ <propval name='expire' type='astring' value=''/>
+ <propval name='home_zfs_dataset' type='astring' value=''/>
+ <propval name='home_mountpoint' type='astring' value=''/>
+ </property_group>
+
+ <!-- The following property group is used only at install
+ time to configure an initial root account -->
+ <property_group name='root_account' type='application'>
+ <stability value='Evolving' />
+ <propval name='read_authorization' type='astring'
+ value='solaris.smf.read.system-config' />
+ <propval name='password' type='astring' value='' />
+ <propval name='type' type='astring' value=''/>
+ <propval name='expire' type='astring' value=''/>
+ </property_group>
+
+ <stability value='Unstable' />
+
+ <template>
+ <common_name>
+ <loctext xml:lang='C'>
+ system configuration
+ </loctext>
+ </common_name>
+ </template>
+</service>
+</service_bundle>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/system-config/tools/Makefile Tue Jul 06 09:11:29 2010 +0200
@@ -0,0 +1,40 @@
+#
+# CDDL HEADER START
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+#
+
+FILES = sc_conv.ksh
+
+include $(SRC)/cmd/Makefile.cmd
+
+FILEMODE= 555
+
+all: $(FILES)
+
+install: all $(ROOTUSRLIBINSTALL) $(ROOTUSRLIBINSTALLFILES)
+
+clobber clean:
+
+$(FILES):
+
+include $(SRC)/cmd/Makefile.targ
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/system-config/tools/sc_conv.ksh Tue Jul 06 09:11:29 2010 +0200
@@ -0,0 +1,309 @@
+#!/bin/ksh
+#
+# CDDL HEADER START
+#
+# 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]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# This script converts SC manifest from old format (build < 144) to
+# the new one introduced in build 144.
+#
+# It is part of the AI image and is utilized by Automated Installer
+# when user provides SC manifest in old format. In such case, SC manifest
+# is converted to the new format during the installation.
+#
+# In order to ease the transition, the script can be also used as a conversion
+# tool on AI server side (e.g. by administrator) to convert existing SC
+# manifests to the new format.
+#
+# Following formats of SC manifests are supported:
+# * standalone SC manifest
+# * manifest embedded in AI combined manifest as XML comment
+#
+
+#
+# Establish PATH for non-built in commands
+#
+export PATH=/usr/bin:/usr/sbin
+
+SC_EMBEDDED_TAG="<sc_embedded_manifest"
+MANIFEST_TMP=/tmp/manifest_tmp.$$
+SC_VALUE_RE_BEG=".*[\040\009]value[\040\009]*=[\040\009]*[\042\047]"
+SC_VALUE_RE_END="[\042\047][\040\009]*\/>.*\$"
+
+# builtins
+builtin cat
+builtin grep
+builtin rm
+
+#
+# Print error message to stderr and exit
+#
+error_exit() {
+ print -u2 "$@"
+
+ exit 1
+}
+
+#
+# create_new_manifest
+#
+# Description:
+# Create manifest containing template SC manifest in new format.
+# If combined manifest was provided, copy install portion of AI manifest,
+# since it has not changed.
+#
+# Parameters:
+# $1 - old manifest
+# $2 - new manifest
+# $3 - true - old manifest is combined AI manifest
+# false - old manifest is standalone SC manifest
+#
+create_new_manifest()
+{
+ typeset src_man="$1"
+ typeset dst_man="$2"
+ typeset is_combined="$3"
+
+ #
+ # If it is combined AI manifest, copy AI portion of it and embed
+ # SC manifest as a comment, since this is how it is currently handled.
+ # On the other hand, standalone SC manifest is standard XML file.
+ #
+ if $is_combined; then
+ nawk '{ print } ; $0 ~ end_tag { exit }' \
+ end_tag="$SC_EMBEDDED_TAG" "$src_man" > "$dst_man"
+
+ print "<!-- <?xml version='1.0'?>" >> "$dst_man"
+ else
+ print "<?xml version='1.0'?>" > "$dst_man"
+ fi
+
+ cat <<-EOF >> "$dst_man"
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<service_bundle type="profile" name="system configuration">
+ <service name="system/install/config" version="1" type="service">
+ <instance name="default" enabled="true">
+ <property_group name="user_account" type="application">
+ <propval name="login" type="astring" value=""/>
+ <propval name="password" type="astring" value=""/>
+ <propval name="description" type="astring" value=""/>
+ <propval name="shell" type="astring" value="/usr/bin/bash"/>
+ <propval name="uid" type='count' value='101'/>
+ <propval name="gid" type='count' value='10'/>
+ <propval name="type" type="astring" value="normal"/>
+ <propval name="roles" type="astring" value="root"/>
+ </property_group>
+
+ <property_group name="root_account" type="application">
+ <propval name="password" type="astring" value=""/>
+ <propval name="type" type="astring" value="role"/>
+ </property_group>
+
+ <property_group name="other_sc_params" type="application">
+ <propval name="timezone" type="astring" value=""/>
+ <propval name="hostname" type="astring" value=""/>
+ </property_group>
+ </instance>
+ </service>
+
+ <service name="system/console-login" version="1" type="service">
+ <property_group name="ttymon" type="application">
+ <propval name="terminal_type" type="astring" value="sun"/>
+ </property_group>
+ </service>
+
+ <service name="network/physical" version="1" type="service">
+ <instance name="nwam" enabled="true"/>
+ <instance name="default" enabled="false"/>
+ </service>
+</service_bundle>
+ EOF
+
+ # if combined AI manifest, finish it by appropriate XML end tags
+ if $is_combined; then
+ cat <<-EOF >> "$dst_man"
+ -->
+ </sc_embedded_manifest>
+</ai_criteria_manifest>
+ EOF
+ fi
+}
+
+#
+# get_value
+#
+# Description:
+# Obtains value of given XML tag from old SC manifest
+# XML parser obeys the same set of rules as AI parser and makes the same
+# assumptions. This approach assures that if SC manifest validates in AI,
+# it is also valid for purposes of this conversion.
+#
+# Rules and assumptions:
+# - Whole SC element along with its 'name', 'type' and 'value' attributes
+# fits one line
+# - tokens are separated by one or more spaces or tabulators
+# - 'value' attributes are quoted by single or double quotes,
+# e.g. both value="opensolaris" or value='opensolaris' are allowed
+#
+#
+# Parameters:
+# $1 - XML tag name
+# $2 - path to old manifest
+#
+get_value()
+{
+ typeset xml_tag="$1"
+ typeset old_sc_manifest="$2"
+
+ nawk '{ if (match($0, "<propval.*" tag ".*\/>") != 0) { \
+ sub(re_beg,""); sub(re_end,""); print ; exit }}' \
+ re_beg="$SC_VALUE_RE_BEG" re_end="$SC_VALUE_RE_END" \
+ tag=$xml_tag "$old_sc_manifest"
+}
+
+### MAIN ###
+if (( $# != 2 )) ; then
+ error_exit "Usage: $0 old_manifest.xml new_manifest.xml"
+fi
+
+typeset manifest_old="$1"
+typeset manifest_new="$2"
+
+# check if source can be accessed
+if [[ ! -f "$manifest_old" ]] ; then
+ error_exit "Could not access original AI manifest $manifest_old," \
+ "aborting."
+fi
+
+# if destination file exists, inform user that it will be overwritten
+if [[ -f "$manifest_new" ]] ; then
+ print "$manifest_new exists, it will be saved to" \
+ "$manifest_new.saved."
+
+ mv "$manifest_new" "${manifest_new}.saved"
+
+ if (( $? != 0 )) ; then
+ error_exit "Failed to move "$manifest_new" to" \
+ "${manifest_new}.saved, aborting."
+ fi
+fi
+
+# create temporary ai manifest
+touch "$MANIFEST_TMP"
+
+if (( $? != 0 )) ; then
+ error_exit "Failed to create temporary file $MANIFEST_TMP, aborting."
+fi
+
+#
+# Convert old SC manifest to new format. SC manifest can be provided in two
+# forms. Either embedded in combined AI manifest or as a standalone file.
+# Detect the form we are going to deal with and take appropriate approach.
+#
+# For combined AI manifest:
+# * Copy install portion of AI manifest, since it has not changed
+# Rest of steps is the same for both forms:
+# * Append SC template compliant with new format
+# * Replace SC parameters in SC template with the ones taken from original
+# SC manifest
+#
+
+#
+# Detect form of provided manifest
+# In case of combined AI manifest, SC portion is enclosed in XML tag
+# SC_EMBEDDED_TAG
+#
+grep $SC_EMBEDDED_TAG $manifest_old > /dev/null 2>&1
+
+if (( $? == 0 )) ; then
+ print "Provided SC manifest is part of AI combined manifest."
+ is_combined_manifest=true
+else
+ print "Standalone SC manifest provided."
+ is_combined_manifest=false
+fi
+
+#
+# Start with creating manifest which contains SC template manifest in new
+# format while keeping rest of content untouched.
+#
+create_new_manifest "$manifest_old" "$MANIFEST_TMP" $is_combined_manifest
+
+#
+# Populate SC parameters in new manifest from those defined in old manifest
+# First obtain SC parameters from old manifest
+#
+
+username=$(get_value "username" "$manifest_old")
+userpass=$(get_value "userpass" "$manifest_old")
+description=$(get_value "description" "$manifest_old")
+rootpass=$(get_value "rootpass" "$manifest_old")
+timezone=$(get_value "timezone" "$manifest_old")
+nodename=$(get_value "hostname" "$manifest_old")
+
+print username=$username
+print userpass=$userpass
+print description=$description
+print rootpass=$rootpass
+print timezone=$timezone
+print nodename=$nodename
+
+#
+# Populate SC parameters in new SC manifest from obtained values.
+# If particular parameter is not defined in original manifest (has been read
+# as empty string), do not populate it in new manifest either.
+#
+nawk ' \
+ { skip = "false" } \
+ /<property_group name="user_account"/ { pconf = "user" } \
+ /<property_group name="root_account"/ { pconf = "root" } \
+ /<propval.*login/ { \
+ sub(/value="/, "&" login); if (login == "") skip = "true" } \
+ /<propval.*password/ && (pconf == "user") { \
+ sub(/value="/, "&" up); if (up == "") skip = "true" } \
+ /<propval.*password/ && (pconf == "root") { \
+ sub(/value="/, "&" rp); if (rp == "") skip = "true" } \
+ /<propval.*description/ { \
+ sub(/value="/, "&" desc); if (desc == "") skip = "true" } \
+ /<propval.*timezone/ { \
+ sub(/value="/, "&" tz); if (tz == "") skip = "true" } \
+ /<propval.*hostname/ { \
+ sub(/value="/, "&" nn); if (nn == "") skip = "true" } \
+ { if (skip == "false") print}' \
+ login="$username" up="$userpass" desc="$description" rp="$rootpass" \
+ tz="$timezone" nn="$nodename" \
+ "$MANIFEST_TMP" > "$manifest_new"
+
+if (( $? != 0 )) ; then
+ error_exit "Failed to create target ai manifest $manifest_new."
+fi
+
+# remove temporary file
+rm $MANIFEST_TMP
+
+if (( $? != 0 )) ; then
+ error_exit "Failed to remove temporary file $MANIFEST_TMP."
+fi
+
+exit 0
+
--- a/usr/src/lib/libict/ict.c Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/lib/libict/ict.c Tue Jul 06 09:11:29 2010 +0200
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <errno.h>
@@ -74,7 +73,6 @@
char *res_buf = NULL;
char *src = source;
int alloc_size = 0;
- int i = 0;
int quote_cnt = 0;
int src_len = 0;
@@ -260,9 +258,6 @@
{
char *_this_func_ = "ict_configure_user_directory";
char homedir[MAXPATHLEN];
- char filesystem[MAXPATHLEN];
- char cmd[MAXPATHLEN];
- int ret;
int saverr = 0;
uid_t uid;
gid_t gid;
@@ -957,7 +952,7 @@
"/var/svc/log/application-auto-installer:default.log",
"/var/svc/log/application-manifest-locator:default.log",
"/var/adm/messages",
- "/tmp/ai_combined_manifest.xml",
+ "/tmp/ai_manifest.xml",
NULL };
boolean_t redirect = B_FALSE;
@@ -1074,7 +1069,7 @@
* catch stderr for debugging purposes
*/
if (redirect) {
- strlcpy(buf, cmd, sizeof (buf));
+ (void) strlcpy(buf, cmd, sizeof (buf));
if (strlcat(buf, " 2>&1 1>/dev/null", MAXPATHLEN) >= MAXPATHLEN)
ict_debug_print(LS_DBGLVL_WARN,
"ict_safe_system: Couldn't redirect stderr\n");
--- a/usr/src/lib/libict/ict_test.c Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/lib/libict/ict_test.c Tue Jul 06 09:11:29 2010 +0200
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -168,7 +167,7 @@
(void) fprintf(stdout, "Invoking ICT: \n");
(void) fprintf(stdout, "%s(%s, %s, %s)\n",
INSTALLBOOT, argv[2], argv[3], argv[4]);
- ict_installboot(argv[2], argv[3], argv[4]);
+ ict_installboot(argv[2], argv[3], (boolean_t)argv[4]);
(void) fprintf(stdout, "Result \n\t%s\n",
ICT_STR_ERROR(ict_errno));
}
--- a/usr/src/lib/libict_pymod/ict.py Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/lib/libict_pymod/ict.py Tue Jul 06 09:11:29 2010 +0200
@@ -150,7 +150,6 @@
ICT_FDISK_FAILED,
ICT_UPDATE_DUMPADM_NODENAME_FAILED,
ICT_CONFIGURE_NWAM_FAILED,
-ICT_ENABLE_NWAM_AI_FAILED,
ICT_ENABLE_NWAM_FAILED,
ICT_FIX_FAILSAFE_MENU_FAILED,
ICT_CREATE_SMF_REPO_FAILED,
@@ -188,7 +187,8 @@
ICT_SET_PART_ACTIVE_FAILED,
ICT_SVCCFG_FAILURE,
ICT_SET_AUTOHOME_FAILED,
-ICT_COPY_CAPABILITY_FAILED
+ICT_COPY_CAPABILITY_FAILED,
+ICT_APPLY_SYSCONFIG_FAILED
) = range(200,256)
#Global variables
@@ -348,6 +348,9 @@
bootenvrc - normal location of bootenv.rc
autohome - normal location of autohome map
loc_grubmenu - normal location of GRUB menu
+ ai_sc_profile - SC profile generated by Automated Installer
+ target_sc_profile = target SC profile
+
class initializer will exit with error status if:
- basedir is missing or empty
@@ -359,7 +362,9 @@
debuglvl = -1,
bootenvrc = '/boot/solaris/bootenv.rc',
autohome = '/etc/auto_home',
- loc_grubmenu = '/boot/grub/menu.lst'):
+ loc_grubmenu = '/boot/grub/menu.lst',
+ ai_sc_profile = '/tmp/sc_manifest.xml',
+ target_sc_profile = 'sc_profile.xml'):
# determine whether we are doing AI install or slim install
self.livecd_install = False
@@ -376,7 +381,8 @@
self.text_install = True
if basedir == '':
- prerror('Base directory must be passed')
+ err_str = 'Base directory must be passed'
+ prerror(err_str)
raise ValueError(err_str)
if basedir == '/':
'''
@@ -428,10 +434,10 @@
self.kbd_layout_file = '/usr/share/lib/keytables/type_6/kbd_layouts'
# determine whether we are installing to an iSCSI boot target
- self.iscsi_boot_install = False
- if os.access("/.iscsi_boot", os.R_OK):
- _dbg_msg('Determined to be doing iSCSI boot install')
- self.iscsi_boot_install = True
+ self.iscsi_boot_install = False
+ if os.access("/.iscsi_boot", os.R_OK):
+ _dbg_msg('Determined to be doing iSCSI boot install')
+ self.iscsi_boot_install = True
#take root poolname from mnttab
# Note there are TABs in the blow expression.
@@ -462,6 +468,11 @@
self.autohome = basedir + autohome
+ # path to System Configuration profile generated by Automated Installer
+ self.ai_sc_profile = ai_sc_profile
+ # name of target System Configuration profile
+ self.sc_profile = target_sc_profile
+
#support methods
def _get_bootprop(self, property_id):
'''support method - get property from bootenv.rc
@@ -637,7 +648,7 @@
if cols[0] == '191':
#don't change active partiton if installing to logical
if partition_number > 4:
- dont_change_active = True
+ dont_change_active = True
if cols[1] != '128':
cols[1] = '128' #active partition
made_fdisk_changes = True
@@ -661,7 +672,8 @@
fdiskout.append(lnout)
partition_number = partition_number + 1
if dont_change_active:
- _dbg_msg('Install partition is logical partition. Active partition not changed.')
+ _dbg_msg('Install partition is logical partition.'
+ ' Active partition not changed.')
return 0
if not made_fdisk_changes:
_dbg_msg('No disk format changes - fdisk not run')
@@ -1308,7 +1320,10 @@
('ns_dns.xml',
self.basedir + '/etc/svc/profile/name_service.xml'),
('inetd_generic.xml',
- self.basedir + '/etc/svc/profile/inetd_services.xml')):
+ self.basedir + '/etc/svc/profile/inetd_services.xml'),
+ (self.sc_profile,
+ self.basedir + '/etc/svc/profile/site.xml')):
+
try:
os.unlink(dst)
except OSError, (errno, strerror):
@@ -1358,12 +1373,8 @@
'''
_register_task(inspect.currentframe())
sys_unconfig_entries = [
- '/lib/svc/method/sshd',
'/usr/sbin/sysidkbd',
- '/usr/lib/cc-ccr/bin/eraseCCRRepository',
'/usr/sbin/sysidpm',
- '/usr/lib/scn/bin/cleanup-scn-base',
- '/lib/svc/method/net-nwam',
]
return_status = 0
try:
@@ -1423,62 +1434,6 @@
return return_status
- def _enable_nwam_in_svccfg(self):
- '''support method: enable NWAM service in service repository
- disable network/physical:default
- returns 0 for success, otherwise error code
- '''
- svccfg_repository = self.basedir + '/etc/svc/repository.db'
- svccfg_tempfile = '/tmp/svccfg_enable_nwam'
-
- #Check for existence of altroot repository
- if not os.path.exists(svccfg_repository):
- prerror('Error: service repository does not exist: file ' + svccfg_repository)
- prerror('NWAM service might not be enabled on reboot.')
- prerror('Failure. Returning: ICT_SVCCFG_FAILURE')
- return ICT_SVCCFG_FAILURE
- #write svccfg file and execute with svccfg -f
- try:
- fop = open(svccfg_tempfile, 'w')
- fop.write("select network/physical:nwam\n")
- fop.write("setprop general/enabled=true\n")
- fop.write("select network/physical:default\n")
- fop.write("setprop general/enabled=false\n")
- fop.write("exit\n")
- fop.close()
- except OSError, (errno, strerror):
- prerror('Error in writing to svccfg command file. ' + strerror)
- prerror('NWAM service might not be enabled on reboot.')
- prerror('Failure. Returning: ICT_SVCCFG_FAILURE')
- return ICT_SVCCFG_FAILURE
- except:
- prerror('Unexpected error in writing to svccfg command file.')
- prerror(traceback.format_exc()) #traceback to stdout and log
- prerror('NWAM service might not be enabled on reboot.')
- prerror('Failure. Returning: ICT_SVCCFG_FAILURE')
- return ICT_SVCCFG_FAILURE
-
- #set environment variable temporarily to write to altroot service repository
- origenv = os.getenv('SVCCFG_REPOSITORY')
- os.putenv('SVCCFG_REPOSITORY', svccfg_repository)
-
- # modify service configuration to enable NWAM on reboot
- cmd = '/usr/sbin/svccfg -f ' + svccfg_tempfile
- status = _cmd_status(cmd)
-
- #restore original environment variable
- if origenv: #putenv does not accept "None"
- os.putenv('SVCCFG_REPOSITORY', origenv)
- else:
- os.unsetenv('SVCCFG_REPOSITORY')
- if status != 0:
- prerror('Unexpected error issuing ' + cmd)
- prerror('NWAM service might not be enabled on reboot.')
- prerror('Failure. Returning: ICT_SVCCFG_FAILURE')
- return ICT_SVCCFG_FAILURE
-
- return 0
-
def configure_nwam(self):
'''ICT - configure nwam by creating /etc/nwam/llp with
the preferred interface followed by dhcp in it.
@@ -1534,65 +1489,6 @@
return 0
- def enable_nwam_ai(self):
- '''ICT - Enable nwam service in AI environment
- If running in an autoinstall environment,
- add file /var/svc/profile/upgrade, which is a
- hack to enable nwam and can be taken out once
- the nwam profile is included
- in the SMF global seed repository
-
- return 0, otherwise error status
- '''
- _register_task(inspect.currentframe())
-
- return_status = 0
- op = None
-
- """
- For ISCSI boot, if the NWAM service transitions from disabled
- to enabled during boot, the connection to the iSCSI boot target
- will be lost. If the system is booted with NWAM already enabled,
- the iSCSI boot target connection is maintained.
-
- As a workaround for this NWAM behavior, the service repository
- is modified so that system is booted with NWAM already enabled
- for iSCSI boot.
- """
- if self.iscsi_boot_install:
- info_msg('iSCSI boot - enable nwam in service repository')
- return self._enable_nwam_in_svccfg()
-
- upgradefile = self.basedir + '/var/svc/profile/upgrade'
- disable_net_def = '/usr/sbin/svcadm disable network/physical:default'
- enable_net_nwam = '/usr/sbin/svcadm enable network/physical:nwam'
-
- try:
- op = open(upgradefile, 'a')
- #add the line with the updated property
- op.write(disable_net_def + '\n')
- op.write(enable_net_nwam + '\n')
- except OSError, (errno, strerror):
- prerror('Update to <target>/var/svc/profile/upgrade to enable ' +
- 'nwam failed. ' + strerror + ' file=' + upgradefile +
- 'failed to add the lines:\n' + disable_net_def +
- '\n' + enable_net_nwam + '\n')
- prerror('Failure. Returning: ICT_ENABLE_NWAM_AI_FAILED')
- return_status = ICT_ENABLE_NWAM_AI_FAILED
- except StandardError:
- prerror('Unexpected error during updating to ' +
- '<target>/var/svc/profile/upgrade to enable nwam. ' +
- ' file=' + upgradefile + 'failed to add the lines:\n' +
- disable_net_def + '\n' + enable_net_nwam + '\n')
- prerror(traceback.format_exc()) #traceback to stdout and log
- prerror('Failure. Returning: ICT_ENABLE_NWAM_AI_FAILED')
- return_status = ICT_ENABLE_NWAM_AI_FAILED
-
- if op != None:
- op.close()
-
- return return_status
-
def enable_nwam(self):
'''ICT - Enable nwam service
SVCCFG_DTD=basedir + '/usr/share/lib/xml/dtd/service_bundle.dtd.1'
@@ -2389,7 +2285,7 @@
try:
shutil.copy2("/boot/grub/menu.lst", self.basedir +
"/boot/grub/menu.lst")
- except (OSError,IOError) as err:
+ except (OSError, IOError) as err:
prerror('Error copying /boot/grub/menu.lst to ' +
self.basedir + '/boot/grub/menu.lst :' + str(err))
@@ -2556,6 +2452,64 @@
return return_status
+ def apply_sysconfig_profile(self):
+ '''ICT - apply system configuration SMF profile to the target.
+ The SMF profile will be applied during first boot as part of
+ Early Manifest Import process.
+
+ Carry out only syntactic validation of SMF profile.
+
+ return 0 on success, error code otherwise
+ '''
+ _register_task(inspect.currentframe())
+
+ sc_profile_src = self.ai_sc_profile
+ sc_profile_dst = self.basedir + '/etc/svc/profile/' + \
+ self.sc_profile
+ os.environ["SVCCFG_DTD"] = self.basedir + \
+ '/usr/share/lib/xml/dtd/service_bundle.dtd.1'
+ os.environ["SVCCFG_REPOSITORY"] = self.basedir + \
+ '/etc/svc/repository.db'
+ cmd = '/usr/sbin/svccfg apply -n ' + sc_profile_src + ' 2>&1'
+ status, oa = _cmd_out(cmd)
+
+ if status == 0:
+ write_log(ICTID, 'Syntactic validation of System configuration '
+ 'profile succeeded\n')
+ else:
+ prerror('Syntactic validation of System configuration profile '
+ 'failed. exit status=' + str(status))
+ prerror('Command to validate configuration profile was: ' + cmd)
+ for ln in oa:
+ prerror(ln)
+
+ prerror('Failure. Returning: ICT_APPLY_SYSCONFIG_FAILED')
+ return ICT_APPLY_SYSCONFIG_FAILED
+
+ # copy SMF profile to the target and make sure it can be read only
+ # by root in order to protect encrypted password for configured
+ # root and user accounts
+ try:
+ shutil.copyfile(sc_profile_src, sc_profile_dst)
+ os.chmod(sc_profile_dst, S_IRUSR) # read-only by user (root)
+ os.chown(sc_profile_dst, 0, 3) # chown root:sys
+
+ except OSError, (errno, strerror):
+ prerror('Error when copying System Configuration profile ' +
+ sc_profile_src + ' to ' + sc_profile_dst + ' : ' +
+ strerror)
+ prerror('Failure. Returning: ICT_APPLY_SYSCONFIG_FAILED')
+ return ICT_APPLY_SYSCONFIG_FAILED
+ except StandardError:
+ prerror('Unexpected error when copying System Configuration ' +
+ ' profile ' + sc_profile_src + ' to ' + sc_profile_dst)
+ prerror(traceback.format_exc()) #traceback to stdout and log
+ prerror('Failure. Returning: ICT_APPLY_SYSCONFIG_FAILED')
+ return ICT_APPLY_SYSCONFIG_FAILED
+
+ return 0
+
+
def ict_test(self, optparm=None):
'''ICT - ict test
This ict can be used to test the ICT object from the command line.
--- a/usr/src/lib/liborchestrator/orchestrator_private.h Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/lib/liborchestrator/orchestrator_private.h Tue Jul 06 09:11:29 2010 +0200
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _ORCHESTRATOR_PRIVATE_H
@@ -284,8 +283,6 @@
extern int16_t om_errno;
extern om_handle_t omh;
extern boolean_t whole_disk; /* slim install */
-extern char *zfs_fs_names[ZFS_FS_NUM];
-extern char *zfs_shared_fs_names[ZFS_SHARED_FS_NUM];
/*
* private prototypes
--- a/usr/src/lib/liborchestrator/perform_slim_install.c Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/lib/liborchestrator/perform_slim_install.c Tue Jul 06 09:11:29 2010 +0200
@@ -101,11 +101,12 @@
/*
* l_zfs_shared_fs_num is the local representation of ZFS_SHARED_FS_NUM
- * l_zfs_shared_fs_num is initially set to ZFS_SHARED_FS_NUM but
- * if the user does not want a user account the value will be
- * reduced by one.
+ * l_zfs_shared_fs_num is initially set to ZFS_SHARED_FS_NUM - 1 and
+ * if the user wants to create user account and is running interactive
+ * installer, the value will be increased by one to count in home directory
+ * ZFS dataset.
*/
-static int l_zfs_shared_fs_num = ZFS_SHARED_FS_NUM;
+static int l_zfs_shared_fs_num = ZFS_SHARED_FS_NUM - 1;
static om_callback_t om_cb;
static char zfs_device[MAXDEVSIZE];
@@ -115,30 +116,6 @@
static char *zfs_shared_fs_names[ZFS_SHARED_FS_NUM] =
{"/export", "/export/home", zfs_shared_user_login};
static image_info_t image_info = {B_FALSE, 4096, 1.0, "off"};
-static int tm_percentage_done = 0;
-
-static struct _shortloclist {
- const char *shortloc;
- boolean_t added;
-} shortloclist[] = {
- /*
- * sorting in reverse alphabetical order since
- * entry for substring (e.g. "zh") needs to come
- * before longer name (e.g. "zh_TW" or "zh_HK")
- */
- { "zh_TW", B_FALSE },
- { "zh_HK", B_FALSE },
- { "zh", B_FALSE },
- { "sv", B_FALSE },
- { "pt_BR", B_FALSE },
- { "ko", B_FALSE },
- { "ja", B_FALSE },
- { "it", B_FALSE },
- { "fr", B_FALSE },
- { "es", B_FALSE },
- { "de", B_FALSE },
- { NULL, B_FALSE },
-};
extern char **environ;
@@ -146,13 +123,8 @@
* local functions
*/
-
-static void add_shortloc(const char *locale, FILE *fp);
static char *find_state_file();
-static void init_shortloclist(void);
-static void read_and_save_locale(char *path);
static void remove_component(char *path);
-static int replace_db(char *name, char *value);
static void set_system_state(void);
static int trav_link(char **path);
static void write_sysid_state(sys_config *sysconfigp);
@@ -177,7 +149,6 @@
static void setup_etc_vfstab_for_swap(char *target);
static int reset_zfs_mount_property(char *target, int transfer_mode);
static void activate_be(char *be_name);
-static void transfer_config_files(char *target, int transfer_mode);
static void handle_TM_callback(const int percent, const char *message);
static int prepare_zfs_root_pool_attrs(nvlist_t **attrs, char *disk_name,
uint8_t slice_id);
@@ -231,7 +202,7 @@
return (OM_FAILURE);
}
- if (ret = be_unmount(be_attrs) != BE_SUCCESS) {
+ if ((ret = be_unmount(be_attrs)) != BE_SUCCESS) {
om_log_print("Couldn't unmount target BE,"
" be_unmount() failed with return code %d\n", ret);
nvlist_free(be_attrs);
@@ -277,13 +248,17 @@
om_perform_install(nvlist_t *uchoices, om_callback_t cb)
{
char *name;
- char *lname = NULL, *rpasswd = NULL, *hostname = NULL,
- *uname = NULL, *upasswd = NULL;
+ char *lname = EMPTY_STR;
+ char *rpasswd = OM_DEFAULT_ROOT_PASSWORD;
+ char *hostname = EMPTY_STR;
+ char *uname = EMPTY_STR;
+ char *upasswd = OM_DEFAULT_USER_PASSWORD;
int status = OM_SUCCESS;
nvlist_t *target_attrs = NULL, **transfer_attr;
uint_t transfer_attr_num;
uint8_t type;
char *ti_test = getenv("TI_SLIM_TEST");
+ char *nv_string;
int ret = 0;
if (uchoices == NULL) {
@@ -362,99 +337,113 @@
om_debug_print(OM_DBGLVL_INFO, "Default locale specified: %s\n",
def_locale);
}
- /*
- * Get the root password
- */
- if (nvlist_lookup_string(uchoices,
- OM_ATTR_ROOT_PASSWORD, &rpasswd) != 0) {
- /*
- * Root password is not passed, so don't set it
- * Log the information and set the default password
- */
- om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_ROOT_PASSWORD not set,"
- "set the default root password\n");
- om_log_print("Root password not specified, set to default\n");
- rpasswd = OM_DEFAULT_ROOT_PASSWORD;
- } else {
- om_debug_print(OM_DBGLVL_INFO, "Got root passwd\n");
- }
/*
- * Get the user name,if set, which is different than the login
- * name.
+ * In case of automated installation (AI), user and root accounts
+ * are configured on installed system at the first boot
+ * by svc:/system/install/config SMF service. Thus for AI scenario,
+ * just skip dealing with this kind of configuration in the installer.
*/
- if (nvlist_lookup_string(uchoices,
- OM_ATTR_USER_NAME, &uname) != 0) {
- /*
- * User name is not passed, so don't set it
- * Log the information and continue
- */
- om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_USER_NAME not set,"
- "User name not available\n");
- om_log_print("User name not specified\n");
- }
- if (uname) {
- om_debug_print(OM_DBGLVL_INFO, "User name set to "
- "%s\n", uname);
-
- } else {
- uname = EMPTY_STR;
- }
-
- if (nvlist_lookup_string(uchoices, OM_ATTR_LOGIN_NAME, &lname) != 0) {
+ if (!om_is_automated_installation()) {
/*
- * No login name, don't worry about getting passwd info.
- * Log this data and move on.
+ * Get the root password
*/
- l_zfs_shared_fs_num = ZFS_SHARED_FS_NUM - 1;
- lname = EMPTY_STR;
- upasswd = OM_DEFAULT_USER_PASSWORD;
- om_debug_print(OM_DBGLVL_WARN,
- "OM_ATTR_LOGIN_NAME not set,"
- "User login name not available\n");
- om_log_print("User login name not specified\n");
- } else {
+ if (nvlist_lookup_string(uchoices,
+ OM_ATTR_ROOT_PASSWORD, &nv_string) != 0) {
+ /*
+ * Root password is not passed, so don't set it,
+ * just log the information.
+ */
+ om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_ROOT_PASSWORD "
+ " not set, set the default root password\n");
+ om_log_print("Root password not specified, set to "
+ " default\n");
+ } else {
+ rpasswd = nv_string;
+ om_debug_print(OM_DBGLVL_INFO, "Got root passwd\n");
+ }
+
/*
- * we got the user name.
- * Get the password
+ * Get the user name,if set, which is different than the login
+ * name.
*/
- om_debug_print(OM_DBGLVL_INFO, "User login name set to "
- "%s\n", lname);
-
- (void) snprintf(zfs_shared_user_login,
- sizeof (zfs_shared_user_login),
- "/export/home/%s", lname);
-
- om_debug_print(OM_DBGLVL_INFO, "zfs shared user login set to "
- "%s\n", zfs_shared_user_login);
if (nvlist_lookup_string(uchoices,
- OM_ATTR_USER_PASSWORD, &upasswd) != 0) {
- /* Password not specified, use default value */
- upasswd = OM_DEFAULT_USER_PASSWORD;
+ OM_ATTR_USER_NAME, &nv_string) != 0) {
+ /*
+ * User name is not passed, so don't set it
+ * Log the information and continue
+ */
+ om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_USER_NAME "
+ "not set, User name not available\n");
+ om_log_print("User name not specified\n");
} else {
+ uname = nv_string;
+
+ om_debug_print(OM_DBGLVL_INFO, "User name set to "
+ "%s\n", uname);
+ }
+
+ if (nvlist_lookup_string(uchoices, OM_ATTR_LOGIN_NAME,
+ &nv_string) != 0) {
+ /*
+ * No login name, don't worry about getting passwd info.
+ * Log this data and move on.
+ */
+ om_debug_print(OM_DBGLVL_WARN,
+ "OM_ATTR_LOGIN_NAME not set,"
+ "User login name not available\n");
+ om_log_print("User login name not specified\n");
+ } else {
+ lname = nv_string;
/*
- * Got user name and password
+ * User account will be created - count in shared ZFS
+ * dataset which will be created for user's
+ * home directory
+ */
+ l_zfs_shared_fs_num++;
+
+ /*
+ * we got the user name.
+ * Get the password
*/
- om_debug_print(OM_DBGLVL_INFO, "Got user password\n");
+ om_debug_print(OM_DBGLVL_INFO, "User login name set to "
+ "%s\n", lname);
+
+ (void) snprintf(zfs_shared_user_login,
+ sizeof (zfs_shared_user_login),
+ "/export/home/%s", lname);
+
+ om_debug_print(OM_DBGLVL_INFO, "zfs shared user login "
+ "set to %s\n", zfs_shared_user_login);
+
+ if (nvlist_lookup_string(uchoices,
+ OM_ATTR_USER_PASSWORD, &nv_string) == 0) {
+ upasswd = nv_string;
+
+ /*
+ * Got user name and password
+ */
+ om_debug_print(OM_DBGLVL_INFO,
+ "Got user password\n");
+ }
}
}
if (nvlist_lookup_string(uchoices, OM_ATTR_HOST_NAME,
- &hostname) != 0) {
+ &nv_string) != 0) {
/*
* User has cleared default host name for some reason.
* NWAM will use dhcp so a dhcp address will become
* the host/nodename.
*/
- hostname = EMPTY_STR;
om_debug_print(OM_DBGLVL_WARN, "OM_ATTR_HOST_NAME "
"not set,"
"User probably cleared default host name\n");
-
} else {
+ hostname = nv_string;
/*
* Hostname will be set in function call_transfer_module
* using ICT ict_set_host_node_name
@@ -1686,15 +1675,42 @@
}
/*
- * Create user directory if needed
+ * Configure user account - only for interactive installers
+ * In case of automated installation (AI), user and root accounts
+ * are configured on installed system at the first boot
+ * by svc:/system/install/config SMF service. Thus for AI scenario,
+ * just skip dealing with this kind of configuration in the installer.
*/
- if (ict_configure_user_directory(INSTALLED_ROOT_DIR,
- tcb_args->lname) != ICT_SUCCESS) {
- om_log_print("Couldn't configure user directory\n"
- "for user: %s\n%s\n", tcb_args->lname,
- ICT_STR_ERROR(ict_errno));
- status = -1;
+ if (!om_is_automated_installation()) {
+ /* Configure user directory */
+ if (ict_configure_user_directory(INSTALLED_ROOT_DIR,
+ tcb_args->lname) != ICT_SUCCESS) {
+ om_log_print("Couldn't configure user directory\n"
+ "for user: %s\n%s\n", tcb_args->lname,
+ ICT_STR_ERROR(ict_errno));
+ status = -1;
+ }
+
+ /* Create personal initialization files */
+ if (ict_set_user_profile(tcb_args->target, tcb_args->lname) !=
+ ICT_SUCCESS) {
+ om_log_print("Couldn't set the user environment\n"
+ "for user: %s\n%s\n",
+ tcb_args->lname, ICT_STR_ERROR(ict_errno));
+ status = -1;
+ }
+
+ /*
+ * configure root account as a role and assign root role to user
+ */
+ if (ict_set_user_role(tcb_args->target, tcb_args->lname,
+ transfer_mode) != ICT_SUCCESS) {
+ om_log_print("Couldn't set the user role\n"
+ "for user: %s\n%s\n", tcb_args->lname,
+ ICT_STR_ERROR(ict_errno));
+ status = -1;
+ }
}
/*
@@ -1714,14 +1730,6 @@
status = -1;
}
- if (ict_set_user_profile(tcb_args->target, tcb_args->lname) !=
- ICT_SUCCESS) {
- om_log_print("Couldn't set the user environment\n"
- "for user: %s\n%s\n",
- tcb_args->lname, ICT_STR_ERROR(ict_errno));
- status = -1;
- }
-
activate_be(INIT_BE_NAME);
if (ict_installboot(tcb_args->target, zfs_device,
@@ -1731,14 +1739,6 @@
status = -1;
}
- if (ict_set_user_role(tcb_args->target, tcb_args->lname,
- transfer_mode) != ICT_SUCCESS) {
- om_log_print("Couldn't set the user role\n"
- "for user: %s\n%s\n", tcb_args->lname,
- ICT_STR_ERROR(ict_errno));
- status = -1;
- }
-
/*
* run_install_finish_script performs a group of ICT
*/
@@ -1824,7 +1824,6 @@
cb_data.percentage_done = percent;
cb_data.message = message;
om_cb(&cb_data, 0);
- tm_percentage_done = percent;
}
@@ -2000,87 +1999,6 @@
}
-static int
-replace_db(char *name, char *value)
-{
-
- FILE *ifp, *ofp; /* Input & output files */
- int tmp;
- char *tmpdir; /* Temp file name and location */
- char *tdb;
-
- /*
- * Generate temporary file name to use. We make sure it's in the same
- * directory as the db we're processing so that we can use rename to
- * do the replace later. Otherwise we run the risk of being on the
- * wrong filesystem and having rename() fail for that reason.
- */
- if (name == NULL || value == NULL) {
- om_debug_print(OM_DBGLVL_INFO,
- "Invalid values for replacing db\n");
- return (OM_FAILURE);
- }
- tdb = strdup(name);
- if (tdb == NULL) {
- om_set_error(OM_NO_SPACE);
- om_log_print("Could not allocate space for %s\n", name);
- return (OM_FAILURE);
- }
- if (trav_link(&tdb) == -1) {
- om_set_error(OM_NO_SUCH_DB_FILE);
- om_log_print("Couldn't fine db file %s\n", name);
- return (OM_FAILURE);
- }
-
- tmpdir = (char *)malloc(strlen(tdb) + 7);
- if (tmpdir == NULL) {
- om_set_error(OM_NO_SPACE);
- return (OM_FAILURE);
- }
- (void) memset(tmpdir, 0, strlen(tdb) + 7);
-
- (void) snprintf(tmpdir, strlen(tdb), "%s", tdb);
- (void) strcat(tmpdir, "XXXXXX");
- if ((tmp = mkstemp(tmpdir)) == -1) {
- om_debug_print(OM_DBGLVL_ERR,
- "Can't create temp file for replacing db\n");
- om_set_error(OM_CANT_CREATE_TMP_FILE);
- free(tmpdir);
- return (OM_FAILURE);
- }
-
- ofp = fdopen(tmp, "w");
- if (ofp == NULL) {
- om_set_error(OM_CANT_CREATE_TMP_FILE);
- return (OM_FAILURE);
- }
-
- if (fprintf(ofp, "%s\n", value) == EOF) {
- om_set_error(OM_CANT_WRITE_TMP_FILE);
- (void) fclose(ofp);
- return (OM_FAILURE);
- }
-
- /* Quick check to make sure we have read & write rights to the file */
- if ((ifp = fopen(tdb, "w")) != NULL)
- (void) fclose(ifp);
- else if (errno != ENOENT) {
- om_debug_print(OM_DBGLVL_ERR,
- "Cannot open file to rename to\n");
- return (OM_FAILURE);
- }
- (void) fclose(ofp);
-
- if (rename(tmpdir, tdb) != 0) {
- free(tmpdir);
- om_set_error(OM_SETNODE_FAILURE);
- om_debug_print(OM_DBGLVL_ERR,
- "Could not rename file %s to %s\n", tmp, name);
- return (OM_FAILURE);
- }
- return (OM_SUCCESS);
-}
-
static char *
find_state_file()
{
@@ -2243,31 +2161,6 @@
(void) fclose(fp);
}
-static void
-add_shortloc(const char *locale, FILE *fp)
-{
- struct _shortloclist *p = NULL;
-
- for (p = shortloclist; p->shortloc != NULL; p++) {
- if (strncmp(p->shortloc, locale, strlen(p->shortloc)) == 0) {
- if (p->added == B_FALSE) {
- (void) fprintf(fp, "locale %s\n", p->shortloc);
- p->added = B_TRUE;
- }
- break;
- }
- }
-}
-
-static void
-init_shortloclist(void)
-{
- struct _shortloclist *p = NULL;
- for (p = shortloclist; p->shortloc != NULL; p++) {
- p->added = B_FALSE;
- }
-}
-
/*
* Inform GUI of error condition through callback
*/
@@ -2300,44 +2193,6 @@
om_cb(&cb_data, 0);
}
-static void
-read_and_save_locale(char *path)
-{
- char lc_collate[MAX_LOCALE];
- char lc_ctype[MAX_LOCALE];
- char lc_messages[MAX_LOCALE];
- char lc_monetary[MAX_LOCALE];
- char lc_numeric[MAX_LOCALE];
- char lc_time[MAX_LOCALE];
- char lang[MAX_LOCALE];
- FILE *tmpfp = NULL;
- FILE *deffp = NULL;
-
- if (path[0] == '\0')
- return;
-
- tmpfp = fopen(path, "r");
- if (tmpfp == NULL)
- return;
-
- (void) read_locale_file(tmpfp, lang, lc_collate, lc_ctype,
- lc_messages, lc_monetary, lc_numeric, lc_time);
-
- (void) fclose(tmpfp);
-
- deffp = fopen(TMP_DEFSYSLOC, "w");
- if (deffp == NULL) {
- return;
- }
-
- /*
- * Don't care about error. If error, then system will behave
- * as it does currently during SUUpgrade.
- */
- fprintf(deffp, "%s\n", lc_ctype);
- (void) fclose(deffp);
-}
-
/*
* Add swap entry to /etc/vfstab
*/
--- a/usr/src/pkg/manifests/SUNWslim-utils.mf Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkg/manifests/SUNWslim-utils.mf Tue Jul 06 09:11:29 2010 +0200
@@ -39,6 +39,10 @@
dir path=jack/Documents owner=jack group=staff
dir path=lib
dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
+dir path=lib/svc/manifest/system/device group=sys
+dir path=lib/svc/manifest/system/filesystem group=sys
dir path=lib/svc/method
dir path=lib/svc/share
dir path=mnt group=sys
@@ -49,12 +53,6 @@
dir path=usr/lib/install
dir path=usr/sbin
dir path=usr/share group=sys
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
-dir path=var/svc/manifest/system/device group=sys
-dir path=var/svc/manifest/system/filesystem group=sys
file path=etc/svc/profile/network_nwam.xml mode=0444 group=sys
file path=jack/.bashrc mode=0755 owner=jack group=staff
file path=jack/.config/autostart/iotrace.desktop owner=jack group=staff
@@ -68,6 +66,12 @@
file path=jack/Desktop/gparted.desktop owner=jack group=staff
file path=jack/Desktop/install_opensolaris.desktop owner=jack group=staff
file path=jack/xorg.conf.vesa owner=jack group=staff
+file path=lib/svc/manifest/system/filesystem/live-root-fs-minimal.xml mode=0444 group=sys
+file path=lib/svc/manifest/system/filesystem/live-root-fs.xml mode=0444 group=sys
+file path=lib/svc/manifest/system/filesystem/live-usr-fs.xml mode=0444 group=sys
+file path=lib/svc/manifest/system/live-a11y.xml mode=0444 group=sys
+file path=lib/svc/manifest/system/live-io-tracing.xml mode=0444 group=sys
+file path=lib/svc/manifest/system/live-sysidtool.xml mode=0444 group=sys
file path=lib/svc/method/live-a11y mode=0555
file path=lib/svc/method/live-fs-root-minimal mode=0555
file path=lib/svc/method/live-io-tracing mode=0555
@@ -81,12 +85,6 @@
file path=usr/lib/install/live_img_pkg5_prep mode=0555
file path=usr/sbin/iotrace
file path=usr/sbin/set_lang mode=0555
-file path=var/svc/manifest/system/filesystem/live-root-fs-minimal.xml mode=0444 group=sys
-file path=var/svc/manifest/system/filesystem/live-root-fs.xml mode=0444 group=sys
-file path=var/svc/manifest/system/filesystem/live-usr-fs.xml mode=0444 group=sys
-file path=var/svc/manifest/system/live-a11y.xml mode=0444 group=sys
-file path=var/svc/manifest/system/live-io-tracing.xml mode=0444 group=sys
-file path=var/svc/manifest/system/live-sysidtool.xml mode=0444 group=sys
license cr_Sun license=cr_Sun
license lic_CDDL license=lic_CDDL
user username=jack uid=65432 group=staff gcos-field="Default User" home-dir=/jack \
--- a/usr/src/pkg/manifests/install-installadm.mf Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkg/manifests/install-installadm.mf Tue Jul 06 09:11:29 2010 +0200
@@ -40,6 +40,9 @@
dir path=lib
dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
+dir path=lib/svc/manifest/system/install group=sys
dir path=lib/svc/method
dir path=usr group=sys
dir path=usr/lib
@@ -70,10 +73,7 @@
dir path=var/installadm/ai-webserver/AI_data group=sys
dir path=var/installadm/ai-webserver/AI_files group=sys
dir path=var/installadm/services group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
-dir path=var/svc/manifest/system/install group=sys
+file path=lib/svc/manifest/system/install/server.xml group=sys
file path=lib/svc/method/svc-install-server mode=0555
file path=usr/lib/installadm/check-server-setup
file path=usr/lib/installadm/create_client.py
@@ -158,7 +158,6 @@
file path=usr/share/man/man1m/installadm.1m mode=0444
file path=var/installadm/ai-webserver/ai-httpd.conf
file path=var/installadm/ai-webserver/AI.db
-file path=var/svc/manifest/system/install/server.xml group=sys
license cr_Sun license=cr_Sun
license lic_CDDL license=lic_CDDL
link path=usr/lib/installadm/create-client target=create_client.py
--- a/usr/src/pkg/manifests/system-install-auto-install.mf Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkg/manifests/system-install-auto-install.mf Tue Jul 06 09:11:29 2010 +0200
@@ -30,32 +30,32 @@
set name=variant.opensolaris.zone value=global
dir path=lib
dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/application group=sys
dir path=lib/svc/method
dir path=usr group=sys
dir path=usr/bin
dir path=usr/sbin
dir path=usr/lib
+dir path=usr/lib/install
dir path=usr/lib/python2.6
dir path=usr/lib/python2.6/vendor-packages
dir path=usr/lib/python2.6/vendor-packages/osol_install
dir path=usr/lib/python2.6/vendor-packages/osol_install/auto_install
dir path=usr/share group=sys
dir path=usr/share/auto_install group=sys
-dir path=var group=sys
-dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/application group=sys
file path=lib/svc/method/auto-installer mode=0555
file path=lib/svc/method/manifest-locator mode=0555
file path=usr/bin/ai_get_manifest mode=0555
file path=usr/bin/ai_sd mode=0555
file path=usr/bin/auto-install mode=0555
+file path=usr/lib/install/sc_conv.ksh mode=0555
file path=usr/lib/python2.6/vendor-packages/osol_install/auto_install/ai_parse_manifest.py mode=0444
file path=usr/lib/python2.6/vendor-packages/osol_install/auto_install/ai_parse_manifest.pyc mode=0444
file path=usr/sbin/get_manifest mode=0555
file path=usr/share/auto_install/ai_manifest.defval.xml group=sys
-file path=var/svc/manifest/application/auto-installer.xml mode=0444 group=sys
-file path=var/svc/manifest/application/manifest-locator.xml mode=0444 group=sys
+file path=lib/svc/manifest/application/auto-installer.xml mode=0444 group=sys
+file path=lib/svc/manifest/application/manifest-locator.xml mode=0444 group=sys
license cr_Sun license=cr_Sun
license lic_CDDL license=lic_CDDL
link path=usr/lib/python2.6/vendor-packages/osol_install/auto_install/ai_get_manifest.py target=../../../../../bin/ai_get_manifest
--- a/usr/src/pkg/manifests/system-install-text-install.mf Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkg/manifests/system-install-text-install.mf Tue Jul 06 09:11:29 2010 +0200
@@ -28,6 +28,10 @@
set name=info.classification value="org.opensolaris.category.2008:System/Administration and Configuration"
set name=variant.arch value=$(ARCH)
set name=variant.opensolaris.zone value=global
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
dir path=opt group=sys
dir path=opt/install-test group=sys
dir path=opt/install-test/bin
@@ -46,8 +50,7 @@
dir path=usr/share/text-install/help/C group=sys
dir path=var group=sys
dir path=var/svc group=sys
-dir path=var/svc/manifest group=sys
-dir path=var/svc/manifest/system group=sys
+file path=lib/svc/manifest/system/text-mode-menu.xml mode=0444 group=sys
file path=opt/install-test/bin/ict_test mode=0555
file path=usr/bin/text-install mode=0555 group=sys
file path=usr/lib/python2.6/vendor-packages/osol_install/profile/__init__.py mode=0444
@@ -145,6 +148,5 @@
file path=usr/share/text-install/help/C/x86_fdisk_partitions.txt group=sys
file path=usr/share/text-install/help/C/x86_fdisk_slices_select.txt group=sys
file path=usr/share/text-install/help/C/x86_fdisk_slices.txt group=sys
-file path=var/svc/manifest/system/text-mode-menu.xml mode=0444 group=sys
license cr_Sun license=cr_Sun
license lic_CDDL license=lic_CDDL
--- a/usr/src/pkg/manifests/system-install.mf Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkg/manifests/system-install.mf Tue Jul 06 09:11:29 2010 +0200
@@ -29,6 +29,11 @@
set name=variant.opensolaris.zone value=global value=nonglobal
depend fmri=install/beadm type=require
depend fmri=library/python-2/python-extra-26 type=require
+dir path=lib
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
+dir path=lib/svc/method
dir path=sbin group=sys
dir path=usr group=sys
dir path=usr/bin
@@ -45,6 +50,9 @@
dir path=usr/share/lib/xml/rng group=sys
dir path=usr/snadm
dir path=usr/snadm/lib
+
+file path=lib/svc/manifest/system/install/system-config.xml mode=0444 group=sys
+file path=lib/svc/method/svc-system-config mode=0555
file path=sbin/install-finish mode=0555
file path=usr/bin/ManifestRead mode=0555
file path=usr/bin/ManifestServ mode=0555
--- a/usr/src/pkgdefs/SUNWauto-install-common/prototype_com Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkgdefs/SUNWauto-install-common/prototype_com Tue Jul 06 09:11:29 2010 +0200
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# This required package information file contains a list of package contents.
@@ -48,6 +47,12 @@
f none usr/lib/python2.6/vendor-packages/osol_install/auto_install/__init__.py 0444 root bin
f none usr/lib/python2.6/vendor-packages/osol_install/auto_install/__init__.pyc 0444 root bin
+#
+# Automated Installer tools
+#
+d none usr/lib/install 0755 root bin
+f none usr/lib/install/sc_conv.ksh 0555 root bin
+
# Automated install manifest related files
d none usr/share 0755 root sys
d none usr/share/auto_install 0755 root sys
--- a/usr/src/pkgdefs/SUNWauto-install/prototype_com Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkgdefs/SUNWauto-install/prototype_com Tue Jul 06 09:11:29 2010 +0200
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# This required package information file contains a list of package contents.
@@ -62,13 +61,11 @@
d none lib 755 root bin
d none lib/svc 755 root bin
+d none lib/svc/manifest 0755 root sys
+d none lib/svc/manifest/application 0755 root sys
+f none lib/svc/manifest/application/auto-installer.xml 0444 root sys
+f none lib/svc/manifest/application/manifest-locator.xml 0444 root sys
d none lib/svc/method 755 root bin
f none lib/svc/method/auto-installer 555 root bin
f none lib/svc/method/manifest-locator 555 root bin
-d none var 0755 root sys
-d none var/svc 0755 root sys
-d none var/svc/manifest 0755 root sys
-d none var/svc/manifest/application 0755 root sys
-f none var/svc/manifest/application/auto-installer.xml 0444 root sys
-f none var/svc/manifest/application/manifest-locator.xml 0444 root sys
--- a/usr/src/pkgdefs/SUNWinstall/prototype_com Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkgdefs/SUNWinstall/prototype_com Tue Jul 06 09:11:29 2010 +0200
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
@@ -37,6 +36,16 @@
i pkginfo
i copyright
i depend
+
+d none lib 755 root bin
+d none lib/svc 755 root bin
+d none lib/svc/manifest 0755 root sys
+d none lib/svc/manifest/system 0755 root sys
+d none lib/svc/manifest/system/install 0755 root sys
+f none lib/svc/manifest/system/install/system-config.xml 0444 root sys
+d none lib/svc/method 755 root bin
+f none lib/svc/method/svc-system-config 555 root bin
+
d none sbin 0755 root sys
d none usr 0755 root sys
d none usr/bin 0755 root bin
--- a/usr/src/pkgdefs/SUNWinstalladm-tools/prototype_com Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkgdefs/SUNWinstalladm-tools/prototype_com Tue Jul 06 09:11:29 2010 +0200
@@ -19,8 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# This required package information file contains a list of package contents.
@@ -152,12 +151,11 @@
d none var/installadm/ai-webserver/AI_files 755 root sys
d none var/installadm/ai-webserver/AI_data 755 root sys
d none var/installadm/services 755 root sys
-d none var/svc 755 root sys
-d none var/svc/manifest 755 root sys
-d none var/svc/manifest/system 755 root sys
-d none var/svc/manifest/system/install 755 root sys
-f none var/svc/manifest/system/install/server.xml 0444 root sys
d none lib 755 root bin
d none lib/svc 0755 root bin
+d none lib/svc/manifest 755 root sys
+d none lib/svc/manifest/system 755 root sys
+d none lib/svc/manifest/system/install 755 root sys
+f none lib/svc/manifest/system/install/server.xml 0444 root sys
d none lib/svc/method 0755 root bin
f none lib/svc/method/svc-install-server 0555 root bin
--- a/usr/src/pkgdefs/SUNWslim-utils/prototype_com Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkgdefs/SUNWslim-utils/prototype_com Tue Jul 06 09:11:29 2010 +0200
@@ -32,6 +32,10 @@
!default 555 root bin
d none .cdrom 755 root sys
+d none etc 755 root sys
+d none etc/svc 755 root sys
+d none etc/svc/profile 755 root sys
+f none etc/svc/profile/network_nwam.xml 444 root sys
d none usr 755 root sys
d none usr/lib 755 root bin
d none usr/lib/install 755 root bin
@@ -61,8 +65,15 @@
d none jack/Documents 755 jack staff
d none lib 755 root bin
d none lib/svc 755 root bin
-d none lib/svc/share 755 root bin
-f none lib/svc/share/live_fs_include.sh 444 root bin
+d none lib/svc/manifest 755 root sys
+d none lib/svc/manifest/system 755 root sys
+d none lib/svc/manifest/system/filesystem 755 root sys
+f none lib/svc/manifest/system/live-a11y.xml 444 root sys
+f none lib/svc/manifest/system/live-io-tracing.xml 444 root sys
+f none lib/svc/manifest/system/live-sysidtool.xml 444 root sys
+f none lib/svc/manifest/system/filesystem/live-root-fs.xml 444 root sys
+f none lib/svc/manifest/system/filesystem/live-root-fs-minimal.xml 444 root sys
+f none lib/svc/manifest/system/filesystem/live-usr-fs.xml 444 root sys
d none lib/svc/method 755 root bin
f none lib/svc/method/live-a11y 555 root bin
f none lib/svc/method/live-fs-root-minimal 555 root bin
@@ -70,21 +81,7 @@
f none lib/svc/method/live-sysidtool-system 555 root bin
f none lib/svc/method/media-fs-root 555 root bin
f none lib/svc/method/net-fs-root 555 root bin
+d none lib/svc/share 755 root bin
+f none lib/svc/share/live_fs_include.sh 444 root bin
d none mnt 755 root sys
d none mnt/misc 755 root sys
-d none var 755 root sys
-d none var/svc 755 root sys
-d none var/svc/manifest 755 root sys
-d none var/svc/manifest/system 755 root sys
-d none var/svc/manifest/system/device 755 root sys
-d none var/svc/manifest/system/filesystem 755 root sys
-f none var/svc/manifest/system/live-a11y.xml 444 root sys
-f none var/svc/manifest/system/live-io-tracing.xml 444 root sys
-f none var/svc/manifest/system/live-sysidtool.xml 444 root sys
-f none var/svc/manifest/system/filesystem/live-root-fs.xml 444 root sys
-f none var/svc/manifest/system/filesystem/live-root-fs-minimal.xml 444 root sys
-f none var/svc/manifest/system/filesystem/live-usr-fs.xml 444 root sys
-d none etc 755 root sys
-d none etc/svc 755 root sys
-d none etc/svc/profile 755 root sys
-f none etc/svc/profile/network_nwam.xml 444 root sys
--- a/usr/src/pkgdefs/SUNWtext-install/prototype_com Thu Jul 01 11:00:04 2010 +0100
+++ b/usr/src/pkgdefs/SUNWtext-install/prototype_com Tue Jul 06 09:11:29 2010 +0200
@@ -37,6 +37,12 @@
i copyright
i depend
+d none lib 0755 root bin
+d none lib/svc 0755 root sys
+d none lib/svc/manifest 0755 root sys
+d none lib/svc/manifest/system 0755 root sys
+f none lib/svc/manifest/system/text-mode-menu.xml 0444 root sys
+
d none usr/bin 0755 root bin
f none usr/bin/text-install 0555 root sys
d none usr 0755 root sys
@@ -144,11 +150,6 @@
f none usr/share/text-install/help/C/x86_fdisk_partitions_select.txt 0644 root sys
f none usr/share/text-install/help/C/x86_fdisk_slices.txt 0644 root sys
f none usr/share/text-install/help/C/x86_fdisk_slices_select.txt 0644 root sys
-d none var 0755 root sys
-d none var/svc 0755 root sys
-d none var/svc/manifest 0755 root sys
-d none var/svc/manifest/system 0755 root sys
-f none var/svc/manifest/system/text-mode-menu.xml 0444 root sys
d none usr/sbin 0755 root bin
f none usr/sbin/text-mode-menu 0555 root bin