From 6771c4454eab2661166c1c672db7b76ff3f18020 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 31 Jan 2020 18:56:52 +0100 Subject: wg-quick: android: split uids into multiple commands Different versions of netd have different limits on how many can be passed at once. Signed-off-by: Jason A. Donenfeld Reported-by: Alexey --- src/wg-quick/android.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/wg-quick/android.c b/src/wg-quick/android.c index cedc8a7..54ea81c 100644 --- a/src/wg-quick/android.c +++ b/src/wg-quick/android.c @@ -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) -- cgit v1.2.3-59-g8ed1b