return 0;
}
-#define FOLLOW_MAX 8
+int config_parse_bindtodevice(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
-static char *build_path(const char *path, const char *filename) {
- char *e, *r;
- size_t k;
+ Socket *s = data;
+ char *n;
- assert(path);
assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
- /* This removes the last component of path and appends
- * filename, unless the latter is absolute anyway or the
- * former isn't */
-
- if (path_is_absolute(filename))
- return strdup(filename);
+ if (rvalue[0] && !streq(rvalue, "*")) {
+ if (!(n = strdup(rvalue)))
+ return -ENOMEM;
+ } else
+ n = NULL;
- if (!(e = strrchr(path, '/')))
- return strdup(filename);
+ free(s->bind_to_device);
+ s->bind_to_device = n;
- k = strlen(filename);
- if (!(r = new(char, e-path+1+k+1)))
- return NULL;
+ return 0;
+}
- memcpy(r, path, e-path+1);
- memcpy(r+(e-path)+1, filename, k+1);
+#define FOLLOW_MAX 8
- return r;
-}
static int open_follow(char **filename, FILE **_f, Set *names, char **_id) {
unsigned c = 0;
if ((r = readlink_malloc(*filename, &target)) < 0)
return r;
- k = build_path(*filename, target);
+ k = file_in_same_dir(*filename, target);
free(target);
if (!k)
{ "ListenFIFO", config_parse_listen, &u->socket, "Socket" },
{ "BindIPv6Only", config_parse_socket_bind, &u->socket, "Socket" },
{ "Backlog", config_parse_unsigned, &u->socket.backlog, "Socket" },
+ { "BindToDevice", config_parse_bindtodevice, &u->socket, "Socket" },
{ "ExecStartPre", config_parse_exec, u->socket.exec_command+SOCKET_EXEC_START_PRE, "Socket" },
{ "ExecStartPost", config_parse_exec, u->socket.exec_command+SOCKET_EXEC_START_POST, "Socket" },
{ "ExecStopPre", config_parse_exec, u->socket.exec_command+SOCKET_EXEC_STOP_PRE, "Socket" },