summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Poole <netstar@gmail.com>2016-09-08 10:06:51 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-09-08 10:18:10 -0400
commitfddcaa43c43c14a9510fd198accb71389985bd96 (patch)
tree5407e0c4be408ee4a1fd521276b23b174cdbf589
parentadfa905e095c8a6657c991f94a833c302ea8443e (diff)
OpenBSD non-PAM lokker authentication.
Reviewers: ManMower, zmike! Subscribers: raster, ManMower, cedric Differential Revision: https://phab.enlightenment.org/D4204
-rw-r--r--src/bin/e_auth.c39
-rw-r--r--src/bin/e_desklock.c2
-rw-r--r--src/bin/e_sys_main.c59
3 files changed, 97 insertions, 3 deletions
diff --git a/src/bin/e_auth.c b/src/bin/e_auth.c
index 78d171c2f..9754ce2d9 100644
--- a/src/bin/e_auth.c
+++ b/src/bin/e_auth.c
@@ -1,6 +1,6 @@
1#include "e.h" 1#include "e.h"
2 2
3#if defined(HAVE_PAM) && !defined(__FreeBSD__) 3#if defined(HAVE_PAM) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
4# include <security/pam_appl.h> 4# include <security/pam_appl.h>
5# include <pwd.h> 5# include <pwd.h>
6 6
@@ -128,7 +128,7 @@ _auth_pam_init(E_Auth *da)
128 free(current_host); 128 free(current_host);
129 return 0; 129 return 0;
130} 130}
131#endif // HAVE_PAM && !__FreeBSD__ 131#endif // HAVE_PAM && !__FreeBSD__ && !_OpenBSD__
132 132
133E_API int 133E_API int
134#if defined(__FreeBSD__) 134#if defined(__FreeBSD__)
@@ -165,6 +165,41 @@ out:
165 165
166 return ret; 166 return ret;
167} 167}
168#elif defined(__OpenBSD__)
169e_auth_begin(char *passwd)
170{
171 char exe_path[PATH_MAX], *p;
172 Ecore_Exe *exe = NULL;
173 int ret = 0;
174 int len = strlen(passwd);
175
176 if (len == 0) goto out;
177
178 snprintf(exe_path, sizeof(exe_path), "%s/enlightenment/utils/enlightenment_sys -z",
179 e_prefix_lib_get());
180
181 exe = ecore_exe_pipe_run(exe_path, ECORE_EXE_PIPE_WRITE, NULL);
182 if (!exe) goto out;
183 if (ecore_exe_send(exe, passwd, len) != EINA_TRUE) goto out;
184 if (ecore_exe_send(exe, "\n", 1) != EINA_TRUE) goto out;
185 ecore_exe_close_stdin(exe);
186
187 ret = ecore_exe_pid_get(exe);
188 if (ret == -1)
189 {
190 ret = 0;
191 goto out;
192 }
193
194 exe = NULL;
195out:
196 if (exe) ecore_exe_free(exe);
197
198 for (p = passwd; *p; p++)
199 *p = 0;
200
201 return ret;
202}
168#elif defined(HAVE_PAM) 203#elif defined(HAVE_PAM)
169e_auth_begin(char *passwd) 204e_auth_begin(char *passwd)
170{ 205{
diff --git a/src/bin/e_desklock.c b/src/bin/e_desklock.c
index d29183528..7b2a767ed 100644
--- a/src/bin/e_desklock.c
+++ b/src/bin/e_desklock.c
@@ -259,7 +259,7 @@ e_desklock_show(Eina_Bool suspend)
259 return 1; 259 return 1;
260 } 260 }
261 261
262#ifndef HAVE_PAM 262#if ! defined(HAVE_PAM) && ! defined(__OpenBSD__)
263 if (e_desklock_is_system()) 263 if (e_desklock_is_system())
264 { 264 {
265 e_util_dialog_show(_("Error - no PAM support"), 265 e_util_dialog_show(_("Error - no PAM support"),
diff --git a/src/bin/e_sys_main.c b/src/bin/e_sys_main.c
index 79f30efb3..54c60b9c3 100644
--- a/src/bin/e_sys_main.c
+++ b/src/bin/e_sys_main.c
@@ -49,6 +49,56 @@ static int auth_etc_enlightenment_sysactions(char *a,
49static void auth_etc_enlightenment_sysactions_perm(char *path); 49static void auth_etc_enlightenment_sysactions_perm(char *path);
50static char *get_word(char *s, 50static char *get_word(char *s,
51 char *d); 51 char *d);
52#if defined(__OpenBSD__)
53
54static void
55_exit_backoff(void)
56{
57 sleep(3);
58 exit(1 << 7);
59}
60
61static int
62_check_auth(const char *guess)
63{
64 struct passwd *pw_ent;
65 uid_t uid = getuid();
66
67 pw_ent = getpwuid_shadow(uid);
68 if (!pw_ent)
69 _exit_backoff();
70
71 return crypt_checkpass(guess, pw_ent->pw_passwd);
72}
73
74static int
75auth_generic_enlightenment_desklock(void)
76{
77 char buf[4096];
78 char byte[1];
79 int res = -1;
80 int i = 0;
81
82 while (read(STDIN_FILENO, byte, sizeof(byte)) > 0)
83 {
84 if (byte[0] == '\n') break;
85 buf[i++] = byte[0];
86 if (i == sizeof(buf) -1) break;
87 }
88
89 buf[i] = '\0';
90
91 if (!i)
92 _exit_backoff();
93
94 res = _check_auth(buf);
95
96 if (res) _exit_backoff();
97
98 return res;
99}
100
101#endif
52 102
53/* local subsystem globals */ 103/* local subsystem globals */
54static Eina_Hash *actions = NULL; 104static Eina_Hash *actions = NULL;
@@ -82,6 +132,15 @@ main(int argc,
82 exit(0); 132 exit(0);
83 } 133 }
84 } 134 }
135#if defined(__OpenBSD__)
136 if (argc >= 2)
137 {
138 if (!strcmp(argv[1], "-z"))
139 {
140 exit(auth_generic_enlightenment_desklock());
141 }
142 }
143#endif
85 if (argc >= 3) 144 if (argc >= 3)
86 { 145 {
87 if ((argc == 3) && (!strcmp(argv[1], "-t"))) 146 if ((argc == 3) && (!strcmp(argv[1], "-t")))