Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame^] | 5 | #include "debugd/src/netif_tool.h" |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include <dbus-c++/dbus.h> |
| 10 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame^] | 11 | #include "debugd/src/process_with_output.h" |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 12 | |
Ben Chan | 55903dd | 2014-04-24 00:29:04 -0700 | [diff] [blame] | 13 | using base::StringPrintf; |
| 14 | |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 15 | namespace debugd { |
| 16 | |
| 17 | NetifTool::NetifTool() { } |
| 18 | |
| 19 | NetifTool::~NetifTool() { } |
| 20 | |
| 21 | std::string NetifTool::GetInterfaces(DBus::Error* error) { |
Ben Chan | 297c3c2 | 2013-07-17 17:34:12 -0700 | [diff] [blame] | 22 | std::string path; |
| 23 | if (!SandboxedProcess::GetHelperPath("netif", &path)) |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 24 | return "<path too long>"; |
Ben Chan | 297c3c2 | 2013-07-17 17:34:12 -0700 | [diff] [blame] | 25 | |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 26 | ProcessWithOutput p; |
| 27 | if (!p.Init()) |
| 28 | return "<can't create process>"; |
| 29 | p.AddArg(path); |
| 30 | p.Run(); |
| 31 | std::string out; |
| 32 | p.GetOutput(&out); |
| 33 | return out; |
| 34 | } |
| 35 | |
| 36 | } // namespace debugd |