Skip to content

Commit

Permalink
Add hook environment variables
Browse files Browse the repository at this point in the history
Closes #83
  • Loading branch information
ndilieto committed Dec 29, 2024
1 parent cec7723 commit c564795
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
34 changes: 33 additions & 1 deletion docs/uacme.html
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,38 @@ <h2 id="_environment">ENVIRONMENT</h2>
</div>
</div>
<div class="sect1">
<h2 id="_hook_environment">HOOK ENVIRONMENT</h2>
<div class="sectionbody">
<div class="paragraph"><p>The following environment variables are exported for use by the hook program:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
<strong>UACME_CONFDIR</strong>
</dt>
<dd>
<p>
Path to <em>CONFDIR</em>, see <strong>-c, --confdir</strong>
</p>
</dd>
<dt class="hdlist1">
<strong>UACME_VERBOSE</strong>
</dt>
<dd>
<p>
Verbosity, see <strong>-v, --verbose</strong>
</p>
</dd>
<dt class="hdlist1">
<strong>UACME_METHOD</strong>, <strong>UACME_TYPE</strong>, <strong>UACME_IDENT</strong>, <strong>UACME_TOKEN</strong>, <strong>UACME_AUTH</strong>
</dt>
<dd>
<p>
Copies of the hook program arguments, see <strong>-h, --hook</strong>
</p>
</dd>
</dl></div>
</div>
</div>
<div class="sect1">
<h2 id="_exit_status">EXIT STATUS</h2>
<div class="sectionbody">
<div class="dlist"><dl>
Expand Down Expand Up @@ -1442,7 +1474,7 @@ <h2 id="_copyright">COPYRIGHT</h2>
<div id="footer-text">
Version 1.7.5<br>
Last updated
2024-12-29 11:22:08 CET
2024-12-29 17:04:25 CET
</div>
</div>
</body>
Expand Down
22 changes: 22 additions & 0 deletions uacme.1
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,28 @@ Interface name and IP address or hostname
String holding the proxy hostname or dotted numerical IP address\&. A numerical IPv6 address must be written within [brackets]\&. To specify port number in this string, append :[port] to the end of the host name\&. If not specified, default to using port 1080\&. The proxy string may be prefixed with [scheme]:// to specify which kind of proxy is used (http://, https://, socks4://, socks4a://, socks5://, socks5h://)\&. The proxy can also be specified with its associated credentials like for ordinary URLs in the style:
\fIscheme://username:password@hostname\fR
.RE
.SH "HOOK ENVIRONMENT"
.sp
The following environment variables are exported for use by the hook program:
.PP
\fBUACME_CONFDIR\fR
.RS 4
Path to
\fICONFDIR\fR, see
\fB\-c, \-\-confdir\fR
.RE
.PP
\fBUACME_VERBOSE\fR
.RS 4
Verbosity, see
\fB\-v, \-\-verbose\fR
.RE
.PP
\fBUACME_METHOD\fR, \fBUACME_TYPE\fR, \fBUACME_IDENT\fR, \fBUACME_TOKEN\fR, \fBUACME_AUTH\fR
.RS 4
Copies of the hook program arguments, see
\fB\-h, \-\-hook\fR
.RE
.SH "EXIT STATUS"
.PP
\fB0\fR
Expand Down
14 changes: 14 additions & 0 deletions uacme.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,20 @@ ENVIRONMENT
for ordinary URLs in the style: 'scheme://username:password@hostname'


HOOK ENVIRONMENT
----------------
The following environment variables are exported for use by the hook program:

*UACME_CONFDIR*::
Path to 'CONFDIR', see *-c, --confdir*

*UACME_VERBOSE*::
Verbosity, see *-v, --verbose*

*UACME_METHOD*, *UACME_TYPE*, *UACME_IDENT*, *UACME_TOKEN*, *UACME_AUTH*::
Copies of the hook program arguments, see *-h, --hook*


EXIT STATUS
-----------
*0*::
Expand Down
9 changes: 9 additions & 0 deletions uacme.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ int hook_run(const char *prog, const char *method, const char *type,
else
warnx("hook_run: %s terminated abnormally", prog);
} else { // child
setenv("UACME_METHOD", method, 1);
setenv("UACME_TYPE", type, 1);
setenv("UACME_IDENT", ident, 1);
setenv("UACME_TOKEN", token, 1);
setenv("UACME_AUTH", auth, 1);
if (execl(prog, prog, method, type, ident, token, auth,
(char *)NULL) < 0) {
warn("hook_run: failed to execute %s", prog);
Expand Down Expand Up @@ -1696,6 +1701,10 @@ int main(int argc, char **argv)
} else
msg(1, "version " PACKAGE_VERSION " starting on %s", buf);

snprintf(buf, sizeof(buf), "%d", g_loglevel);
setenv("UACME_VERBOSE", buf, 1);
setenv("UACME_CONFDIR", confdir, 1);

if (a.hook && access(a.hook, R_OK | X_OK) < 0) {
warn("%s", a.hook);
goto out;
Expand Down

0 comments on commit c564795

Please sign in to comment.