<div dir="ltr"><div>we used patched version on many workstantions (linux and windows) and found that this feature allows to flexibly and automatically manage the stunnel configuration on the workstations.</div><div><br></div><div>environment variables like $HOME, %USERNAME% and others defined once and never changed, that does not affect stunnel restart and configuration reload.</div><div>but it allows us to have a single configuration for all users.</div><div><br></div><div>the only question that remains: how to use this feature where there is no environment variables (WinCE, which we do not have).</div><div>may by ExpandEnvironmentStringsA stub specifically for WinCE?</div><div>any comments, Pierre?</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-07-07 15:42 GMT+04:00 Dmitry Bakshaev <span dir="ltr"><<a href="mailto:dab1818@gmail.com" target="_blank">dab1818@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-06-01 12:29 GMT+04:00 Pierre Delaage <span dir="ltr"><<a href="mailto:delaage.pierre@free.fr" target="_blank">delaage.pierre@free.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Hello,<br>
    To my mind, admin tasks such as conf file customization, should be
    performed by admin scripts, not app running in admin mode.<br>
    <br>
    With <b>GnuWin32 </b>sed AND echo commands, things are really
    simple :<br>
    <br>
    <b>stunnel.conf :</b><b><br>
    </b>
    <pre>cert = %USERPROFILE%\.config\my.pem (windows)</pre>
    <pre>output = %APPDATA%\stunnel.log (windows)</pre>
    <br>
    <b>script "envsed.bat" on Windows :</b><b><br>
    </b><br>
    <pre>cat stunnel.conf | ^</pre>
    <pre>sed -r -e "s/^(.*)$/C\:\\Progra~2\\<wbr>GnuWin32\\bin\\echo.EXE \1/e" </pre>
    <br>
    every envvar "à la windows" is expanded ....<br>
    Will work the same in Linux.<br></div></blockquote><div><br></div><div>yes. this is primary goal of this patch - do not edit (manually or with sed) config file for each user.<br></div><div>if user added/removed, if port/host changed, etc.<br></div><div>admin mantains only one config that fit all users.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
    <br>
    If we really modify stunnel to do that job, I recommend to (try to)
    use stubs for WCE trying to keep one main code, and keeping an
    acceptable behavior in WCE,<br>
    instead of playing with #if WCE #else etc ...<br></div></blockquote><div><br>I am not familiar with the Windows CE,<br>first and last time when seen the WinCE-device - the beginning of the 2000s.<br><br>point into the right direction if you know.<br></div><div>win32 has native ExpandEnvironmentStringsA() function,<br></div><div>on other platform used stub/wrapper around getvar() function (#ifndef USE_WIN32).<br></div><div>WinCE do not has ExpandEnvironmentStringsA() or getvar(), besause do not has environment variables.<br></div><div>#ifndef _WIN32_WCE - simple way to not execute unnecessary code at all,<br></div><div>but attached patch version has ExpandEnvironmentStringsA stub for WinCE, please review it.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
    <br>
    Another way to proceed is that stunnel recognizes a very small set
    of "pseudo-envvars", like eg we can find in samba conf files,<br>
    such as, eg, %u for current user home folder, and that it expands
    (or "translate") internally with its own logic (of course using
    system calls if needed),<br>
    but in any case, stunnel has to do some work for tokenization,
    something that I think dangerous :<br>
    it would not be good that stunnel expands ANY envvar, known or
    UNKNOWN, without being able to predict the effects on its execution.<br></div></blockquote><div><br></div><div>environment variables values owned by user. only owner or admin cat change it, not any-other user.<br></div><div>starting process with admin/system/current_user privileges process <span lang="en"><span>inherits </span></span>admin/system/current_user envvars values.<br>stunnel not expands ANY or UNKNOWN envvars - only those that admin will specified in config file.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
    Moreover, envars can be modified on the fly in an unpredictable way:
    what if stunnel reloads the conf after an envvar change ?<br>
    if it even does NOT detect the change, there may be issues ...and if
    it detects the change and reloads, there may be other issues...<br>
    <br></div></blockquote><div>if running process not modify envvars by himself ExpandEnvironmentStrings/<wbr>getvar expands to values taken on process start.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
    Anyway, for the purpose of having multiple stunnel processes,
    running in user space, started from USER command line, it does not
    appear clear to me why an admin should create the USER conf
    files...the USER should be aware of what is he/she doing with
    stunnel?<br></div></blockquote><div>admin manages stunnel and applications configuration on server and client side: hosts, ports, other stunnel options.<br></div><div>user has own private certificate used with stunnel and works with applications through stunnel.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
    and it is not clear why and HOW multiple users, logged-on on the
    ?same? machine, each working in USER SPACE, should run stunnel
    simultaneously ...<br></div></blockquote><div>not necessary simultaneously - stunnel may use same ports on localhost for all users (from one global config).<br></div><div>users alternately starts his own stunnel process with own certificate (path expanded from one global config).<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
    <br>
    Question is also : if stunnel is running as a service, how will it
    deal with conf file containing ENVVARS, and what interest for this
    as system-wide stunnel just need one unique conf file.<br></div><br></blockquote></div>on server or client side?<br>for example on server with miltiple stunnel instances for create predictable log files names (without manually editing):<br>output = /var/log/stunnel/stunnel_${<wbr>SVCNAME}.log<br></div></div>
</blockquote></div><br></div>