summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell/login_check.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-03-27 15:31:52 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-03-27 15:31:52 +0000
commit2649eef33ab4947ad690a90e381056e285d46635 (patch)
treeb6332f7070186571127312c36f155cc3ea405b1c /cpukit/libmisc/shell/login_check.c
parent2009-03-27 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-2649eef33ab4947ad690a90e381056e285d46635.tar.bz2
2009-03-27 Sebastian Huber <sebastian.huber@embedded-brains.de>
* 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.
Diffstat (limited to 'cpukit/libmisc/shell/login_check.c')
-rw-r--r--cpukit/libmisc/shell/login_check.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/cpukit/libmisc/shell/login_check.c b/cpukit/libmisc/shell/login_check.c
new file mode 100644
index 0000000000..066ab16b61
--- /dev/null
+++ b/cpukit/libmisc/shell/login_check.c
@@ -0,0 +1,58 @@
+/**
+ * @file
+ *
+ * @author Sebastian Huber <sebastian.huber@embedded-brains.de>
+ *
+ * @brief Shell login check function.
+ */
+
+/*
+ * Copyright (c) 2009
+ * Embedded Brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * rtems@embedded-brains.de
+ *
+ * Based on work from Chris Johns, Fernando Ruiz and Till Straumann.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <pwd.h>
+
+#include <rtems/login.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;
+}