summaryrefslogtreecommitdiffstats
path: root/avahi-daemon/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'avahi-daemon/main.c')
-rw-r--r--avahi-daemon/main.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c
index d270c31..d1a3b3e 100644
--- a/avahi-daemon/main.c
+++ b/avahi-daemon/main.c
@@ -106,6 +106,9 @@ typedef struct {
#ifdef HAVE_DBUS
int enable_dbus;
int fail_on_missing_dbus;
+ unsigned n_clients_max;
+ unsigned n_objects_per_client_max;
+ unsigned n_entries_per_entry_group_max;
#endif
int drop_root;
int set_rlimits;
@@ -527,6 +530,26 @@ static int is_yes(const char *s) {
return *s == 'y' || *s == 'Y' || *s == '1' || *s == 't' || *s == 'T';
}
+static int parse_unsigned(const char *s, unsigned *u) {
+ char *e = NULL;
+ unsigned long ul;
+ unsigned k;
+
+ errno = 0;
+ ul = strtoul(s, &e, 0);
+
+ if (!e || *e || errno != 0)
+ return -1;
+
+ k = (unsigned) ul;
+
+ if ((unsigned long) k != ul)
+ return -1;
+
+ *u = k;
+ return 0;
+}
+
static int load_config_file(DaemonConfig *c) {
int r = -1;
AvahiIniFile *f;
@@ -618,6 +641,44 @@ static int load_config_file(DaemonConfig *c) {
c->server_config.deny_interfaces = avahi_string_list_add(c->server_config.deny_interfaces, *t);
avahi_strfreev(e);
+ } else if (strcasecmp(p->key, "cache-entries-max") == 0) {
+ unsigned k;
+
+ if (parse_unsigned(p->value, &k) < 0) {
+ avahi_log_error("Invalid cache-entries-max setting %s", p->value);
+ goto finish;
+ }
+
+ c->server_config.n_cache_entries_max = k;
+#ifdef HAVE_DBUS
+ } else if (strcasecmp(p->key, "clients-max") == 0) {
+ unsigned k;
+
+ if (parse_unsigned(p->value, &k) < 0) {
+ avahi_log_error("Invalid clients-max setting %s", p->value);
+ goto finish;
+ }
+
+ c->n_clients_max = k;
+ } else if (strcasecmp(p->key, "objects-per-client-max") == 0) {
+ unsigned k;
+
+ if (parse_unsigned(p->value, &k) < 0) {
+ avahi_log_error("Invalid objects-per-client-max setting %s", p->value);
+ goto finish;
+ }
+
+ c->n_objects_per_client_max = k;
+ } else if (strcasecmp(p->key, "entries-per-entry-group-max") == 0) {
+ unsigned k;
+
+ if (parse_unsigned(p->value, &k) < 0) {
+ avahi_log_error("Invalid entries-per-entry-group-max setting %s", p->value);
+ goto finish;
+ }
+
+ c->n_entries_per_entry_group_max = k;
+#endif
} else {
avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name);
goto finish;
@@ -1009,7 +1070,12 @@ static int run_server(DaemonConfig *c) {
#ifdef HAVE_DBUS
if (c->enable_dbus) {
- if (dbus_protocol_setup(poll_api, config.disable_user_service_publishing, !c->fail_on_missing_dbus
+ if (dbus_protocol_setup(poll_api,
+ config.disable_user_service_publishing,
+ config.n_clients_max,
+ config.n_objects_per_client_max,
+ config.n_entries_per_entry_group_max,
+ !c->fail_on_missing_dbus
#ifdef ENABLE_CHROOT
&& !config.use_chroot
#endif
@@ -1347,6 +1413,9 @@ int main(int argc, char *argv[]) {
#ifdef HAVE_DBUS
config.enable_dbus = 1;
config.fail_on_missing_dbus = 1;
+ config.n_clients_max = 0;
+ config.n_objects_per_client_max = 0;
+ config.n_entries_per_entry_group_max = 0;
#endif
config.drop_root = 1;