- char *cp;
- const char *pw_passwd, *pw_shell;
- size_t nsize, psize, csize, gsize, dsize, ssize, total;
- struct passwd *newpw;
-
- /* Get shadow password if available. */
- pw_passwd = sudo_getepw(pw);
-
- /* If shell field is empty, expand to _PATH_BSHELL. */
- pw_shell = (pw->pw_shell == NULL || pw->pw_shell[0] == '\0')
- ? _PATH_BSHELL : pw->pw_shell;
-
- /* Allocate in one big chunk for easy freeing. */
- nsize = psize = csize = gsize = dsize = ssize = 0;
- total = sizeof(struct passwd);
- if (pw->pw_name) {
- nsize = strlen(pw->pw_name) + 1;
- total += nsize;
- }
- if (pw_passwd) {
- psize = strlen(pw_passwd) + 1;
- total += psize;
- }
-#ifdef HAVE_LOGIN_CAP_H
- if (pw->pw_class) {
- csize = strlen(pw->pw_class) + 1;
- total += csize;
- }