Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unix Passwd wrapper?

34 views
Skip to first unread message

Davis Steven Alston

unread,
Jun 15, 1996, 3:00:00 AM6/15/96
to

s there a way to automatically set passwords for accounts?

ie type /bin/passwd user password

instead of having to run /bin/passwd interactively? I`m attempting to write
a CSH script to create accounts and set default passwords.


bill davidsen

unread,
Jun 17, 1996, 3:00:00 AM6/17/96
to

In article <4ptusq$r...@news.asiaonline.net>,

No comment on your choice of language, but I'd be tempted to do it
in C and use the system calls. From memory, try "man putpwent."
--
Bill Davidsen (davi...@tmr.com)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me

Leo Marbun

unread,
Jun 17, 1996, 3:00:00 AM6/17/96
to

In article <4ptusq$r...@news.asiaonline.net>,

s...@asiaonline.net (Davis Steven Alston) wrote:
>s there a way to automatically set passwords for accounts?
>
>ie type /bin/passwd user password
>
>instead of having to run /bin/passwd interactively? I`m attempting to write
>a CSH script to create accounts and set default passwords.
>
>
>

Write a script in expect.

Andrew Moar

unread,
Jun 19, 1996, 3:00:00 AM6/19/96
to

Davis Steven Alston <s...@asiaonline.net> wrote:
| Is there a way to automatically set passwords for accounts?

|
| ie type /bin/passwd user password
|
| instead of having to run /bin/passwd interactively? I`m attempting to write
| a CSH script to create accounts and set default passwords.

I'd use expect. Have a look at http://www.cme.nist.gov/pub/expect/

Andrew Moar : email A.M...@latrobe.edu.au : ph. (03) 479 3928
Systems Programmer, Information Technology
La Trobe University, Melbourne


krw

unread,
Jun 19, 1996, 3:00:00 AM6/19/96
to

Andrew Moar (a.m...@latrobe.edu.au) wrote:

Hmm... I'm almost finished with a newusr command in C. My idea was to check
for evertyihg, including nfs mounted home directories, soft links to
home directory roots, and suggest home directories for users in certain
groups by checking to see where most members of a group currently reside.
After all, I won't be here forever, and after I leave, unix haters will have
to administer UNIX computers they know nothing about.

Anyways, if you are interested, I suspect I will have some functional code
finished by next week sometime.


BTW, who was talking about putpwent? Is that POSIX? I noticed that I have
it, but don't know if it can be used to create a new entry.

Ken.

--
/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\
\ The Whittaker's domain! /
/ Try our MUD (Multi User Domain) \
\ Come to: /
/ aGe oF iNsaNitY \
\ telnet to: newton.whit.org 4000 /
/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\--/--\

Don Shesnicky

unread,
Jun 21, 1996, 3:00:00 AM6/21/96
to

I think this Perl script would do it (no warranty what so ever, use at
your own risk). It's missing the ./ characters from the salt list.
Sample output:

% crypt_passwd testone2
ppHOs/VqtIKd.


-------
#!/usr/local/bin/perl

{

@salt = ('a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'0','1','2','3','4','5','6','7','8','9');
$salt_cnt = 62;

if($#ARGV != 0) {
print "usage: crypt_passwd passwd\n";
exit;
}

$input = $ARGV[0];

srand(time|$$);
$salt1 = int(rand($salt_cnt)) + 1;
$salt1 = @salt[$salt1];
$salt2 = int(rand($salt_cnt)) + 1;
$salt2 = @salt[$salt2];
$salt1 = "$salt1$salt2";
$encrypted = crypt($input,$salt1);
print "$encrypted\n";
}

-------------


Chris Riney

unread,
Jun 21, 1996, 3:00:00 AM6/21/96
to

Only problem that I can see is that passwd(1) tends to open /dev/tty
instead of relying on the current STDIO and STDOUT, usually for security/
spoofing reasons (similar to what is proposed here).

Easyest meathod would be to write a C or Perl application and use the crypt(3)
and getpwent(3)/putpwent(3) functions.

Andrew Moar (a.m...@latrobe.edu.au) wrote:
: Davis Steven Alston <s...@asiaonline.net> wrote:
: | Is there a way to automatically set passwords for accounts?
: |
: | ie type /bin/passwd user password
: |
: | instead of having to run /bin/passwd interactively? I`m attempting to write
: | a CSH script to create accounts and set default passwords.

: I'd use expect. Have a look at http://www.cme.nist.gov/pub/expect/

: Andrew Moar : email A.M...@latrobe.edu.au : ph. (03) 479 3928
: Systems Programmer, Information Technology
: La Trobe University, Melbourne


--
Chris Riney E-mail: cri...@tandy.com
Technical Services PostM...@tandy.com
Tandy Information Services Phone: (817) 878-0308

0 new messages