source: rtems/cpukit/telnetd/check_passwd.c @ 2aa8014

4.104.115
Last change on this file since 2aa8014 was cbd1e87, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 04/14/09 at 08:50:03

adapt copyright statements

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[8ad6681b]1/* $Id$ */
2
[8a775c27]3/*
[8ad6681b]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.
[8a775c27]9 *
[8ad6681b]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.
[8a775c27]15 *
[8ad6681b]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.
[8a775c27]24 *
[8ad6681b]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.
[8a775c27]29 *
[8ad6681b]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
[8a775c27]34 * freely use it for any purpose without restriction.
35 *
[8ad6681b]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.
[8a775c27]44 *
[8ad6681b]45 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
[8a775c27]46 *
[cbd1e87]47 * Copyright (c) 2009 embedded brains GmbH and others.
48 *
[8a775c27]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 */
[8ad6681b]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
[8a775c27]68#include <rtems/telnetd.h>
[8ad6681b]69
[8a775c27]70#include "passwd.h"
[8ad6681b]71
[8a775c27]72char *__des_crypt_r( const char *, const char *, char *, int);
[8ad6681b]73
[8a775c27]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)
[8ad6681b]85{
[8a775c27]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
[8ad6681b]96  }
97
[8a775c27]98  strncpy( salt, pw, 2);
99  salt [2] = '\0';
[8ad6681b]100
[8a775c27]101  return strcmp(
102    __des_crypt_r( passphrase, salt, cryptbuf, sizeof( cryptbuf)),
103    pw
104  ) == 0;
[8ad6681b]105}
Note: See TracBrowser for help on using the repository browser.