~ubuntu-branches/ubuntu/maverick/dbus/maverick-proposed

« back to all changes in this revision

Viewing changes to bus/config-parser.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-27 13:06:32 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20100927130632-bqs145trvchd2lmf
Tags: 1.4.0-0ubuntu1
* New upstream release
 - Fixes https://bugs.freedesktop.org/show_bug.cgi?id=17754 Race condition in protected_change_timeout
 - Requested by various upstream KDE developers http://lists.kde.org/?t=128514970000004&r=1&w=2

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
21
 *
22
22
 */
 
23
 
 
24
#include <config.h>
23
25
#include "config-parser-common.h"
24
26
#include "config-parser.h"
25
27
#include "test.h"
115
117
  unsigned int keep_umask : 1; /**< TRUE to keep original umask when forking */
116
118
 
117
119
  unsigned int is_toplevel : 1; /**< FALSE if we are a sub-config-file inside another one */
 
120
 
 
121
  unsigned int allow_anonymous : 1; /**< TRUE to allow anonymous connections */
118
122
};
119
123
 
120
124
static Element*
402
406
      parser->limits.max_incoming_bytes = _DBUS_ONE_MEGABYTE * 127;
403
407
      parser->limits.max_outgoing_bytes = _DBUS_ONE_MEGABYTE * 127;
404
408
      parser->limits.max_message_size = _DBUS_ONE_MEGABYTE * 32;
 
409
 
 
410
      /* We set relatively conservative values here since due to the
 
411
      way SCM_RIGHTS works we need to preallocate an array for the
 
412
      maximum number of file descriptors we can receive. Picking a
 
413
      high value here thus translates directly to more memory
 
414
      allocation. */
 
415
      parser->limits.max_incoming_unix_fds = 1024*4;
 
416
      parser->limits.max_outgoing_unix_fds = 1024*4;
 
417
      parser->limits.max_message_unix_fds = 1024;
405
418
      
406
419
      /* Making this long means the user has to wait longer for an error
407
420
       * message if something screws up, but making it too short means
851
864
 
852
865
      return TRUE;
853
866
    }
 
867
  else if (element_type == ELEMENT_ALLOW_ANONYMOUS)
 
868
    {
 
869
      if (!check_no_attributes (parser, "allow_anonymous", attribute_names, attribute_values, error))
 
870
        return FALSE;
 
871
 
 
872
      if (push_element (parser, ELEMENT_ALLOW_ANONYMOUS) == NULL)
 
873
        {
 
874
          BUS_SET_OOM (error);
 
875
          return FALSE;
 
876
        }
 
877
 
 
878
      parser->allow_anonymous = TRUE;
 
879
      return TRUE;
 
880
    }
854
881
  else if (element_type == ELEMENT_SERVICEDIR)
855
882
    {
856
883
      if (!check_no_attributes (parser, "servicedir", attribute_names, attribute_values, error))
1812
1839
      must_be_positive = TRUE;
1813
1840
      parser->limits.max_incoming_bytes = value;
1814
1841
    }
 
1842
  else if (strcmp (name, "max_incoming_unix_fds") == 0)
 
1843
    {
 
1844
      must_be_positive = TRUE;
 
1845
      parser->limits.max_incoming_unix_fds = value;
 
1846
    }
1815
1847
  else if (strcmp (name, "max_outgoing_bytes") == 0)
1816
1848
    {
1817
1849
      must_be_positive = TRUE;
1818
1850
      parser->limits.max_outgoing_bytes = value;
1819
1851
    }
 
1852
  else if (strcmp (name, "max_outgoing_unix_fds") == 0)
 
1853
    {
 
1854
      must_be_positive = TRUE;
 
1855
      parser->limits.max_outgoing_unix_fds = value;
 
1856
    }
1820
1857
  else if (strcmp (name, "max_message_size") == 0)
1821
1858
    {
1822
1859
      must_be_positive = TRUE;
1823
1860
      parser->limits.max_message_size = value;
1824
1861
    }
 
1862
  else if (strcmp (name, "max_message_unix_fds") == 0)
 
1863
    {
 
1864
      must_be_positive = TRUE;
 
1865
      parser->limits.max_message_unix_fds = value;
 
1866
    }
1825
1867
  else if (strcmp (name, "service_start_timeout") == 0)
1826
1868
    {
1827
1869
      must_be_positive = TRUE;
1994
2036
    case ELEMENT_ASSOCIATE:
1995
2037
    case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
1996
2038
    case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
 
2039
    case ELEMENT_ALLOW_ANONYMOUS:
1997
2040
      break;
1998
2041
    }
1999
2042
 
2289
2332
    case ELEMENT_KEEP_UMASK:
2290
2333
    case ELEMENT_STANDARD_SESSION_SERVICEDIRS:    
2291
2334
    case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:    
 
2335
    case ELEMENT_ALLOW_ANONYMOUS:
2292
2336
    case ELEMENT_SELINUX:
2293
2337
    case ELEMENT_ASSOCIATE:
2294
2338
      if (all_whitespace (content))
2621
2665
  return parser->keep_umask;
2622
2666
}
2623
2667
 
 
2668
dbus_bool_t
 
2669
bus_config_parser_get_allow_anonymous (BusConfigParser   *parser)
 
2670
{
 
2671
  return parser->allow_anonymous;
 
2672
}
 
2673
 
2624
2674
const char *
2625
2675
bus_config_parser_get_pidfile (BusConfigParser   *parser)
2626
2676
{
2965
3015
{
2966
3016
  return
2967
3017
    (a->max_incoming_bytes == b->max_incoming_bytes
 
3018
     || a->max_incoming_unix_fds == b->max_incoming_unix_fds
2968
3019
     || a->max_outgoing_bytes == b->max_outgoing_bytes
 
3020
     || a->max_outgoing_unix_fds == b->max_outgoing_unix_fds
2969
3021
     || a->max_message_size == b->max_message_size
 
3022
     || a->max_message_unix_fds == b->max_message_unix_fds
2970
3023
     || a->activation_timeout == b->activation_timeout
2971
3024
     || a->auth_timeout == b->auth_timeout
2972
3025
     || a->max_completed_connections == b->max_completed_connections
3205
3258
#ifdef DBUS_UNIX
3206
3259
         "/testhome/foo/.testlocal/testshare/dbus-1/services",
3207
3260
#endif
 
3261
#ifdef DBUS_WIN
 
3262
         NULL,
 
3263
#endif
3208
3264
         NULL
3209
3265
        };
3210
3266
 
3328
3384
         "/testusr/testshare/dbus-1/system-services",
3329
3385
#endif
3330
3386
         DBUS_DATADIR"/dbus-1/system-services",
 
3387
#ifdef DBUS_WIN
 
3388
         NULL,
 
3389
#endif
3331
3390
         NULL
3332
3391
        };
3333
3392
 
3457
3516
  if (!test_default_session_servicedirs())
3458
3517
    return FALSE;
3459
3518
 
 
3519
#ifdef DBUS_WIN
 
3520
  printf("default system service dir skipped\n");
 
3521
#else
3460
3522
  if (!test_default_system_servicedirs())
3461
3523
    return FALSE;
 
3524
#endif
3462
3525
 
3463
3526
  if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
3464
3527
    return FALSE;