editing /etc/passwd

  • Follow


Hi.

Is there any problem if I edit /etc/passwd file ?

Which vi command (or another command) can I use to
find hidden characters in this file ?

Thanks to all.
0
Reply apogeusistemas 5/20/2008 10:40:31 PM

apogeusistemas@gmail.com wrote:
> Hi.
> 
> Is there any problem if I edit /etc/passwd file ?
> 
> Which vi command (or another command) can I use to
> find hidden characters in this file ?
> 
> Thanks to all.

use the readonly view command
$ view /etc/passwd
and
:set list
this will show characters.
:set nolist
reverts
/Jorgen
0
Reply Jorgen 5/20/2008 10:51:53 PM


apogeusistemas@gmail.com wrote:
> Hi.
> 
> Is there any problem if I edit /etc/passwd file ?
> 
> Which vi command (or another command) can I use to
> find hidden characters in this file ?
> 
> Thanks to all.

There is a risk to editing /etc/passwd!  Vi does NOT lock the file!  If 
  someone else is changing something in /etc/passwd, one or both of you 
are going to get screwed!  The risk, on a single user workstation is 
just about zero.  On a multiuser system it's a crapshoot!!!  There IS a 
way to lock /etc/passwd and/or /etc/shadow which I never used; I never 
need it!

This was discussed either here or on comp.sys.sun.admin two or three 
months ago.  You could try googling for it or you could rtfm to find out 
what it is.  Or maybe some kind person will pop up and tell you.
0
Reply Richard 5/20/2008 11:00:04 PM

apogeusistemas@gmail.com wrote:
> Hi.
> 
> Is there any problem if I edit /etc/passwd file ?
> 
> Which vi command (or another command) can I use to
> find hidden characters in this file ?
> 
> Thanks to all.

If your system has it try 'vipw' command.
If not, first make a copy of passwd and shadow,
then edit the copies.

When done, run 'pwck passwd.copy shadow.copy'.
If everything is good, replace the originals with the copies.

If using 'vipw' you should still run 'pwck' when done (no
options needed in this case), before re-booting!

But this hand editing shouldn't be needed to change one (or a
small number of) password(s).  You need to read the Solaris
man page for the passwd command.  Please note if not using
the files /etc/passwd or /etc/shadow, editing those files
won't solve your problem.  You need to determine if your
host uses files, NIS/NIS+/LDAP/Kerberos instead, and update
the relevant password database.  With the correct options
I believe the passwd command should do that correctly.

-Wayne
0
Reply Wayne 5/20/2008 11:20:23 PM

Richard B. Gilbert wrote:
> apogeusistemas@gmail.com wrote:
>> Hi.
>>
>> Is there any problem if I edit /etc/passwd file ?
>>
>> Which vi command (or another command) can I use to
>> find hidden characters in this file ?
>>
>> Thanks to all.
> 
> There is a risk to editing /etc/passwd!  Vi does NOT lock the file!  If 
>  someone else is changing something in /etc/passwd, one or both of you 
> are going to get screwed!  The risk, on a single user workstation is 
> just about zero.  On a multiuser system it's a crapshoot!!!  There IS a 
> way to lock /etc/passwd and/or /etc/shadow which I never used; I never 
> need it!
> 
> This was discussed either here or on comp.sys.sun.admin two or three 
> months ago.  You could try googling for it or you could rtfm to find out 
> what it is.  Or maybe some kind person will pop up and tell you.

There is a library call for this, lckpwdf(3) ("LoCK PassWord Files"?).
Since several files are involved this creates /etc/.lckpwdf if missing
and locks/unlocks that.

AFAIK there is no user-level command to lock these, which comes up
on this group every few months when someone wants to create a non-interactive
script to update password data safely (as possible).  (There is no
good way.)

-Wayne
0
Reply Wayne 5/20/2008 11:31:20 PM

In article <48335c8b$0$12971$4c368faf@roadrunner.com>,
Wayne  <nospam@all4me.invalid> wrote:
>apogeusistemas@gmail.com wrote:
>If your system has it try 'vipw' command.

I use the vipw command, which lives in /usr/ucb/vipw.  A default installation
of S10 or Nevada or OpenSolaris should include the /usr/ucb commands.


--
Daniel L. McDonald  -  Solaris Security & Networking Engineering
Mail: danmcd@sun.com             |  * MY OPINIONS ARE NOT NECESSARILY SUN'S! *
35 Network Drive  Burlington, MA |"rising falling at force ten
http://blogs.sun.com/danmcd/     | we twist the world and ride the wind" - Rush
0
Reply danmcd 5/20/2008 11:46:39 PM

On Tue, 20 May 2008 19:31:20 -0400
Wayne <nospam@all4me.invalid> wrote:

> AFAIK there is no user-level command to lock these, which comes up
> on this group every few months when someone wants to create a
> non-interactive script to update password data safely (as possible).
> (There is no good way.)

What's wrong with `EDITOR=/foo/script.sh vipw`?

-- 
Andrew Deason
adeason2@uiuc.edu
0
Reply Andrew 5/21/2008 4:07:40 AM

Wayne <nospam@all4me.invalid> wrote:
> If your system has it try 'vipw' command.
> If not, first make a copy of passwd and shadow,
> then edit the copies.
> 
> When done, run 'pwck passwd.copy shadow.copy'.
> If everything is good, replace the originals with the copies.

And if the system had changed a password or made changes since you
copied the files, you've just nuked those changes.

-- 
Darren
0
Reply ddunham 5/21/2008 6:14:01 AM

Darren Dunham wrote:
> Wayne <nospam@all4me.invalid> wrote:
>> If your system has it try 'vipw' command.
>> If not, first make a copy of passwd and shadow,
>> then edit the copies.
>>
>> When done, run 'pwck passwd.copy shadow.copy'.
>> If everything is good, replace the originals with the copies.
> 
> And if the system had changed a password or made changes since you
> copied the files, you've just nuked those changes.
> 

That's what change management is for.  But the window of opportunity
is very small, a few seconds.  On systems with hundreds/thousands
of users files are rarely used.  In practice this procedure
is very safe.

-Wayne
0
Reply Wayne 5/21/2008 6:36:10 AM

On Tue, 20 May 2008 15:40:31 -0700 (PDT), apogeusistemas@gmail.com <apogeusistemas@gmail.com> wrote:
| Hi.
|
| Is there any problem if I edit /etc/passwd file ?
|
| Which vi command (or another command) can I use to
| find hidden characters in this file ?


If all you want is to find hidden/unusual characters, try the 'od'
command. I use 'od -c' for stuff like that.


-- 
Reverend Paul Colquhoun, ULC.    http://andor.dropbear.id.au/~paulcol
     Asking for technical help in newsgroups?  Read this first:
        http://catb.org/~esr/faqs/smart-questions.html#intro
0
Reply Paul 5/21/2008 6:39:04 AM

Paul Colquhoun wrote:
> On Tue, 20 May 2008 15:40:31 -0700 (PDT), apogeusistemas@gmail.com <apogeusistemas@gmail.com> wrote:
> | Hi.
> |
> | Is there any problem if I edit /etc/passwd file ?
> |
> | Which vi command (or another command) can I use to
> | find hidden characters in this file ?
> 
> 
> If all you want is to find hidden/unusual characters, try the 'od'
> command. I use 'od -c' for stuff like that.
> 
> 
I find cat -vet useful.

Pete.
0
Reply Peter 5/21/2008 7:41:43 AM

10 Replies
205 Views

(page loaded in 0.399 seconds)

Similiar Articles:













7/25/2012 2:57:43 AM


Reply: