Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logfile open mode and permission plus location configurability. #556

Merged
merged 2 commits into from
Jan 18, 2023

Conversation

jshort
Copy link
Collaborator

@jshort jshort commented Dec 20, 2022

This addresses #555

Testing:

❯ ./et --help                                                                                                                                                                                                       11:50:47  12.20.22
Remote shell for the busy and impatient
Usage:
  et [OPTION...] [user@]host[:port]

  Note that 'host' can be a hostname or ipv4 address with or without a port
  or an ipv6 address. If the ipv6 address is abbreviated with :: then it must
  be specfied without a port (use -p,--port).

  -h, --help                 Print help
      --version              Print version
  -u, --username             Username
      --host arg             Remote host name
  -p, --port arg             Remote machine etserver port (default: 2022)
  -c, --command arg          Run command on connect
      --terminal-path arg    Path to etterminal on server side. Use if
                             etterminal is not on the system path.
  -t, --tunnel arg           Tunnel: Array of source:destination ports or
                             srcStart-srcEnd:dstStart-dstEnd (inclusive) port
                             ranges (e.g. 10080:80,10443:443,
                             10090-10092:8000-8002)
  -r, --reversetunnel arg    Reverse Tunnel: Array of source:destination
                             ports or srcStart-srcEnd:dstStart-dstEnd (inclusive)
                             port ranges
      --jumphost arg         jumphost between localhost and destination
      --jport arg            Jumphost machine port (default: 2022)
  -x, --kill-other-sessions  kill all old sessions belonging to the user
      --macserver            Set when connecting to an macOS server.  Sets
                             --terminal-path=/usr/local/bin/etterminal
  -v, --verbose arg          Enable verbose logging (default: 0)
  -k, --keepalive arg        Client keepalive duration in seconds
  -l, --logdir arg           Base directory for log files. (default: /tmp/)
...
 ✔  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ls -la /tmp/etclient*                                                                                                                                                                                             11:48:40  12.20.22
zsh: no matches found: /tmp/etclient*
 ↵ 1  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ./et dev:8080                                                                                                                                                                                                     11:48:51  12.20.22
Could not reach the ET server: dev:8080

 ↵ 1  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ls -la /tmp/etclient*                                                                                                                                                                                             11:49:13  12.20.22
-rw------- 1 jwshort users 4416 Dec 20 11:49 /tmp/etclient-2022-12-20_11-49-09.log
-rw------- 1 jwshort users   52 Dec 20 11:49 /tmp/etclient-stderr-2022-12-20_11-49-09.log
 ✔  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ls -la ~/etclient-*                                                                                                                                                                                               11:49:16  12.20.22
zsh: no matches found: /home/jwshort/etclient-*
 ↵ 1  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ./et dev:8080 --logdir ~/                                                                                                                                                                                         11:50:21  12.20.22
Could not reach the ET server: dev:8080

 ↵ 1  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ls -la ~/etclient-*                                                                                                                                                                                               11:50:44  12.20.22
-rw------- 1 jwshort users 4416 Dec 20 11:50 /home/jwshort/etclient-2022-12-20_11-50-41.log
-rw------- 1 jwshort users   52 Dec 20 11:50 /home/jwshort/etclient-stderr-2022-12-20_11-50-41.log
 ✔  ⚙  jwshort@  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ls -la /tmp/etserver-*                                                                                                                                                                                            11:53:45  12.20.22
zsh: no matches found: /tmp/etserver-*
 ↵ 1  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ cat et.cfg                                                                                                                                                                                                        11:53:46  12.20.22
; et.cfg : Config file for Eternal Terminal
;

[Networking]
port = 2022
# bind_ip = 0.0.0.0

[Debug]
verbose = 0
silent = 0
logsize = 20971520
telemetry = 1
 ✔  ⚙  jwshort ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ./etserver --cfgfile=et.cfg                                                                                                                                                                                       11:53:54  12.20.22
^C
Got interrupt (perhaps ctrl+c?): 2.  Exiting.

 ↵ 2  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ls -la /tmp/etserver-*                                                                                                                                                                                            11:54:25  12.20.22
-rw------- 1 jwshort users 393 Dec 20 11:54 /tmp/etserver-2022-12-20_11-54-20.log
-rw------- 1 jwshort users  73 Dec 20 11:54 /tmp/etserver-stderr-2022-12-20_11-54-20.log
 ✔  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ vim et.cfg                                                                                                                                                                                                        11:54:27  12.20.22
 ✔  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ cat et.cfg                                                                                                                                                                                                        11:54:42  12.20.22
; et.cfg : Config file for Eternal Terminal
;

[Networking]
port = 2022
# bind_ip = 0.0.0.0

[Debug]
verbose = 0
silent = 0
logsize = 20971520
logdirectory = /home/jwshort
telemetry = 1
 ✔  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ./etserver --cfgfile=et.cfg                                                                                                                                                                                       11:54:44  12.20.22
^C
Got interrupt (perhaps ctrl+c?): 2.  Exiting.

 ↵ 2  ⚙  jwshort  ~/git/EternalTerminal/build   logfile_location_perms 
 ❯ ls -la ~/etserver-*                                                                                                                                                                                               11:54:55  12.20.22
-rw------- 1 jwshort users 393 Dec 20 11:54 /home/jwshort/etserver-2022-12-20_11-54-48.log
-rw------- 1 jwshort users  73 Dec 20 11:54 /home/jwshort/etserver-stderr-2022-12-20_11-54-48.log

@jshort jshort force-pushed the logfile_location_perms branch 5 times, most recently from 71e81e4 to d4716c2 Compare December 21, 2022 17:14
@codecov-commenter
Copy link

codecov-commenter commented Dec 21, 2022

Codecov Report

Base: 73.02% // Head: 72.97% // Decreases project coverage by -0.05% ⚠️

Coverage data is based on head (04e64d4) compared to base (7289e04).
Patch coverage: 76.31% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #556      +/-   ##
==========================================
- Coverage   73.02%   72.97%   -0.06%     
==========================================
  Files          50       50              
  Lines        3029     3049      +20     
==========================================
+ Hits         2212     2225      +13     
- Misses        817      824       +7     
Impacted Files Coverage Δ
src/base/LogHandler.cpp 81.35% <74.28%> (+18.19%) ⬆️
test/Main.cpp 100.00% <100.00%> (ø)
src/base/ServerConnection.cpp 70.75% <0.00%> (-6.61%) ⬇️
src/terminal/UserTerminalHandler.cpp 70.00% <0.00%> (-1.27%) ⬇️
src/base/Connection.cpp 87.82% <0.00%> (-0.87%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jshort jshort force-pushed the logfile_location_perms branch 3 times, most recently from 24bc7d9 to c9987d2 Compare December 22, 2022 01:13
@acipm
Copy link

acipm commented Jan 13, 2023

Hi, I saw there were two CVEs assigned to this: CVE-2022-48257 and CVE-2022-48258.

Is there a reason why this is not merged yet? Thanks!

@jshort jshort force-pushed the logfile_location_perms branch from c9987d2 to 04e64d4 Compare January 13, 2023 17:58
@jshort jshort merged commit 92c4c6a into MisterTea:master Jan 18, 2023
jshort added a commit to jshort/EternalTerminal that referenced this pull request May 2, 2024
In addition to opt-in for telemetry (see MisterTea#553) this uses the log
directory override from MisterTea#556 to place the sentry/telemetry logs.
jshort added a commit to jshort/EternalTerminal that referenced this pull request May 2, 2024
In addition to opt-in for telemetry (see MisterTea#553) this uses the log
directory override from MisterTea#556 to place the sentry/telemetry logs.
MisterTea pushed a commit that referenced this pull request May 2, 2024
In addition to opt-in for telemetry (see #553) this uses the log
directory override from #556 to place the sentry/telemetry logs.
// O_NOFOLLOW does not exist on windows
FATAL_FAIL(::open(fullFname.c_str(), O_EXCL | O_CREAT, 0600));
#else
FATAL_FAIL(::open(fullFname.c_str(), O_NOFOLLOW | O_EXCL | O_CREAT, 0600));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formulation produces on failure

2024-11-18 11:53:08,053 FATAL [default] Stack Trace: 
[0] 0x000000010088bcab et::LogHandler::createLogFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
[1] 0x000000010088b66d et::LogHandler::setupLogFiles(el::Configurations*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, bool, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>)
[2] 0x00000001007d352b main
[3] 0x0000000200a562cd start
Error: (2): No such file or directory

can we at least log the filename? it does not seem appropriate to use FATAL_FAIL in anything other than tests (and even then it would produce hard-to-action failures).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants