Esempio n. 1
0
static int
xrdp_listen_get_port_address(char* port, int port_bytes,
                             char* address, int address_bytes)
{
  int fd;
  int error;
  int index;
  char* val;
  struct list* names;
  struct list* values;
  char cfg_file[256];

  /* default to port 3389 */
  g_strncpy(port, "3389", port_bytes - 1);
  /* Default to all */
  g_strncpy(address, "0.0.0.0", address_bytes - 1);
  /* see if port or address is in xrdp.ini file */
  file_config_name("xrdp.ini", cfg_file, 255);
  fd = g_file_open(cfg_file);
  if (fd > 0)
  {
    names = list_create();
    names->auto_free = 1;
    values = list_create();
    values->auto_free = 1;
    if (file_read_section(fd, "globals", names, values) == 0)
    {
      for (index = 0; index < names->count; index++)
      {
        val = (char*)list_get_item(names, index);
        if (val != 0)
        {
          if (g_strcasecmp(val, "port") == 0)
          {
            val = (char*)list_get_item(values, index);
            error = g_atoi(val);
            if ((error > 0) && (error < 65000))
            {
              g_strncpy(port, val, port_bytes - 1);
            }
          }
          if (g_strcasecmp(val, "address") == 0)
          {
            val = (char*)list_get_item(values, index);
            g_strncpy(address, val, address_bytes - 1);
          }
        }
      }
    }
    list_delete(names);
    list_delete(values);
    g_file_close(fd);
  }
  return 0;
}
Esempio n. 2
0
static int
xrdp_mm_get_sesman_port(char* port, int port_bytes)
{
  int fd = -1;
  int error = 0;
  int index = 0;
  char* val = 0;
  char cfg_file[256];
  struct list* names = (struct list *)NULL;
  struct list* values = (struct list *)NULL;

  g_memset(cfg_file,0,sizeof(char) * 256);
  /* default to port 3350 */
  g_strncpy(port, "3350", port_bytes - 1);
  /* see if port is in xrdp.ini file */
  file_config_name("sesman.ini", cfg_file, 255);
  fd = g_file_open(cfg_file);
  if (fd > 0)
  {
    names = list_create();
    names->auto_free = 1;
    values = list_create();
    values->auto_free = 1;
    if (file_read_section(fd, "Globals", names, values) == 0)
    {
      for (index = 0; index < names->count; index++)
      {
        val = (char*)list_get_item(names, index);
        if (val != 0)
        {
          if (g_strcasecmp(val, "ListenPort") == 0)
          {
            val = (char*)list_get_item(values, index);
            error = g_atoi(val);
            if ((error > 0) && (error < 65000))
            {
              g_strncpy(port, val, port_bytes - 1);
            }
            break;
          }
        }
      }
    }
    list_delete(names);
    list_delete(values);
    g_file_close(fd);
  }

  return 0;
}
Esempio n. 3
0
int
xrdp_listen_get_port(char* port, int port_bytes)
{
  int fd;
  int error;
  int index;
  char* val;
  struct list* names;
  struct list* values;

  /* default to port 3389 */
  g_strncpy(port, "3389", port_bytes - 1);
  /* see if port is in xrdp.ini file */
  fd = g_file_open(XRDP_CFG_FILE);
  if (fd > 0)
  {
    names = list_create();
    names->auto_free = 1;
    values = list_create();
    values->auto_free = 1;
    if (file_read_section(fd, "globals", names, values) == 0)
    {
      for (index = 0; index < names->count; index++)
      {
        val = (char*)list_get_item(names, index);
        if (val != 0)
        {
          if (g_strcasecmp(val, "port") == 0)
          {
            val = (char*)list_get_item(values, index);
            error = g_atoi(val);
            if ((error > 0) && (error < 65000))
            {
              g_strncpy(port, val, port_bytes - 1);
            }
            break;
          }
        }
      }
    }
    list_delete(names);
    list_delete(values);
    g_file_close(fd);
  }
  return 0;
}
Esempio n. 4
0
static int
xrdp_listen_get_port_address(char *port, int port_bytes,
                             char *address, int address_bytes,
                             int *tcp_nodelay, int *tcp_keepalive,
                             struct xrdp_startup_params *startup_param)
{
    int fd;
    int error;
    int index;
    char *val;
    struct list *names;
    struct list *values;
    char cfg_file[256];

    /* default to port 3389 */
    g_strncpy(port, "3389", port_bytes - 1);
    /* Default to all */
    g_strncpy(address, "0.0.0.0", address_bytes - 1);
    /* see if port or address is in xrdp.ini file */
    g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
    fd = g_file_open(cfg_file);
    *tcp_nodelay = 0 ;
    *tcp_keepalive = 0 ;

    if (fd != -1)
    {
        names = list_create();
        names->auto_free = 1;
        values = list_create();
        values->auto_free = 1;

        if (file_read_section(fd, "globals", names, values) == 0)
        {
            for (index = 0; index < names->count; index++)
            {
                val = (char *)list_get_item(names, index);

                if (val != 0)
                {
                    if (g_strcasecmp(val, "port") == 0)
                    {
                        val = (char *)list_get_item(values, index);
                        if (val[0] == '/')
                        {
                            g_strncpy(port, val, port_bytes - 1);
                        }
                        else
                        {
                            error = g_atoi(val);
                            if ((error > 0) && (error < 65000))
                            {
                                g_strncpy(port, val, port_bytes - 1);
                            }
                        }
                    }

                    if (g_strcasecmp(val, "address") == 0)
                    {
                        val = (char *)list_get_item(values, index);
                        g_strncpy(address, val, address_bytes - 1);
                    }

                    if (g_strcasecmp(val, "fork") == 0)
                    {
                        val = (char *)list_get_item(values, index);
                        startup_param->fork = g_text2bool(val);
                    }

                    if (g_strcasecmp(val, "tcp_nodelay") == 0)
                    {
                        val = (char *)list_get_item(values, index);
                        *tcp_nodelay = g_text2bool(val);
                    }

                    if (g_strcasecmp(val, "tcp_keepalive") == 0)
                    {
                        val = (char *)list_get_item(values, index);
                        *tcp_keepalive = g_text2bool(val);
                    }

                    if (g_strcasecmp(val, "tcp_send_buffer_bytes") == 0)
                    {
                        val = (char *)list_get_item(values, index);
                        startup_param->send_buffer_bytes = g_atoi(val);
                    }

                    if (g_strcasecmp(val, "tcp_recv_buffer_bytes") == 0)
                    {
                        val = (char *)list_get_item(values, index);
                        startup_param->recv_buffer_bytes = g_atoi(val);
                    }
                }
            }
        }

        list_delete(names);
        list_delete(values);
    }

    if (fd != -1)
        g_file_close(fd);

    /* startup_param overrides */
    if (startup_param->port[0] != 0)
    {
        g_strncpy(port, startup_param->port, port_bytes - 1);
    }

    return 0;
}
Esempio n. 5
0
File: log.c Progetto: speidy/xrdp
enum logReturns DEFAULT_CC
internal_config_read_logging(int file, struct log_config *lc,
                             struct list *param_n,
                             struct list *param_v,
                             const char *applicationName)
{
    int i;
    char *buf;
    char *temp_buf;

    list_clear(param_v);
    list_clear(param_n);

    /* setting defaults */
    lc->program_name = applicationName;
    lc->log_file = 0;
    lc->fd = 0;
    lc->log_level = LOG_LEVEL_DEBUG;
    lc->enable_syslog = 0;
    lc->syslog_level = LOG_LEVEL_DEBUG;

    file_read_section(file, SESMAN_CFG_LOGGING, param_n, param_v);

    for (i = 0; i < param_n->count; i++)
    {
        buf = (char *)list_get_item(param_n, i);

        if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_FILE))
        {
            lc->log_file = g_strdup((char *)list_get_item(param_v, i));

            if (lc->log_file != NULL)
            {
                if (lc->log_file[0] != '/')
                {
                    temp_buf = (char *)g_malloc(512, 0);
                    g_snprintf(temp_buf, 511, "%s/%s", XRDP_LOG_PATH, lc->log_file);
                    g_free(lc->log_file);
                    lc->log_file = temp_buf;
                }
            }
        }

        if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_LEVEL))
        {
            lc->log_level = internal_log_text2level((char *)list_get_item(param_v, i));
        }

        if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG))
        {
            lc->enable_syslog = g_text2bool((char *)list_get_item(param_v, i));
        }

        if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL))
        {
            lc->syslog_level = internal_log_text2level((char *)list_get_item(param_v, i));
        }
    }

    if (0 == lc->log_file)
    {
        lc->log_file = g_strdup("./sesman.log");
    }

    /* try to create path if not exist */
    g_create_path(lc->log_file);

    g_printf("logging configuration:\r\n");
    g_printf("\tLogFile:       %s\r\n", lc->log_file);
    g_printf("\tLogLevel:      %i\r\n", lc->log_level);
    g_printf("\tEnableSyslog:  %i\r\n", lc->enable_syslog);
    g_printf("\tSyslogLevel:   %i\r\n", lc->syslog_level);
    return LOG_STARTUP_OK;
}