source: rtems/cpukit/telnetd/check_passwd.c @ 8a775c27

4.104.115
Last change on this file since 8a775c27 was 8a775c27, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/09 at 13:45:31

2009-03-27 Sebastian Huber <sebastian.huber@…>

  • Makefile.am, preinstall.am, libmisc/Makefile.am, libmisc/shell/shell.c, libmisc/shell/shell.h, telnetd/check_passwd.c, telnetd/telnetd.c, telnetd/telnetd.h: Generalized login check.
  • libmisc/shell/login.h, libmisc/shell/login_check.c, libmisc/shell/login_prompt.c: New files.
  • libmisc/stackchk/check.c: Changed format for blown stack message.
  • libcsupport/src/libio_sockets.c: Removed superfluous cast.
  • libnetworking/rtems/ftpfs.h: Documentation.
  • 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
48 * embedded brains GmbH
49 * Obere Lagerstr. 30
50 * D-82178 Puchheim
51 * Germany
52 * <rtems@embedded-brains.de>
53 *
54 * Modified by Sebastian Huber <sebastian.huber@embedded-brains.de>.
55 *
56 * The license and distribution terms for this file may be
57 * found in the file LICENSE in this distribution or at
58 * http://www.rtems.com/license/LICENSE.
59 */
60
61#include <termios.h>
62#include <errno.h>
63#include <stdio.h>
64#include <unistd.h>
65#include <stdlib.h>
66#include <string.h>
67#include <syslog.h>
68
69#include <rtems/telnetd.h>
70
71#include "passwd.h"
72
73char *__des_crypt_r( const char *, const char *, char *, int);
74
75/**
76 * @brief Standard Telnet login check that uses DES to encrypt the passphrase.
77 *
78 * Takes a @a passphrase, encrypts it and compares it to the encrypted
79 * passphrase in the @c TELNETD_PASSWD environment variable.  No password is
80 * required if @c TELNETD_PASSWD is unset.  The argument @a user is ignored.
81 */
82bool rtems_telnetd_login_check(
83  const char *user,
84  const char *passphrase
85)
86{
87  char *pw = getenv( "TELNETD_PASSWD");
88  char cryptbuf [21];
89  char salt [3];
90
91  if (pw == NULL || strlen( pw) == 0) {
92    #ifdef TELNETD_DEFAULT_PASSWD
93      pw = TELNETD_DEFAULT_PASSWD;
94    #else
95      return true;
96    #endif
97  }
98
99  strncpy( salt, pw, 2);
100  salt [2] = '\0';
101
102  return strcmp(
103    __des_crypt_r( passphrase, salt, cryptbuf, sizeof( cryptbuf)),
104    pw
105  ) == 0;
106}
Note: See TracBrowser for help on using the repository browser.