set_cmnd_path(const char *runchroot)
{
    char *path = user_path;
    int ret;
    debug_decl(set_cmnd_path, SUDOERS_DEBUG_PLUGIN);

    if (def_secure_path && !user_is_exempt())
	path = def_secure_path;
    if (!set_perms(PERM_RUNAS))
	debug_return_int(NOT_FOUND_ERROR);
    ret = find_path(NewArgv[0], &user_cmnd, user_stat, path,
	runchroot, def_ignore_dot, NULL);
    if (!restore_perms())
	debug_return_int(NOT_FOUND_ERROR);
    if (ret == NOT_FOUND) {
	/* Failed as root, try as invoking user. */
	if (!set_perms(PERM_USER))
	    debug_return_int(false);
	ret = find_path(NewArgv[0], &user_cmnd, user_stat, path,
	    runchroot, def_ignore_dot, NULL);
	if (!restore_perms())
	    debug_return_int(NOT_FOUND_ERROR);
    }

    debug_return_int(ret);
}
set_cmnd_path(const char *runchroot)
{
    char *path = user_path;
    int ret;
    debug_decl(set_cmnd_path, SUDOERS_DEBUG_PLUGIN);

    if (def_secure_path && !user_is_exempt())
	path = def_secure_path;
    if (!set_perms(PERM_RUNAS))
	debug_return_int(NOT_FOUND_ERROR);
    ret = find_path(NewArgv[0], &user_cmnd, user_stat, path,
	runchroot, def_ignore_dot, NULL);
    if (!restore_perms())
	debug_return_int(NOT_FOUND_ERROR);
    if (ret == NOT_FOUND) {
	 
	if (!set_perms(PERM_USER))
	    debug_return_int(false);
	ret = find_path(NewArgv[0], &user_cmnd, user_stat, path,
	    runchroot, def_ignore_dot, NULL);
	if (!restore_perms())
	    debug_return_int(NOT_FOUND_ERROR);
    }

    debug_return_int(ret);
}