Skip to content

feat(ns-don): enhance session management with logging and expiration checks#1554

Open
stephdl wants to merge 1 commit intomainfrom
sdl-1542
Open

feat(ns-don): enhance session management with logging and expiration checks#1554
stephdl wants to merge 1 commit intomainfrom
sdl-1542

Conversation

@stephdl
Copy link
Copy Markdown
Contributor

@stephdl stephdl commented Mar 4, 2026

This PR adds time-based session management to the Don remote support tool:

  • Tracks session expiration - Sessions now show how much time is left (default 24 hours)
  • Auto-cleanup - Hourly cron job automatically stops expired sessions
  • Extend command - New don extend adds 7 days (one-time only)
  • Logging - All session events (start/stop/extend/expire) now log to syslog
  • Bug fixes - Prevents double logging during cleanup and improves variable quoting

Result: Remote support sessions are now time-limited with automatic expiration, better visibility, and audit trails.

echo "[4/6] Simulating 25 hours have passed..."
current_time=$(date +%s)
old_time=$((current_time - 90000))  # 90000 seconds = 25 hours
echo $old_time > /var/run/don/session_start
echo "[7/8] Simulating 8 days have passed..."
current_time=$(date +%s)
old_time=$((current_time - 691200))  # 691200 seconds = 8 days
echo $old_time > /var/run/don/session_start

@stephdl stephdl requested review from Tbaile and gsanchietti March 5, 2026 11:29
@stephdl stephdl force-pushed the sdl-1542 branch 4 times, most recently from fd4d2ab to e27b518 Compare March 5, 2026 16:36
@stephdl stephdl requested a review from Copilot March 5, 2026 18:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@stephdl stephdl requested a review from Copilot March 5, 2026 18:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Member

@gsanchietti gsanchietti left a comment

Choose a reason for hiding this comment

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

Remove also the init script

@stephdl stephdl changed the title Enhance session management with logging and expiration checks fix(ns-don): enhance session management with logging and expiration checks Mar 6, 2026
@stephdl stephdl requested review from Tbaile and gsanchietti March 6, 2026 13:54
@stephdl stephdl changed the title fix(ns-don): enhance session management with logging and expiration checks feat(ns-don): enhance session management with logging and expiration checks Mar 6, 2026
Copy link
Copy Markdown
Collaborator

@Tbaile Tbaile left a comment

Choose a reason for hiding this comment

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

Good for me, will merge after image release

@gsanchietti
Copy link
Copy Markdown
Member

@stephdl could you please update also the documentation inside nethsecurity-docs repo?

@gsanchietti
Copy link
Copy Markdown
Member

I've found another problem: when don stopped or don expire is called, the script logs the same line 2 times:

Apr  7 20:14:50 NethSec don: Remote support session stopped
Apr  7 20:14:51 NethSec don: Remote support session stopped

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI commented Mar 30, 2026

I've found another problem: when don stopped or don expire is called, the script logs the same line 2 times:

Apr  7 20:14:50 NethSec don: Remote support session stopped

...

Fixed in 544bb69. The double logging was caused by the cleanup lock file living inside $base_dir — once rm -rf "$base_dir" ran, the lock was gone, so the VPN down callback's don stop could re-enter cleanup and log again. Replaced the lock mechanism with a simple check: if $credentials doesn't exist, cleanup returns early (session already stopped).

Remove also the init script

Removed in 544bb69. The [ -x /etc/init.d/cron ] && /etc/init.d/cron restart calls have been removed from both add_cron_expiration and remove_cron_expiration.

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.

5 participants