Пример #1
0
/*
 * Called from start_init_common(), to set init's core file path and content.
 */
void
init_core(void)
{
	struct core_globals *cg;

	/*
	 * The first time we hit this, in the global zone, we have to
	 * initialize the zsd key.
	 */
	if (INGLOBALZONE(curproc)) {
		zone_key_create(&core_zone_key, core_init_zone, NULL,
		    core_free_zone);
	}

	/*
	 * zone_key_create will have called core_init_zone for the
	 * global zone, which sets up the default path and content
	 * variables.
	 */
	VERIFY((cg = zone_getspecific(core_zone_key, curproc->p_zone)) != NULL);

	corectl_path_hold(cg->core_default_path);
	corectl_content_hold(cg->core_default_content);

	curproc->p_corefile = cg->core_default_path;
	curproc->p_content = cg->core_default_content;
}
Пример #2
0
void
sec_subrinit(void)
{
	authkern_cache = kmem_cache_create("authkern_cache",
	    sizeof (AUTH), 0, authkern_init, NULL, NULL, NULL, NULL, 0);
	authnone_cache = kmem_cache_create("authnone_cache",
	    sizeof (AUTH), 0, authnone_init, NULL, NULL, NULL, NULL, 0);
	authloopback_cache = kmem_cache_create("authloopback_cache",
	    sizeof (AUTH), 0, authloopback_init, NULL, NULL, NULL, NULL, 0);
	mutex_init(&desauthtab_lock, NULL, MUTEX_DEFAULT, NULL);

	/* RPC stuff */
	mutex_init(&authdes_ops_lock, NULL, MUTEX_DEFAULT, NULL);
	zone_key_create(&auth_zone_key, auth_zone_init, NULL, auth_zone_fini);
}
Пример #3
0
int
_init(void)
{
	int error;

	(void) ddi_soft_state_init(&statep, sizeof (smb_dev_t), 1);

	/* Can initialize some mutexes also. */
	mutex_init(&dev_lck, NULL, MUTEX_DRIVER, NULL);
	/*
	 * Create a major name and number.
	 */
	nsmb_major = ddi_name_to_major(NSMB_NAME);
	nsmb_minor = 0;

	/* Connection data structures. */
	(void) smb_sm_init();

	/* Initialize password Key chain DB. */
	smb_pkey_init();

	/* Time conversion stuff. */
	smb_time_init();

	/* Initialize crypto mechanisms. */
	smb_crypto_mech_init();

	zone_key_create(&nsmb_zone_key, NULL, nsmb_zone_shutdown,
	    nsmb_zone_destroy);

	/*
	 * Install the module.  Do this after other init,
	 * to prevent entrances before we're ready.
	 */
	if ((error = mod_install((&nsmb_modlinkage))) != 0) {

		/* Same as 2nd half of _fini */
		(void) zone_key_delete(nsmb_zone_key);
		smb_pkey_fini();
		smb_sm_done();
		mutex_destroy(&dev_lck);
		ddi_soft_state_fini(&statep);

		return (error);
	}

	return (0);
}
Пример #4
0
void
netstack_init(void)
{
	mutex_init(&netstack_g_lock, NULL, MUTEX_DEFAULT, NULL);
	mutex_init(&netstack_shared_lock, NULL, MUTEX_DEFAULT, NULL);

	netstack_initialized = 1;

	/*
	 * We want to be informed each time a zone is created or
	 * destroyed in the kernel, so we can maintain the
	 * stack instance information.
	 */
	zone_key_create(&netstack_zone_key, netstack_zone_create,
	    netstack_zone_shutdown, netstack_zone_destroy);
}
Пример #5
0
/*
 * This routine is invoked automatically when the kernel module
 * containing this routine is loaded.  This allows module specific
 * initialization to be done when the module is loaded.
 */
int
_init(void)
{
	int status;

	if ((status = nfs_clntinit()) != 0) {
		cmn_err(CE_WARN, "_init: nfs_clntinit failed");
		return (status);
	}

	/*
	 * Create the version specific kstats.
	 *
	 * PSARC 2001/697 Contract Private Interface
	 * All nfs kstats are under SunMC contract
	 * Please refer to the PSARC listed above and contact
	 * SunMC before making any changes!
	 *
	 * Changes must be reviewed by Solaris File Sharing
	 * Changes must be communicated to [email protected]
	 *
	 */

	zone_key_create(&nfsstat_zone_key, nfsstat_zone_init, NULL,
	    nfsstat_zone_fini);
	status = mod_install((struct modlinkage *)&modlinkage);

	if (status)  {
		(void) zone_key_delete(nfsstat_zone_key);

		/*
		 * Failed to install module, cleanup previous
		 * initialization work.
		 */
		nfs_clntfini();

		/*
		 * Clean up work performed indirectly by mod_installfs()
		 * as a result of our call to mod_install().
		 */
		nfs4fini();
		nfs3fini();
		nfsfini();
	}
	return (status);
}
Пример #6
0
int
_init(void)
{
    int result;

    msq_svc = ipcs_create("msqids", rc_project_msgmni, rc_zone_msgmni,
                          sizeof (kmsqid_t), msg_dtor, msg_rmid, AT_IPC_MSG,
                          offsetof(ipc_rqty_t, ipcq_msgmni));
    zone_key_create(&msg_zone_key, NULL, msg_remove_zone, NULL);

    if ((result = mod_install(&modlinkage)) == 0)
        return (0);

    (void) zone_key_delete(msg_zone_key);
    ipcs_destroy(msq_svc);

    return (result);
}
Пример #7
0
int
_init(void)
{
    int result;

    sem_svc = ipcs_create("semids", rc_project_semmni, rc_zone_semmni,
                          sizeof (ksemid_t), sem_dtor, sem_rmid, AT_IPC_SEM,
                          offsetof(ipc_rqty_t, ipcq_semmni));
    zone_key_create(&sem_zone_key, NULL, sem_remove_zone, NULL);

    if ((result = mod_install(&modlinkage)) == 0)
        return (0);

    (void) zone_key_delete(sem_zone_key);
    ipcs_destroy(sem_svc);

    return (result);
}
Пример #8
0
int
_init(void)
{
	int error;

	mutex_init(&acct_list_lock, NULL, MUTEX_DEFAULT, NULL);
	list_create(&acct_list, sizeof (struct acct_globals),
	    offsetof(struct acct_globals, aclink));
	/*
	 * Using an initializer here wastes a bit of memory for zones that
	 * don't use accounting, but vastly simplifies the locking.
	 */
	zone_key_create(&acct_zone_key, acct_init, acct_shutdown, acct_fini);
	if ((error = mod_install(&modlinkage)) != 0) {
		(void) zone_key_delete(acct_zone_key);
		list_destroy(&acct_list);
		mutex_destroy(&acct_list_lock);
	}
	return (error);
}
Пример #9
0
void
log_init(void)
{
	int log_maxzones;

	/*
	 * Create a backlog queue to consume console messages during periods
	 * when there is no console reader (e.g. before syslogd(1M) starts).
	 */
	log_backlogq = log_consq = log_makeq(0, LOG_HIWAT, NULL);

	/*
	 * Create a queue to hold free message of size <= LOG_MSGSIZE.
	 * Calls from high-level interrupt handlers will do a getq_noenab()
	 * from this queue, so its q_lock must be a maximum SPL spin lock.
	 */
	log_freeq = log_makeq(LOG_MINFREE, LOG_MAXFREE, (void *)ipltospl(SPL8));

	/*
	 * Create a queue for messages from high-level interrupt context.
	 * These messages are drained via softcall, or explicitly by panic().
	 */
	log_intrq = log_makeq(0, LOG_HIWAT, (void *)ipltospl(SPL8));

	/*
	 * Create a queue to hold the most recent 8K of console messages.
	 * Useful for debugging.  Required by the "$<msgbuf" adb macro.
	 */
	log_recentq = log_makeq(0, LOG_RECENTSIZE, NULL);

	/*
	 * Create an id space for clone devices opened via /dev/log.
	 * Need to limit the number of zones to avoid exceeding the
	 * available minor number space.
	 */
	log_maxzones = (L_MAXMIN32 - LOG_LOGMIN) / LOG_NUMCLONES - 1;
	if (log_maxzones < maxzones)
		maxzones = log_maxzones;
	log_minorspace = id_space_create("logminor_space", LOG_LOGMIN + 1,
	    L_MAXMIN32);
	/*
	 * Put ourselves on the ZSD list.  Note that zones have not been
	 * initialized yet, but our constructor will be called on the global
	 * zone when they are.
	 */
	zone_key_create(&log_zone_key, log_zoneinit, NULL, log_zonefree);

	/*
	 * Initialize backlog structure.
	 */
	log_backlog.log_zoneid = GLOBAL_ZONEID;
	log_backlog.log_minor = LOG_BACKLOG;

	/* Allocate kmem cache for conslog's log structures */
	log_cons_cache = kmem_cache_create("log_cons_cache",
	    sizeof (struct log), 0, log_cons_constructor, log_cons_destructor,
	    NULL, NULL, NULL, 0);

	/*
	 * Let the logging begin.
	 */
	log_update(&log_backlog, log_backlogq, SL_CONSOLE, log_console);

	/*
	 * Now that logging is enabled, emit the OS banner.
	 */
	printf("\rSunOS Release %s Version %s %u-bit\n",
	    utsname.release, utsname.version, NBBY * (uint_t)sizeof (void *));
	printf("Copyright (c) 1983, 2010, Oracle and/or its affiliates. "
	    "All rights reserved.\n");
	printf("Copyright 2015 Nexenta Systems, Inc.  All rights reserved.\n");
#ifdef DEBUG
	printf("DEBUG enabled\n");
#endif
}
Пример #10
0
void
cred_init(void)
{
	priv_init();

	crsize = sizeof (cred_t);

	if (get_c2audit_load() > 0) {
#ifdef _LP64
		/* assure audit context is 64-bit aligned */
		audoff = (crsize +
		    sizeof (int64_t) - 1) & ~(sizeof (int64_t) - 1);
#else	/* _LP64 */
		audoff = crsize;
#endif	/* _LP64 */
		crsize = audoff + sizeof (auditinfo_addr_t);
		crsize = (crsize + sizeof (int) - 1) & ~(sizeof (int) - 1);
	}

	cred_cache = kmem_cache_create("cred_cache", crsize, 0,
	    NULL, NULL, NULL, NULL, NULL, 0);

	/*
	 * dummycr is used to copy initial state for creds.
	 */
	dummycr = cralloc();
	bzero(dummycr, crsize);
	dummycr->cr_ref = 1;
	dummycr->cr_uid = (uid_t)-1;
	dummycr->cr_gid = (gid_t)-1;
	dummycr->cr_ruid = (uid_t)-1;
	dummycr->cr_rgid = (gid_t)-1;
	dummycr->cr_suid = (uid_t)-1;
	dummycr->cr_sgid = (gid_t)-1;


	/*
	 * kcred is used by anything that needs all privileges; it's
	 * also the template used for crget as it has all the compatible
	 * sets filled in.
	 */
	kcred = cralloc();

	bzero(kcred, crsize);
	kcred->cr_ref = 1;

	/* kcred is never freed, so we don't need zone_cred_hold here */
	kcred->cr_zone = &zone0;

	priv_fillset(&CR_LPRIV(kcred));
	CR_IPRIV(kcred) = *priv_basic;

	/* Not a basic privilege, if chown is not restricted add it to I0 */
	if (!rstchown)
		priv_addset(&CR_IPRIV(kcred), PRIV_FILE_CHOWN_SELF);

	/* Basic privilege, if link is restricted remove it from I0 */
	if (rstlink)
		priv_delset(&CR_IPRIV(kcred), PRIV_FILE_LINK_ANY);

	CR_EPRIV(kcred) = CR_PPRIV(kcred) = CR_IPRIV(kcred);

	CR_FLAGS(kcred) = NET_MAC_AWARE;

	/*
	 * Set up credentials of p0.
	 */
	ttoproc(curthread)->p_cred = kcred;
	curthread->t_cred = kcred;

	ucredsize = UCRED_SIZE;

	mutex_init(&ephemeral_zone_mutex, NULL, MUTEX_DEFAULT, NULL);
	zone_key_create(&ephemeral_zone_key, NULL, NULL, destroy_ephemeral_zsd);
}