7199N/AFrom 1564b58074df543f4e90b2fee79199c5dd36afca Mon Sep 17 00:00:00 2001
7199N/AFrom: Alan Coopersmith <alan.coopersmith@oracle.com>
7199N/ADate: Tue, 29 Dec 2015 13:35:20 -0800
7199N/ASubject: [PATCH 05/19] smf contracts
7199N/ABug 15491359 - SUNBT6720967 gdm is insufficiently contract-aware
7199N/AOriginal date:2008-05-05 owner:yippi type:feature doo:14007
7199N/A 3 files changed, 160 insertions(+)
7199N/A #undef HAVE_SOLARIS_XINERAMA
7199N/Aindex 0ada667..5e97a41 100644
7199N/A@@ -965,6 +965,14 @@ if test "x$enable_rbac_shutdown" != "xno"; then
7199N/A+dnl ---------------------------------------------------------------------------
7199N/A+dnl check for Solaris SMF contract support
7199N/A+dnl ---------------------------------------------------------------------------
7199N/A+AC_MSG_CHECKING(for Solaris SMF contract support)
7199N/A+AC_CHECK_LIB(contract, ct_tmpl_activate, [
7199N/A+ AC_DEFINE(HAVE_SMF_CONTRACTS)
7199N/A+ EXTRA_DAEMON_LIBS="$EXTRA_DAEMON_LIBS -lcontract" ])
7199N/A dnl ---------------------------------------------------------------------------
7199N/A dnl check for backtrace support
7199N/A@@ -117,9 +124,145 @@ session_worker_job_setup_journal_fds (void)
7199N/A+static int contracts_fd = -1;
7199N/A+ const char *errmsg = "opening process contract template";
7199N/A+ * On failure, just continue since it is better to start with
7199N/A+ * children in the same contract than to not start them at all.
7199N/A+ errmsg = "setting contract terms";
7199N/A+ if ((errno = ct_pr_tmpl_set_param (contracts_fd, CT_PR_PGRPONLY)))
7199N/A+ if ((errno = ct_tmpl_set_informative (contracts_fd, CT_PR_EV_HWERR)))
7199N/A+ if ((errno = ct_pr_tmpl_set_fatal (contracts_fd, CT_PR_EV_HWERR)))
7199N/A+ if ((errno = ct_tmpl_set_critical (contracts_fd, 0)))
7199N/A+ errmsg = "setting active template";
7199N/A+ if ((errno = ct_tmpl_activate (contracts_fd)))
7199N/A+ g_debug ("Set active contract");
7199N/A+ (void) close (contracts_fd);
7199N/A+ g_debug ("Error setting up active contract template: %s while %s",
7199N/A+ strerror (errno), errmsg);
7199N/A+contracts_post_fork_child (void)
7199N/A+ /* Clear active template so no new contracts are created on fork */
7199N/A+ if ((errno = (ct_tmpl_clear (contracts_fd)))) {
7199N/A+ "Error clearing active contract template (child): %s",
7199N/A+ g_debug ("Cleared active contract template (child)");
7199N/A+ (void) close (contracts_fd);
7199N/A+contracts_post_fork_parent (int fork_succeeded)
7199N/A+ /* Clear active template, abandon latest contract. */
7199N/A+ if ((errno = ct_tmpl_clear (contracts_fd)))
7199N/A+ g_debug ("Error while clearing active contract template: %s",
7199N/A+ g_debug ("Cleared active contract template (parent)");
7199N/A+ g_debug ("Error getting latest contract: %s",
7199N/A+ if ((errno = ct_status_read (cfd, CTD_COMMON, &status)) != 0) {
7199N/A+ g_debug ("Error getting latest contract ID: %s",
7199N/A+ latest = ct_status_get_id (status);
7199N/A+ if ((snprintf (path, PATH_MAX, CTFS_ROOT "/all/%
ld/ctl",
7199N/A+ (long) latest)) >= PATH_MAX) {
7199N/A+ g_debug ("Error opening the latest contract ctl file: %s",
7199N/A+ cfd = open64 (path, O_WRONLY);
7199N/A+ g_debug ("Error opening the latest contract ctl file: %s",
7199N/A+ if ((errno = ct_ctl_abandon (cfd)))
7199N/A+ g_debug ("Error abandoning latest contract: %s",
7199N/A+ g_debug ("Abandoned latest contract");
7199N/A+#endif /* HAVE_SMF_CONTRACTS */
7199N/A session_worker_job_child_setup (GdmSessionWorkerJob *session_worker_job)
7199N/A+ contracts_post_fork_child ();
7199N/A session_worker_job_setup_journal_fds ();
7199N/A /* Terminate the process when the parent dies */
7199N/A@@ -273,6 +416,10 @@ gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job,
7199N/A env = get_job_environment (session_worker_job);
7199N/A ret = g_spawn_async_with_pipes (NULL,
7199N/A@@ -286,6 +433,10 @@ gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job,
7199N/A+ contracts_post_fork_parent ((session_worker_job->priv->pid > 0));
7199N/A g_ptr_array_foreach (args, (GFunc)g_free, NULL);
7199N/A g_ptr_array_free (args, TRUE);