| | @@ -1843,52 +1843,52 @@ |
| 1843 | 1843 | process_one_web_page(zNotFound, pFileGlob); |
| 1844 | 1844 | } |
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | 1847 | /* |
| 1848 | | -** If g.argv[2] exists then it is either the name of a repository |
| 1848 | +** If g.argv[arg] exists then it is either the name of a repository |
| 1849 | 1849 | ** that will be used by a server, or else it is a directory that |
| 1850 | | -** contains multiple repositories that can be served. If g.argv[2] |
| 1850 | +** contains multiple repositories that can be served. If g.argv[arg] |
| 1851 | 1851 | ** is a directory, the repositories it contains must be named |
| 1852 | | -** "*.fossil". If g.argv[2] does not exists, then we must be within |
| 1852 | +** "*.fossil". If g.argv[arg] does not exists, then we must be within |
| 1853 | 1853 | ** a check-out and the repository to be served is the repository of |
| 1854 | 1854 | ** that check-out. |
| 1855 | 1855 | ** |
| 1856 | | -** Open the repository to be served if it is known. If g.argv[2] is |
| 1856 | +** Open the repository to be served if it is known. If g.argv[arg] is |
| 1857 | 1857 | ** a directory full of repositories, then set g.zRepositoryName to |
| 1858 | 1858 | ** the name of that directory and the specific repository will be |
| 1859 | 1859 | ** opened later by process_one_web_page() based on the content of |
| 1860 | 1860 | ** the PATH_INFO variable. |
| 1861 | 1861 | ** |
| 1862 | 1862 | ** If disallowDir is set, then the directory full of repositories method |
| 1863 | 1863 | ** is disallowed. |
| 1864 | 1864 | */ |
| 1865 | | -static void find_server_repository(int disallowDir){ |
| 1866 | | - if( g.argc<3 ){ |
| 1865 | +static void find_server_repository(int disallowDir, int arg){ |
| 1866 | + if( g.argc<=arg ){ |
| 1867 | 1867 | db_must_be_within_tree(); |
| 1868 | | - }else if( file_isdir(g.argv[2])==1 ){ |
| 1868 | + }else if( file_isdir(g.argv[arg])==1 ){ |
| 1869 | 1869 | if( disallowDir ){ |
| 1870 | | - fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]); |
| 1870 | + fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[arg]); |
| 1871 | 1871 | }else{ |
| 1872 | | - g.zRepositoryName = mprintf("%s", g.argv[2]); |
| 1872 | + g.zRepositoryName = mprintf("%s", g.argv[arg]); |
| 1873 | 1873 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 1874 | 1874 | } |
| 1875 | 1875 | }else{ |
| 1876 | | - db_open_repository(g.argv[2]); |
| 1876 | + db_open_repository(g.argv[arg]); |
| 1877 | 1877 | } |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | 1880 | /* |
| 1881 | 1881 | ** undocumented format: |
| 1882 | 1882 | ** |
| 1883 | | -** fossil http REPOSITORY INFILE OUTFILE IPADDR |
| 1883 | +** fossil http INFILE OUTFILE IPADDR ?REPOSITORY? |
| 1884 | 1884 | ** |
| 1885 | 1885 | ** The argv==6 form is used by the win32 server only. |
| 1886 | 1886 | ** |
| 1887 | 1887 | ** COMMAND: http* |
| 1888 | 1888 | ** |
| 1889 | | -** Usage: %fossil http REPOSITORY ?OPTIONS? |
| 1889 | +** Usage: %fossil http ?REPOSITORY? ?OPTIONS? |
| 1890 | 1890 | ** |
| 1891 | 1891 | ** Handle a single HTTP request appearing on stdin. The resulting webpage |
| 1892 | 1892 | ** is delivered on stdout. This method is used to launch an HTTP request |
| 1893 | 1893 | ** handler from inetd, for example. The argument is the name of the |
| 1894 | 1894 | ** repository. |
| | @@ -1959,30 +1959,31 @@ |
| 1959 | 1959 | g.cgiOutput = 1; |
| 1960 | 1960 | |
| 1961 | 1961 | /* We should be done with options.. */ |
| 1962 | 1962 | verify_all_options(); |
| 1963 | 1963 | |
| 1964 | | - if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ |
| 1964 | + if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){ |
| 1965 | 1965 | fossil_fatal("no repository specified"); |
| 1966 | 1966 | } |
| 1967 | 1967 | g.fullHttpReply = 1; |
| 1968 | | - if( g.argc==6 ){ |
| 1969 | | - g.httpIn = fossil_fopen(g.argv[3], "rb"); |
| 1970 | | - g.httpOut = fossil_fopen(g.argv[4], "wb"); |
| 1971 | | - zIpAddr = g.argv[5]; |
| 1968 | + if( g.argc>=5 ){ |
| 1969 | + g.httpIn = fossil_fopen(g.argv[2], "rb"); |
| 1970 | + g.httpOut = fossil_fopen(g.argv[3], "wb"); |
| 1971 | + zIpAddr = g.argv[4]; |
| 1972 | + find_server_repository(0, 5); |
| 1972 | 1973 | }else{ |
| 1973 | 1974 | g.httpIn = stdin; |
| 1974 | 1975 | g.httpOut = stdout; |
| 1975 | 1976 | zIpAddr = 0; |
| 1977 | + find_server_repository(0, 2); |
| 1976 | 1978 | } |
| 1977 | 1979 | if( zIpAddr==0 ){ |
| 1978 | 1980 | zIpAddr = cgi_ssh_remote_addr(0); |
| 1979 | 1981 | if( zIpAddr && zIpAddr[0] ){ |
| 1980 | 1982 | g.fSshClient |= CGI_SSH_CLIENT; |
| 1981 | 1983 | } |
| 1982 | 1984 | } |
| 1983 | | - find_server_repository(0); |
| 1984 | 1985 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1985 | 1986 | if( useSCGI ){ |
| 1986 | 1987 | cgi_handle_scgi_request(); |
| 1987 | 1988 | }else if( g.fSshClient & CGI_SSH_CLIENT ){ |
| 1988 | 1989 | ssh_request_loop(zIpAddr, glob_create(zFileGlob)); |
| | @@ -2018,11 +2019,11 @@ |
| 2018 | 2019 | Th_InitTraceLog(); |
| 2019 | 2020 | login_set_capabilities("sx", 0); |
| 2020 | 2021 | g.useLocalauth = 1; |
| 2021 | 2022 | g.httpIn = stdin; |
| 2022 | 2023 | g.httpOut = stdout; |
| 2023 | | - find_server_repository(0); |
| 2024 | + find_server_repository(0, 2); |
| 2024 | 2025 | g.cgiOutput = 1; |
| 2025 | 2026 | g.fullHttpReply = 1; |
| 2026 | 2027 | zIpAddr = cgi_ssh_remote_addr(0); |
| 2027 | 2028 | if( zIpAddr && zIpAddr[0] ){ |
| 2028 | 2029 | g.fSshClient |= CGI_SSH_CLIENT; |
| | @@ -2155,11 +2156,11 @@ |
| 2155 | 2156 | isUiCmd = g.argv[1][0]=='u'; |
| 2156 | 2157 | if( isUiCmd ){ |
| 2157 | 2158 | flags |= HTTP_SERVER_LOCALHOST; |
| 2158 | 2159 | g.useLocalauth = 1; |
| 2159 | 2160 | } |
| 2160 | | - find_server_repository(isUiCmd && zNotFound==0); |
| 2161 | + find_server_repository(isUiCmd && zNotFound==0, 2); |
| 2161 | 2162 | if( zPort ){ |
| 2162 | 2163 | int i; |
| 2163 | 2164 | for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){} |
| 2164 | 2165 | if( i>0 ){ |
| 2165 | 2166 | zIpAddr = mprintf("%.*s", i, zPort); |
| | @@ -2205,11 +2206,11 @@ |
| 2205 | 2206 | g.httpOut = stdout; |
| 2206 | 2207 | if( g.fHttpTrace || g.fSqlTrace ){ |
| 2207 | 2208 | fprintf(stderr, "====== SERVER pid %d =======\n", getpid()); |
| 2208 | 2209 | } |
| 2209 | 2210 | g.cgiOutput = 1; |
| 2210 | | - find_server_repository(isUiCmd && zNotFound==0); |
| 2211 | + find_server_repository(isUiCmd && zNotFound==0, 2); |
| 2211 | 2212 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 2212 | 2213 | if( flags & HTTP_SERVER_SCGI ){ |
| 2213 | 2214 | cgi_handle_scgi_request(); |
| 2214 | 2215 | }else{ |
| 2215 | 2216 | cgi_handle_http_request(0); |
| 2216 | 2217 | |