Skip to content

Fix: Remote view and RDP if no user shares are set.#2309

Merged
limetech merged 2 commits into
unraid:masterfrom
SimonFair:Fix-PCI-changes
Jul 27, 2025
Merged

Fix: Remote view and RDP if no user shares are set.#2309
limetech merged 2 commits into
unraid:masterfrom
SimonFair:Fix-PCI-changes

Conversation

@SimonFair

@SimonFair SimonFair commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

If system is set with no user shares. For VMs the remote view and rdp options fail. This PR resolve the issue,

image

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of remote viewer file paths to ensure compatibility with custom system directory configurations.

@coderabbitai

coderabbitai Bot commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A new variable is introduced to dynamically determine the system path based on the VM image file location. All hardcoded references to the /mnt/user/system/remoteviewer directory are replaced with a path constructed from this dynamic variable, affecting how remote viewer files are created and stored.

Changes

File(s) Change Summary
emhttp/plugins/dynamix.vm.manager/include/VMajax.php Replaced hardcoded /mnt/user/system/remoteviewer paths with a dynamically determined system path variable; updated directory and file creation logic accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

A bunny hopped through code so neat,
Replacing paths beneath its feet.
No longer hard, the routes now flow,
Dynamic trails where files can go.
With every hop, the logic's clear—
The system’s path is now right here!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95ac39b and 578ccc2.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix.vm.manager/include/VMajax.php (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • emhttp/plugins/dynamix.vm.manager/include/VMajax.php
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
emhttp/plugins/dynamix.vm.manager/include/VMajax.php (1)

23-25: Consider refactoring to a helper function for better maintainability.

The dynamic path extraction logic is used in multiple places throughout the file. Consider extracting this into a helper function to improve code reusability and make it easier to add proper error handling.

Add this helper function near the top of the file:

function getSystemPath() {
    global $domain_cfg;
    
    if (empty($domain_cfg['IMAGE_FILE'])) {
        return false;
    }
    
    if (preg_match('#^(.*?/system/)#', $domain_cfg['IMAGE_FILE'], $matches)) {
        return $matches[1];
    }
    
    return false;
}

Then replace the current usage with:

-if (preg_match('#^(.*?/system/)#', $domain_cfg['IMAGE_FILE'], $matches)) {
-    $domain_system_path = $matches[1];
-}
+$domain_system_path = getSystemPath();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 092557f and 95ac39b.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix.vm.manager/include/VMajax.php (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
emhttp/plugins/dynamix.vm.manager/include/VMajax.php (2)

Learnt from: zackspear
PR: #2099
File: emhttp/plugins/dynamix.my.servers/include/web-components-extractor.php:13-19
Timestamp: 2025-03-27T22:04:34.550Z
Learning: The file emhttp/plugins/dynamix.my.servers/include/web-components-extractor.php is synced from another repository and should not be modified directly in the webgui repository.

Learnt from: zackspear
PR: #2099
File: emhttp/plugins/dynamix.my.servers/include/activation-code-extractor.php:58-74
Timestamp: 2025-03-27T22:04:00.594Z
Learning: The file emhttp/plugins/dynamix.my.servers/include/activation-code-extractor.php is synced from a different repository, and modifications should not be suggested in this repository's context. Changes should be proposed in the source repository instead.

Comment on lines +23 to +25
if (preg_match('#^(.*?/system/)#', $domain_cfg['IMAGE_FILE'], $matches)) {
$domain_system_path = $matches[1];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify regex pattern handles edge cases properly.

The regex pattern #^(.*?/system/)# extracts the system path from the VM image file location. However, there are potential issues:

  1. The variable $domain_system_path is not initialized if the regex doesn't match
  2. No validation that $domain_cfg['IMAGE_FILE'] exists or is not empty

Run the following script to verify how this pattern behaves with various VM image file paths:


🏁 Script executed:

#!/bin/bash
# Description: Check for potential edge cases in VM image file paths and verify regex behavior

# Search for usage of domain_cfg IMAGE_FILE to understand expected formats
rg -A 3 -B 3 "IMAGE_FILE|domain_cfg" --type php

# Look for any initialization or default values for domain_cfg
ast-grep --pattern 'domain_cfg = $_'

# Check if there are any safeguards for missing domain_cfg
rg "isset.*domain_cfg|empty.*domain_cfg" --type php

Length of output: 25814


🏁 Script executed:

#!/bin/bash
# Show the initial context of VMajax.php to confirm where and how $domain_cfg and IMAGE_FILE are defined
sed -n '1,100p' emhttp/plugins/dynamix.vm.manager/include/VMajax.php

Length of output: 3447


Ensure IMAGE_FILE is validated and $domain_system_path is always initialized

Wrap the regex in a non-empty check and provide a sensible default for $domain_system_path so it can never remain undefined:

• File: emhttp/plugins/dynamix.vm.manager/include/VMajax.php
Lines: ~23–25

Suggested diff:

- if (preg_match('#^(.*?/system/)#', $domain_cfg['IMAGE_FILE'], $matches)) {
-     $domain_system_path = $matches[1];
- }
+ // Default to the standard system share
+ $domain_system_path = '/mnt/user/system/';
+ if (!empty($domain_cfg['IMAGE_FILE'])
+     && preg_match('#^(.*?/system/)#', $domain_cfg['IMAGE_FILE'], $matches)
+ ) {
+     $domain_system_path = $matches[1];
+ }

This guarantees:

  • $domain_system_path is always defined (no “undefined variable” errors).
  • We only attempt the regex when IMAGE_FILE is set and non-empty.
  • Fallback remains compatible with existing Unraid conventions.
🤖 Prompt for AI Agents
In emhttp/plugins/dynamix.vm.manager/include/VMajax.php around lines 23 to 25,
ensure $domain_system_path is always initialized by first checking that
$domain_cfg['IMAGE_FILE'] is set and non-empty before running the preg_match.
Initialize $domain_system_path with a sensible default value before the
condition to avoid undefined variable errors. This ensures safe regex execution
and maintains compatibility with existing Unraid conventions.

Comment thread emhttp/plugins/dynamix.vm.manager/include/VMajax.php
Comment thread emhttp/plugins/dynamix.vm.manager/include/VMajax.php
Comment thread emhttp/plugins/dynamix.vm.manager/include/VMajax.php
@SimonFair SimonFair marked this pull request as draft July 24, 2025 19:51
@SimonFair SimonFair marked this pull request as ready for review July 26, 2025 09:06
@limetech limetech merged commit b511079 into unraid:master Jul 27, 2025
1 check passed
@SimonFair SimonFair deleted the Fix-PCI-changes branch January 8, 2026 16:26
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.

2 participants