Commit 5bfb47a1 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[remoting host][linux] Create symlink to latest host log file

This CL makes the Linux host service create a symlink to the latest host
log file, so that it can be easier to locate.

Bug: 1124862
Change-Id: I5a16d530ba3270e2441154f74d4ba543628343af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2393058
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Reviewed-by: default avatarLambros Lambrou <lambroslambrou@chromium.org>
Reviewed-by: default avatarErik Jensen <rkjnsn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804453}
parent 02450ef4
...@@ -74,6 +74,9 @@ const char kExeSymlink[] = "/proc/self/exe"; ...@@ -74,6 +74,9 @@ const char kExeSymlink[] = "/proc/self/exe";
const char kLogFileTemplate[] = const char kLogFileTemplate[] =
"/tmp/chrome_remote_desktop_%Y%m%d_%H%M%S_XXXXXX"; "/tmp/chrome_remote_desktop_%Y%m%d_%H%M%S_XXXXXX";
// The filename for the latest log symlink.
constexpr char kLatestLogSymlink[] = "/tmp/chrome_remote_desktop.latest";
const char kUsageMessage[] = const char kUsageMessage[] =
"This program is not intended to be run by end users. To configure Chrome\n" "This program is not intended to be run by end users. To configure Chrome\n"
"Remote Desktop, please install the app from the Chrome Web Store:\n" "Remote Desktop, please install the app from the Chrome Web Store:\n"
...@@ -474,6 +477,9 @@ bool ExecuteSession(std::string user, ...@@ -474,6 +477,9 @@ bool ExecuteSession(std::string user,
if (chown_log) { if (chown_log) {
int result = fchown(STDOUT_FILENO, pwinfo->pw_uid, pwinfo->pw_gid); int result = fchown(STDOUT_FILENO, pwinfo->pw_uid, pwinfo->pw_gid);
PLOG_IF(WARNING, result != 0) << "Failed to change log file owner"; PLOG_IF(WARNING, result != 0) << "Failed to change log file owner";
result = lchown(kLatestLogSymlink, pwinfo->pw_uid, pwinfo->pw_gid);
PLOG_IF(WARNING, result != 0)
<< "Failed to change latest log symlink owner";
} }
pid_t child_pid = fork(); pid_t child_pid = fork();
...@@ -546,6 +552,16 @@ LogFile OpenLogFile() { ...@@ -546,6 +552,16 @@ LogFile OpenLogFile() {
mode_t mode = umask(0177); mode_t mode = umask(0177);
int fd = mkstemp(logfile); int fd = mkstemp(logfile);
PCHECK(fd != -1) << "Failed to open log file"; PCHECK(fd != -1) << "Failed to open log file";
// Creates a symlink to make the logs easier to find.
int symlink_ret = symlink(logfile, kLatestLogSymlink);
if (symlink_ret != 0 && errno == EEXIST) {
unlink(kLatestLogSymlink);
symlink_ret = symlink(logfile, kLatestLogSymlink);
}
PLOG_IF(ERROR, symlink_ret != 0)
<< "Failed to create log symlink to " << logfile;
umask(mode); umask(mode);
return {fd, logfile}; return {fd, logfile};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment