OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Platform-specific utility methods shared by several scripts.""" | 6 """Platform-specific utility methods shared by several scripts.""" |
7 | 7 |
8 import os | 8 import os |
9 import subprocess | 9 import subprocess |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 apache2: boolean if true will cause this function to return start | 74 apache2: boolean if true will cause this function to return start |
75 command for Apache 2.x as opposed to Apache 1.3.x. This flag | 75 command for Apache 2.x as opposed to Apache 1.3.x. This flag |
76 is ignored on Linux (but preserved here for compatibility in | 76 is ignored on Linux (but preserved here for compatibility in |
77 function signature with win), where apache2 is used always | 77 function signature with win), where apache2 is used always |
78 """ | 78 """ |
79 | 79 |
80 exe_name = "apache2" | 80 exe_name = "apache2" |
81 cert_file = google.path_utils.FindUpward(self._base_dir, 'tools', | 81 cert_file = google.path_utils.FindUpward(self._base_dir, 'tools', |
82 'python', 'google', | 82 'python', 'google', |
83 'httpd_config', 'httpd2.pem') | 83 'httpd_config', 'httpd2.pem') |
| 84 ssl_enabled = os.path.exists('/etc/apache2/mods-enabled/ssl.conf') |
| 85 |
84 httpd_vars = { | 86 httpd_vars = { |
85 "httpd_executable_path": | 87 "httpd_executable_path": |
86 os.path.join(self._UnixRoot(), "usr", "sbin", exe_name), | 88 os.path.join(self._UnixRoot(), "usr", "sbin", exe_name), |
87 "httpd_conf_path": httpd_conf_path, | 89 "httpd_conf_path": httpd_conf_path, |
88 "ssl_certificate_file": cert_file, | 90 "ssl_certificate_file": cert_file, |
89 "document_root" : document_root, | 91 "document_root" : document_root, |
90 "server_root": os.path.join(self._UnixRoot(), "usr"), | 92 "server_root": os.path.join(self._UnixRoot(), "usr"), |
91 "mime_types_path": mime_types_path, | 93 "mime_types_path": mime_types_path, |
92 "output_dir": output_dir, | 94 "output_dir": output_dir, |
93 "ssl_mutex": "file:"+os.path.join(output_dir, "ssl_mutex"), | 95 "ssl_mutex": "file:"+os.path.join(output_dir, "ssl_mutex"), |
| 96 "ssl_session_cache": |
| 97 "shmcb:" + os.path.join(output_dir, "ssl_scache") + "(512000)", |
94 "user": os.environ.get("USER", "#%d" % os.geteuid()), | 98 "user": os.environ.get("USER", "#%d" % os.geteuid()), |
95 "lock_file": os.path.join(output_dir, "accept.lock"), | 99 "lock_file": os.path.join(output_dir, "accept.lock"), |
96 } | 100 } |
97 | 101 |
98 google.path_utils.MaybeMakeDirectory(output_dir) | 102 google.path_utils.MaybeMakeDirectory(output_dir) |
99 | 103 |
100 # We have to wrap the command in bash | 104 # We have to wrap the command in bash |
101 # -C: process directive before reading config files | 105 # -C: process directive before reading config files |
102 # -c: process directive after reading config files | 106 # -c: process directive after reading config files |
103 # Apache wouldn't run CGIs with permissions==700 unless we add | 107 # Apache wouldn't run CGIs with permissions==700 unless we add |
104 # -c User "<username>" | 108 # -c User "<username>" |
105 httpd_cmd_string = ( | 109 httpd_cmd_string = ( |
106 '%(httpd_executable_path)s' | 110 '%(httpd_executable_path)s' |
107 ' -f %(httpd_conf_path)s' | 111 ' -f %(httpd_conf_path)s' |
108 ' -c \'TypesConfig "%(mime_types_path)s"\'' | 112 ' -c \'TypesConfig "%(mime_types_path)s"\'' |
109 ' -c \'CustomLog "%(output_dir)s/access_log.txt" common\'' | 113 ' -c \'CustomLog "%(output_dir)s/access_log.txt" common\'' |
110 ' -c \'ErrorLog "%(output_dir)s/error_log.txt"\'' | 114 ' -c \'ErrorLog "%(output_dir)s/error_log.txt"\'' |
111 ' -c \'PidFile "%(output_dir)s/httpd.pid"\'' | 115 ' -c \'PidFile "%(output_dir)s/httpd.pid"\'' |
112 ' -C \'User "%(user)s"\'' | 116 ' -C \'User "%(user)s"\'' |
113 ' -C \'ServerRoot "%(server_root)s"\'' | 117 ' -C \'ServerRoot "%(server_root)s"\'' |
114 ' -c \'LockFile "%(lock_file)s"\'' | 118 ' -c \'LockFile "%(lock_file)s"\'' |
115 ' -c \'SSLCertificateFile "%(ssl_certificate_file)s"\'' | |
116 ' -c \'SSLMutex "%(ssl_mutex)s"\'' | |
117 ) | 119 ) |
118 | 120 |
119 if document_root: | 121 if document_root: |
120 httpd_cmd_string += ' -C \'DocumentRoot "%(document_root)s"\'' | 122 httpd_cmd_string += ' -C \'DocumentRoot "%(document_root)s"\'' |
| 123 |
| 124 if ssl_enabled: |
| 125 httpd_cmd_string += ( |
| 126 ' -c \'SSLCertificateFile "%(ssl_certificate_file)s"\'' |
| 127 ' -c \'SSLMutex "%(ssl_mutex)s"\'' |
| 128 ' -c \'SSLSessionCache "%(ssl_session_cache)s"\'' |
| 129 ) |
| 130 |
121 # Save a copy of httpd_cmd_string to use for stopping httpd | 131 # Save a copy of httpd_cmd_string to use for stopping httpd |
122 self._httpd_cmd_string = httpd_cmd_string % httpd_vars | 132 self._httpd_cmd_string = httpd_cmd_string % httpd_vars |
123 | 133 |
124 httpd_cmd = [self._bash, "-c", self._httpd_cmd_string] | 134 httpd_cmd = [self._bash, "-c", self._httpd_cmd_string] |
125 return httpd_cmd | 135 return httpd_cmd |
126 | 136 |
127 def GetStopHttpdCommand(self): | 137 def GetStopHttpdCommand(self): |
128 """Returns a list of strings that contains the command line+args needed to | 138 """Returns a list of strings that contains the command line+args needed to |
129 stop the http server used in the http tests. | 139 stop the http server used in the http tests. |
130 | 140 |
131 This tries to fetch the pid of httpd (if available) and returns the | 141 This tries to fetch the pid of httpd (if available) and returns the |
132 command to kill it. If pid is not available, kill all httpd processes | 142 command to kill it. If pid is not available, kill all httpd processes |
133 """ | 143 """ |
134 | 144 |
135 if not self._httpd_cmd_string: | 145 if not self._httpd_cmd_string: |
136 return ["true"] # Haven't been asked for the start cmd yet. Just pass. | 146 return ["true"] # Haven't been asked for the start cmd yet. Just pass. |
137 # Add a sleep after the shutdown because sometimes it takes some time for | 147 # Add a sleep after the shutdown because sometimes it takes some time for |
138 # the port to be available again. | 148 # the port to be available again. |
139 return [self._bash, "-c", self._httpd_cmd_string + ' -k stop && sleep 5'] | 149 return [self._bash, "-c", self._httpd_cmd_string + ' -k stop && sleep 5'] |
OLD | NEW |