Ejemplo n.º 1
0
/* return our global_sam_sid */
DOM_SID *get_global_sam_sid(void)
{
	if (global_sam_sid != NULL)
		return global_sam_sid;
	
	/* memory for global_sam_sid is allocated in 
	   pdb_generate_sam_sid() as needed */

	if (!pdb_generate_sam_sid()) {
		smb_panic("Could not generate a machine SID\n");
	}
	
	return global_sam_sid;
}
Ejemplo n.º 2
0
/* return our global_sam_sid */
struct dom_sid *get_global_sam_sid(void)
{
    struct db_context *db;

    if (global_sam_sid != NULL)
        return global_sam_sid;

    /*
     * memory for global_sam_sid is allocated in
     * pdb_generate_sam_sid() as needed
     *
     * Note: this is garded by a transaction
     *       to prevent races on startup which
     *       can happen with some dbwrap backends
     */

    db = secrets_db_ctx();
    if (!db) {
        smb_panic("could not open secrets db");
    }

    if (db->transaction_start(db) != 0) {
        smb_panic("could not start transaction on secrets db");
    }

    if (!(global_sam_sid = pdb_generate_sam_sid())) {
        db->transaction_cancel(db);
        smb_panic("could not generate a machine SID");
    }

    if (db->transaction_commit(db) != 0) {
        smb_panic("could not start commit secrets db");
    }

    return global_sam_sid;
}