blob: 4efed779ce9e4e4cbc9516842b02ba01df227d35 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/**
* @file
*
* @brief Shell login check function.
*/
/*
* Copyright (c) 2009 embedded brains GmbH and others.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* Based on work from Chris Johns and Fernando Ruiz.
*
* Derived from file "cpukit/libmisc/shell/shell.c".
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#include <string.h>
#include <rtems/shell.h>
#include <rtems/userenv.h>
bool rtems_shell_login_check(
const char *user,
const char *passphrase
)
{
struct passwd *pw = getpwnam( user);
/* Valid user? */
if (pw != NULL && strcmp( pw->pw_passwd, "!") != 0) {
setuid( pw->pw_uid);
setgid( pw->pw_gid);
rtems_current_user_env->euid = 0;
rtems_current_user_env->egid = 0;
chown( rtems_current_shell_env->devname, pw->pw_uid, 0);
rtems_current_user_env->euid = pw->pw_uid;
rtems_current_user_env->egid = pw->pw_gid;
if (strcmp( pw->pw_passwd, "*") == 0) {
/* TODO: /etc/shadow */
return true;
} else {
/* TODO: crypt() */
return true;
}
}
return false;
}
|