Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 621662
Collapse All | Expand All

(-)a/routing.c (-1 / +12 lines)
Lines 112-124 void routing_init(char *ip) { Link Here
112
#endif /* Solaris */ 
112
#endif /* Solaris */ 
113
#if defined(__linux)
113
#if defined(__linux)
114
  char buf[256];
114
  char buf[256];
115
  char tbuf[256];
116
  const char * uidStart;
115
  FILE *p;
117
  FILE *p;
116
118
117
  snprintf(buf, 255, "%s route get %s", IP_BINARY, ip);
119
  snprintf(buf, 255, "%s route get %s", IP_BINARY, ip);
118
  p = popen(buf, "r");
120
  p = popen(buf, "r");
119
  fgets(buf, 255, p);
121
  fgets(buf, 255, p);
120
  /* TODO: check for failure of fgets */
122
  /* TODO: check for failure of fgets */
121
  route = strdup(buf);
123
  /* Starting with iproute2 4.10.0, call to 'ip route get' will contain uid value.
124
   * Still uid should not be used in other calls (i.e. replace, delete). */
125
  uidStart = strstr(buf, " uid");
126
  if (uidStart) {
127
    snprintf(tbuf, uidStart - buf + 1, "%s", buf);
128
    route = strdup(tbuf);
129
  }
130
  else {
131
    route = strdup(buf);
132
  }
122
  pclose(p);
133
  pclose(p);
123
  /* TODO: check for failure of command */
134
  /* TODO: check for failure of command */
124
#endif /* __linux__ */
135
#endif /* __linux__ */

Return to bug 621662