SUMMARY: Crypt

From: Ing. Silvia Beltran S. (sbelt@mailer.sagar.gob.mx)
Date: Tue Aug 05 1997 - 12:23:19 CDT


Thanks Sun Managers,

Thanks for all the people that answered my question, They helped me a
lot.
Silvia.
------------------------------------------
The question was:
I want to automate the task of add users, I did a script that added the
specific line in the /etc/passwd, but I want to add the encripted
password also, Does somebody know the use of crypt ? The man pages just
tell me:
crypt key password
and I use for example: crypt jo LIkes9
the result is: !d"yp
and this is not a valid password .....
-------------------------------------------------
The answer was:

Compile this program and run it from the command line with the following

option.
cc -o rpass rpass.c
rpass sspasswd
Where ss represents the salt and passwd represents the actual password.
This is modification of similar program posted on sun-managers mailing
list.
Kamal
/* Reverse with easy salt mkpasswd.c */
#include <stdio.h>
#include <string.h>
main(argc,argv)
int argc;
char *argv[];
{
  char line[512],salt[3];
  int i,l;
  salt[2]='\0';
  if(argc == 1) /* No parameters there read from standard input */
  {
    while(gets(line) != NULL)
    {
      l=strlen(line);
      if(l > 2)
      {
        salt[0]=line[0];
        salt[1]=line[1];
        printf("%s\n",crypt(line+2,salt));
      }
      else
        fprintf(stderr,"Too short [%i] \"%s\"\n",l,line);
    }
  }
  else
  {
    for(i=1;i<argc;i++)
    {
      l=strlen(argv[i]);
      if(l > 2)
      {
        salt[0]=argv[i][0];
        salt[1]=argv[i][1];
        printf("%s\n",crypt(argv[i]+2,salt));
      }
      else
        fprintf(stderr,"Too short [%i] \"%s\"\n",l,argv[i]);
    }
  }
}

-----------------------------------
Comments:

Stephen Harris <sweh@mpn.com>"The command line crypt program is not the
same as the crypt() function call."
Silvia: sorry, I was confusing the ideas.

Rich Snyder <rsnyder@eos.hitc.com> "There is also a Perl crypt function
that does the same thing if you prefer Perl."
Silvia: I prefer use the c program :)

Michal Dombrowski <temple@mat.uni.torun.pl> "Perhaps you could use the
standard Solaris tool named 'useradd'"
Silvia: But useradd doesn't add the password

Jim Harmon <jharmon@telecnnct.com> "First, built the line that will
include the passwd, leaving the "passwd" field = ",." And then tell the
new user to login, or instead, after creating this line, invoke "passwd"
as root and install your new passwd for the user with expect or some
other utility."
Silvia: Well, the users can take them mails just using a POP/client,
they can't do telnet to the server ( policy), the second option ...
sometimes I have to set up 100 emails (more or less), imagine the
slowness with passwd, third option ... I used expect with a script,but
when the program take the user 30, the program break I don't know why
but that happend.

-----------------------------------
Special Thanks for:

Kamal Kantawala <kamal@mcc.com>
BCE User <iwallace@bcoe.bm>
Bob Bridgham <robbie@b-e-s-t.com>
"Rich Snyder" <rsnyder@eos.hitc.com>
Javier Figueiredo <jfigue@impsat1.com.ar>
D.White@mcs.surrey.ac.uk
peter.allan@aeat.co.uk (Peter M Allan)
John Birtley <john@baesema.co.uk>
Stephen Harris <sweh@mpn.com>
Michal Dombrowski <temple@mat.uni.torun.pl>
Chris Marble <cmarble@orion.ac.hmc.edu>
Jose Luis Delgado <jdelgado@nexus.net.mx>
Jim Harmon <jharmon@telecnnct.com>
Mike.Carson@telos.com (Mike Carson)
Ada Chan <chan@library.ucsf.edu>
"Brion Leary" <brion@dia.state.ma.us>
Ian TCollins <itc1@scigen.co.uk>
Gerald Combs - Unicom Communications <gerald@unicom.net>
"Alex Lattanzi" <alattanzi@impsat1.com>
fpardo@tisny.com (Frank Pardo)
Jim McVey <jmcvey@nhgri.nih.gov>
John D Groenveld <groenvel@cse.psu.edu>
Troy Wollenslegel <troy@intranet.org>
Tawanda Queen <trq96@acs.org>



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:00 CDT