Ramana Reddy
Ramana Reddy

Reputation: 399

Errors while changing "passwd" in openwrt

I am using ext4 as my root file system. I am using OpenWRT Chaos Calmer. When I change the passwd, I see the following error sometimes:

root@US16SIQC:~# passwd 
Changing password for root
New password: 
Bad password: too short
Retype password: 

passwd: can't create '/etc/passwd+': File exists
passwd: can't update password file /etc/passwd

These things happen sometimes only. What is the fix for this?

Whenever I change the passwd, it creates passwd+ and passwd- files. I undersatnd that passwd+ file gets copied into passwd file and passwd- is a backup file. So when the first error came, this file still exists.

Please help on this. Thanks in advance!!

[EDIT]: I Fixed the read-only filesystem problem, but still see the issue.

Steps to reproduce:

  1. Change passwd (Passwd changed successfully)
  2. Observe that there is no passwd+ file in /etc
  3. Do a hard power reboot
  4. Observed that passwd+ is exists under /etc
  5. Now I cannot change it unless I remove the passwd+ file

This happens only by hard reboot, not by soft reboot.

I am using imx6dl based custom board with eMMC flash containing two partitions-one vfat(zImage and dtb) and other etx4(rootfs).

Upvotes: 1

Views: 4844

Answers (3)

Brad Grissom
Brad Grissom

Reputation: 3933

I experienced the same behavior on a different embedded linux system. I found that by resetting the password and immediately power cycling, the issue would crop up.

Looking into busybox's implementation, I found that the /etc/passwd+ file is a temp file for the new changes. Once it has been successfully written with the new changes, it is moved back to /etc/passwd

So the presense of /etc/passwd+ indicates the previous iteration failed in some way, either with a power cycle before it could be moved (or removed), or a filesystem error of sorts (a lot can happen in that regard on an embedded system like power glitches, full filesystem, corrupt NAND flash, over-temperature, etc.)

The busybox implementation will error out if the file already exists:

From libbb/update_passwd.c

123     /* Try to create "/etc/passwd+". Wait if it exists. */
124     i = 30;
125     do {
126         // FIXME: on last iteration try w/o O_EXCL but with O_TRUNC?
127         new_fd = open(fnamesfx, O_WRONLY|O_CREAT|O_EXCL, 0600);
128         if (new_fd >= 0) goto created;
129         if (errno != EEXIST) break;
130         usleep(100000); /* 0.1 sec */
131     } while (--i);
132     bb_perror_msg("can't create '%s'", fnamesfx);
133     goto close_old_fp;

Upvotes: 0

vahid-dan
vahid-dan

Reputation: 322

I had the same problem. I wasn't able to set a password for root. The file was read-only. There were some mounting error logs while the system was booting. The problem solved by re-installing the OpenWRT. Apparently, it was a file system issue.

Upvotes: 1

fossil
fossil

Reputation: 770

OpenWRT is not installed correctly.

Usually, this happens when the overlay file system is not initialised properly.

root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                     320       232        88  73% /
/dev/root                 2560      2560         0 100% /rom
tmpfs                    14504        96     14408   1% /tmp
/dev/mtdblock3             320       232        88  73% /overlay
overlayfs:/overlay         320       232        88  73% /
tmpfs                      512         0       512   0% /dev

If you run df at root prompt, you should see overlays:/overlay filesystem mounted on /.

One of the possible causes is trying to install image bigger than the flash. Or, probably the reboot after installation was interrupted.

Upvotes: 0

Related Questions