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

4.104.115
Last change on this file since ddeb7730 was ddeb7730, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/10 at 15:08:04

2010-03-27 Joel Sherrill <joel.sherrill@…>

  • libgnat/ada_intrsupp.c, telnetd/check_passwd.c, telnetd/des.c, telnetd/genpw.c: Add include of config.h
  • 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#ifdef HAVE_CONFIG_H
61#include "config.h"
62#endif
63
64#include <termios.h>
65#include <errno.h>
66#include <stdio.h>
67#include <unistd.h>
68#include <stdlib.h>
69#include <string.h>
70#include <syslog.h>
71
72#include <rtems/telnetd.h>
73
74#include "passwd.h"
75
76char *__des_crypt_r( const char *, const char *, char *, int);
77
78/**
79 * @brief Standard Telnet login check that uses DES to encrypt the passphrase.
80 *
81 * Takes a @a passphrase, encrypts it and compares it to the encrypted
82 * passphrase in the @c TELNETD_PASSWD environment variable.  No password is
83 * required if @c TELNETD_PASSWD is unset.  The argument @a user is ignored.
84 */
85bool rtems_telnetd_login_check(
86  const char *user,
87  const char *passphrase
88)
89{
90  char *pw = getenv( "TELNETD_PASSWD");
91  char cryptbuf [21];
92  char salt [3];
93
94  if (pw == NULL || strlen( pw) == 0) {
95    #ifdef TELNETD_DEFAULT_PASSWD
96      pw = TELNETD_DEFAULT_PASSWD;
97    #else
98      return true;
99    #endif
100  }
101
102  strncpy( salt, pw, 2);
103  salt [2] = '\0';
104
105  return strcmp(
106    __des_crypt_r( passphrase, salt, cryptbuf, sizeof( cryptbuf)),
107    pw
108  ) == 0;
109}
Note: See TracBrowser for help on using the repository browser.