static function readAuthorizedKey($username) { $p = os_get_home_dir($username); if ($p === '/tmp' && $username) { lxfile_mkdir("/home/{$username}"); lxshell_return("usermod", "-d", "/home/{$username}", $username); lxfile_unix_chown_rec("/home/{$username}", "{$username}:{$username}"); $p = "/home/{$username}"; } if (!$p) { return; } $f = "{$p}/.ssh/authorized_keys"; if (lxfile_exists("{$f}2")) { $s = lfile_get_contents("{$f}2"); $s = "\n{$s}\n"; lfile_put_contents($f, $s, FILE_APPEND); lunlink("{$f}2"); } return lfile_get_contents($f); }
function fixZshEtc() { return; // TODO: Remove /root/.etc/ global $global_dontlogshell; $global_dontlogshell = true; $dir = os_get_home_dir("root"); if (lxfile_exists("{$dir}/.etc")) { lxfile_cp("htmllib/filecore/lxetc/commands.shell", "{$dir}/.etc/"); return; } $ret = lxshell_return("rpm", "-q", "zsh", "vim-ehhanced"); if ($ret) { system("yum -y install zsh vim-enhanced"); } print "Copy LxEtc\n"; lxfile_cp_rec("htmllib/filecore/lxetc/", "{$dir}/.etc"); }
function remove_scpid($cont) { $home = os_get_home_dir("root"); $file = "{$home}/.ssh/authorized_keys2"; $list = lfile_trim($file); foreach ($list as $l) { if (!$l) { continue; } if ($l === $cont) { continue; } $nlist[] = $l; } lfile_put_contents($file, implode("\n", $nlist) . "\n"); }