We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
All temp files will now be placed inside /tmp/passenger.XXX instead of 
inside /tmp. This makes it easier to keep /tmp clean.
Hongli Lai (Phusion) (author)
Wed Nov 19 12:17:44 -0800 2008
commit  f8e055742b9dec150807a83f8384171546bc6496
tree    a736ec43190c397d4b891b89d791f3782144dbc6
parent  2434de04c45846e20293418aea42d54bc13abbaf
...
40
41
42
43
44
 
 
45
46
47
...
99
100
101
102
 
103
104
105
...
40
41
42
 
 
43
44
45
46
47
...
99
100
101
 
102
103
104
105
0
@@ -40,8 +40,8 @@ end
0
 # and attempt to remove stale status FIFO files.
0
 def list_and_clean_status_fifos
0
   result = []
0
- Dir["/tmp/passenger_status.*.fifo"].each do |filename|
0
- filename =~ /(\d+).fifo$/
0
+ Dir["/tmp/passenger.*/status.fifo"].each do |filename|
0
+ filename =~ /passenger.(\d+)/
0
     pid = $1.to_i
0
     if process_is_alive?(pid)
0
       result << StatusFifo.new(filename, pid)
0
@@ -99,7 +99,7 @@ def start
0
       exit 1
0
     end
0
   else
0
- show_status(StatusFifo.new("/tmp/passenger_status.#{ARGV[0]}.fifo", ARGV[0].to_i))
0
+ show_status(StatusFifo.new("/tmp/passenger.#{ARGV[0]}/status.fifo", ARGV[0].to_i))
0
   end
0
 end
0
 
...
533
534
535
536
537
 
 
 
 
538
539
540
...
533
534
535
 
 
536
537
538
539
540
541
542
0
@@ -533,8 +533,10 @@ private:
0
     char filename[PATH_MAX];
0
     int ret;
0
     
0
- snprintf(filename, sizeof(filename), "/tmp/passenger_status.%lu.fifo",
0
- (unsigned long) getpid());
0
+ createPassengerTempDir();
0
+
0
+ snprintf(filename, sizeof(filename), "%s/status.fifo",
0
+ getPassengerTempDir().c_str());
0
     filename[PATH_MAX - 1] = '\0';
0
     do {
0
       ret = mkfifo(filename, S_IRUSR | S_IWUSR);
...
685
686
687
 
 
688
689
690
...
725
726
727
 
 
 
 
728
729
730
...
685
686
687
688
689
690
691
692
...
727
728
729
730
731
732
733
734
735
736
0
@@ -685,6 +685,8 @@ public:
0
     const char *ruby, *user;
0
     string applicationPoolServerExe, spawnServer;
0
     
0
+ createPassengerTempDir();
0
+
0
     ruby = (config->ruby != NULL) ? config->ruby : DEFAULT_RUBY_COMMAND;
0
     if (config->userSwitching) {
0
       user = "";
0
@@ -725,6 +727,10 @@ public:
0
     );
0
   }
0
   
0
+ ~Hooks() {
0
+ removeDirTree(getPassengerTempDir().c_str());
0
+ }
0
+
0
   void initChild(apr_pool_t *pchild, server_rec *s) {
0
     ServerConfig *config = getServerConfig(s);
0
     
...
171
172
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
175
176
...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
0
@@ -171,6 +171,86 @@ canonicalizePath(const string &path) {
0
   #endif
0
 }
0
 
0
+const char *
0
+getTempDir() {
0
+ const char *temp_dir = getenv("TMP");
0
+ if (temp_dir == NULL || *temp_dir == '\0') {
0
+ temp_dir = "/tmp";
0
+ }
0
+ return temp_dir;
0
+}
0
+
0
+string
0
+getPassengerTempDir(bool bypassCache) {
0
+ if (bypassCache) {
0
+ goto calculateResult;
0
+ } else {
0
+ const char *tmp = getenv("PHUSION_PASSENGER_TMP");
0
+ if (tmp != NULL && *tmp != '\0') {
0
+ return tmp;
0
+ } else {
0
+ goto calculateResult;
0
+ }
0
+ }
0
+
0
+ calculateResult:
0
+ const char *temp_dir = getTempDir();
0
+ char buffer[PATH_MAX];
0
+
0
+ snprintf(buffer, sizeof(buffer), "%s/passenger.%d", temp_dir, getpid());
0
+ buffer[sizeof(buffer) - 1] = '\0';
0
+ setenv("PHUSION_PASSENGER_TMP", buffer, 1);
0
+ return buffer;
0
+}
0
+
0
+void
0
+createPassengerTempDir() {
0
+ makeDirTree(getPassengerTempDir().c_str(), "u=rwxs,g=wxs,o=wxs");
0
+}
0
+
0
+void
0
+makeDirTree(const char *path, const char *mode) {
0
+ char command[PATH_MAX + 10];
0
+ snprintf(command, sizeof(command), "mkdir -p -m \"%s\" \"%s\"", mode, path);
0
+ command[sizeof(command) - 1] = '\0';
0
+
0
+ int result;
0
+ do {
0
+ result = system(command);
0
+ } while (result == -1 && errno == EINTR);
0
+ if (result != 0) {
0
+ char message[1024];
0
+ int e = errno;
0
+
0
+ snprintf(message, sizeof(message) - 1, "Cannot create directory '%s'", path);
0
+ message[sizeof(message) - 1] = '\0';
0
+ if (result == -1) {
0
+ throw SystemException(message, e);
0
+ } else {
0
+ throw IOException(message);
0
+ }
0
+ }
0
+}
0
+
0
+void
0
+removeDirTree(const char *path) {
0
+ char command[PATH_MAX + 10];
0
+ snprintf(command, sizeof(command), "rm -rf \"%s\"", path);
0
+ command[sizeof(command) - 1] = '\0';
0
+
0
+ int result;
0
+ do {
0
+ result = system(command);
0
+ } while (result == -1 && errno == EINTR);
0
+ if (result == -1) {
0
+ char message[1024];
0
+
0
+ snprintf(message, sizeof(message) - 1, "Cannot create directory '%s'", path);
0
+ message[sizeof(message) - 1] = '\0';
0
+ throw IOException(message);
0
+ }
0
+}
0
+
0
 bool
0
 verifyRailsDir(const string &dir) {
0
   string temp(dir);
...
203
204
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
207
208
...
250
251
252
253
254
 
255
256
257
258
259
260
261
262
263
 
264
265
266
267
 
 
 
 
268
269
270
...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
...
304
305
306
 
 
307
308
309
310
 
 
 
 
 
 
311
312
313
314
 
315
316
317
318
319
320
321
0
@@ -203,6 +203,60 @@ string findApplicationPoolServer(const char *passengerRoot);
0
 string canonicalizePath(const string &path);
0
 
0
 /**
0
+ * Return the path name for the directory in which temporary files are
0
+ * to be stored.
0
+ *
0
+ * @ensure result != NULL
0
+ * @ingroup Support
0
+ */
0
+const char *getTempDir();
0
+
0
+/**
0
+ * Return the path name for the directory in which Phusion Passenger-specific
0
+ * temporary files are to be stored. This directory is unique for this instance
0
+ * of the web server in which Phusion Passenger is running.
0
+ *
0
+ * The result will be cached into the PHUSION_PASSENGER_TMP environment variable,
0
+ * which will be used for future calls to this function. To bypass this cache,
0
+ * set 'bypassCache' to true.
0
+ *
0
+ * @ensure !result.empty()
0
+ * @ingroup Support
0
+ */
0
+string getPassengerTempDir(bool bypassCache = false);
0
+
0
+/* Create a temp folder for storing Phusion Passenger-specific temp files,
0
+ * such as temporarily buffered uploads, sockets for backend processes, etc.
0
+ * This call also sets the PHUSION_PASSENGER_TMP environment variable, which
0
+ * allows backend processes to find this temp folder.
0
+ *
0
+ * Does nothing if this folder already exists.
0
+ *
0
+ * @throws IOException Something went wrong.
0
+ * @throws SystemException Something went wrong.
0
+ */
0
+void createPassengerTempDir();
0
+
0
+/**
0
+ * Create the directory at the given path, creating intermediate directories
0
+ * if necessary. The created directories' permissions are as specified by the
0
+ * 'mode' parameter.
0
+ *
0
+ * If 'path' already exists, then nothing will happen.
0
+ *
0
+ * @throws IOException Something went wrong.
0
+ * @throws SystemException Something went wrong.
0
+ */
0
+void makeDirTree(const char *path, const char *mode = "u=rwx,g=,o=");
0
+
0
+/**
0
+ * Remove an entire directory tree recursively.
0
+ *
0
+ * @throws SystemException Something went wrong.
0
+ */
0
+void removeDirTree(const char *path);
0
+
0
+/**
0
  * Check whether the specified directory is a valid Ruby on Rails
0
  * 'public' directory.
0
  *
0
@@ -250,21 +304,18 @@ public:
0
    * a big not-in-memory buffer to work with.
0
    * @throws SystemException Something went wrong.
0
    */
0
- TempFile(bool anonymous = true) {
0
- const char *temp_dir;
0
+ TempFile(const char *identifier = "temp", bool anonymous = true) {
0
     char templ[PATH_MAX];
0
     int fd;
0
     
0
- temp_dir = getenv("TMP");
0
- if (temp_dir == NULL || *temp_dir == '\0') {
0
- temp_dir = "/tmp";
0
- }
0
-
0
- snprintf(templ, sizeof(templ), "%s/passenger.XXXXXX", temp_dir);
0
+ snprintf(templ, sizeof(templ), "%s/%s.XXXXXX", getPassengerTempDir().c_str(), identifier);
0
     templ[sizeof(templ) - 1] = '\0';
0
     fd = mkstemp(templ);
0
     if (fd == -1) {
0
- throw SystemException("Cannot create a temporary file", errno);
0
+ char message[1024];
0
+ snprintf(message, sizeof(message), "Cannot create a temporary file '%s'", templ);
0
+ message[sizeof(message) - 1] = '\0';
0
+ throw SystemException(message, errno);
0
     }
0
     if (anonymous) {
0
       fchmod(fd, 0000);
...
299
300
301
302
 
303
304
305
...
433
434
435
436
437
 
 
438
439
440
...
299
300
301
 
302
303
304
305
...
433
434
435
 
 
436
437
438
439
440
0
@@ -299,7 +299,7 @@ private
0
     done = false
0
     while !done
0
       begin
0
- @socket_name = "/tmp/passenger.#{generate_random_id(:base64)}"
0
+ @socket_name = "#{passenger_tmpdir}/passenger_backend.#{generate_random_id(:base64)}"
0
         @socket_name = @socket_name.slice(0, NativeSupport::UNIX_PATH_MAX - 1)
0
         @socket = UNIXServer.new(@socket_name)
0
         File.chmod(0600, @socket_name)
0
@@ -433,8 +433,8 @@ private
0
   end
0
   
0
   def abstract_namespace_sockets_allowed?
0
- return !ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS'] ||
0
- ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS'].empty?
0
+ value = ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS']
0
+ return value.nil? || value.empty?
0
   end
0
 
0
   def self.determine_passenger_version
...
346
347
348
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
350
351
...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
0
@@ -346,6 +346,20 @@ protected
0
       end
0
     end
0
   end
0
+
0
+ # Returns the directory in which to store Phusion Passenger-specific
0
+ # temporary files. If +create+ is true, then this method creates the
0
+ # directory if it doesn't exist.
0
+ def passenger_tmpdir(create = true)
0
+ dir = ENV['PHUSION_PASSENGER_TMP']
0
+ if dir.nil? || dir.empty?
0
+ dir = Dir.tmpdir
0
+ end
0
+ if create && !File.exist?(dir)
0
+ system("mkdir", "-p", "-m", "u=rwxs,g=wxs,o=wxs", dir)
0
+ end
0
+ return dir
0
+ end
0
 end
0
 
0
 end # module Passenger
...
1
2
 
 
 
 
3
4
5
...
13
14
15
 
 
16
17
18
19
 
 
20
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
23
24
...
98
99
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
...
1
2
3
4
5
6
7
8
9
...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
0
@@ -1,5 +1,9 @@
0
 #include "tut.h"
0
 #include "Utils.h"
0
+#include <sys/types.h>
0
+#include <sys/stat.h>
0
+#include <stdio.h>
0
+#include <dirent.h>
0
 #include <unistd.h>
0
 #include <limits.h>
0
 
0
@@ -13,12 +17,31 @@ namespace tut {
0
     
0
     UtilsTest() {
0
       oldPath = getenv("PATH");
0
+ unsetenv("TMP");
0
+ unsetenv("PHUSION_PASSENGER_TMP");
0
     }
0
     
0
     ~UtilsTest() {
0
       setenv("PATH", oldPath.c_str(), 1);
0
+ unsetenv("TMP");
0
+ unsetenv("PHUSION_PASSENGER_TMP");
0
     }
0
   };
0
+
0
+ static vector<string>
0
+ listDir(const char *path) {
0
+ vector<string> result;
0
+ DIR *d = opendir(path);
0
+ struct dirent *ent;
0
+
0
+ while ((ent = readdir(d)) != NULL) {
0
+ if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) {
0
+ continue;
0
+ }
0
+ result.push_back(ent->d_name);
0
+ }
0
+ return result;
0
+ }
0
 
0
   DEFINE_TEST_GROUP(UtilsTest);
0
 
0
@@ -98,4 +121,106 @@ namespace tut {
0
     setenv("PATH", binpath.c_str(), 1);
0
     ensure("Spawn server is found.", !findSpawnServer().empty());
0
   }
0
+
0
+
0
+ /***** Test getTempDir() *****/
0
+
0
+ TEST_METHOD(11) {
0
+ // It returns "/tmp" if the TMP environment is NULL.
0
+ ensure_equals(string(getTempDir()), "/tmp");
0
+ }
0
+
0
+ TEST_METHOD(12) {
0
+ // It returns "/tmp" if the TMP environment is an empty string.
0
+ setenv("TMP", "", 1);
0
+ ensure_equals(string(getTempDir()), "/tmp");
0
+ }
0
+
0
+ TEST_METHOD(13) {
0
+ // It returns the value of the TMP environment if it is not NULL and not empty.
0
+ setenv("TMP", "/foo", 1);
0
+ ensure_equals(string(getTempDir()), "/foo");
0
+ }
0
+
0
+
0
+ /***** Test getPassengerTempDir() *****/
0
+
0
+ TEST_METHOD(15) {
0
+ // It returns "(tempdir)/passenger.(pid)"
0
+ char dir[128];
0
+
0
+ snprintf(dir, sizeof(dir), "/tmp/passenger.%d", getpid());
0
+ ensure_equals(getPassengerTempDir(), dir);
0
+ }
0
+
0
+ TEST_METHOD(16) {
0
+ // It caches the result into the PHUSION_PASSENGER_TMP environment variable.
0
+ char dir[128];
0
+
0
+ snprintf(dir, sizeof(dir), "/tmp/passenger.%d", getpid());
0
+ getPassengerTempDir();
0
+ ensure_equals(getenv("PHUSION_PASSENGER_TMP"), string(dir));
0
+ }
0
+
0
+ TEST_METHOD(17) {
0
+ // It returns the value of the PHUSION_PASSENGER_TMP environment variable if it's not NULL and not an empty string.
0
+ setenv("PHUSION_PASSENGER_TMP", "/foo", 1);
0
+ ensure_equals(getPassengerTempDir(), "/foo");
0
+ }
0
+
0
+ TEST_METHOD(18) {
0
+ // It does not use query the PHUSION_PASSENGER_TMP environment variable if bypassCache is true.
0
+ char dir[128];
0
+
0
+ setenv("PHUSION_PASSENGER_TMP", "/foo", 1);
0
+ snprintf(dir, sizeof(dir), "/tmp/passenger.%d", getpid());
0
+ ensure_equals(getPassengerTempDir(true), dir);
0
+ }
0
+
0
+
0
+ /***** Test TempFile *****/
0
+
0
+ TEST_METHOD(20) {
0
+ // It creates a temp file inside getPassengerTempDir().
0
+ setenv("PHUSION_PASSENGER_TMP", "utils_test.tmp", 1);
0
+ mkdir("utils_test.tmp", S_IRWXU);
0
+ TempFile t("temp", false);
0
+ unsigned int size = listDir("utils_test.tmp").size();
0
+ removeDirTree("utils_test.tmp");
0
+ ensure_equals(size, 1u);
0
+ }
0
+
0
+ TEST_METHOD(21) {
0
+ // It deletes the temp file upon destruction.
0
+ setenv("PHUSION_PASSENGER_TMP", "utils_test.tmp", 1);
0
+ mkdir("utils_test.tmp", S_IRWXU);
0
+ {
0
+ TempFile t("temp", false);
0
+ }
0
+ bool dirEmpty = listDir("utils_test.tmp").empty();
0
+ removeDirTree("utils_test.tmp");
0
+ ensure(dirEmpty);
0
+ }
0
+
0
+ TEST_METHOD(22) {
0
+ // The temp file's filename is constructed using the given identifier.
0
+ setenv("PHUSION_PASSENGER_TMP", "utils_test.tmp", 1);
0
+ mkdir("utils_test.tmp", S_IRWXU);
0
+ TempFile t("foobar", false);
0
+ vector<string> files(listDir("utils_test.tmp"));
0
+ removeDirTree("utils_test.tmp");
0
+
0
+ ensure(files[0].find("foobar") != string::npos);
0
+ }
0
+
0
+ TEST_METHOD(23) {
0
+ // It immediately unlinks the temp file if 'anonymous' is true.
0
+ // It creates a temp file inside getPassengerTempDir().
0
+ setenv("PHUSION_PASSENGER_TMP", "utils_test.tmp", 1);
0
+ mkdir("utils_test.tmp", S_IRWXU);
0
+ TempFile t;
0
+ unsigned int size = listDir("utils_test.tmp").size();
0
+ removeDirTree("utils_test.tmp");
0
+ ensure_equals(size, 0u);
0
+ }
0
 }
...
2
3
4
 
 
5
6
7
8
 
9
10
11
...
18
19
20
 
 
 
 
21
22
23
...
43
44
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
47
48
...
2
3
4
5
6
7
8
9
10
11
12
13
14
...
21
22
23
24
25
26
27
28
29
30
...
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
0
@@ -2,10 +2,13 @@ require 'support/config'
0
 require 'support/test_helper'
0
 require 'passenger/abstract_request_handler'
0
 
0
+require 'fileutils'
0
+
0
 include Passenger
0
 
0
 describe AbstractRequestHandler do
0
   before :each do
0
+ prepare
0
     @owner_pipe = IO.pipe
0
     @request_handler = AbstractRequestHandler.new(@owner_pipe[1])
0
     def @request_handler.process_request(*args)
0
@@ -18,6 +21,10 @@ describe AbstractRequestHandler do
0
     @owner_pipe[0].close rescue nil
0
   end
0
   
0
+ def prepare
0
+ # Do nothing. To be overrided by sub describe blocks.
0
+ end
0
+
0
   it "exits if the owner pipe is closed" do
0
     @request_handler.start_main_loop_thread
0
     @owner_pipe[0].close
0
@@ -43,6 +50,23 @@ describe AbstractRequestHandler do
0
     @request_handler.processed_requests.should == 0
0
   end
0
   
0
+ describe "if abstract namespace sockets are not supported on the current platform" do
0
+ def prepare
0
+ ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS'] = "true"
0
+ ENV['PHUSION_PASSENGER_TMP'] = "abstract_request_handler_spec.tmp"
0
+ end
0
+
0
+ after :each do
0
+ ENV.delete('PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS')
0
+ ENV.delete('PHUSION_PASSENGER_TMP')
0
+ FileUtils.rm_rf("abstract_request_handler_spec.tmp")
0
+ end
0
+
0
+ it "creates a socket file in the Phusion Passenger temp folder" do
0
+ Dir["abstract_request_handler_spec.tmp/*"].should_not be_empty
0
+ end
0
+ end
0
+
0
   def wait_until
0
     while !yield
0
       sleep 0.01
...
30
31
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
0
@@ -30,4 +30,38 @@ describe Utils do
0
       File.unlink(filename) rescue nil
0
     end
0
   end
0
+
0
+ describe "#passenger_tmpdir" do
0
+ before :each do
0
+ ENV.delete('PHUSION_PASSENGER_TMP')
0
+ end
0
+
0
+ after :each do
0
+ ENV.delete('PHUSION_PASSENGER_TMP')
0
+ end
0
+
0
+ it "returns Dir.tmpdir if ENV['PHUSION_PASSENGER_TMP'] is nil" do
0
+ passenger_tmpdir(false).should == Dir.tmpdir
0
+ end
0
+
0
+ it "returns Dir.tmpdir if ENV['PHUSION_PASSENGER_TMP'] is an empty string" do
0
+ ENV['PHUSION_PASSENGER_TMP'] = ''
0
+ passenger_tmpdir(false).should == Dir.tmpdir
0
+ end
0
+
0
+ it "returns ENV['PHUSION_PASSENGER_TMP'] if it's set" do
0
+ ENV['PHUSION_PASSENGER_TMP'] = '/foo'
0
+ passenger_tmpdir(false).should == '/foo'
0
+ end
0
+
0
+ it "creates the directory if it doesn't exist, if the 'create' argument is true" do
0
+ ENV['PHUSION_PASSENGER_TMP'] = 'utils_spec.tmp'
0
+ passenger_tmpdir
0
+ begin
0
+ File.directory?('utils_spec.tmp').should be_true
0
+ ensure
0
+ Dir.rmdir('utils_spec.tmp') rescue nil
0
+ end
0
+ end
0
+ end
0
 end

Comments

    No one has commented yet.