]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg-quick: android: split uids into multiple commands
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 31 Jan 2020 17:56:52 +0000 (18:56 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 31 Jan 2020 17:56:52 +0000 (18:56 +0100)
Different versions of netd have different limits on how many can be
passed at once.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reported-by: Alexey <zaranecc@bk.ru>
src/wg-quick/android.c

index cedc8a7d054a470b259b2b5db4f80ece0e0962e7..54ea81cc0f9edcebf3f6e185f9be78c8a3d975a1 100644 (file)
@@ -785,6 +785,7 @@ static uid_t *get_uid_list(const char *selected_applications)
 static void set_users(unsigned int netid, const char *excluded_applications)
 {
        _cleanup_free_ uid_t *excluded_uids = get_uid_list(excluded_applications);
+       unsigned int args_per_command = 0;
        _cleanup_free_ char *ranges = NULL;
        char range[22];
        uid_t start;
@@ -797,13 +798,19 @@ static void set_users(unsigned int netid, const char *excluded_applications)
                else
                        snprintf(range, sizeof(range), "%u-%u", start, *excluded_uids - 1);
                ranges = concat_and_free(ranges, " ", range);
+               if (++args_per_command % 18 == 0) {
+                       cndc("network users add %u %s", netid, ranges);
+                       free(ranges);
+                       ranges = NULL;
+               }
        }
        if (start < 99999) {
                snprintf(range, sizeof(range), "%u-99999", start);
                ranges = concat_and_free(ranges, " ", range);
        }
 
-       cndc("network users add %u %s", netid, ranges);
+       if (ranges)
+               cndc("network users add %u %s", netid, ranges);
 }
 
 static void set_dnses(unsigned int netid, const char *dnses)