old_fp = fopen(filename, "r+");
else
old_fp = fopen_or_warn(filename, "r+");
- if (!old_fp)
+ if (!old_fp) {
+ if (shadow)
+ ret = 0; /* missing shadow is not an error */
goto free_mem;
+ }
old_fd = fileno(old_fp);
selinux_preserve_fcontext(old_fd);
fchown(new_fd, sb.st_uid, sb.st_gid);
}
errno = 0;
- new_fp = fdopen(new_fd, "w");
- if (!new_fp) {
- bb_perror_nomsg();
- close(new_fd);
- goto unlink_new;
- }
+ new_fp = xfdopen_for_write(new_fd);
/* Backup file is "/etc/passwd-" */
*sfx_char = '-';