From 118b0019658890837ab8e19608ce0779cb6f4d9a Mon Sep 17 00:00:00 2001 From: Dante Catalfamo Date: Tue, 7 Jul 2020 22:28:28 -0400 Subject: Move WIP posts to WIP folders --- .../WIP-how-bsd-authentication-works/graph.dot | 67 +++ .../WIP-how-bsd-authentication-works/index.org | 473 +++++++++++++++++++++ 2 files changed, 540 insertions(+) create mode 100644 content/posts/WIP-how-bsd-authentication-works/graph.dot create mode 100644 content/posts/WIP-how-bsd-authentication-works/index.org (limited to 'content/posts/WIP-how-bsd-authentication-works') diff --git a/content/posts/WIP-how-bsd-authentication-works/graph.dot b/content/posts/WIP-how-bsd-authentication-works/graph.dot new file mode 100644 index 0000000..6414b11 --- /dev/null +++ b/content/posts/WIP-how-bsd-authentication-works/graph.dot @@ -0,0 +1,67 @@ +digraph G { + subgraph cluster_authenticate { + label = "authenticate.c" + auth_userokay; + auth_usercheck; + auth_verify; + } + + subgraph cluster_auth_subr { + label = "auth_subr.c" + auth_open; + auth_call; + auth_close; + // auth_setitem; + // auth_setdata; + // auth_setopts; + auth_set[label="auth_set*"]; + auth_setstate; + // _auth_spool; + } + + subgraph cluster_login_cap { + label = "libc/login_cap.c" + login_getclass + login_getstyle + } + + subgraph cluster_getpwent { + label = "libc/getpwent.c" + getpwnam_r; + } + + subgraph cluster_exec { + login[label="login_*"]; + execve; + } + + + start -> auth_userokay; + auth_userokay -> auth_usercheck; + auth_usercheck -> getpwnam_r; + auth_usercheck -> login_getclass; + auth_usercheck -> login_getstyle; + // if password given + auth_usercheck -> auth_open; + // auth_usercheck -> auth_setitem; + // auth_usercheck -> auth_setdata; + auth_usercheck -> auth_set; + // fi + auth_usercheck -> auth_verify; + + auth_verify -> auth_setstate; + auth_verify -> auth_call; + + auth_call -> execve[label="fork()"]; + // auth_call -> _auth_spool; + + execve -> login; + login -> auth_call[label="back channel"]; + // login -> _auth_spool[label="back channel"]; + + + // auth_usercheck -> { auth_setitem auth_setdata auth_setopts } + + // auth_call -> auth_userokay; + auth_userokay -> auth_close; +} diff --git a/content/posts/WIP-how-bsd-authentication-works/index.org b/content/posts/WIP-how-bsd-authentication-works/index.org new file mode 100644 index 0000000..4126284 --- /dev/null +++ b/content/posts/WIP-how-bsd-authentication-works/index.org @@ -0,0 +1,473 @@ +#+TITLE: How BSD Authentication Works +#+DATE: 2020-06-26T18:31:36-04:00 +#+DRAFT: true +#+DESCRIPTION: +#+TAGS[]: openbsd +#+KEYWORDS[]: openbsd +#+SLUG: +#+SUMMARY: +#+SHOWTOC: true + +[[https://web.archive.org/web/20170327150148/http://www.penzin.net/bsdauth/]] +* History + + OpenBSD is quite different from many other Unix-like operating systems + in many ways, but one way which I find interesting is the + authentication system. Most systems from AIX, Solaris, and Linux to + most BSDs including MacOS use some form of a system called Pluggable + Authentication Module (PAM). The two main implementations of PAM are + [[http://www.linux-pam.org/][Linux PAM]] and [[https://www.openpam.org/][OpenPAM]]. PAM modules are created a dynamically loaded + shared objects, which communicate using a set of standard + interfaces ([[https://linux.die.net/man/3/pam][Linux-PAM]] and [[https://www.freebsd.org/cgi/man.cgi?query=pam&apropos=0&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html][OpenPAM]]). PAM is configured using the [[https://linux.die.net/man/5/pam.d][pam.d]] + directory and [[https://www.freebsd.org/cgi/man.cgi?query=pam.conf&sektion=5&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports][pam.conf]]. + + OpenBSD on the other hand uses a mechanism called BSD + Authentication. It was originally developed for a proprietary + operating system called [[https://en.wikipedia.org/wiki/BSD/OS][BSD/OS]] by [[https://en.wikipedia.org/wiki/Berkeley_Software_Design][Berkeley Software Design Inc.]], who + later donated the system. It was adopted by OpenBSD in release + 2.9. BSD Auth is comparatively much simpler than PAM. Modules or, + authentication "styles", are instead stand alone applications or + scripts that communicate over IPC (=PF_LOCAL, SOCK_STREAM=, + specifically). The program or script has no ability to interfere + with the parent and can very easily revoke permissions using + [[https://man.openbsd.org/pledge][=pledge(2)=]] or [[https://man.openbsd.org/unveil][=unveil(2)=]]. The BSD Authentication system of + configured through [[https://man.openbsd.org/login.conf][=login.conf(5)=]]. + +* Why + + This one is pretty difficult, since there seems to be very little + information about how BSD Auth works apart from the source code + itself. This is my best attempt to understand the flow of BSD Auth + from what I've read. + +* BSD Auth Modules + + These programs or scripts are located in =/usr/libexec/auth/= with the + naming convention =login_