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 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 7 | #include "debugd/src/process_with_output.h" |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 8 | |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 9 | namespace debugd { |
| 10 | |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 11 | std::string NetifTool::GetInterfaces(DBus::Error* error) { |
Ben Chan | 297c3c2 | 2013-07-17 17:34:12 -0700 | [diff] [blame] | 12 | std::string path; |
| 13 | if (!SandboxedProcess::GetHelperPath("netif", &path)) |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 14 | return "<path too long>"; |
Ben Chan | 297c3c2 | 2013-07-17 17:34:12 -0700 | [diff] [blame] | 15 | |
Elly Jones | ad1e9d9 | 2012-07-20 15:39:23 -0400 | [diff] [blame] | 16 | ProcessWithOutput p; |
| 17 | if (!p.Init()) |
| 18 | return "<can't create process>"; |
| 19 | p.AddArg(path); |
| 20 | p.Run(); |
| 21 | std::string out; |
| 22 | p.GetOutput(&out); |
| 23 | return out; |
| 24 | } |
| 25 | |
| 26 | } // namespace debugd |