20
static int log_syslog;
21
static int verbose;
22
static int reuseaddr;
23
+static int informative_errors;
24
25
static const char daemon_usage[] =
26
"git daemon [--verbose] [--syslog] [--export-all]\n"
248
return 0;
249
}
250
251
+static int daemon_error(const char *dir, const char *msg)
252
+{
253
+ if (!informative_errors)
254
+ msg = "access denied or repository not exported";
255
+ packet_write(1, "ERR %s: %s", msg, dir);
256
+ return -1;
257
+}
258
+
259
static int run_service(char *dir, struct daemon_service *service)
260
{
261
const char *path;
266
if (!enabled && !service->overridable) {
267
logerror("'%s': service not enabled.", service->name);
268
errno = EACCES;
260
- return -1;
269
+ return daemon_error(dir, "service not enabled");
270
}
271
272
if (!(path = path_ok(dir)))
264
- return -1;
273
+ return daemon_error(dir, "no such repository");
274
275
/*
276
* Security on the cheap.
286
if (!export_all_trees && access("git-daemon-export-ok", F_OK)) {
287
logerror("'%s': repository not exported.", path);
288
errno = EACCES;
280
- return -1;
289
+ return daemon_error(dir, "repository not exported");
290
}
291
292
if (service->overridable) {
300
logerror("'%s': service not enabled for '%s'",
301
service->name, path);
302
errno = EACCES;
294
- return -1;
303
+ return daemon_error(dir, "service not enabled");
304
}
305
306
/*
1176
make_service_overridable(arg + 18, 0);
1177
continue;
1178
}
1179
+ if (!prefixcmp(arg, "--informative-errors")) {
1180
+ informative_errors = 1;
1181
+ continue;
1182
+ }
1183
+ if (!prefixcmp(arg, "--no-informative-errors")) {
1184
+ informative_errors = 0;
1185
+ continue;
1186
+ }
1187
if (!strcmp(arg, "--")) {
1188
ok_paths = &argv[i+1];
1189
break;