From: Jason A. Donenfeld Date: Fri, 31 Jan 2020 17:56:52 +0000 (+0100) Subject: wg-quick: android: split uids into multiple commands X-Git-Tag: v1.0.20200206~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6771c4454eab2661166c1c672db7b76ff3f18020;p=thirdparty%2Fwireguard-tools.git 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 --- 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)