|
@@ -726,7 +726,7 @@ void baduname(char *confhas, char *myuname) {
|
|
|
|
|
|
|
|
char *homedir(bool useconf)
|
|
char *homedir(bool useconf)
|
|
|
{
|
|
{
|
|
|
- static char homedir_buf[DIRMAX] = "";
|
|
|
|
|
|
|
+ static char homedir_buf[PATH_MAX] = "";
|
|
|
|
|
|
|
|
if (!homedir_buf[0]) {
|
|
if (!homedir_buf[0]) {
|
|
|
char tmp[DIRMAX] = "";
|
|
char tmp[DIRMAX] = "";
|
|
@@ -747,8 +747,10 @@ char *homedir(bool useconf)
|
|
|
#endif /* CYGWIN_HACKS */
|
|
#endif /* CYGWIN_HACKS */
|
|
|
}
|
|
}
|
|
|
ContextNote(STR("realpath()"));
|
|
ContextNote(STR("realpath()"));
|
|
|
- if (tmp[0])
|
|
|
|
|
|
|
+ if (tmp[0]) {
|
|
|
realpath(tmp, homedir_buf); /* this will convert lame home dirs of /home/blah->/usr/home/blah */
|
|
realpath(tmp, homedir_buf); /* this will convert lame home dirs of /home/blah->/usr/home/blah */
|
|
|
|
|
+ homedir_buf[DIRMAX] = 0;
|
|
|
|
|
+ }
|
|
|
ContextNote(STR("realpath(): Success"));
|
|
ContextNote(STR("realpath(): Success"));
|
|
|
}
|
|
}
|
|
|
return homedir_buf[0] ? homedir_buf : NULL;
|
|
return homedir_buf[0] ? homedir_buf : NULL;
|
|
@@ -858,12 +860,13 @@ char *move_bin(const char *ipath, const char *file, bool run)
|
|
|
|
|
|
|
|
/* move the binary to the correct place */
|
|
/* move the binary to the correct place */
|
|
|
static char newbin[DIRMAX] = "";
|
|
static char newbin[DIRMAX] = "";
|
|
|
- char real[DIRMAX] = "";
|
|
|
|
|
|
|
+ char real[PATH_MAX] = "";
|
|
|
|
|
|
|
|
simple_snprintf(newbin, sizeof newbin, "%s%s%s", path, path[strlen(path) - 1] == '/' ? "" : "/", file);
|
|
simple_snprintf(newbin, sizeof newbin, "%s%s%s", path, path[strlen(path) - 1] == '/' ? "" : "/", file);
|
|
|
|
|
|
|
|
ContextNote(STR("realpath()"));
|
|
ContextNote(STR("realpath()"));
|
|
|
realpath(binname, real); /* get the realpath of binname */
|
|
realpath(binname, real); /* get the realpath of binname */
|
|
|
|
|
+ real[DIRMAX] = 0;
|
|
|
ContextNote(STR("realpath(): Success"));
|
|
ContextNote(STR("realpath(): Success"));
|
|
|
/* running from wrong dir, or wrong bin name.. lets try to fix that :) */
|
|
/* running from wrong dir, or wrong bin name.. lets try to fix that :) */
|
|
|
sdprintf(STR("binname: %s"), binname);
|
|
sdprintf(STR("binname: %s"), binname);
|
|
@@ -894,7 +897,10 @@ char *move_bin(const char *ipath, const char *file, bool run)
|
|
|
if (run) {
|
|
if (run) {
|
|
|
simple_snprintf(newbin, sizeof newbin, "%s%s%s",
|
|
simple_snprintf(newbin, sizeof newbin, "%s%s%s",
|
|
|
path, path[strlen(path) - 1] == '/' ? "" : "/", shell_escape(file));
|
|
path, path[strlen(path) - 1] == '/' ? "" : "/", shell_escape(file));
|
|
|
- system(newbin);
|
|
|
|
|
|
|
+ if (system(newbin) == -1) {
|
|
|
|
|
+ printf("Unable to automatically start new binary.\n");
|
|
|
|
|
+ exit(1);
|
|
|
|
|
+ }
|
|
|
sdprintf(STR("exiting to let new binary run..."));
|
|
sdprintf(STR("exiting to let new binary run..."));
|
|
|
exit(0);
|
|
exit(0);
|
|
|
}
|
|
}
|