Check-in [38be9473fe]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Made nano Fossil more unified in setting HOME and USER to something random
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:38be9473fec1fe65dfbe68bca6195e911bf31aef
User & Date: rkeene 2016-09-13 19:05:13
Context
2016-10-03
16:51
Setting/unsetting environment variables in the constructor causes issues when objects are created and destroyed, leaving environment variables unset -- instead paramaterize the call to Fossil, this is better anyway check-in: 1af745f0f9 user: rkeene tags: trunk
2016-09-13
19:05
Made nano Fossil more unified in setting HOME and USER to something random check-in: 38be9473fe user: rkeene tags: trunk
18:48
Removed firstname/lastname fields (issue [544067e8c0]) check-in: 5d7dae3b56 user: rkeene tags: trunk
Changes

Changes to nano/fossil.php.

1
2
3
4
5
6

7
8
9
10
11












12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
..
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php

class Nano_Fossil
{
    protected $path;
    protected $user;


    public function __construct($user)
    {
        $this->path = $_SERVER['DOCUMENT_ROOT'] . '/../repos/' . $user['username'] . '/';
        $this->user = $user;












    }

    public function newRepo($repo, $password = null, $private = 0, $projectCode = null)
    {
        if (!file_exists($this->path)) {
            mkdir($this->path);

            $content = "#!/usr/local/bin/fossil\ndirectory: ./\nnotfound: http://{$_SERVER['SERVER_NAME']}/notfound";
            file_put_contents("{$this->path}repository", $content);
            chmod("{$this->path}repository", 0555);
        }

        if (!file_exists("{$this->path}{$repo}.fossil")) {
            putenv('HOME=/tmp');
            putenv("USER={$this->user['username']}");
            putenv("GATEWAY_INTERFACE");
            exec("/usr/local/bin/fossil new -A " . escapeshellarg($this->user['username']) . " " . escapeshellarg("{$this->path}{$repo}.fossil"), $output, $return);

            if ($return !== 0) {
                if (file_exists("{$this->path}{$repo}.fossil")) {
                    unlink("{$this->path}{$repo}.fossil");
                }

................................................................................

            $content = "#!/usr/local/bin/fossil\ndirectory: ./\nnotfound: http://{$_SERVER['SERVER_NAME']}/notfound";
            file_put_contents("{$this->path}repository", $content);
            chmod("{$this->path}repository", 0555);
        }

        if (!file_exists("{$this->path}{$repo}.fossil")) {
            putenv('HOME=/tmp');
            putenv("USER={$this->user['username']}");
            putenv("GATEWAY_INTERFACE");
            exec("timeout 3600 /usr/local/bin/fossil clone -A " . escapeshellarg($this->user['username']) . " " . escapeshellarg($url) . " " . escapeshellarg("{$this->path}{$repo}.fossil"), $output,
                 $return);

            if ($return !== 0) {
                if (file_exists("{$this->path}{$repo}.fossil")) {
                    unlink("{$this->path}{$repo}.fossil");
                }
................................................................................

            $content = "#!/usr/local/bin/fossil\ndirectory: ./\nnotfound: http://{$_SERVER['SERVER_NAME']}/notfound";
            file_put_contents("{$this->path}repository", $content);
            chmod("{$this->path}repository", 0555);
        }

        if (!file_exists("{$this->path}{$repo}.fossil")) {
            putenv('HOME=/tmp');
            putenv("USER={$this->user['username']}");
            putenv("GATEWAY_INTERFACE");

            if (!@move_uploaded_file($file['tmp_name'], "{$this->path}{$repo}.fossil")) {
                return false;
            }

            exec("/usr/local/bin/fossil config -R " . escapeshellarg("{$this->path}{$repo}.fossil") . " export project /tmp/config",
                 $output, $return);

................................................................................
            if (file_exists($url) || preg_match('/:\/\//', $url) == 0) {
                $outputstr = "Invalid URL";
                return false;
            }
        }

        if (file_exists("{$this->path}{$repo}.fossil")) {
            putenv('HOME=/tmp');
            putenv("USER={$this->user['username']}");
            putenv("GATEWAY_INTERFACE");
            if ($url == '') {
                exec("timeout 3600 /usr/local/bin/fossil pull -R " . escapeshellarg("{$this->path}{$repo}.fossil") . " 2>&1",
                  $output, $return);
            } else {
                exec("timeout 3600 /usr/local/bin/fossil pull " . escapeshellarg($url) . " -R " . escapeshellarg("{$this->path}{$repo}.fossil") . " 2>&1",
                  $output, $return);
            }






>





>
>
>
>
>
>
>
>
>
>
>
>













<
<
<







 







<
<
<







 







<
<
<
<







 







<
<
<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37



38
39
40
41
42
43
44
...
105
106
107
108
109
110
111



112
113
114
115
116
117
118
...
171
172
173
174
175
176
177




178
179
180
181
182
183
184
...
253
254
255
256
257
258
259



260
261
262
263
264
265
266
<?php

class Nano_Fossil
{
    protected $path;
    protected $user;
    protected $workdir;

    public function __construct($user)
    {
        $this->path = $_SERVER['DOCUMENT_ROOT'] . '/../repos/' . $user['username'] . '/';
        $this->user = $user;
        $this->workdir = "/tmp/workdir-flint-" . bin2hex(openssl_random_pseudo_bytes(20));

        mkdir($this->workdir);
        putenv("HOME={$this->workdir}");
        putenv("USER={$this->user['username']}");
        putenv("GATEWAY_INTERFACE");
    }

    public function __destruct() {
        putenv("HOME");
        putenv("USER");
        system("rm -rf '{$this->workdir}'");
    }

    public function newRepo($repo, $password = null, $private = 0, $projectCode = null)
    {
        if (!file_exists($this->path)) {
            mkdir($this->path);

            $content = "#!/usr/local/bin/fossil\ndirectory: ./\nnotfound: http://{$_SERVER['SERVER_NAME']}/notfound";
            file_put_contents("{$this->path}repository", $content);
            chmod("{$this->path}repository", 0555);
        }

        if (!file_exists("{$this->path}{$repo}.fossil")) {



            exec("/usr/local/bin/fossil new -A " . escapeshellarg($this->user['username']) . " " . escapeshellarg("{$this->path}{$repo}.fossil"), $output, $return);

            if ($return !== 0) {
                if (file_exists("{$this->path}{$repo}.fossil")) {
                    unlink("{$this->path}{$repo}.fossil");
                }

................................................................................

            $content = "#!/usr/local/bin/fossil\ndirectory: ./\nnotfound: http://{$_SERVER['SERVER_NAME']}/notfound";
            file_put_contents("{$this->path}repository", $content);
            chmod("{$this->path}repository", 0555);
        }

        if (!file_exists("{$this->path}{$repo}.fossil")) {



            exec("timeout 3600 /usr/local/bin/fossil clone -A " . escapeshellarg($this->user['username']) . " " . escapeshellarg($url) . " " . escapeshellarg("{$this->path}{$repo}.fossil"), $output,
                 $return);

            if ($return !== 0) {
                if (file_exists("{$this->path}{$repo}.fossil")) {
                    unlink("{$this->path}{$repo}.fossil");
                }
................................................................................

            $content = "#!/usr/local/bin/fossil\ndirectory: ./\nnotfound: http://{$_SERVER['SERVER_NAME']}/notfound";
            file_put_contents("{$this->path}repository", $content);
            chmod("{$this->path}repository", 0555);
        }

        if (!file_exists("{$this->path}{$repo}.fossil")) {




            if (!@move_uploaded_file($file['tmp_name'], "{$this->path}{$repo}.fossil")) {
                return false;
            }

            exec("/usr/local/bin/fossil config -R " . escapeshellarg("{$this->path}{$repo}.fossil") . " export project /tmp/config",
                 $output, $return);

................................................................................
            if (file_exists($url) || preg_match('/:\/\//', $url) == 0) {
                $outputstr = "Invalid URL";
                return false;
            }
        }

        if (file_exists("{$this->path}{$repo}.fossil")) {



            if ($url == '') {
                exec("timeout 3600 /usr/local/bin/fossil pull -R " . escapeshellarg("{$this->path}{$repo}.fossil") . " 2>&1",
                  $output, $return);
            } else {
                exec("timeout 3600 /usr/local/bin/fossil pull " . escapeshellarg($url) . " -R " . escapeshellarg("{$this->path}{$repo}.fossil") . " 2>&1",
                  $output, $return);
            }