daemon: ensure that base-path is an existing directory
Any request to the daemon would fail if base-path (if specified) is not a directory. We now check for this condition early. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Feb 26, 2008 at 13:00 UTC
20632071560ad4915f4e620d3c053e5ee3af80f3
1 file changed
+8
daemon.c
+8
@@ -1184,6 +1184,14 @@ int main(int argc, char **argv)
1184
if (strict_paths && (!ok_paths || !*ok_paths))
1185
die("option --strict-paths requires a whitelist");
1186
1187
+ if (base_path) {
1188
+ struct stat st;
1189
+
1190
+ if (stat(base_path, &st) || !S_ISDIR(st.st_mode))
1191
+ die("base-path '%s' does not exist or "
1192
+ "is not a directory", base_path);
1193
+ }
1194
+
1195
if (inetd_mode) {
1196
struct sockaddr_storage ss;
1197
struct sockaddr *peer = (struct sockaddr *)&ss;