4.104.115
Last change
on this file since 9a77af8 was
9a77af8,
checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/26/10 at 17:18:43
|
Add HAVE_CONFIG_H support to let files receive configure defines.
|
-
Property mode set to
100644
|
File size:
1.3 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 | #ifdef HAVE_CONFIG_H |
---|
26 | #include "config.h" |
---|
27 | #endif |
---|
28 | |
---|
29 | #include <sys/types.h> |
---|
30 | #include <unistd.h> |
---|
31 | #include <pwd.h> |
---|
32 | |
---|
33 | #include <rtems/shell.h> |
---|
34 | #include <rtems/userenv.h> |
---|
35 | |
---|
36 | bool rtems_shell_login_check( |
---|
37 | const char *user, |
---|
38 | const char *passphrase |
---|
39 | ) |
---|
40 | { |
---|
41 | struct passwd *pw = getpwnam( user); |
---|
42 | |
---|
43 | /* Valid user? */ |
---|
44 | if (pw != NULL && strcmp( pw->pw_passwd, "!") != 0) { |
---|
45 | setuid( pw->pw_uid); |
---|
46 | setgid( pw->pw_gid); |
---|
47 | rtems_current_user_env->euid = 0; |
---|
48 | rtems_current_user_env->egid = 0; |
---|
49 | chown( rtems_current_shell_env->devname, pw->pw_uid, 0); |
---|
50 | rtems_current_user_env->euid = pw->pw_uid; |
---|
51 | rtems_current_user_env->egid = pw->pw_gid; |
---|
52 | if (strcmp( pw->pw_passwd, "*") == 0) { |
---|
53 | /* TODO: /etc/shadow */ |
---|
54 | return true; |
---|
55 | } else { |
---|
56 | /* TODO: crypt() */ |
---|
57 | return true; |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | return false; |
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.