Example #1
0
File: crypt.c Project: ares89/vlc
int main (int argc, char **argv)
{
  gaainfo info;
  const char *passwd;
  int salt_size, ret;
#ifndef _WIN32
   struct passwd *pwd;
#endif

  set_program_name (argv[0]);

  if ((ret = gnutls_global_init ()) < 0)
    {
      fprintf (stderr, "global_init: %s\n", gnutls_strerror (ret));
      exit (1);
    }

  umask (066);

  if (gaa (argc, argv, &info) != -1)
    {
      fprintf (stderr, "Error in the arguments.\n");
      return -1;
    }

  gnutls_global_set_log_function (tls_log_func);
  gnutls_global_set_log_level (info.debug);

  if (info.create_conf != NULL)
    {
      return generate_create_conf (info.create_conf);
    }

  if (info.passwd == NULL)
    info.passwd = (char *) KPASSWD;
  if (info.passwd_conf == NULL)
    info.passwd_conf = (char *) KPASSWD_CONF;

  if (info.username == NULL)
    {
#ifndef _WIN32
      pwd = getpwuid (getuid ());

      if (pwd == NULL)
        {
          fprintf (stderr, "No such user\n");
          return -1;
        }

      info.username = pwd->pw_name;
#else
      fprintf (stderr, "Please specify a user\n");
      return -1;
#endif
    }

  salt_size = 16;

  passwd = getpass ("Enter password: "******"Please specify a password\n");
      return -1;
    }

/* not ready yet */
  if (info.verify != 0)
    {
      return verify_passwd (info.passwd_conf, info.passwd,
                            info.username, passwd);
    }


  return crypt_int (info.username, passwd, salt_size,
                    info.passwd_conf, info.passwd, info.index);

}
Example #2
0
int main (int argc, char **argv)
{
  const char *passwd;
  int salt_size, ret;
  int optct;
  const char* fpasswd, *fpasswd_conf;
  const char* username;
#ifndef _WIN32
   struct passwd *pwd;
#endif

  set_program_name (argv[0]);

  if ((ret = gnutls_global_init ()) < 0)
    {
      fprintf (stderr, "global_init: %s\n", gnutls_strerror (ret));
      exit (1);
    }

  umask (066);

  optct = optionProcess( &srptoolOptions, argc, argv);
  argc -= optct;
  argv += optct;

  gnutls_global_set_log_function (tls_log_func);
  gnutls_global_set_log_level (OPT_VALUE_DEBUG);

  if (HAVE_OPT(CREATE_CONF))
    {
      return generate_create_conf (OPT_ARG(CREATE_CONF));
    }

  if (HAVE_OPT(PASSWD))
    fpasswd = OPT_ARG(PASSWD);
  else
    fpasswd = (char *) KPASSWD;

  if (HAVE_OPT(PASSWD_CONF))
    fpasswd_conf = OPT_ARG(PASSWD_CONF);
  else
    fpasswd_conf = (char *) KPASSWD_CONF;

  if (HAVE_OPT(USERNAME))
    username = OPT_ARG(USERNAME);
  else
    {
#ifndef _WIN32
      pwd = getpwuid (getuid ());

      if (pwd == NULL)
        {
          fprintf (stderr, "No such user\n");
          return -1;
        }

      username = pwd->pw_name;
#else
      fprintf (stderr, "Please specify a user\n");
      return -1;
#endif
    }

  salt_size = 16;

  passwd = getpass ("Enter password: "******"Please specify a password\n");
      return -1;
    }

/* not ready yet */
  if (HAVE_OPT(VERIFY))
    {
      return verify_passwd (fpasswd_conf, fpasswd,
                            username, passwd);
    }


  return crypt_int (username, passwd, salt_size,
                    fpasswd_conf, fpasswd, VALUE_OPT_INDEX);

}
Example #3
0
int
main (int argc, char **argv)
{
  gaainfo info;
  const char *passwd;
  int salt, ret;
  struct passwd *pwd;

  if ((ret = gnutls_global_init ()) < 0)
    {
      fprintf (stderr, "global_init: %s\n", gnutls_strerror (ret));
      exit (1);
    }

#ifdef HAVE_UMASK
  umask (066);
#endif

  if (gaa (argc, argv, &info) != -1)
    {
      fprintf (stderr, "Error in the arguments.\n");
      return -1;
    }

  salt = info.salt;

  if (info.create_conf != NULL)
    {
      return generate_create_conf (info.create_conf);
    }

  if (info.passwd == NULL)
    info.passwd = KPASSWD;
  if (info.passwd_conf == NULL)
    info.passwd_conf = KPASSWD_CONF;

  if (info.username == NULL)
    {
#ifndef _WIN32
      pwd = getpwuid (getuid ());

      if (pwd == NULL)
	{
	  fprintf (stderr, "No such user\n");
	  return -1;
	}

      info.username = pwd->pw_name;
#else
      fprintf (stderr, "Please specify a user\n");
      return -1;
#endif
    }

  salt = 16;

  passwd = getpass ("Enter password: "******"Please specify a password\n");
      return -1;
    }

/* not ready yet */
  if (info.verify != 0)
    {
      return verify_passwd (info.passwd_conf, info.passwd,
			    info.username, passwd);
    }


  return crypt_int (info.username, passwd, salt,
		    info.passwd_conf, info.passwd, info.index);

}