cyclid-lxd-plugin 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28191bf50cd5de65833791d6de820ca8e16b5e9e
4
- data.tar.gz: fee02e95b7031694e032d00b13aa58136f338951
3
+ metadata.gz: e80ccc304ef0f78bf3f751b3ecbf54e2643ded81
4
+ data.tar.gz: f84ddd8155cbb87826aca0053b7059d3e025568c
5
5
  SHA512:
6
- metadata.gz: 792ea700154e73b4ded74ec0e31fe9d4270044fcc8f0c987dfba61694d4647866b7b700b1f20a827a871fa547a10858b44588bb850bdf5b9bc71774c43431467
7
- data.tar.gz: 10995f857e821416149dfe18907e46539f5d98f0d13a8426b7673a7371711085c940af54177dc467a2a61baa291d4af1ff25d5c5edb14be8f0f8733e13bbf377
6
+ metadata.gz: cb140871d9551c64dc377f410b9a0c7c5f9c833ed83050a5ce67fc40d1741a7958aa066ae28590ff27b2adc15374203729dfd5bf7c1c3e5f597d4d8c2e12ad69
7
+ data.tar.gz: 8e2e30db75e1623140300e5650c0e082c6dd8df306bd29a15c8530cf0410d3dfdbb18b9f1c4ada5658563be6bf23b9740b626d5b577ab6c22dbe94f9c2cc2e39
@@ -46,9 +46,12 @@ module Cyclid
46
46
  client_key: @config[:client_key])
47
47
 
48
48
  # Grab some data from the context
49
+ Cyclid.logger.debug "lxdapi args=#{args.inspect}"
49
50
  ctx = args[:ctx]
50
51
  @base_env = { 'HOME' => ctx[:workspace],
51
52
  'TERM' => 'xterm-mono' }
53
+
54
+ @username = ctx[:username]
52
55
  end
53
56
 
54
57
  # Execute a command via. the LXD API
@@ -79,9 +82,11 @@ module Cyclid
79
82
  ws.on :message do |msg|
80
83
  close if msg.data.empty?
81
84
  # Strip out any XTerm control characters and convert lint endings
82
- data = msg.data.force_encoding('UTF-8')
83
- .gsub(/\r\n/, "\n")
84
- .gsub(/\r+/, "\n")
85
+ data = msg.data.encode('US-ASCII',
86
+ invalid: :replace,
87
+ undef: :replace,
88
+ universal_newline: true)
89
+ .squeeze("\n")
85
90
  .gsub(/\033\[(.?\d+\D?|\w+)/, '')
86
91
 
87
92
  log.write data
@@ -154,7 +159,11 @@ module Cyclid
154
159
  def build_command(cmd, path = nil)
155
160
  command = []
156
161
  command << "cd #{path}" if path
157
- command << cmd
162
+ command << if @username == 'root'
163
+ cmd
164
+ else
165
+ "sudo -E #{cmd}"
166
+ end
158
167
  "sh -l -c '#{command.join(';')}'"
159
168
  end
160
169
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclid-lxd-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Van Der Vliet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-15 00:00:00.000000000 Z
11
+ date: 2016-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hyperkit
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: websocket-client-simple
29
29
  requirement: !ruby/object:Gem::Requirement