source: rtems/cpukit/libmisc/shell/login_check.c @ cbd1e87

4.104.115
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: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Shell login check function.
5 */
6
7/*
8 * Copyright (c) 2009 embedded brains GmbH and others.
9 *
10 * embedded brains GmbH
11 * Obere Lagerstr. 30
12 * D-82178 Puchheim
13 * Germany
14 * <rtems@embedded-brains.de>
15 *
16 * Based on work from Chris Johns and Fernando Ruiz.
17 *
18 * Derived from file "cpukit/libmisc/shell/shell.c".
19 *
20 * The license and distribution terms for this file may be
21 * found in the file LICENSE in this distribution or at
22 * http://www.rtems.com/license/LICENSE.
23 */
24
25#include <sys/types.h>
26#include <unistd.h>
27#include <pwd.h>
28
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.