LibC: Add passwords to putpwent

This commit is contained in:
Peter Elliott 2020-07-25 16:05:19 -06:00 committed by Andreas Kling
parent e57a432118
commit 3c1c5cc541
Notes: sideshowbarker 2024-07-19 04:30:56 +09:00

View file

@ -145,6 +145,7 @@ next_entry:
__pwdb_entry->pw_gecos = __pwdb_entry->gecos_buffer;
__pwdb_entry->pw_dir = __pwdb_entry->dir_buffer;
__pwdb_entry->pw_shell = __pwdb_entry->shell_buffer;
strncpy(__pwdb_entry->name_buffer, e_name.characters(), PWDB_STR_MAX_LEN - 1);
strncpy(__pwdb_entry->passwd_buffer, e_passwd.characters(), PWDB_STR_MAX_LEN - 1);
strncpy(__pwdb_entry->gecos_buffer, e_gecos.characters(), PWDB_STR_MAX_LEN - 1);
@ -155,7 +156,7 @@ next_entry:
int putpwent(const struct passwd* p, FILE* stream)
{
if (!p || !stream || !p->pw_name || !p->pw_dir || !p->pw_gecos || !p->pw_shell) {
if (!p || !stream || !p->pw_passwd || !p->pw_name || !p->pw_dir || !p->pw_gecos || !p->pw_shell) {
errno = EINVAL;
return -1;
}
@ -169,7 +170,7 @@ int putpwent(const struct passwd* p, FILE* stream)
return -1;
}
int nwritten = fprintf(stream, "%s:x:%u:%u:%s,,,:%s:%s\n", p->pw_name, p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
int nwritten = fprintf(stream, "%s:%s:%u:%u:%s,,,:%s:%s\n", p->pw_name, p->pw_passwd, p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
if (!nwritten || nwritten < 0) {
errno = ferror(stream);
return -1;