4.104.115
Rev | Line | |
---|
[2649eef] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @brief Shell login check function. |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | /* |
---|
[cbd1e87] | 8 | * Copyright (c) 2009 embedded brains GmbH and others. |
---|
| 9 | * |
---|
| 10 | * embedded brains GmbH |
---|
[2649eef] | 11 | * Obere Lagerstr. 30 |
---|
| 12 | * D-82178 Puchheim |
---|
| 13 | * Germany |
---|
[cbd1e87] | 14 | * <rtems@embedded-brains.de> |
---|
| 15 | * |
---|
| 16 | * Based on work from Chris Johns and Fernando Ruiz. |
---|
[2649eef] | 17 | * |
---|
[cbd1e87] | 18 | * Derived from file "cpukit/libmisc/shell/shell.c". |
---|
[2649eef] | 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 | |
---|
| 32 | bool 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.