On Wed, Apr 6, 2011 at 7:10 PM, David Sommerseth <dav...@redhat.com> wrote:
> In commit 4e1cc5f6dda22e9 the create_temp_filename() function was
> reviewed and hardened, which in the end renamed this function to
> create_temp_file() in commit 495e3cec5d156.
>
> With these changes it became more evident that OpenVPN needs a directory
> where it can create temporary files.  The create_temp_file() will create
> such files f.ex. if --client-connect or --plugin which makes use of
> the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY hook, such as openvpn-auth-pam.so.
>
> When this happens, OpenVPN will normally create these files in the directory
> OpenVPN was started.  In many cases, this will fail due to restricted access.
> By using --tmp-dir and pointing it to a directory writeable to the user
> running OpenVPN, it works again.
>
> This patch makes OpenVPN use a more suitable temproary directory by default,
> instead of the current working directory.  On non-Windows platforms this
> default value is set to '/tmp', but can be modified at compile-time by
> running ./configure --with-tmp-dir-path=<TEMP DIR PATH>.  On Windows, it
> will look up %TEMP% and %TMP% first, and if that doesn't give any clues, it
> will fallback to C:\WINDOWS\Temp in the end.

I don't understand,
if you use windows environment variables, then why not do the same on Unix?
You have the standard TMPDIR [1] variable, and fallback to /tmp.

Also, at Windows you should go into %SystemRoot%\Temp using
ExpandEnvironmentVariable() and not hardcode C:\

And if you have a sane fallback ot system location, why you need to
add a compile time option to override?

[1] http://en.wikipedia.org/wiki/TMPDIR

> +AC_ARG_WITH(tmp-dir-path,
> +   [  --with-tmp-dir-path=PATH  Default tmp-dir to use when not configured 
> (unset defaults to /tmp)],
> +   [TMPDIRPATH="$withval"]
> +)
> +

<snip>

> +dnl set the default temporary directory
> +if test -z "$TMPDIRPATH"; then
> +   TMPDIRPATH="/tmp"
> +fi
> +AC_DEFINE_UNQUOTED(DEFAULT_TMPDIR, "$TMPDIRPATH", [Default --tmp-dir])
> +

Both should be something like:
---
AC_ARG_WITH(
   [tmp-dir-path],
   [AS_HELP_STRING([--with-tmp-dir-path=PATH], [Default tmp-dir to use
when not configured (unset defaults to /tmp)])],
   [TMPDIRPATH="$withval"],
   [
      case "${host}" in
         *-mingw*) TMPDIRPATH="%SystemRoot%/Temp" ;;
         *) TMPDIRPATH="/tmp" ;;
      esac
)
AC_DEFINE_UNQUOTED([DEFAULT_TMPDIR], [${TMPDIRPATH}], [Default --tmp-dir])
---

Alon.

Reply via email to