- if (getpwuid_r (getuid (), &passwd, pw_buf, pw_buf_size, &ignored) == 0) {
+ if (pw_buf_size == -1) pw_buf_size = 64;
+
+ while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
+ pw_buf_size, &ignored)) == ERANGE) {
+ pw_buf_size = pw_buf_size * 2;
+ pw_buf = talloc_zero_size(ctx, pw_buf_size);
+ }
+
+ if (e == 0) {