~ubuntu-branches/ubuntu/intrepid/git-core/intrepid-security

« back to all changes in this revision

Viewing changes to daemon.c

  • Committer: Package Import Robot
  • Author(s): Gerrit Pape
  • Date: 2007-10-04 08:27:01 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20071004082701-rsd058ontoqz4i30
Tags: 1:1.5.3.4-1
new upstream point release (closes: #445188).

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
static const char daemon_usage[] =
17
17
"git-daemon [--verbose] [--syslog] [--export-all]\n"
18
18
"           [--timeout=n] [--init-timeout=n] [--strict-paths]\n"
19
 
"           [--base-path=path] [--user-path | --user-path=path]\n"
 
19
"           [--base-path=path] [--base-path-relaxed]\n"
 
20
"           [--user-path | --user-path=path]\n"
20
21
"           [--interpolated-path=path]\n"
21
22
"           [--reuseaddr] [--detach] [--pid-file=file]\n"
22
23
"           [--[enable|disable|allow-override|forbid-override]=service]\n"
34
35
/* Take all paths relative to this one if non-NULL */
35
36
static char *base_path;
36
37
static char *interpolated_path;
 
38
static int base_path_relaxed;
37
39
 
38
40
/* Flag indicating client sent extra args. */
39
41
static int saw_extended_args;
133
135
{
134
136
        int sl, ndot;
135
137
 
136
 
        /* 
 
138
        /*
137
139
         * This resurrects the belts and suspenders paranoia check by HPA
138
140
         * done in <435560F7.4080006@zytor.com> thread, now enter_repo()
139
141
         * does not do getcwd() based path canonicalizations.
180
182
{
181
183
        static char rpath[PATH_MAX];
182
184
        static char interp_path[PATH_MAX];
 
185
        int retried_path = 0;
183
186
        char *path;
184
187
        char *dir;
185
188
 
235
238
                dir = rpath;
236
239
        }
237
240
 
238
 
        path = enter_repo(dir, strict_paths);
 
241
        do {
 
242
                path = enter_repo(dir, strict_paths);
 
243
                if (path)
 
244
                        break;
 
245
 
 
246
                /*
 
247
                 * if we fail and base_path_relaxed is enabled, try without
 
248
                 * prefixing the base path
 
249
                 */
 
250
                if (base_path && base_path_relaxed && !retried_path) {
 
251
                        dir = itable[INTERP_SLOT_DIR].value;
 
252
                        retried_path = 1;
 
253
                        continue;
 
254
                }
 
255
                break;
 
256
        } while (1);
239
257
 
240
258
        if (!path) {
241
259
                logerror("'%s': unable to chdir or not a git archive", dir);
247
265
                int pathlen = strlen(path);
248
266
 
249
267
                /* The validation is done on the paths after enter_repo
250
 
                 * appends optional {.git,.git/.git} and friends, but 
 
268
                 * appends optional {.git,.git/.git} and friends, but
251
269
                 * it does not use getcwd().  So if your /pub is
252
270
                 * a symlink to /mnt/pub, you can whitelist /pub and
253
271
                 * do not have to say /mnt/pub.
439
457
        }
440
458
}
441
459
 
442
 
void fill_in_extra_table_entries(struct interp *itable)
 
460
static void fill_in_extra_table_entries(struct interp *itable)
443
461
{
444
462
        char *hp;
445
463
 
1061
1079
                        base_path = arg+12;
1062
1080
                        continue;
1063
1081
                }
 
1082
                if (!strcmp(arg, "--base-path-relaxed")) {
 
1083
                        base_path_relaxed = 1;
 
1084
                        continue;
 
1085
                }
1064
1086
                if (!prefixcmp(arg, "--interpolated-path=")) {
1065
1087
                        interpolated_path = arg+20;
1066
1088
                        continue;