Browse code

Only use tmpdir if tmp_dir is really used.

This fixes starting openvpn compiled as client only version of systems
that have no /tmp (Android). --tmp-dir could only be set if P2MP_SERVER
has been enabled too.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: 1340044749-10694-2-git-send-email-arne@rfc2549.org
URL: http://article.gmane.org/gmane.network.openvpn.devel/6741
Signed-off-by: David Sommerseth <davids@redhat.com>

Arne Schwabe authored on 2012/06/19 03:39:04
Showing 2 changed files
... ...
@@ -858,6 +858,8 @@ init_options (struct options *o, const bool init_gc)
858 858
   o->pkcs11_pin_cache_period = -1;
859 859
 #endif			/* ENABLE_PKCS11 */
860 860
 
861
+/* tmp is only used in P2MP server context */
862
+#if P2MP_SERVER
861 863
   /* Set default --tmp-dir */
862 864
 #ifdef WIN32
863 865
   /* On Windows, find temp dir via enviroment variables */
... ...
@@ -869,6 +871,7 @@ init_options (struct options *o, const bool init_gc)
869 869
           o->tmp_dir = "/tmp";
870 870
   }
871 871
 #endif /* WIN32 */
872
+#endif /* P2MP_SERVER */
872 873
 }
873 874
 
874 875
 void
... ...
@@ -2766,8 +2769,6 @@ options_postprocess_filechecks (struct options *options)
2766 2766
                              R_OK|X_OK, "--chroot directory");
2767 2767
   errs |= check_file_access (CHKACC_DIRPATH|CHKACC_FILEXSTWR, options->writepid,
2768 2768
                              R_OK|W_OK, "--writepid");
2769
-  errs |= check_file_access (CHKACC_FILE, options->tmp_dir,
2770
-                             R_OK|W_OK|X_OK, "Temporary directory (--tmp-dir)");
2771 2769
 
2772 2770
   /* ** Log related ** */
2773 2771
   errs |= check_file_access (CHKACC_DIRPATH|CHKACC_FILEXSTWR, options->status_file,
... ...
@@ -2781,6 +2782,8 @@ options_postprocess_filechecks (struct options *options)
2781 2781
 #if P2MP_SERVER
2782 2782
   errs |= check_file_access (CHKACC_FILE, options->client_config_dir,
2783 2783
                              R_OK|X_OK, "--client-config-dir");
2784
+  errs |= check_file_access (CHKACC_FILE, options->tmp_dir,
2785
+                             R_OK|W_OK|X_OK, "Temporary directory (--tmp-dir)");
2784 2786
 
2785 2787
   /* ** Script hooks that accept an optionally quoted and/or escaped executable path, ** */
2786 2788
   /* ** optionally followed by arguments ** */
... ...
@@ -399,11 +399,13 @@ struct options
399 399
   struct plugin_option_list *plugin_list;
400 400
 #endif
401 401
 
402
-  const char *tmp_dir;
402
+
403 403
 
404 404
 #if P2MP
405 405
 
406 406
 #if P2MP_SERVER
407
+  /* the tmp dir is for now only used in the P2P server context */
408
+  const char *tmp_dir;
407 409
   bool server_defined;
408 410
   in_addr_t server_network;
409 411
   in_addr_t server_netmask;