129 | | if self.form.has_key("datatype") : |
130 | | self.options["data"] = self.form["datatype"].value |
131 | | if self.form.has_key("format") : |
132 | | self.options["format"] = self.form["format"].value |
133 | | if self.form.has_key("filter") : |
134 | | self.arguments = self.form["filter"].value.split() |
135 | | |
136 | | # when no authentication is done, or when the remote username |
137 | | # is 'root' (even if not run as root of course), then unrestricted |
138 | | # dump is allowed. |
139 | | remuser = os.environ.get("REMOTE_USER", "root") |
140 | | # special hack to accomodate mod_auth_ldap Apache module |
142 | | remuser = remuser.split("=")[1].split(",")[0] |
143 | | except IndexError : |
144 | | pass |
145 | | if remuser != "root" : |
146 | | # non-'root' users when the script is password protected |
147 | | # can not dump any data as they like, we restrict them |
148 | | # to their own datas. |
149 | | if self.options["data"] not in ["printers", "pmembers", "groups", "gpquotas"] : |
150 | | self.arguments.append("username=%s" % remuser) |
151 | | |
152 | | if self.options["format"] in ("csv", "ssv") : |
153 | | #ctype = "application/vnd.sun.xml.calc" # OpenOffice.org |
154 | | ctype = "text/comma-separated-values" |
155 | | fname = "dump.csv" |
156 | | elif self.options["format"] == "tsv" : |
157 | | #ctype = "application/vnd.sun.xml.calc" # OpenOffice.org |
158 | | ctype = "text/tab-separated-values" |
159 | | fname = "dump.tsv" |
160 | | elif self.options["format"] == "xml" : |
161 | | ctype = "text/xml" |
162 | | fname = "dump.xml" |
163 | | elif self.options["format"] == "cups" : |
164 | | ctype = "text/plain" |
165 | | fname = "page_log" |
166 | | print "Content-type: %s" % ctype |
167 | | print "Content-disposition: attachment; filename=%s" % fname |
168 | | print |
169 | | try : |
| 130 | if self.form.has_key("datatype") : |
| 131 | self.options["data"] = self.form["datatype"].value |
| 132 | if self.form.has_key("format") : |
| 133 | self.options["format"] = self.form["format"].value |
| 134 | if self.form.has_key("filter") : |
| 135 | self.arguments = self.form["filter"].value.split() |
| 136 | |
| 137 | # when no authentication is done, or when the remote username |
| 138 | # is 'root' (even if not run as root of course), then unrestricted |
| 139 | # dump is allowed. |
| 140 | remuser = os.environ.get("REMOTE_USER", "root") |
| 141 | # special hack to accomodate mod_auth_ldap Apache module |
| 142 | try : |
| 143 | remuser = remuser.split("=")[1].split(",")[0] |
| 144 | except IndexError : |
| 145 | pass |
| 146 | if remuser != "root" : |
| 147 | # non-'root' users when the script is password protected |
| 148 | # can not dump any data as they like, we restrict them |
| 149 | # to their own datas. |
| 150 | if self.options["data"] not in ["printers", "pmembers", "groups", "gpquotas"] : |
| 151 | self.arguments.append("username=%s" % remuser) |
| 152 | |
| 153 | if self.options["format"] in ("csv", "ssv") : |
| 154 | #ctype = "application/vnd.sun.xml.calc" # OpenOffice.org |
| 155 | ctype = "text/comma-separated-values" |
| 156 | fname = "dump.csv" |
| 157 | elif self.options["format"] == "tsv" : |
| 158 | #ctype = "application/vnd.sun.xml.calc" # OpenOffice.org |
| 159 | ctype = "text/tab-separated-values" |
| 160 | fname = "dump.tsv" |
| 161 | elif self.options["format"] == "xml" : |
| 162 | ctype = "text/xml" |
| 163 | fname = "dump.xml" |
| 164 | elif self.options["format"] == "cups" : |
| 165 | ctype = "text/plain" |
| 166 | fname = "page_log" |
| 167 | print "Content-type: %s" % ctype |
| 168 | print "Content-disposition: attachment; filename=%s" % fname |
| 169 | print |