Browse Source

Added check to make sure we don't add blank keys

tags/v1.1^2
Teknikode 6 years ago
parent
commit
9fcc3a2c0b
2 changed files with 12 additions and 14 deletions
  1. 1
    1
      includes/Git.php
  2. 11
    13
      includes/update_profile.php

+ 1
- 1
includes/Git.php View File

@@ -286,7 +286,7 @@ class GitRepo {
} else {
$env = array_merge($_ENV, $this->envopts);
}
print_r($env);
$cwd = $this->repo_path;
$resource = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
$stdout = stream_get_contents($pipes[1]);

+ 11
- 13
includes/update_profile.php View File

@@ -134,12 +134,7 @@ if(isset($_POST))
$Git = new Git();
$Git->windows_mode();
$repo = $Git->open($CONF['git_repo_path'][0].'gitolite-admin\\');
$repo->setenv('HOME', '/home/iusr');
echo "user: ".trim(shell_exec('whoami'))."<br />";
echo "uid: ".getmyuid()."<br />";
echo "gid: ".getmygid()."<br />";
echo "pid: ".getmypid()."<br />";
$repo->setenv('HOME', '/home/iusr')
$repo->pull('origin', 'master');
if (is_dir($CONF['git_repo_path'][0].'gitolite-admin\\keydir\\u\\'.$user->username))
@@ -159,13 +154,16 @@ if(isset($_POST))
foreach ($keys as $key)
{
preg_match($pattern, $key, $matches);
$key = "ssh-rsa " . $matches[2];
$keyFileName = $CONF['git_repo_path'][0].'gitolite-admin\\keydir\\u\\'.$user->username."\\".$user->username."@Key".$index.".pub";
$fileHandle = fopen($keyFileName, 'w');
fwrite($fileHandle, $key);
fclose($fileHandle);
$index++;
if (trim($matches[2]) != "")
{
$key = "ssh-rsa " . $matches[2];
$keyFileName = $CONF['git_repo_path'][0].'gitolite-admin\\keydir\\u\\'.$user->username."\\".$user->username."@Key".$index.".pub";
$fileHandle = fopen($keyFileName, 'w');
fwrite($fileHandle, $key);
fclose($fileHandle);
$index++;
}
}
$repo->add('.');
$repo->commit('Modified keys for '.$user->username);

Loading…
Cancel
Save