Hello,

I need a script that checks a password file or invalid users. I am on a Unix box and all the passwords are NIS. I just add them to a front end. But users come and go - but their passwords stay - and the list just get long.

I want to take each password - one by one - do a ypmatch on it - if it is in NIS - keep it - if not - delete it.

If possible if ypmatch comes back with a 'cracked' or 'expired' email the admin.

What I plan to do - check the list for lines beginning with "+" - do a system call with the first field (Unix ID) doing a ypmatch.

I am not sure how to interpret the out come though - is it there or not.

Anybody have suggestions on how to proceed - or aware of a library that would help with this?

i.e.
root:123456/xx.xxx:0:3::/home/root:/csh <---skip
johnny:XXXxxxXXXxxx:0:3:John Admin:/home/John:bin/csh <---skip
+dots::0:0:Support:/home/support:/bin/csh <--in NIS - keep
+user1::0:0:Hobbit Bilbo:/home/asia:/bin/csh <--in NIS - keep
+user2::0:0:Jim Bean:/home/asia:/bin/csh <--not in NIS remove
+user3::0:0:Bill Gates:/home/asia:/bin/csh <--in NIS - keep
It will write the new password file - but without user2

Thanks,
V

In reply to Password file and NIS check? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.