From a93761f06eb75fcfaca85582bfb2d1def609ae6d Mon Sep 17 00:00:00 2001
From: Dante Catalfamo
Date: Sun, 30 May 2021 16:28:04 -0400
Subject: bsd-auth: add more funcs
---
 .../WIP-how-bsd-authentication-works/index.org     | 73 ++++++++++++++++++++--
 1 file changed, 68 insertions(+), 5 deletions(-)
(limited to 'content/posts/WIP-how-bsd-authentication-works')
diff --git a/content/posts/WIP-how-bsd-authentication-works/index.org b/content/posts/WIP-how-bsd-authentication-works/index.org
index 70fc635..60d84b8 100644
--- a/content/posts/WIP-how-bsd-authentication-works/index.org
+++ b/content/posts/WIP-how-bsd-authentication-works/index.org
@@ -52,11 +52,8 @@
   :CUSTOM_ID: why
   :END:
 
-  This one is pretty difficult, since there seems to be very little
-  information about how BSD Auth works apart from the source code
-  itself and the man pages, which intentionally keep the internals
-  opaque. This is my best attempt to understand and describe the flow
-  of BSD Auth.
+  I was curious about how the internals of BSD Auth worked, and I
+  figured someone else might be too :-).
 
 * Documentation
   :PROPERTIES:
@@ -673,6 +670,72 @@
    =BI_UNSETENV= from =as->spool=. This is explained under the
    =auth_call= section.
 
+** auth_clroption
+   :PROPERTIES:
+   :CUSTOM_ID: auth_clroption
+   :END:
+
+   @@html:   @@
+   #+begin_src c
+   void auth_clroption(auth_session_t *as, char *option)
+   #+end_src
+   @@html: 
 @@
+   #+begin_src c
+   {
+       struct authopts *opt, *oopt;
+       size_t len;
+
+       len = strlen(option);
+
+       if ((opt = as->optlist) == NULL)
+           return;
+
+       if (strncmp(opt->opt, option, len) == 0 &&
+           (opt->opt[len] == '=' || opt->opt[len] == '\0')) {
+           as->optlist = opt->next;
+           free(opt);
+           return;
+       }
+
+       while ((oopt = opt->next) != NULL) {
+           if (strncmp(oopt->opt, option, len) == 0 &&
+               (oopt->opt[len] == '=' || oopt->opt[len] == '\0')) {
+               opt->next = oopt->next;
+               free(oopt);
+               return;
+           }
+           opt = oopt;
+       }
+   }
+   #+end_src
+   @@html:   @@
+
+   =auth_clroption= removes the option named =option= from =as=.
+
+** auth_clroptions
+   :PROPERTIES:
+   :CUSTOM_ID: auth_clroptions
+   :END:
+
+   @@html:   @@
+   #+begin_src c
+   void auth_clroptions(auth_session_t *as)
+   #+end_src
+   @@html: 
 @@
+   #+begin_src c
+   {
+       struct authopts *opt;
+
+       while ((opt = as->optlist) != NULL) {
+           as->optlist = opt->next;
+           free(opt);
+       }
+   }
+   #+end_src
+   @@html:   @@
+
+   =auth_clroptions= clears all options from =as=.
+
 ** auth_setenv
    :PROPERTIES:
    :CUSTOM_ID: auth_setenv
-- 
cgit v1.2.3