LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   adduser not working - unable to lock passwd (https://www.linuxquestions.org/questions/linux-general-1/adduser-not-working-unable-to-lock-passwd-61188/)

Shin Takeshita 05-22-2003 11:16 AM

adduser not working - unable to lock passwd
 
I am running RH 7.2 (I think. It's 7.x for sure. It's been up for so long) as a samba and web server for internal network. Recently, I tried to add a user using linuxconf but did not work. I tried "useradd", but it could not be executed because it can not "lock the password file".
(exact output is - useradd: unable to lock password file)

I ended up adding the users by manually creating the
home directories and vi-ing the /etc/passwd and /etc/shadow
files, copying all the .bash* files etc. from another existing home directory, chown-ing (-R) the home directories, then running passwd <newuser>.

I ran fuser to see if there is any process (like another session of linuxconf I fogot to close, etc.) using passwd or shadow, but there seems to be no other process accessing the file.

Can anyone help me with figuring out what is going on?

Thanks.

rch 05-23-2003 09:22 AM

Re: adduser not working - unable to lock passwd
 
Quote:

Originally posted by Shin Takeshita
I am running RH 7.2 (I think. It's 7.x for sure. It's been up for so long) as a samba and web server for internal network. Recently, I tried to add a user using linuxconf but did not work. I tried "useradd", but it could not be executed because it can not "lock the password file".
(exact output is - useradd: unable to lock password file)

I ended up adding the users by manually creating the
home directories and vi-ing the /etc/passwd and /etc/shadow
files, copying all the .bash* files etc. from another existing home directory, chown-ing (-R) the home directories, then running passwd <newuser>.

I ran fuser to see if there is any process (like another session of linuxconf I fogot to close, etc.) using passwd or shadow, but there seems to be no other process accessing the file.

Can anyone help me with figuring out what is going on?
Thanks.

You can't add a user unless you are suid
So try that with root and it should work.

Shin Takeshita 05-23-2003 11:30 AM

I have executed su.

Note that I was able to vi /etc/passwd and /etc/shadow.
If I were not root, I wouldn't be able to do that.
I am not daring enough to give anything more than 644 and 400, respectively, to these files.

The error message was not that I do not have write priviledge to the password file, but "unable to lock."

rch 05-27-2003 09:41 AM

Quote:

Originally posted by Shin Takeshita
I have executed su.

Note that I was able to vi /etc/passwd and /etc/shadow.
If I were not root, I wouldn't be able to do that.
I am not daring enough to give anything more than 644 and 400, respectively, to these files.

The error message was not that I do not have write priviledge to the password file, but "unable to lock."

I had similiar problem like yours when I was trying to change my password over telnet.The password file /etc/passwd needs to be locked to access it(means that it should not be used by anybody else(or any other process)).Maybe you are familiar with the locks in /var/.So I ask you whether you were changing the password through the network or anything else was using it?
You can't use 400 coz if some user other than root try to access it he will be denied.
You can try 744 normally as it would not compromise your security.

syncretism 10-24-2014 04:51 PM

Sorry for resurrecting a thread so old, but it's the first result Google returned after I encountered this behavior today.

I got the same adduser error and saw the expected lockfile, /etc/.pwd.lock. lsof showed nothing using it, and when I removed it, it would appear again after running the adduser command. The cause was - in this case, at least - pretty prosaic; the filesystem was full. After space was freed up, the command ran as expected. I hope that's helpful for someone else ten years from now.


All times are GMT -5. The time now is 03:04 PM.