Skip to content

Commit

Permalink
Improve error messages for base directory creation
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Aug 29, 2024
1 parent edee4db commit 9df4f39
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions unix/vncpasswd/vncpasswd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion unix/vncserver/vncsession.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions vncviewer/ServerDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions vncviewer/parameters.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions vncviewer/vncviewer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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));
}
}

Expand Down

0 comments on commit 9df4f39

Please sign in to comment.