Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13908] CLI: If the analytics config files in .titanium are not writable, the CLI crashes

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-06-05T20:55:21.000+0000
Affected Version/sRelease 3.1.0
Fix Version/s2013 Sprint 12 JS, 2013 Sprint 12, Release 3.2.0
ComponentsCLI
Labelsqe-closed-3.2.0
ReporterBryan Hughes
AssigneeChris Barber
Created2013-05-17T21:39:34.000+0000
Updated2013-12-13T19:53:48.000+0000

Description

if ~/.titanium/analytics.json or ~/.titanium/analytics_session.json are not writable by the user that the node process is running under, the CLI crashes. In practice, these files are mode 644 by default (writable only by the owner), so running node as anything other than the user that installed the CLI will cause a crash. An easy way to replicate:
sudo chown root:admin ~/.titanium/analytics.json ~/.titanium/analytics_session.json

Comments

  1. Bryan Hughes 2013-05-17

    PR: https://github.com/appcelerator/node-appc/pull/44 3_1_X: https://github.com/appcelerator/node-appc/pull/45
  2. Eric Merriman 2013-05-29

    After setting permissions in the "easy to replicate" area of the description, I ran "ti sdk". This fails. I also tried "ti create" which failed as well, here is some output:
       
       emerrimanMBP:.titanium emerriman$ 
       fs.js:338
         return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                        ^
       Error: EACCES, permission denied '/Users/emerriman/.titanium/analytics_session.json'
           at Object.fs.openSync (fs.js:338:18)
           at Object.fs.writeFileSync (fs.js:756:15)
           at /usr/local/lib/node_modules/titanium/node_modules/node-appc/lib/analytics.js:140:7
           at async.parallel (/usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:476:17)
           at async.forEach (/usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:94:25)
           at async.parallel (/usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:473:21)
           at process.on.async.parallel.osinfo (/usr/local/lib/node_modules/titanium/node_modules/node-appc/lib/analytics.js:56:5)
           at module.exports.getOSInfo (/usr/local/lib/node_modules/titanium/node_modules/node-appc/lib/environ.js:215:4)
           at ChildProcess.exithandler (child_process.js:538:7)
           at ChildProcess.EventEmitter.emit (events.js:99:17)
       
       
    I am using CLI 3.1.1 alpha
  3. Ingo Muschenetz 2013-05-30

    Not required for 3.1.1, since normal usage is not likely to uncover this bug. Moving to 3.2.0.
  4. Chris Barber 2013-06-05

    To test:
       sudo chown root:admin ~/.titanium/analytics.json ~/.titanium/analytics_session.json ~/.titanium/config.json ~/.titanium/auth_session.json
       
    *Test analytics not working:*
       titanium sdk
       
    *Result:* You should not see an exception dump *Check analytics.json is not writable*
       titanium
       
    *Result:*
       <snip>
       Required file ~/.titanium/analytics.json is not writable.
       Please ensure the Titanium CLI has access to modify this file.
       <snip>
       
    *Reset analytics.json owner*
       sudo chown whoami:staff ~/.titanium/analytics.json
       
    *Check analytics_session.json is not writable*
       titanium
       
    *Result:*
       <snip>
       Required file ~/.titanium/analytics_session.json is not writable.
       Please ensure the Titanium CLI has access to modify this file.
       <snip>
       
    *Reset analytics_session.json owner*
       sudo chown whoami:staff ~/.titanium/analytics_session.json
       
    *Check warnings are off*
       titanium
       
    *Result:* No warning message since both analytics files are now writable. *Check config file is not writable*
       titanium config user.age 21
       
    *Result:*
       [ERROR] Unable to write config file /Users/chris/.titanium/config.json
       [ERROR] Please ensure the Titanium CLI has access to modify this file.
       
    *Reset config.json owner*
       sudo chown whoami:staff ~/.titanium/config.json
       
    *Check warnings are off*
       titanium config user.age 21
       
    *Result:* user.age saved *Verify again:*
       titanium config user.age
       
    *Result:* 21 *Check auth_session.json not writable*
       titanium logout
       
    *Result:*
       [ERROR] Session file "/Users/chris/.titanium/auth_session.json" is not writable
       [ERROR] Please ensure the Titanium CLI has access to modify this file.
       [ERROR] You are still logged in
       
    *Reset auth_session.json owner*
       sudo chown whoami:staff ~/.titanium/auth_session.json
       
    *Logout*
       titanium logout
       
    *Result:* Logged out successfully *Change auth_session.json owner to root*
       sudo chown root:admin ~/.titanium/auth_session.json
       
    *Login*
       titanium login
       
    *Result*
       [ERROR] Session file "/Users/chris/.titanium/auth_session.json" is not writable
       [ERROR] Please ensure the Titanium CLI has access to modify this file.
       [ERROR] You are currently logged out
       
    *Reset auth_session.json owner*
       sudo chown whoami:staff ~/.titanium/auth_session.json
       
    *Login*
       titanium login
       
    *Result:* Logged in successfully
  5. Chris Barber 2013-06-05

    Node-appc master pull request: https://github.com/appcelerator/node-appc/pull/48 Titanium master pull request: https://github.com/appcelerator/titanium/pull/42
  6. Bryan Hughes 2013-06-05

    Note: the exact errors/messages I got were slightly different at times that the test instructions indicated, but everything worked as I would expect it too (probably due to what analytics were queued up, if any).
  7. Samuel Dowse 2013-12-13

    Verified fixed on: Mac OSX 10.9 Mavericks Titanium SDK, build: 3.2.0.v20131212122847 CLI: 3.2.0-cr Ran testcases provided in comments. All worked as expected. Closing.

JSON Source