Ejemplo n.º 1
0
NTSTATUS _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u)
{
	if (!create_policy_hnd(p, &r_u->pol, free_reg_info, NULL))
		return NT_STATUS_OBJECT_NAME_NOT_FOUND;

	return NT_STATUS_OK;
}
Ejemplo n.º 2
0
NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u)
{
	POLICY_HND pol;
	fstring name;
	struct reg_info *info = NULL;

	DEBUG(5,("reg_open_entry: %d\n", __LINE__));

	if (!find_policy_by_hnd(p, &q_u->pol, NULL))
		return NT_STATUS_INVALID_HANDLE;

	fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len));

	DEBUG(5,("reg_open_entry: %s\n", name));

	/* lkcl XXXX do a check on the name, here */
	if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") &&
	    !strequal(name, "System\\CurrentControlSet\\services\\Netlogon\\parameters\\"))
			return NT_STATUS_ACCESS_DENIED;

	if ((info = (struct reg_info *)malloc(sizeof(struct reg_info))) == NULL)
		return NT_STATUS_NO_MEMORY;

	ZERO_STRUCTP(info);
	fstrcpy(info->name, name);

	if (!create_policy_hnd(p, &pol, free_reg_info, (void *)info))
		return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */

	init_reg_r_open_entry(r_u, &pol, NT_STATUS_OK);

	DEBUG(5,("reg_open_entry: %d\n", __LINE__));

	return r_u->status;
}
Ejemplo n.º 3
0
static NTSTATUS elog_open( pipes_struct * p, const char *logname, struct policy_handle *hnd )
{
	EVENTLOG_INFO *elog;

	/* first thing is to validate the eventlog name */

	if ( !elog_validate_logname( logname ) )
		return NT_STATUS_OBJECT_PATH_INVALID;

	if ( !(elog = TALLOC_ZERO_P( NULL, EVENTLOG_INFO )) )
		return NT_STATUS_NO_MEMORY;
	talloc_set_destructor(elog, eventlog_info_destructor);

	elog->logname = talloc_strdup( elog, logname );

	/* Open the tdb first (so that we can create any new tdbs if necessary).
	   We have to do this as root and then use an internal access check
	   on the file permissions since you can only have a tdb open once
	   in a single process */

	become_root();
	elog->etdb = elog_open_tdb( elog->logname, False, False );
	unbecome_root();

	if ( !elog->etdb ) {
		/* according to MSDN, if the logfile cannot be found, we should
		  default to the "Application" log */

		if ( !strequal( logname, ELOG_APPL ) ) {

			TALLOC_FREE( elog->logname );

			elog->logname = talloc_strdup( elog, ELOG_APPL );

			/* do the access check */
			if ( !elog_check_access( elog, p->server_info->ptok ) ) {
				TALLOC_FREE( elog );
				return NT_STATUS_ACCESS_DENIED;
			}

			become_root();
			elog->etdb = elog_open_tdb( elog->logname, False, False );
			unbecome_root();
		}

		if ( !elog->etdb ) {
			TALLOC_FREE( elog );
			return NT_STATUS_ACCESS_DENIED;	/* ??? */
		}
	}

	/* now do the access check.  Close the tdb if we fail here */

	if ( !elog_check_access( elog, p->server_info->ptok ) ) {
		TALLOC_FREE( elog );
		return NT_STATUS_ACCESS_DENIED;
	}

	/* create the policy handle */

	if ( !create_policy_hnd( p, hnd, elog ) ) {
		TALLOC_FREE(elog);
		return NT_STATUS_NO_MEMORY;
	}

	/* set the initial current_record pointer */

	if ( !get_oldest_entry_hook( elog ) ) {
		DEBUG(3,("elog_open: Successfully opened eventlog but can't "
			"get any information on internal records!\n"));
	}

	elog->current_record = elog->oldest_entry;

	return NT_STATUS_OK;
}