diff options
Diffstat (limited to 'content/posts/WIP-how-bsd-authentication-works/index.org')
-rw-r--r-- | content/posts/WIP-how-bsd-authentication-works/index.org | 78 |
1 files changed, 71 insertions, 7 deletions
diff --git a/content/posts/WIP-how-bsd-authentication-works/index.org b/content/posts/WIP-how-bsd-authentication-works/index.org index 6c211a9..9fd5fdd 100644 --- a/content/posts/WIP-how-bsd-authentication-works/index.org +++ b/content/posts/WIP-how-bsd-authentication-works/index.org @@ -424,11 +424,14 @@ @@html: </details> @@ [[https://man.openbsd.org/auth_subr.3#auth_setitem][=auth_setitem=]] is used to set one of several different fields of - =as= to =value=. Depending on the value of =item=, it can be the - =challenge=, =class=, =name=, =service=, =style=, or =interactive= - field. If =value= is =NULL=, it clears that field. If =item= is - =AUTHV_ALL= and =value= is =NULL=, all fields are cleared. It - returns =0= on success. + =as= to =value=. Depending on the value of =item= ([[#auth_item_t][=auth_item_t=]]), it + can be the =challenge=, =class=, =name=, =service=, =style=, or + =interactive= field. If =value= is =NULL=, it clears that field. If + =item= is =AUTHV_ALL= and =value= is =NULL=, all fields are + cleared. It returns =0= on success. + + *Note*: As of writing, the man page displays the incorrect name for + the constants. #+CAPTION: Taken from [[https://man.openbsd.org/auth_subr.3#auth_getitem][=auth_subr(3)=]] #+begin_src text @@ -672,7 +675,7 @@ #+end_src @@html: </details> @@ - [[https://man.openbsd.org/auth_subr.3#auth_set_va_list][=auth_set_va_list=]] copies =ap= to the =ap= field in =as= + [[https://man.openbsd.org/auth_subr.3#auth_set_va_list][=auth_set_va_list=]] copies =ap= to =as->ap=. ** auth_clrenv :PROPERTIES: @@ -932,7 +935,7 @@ escape sequences in the value, and returns the newly created string. - For convenience, the function [[https://man.openbsd.org/man3/authenticate.3#auth_mkvalue][=auth_mkvalue(3)=]] can be used inside + For convenience, the function [[#auth_mkvalue][=auth_mkvalue=]] can be used inside of the authentication module to create and return appropriately escaped value strings. @@ -2525,6 +2528,67 @@ [[https://man.openbsd.org/man3/authenticate.3#auth_cat][=auth_cat=]] is a helper function that will write the contents of a =file= to =stdout=. It returns =0= on failure or =1= on success. +* auth_mkvalue + :PROPERTIES: + :CUSTOM_ID: auth_mkvalue + :END: + + @@html: <details> <summary> @@ + #+begin_src c + char *auth_mkvalue(char *value) + #+end_src + + @@html: </summary> @@ + #+begin_src c + { + char *big, *p; + + big = malloc(strlen(value) * 4 + 1); + if (big == NULL) + return (NULL); + /* + ,* XXX - There should be a more standardized + ,* routine for doing this sort of thing. + ,*/ + for (p = big; *value; ++value) { + switch (*value) { + case '\r': + ,*p++ = '\\'; + ,*p++ = 'r'; + break; + case '\n': + ,*p++ = '\\'; + ,*p++ = 'n'; + break; + case '\\': + ,*p++ = '\\'; + ,*p++ = *value; + break; + case '\t': + case ' ': + if (p == big) + ,*p++ = '\\'; + ,*p++ = *value; + break; + default: + if (!isprint((unsigned char)*value)) { + ,*p++ = '\\'; + ,*p++ = ((*value >> 6) & 0x3) + '0'; + ,*p++ = ((*value >> 3) & 0x7) + '0'; + ,*p++ = ((*value ) & 0x7) + '0'; + } else + ,*p++ = *value; + break; + } + } + ,*p = '\0'; + return (big); + } + #+end_src + @@html: </details> @@ + + [[https://man.openbsd.org/authenticate.3#auth_mkvalue][=auth_mkvalue=]] creates an escaped string which can be decoded by [[#auth_getvalue][=auth_getvalue=]]. + * _auth_validuser :PROPERTIES: :CUSTOM_ID: _auth_validuser |