2 econf.c -- configuration code
3 Copyright (C) 2018 Guus Sliepen <guus@meshlink.io>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <sys/types.h>
28 #include "meshlink_internal.h"
32 /// Generate a path to the main configuration file.
33 static void make_main_path(meshlink_handle_t *mesh, const char *conf_subdir, char *path, size_t len) {
38 snprintf(path, len, "%s" SLASH "%s" SLASH "meshlink.conf", mesh->confbase, conf_subdir);
41 /// Generate a path to a host configuration file.
42 static void make_host_path(meshlink_handle_t *mesh, const char *conf_subdir, const char *name, char *path, size_t len) {
48 snprintf(path, len, "%s" SLASH "%s" SLASH "hosts" SLASH "%s", mesh->confbase, conf_subdir, name);
51 /// Generate a path to an unused invitation file.
52 static void make_invitation_path(meshlink_handle_t *mesh, const char *conf_subdir, const char *name, char *path, size_t len) {
58 snprintf(path, len, "%s" SLASH "%s" SLASH "invitations" SLASH "%s", mesh->confbase, conf_subdir, name);
61 /// Generate a path to a used invitation file.
62 static void make_used_invitation_path(meshlink_handle_t *mesh, const char *conf_subdir, const char *name, char *path, size_t len) {
68 snprintf(path, len, "%s" SLASH "%s" SLASH "invitations" SLASH "%s.used", mesh->confbase, conf_subdir, name);
71 /// Remove a directory recursively
72 static void deltree(const char *dirname) {
75 DIR *d = opendir(dirname);
80 while((ent = readdir(d))) {
81 if(ent->d_name[0] == '.') {
85 char filename[PATH_MAX];
86 snprintf(filename, sizeof(filename), "%s" SLASH "%s", dirname, ent->d_name);
88 if(unlink(filename)) {
99 static bool sync_path(const char *pathname) {
102 int fd = open(pathname, O_RDONLY);
105 logger(NULL, MESHLINK_ERROR, "Failed to open %s: %s\n", pathname, strerror(errno));
106 meshlink_errno = MESHLINK_ESTORAGE;
111 logger(NULL, MESHLINK_ERROR, "Failed to sync %s: %s\n", pathname, strerror(errno));
113 meshlink_errno = MESHLINK_ESTORAGE;
118 logger(NULL, MESHLINK_ERROR, "Failed to close %s: %s\n", pathname, strerror(errno));
120 meshlink_errno = MESHLINK_ESTORAGE;
127 /// Try decrypting the main configuration file from the given sub-directory.
128 static bool main_config_decrypt(meshlink_handle_t *mesh, const char *conf_subdir) {
129 assert(mesh->config_key);
130 assert(mesh->confbase);
135 if(!main_config_read(mesh, conf_subdir, &config, mesh->config_key)) {
136 logger(mesh, MESHLINK_ERROR, "Could not read main configuration file");
140 packmsg_input_t in = {config.buf, config.len};
142 uint32_t version = packmsg_get_uint32(&in);
143 config_free(&config);
145 return version == MESHLINK_CONFIG_VERSION;
148 /// Create a fresh configuration directory
149 bool config_init(meshlink_handle_t *mesh, const char *conf_subdir) {
152 if(!mesh->confbase) {
156 if(mkdir(mesh->confbase, 0700) && errno != EEXIST) {
157 logger(mesh, MESHLINK_DEBUG, "Could not create directory %s: %s\n", mesh->confbase, strerror(errno));
163 // Create "current" sub-directory in the confbase
164 snprintf(path, sizeof(path), "%s" SLASH "%s", mesh->confbase, conf_subdir);
167 if(mkdir(path, 0700)) {
168 logger(mesh, MESHLINK_DEBUG, "Could not create directory %s: %s\n", path, strerror(errno));
172 make_host_path(mesh, conf_subdir, "", path, sizeof(path));
174 if(mkdir(path, 0700)) {
175 logger(mesh, MESHLINK_DEBUG, "Could not create directory %s: %s\n", path, strerror(errno));
179 make_invitation_path(mesh, conf_subdir, "", path, sizeof(path));
181 if(mkdir(path, 0700)) {
182 logger(mesh, MESHLINK_DEBUG, "Could not create directory %s: %s\n", path, strerror(errno));
189 /// Wipe an existing configuration directory
190 bool config_destroy(const char *confbase, const char *conf_subdir) {
201 // Check the presence of configuration base sub directory.
202 snprintf(path, sizeof(path), "%s" SLASH "%s", confbase, conf_subdir);
204 if(stat(path, &st)) {
205 if(errno == ENOENT) {
208 logger(NULL, MESHLINK_ERROR, "Cannot stat %s: %s\n", path, strerror(errno));
209 meshlink_errno = MESHLINK_ESTORAGE;
214 // Remove meshlink.conf
215 snprintf(path, sizeof(path), "%s" SLASH "%s" SLASH "meshlink.conf", confbase, conf_subdir);
218 if(errno != ENOENT) {
219 logger(NULL, MESHLINK_ERROR, "Cannot delete %s: %s\n", path, strerror(errno));
220 meshlink_errno = MESHLINK_ESTORAGE;
225 snprintf(path, sizeof(path), "%s" SLASH "%s", confbase, conf_subdir);
230 static bool copytree(const char *src_dir_name, const void *src_key, const char *dst_dir_name, const void *dst_key) {
231 assert(src_dir_name);
232 assert(dst_dir_name);
234 char src_filename[PATH_MAX];
235 char dst_filename[PATH_MAX];
238 DIR *src_dir = opendir(src_dir_name);
241 logger(NULL, MESHLINK_ERROR, "Could not open directory file %s\n", src_dir_name);
245 // Delete if already exists and create a new destination directory
246 deltree(dst_dir_name);
248 if(mkdir(dst_dir_name, 0700)) {
249 logger(NULL, MESHLINK_ERROR, "Could not create directory %s\n", dst_filename);
253 while((ent = readdir(src_dir))) {
254 if(ent->d_name[0] == '.') {
258 snprintf(dst_filename, sizeof(dst_filename), "%s" SLASH "%s", dst_dir_name, ent->d_name);
259 snprintf(src_filename, sizeof(src_filename), "%s" SLASH "%s", src_dir_name, ent->d_name);
261 if(ent->d_type == DT_DIR) {
262 if(!copytree(src_filename, src_key, dst_filename, dst_key)) {
263 logger(NULL, MESHLINK_ERROR, "Copying %s to %s failed\n", src_filename, dst_filename);
267 if(!sync_path(dst_filename)) {
270 } else if(ent->d_type == DT_REG) {
274 if(stat(src_filename, &st)) {
275 logger(NULL, MESHLINK_ERROR, "Could not stat file `%s': %s\n", src_filename, strerror(errno));
279 FILE *f = fopen(src_filename, "r");
282 logger(NULL, MESHLINK_ERROR, "Failed to open `%s': %s\n", src_filename, strerror(errno));
286 if(!config_read_file(NULL, f, &config, src_key)) {
287 logger(NULL, MESHLINK_ERROR, "Failed to read `%s': %s\n", src_filename, strerror(errno));
293 logger(NULL, MESHLINK_ERROR, "Failed to close `%s': %s\n", src_filename, strerror(errno));
294 config_free(&config);
298 f = fopen(dst_filename, "w");
301 logger(NULL, MESHLINK_ERROR, "Failed to open `%s': %s", dst_filename, strerror(errno));
302 config_free(&config);
306 if(!config_write_file(NULL, f, &config, dst_key)) {
307 logger(NULL, MESHLINK_ERROR, "Failed to write `%s': %s", dst_filename, strerror(errno));
308 config_free(&config);
314 logger(NULL, MESHLINK_ERROR, "Failed to close `%s': %s", dst_filename, strerror(errno));
315 config_free(&config);
319 config_free(&config);
321 struct utimbuf times;
322 times.modtime = st.st_mtime;
323 times.actime = st.st_atime;
325 if(utime(dst_filename, ×)) {
326 logger(NULL, MESHLINK_ERROR, "Failed to utime `%s': %s", dst_filename, strerror(errno));
336 bool config_copy(meshlink_handle_t *mesh, const char *src_dir_name, const void *src_key, const char *dst_dir_name, const void *dst_key) {
337 assert(src_dir_name);
338 assert(dst_dir_name);
340 char src_filename[PATH_MAX];
341 char dst_filename[PATH_MAX];
343 snprintf(dst_filename, sizeof(dst_filename), "%s" SLASH "%s", mesh->confbase, dst_dir_name);
344 snprintf(src_filename, sizeof(src_filename), "%s" SLASH "%s", mesh->confbase, src_dir_name);
346 return copytree(src_filename, src_key, dst_filename, dst_key);
349 /// Check the presence of the main configuration file.
350 bool main_config_exists(meshlink_handle_t *mesh, const char *conf_subdir) {
353 if(!mesh->confbase) {
358 make_main_path(mesh, conf_subdir, path, sizeof(path));
359 return access(path, F_OK) == 0;
362 bool config_rename(meshlink_handle_t *mesh, const char *old_conf_subdir, const char *new_conf_subdir) {
363 assert(old_conf_subdir);
364 assert(new_conf_subdir);
366 if(!mesh->confbase) {
370 char old_path[PATH_MAX];
371 char new_path[PATH_MAX];
373 snprintf(old_path, sizeof(old_path), "%s" SLASH "%s", mesh->confbase, old_conf_subdir);
374 snprintf(new_path, sizeof(new_path), "%s" SLASH "%s", mesh->confbase, new_conf_subdir);
376 return rename(old_path, new_path) == 0;
379 bool config_sync(meshlink_handle_t *mesh, const char *conf_subdir) {
382 if(!mesh->confbase) {
387 snprintf(path, sizeof(path), "%s" SLASH "%s" SLASH "hosts", mesh->confbase, conf_subdir);
389 if(!sync_path(path)) {
393 snprintf(path, sizeof(path), "%s" SLASH "%s", mesh->confbase, conf_subdir);
395 if(!sync_path(path)) {
402 bool meshlink_confbase_exists(meshlink_handle_t *mesh) {
403 if(!mesh->confbase) {
407 bool confbase_exists = false;
408 bool confbase_decryptable = false;
410 if(main_config_exists(mesh, "current")) {
411 confbase_exists = true;
413 if(mesh->config_key && main_config_decrypt(mesh, "current")) {
414 confbase_decryptable = true;
418 if(mesh->config_key && !confbase_decryptable && main_config_exists(mesh, "new")) {
419 confbase_exists = true;
421 if(main_config_decrypt(mesh, "new")) {
422 if(!config_destroy(mesh->confbase, "current")) {
426 if(!config_rename(mesh, "new", "current")) {
430 confbase_decryptable = true;
434 if(mesh->config_key && !confbase_decryptable && main_config_exists(mesh, "old")) {
435 confbase_exists = true;
437 if(main_config_decrypt(mesh, "old")) {
438 if(!config_destroy(mesh->confbase, "current")) {
442 if(!config_rename(mesh, "old", "current")) {
446 confbase_decryptable = true;
450 // Cleanup if current is existing with old and new
451 if(confbase_exists && confbase_decryptable) {
452 config_destroy(mesh->confbase, "old");
453 config_destroy(mesh->confbase, "new");
456 return confbase_exists;
459 /// Lock the main configuration file.
460 bool main_config_lock(meshlink_handle_t *mesh) {
461 if(!mesh->confbase) {
466 make_main_path(mesh, "current", path, sizeof(path));
468 mesh->conffile = fopen(path, "r");
470 if(!mesh->conffile) {
471 logger(NULL, MESHLINK_ERROR, "Cannot not open %s: %s\n", path, strerror(errno));
472 meshlink_errno = MESHLINK_ESTORAGE;
477 fcntl(fileno(mesh->conffile), F_SETFD, FD_CLOEXEC);
481 // TODO: use _locking()?
484 if(flock(fileno(mesh->conffile), LOCK_EX | LOCK_NB) != 0) {
485 logger(NULL, MESHLINK_ERROR, "Cannot lock %s: %s\n", path, strerror(errno));
486 fclose(mesh->conffile);
487 mesh->conffile = NULL;
488 meshlink_errno = MESHLINK_EBUSY;
497 /// Unlock the main configuration file.
498 void main_config_unlock(meshlink_handle_t *mesh) {
500 fclose(mesh->conffile);
501 mesh->conffile = NULL;
505 /// Read a configuration file from a FILE handle.
506 bool config_read_file(meshlink_handle_t *mesh, FILE *f, config_t *config, const void *key) {
511 if(fseek(f, 0, SEEK_END) || !(len = ftell(f)) || fseek(f, 0, SEEK_SET)) {
512 logger(mesh, MESHLINK_ERROR, "Cannot get config file size: %s\n", strerror(errno));
513 meshlink_errno = MESHLINK_ESTORAGE;
517 uint8_t *buf = xmalloc(len);
519 if(fread(buf, len, 1, f) != 1) {
520 logger(mesh, MESHLINK_ERROR, "Cannot read config file: %s\n", strerror(errno));
521 meshlink_errno = MESHLINK_ESTORAGE;
526 uint8_t *decrypted = xmalloc(len);
527 size_t decrypted_len = len;
528 chacha_poly1305_ctx_t *ctx = chacha_poly1305_init();
529 chacha_poly1305_set_key(ctx, key);
531 if(len > 12 && chacha_poly1305_decrypt_iv96(ctx, buf, buf + 12, len - 12, decrypted, &decrypted_len)) {
532 chacha_poly1305_exit(ctx);
534 config->buf = decrypted;
535 config->len = decrypted_len;
538 logger(mesh, MESHLINK_ERROR, "Cannot decrypt config file\n");
539 meshlink_errno = MESHLINK_ESTORAGE;
540 chacha_poly1305_exit(ctx);
553 /// Write a configuration file to a FILE handle.
554 bool config_write_file(meshlink_handle_t *mesh, FILE *f, const config_t *config, const void *key) {
558 uint8_t buf[config->len + 16];
559 size_t len = sizeof(buf);
561 randomize(&seqbuf, sizeof(seqbuf));
562 chacha_poly1305_ctx_t *ctx = chacha_poly1305_init();
563 chacha_poly1305_set_key(ctx, key);
564 bool success = false;
566 if(chacha_poly1305_encrypt_iv96(ctx, seqbuf, config->buf, config->len, buf, &len)) {
567 success = fwrite(seqbuf, sizeof(seqbuf), 1, f) == 1 && fwrite(buf, len, 1, f) == 1;
570 logger(mesh, MESHLINK_ERROR, "Cannot write config file: %s", strerror(errno));
573 meshlink_errno = MESHLINK_ESTORAGE;
575 logger(mesh, MESHLINK_ERROR, "Cannot encrypt config file\n");
576 meshlink_errno = MESHLINK_ESTORAGE;
579 chacha_poly1305_exit(ctx);
583 if(fwrite(config->buf, config->len, 1, f) != 1) {
584 logger(mesh, MESHLINK_ERROR, "Cannot write config file: %s", strerror(errno));
585 meshlink_errno = MESHLINK_ESTORAGE;
590 logger(mesh, MESHLINK_ERROR, "Failed to flush file: %s", strerror(errno));
591 meshlink_errno = MESHLINK_ESTORAGE;
595 if(fsync(fileno(f))) {
596 logger(mesh, MESHLINK_ERROR, "Failed to sync file: %s\n", strerror(errno));
597 meshlink_errno = MESHLINK_ESTORAGE;
604 /// Free resources of a loaded configuration file.
605 void config_free(config_t *config) {
606 assert(!config->len || config->buf);
608 free((uint8_t *)config->buf);
613 /// Check the presence of a host configuration file.
614 bool config_exists(meshlink_handle_t *mesh, const char *conf_subdir, const char *name) {
617 if(!mesh->confbase) {
622 make_host_path(mesh, conf_subdir, name, path, sizeof(path));
624 return access(path, F_OK) == 0;
627 /// Read a host configuration file.
628 bool config_read(meshlink_handle_t *mesh, const char *conf_subdir, const char *name, config_t *config, void *key) {
631 if(!mesh->confbase) {
636 make_host_path(mesh, conf_subdir, name, path, sizeof(path));
638 FILE *f = fopen(path, "r");
641 logger(mesh, MESHLINK_ERROR, "Failed to open `%s': %s", path, strerror(errno));
645 if(!config_read_file(mesh, f, config, key)) {
646 logger(mesh, MESHLINK_ERROR, "Failed to read `%s': %s", path, strerror(errno));
656 bool config_scan_all(meshlink_handle_t *mesh, const char *conf_subdir, const char *conf_type, config_scan_action_t action, void *arg) {
660 if(!mesh->confbase) {
666 char dname[PATH_MAX];
667 snprintf(dname, sizeof(dname), "%s" SLASH "%s" SLASH "%s", mesh->confbase, conf_subdir, conf_type);
669 dir = opendir(dname);
672 logger(mesh, MESHLINK_ERROR, "Could not open %s: %s", dname, strerror(errno));
673 meshlink_errno = MESHLINK_ESTORAGE;
677 while((ent = readdir(dir))) {
678 if(ent->d_name[0] == '.') {
682 if(!action(mesh, ent->d_name, arg)) {
692 /// Write a host configuration file.
693 bool config_write(meshlink_handle_t *mesh, const char *conf_subdir, const char *name, const config_t *config, void *key) {
698 if(!mesh->confbase) {
703 char tmp_path[PATH_MAX + 4];
704 make_host_path(mesh, conf_subdir, name, path, sizeof(path));
705 snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", path);
707 FILE *f = fopen(tmp_path, "w");
710 logger(mesh, MESHLINK_ERROR, "Failed to open `%s': %s", tmp_path, strerror(errno));
711 meshlink_errno = MESHLINK_ESTORAGE;
715 if(!config_write_file(mesh, f, config, key)) {
716 logger(mesh, MESHLINK_ERROR, "Failed to write `%s': %s", tmp_path, strerror(errno));
722 logger(mesh, MESHLINK_ERROR, "Failed to close `%s': %s", tmp_path, strerror(errno));
723 meshlink_errno = MESHLINK_ESTORAGE;
727 if(rename(tmp_path, path)) {
728 logger(mesh, MESHLINK_ERROR, "Failed to rename `%s' to `%s': %s", tmp_path, path, strerror(errno));
729 meshlink_errno = MESHLINK_ESTORAGE;
736 /// Read the main configuration file.
737 bool main_config_read(meshlink_handle_t *mesh, const char *conf_subdir, config_t *config, void *key) {
741 if(!mesh->confbase) {
746 make_main_path(mesh, conf_subdir, path, sizeof(path));
748 FILE *f = fopen(path, "r");
751 logger(mesh, MESHLINK_ERROR, "Failed to open `%s': %s", path, strerror(errno));
755 if(!config_read_file(mesh, f, config, key)) {
756 logger(mesh, MESHLINK_ERROR, "Failed to read `%s': %s", path, strerror(errno));
766 /// Write the main configuration file.
767 bool main_config_write(meshlink_handle_t *mesh, const char *conf_subdir, const config_t *config, void *key) {
771 if(!mesh->confbase) {
776 char tmp_path[PATH_MAX + 4];
777 make_main_path(mesh, conf_subdir, path, sizeof(path));
778 snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", path);
780 FILE *f = fopen(tmp_path, "w");
783 logger(mesh, MESHLINK_ERROR, "Failed to open `%s': %s", tmp_path, strerror(errno));
784 meshlink_errno = MESHLINK_ESTORAGE;
788 if(!config_write_file(mesh, f, config, key)) {
789 logger(mesh, MESHLINK_ERROR, "Failed to write `%s': %s", tmp_path, strerror(errno));
794 if(rename(tmp_path, path)) {
795 logger(mesh, MESHLINK_ERROR, "Failed to rename `%s' to `%s': %s", tmp_path, path, strerror(errno));
796 meshlink_errno = MESHLINK_ESTORAGE;
802 logger(mesh, MESHLINK_ERROR, "Failed to close `%s': %s", tmp_path, strerror(errno));
803 meshlink_errno = MESHLINK_ESTORAGE;
810 /// Read an invitation file from the confbase sub-directory, and immediately delete it.
811 bool invitation_read(meshlink_handle_t *mesh, const char *conf_subdir, const char *name, config_t *config, void *key) {
816 if(!mesh->confbase) {
821 char used_path[PATH_MAX];
822 make_invitation_path(mesh, conf_subdir, name, path, sizeof(path));
823 make_used_invitation_path(mesh, conf_subdir, name, used_path, sizeof(used_path));
825 // Atomically rename the invitation file
826 if(rename(path, used_path)) {
827 if(errno == ENOENT) {
828 logger(mesh, MESHLINK_ERROR, "Peer tried to use non-existing invitation %s\n", name);
830 logger(mesh, MESHLINK_ERROR, "Error trying to rename invitation %s\n", name);
836 FILE *f = fopen(used_path, "r");
839 logger(mesh, MESHLINK_ERROR, "Failed to open `%s': %s", path, strerror(errno));
843 // Check the timestamp
846 if(fstat(fileno(f), &st)) {
847 logger(mesh, MESHLINK_ERROR, "Could not stat invitation file %s\n", name);
853 if(mesh->loop.now.tv_sec >= st.st_mtime + mesh->invitation_timeout) {
854 logger(mesh, MESHLINK_ERROR, "Peer tried to use an outdated invitation file %s\n", name);
860 if(!config_read_file(mesh, f, config, key)) {
861 logger(mesh, MESHLINK_ERROR, "Failed to read `%s': %s", path, strerror(errno));
869 if(unlink(used_path)) {
870 logger(mesh, MESHLINK_ERROR, "Failed to unlink `%s': %s", path, strerror(errno));
874 snprintf(path, sizeof(path), "%s" SLASH "%s" SLASH "invitations", mesh->confbase, conf_subdir);
876 if(!sync_path(path)) {
877 logger(mesh, MESHLINK_ERROR, "Failed to sync `%s': %s", path, strerror(errno));
878 meshlink_errno = MESHLINK_ESTORAGE;
885 /// Write an invitation file.
886 bool invitation_write(meshlink_handle_t *mesh, const char *conf_subdir, const char *name, const config_t *config, void *key) {
891 if(!mesh->confbase) {
896 make_invitation_path(mesh, conf_subdir, name, path, sizeof(path));
898 FILE *f = fopen(path, "w");
901 logger(mesh, MESHLINK_ERROR, "Failed to open `%s': %s", path, strerror(errno));
902 meshlink_errno = MESHLINK_ESTORAGE;
906 if(!config_write_file(mesh, f, config, key)) {
907 logger(mesh, MESHLINK_ERROR, "Failed to write `%s': %s", path, strerror(errno));
913 logger(mesh, MESHLINK_ERROR, "Failed to close `%s': %s", path, strerror(errno));
914 meshlink_errno = MESHLINK_ESTORAGE;
918 snprintf(path, sizeof(path), "%s" SLASH "%s" SLASH "invitations", mesh->confbase, conf_subdir);
920 if(!sync_path(path)) {
921 logger(mesh, MESHLINK_ERROR, "Failed to sync `%s': %s", path, strerror(errno));
922 meshlink_errno = MESHLINK_ESTORAGE;
929 /// Purge old invitation files
930 size_t invitation_purge_old(meshlink_handle_t *mesh, time_t deadline) {
931 if(!mesh->confbase) {
936 make_invitation_path(mesh, "current", "", path, sizeof(path));
938 DIR *dir = opendir(path);
941 logger(mesh, MESHLINK_DEBUG, "Could not read directory %s: %s\n", path, strerror(errno));
942 meshlink_errno = MESHLINK_ESTORAGE;
950 while((ent = readdir(dir))) {
951 if(strlen(ent->d_name) != 24) {
955 char invname[PATH_MAX];
958 if(snprintf(invname, sizeof(invname), "%s" SLASH "%s", path, ent->d_name) >= PATH_MAX) {
959 logger(mesh, MESHLINK_DEBUG, "Filename too long: %s" SLASH "%s", path, ent->d_name);
963 if(!stat(invname, &st)) {
964 if(mesh->invitation_key && deadline < st.st_mtime) {
970 logger(mesh, MESHLINK_DEBUG, "Could not stat %s: %s\n", invname, strerror(errno));
976 logger(mesh, MESHLINK_DEBUG, "Error while reading directory %s: %s\n", path, strerror(errno));
978 meshlink_errno = MESHLINK_ESTORAGE;