Unix Technical Forum

Encrypted password in NIS+ set by hand or with passwd

This is a discussion on Encrypted password in NIS+ set by hand or with passwd within the Sun Solaris Administration forums, part of the Solaris Operating System category; --> Hello, I have a question, maybe it's not very important or only a side effect of something but I'm ...


Go Back   Unix Technical Forum > Unix Operating Systems > Solaris Operating System > Sun Solaris Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2008, 06:06 AM
Soterro
 
Posts: n/a
Default Encrypted password in NIS+ set by hand or with passwd

Hello,

I have a question, maybe it's not very important or only a side effect
of something but I'm really puzzled by this...

I have a nice NIS+ domain. I have a disabled user in it, disabled
because let's say it has no password. The passwd.org_dir entry will
have in this case NP in the password field. Maybe it's locked and will
have *LK*, nevermind.

I'm trying to reenable it and set a new password with the following
perl script (attached below)
Basically it reads the passwd table entry, crypts the new password,
puts it back, and sets also the credentials. The script succeeds, the
user is enabled and able to use its new password. However, when I look
in the passwd table again (nismatch), I see always the encrypted
password keeping the first two characters of the previous value!

Like if the old was NP, the new one will be NPHJ/hbj87g65, if the old
was *LK* the new will be *LHJ/hbj87g65 and such (yes, a password with
a star in front can be perfectly valid). Even with a user with a
previously valid password, like nThiuh75vh the new one will be
nTJ/hbj87g65 What does this mean??? Am I misunderstanding something,
and using the salt for crypt in a wrong way?

Because if I use the normal 'passwd -r nisplus user' interactive
command, the same password gets another encryption. I repeat, both
methods give usable passwords, but with different encryptions, one
sillier...

Thank you,
S

-------perl script, receives as arguments $user, $uid, $domain and
$password--------

open(PWF, "nismatch $user passwd.org_dir |") || die "nismatch $user
failed\n";
@userdesc = split(/:/,<PWF>);
close(PWF);
die "$user not found\n" unless @userdesc[0] ne "";
$salt = substr(@userdesc[1], 0, 2);
$salt = "cq" if length($salt) < 2;
$encryptedpwd = crypt($password, $salt);
$cmd = "nistbladm -e passwd=$encryptedpwd
\[name=$user\],passwd.org_dir.$domain.";
die "Password setting failed\n" unless system($cmd) == 0;
$cmd = "nisaddcred -l $password -p unix.$uid\@$domain -P $user.$domain
des $domain";
die "DES setting failed\n" unless system($cmd) == 0;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:30 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com