Annotation of /trunk/mkinitrd-magellan/busybox/libbb/pw_encrypt.c
Parent Directory | Revision Log
Revision 532 -
(hide annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 751 byte(s)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 751 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | niro | 532 | /* vi: set sw=4 ts=4: */ |
2 | /* | ||
3 | * Utility routine. | ||
4 | * | ||
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | ||
6 | * | ||
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
8 | */ | ||
9 | |||
10 | #include "libbb.h" | ||
11 | #include <crypt.h> | ||
12 | |||
13 | char *pw_encrypt(const char *clear, const char *salt) | ||
14 | { | ||
15 | static char cipher[128]; | ||
16 | char *cp; | ||
17 | |||
18 | #if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */ | ||
19 | if (strncmp(salt, "$2$", 3) == 0) { | ||
20 | return sha1_crypt(clear); | ||
21 | } | ||
22 | #endif | ||
23 | cp = (char *) crypt(clear, salt); | ||
24 | /* if crypt (a nonstandard crypt) returns a string too large, | ||
25 | truncate it so we don't overrun buffers and hope there is | ||
26 | enough security in what's left */ | ||
27 | safe_strncpy(cipher, cp, sizeof(cipher)); | ||
28 | return cipher; | ||
29 | } |