This file is indexed.

/usr/share/ifupdown2/ifupdown/graph.py is in ifupdown2 1.0~git20170314-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/python
#
# Copyright 2014 Cumulus Networks, Inc. All rights reserved.
# Author: Roopa Prabhu, roopa@cumulusnetworks.com
#
# graph --
#    graph helper module for ifupdown
#

import logging
import copy
from collections import deque
try:
    from gvgen import *
except ImportError, e:
    pass

class graph():
    """ graph functions to sort and print interface graph """

    logger = logging.getLogger('ifupdown.graph')

    @classmethod
    def topological_sort_graphs_all(cls, dependency_graphs, indegrees_arg):
        """ runs topological sort on interface list passed as dependency graph

        Args:
            **dependency_graphs** (dict): dependency graph with dependency
                                          lists for interfaces 

            **indegrees_arg** (dict): indegrees array for all interfaces
        """
        S = []
        Q = deque()

        indegrees = copy.deepcopy(indegrees_arg)
        for ifname,indegree in indegrees.items():
            if indegree == 0:
                Q.append(ifname)

        while len(Q):
            # initialize queue
            x = Q.popleft()

            # Get dependents of x
            dlist = dependency_graphs.get(x)
            if not dlist:
                S.append(x)
                continue

            for y in dlist:
                try:
                    indegrees[y] = indegrees.get(y) - 1
                except:
                    cls.logger.debug('topological_sort_graphs_all: did not find %s' %y)
                    indegrees[y] = 0
                    pass
                if indegrees.get(y) == 0:
                    Q.append(y)

            S.append(x)

        for ifname,indegree in indegrees.items():
            if indegree != 0:
                raise Exception('cycle found involving iface %s' %ifname +
                                ' (indegree %d)' %indegree)

        return S

    @classmethod
    def generate_dots(cls, dependency_graph, indegrees):
        """ spits out interface dependency graph in dot format

        Args:
            **dependency_graphs** (dict): dependency graph with dependency
                                          lists for interfaces 

            **indegrees_arg** (dict): indegrees array for all interfaces
        """

        gvgraph = GvGen()
        graphnodes = {}
        for v in dependency_graph.keys():
            graphnodes[v] = gvgraph.newItem(v)

        for i, v in graphnodes.items():
            dlist = dependency_graph.get(i, [])
            if not dlist:
                continue
            for d in dlist:
                gvgraph.newLink(v, graphnodes.get(d))
        gvgraph.dot()