My application used to run fine on PHP 5.4.34 on Amazon Linux server. We upgraded to PHP 5.5.18 in order to use some of the newer libraries. Now the phpseclib generates an error:
Undefined offset: 5827 in /var/www/lib/ShellClient/phpseclib/Math/BigInteger.php on line 1073
In this app I login via Net_SSH2 and execute command another Amazon Linux server.
I start with Crypt_RSA and Net_SSH2
The following code gives notice in infinite loop:
$key = new \Crypt_RSA();
$key->loadKey(file_get_contents([PUBLIC_KEY]));
$ssh = new \Net_SSH2([IP_ADDRESS]], 22);
if(!$ssh->login([USERNAME]], $key)){
return false;
}
$ssh->exec([COMMAND]]);
return true;
The error is in the BigInteger.php in function _subtract, which is used by Net_SSH2).
PHP Notice: Undefined offset: 5827 in /var/www/lib/ShellClient/phpseclib/Math/BigInteger.php on line 1073
if ($carry) {
for (; !$x_value[$i]; ++$i) { //1073
$x_value[$i] = MATH_BIGINTEGER_MAX_DIGIT;
}
--$x_value[$i];
}
Before my app ran on PHP 5.4.34 and login via NetSSH2 worked properly without any warnings.
This problem has been fixed in phpseclib 0.3.9.
My guess: you're not running the latest version of phpseclib. The latest version is 0.3.8. The issue you're describing sounds like https://github.com/phpseclib/phpseclib/pull/331 which has been fixed since 0.3.7.
Related
Using interactive Glue Sessions in a Jupyter Notebook was working correctly with the aws-glue-sessions package version 0.32 installed. After upgrading with pip3 install --upgrade jupyter boto3 aws-glue-sessions to version 0.35, the kernel would not start. Gave an error message in GlueKernel.py line 443 in set_glue_version Exception: Valid Glue versions are {'3.0', '2,0} and the Kernel won't start.
Reverting to version 0.32 resolves the issue. Tried installing 0.35, 0.34, 0.33 and get the error, which makes me think it's something I'm doing wrong or don't understand and not something in the product. Is there anything additional I need to do to upgrade the version of the aws-glue-sessions?
Obviously this is not a good workaround - but it worked for me.
I went into the file GlueKernel.py in the directory: \site-packages\aws_glue_interactive_sessions_kernel\glue_pyspark
and hard-coded the 2nd line of this function to set the version to "3.0"
I'm on windows
def set_glue_version(self, glue_version):
glue_version = str("3.0")
if glue_version not in VALID_GLUE_VERSIONS:
raise Exception(f"Valid Glue versions are {VALID_GLUE_VERSIONS}")
self.glue_version = glue_version
I am a bit lost here as well -- and confused. I will add that I am a python newbie. I am running the whole thing on Windows. AWS has an article that describes the installation. So, I am assuming it's supported. I get the same error as #theOtherOne.
line 443 in set_glue_version Exception: Valid Glue versions are {'3.0', '2,0}
I checked GlueKernel.py of glue_pyspark, and found this code:
def _retrieve_os_env_variable(self, key):
_, output = subprocess.getstatusoutput(f"echo ${key}")
return output or os.environ.get(key)
When I run the code below manually, I get $GLUE_VERSION as final result. That obviously doesn't match '2.0' or '3.0'. The command for retrieving environment variables on Windows is a different one. If my understanding is correct, then this whole thing will never work on Windows. Maybe I am the only one who wants to run it on Windows and no one else cares? I got it to work on WSL, but still. I lost quite some time to fix something that cannot be fixed (or can it?)
import subprocess
import os
_, output = subprocess.getstatusoutput(f"echo $GLUE_VERSION")
osoutput = os.environ.get("GLUE_VERSION")
print(output) #$GLUE_VERSION
print (osoutput) #'3.0'
print(output or osoutput) #$GLUE_VERSION
enter image description here
So the issue seems to be that GLUE_VERSION is not set in the environment variables. Once this is set - it works
I have a container that is built to run selenium-chromedriver with python to download an excel(.xlsx) file from a website.
I am Using SAM to build & deploy this image to be run in AWS Lambda.
When I build the container and invoke it locally, the program executes as expected: The download occurs and I can see the file placed in the root directory of the container.
The problem is: when I deploy this image to AWS and invoke my lambda function I get no errors, however, my download is never executed. The file never appears in my root directory.
My first thought was that maybe I didn't allocate enough memory to the lambda instance. I gave it 512 MB, and the logs said it was using 416MB. Maybe there wasn't enough room to fit another file inside? So I have increased the memory provided to 1024 MB, but still no luck.
My next thought was that maybe the download was just taking a long time, so I also allowed the program to wait for 5 minutes after clicking the download to ensure that the download is given time to complete. Still no luck.
I have also tried setting the following options for chromedriver (full list of chromedriver options posted at bottom):
options.add_argument(f"--user-data-dir={'/tmp'}"),
options.add_argument(f"--data-path={'/tmp'}"),
options.add_argument(f"--disk-cache-dir={'/tmp'}")
and also setting tempfolder = mkdtemp() and passing that into the chrome options as above in place of /tmp. Still no luck.
Since this applicaton is in a container, it should run the same locally as it does on AWS. So I am wondering if it is part of the config outside of the container that is blocking my ability to download a file? Maybe the request is going out but the response is not being allowed back in?
Please let me know if there is anything I need to clarify -- Any help on this issue is greatly appreciated!
Full list of Chromedriver options
options.binary_location = '/opt/chrome/chrome'
options.headless = True
options.add_argument('--disable-extensions')
options.add_argument('--no-first-run')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--disable-client-side-phishing-detection')
options.add_argument('--allow-running-insecure-content')
options.add_argument('--disable-web-security')
options.add_argument('--lang=' + random.choice(language_list))
options.add_argument('--user-agent=' + fake_user_agent.user_agent())
options.add_argument('--no-sandbox')
options.add_argument("--window-size=1920x1080")
options.add_argument("--single-process")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-dev-tools")
options.add_argument("--no-zygote")
options.add_argument(f"--user-data-dir={'/tmp'}")
options.add_argument(f"--data-path={'/tmp'}")
options.add_argument(f"--disk-cache-dir={'/tmp'}")
options.add_argument("--remote-debugging-port=9222")
options.add_argument("start-maximized")
options.add_argument("enable-automation")
options.add_argument("--headless")
options.add_argument("--disable-browser-side-navigation")
options.add_argument("--disable-gpu")
driver = webdriver.Chrome("/opt/chromedriver", options=options)```
Just in case anybody stumbles across this queston in future, adding the following to chrome options solved my issue:
prefs = {
"profile.default_content_settings.popups": 0,
"download.default_directory": r"/tmp",
"directory_upgrade": True
}
options.add_experimental_option("prefs", prefs)
I have an Rmarkdown code to generate a report for multiple parameters. Therefore I am using the knit_child function in a loop where the first iteration runs fine but then it hangs infinitely and never begins a second iteration.
On my desktop (Ubuntu 18.04) the code works fine and the pdf report is generated but on our server (CentOS Linux release 7.1.1503 (Core)) the mentioned problem appears. Based on some research I tried to update pandoc (to version 2.7.2) but the problem persists. There is no difference if I run my scripts from the command line or RStudio.
for (spec in params$species) {
out = tryCatch(c(out, knit_child('child.Rmd')), error = function(e) e)
if (inherits(out, "error")) {
next
}
}
There are no errors, the script just does not move on to the next iteration. If I only provide one species the pdf is generated but not if I want to loop through multiple.
I'm getting an ora-1017 error when trying to connect to my local oracle database(version 11.2.0.3) on an oracle linux version 5 virtual machine using occi.
Connection code piece:
user = "MY_USERNAME";
passwd = "MY_PASSWORD";
db = "localhost:1521/my_instance_name";
env = Environment::createEnvironment(Environment::DEFAULT);
try
{
con = env->createConnection(user, passwd, db);
}
catch (SQLException& ex)
{
cout << ex.getMessage();
exit(EXIT_FAILURE);
}
- I can connect to the schema using sqlplus.
- I tried setting SEC_CASE_SENSITIVE_LOGON to false, didn't help.
- The schema was created using uppercase username and password, I'm giving my variables uppercase values too, and as far as I know OCCI casts the credentials to uppercase anyway so it should work.
- ORACLE_SID environment variable is properly set, as well as the tnsnames.ora data too.
- By the way, this code was tested first on my host pc(win10) using visual studio 2010, and it was working properly, but not on my linux virtual machine(using virtualbox). I tried it using the host stated in tnsnames.ora and localhost both, still getting the same issue, but sqlplus lets me connect using both localhost and the tnsnames host.
I tried everything I could find on google, but still nothing, so if anyone has any useful tips it would be highly appreciated.
Turned out I needed to add the -D_GLIBCXX_USE_CXX11_ABI=0 flag to the compile command, it works now.
When I use the Net_SSH2 library and the read/write functions like this:
$ssh = new Net_SSH2($strServerIPAddress);
if(!$ssh->login($strServerUsername, $strServerPassword))
die("error");
$ssh->write(" service httpd reload\n");
$strApacheRestartResult = $ssh->read("[root#$strServerName ~]#");
$ssh->disconnect();
I get funny characters in the read function results ($strApacheRestartResult) that I dont see when running the same thing via Putty, see below:
service httpd reload
Reloading httpd: [60G[[0;31mFAILED[0;39m]
[root#server1 ~]#
Why are these [60G[[0;31m and [0;39m] in the return data from the read function?
They're ANSI control codes. Their purpose is to control the formatting of the text and the color and what not. To decode them properly you'd need a terminal emulator. phpseclib has one called File_ANSI:
http://phpseclib.sourceforge.net/ssh/examples.html#top
Here's your code rewritten to use it:
$ssh = new Net_SSH2($strServerIPAddress);
$ansi = new File_ANSI();
if(!$ssh->login($strServerUsername, $strServerPassword))
die("error");
$ssh->write(" service httpd reload\n");
$ansi->appendString($ssh->read("[root#$strServerName ~]#"));
echo $ansi->getScreen();
$ssh->disconnect();