Check-in [302ba97f86]

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

Overview
Comment:Update automated rebuild to use suid fossil
Timelines: family | ancestors | descendants | both | setuid-fossil
Files: files | file ages | folders
SHA1: 302ba97f867ddf1c584512d910f059aae0fafec9
User & Date: rkeene 2020-08-23 19:41:28
Context
2020-08-23
19:48
Integrated SetUID support check-in: fb468fff0e user: rkeene tags: trunk
19:41
Update automated rebuild to use suid fossil Closed-Leaf check-in: 302ba97f86 user: rkeene tags: setuid-fossil
19:31
A bit of cleanup check-in: c0a2a1dc2c user: rkeene tags: setuid-fossil
Changes

Changes to nano/fossil.php.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
533
534
535
536
537
538
539

























540
541
542
543

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

	$fossil_config_file = dirname(__FILE__) . '/../config/fossil.cnf';
	$fossil_config = array();
	if (file_exists($fossil_config_file)) {
	        $fossil_config = parse_ini_file($fossil_config_file);
	}
        if (isset($fossil_config['use_suid']) && $fossil_config['use_suid'] === '1') {
            $this->use_suid = true;
        } else {
            $this->use_suid = false;
        }

        /*
................................................................................
            return false;
        }

        system('rm -f ' . escapeshellarg($this->absolute_path) . '/*.fossil');

        unlink("{$this->absolute_path_root}repository");
        rmdir("{$this->absolute_path_root}");


























        return true;
    }
}







|
|
|
|
|







 







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




13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568

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

        $fossil_config_file = dirname(__FILE__) . '/../config/fossil.cnf';
        $fossil_config = array();
        if (file_exists($fossil_config_file)) {
                $fossil_config = parse_ini_file($fossil_config_file);
        }
        if (isset($fossil_config['use_suid']) && $fossil_config['use_suid'] === '1') {
            $this->use_suid = true;
        } else {
            $this->use_suid = false;
        }

        /*
................................................................................
            return false;
        }

        system('rm -f ' . escapeshellarg($this->absolute_path) . '/*.fossil');

        unlink("{$this->absolute_path_root}repository");
        rmdir("{$this->absolute_path_root}");

        return true;
    }

    public function rebuildAllRepos() {
        if (!file_exists("{$this->absolute_path}")) {
            return false;
        }

        $sql = "SELECT name FROM repositories WHERE user_id = :id";
        $bind = array('id' => $this->user['id']);
        $result = Nano_Db::query($sql, $bind);
        if ($result === false) {
            return false;
        }

        foreach ($result as $repo_info) {
            $repo = $repo_info['name'];
            $repo_file = $this->repository_file($repo);
            $this->fossil($repo, array('rebuild', $repo_file, '--quiet', '--wal'), $output, $return, 7200);
            if ($return !== 0) {
                $outputstr = join("\n", $output);
                error_log("Failed while rebuilding {$repo_file}: {$outputstr}");
            }
        }

        return true;
    }
}

Changes to scripts/rebuild.php.

1
2
3
4
5
6
7





8
9




<?php

$repositories = glob('../repos/*/*.fossil');

foreach ($repositories as $repository) {
    echo $repository . "\n";
    system("fossil rebuild -R {$repository}");





    echo "\n";
}






|

|
|
|
>
>
>
>
>
|
|
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php

include('include.php');

$sql = "SELECT * FROM users"; 
if ($result = Nano_Db::query($sql)) {
	foreach ($result as $user) {
		$username = $user['username'];
		echo "Processing User: {$username}\n";
		$fossil = new Nano_Fossil($user);
		$result = $fossil->rebuildAllRepos();
		if (!$result) {
			echo "Failed!\n";
		}
	}
}

?>