From: Frank Lahm Date: Mon, 18 Jul 2011 09:04:19 +0000 (+0200) Subject: Previous commit removed fix for debug printing large amount of supplementary groups X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=83df4690e046f6bd8315ed67c0bef3b00fd0c189 Previous commit removed fix for debug printing large amount of supplementary groups --- diff --git a/etc/afpd/auth.c b/etc/afpd/auth.c index 566a8d0e..eb9b58dd 100644 --- a/etc/afpd/auth.c +++ b/etc/afpd/auth.c @@ -250,6 +250,23 @@ static int set_auth_switch(int expired) return AFP_OK; } +#define GROUPSTR_BUFSIZE 1024 +static const char *print_groups(int ngroups, gid_t *groups) +{ + static char groupsstr[GROUPSTR_BUFSIZE]; + int i; + char *s = groupsstr; + + if (ngroups == 0) + return "-"; + + for (i = 0; (i < ngroups) && (s < &groupsstr[GROUPSTR_BUFSIZE]); i++) { + s += snprintf(s, &groupsstr[GROUPSTR_BUFSIZE] - s, " %u", groups[i]); + } + + return groupsstr; +} + static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expired) { #ifdef ADMIN_GRP @@ -391,28 +408,7 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi } #endif /* TRU64 */ - if (ngroups > 0) { - #define GROUPSTR_BUFSIZE 1024 - char groupsstr[GROUPSTR_BUFSIZE]; - char *s = groupsstr; - int j = GROUPSTR_BUFSIZE; - - int n = snprintf(groupsstr, GROUPSTR_BUFSIZE, "%u", groups[0]); - j -= n; - s += n; - - for (int i = 1; i < ngroups; i++) { - n = snprintf(s, j, ", %u", groups[i]); - if (n == j) { - /* Buffer full */ - LOG(log_debug, logtype_afpd, "login: group string buffer overflow"); - break; - } - j -= n; - s += n; - } - LOG(log_debug, logtype_afpd, "login: %u supplementary groups: %s", ngroups, groupsstr); - } + LOG(log_debug, logtype_afpd, "login: supplementary groups: %s", print_groups(ngroups, groups)); /* There's probably a better way to do this, but for now, we just play root */ #ifdef ADMIN_GRP