source: rtems/cpukit/libmisc/shell/login_check.c @ 2649eef

4.104.11
Last change on this file since 2649eef was 2649eef, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 27, 2009 at 3:31:52 PM

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: 1.3 KB
Line 
1/**
2 * @file
3 *
4 * @author Sebastian Huber <sebastian.huber@embedded-brains.de>
5 *
6 * @brief Shell login check function.
7 */
8
9/*
10 * Copyright (c) 2009
11 * Embedded Brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * rtems@embedded-brains.de
16 *
17 * Based on work from Chris Johns, Fernando Ruiz and Till Straumann.
18 *
19 * The license and distribution terms for this file may be
20 * found in the file LICENSE in this distribution or at
21 * http://www.rtems.com/license/LICENSE.
22 */
23
24#include <sys/types.h>
25#include <unistd.h>
26#include <pwd.h>
27
28#include <rtems/login.h>
29#include <rtems/shell.h>
30#include <rtems/userenv.h>
31
32bool rtems_shell_login_check(
33  const char *user,
34  const char *passphrase
35)
36{
37  struct passwd *pw = getpwnam( user);
38
39  /* Valid user? */
40  if (pw != NULL && strcmp( pw->pw_passwd, "!") != 0) {
41    setuid( pw->pw_uid);
42    setgid( pw->pw_gid);
43    rtems_current_user_env->euid = 0;
44    rtems_current_user_env->egid = 0;
45    chown( rtems_current_shell_env->devname, pw->pw_uid, 0);
46    rtems_current_user_env->euid = pw->pw_uid;
47    rtems_current_user_env->egid = pw->pw_gid;
48    if (strcmp( pw->pw_passwd, "*") == 0) {
49      /* TODO: /etc/shadow */
50      return true;
51    } else {
52      /* TODO: crypt() */
53      return true;
54    }
55  }
56
57  return false;
58}
Note: See TracBrowser for help on using the repository browser.