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 | |
| 5 | #include "netif_tool.h" |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include <dbus-c++/dbus.h> |
| 10 | |
| 11 | #include "process_with_output.h" |
| 12 | |
| 13 | namespace debugd { |
| 14 | |
| 15 | NetifTool::NetifTool() { } |
| 16 | |
| 17 | NetifTool::~NetifTool() { } |
| 18 | |
| 19 | std::string NetifTool::GetInterfaces(DBus::Error* error) { |
| 20 | char *envvar = getenv("DEBUGD_HELPERS"); |
| 21 | std::string path = StringPrintf("%s/netif", envvar ? envvar |
| 22 | : "/usr/libexec/debugd/helpers"); |
| 23 | if (path.length() > PATH_MAX) |
| 24 | return "<path too long>"; |
| 25 | ProcessWithOutput p; |
| 26 | if (!p.Init()) |
| 27 | return "<can't create process>"; |
| 28 | p.AddArg(path); |
| 29 | p.Run(); |
| 30 | std::string out; |
| 31 | p.GetOutput(&out); |
| 32 | return out; |
| 33 | } |
| 34 | |
| 35 | } // namespace debugd |