From 9df4f39c77aa66da992c7632d4ad5847e63d9f16 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 29 Aug 2024 17:22:51 +0200 Subject: [PATCH] Improve error messages for base directory creation --- unix/vncpasswd/vncpasswd.cxx | 5 +++-- unix/vncserver/vncsession.c | 2 +- vncviewer/ServerDialog.cxx | 4 ++-- vncviewer/parameters.cxx | 4 ++-- vncviewer/vncviewer.cxx | 9 ++++++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx index 9f794e12..9833ec7b 100644 --- a/unix/vncpasswd/vncpasswd.cxx +++ b/unix/vncpasswd/vncpasswd.cxx @@ -209,12 +209,13 @@ int main(int argc, char** argv) if (fname[0] == '\0') { const char *configDir = os::getvncconfigdir(); if (configDir == nullptr) { - fprintf(stderr, "Can't obtain VNC config directory\n"); + fprintf(stderr, "Could not determine VNC config directory path\n"); exit(1); } if (os::mkdir_p(configDir, 0777) == -1) { if (errno != EEXIST) { - fprintf(stderr, "Could not create VNC config directory: %s\n", strerror(errno)); + fprintf(stderr, "Could not create VNC config directory \"%s\": %s\n", + configDir, strerror(errno)); exit(1); } } diff --git a/unix/vncserver/vncsession.c b/unix/vncserver/vncsession.c index a10e0789..0830e81a 100644 --- a/unix/vncserver/vncsession.c +++ b/unix/vncserver/vncsession.c @@ -443,7 +443,7 @@ redir_stdio(const char *homedir, const char *display, char **envp) if (mkdir_p(logdir, 0755) == -1) { if (errno != EEXIST) { - syslog(LOG_CRIT, "Failure creating \"%s\": %s", logdir, strerror(errno)); + syslog(LOG_CRIT, "Could not create VNC state directory \"%s\": %s", logdir, strerror(errno)); _exit(EX_OSERR); } } diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index 3bce2b51..d51b8713 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -317,7 +317,7 @@ void ServerDialog::loadServerHistory() const char* stateDir = os::getvncstatedir(); if (stateDir == nullptr) - throw Exception(_("Could not obtain the state directory path")); + throw Exception(_("Could not determine VNC state directory path")); char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY); @@ -383,7 +383,7 @@ void ServerDialog::saveServerHistory() const char* stateDir = os::getvncstatedir(); if (stateDir == nullptr) - throw Exception(_("Could not obtain the state directory path")); + throw Exception(_("Could not determine VNC state directory path")); char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY); diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index a03623db..2e8ad7a1 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -631,7 +631,7 @@ void saveViewerParameters(const char *filename, const char *servername) { const char* configDir = os::getvncconfigdir(); if (configDir == nullptr) - throw Exception(_("Could not obtain the config directory path")); + throw Exception(_("Could not determine VNC config directory path")); snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir); } else { @@ -735,7 +735,7 @@ char* loadViewerParameters(const char *filename) { const char* configDir = os::getvncconfigdir(); if (configDir == nullptr) - throw Exception(_("Could not obtain the config directory path")); + throw Exception(_("Could not determine VNC config directory path")); snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir); } else { diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index c206427b..24099e12 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -560,7 +560,8 @@ create_base_dirs() if (os::mkdir_p(dir, 0755) == -1) { if (errno != EEXIST) - vlog.error(_("Could not create VNC config directory: %s"), strerror(errno)); + vlog.error(_("Could not create VNC config directory \"%s\": %s"), + dir, strerror(errno)); } dir = os::getvncdatadir(); @@ -571,7 +572,8 @@ create_base_dirs() if (os::mkdir_p(dir, 0755) == -1) { if (errno != EEXIST) - vlog.error(_("Could not create VNC data directory: %s"), strerror(errno)); + vlog.error(_("Could not create VNC data directory \"%s\": %s"), + dir, strerror(errno)); } dir = os::getvncstatedir(); @@ -582,7 +584,8 @@ create_base_dirs() if (os::mkdir_p(dir, 0755) == -1) { if (errno != EEXIST) - vlog.error(_("Could not create VNC state directory: %s"), strerror(errno)); + vlog.error(_("Could not create VNC state directory \"%s\": %s"), + dir, strerror(errno)); } } -- 2.39.5