source: rtems/cpukit/telnetd/check_passwd.c @ cbd1e87

4.104.11
Last change on this file since cbd1e87 was cbd1e87, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Apr 14, 2009 at 8:50:03 AM

adapt copyright statements

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/* $Id$ */
2
3/*
4 * Authorship
5 * ----------
6 * This software was created by
7 *     Till Straumann <strauman@slac.stanford.edu>, 2003-2007
8 *         Stanford Linear Accelerator Center, Stanford University.
9 *
10 * Acknowledgement of sponsorship
11 * ------------------------------
12 * This software was produced by
13 *     the Stanford Linear Accelerator Center, Stanford University,
14 *         under Contract DE-AC03-76SFO0515 with the Department of Energy.
15 *
16 * Government disclaimer of liability
17 * ----------------------------------
18 * Neither the United States nor the United States Department of Energy,
19 * nor any of their employees, makes any warranty, express or implied, or
20 * assumes any legal liability or responsibility for the accuracy,
21 * completeness, or usefulness of any data, apparatus, product, or process
22 * disclosed, or represents that its use would not infringe privately owned
23 * rights.
24 *
25 * Stanford disclaimer of liability
26 * --------------------------------
27 * Stanford University makes no representations or warranties, express or
28 * implied, nor assumes any liability for the use of this software.
29 *
30 * Stanford disclaimer of copyright
31 * --------------------------------
32 * Stanford University, owner of the copyright, hereby disclaims its
33 * copyright and all other rights in this software.  Hence, anyone may
34 * freely use it for any purpose without restriction.
35 *
36 * Maintenance of notices
37 * ----------------------
38 * In the interest of clarity regarding the origin and status of this
39 * SLAC software, this and all the preceding Stanford University notices
40 * are to remain affixed to any copy or derivative of this software made
41 * or distributed by the recipient and are to be affixed to any copy of
42 * software made or distributed by the recipient that contains a copy or
43 * derivative of this software.
44 *
45 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
46 *
47 * Copyright (c) 2009 embedded brains GmbH and others.
48 *
49 * embedded brains GmbH
50 * Obere Lagerstr. 30
51 * D-82178 Puchheim
52 * Germany
53 * <rtems@embedded-brains.de>
54 *
55 * The license and distribution terms for this file may be
56 * found in the file LICENSE in this distribution or at
57 * http://www.rtems.com/license/LICENSE.
58 */
59
60#include <termios.h>
61#include <errno.h>
62#include <stdio.h>
63#include <unistd.h>
64#include <stdlib.h>
65#include <string.h>
66#include <syslog.h>
67
68#include <rtems/telnetd.h>
69
70#include "passwd.h"
71
72char *__des_crypt_r( const char *, const char *, char *, int);
73
74/**
75 * @brief Standard Telnet login check that uses DES to encrypt the passphrase.
76 *
77 * Takes a @a passphrase, encrypts it and compares it to the encrypted
78 * passphrase in the @c TELNETD_PASSWD environment variable.  No password is
79 * required if @c TELNETD_PASSWD is unset.  The argument @a user is ignored.
80 */
81bool rtems_telnetd_login_check(
82  const char *user,
83  const char *passphrase
84)
85{
86  char *pw = getenv( "TELNETD_PASSWD");
87  char cryptbuf [21];
88  char salt [3];
89
90  if (pw == NULL || strlen( pw) == 0) {
91    #ifdef TELNETD_DEFAULT_PASSWD
92      pw = TELNETD_DEFAULT_PASSWD;
93    #else
94      return true;
95    #endif
96  }
97
98  strncpy( salt, pw, 2);
99  salt [2] = '\0';
100
101  return strcmp(
102    __des_crypt_r( passphrase, salt, cryptbuf, sizeof( cryptbuf)),
103    pw
104  ) == 0;
105}
Note: See TracBrowser for help on using the repository browser.