Fossil SCM
Allow the "fossil ui" command to specify a directory as long as the "--notfound" option is also used. Give a better error message if these conditions are not met.
Commit
4e368da19cf34e88960fac5dd4225daab1694c1a
Parent
87d6aa31965d7dd…
1 file changed
+9
-5
+9
-5
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -1754,13 +1754,17 @@ | ||
| 1754 | 1754 | ** is disallowed. |
| 1755 | 1755 | */ |
| 1756 | 1756 | static void find_server_repository(int disallowDir){ |
| 1757 | 1757 | if( g.argc<3 ){ |
| 1758 | 1758 | db_must_be_within_tree(); |
| 1759 | - }else if( !disallowDir && file_isdir(g.argv[2])==1 ){ | |
| 1760 | - g.zRepositoryName = mprintf("%s", g.argv[2]); | |
| 1761 | - file_simplify_name(g.zRepositoryName, -1, 0); | |
| 1759 | + }else if( file_isdir(g.argv[2])==1 ){ | |
| 1760 | + if( disallowDir ){ | |
| 1761 | + fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]); | |
| 1762 | + }else{ | |
| 1763 | + g.zRepositoryName = mprintf("%s", g.argv[2]); | |
| 1764 | + file_simplify_name(g.zRepositoryName, -1, 0); | |
| 1765 | + } | |
| 1762 | 1766 | }else{ |
| 1763 | 1767 | db_open_repository(g.argv[2]); |
| 1764 | 1768 | } |
| 1765 | 1769 | } |
| 1766 | 1770 | |
| @@ -1948,11 +1952,11 @@ | ||
| 1948 | 1952 | isUiCmd = g.argv[1][0]=='u'; |
| 1949 | 1953 | if( isUiCmd ){ |
| 1950 | 1954 | flags |= HTTP_SERVER_LOCALHOST; |
| 1951 | 1955 | g.useLocalauth = 1; |
| 1952 | 1956 | } |
| 1953 | - find_server_repository(isUiCmd); | |
| 1957 | + find_server_repository(isUiCmd && zNotFound==0); | |
| 1954 | 1958 | if( zPort ){ |
| 1955 | 1959 | iPort = mxPort = atoi(zPort); |
| 1956 | 1960 | }else{ |
| 1957 | 1961 | iPort = db_get_int("http-port", 8080); |
| 1958 | 1962 | mxPort = iPort+100; |
| @@ -1987,11 +1991,11 @@ | ||
| 1987 | 1991 | g.httpOut = stdout; |
| 1988 | 1992 | if( g.fHttpTrace || g.fSqlTrace ){ |
| 1989 | 1993 | fprintf(stderr, "====== SERVER pid %d =======\n", getpid()); |
| 1990 | 1994 | } |
| 1991 | 1995 | g.cgiOutput = 1; |
| 1992 | - find_server_repository(isUiCmd); | |
| 1996 | + find_server_repository(isUiCmd && zNotFound==0); | |
| 1993 | 1997 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1994 | 1998 | cgi_handle_http_request(0); |
| 1995 | 1999 | process_one_web_page(zNotFound); |
| 1996 | 2000 | #else |
| 1997 | 2001 | /* Win32 implementation */ |
| 1998 | 2002 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1754,13 +1754,17 @@ | |
| 1754 | ** is disallowed. |
| 1755 | */ |
| 1756 | static void find_server_repository(int disallowDir){ |
| 1757 | if( g.argc<3 ){ |
| 1758 | db_must_be_within_tree(); |
| 1759 | }else if( !disallowDir && file_isdir(g.argv[2])==1 ){ |
| 1760 | g.zRepositoryName = mprintf("%s", g.argv[2]); |
| 1761 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 1762 | }else{ |
| 1763 | db_open_repository(g.argv[2]); |
| 1764 | } |
| 1765 | } |
| 1766 | |
| @@ -1948,11 +1952,11 @@ | |
| 1948 | isUiCmd = g.argv[1][0]=='u'; |
| 1949 | if( isUiCmd ){ |
| 1950 | flags |= HTTP_SERVER_LOCALHOST; |
| 1951 | g.useLocalauth = 1; |
| 1952 | } |
| 1953 | find_server_repository(isUiCmd); |
| 1954 | if( zPort ){ |
| 1955 | iPort = mxPort = atoi(zPort); |
| 1956 | }else{ |
| 1957 | iPort = db_get_int("http-port", 8080); |
| 1958 | mxPort = iPort+100; |
| @@ -1987,11 +1991,11 @@ | |
| 1987 | g.httpOut = stdout; |
| 1988 | if( g.fHttpTrace || g.fSqlTrace ){ |
| 1989 | fprintf(stderr, "====== SERVER pid %d =======\n", getpid()); |
| 1990 | } |
| 1991 | g.cgiOutput = 1; |
| 1992 | find_server_repository(isUiCmd); |
| 1993 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1994 | cgi_handle_http_request(0); |
| 1995 | process_one_web_page(zNotFound); |
| 1996 | #else |
| 1997 | /* Win32 implementation */ |
| 1998 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1754,13 +1754,17 @@ | |
| 1754 | ** is disallowed. |
| 1755 | */ |
| 1756 | static void find_server_repository(int disallowDir){ |
| 1757 | if( g.argc<3 ){ |
| 1758 | db_must_be_within_tree(); |
| 1759 | }else if( file_isdir(g.argv[2])==1 ){ |
| 1760 | if( disallowDir ){ |
| 1761 | fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]); |
| 1762 | }else{ |
| 1763 | g.zRepositoryName = mprintf("%s", g.argv[2]); |
| 1764 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 1765 | } |
| 1766 | }else{ |
| 1767 | db_open_repository(g.argv[2]); |
| 1768 | } |
| 1769 | } |
| 1770 | |
| @@ -1948,11 +1952,11 @@ | |
| 1952 | isUiCmd = g.argv[1][0]=='u'; |
| 1953 | if( isUiCmd ){ |
| 1954 | flags |= HTTP_SERVER_LOCALHOST; |
| 1955 | g.useLocalauth = 1; |
| 1956 | } |
| 1957 | find_server_repository(isUiCmd && zNotFound==0); |
| 1958 | if( zPort ){ |
| 1959 | iPort = mxPort = atoi(zPort); |
| 1960 | }else{ |
| 1961 | iPort = db_get_int("http-port", 8080); |
| 1962 | mxPort = iPort+100; |
| @@ -1987,11 +1991,11 @@ | |
| 1991 | g.httpOut = stdout; |
| 1992 | if( g.fHttpTrace || g.fSqlTrace ){ |
| 1993 | fprintf(stderr, "====== SERVER pid %d =======\n", getpid()); |
| 1994 | } |
| 1995 | g.cgiOutput = 1; |
| 1996 | find_server_repository(isUiCmd && zNotFound==0); |
| 1997 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1998 | cgi_handle_http_request(0); |
| 1999 | process_one_web_page(zNotFound); |
| 2000 | #else |
| 2001 | /* Win32 implementation */ |
| 2002 |