• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/package/mkpasswd/mkpasswd.c
Thomas De SchampheleireThomas De Schampheleire committed 59e0692095007 Aug 2013
Raw file
Source viewDiff to previous
xxxxxxxxxx
 
/*
 * Copyright (C) 2001-2008  Marco d'Itri
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
​
/* for crypt, snprintf and strcasecmp */
#define _XOPEN_SOURCE
#define _BSD_SOURCE
​
/* System library */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "config.h"
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#endif
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#ifdef HAVE_XCRYPT
#include <xcrypt.h>
#include <sys/stat.h>
#endif
#ifdef HAVE_LINUX_CRYPT_GENSALT
#define _OW_SOURCE
#include <crypt.h>
#endif
#ifdef HAVE_GETTIMEOFDAY
#include <sys/time.h>
#endif
​
/* Application-specific */
#include "utils.h"
​
/* Global variables */
#ifdef HAVE_GETOPT_LONG
static const struct option longopts[] = {
    {"method",      optional_argument,  NULL, 'm'},
    /* for backward compatibility with versions < 4.7.25 (< 20080321): */
    {"hash",        optional_argument,  NULL, 'H'},
    {"help",        no_argument,        NULL, 'h'},
    {"password-fd", required_argument,  NULL, 'P'},
    {"stdin",       no_argument,        NULL, 's'},
    {"salt",        required_argument,  NULL, 'S'},
    {"rounds",      required_argument,  NULL, 'R'},
    {"version",     no_argument,        NULL, 'V'},
    {NULL,      0,          NULL, 0  }
};
#else
extern char *optarg;
extern int optind;
#endif
​
static const char valid_salts[] = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
​
struct crypt_method {
    const char *method;     /* short name used by the command line option */
    const char *prefix;     /* salt prefix */
    const unsigned int minlen;  /* minimum salt length */
    const unsigned int maxlen;  /* maximum salt length */
    const unsigned int rounds;  /* supports a variable number of rounds */
    const char *desc;       /* long description for the methods list */
};
​
static const struct crypt_method methods[] = {
    /* method       prefix  minlen, maxlen  rounds description */
    { "des",        "", 2,  2,  0,
    N_("standard 56 bit DES-based crypt(3)") },
    { "md5",        "$1$",  8,  8,  0, "MD5" },
#if defined OpenBSD || defined FreeBSD || (defined __SVR4 && defined __sun)
    { "bf",     "$2a$", 22, 22, 1, "Blowfish" },
#endif
#if defined HAVE_LINUX_CRYPT_GENSALT
    { "bf",     "$2a$", 22, 22, 1, "Blowfish, system-specific on 8-bit chars" },
    /* algorithm 2y fixes CVE-2011-2483 */
    { "bfy",        "$2y$", 22, 22, 1, "Blowfish, correct handling of 8-bit chars" },
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.