Bug 1093197 - Errors in user_vars/* files block ssh access, git access
Summary: Errors in user_vars/* files block ssh access, git access
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Containers
Version: 1.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Jhon Honce
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks: 1096833
TreeView+ depends on / blocked
 
Reported: 2014-04-30 22:00 UTC by ziff
Modified: 2014-07-15 10:28 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1096833 (view as bug list)
Environment:
Last Closed: 2014-07-15 10:28:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
user_var_file_bug_connexion (14 bytes, application/octet-stream)
2014-04-30 22:00 UTC, ziff
no flags Details

Description ziff 2014-04-30 22:00:08 UTC
Created attachment 891318 [details]
user_var_file_bug_connexion

Description of problem:
I have post in my user_vars some fileto put some envirronement variable.

the directory is : 
/var/lib/openshift/XXXXX/.env/user_vars

the file content some special character and are not printable.
I attach and example of the file.

then i quit my ssh session.

Now I want to log in again and I got and error.

I can't log in via ssh ( putty / winscp) and I can't commit to git via eclipse.

I can do nothing.

Here is the last log report: 
ssh://XXXXX.com/~/git/jbossews.git/: Traceback (most recent call last):
  File "/usr/bin/oo-trap-user", line 171, in <module>
    gear_env()
  File "/usr/bin/oo-trap-user", line 63, in gear_env
    load_env('~/.env')
  File "/usr/bin/oo-trap-user", line 49, in load_env
    load_env(os.path.join(directory, entry))
  File "/usr/bin/oo-trap-user", line 56, in load_env
    os.environ[env] = file.read().rstrip()
  File "/usr/lib64/python2.6/os.py", line 471, in __setitem__
    putenv(key, item)
TypeError: putenv() argument 2 must be string without null bytes, not str


Version-Release number of selected component (if applicable):


How reproducible:

put in .env/user_vars some file with special caracter not printable ( TEST attach )
exit session
You are now enable to re-connect

Steps to Reproduce:
1.put in .env/user_vars some file with special caracter not printable ( TEST attach )
2.exit session
3.You are now enable to re-connect

Actual results:
 Enable to connect to gear via ssh( putty / winscp / eclipse)

Expected results:

Is there a walk around to delete the file user_vars ? 

I want to be able to connect to my gear via ssh.


Additional info:

Comment 2 ziff 2014-05-02 06:20:21 UTC
I try to override the wrong file in user_vars using the command rhc scp upload but I had an error message : "Remote file, file_path, or directory could not be found."

C:\temp\open>rhc scp -a app -t upload -l ./TEST -r .env/uservars/
Remote file, file_path, or directory could not be found.


I dont know if I am badly using the command or if the scp ( ssh) command is not working.

Comment 3 ziff 2014-05-02 06:22:13 UTC
using user_vars give the same result.

C:\temp\open>rhc scp -a jbossews -t upload -l ./TEST -r .env/user_vars/
Remote file, file_path, or directory could not be found.

Comment 4 Luke Meyer 2014-05-02 13:30:42 UTC
Reassigning to OpenShift Online product corresponding to rhcloud.com in comments.

Comment 5 Luke Meyer 2014-05-02 17:24:16 UTC
FWIW Jhon I set component to node because it sounds like the user succeeded in setting an env var that completely breaks the ability to interact with the gear via ssh. So not really a CLI issue.

Comment 6 Jordan Liggitt 2014-05-02 18:27:27 UTC
Looks like oo-trap-user needs to handle exceptions around this line:
load_env('~/.env/user_vars')

Comment 7 Fabiano Franz 2014-05-02 18:33:43 UTC
Not a rhc issue, user can't ssh/scp/git to the gear.

Comment 8 Jordan Liggitt 2014-05-02 18:36:11 UTC
We'll work on preventing a bad file in the user_vars dir from breaking ssh login. If you can provide the broken username and app name in a private comment, we can work to fix your specific gear to let you log in.

Comment 9 Jordan Liggitt 2014-05-02 19:00:41 UTC
There were some permission errors on the files under user_vars, which we were able to resolve. Please verify you can log in now.

Comment 10 Andy Grimm 2014-05-02 19:03:01 UTC
The problem when I looked into this was different.  It was actually a permissions issue on the user env variables, which I fixed manually.

By the way, handling exceptions around load_env could be bad.  It would be better to handle them around this:

        with open(entry, 'r') as file:
            os.environ[env] = file.read().rstrip()

Otherwise, critical env vars could be skipped depending on how early the broken file is evaluated.

Comment 11 Jordan Liggitt 2014-05-02 19:06:33 UTC
Either permission errors or file format errors can trigger this exception

Comment 13 ziff 2014-05-02 20:15:39 UTC

(In reply to Jordan Liggitt from comment #9)
> There were some permission errors on the files under user_vars, which we
> were able to resolve. Please verify you can log in now.

Thanks you all.

I succeed log in to my gear.

the file under user_vars have been replaced by good file.

[jbossews-xxxx.rhcloud.com yyyyyyyyyyyyyyyyyyyyyyy]\> ls -al .env/user_vars/
total 24
drwxrwx---. 2 root                     yyyyyyyyyyyyyyyyyyyyyyy 4096 Apr 29 15:45 .
drwxr-x---. 3 root                     yyyyyyyyyyyyyyyyyyyyyyy 4096 Apr  9 04:02 ..
-rw-r-----. 1 root                     yyyyyyyyyyyyyyyyyyyyyyy    4 May  1 15:18 XXXXCONNEXION
-rw-r-----. 1 root                     yyyyyyyyyyyyyyyyyyyyyyy    4 May  1 15:19 YYYYCONNEXION
-rw-------. 1 yyyyyyyyyyyyyyyyyyyyyyy yyyyyyyyyyyyyyyyyyyyyyy    1 Apr 29 15:20 TMOUT
-rw-r-----. 1 root                     yyyyyyyyyyyyyyyyyyyyyyy    4 May  1 15:18 ZZZZCONNEXION

Comment 15 Jhon Honce 2014-05-05 23:55:22 UTC
Fixed in https://github.com/openshift/origin-server/pull/5380

Comment 16 Wenjing Zheng 2014-05-06 07:36:27 UTC
Veirified on devenv_4762. git push, ssh works well after the file wich special strings under .env/user_vars.

1. Create an app
2. Copy a file which contains special strings to .env/user_vars
[wzheng@dhcp-65-16 apps]$ rhc scp app1 upload TEST .env/user_vars/
 uploading TEST: 100% complete. 14/14 bytes transferred in 4.500863736 seconds 
3. SSH to the app to check
[app1-d.dev.rhcloud.com 5368c4b580062c43f8000008]\> ls .env/user_vars/
TEST
4. Make some changes in local repo and git push, no error appeas:
[master fd4bdd5] p
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 123
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 285 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
remote: Stopping PHP 5.3 cartridge (Apache+mod_php)
remote: Waiting for stop to finish
remote: Waiting for stop to finish
remote: Building git ref 'master', commit fd4bdd5
remote: Checking .openshift/pear.txt for PEAR dependency...
remote: Preparing build for deployment
remote: Deployment id is f53226ad
remote: Activating deployment
remote: Starting PHP 5.3 cartridge (Apache+mod_php)
remote: Application directory "/" selected as DocumentRoot
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
To ssh://5368c4b580062c43f8000008.rhcloud.com/~/git/app1.git/
   3a3e3e4..fd4bdd5  master -> master


Note You need to log in before you can comment on or make changes to this bug.