blob: 628426370a74237c4be3efb7c86672a0ef32fa7a [file] [log] [blame]
Elly Jonesad1e9d92012-07-20 15:39:23 -04001// 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
13namespace debugd {
14
15NetifTool::NetifTool() { }
16
17NetifTool::~NetifTool() { }
18
19std::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