]>
Commit | Line | Data |
---|---|---|
189935b1 | 1 | /* |
2 | * IRC - Internet Relay Chat, ircd/ircd_xopen.c | |
3 | * Copyright (C) 1990, 1991 Armin Gruner | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 1, or (at your option) | |
8 | * any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
18 | */ | |
19 | /** | |
20 | * @file | |
21 | * @brief Native crypt() function routines | |
37d25209 | 22 | * @version $Id: ircd_crypt_native.c,v 1.7.2.1 2005/12/14 03:01:38 entrope Exp $ |
189935b1 | 23 | * |
24 | * Routines for handling passwords encrypted with the system's native crypt() | |
25 | * function (typically a DES encryption routine, but can be anything nowadays). | |
26 | * | |
27 | */ | |
37d25209 | 28 | #define _XOPEN_SOURCE 500 |
189935b1 | 29 | |
30 | #include "config.h" | |
31 | #include "ircd_crypt.h" | |
32 | #include "ircd_crypt_native.h" | |
33 | #include "ircd_log.h" | |
34 | #include "s_debug.h" | |
35 | #include "ircd_alloc.h" | |
36 | ||
37 | /* #include <assert.h> -- Now using assert in ircd_log.h */ | |
38 | #include <unistd.h> | |
39 | #ifdef HAVE_CRYPT_H | |
40 | #include <crypt.h> | |
41 | #endif | |
42 | ||
43 | /** Simple routine that just calls crypt() with the supplied password and salt | |
44 | * @param key The password we're encrypting. | |
45 | * @param salt The salt we're using to encrypt key | |
46 | * @return The encrypted password. | |
47 | * | |
48 | * Well this bit is (kinda) intact from the original oper password routines :) | |
49 | * It's a very simple wrapper routine that just calls crypt and returns the | |
50 | * result. | |
51 | * -- hikari | |
52 | */ | |
53 | const char* ircd_crypt_native(const char* key, const char* salt) | |
54 | { | |
55 | assert(NULL != key); | |
56 | assert(NULL != salt); | |
57 | ||
58 | Debug((DEBUG_DEBUG, "ircd_crypt_native: key is %s", key)); | |
59 | Debug((DEBUG_DEBUG, "ircd_crypt_native: salt is %s", salt)); | |
60 | ||
61 | return (const char*)crypt(key, salt); | |
62 | } | |
63 | ||
64 | /* register ourself with the list of crypt mechanisms -- hikari */ | |
65 | void ircd_register_crypt_native(void) | |
66 | { | |
67 | crypt_mech_t* crypt_mech; | |
68 | ||
69 | if ((crypt_mech = (crypt_mech_t*)MyMalloc(sizeof(crypt_mech_t))) == NULL) | |
70 | { | |
71 | Debug((DEBUG_MALLOC, "Could not allocate space for crypt_native")); | |
72 | return; | |
73 | } | |
74 | ||
75 | crypt_mech->mechname = "native"; | |
76 | crypt_mech->shortname = "crypt_native"; | |
77 | crypt_mech->description = "System native crypt() function mechanism."; | |
78 | crypt_mech->crypt_function = &ircd_crypt_native; | |
79 | crypt_mech->crypt_token = "$CRYPT$"; | |
80 | crypt_mech->crypt_token_size = 7; | |
81 | ||
82 | ircd_crypt_register_mech(crypt_mech); | |
83 | ||
84 | return; | |
85 | } |