Ejemplo n.º 1
0
	static int APP_CC
read_ini(void)
{
	char filename[256];
	struct list* names;
	struct list* values;
	char* name;
	char* value;
	int index;

	names = list_create();
	names->auto_free = 1;
	values = list_create();
	values->auto_free = 1;
	g_use_unix_socket = 0;
	g_snprintf(filename, 255, "%s/vchannel.ini", XRDP_CFG_PATH);
	if (file_by_name_read_section(filename, "Globals", names, values) == 0)
	{
		for (index = 0; index < names->count; index++)
		{
			name = (char*)list_get_item(names, index);
			value = (char*)list_get_item(values, index);
			if (g_strcasecmp(name, "ListenAddress") == 0)
			{
				if (g_strcasecmp(value, "127.0.0.1") == 0)
				{
					g_use_unix_socket = 1;
				}
			}
		}
	}
	list_delete(names);
	list_delete(values);
	return 0;
}
Ejemplo n.º 2
0
	static int APP_CC
read_logging_conf(void)
{
	char filename[256];
	struct list* names;
	struct list* values;
	char* name;
	char* value;
	int index;

	log_conf.program_name = g_strdup("chansrv");
	log_conf.log_file = 0;
	log_conf.fd = 0;
	log_conf.log_level = LOG_LEVEL_DEBUG;
	log_conf.enable_syslog = 0;
	log_conf.syslog_level = LOG_LEVEL_DEBUG;

	names = list_create();
	names->auto_free = 1;
	values = list_create();
	values->auto_free = 1;
	g_snprintf(filename, 255, "%s/vchannel.ini", XRDP_CFG_PATH);
	if (file_by_name_read_section(filename, CHAN_CFG_LOGGING, names, values) == 0)
	{
		for (index = 0; index < names->count; index++)
		{
			name = (char*)list_get_item(names, index);
			value = (char*)list_get_item(values, index);
			if (0 == g_strcasecmp(name, CHAN_CFG_LOG_FILE))
			{
				log_conf.log_file = g_strdup(value);
			}
			if (0 == g_strcasecmp(name, CHAN_CFG_LOG_LEVEL))
			{
				log_conf.log_level = log_text2level(value);
			}
			if (0 == g_strcasecmp(name, CHAN_CFG_LOG_ENABLE_SYSLOG))
			{
				log_conf.enable_syslog = log_text2bool(value);
			}
			if (0 == g_strcasecmp(name, CHAN_CFG_LOG_SYSLOG_LEVEL))
			{
				log_conf.syslog_level = log_text2level(value);
			}
		}
	}
	list_delete(names);
	list_delete(values);
	return 0;
}
Ejemplo n.º 3
0
static int
xrdp_rdp_read_config(struct xrdp_client_info *client_info)
{
    int index = 0;
    struct list *items = (struct list *)NULL;
    struct list *values = (struct list *)NULL;
    char *item = NULL;
    char *value = NULL;
    char cfg_file[256];
    int pos;
    char *tmp = NULL;
    int tmp_length = 0;

    /* initialize (zero out) local variables: */
    g_memset(cfg_file, 0, sizeof(char) * 256);

    items = list_create();
    items->auto_free = 1;
    values = list_create();
    values->auto_free = 1;
    g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
    DEBUG(("cfg_file %s", cfg_file));
    file_by_name_read_section(cfg_file, "globals", items, values);

    for (index = 0; index < items->count; index++)
    {
        item = (char *)list_get_item(items, index);
        value = (char *)list_get_item(values, index);
        DEBUG(("item %s value %s", item, value));

        if (g_strcasecmp(item, "bitmap_cache") == 0)
        {
            client_info->use_bitmap_cache = g_text2bool(value);
        }
        else if (g_strcasecmp(item, "bitmap_compression") == 0)
        {
            client_info->use_bitmap_comp = g_text2bool(value);
        }
        else if (g_strcasecmp(item, "bulk_compression") == 0)
        {
            client_info->use_bulk_comp = g_text2bool(value);
        }
        else if (g_strcasecmp(item, "crypt_level") == 0)
        {
            if (g_strcasecmp(value, "none") == 0)
            {
                client_info->crypt_level = 0;
            }
            else if (g_strcasecmp(value, "low") == 0)
            {
                client_info->crypt_level = 1;
            }
            else if (g_strcasecmp(value, "medium") == 0)
            {
                client_info->crypt_level = 2;
            }
            else if (g_strcasecmp(value, "high") == 0)
            {
                client_info->crypt_level = 3;
            }
            else if (g_strcasecmp(value, "fips") == 0)
            {
                client_info->crypt_level = 4;
            }
            else
            {
                log_message(LOG_LEVEL_ALWAYS,"Warning: Your configured crypt level is "
                          "undefined, 'high' will be used");
                client_info->crypt_level = 3;
            }
        }
        else if (g_strcasecmp(item, "allow_channels") == 0)
        {
            client_info->channels_allowed = g_text2bool(value);
            if (client_info->channels_allowed == 0)
            {
                log_message(LOG_LEVEL_DEBUG,"Info - All channels are disabled");
            }
        }
        else if (g_strcasecmp(item, "allow_multimon") == 0)
                {
                    client_info->multimon = g_text2bool(value);
                    if (client_info->multimon == 0)
                    {
                        log_message(LOG_LEVEL_DEBUG,"Info - Multi monitor server support disabled");
                    }
                }
        else if (g_strcasecmp(item, "max_bpp") == 0)
        {
            client_info->max_bpp = g_atoi(value);
        }
        else if (g_strcasecmp(item, "rfx_min_pixel") == 0)
        {
            client_info->rfx_min_pixel = g_atoi(value);
        }
        else if (g_strcasecmp(item, "new_cursors") == 0)
        {
            client_info->pointer_flags = g_text2bool(value) == 0 ? 2 : 0;
        }
        else if (g_strcasecmp(item, "require_credentials") == 0)
        {
            client_info->require_credentials = g_text2bool(value);
        }
        else if (g_strcasecmp(item, "use_fastpath") == 0)
        {
            if (g_strcasecmp(value, "output") == 0)
            {
                client_info->use_fast_path = 1;
            }
            else if (g_strcasecmp(value, "input") == 0)
            {
                client_info->use_fast_path = 2;
            }
            else if (g_strcasecmp(value, "both") == 0)
            {
                client_info->use_fast_path = 3;
            }
            else if (g_strcasecmp(value, "none") == 0)
            {
                client_info->use_fast_path = 0;
            }
            else
            {
                log_message(LOG_LEVEL_ALWAYS,"Warning: Your configured fastpath level is "
                          "undefined, fastpath will not be used");
                client_info->use_fast_path = 0;
            }
        }
        else if (g_strcasecmp(item, "ssl_protocols") == 0)
        {
            /* put leading/trailing comma to properly detect "TLSv1" without regex */
            tmp_length = g_strlen(value) + 3;
            tmp = g_new(char, tmp_length);
            g_snprintf(tmp, tmp_length, "%s%s%s", ",", value, ",");
            /* replace all spaces with comma */
            /* to accept space after comma */
            while ((pos = g_pos(tmp, " ")) != -1)
            {
                tmp[pos] = ',';
            }
            ssl_get_protocols_from_string(tmp, &(client_info->ssl_protocols));
            g_free(tmp);
        }
        else if (g_strcasecmp(item, "tls_ciphers") == 0)
Ejemplo n.º 4
0
int
cliprdr_init()
{
  char filename[256];
  struct list* names;
  struct list* values;
  char* name;
  char* value;
  int index;
  int display_num;

  display_num = g_get_display_num_from_display(g_strdup(g_getenv("DISPLAY")));
	if(display_num == 0)
	{
		g_printf("cliprdr[cliprdr_init]: Display must be different of 0\n");
		return ERROR;
	}
	l_config = g_malloc(sizeof(struct log_config), 1);
	l_config->program_name = "cliprdr";
	l_config->log_file = 0;
	l_config->fd = 0;
	l_config->log_level = LOG_LEVEL_DEBUG;
	l_config->enable_syslog = 0;
	l_config->syslog_level = LOG_LEVEL_DEBUG;

  names = list_create();
  names->auto_free = 1;
  values = list_create();
  values->auto_free = 1;
  g_snprintf(filename, 255, "%s/cliprdr.conf", XRDP_CFG_PATH);
  if (file_by_name_read_section(filename, CLIPRDR_CFG_GLOBAL, names, values) == 0)
  {
    for (index = 0; index < names->count; index++)
    {
      name = (char*)list_get_item(names, index);
      value = (char*)list_get_item(values, index);
      if (0 == g_strcasecmp(name, CLIPRDR_CFG_NAME))
      {
        if( g_strlen(value) > 1)
        {
        	l_config->program_name = (char*)g_strdup(value);
        }
      }
    }
  }
  if (file_by_name_read_section(filename, CLIPRDR_CFG_LOGGING, names, values) == 0)
  {
    for (index = 0; index < names->count; index++)
    {
      name = (char*)list_get_item(names, index);
      value = (char*)list_get_item(values, index);
      if (0 == g_strcasecmp(name, CLIPRDR_CFG_LOG_LEVEL))
      {
      	l_config->log_level = log_text2level(value);
      }
    }
  }
  list_delete(names);
  list_delete(values);

	if(log_start(l_config) != LOG_STARTUP_OK)
	{
		g_printf("vchannel[vchannel_init]: Unable to start log system\n");
		return ERROR;
	}
  else
  {
  	return LOG_STARTUP_OK;
  }
  return 0;
}
Ejemplo n.º 5
0
int
disk_init()
{
	char filename[256];
	char log_filename[256];
	struct list* names;
	struct list* values;
	char* name;
	char* value;
	int index;
	int display_num;
	int res;

	display_num = g_get_display_num_from_display(g_strdup(g_getenv("DISPLAY")));
	if(display_num == 0)
	{
		g_printf("vchannel_rdpdr[disk_init]: Display must be different of 0\n");
		return ERROR;
	}
	l_config = g_malloc(sizeof(struct log_config), 1);
	l_config->program_name = "vchannel_rdpdr";
	l_config->log_file = 0;
	l_config->fd = 0;
	l_config->log_level = LOG_LEVEL_DEBUG;
	l_config->enable_syslog = 0;
	l_config->syslog_level = LOG_LEVEL_DEBUG;

	names = list_create();
	names->auto_free = 1;
	values = list_create();
	values->auto_free = 1;
	g_snprintf(filename, 255, "%s/rdpdr.conf", XRDP_CFG_PATH);
	if (file_by_name_read_section(filename, RDPDR_CFG_GLOBAL, names, values) == 0)
	{
		for (index = 0; index < names->count; index++)
		{
			name = (char*)list_get_item(names, index);
			value = (char*)list_get_item(values, index);
			if (0 == g_strcasecmp(name, RDPDR_CFG_NAME))
			{
				if( g_strlen(value) > 1)
				{
					l_config->program_name = (char*)g_strdup(value);
				}
			}
		}
	}
	if (file_by_name_read_section(filename, RDPDR_CFG_LOGGING, names, values) == 0)
	{
		for (index = 0; index < names->count; index++)
		{
			name = (char*)list_get_item(names, index);
			value = (char*)list_get_item(values, index);
			if (0 == g_strcasecmp(name, RDPDR_CFG_LOG_DIR))
			{
				l_config->log_file = (char*)g_strdup(value);
			}
			if (0 == g_strcasecmp(name, RDPDR_CFG_LOG_LEVEL))
			{
				l_config->log_level = log_text2level(value);
			}
			if (0 == g_strcasecmp(name, RDPDR_CFG_LOG_ENABLE_SYSLOG))
			{
				l_config->enable_syslog = log_text2bool(value);
			}
			if (0 == g_strcasecmp(name, RDPDR_CFG_LOG_SYSLOG_LEVEL))
			{
				l_config->syslog_level = log_text2level(value);
			}
		}
	}
	if( g_strlen(l_config->log_file) > 1 && g_strlen(l_config->program_name) > 1)
	{
		g_sprintf(log_filename, "%s/%i/%s.log", l_config->log_file, display_num, l_config->program_name);
		l_config->log_file = (char*)g_strdup(log_filename);
	}
	list_delete(names);
	list_delete(values);
	res = log_start(l_config);
	if( res != LOG_STARTUP_OK)
	{
		g_printf("vchannel_rdpdr[rdpdr_init]: Unable to start log system [%i]\n", res);
		return res;
	}
	return LOG_STARTUP_OK;
}
Ejemplo n.º 6
0
int DEFAULT_CC
printerd_init()
{
	char filename[256];
	struct list *names;
	struct list *values;
	char *name;
	char *value;
	int index;
	int res;

	l_config = g_malloc(sizeof(struct log_config), 1);
	l_config->program_name = g_strdup("printerd");
	l_config->log_file = 0;
	l_config->fd = 0;
	l_config->log_level = LOG_LEVEL_DEBUG;
	l_config->enable_syslog = 0;
	l_config->syslog_level = LOG_LEVEL_DEBUG;

	names = list_create();
	names->auto_free = 1;
	values = list_create();
	values->auto_free = 1;
	g_snprintf(filename, 255, "%s/printerd.ini", XRDP_CFG_PATH);

	if (file_by_name_read_section (filename, PRINTERD_CFG_LOGGING, names, values) == 0) {
		for (index = 0; index < names->count; index++) {
			name = (char *)list_get_item(names, index);
			value = (char *)list_get_item(values, index);
			if (0 == g_strcasecmp(name, PRINTERD_CFG_LOG_DIR)) {
				l_config->log_file = (char *)g_strdup(value);
			}
			if (0 == g_strcasecmp(name, PRINTERD_CFG_LOG_LEVEL)) {
				l_config->log_level = log_text2level(value);
			}
			if (0 ==
			    g_strcasecmp(name, PRINTERD_CFG_LOG_ENABLE_SYSLOG)) {
				l_config->enable_syslog = log_text2bool(value);
			}
			if (0 == g_strcasecmp(name, PRINTERD_CFG_LOG_SYSLOG_LEVEL)) {
				l_config->syslog_level = log_text2level(value);
			}
		}
	}

	if (file_by_name_read_section
	    (filename, PRINTERD_CFG_GLOBAL, names, values) == 0) {
		for (index = 0; index < names->count; index++) {
			name = (char *)list_get_item(names, index);
			value = (char *)list_get_item(values, index);
			if (0 == g_strcasecmp(name, PRINTERD_CFG_GLOBAL_THREAD_COUNT)) {
				thread_count = g_atoi(value);
			}
		}
	}
	list_delete(names);
	list_delete(values);
	res = log_start(l_config);

	if (res != LOG_STARTUP_OK)
	{
		g_printf("xrdp-printerd[printerd_init]: Unable to start log system[%i]\n", res);
		return res;
	}
	else
	{
		return LOG_STARTUP_OK;
	}
}