-
Notifications
You must be signed in to change notification settings - Fork 158
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
[Unprivileged] Windows enablement #4264
Conversation
This pull request is now in conflicts. Could you fix it? 🙏
|
This pull request is now in conflicts. Could you fix it? 🙏
|
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just documentation requests.
|
||
t, err := windows.OpenCurrentProcessToken() | ||
token := windows.Token(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment on why the switch to Token(0) ? We have had so many issues with detecting "admin" I'd just like to be sure we have this documented if things pop up later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
windows.Token(0)
is used because its passed into checkTokenMembership
that when the token is zero that check uses the current process token. It is a simpler way of saying this processes current token, without the need to grab a handle that needs to be closed for the current process.
What do you want documented here? That windows.Token(0)
means the current process token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you want documented here? That
windows.Token(0)
means the current process token?
Probably a few links to MSDN documentation, and just a comment that windows.Token(0)
is current process. I'm just thinking in 3 years if we have a bug around this code in some new Azure environment it is nice to know what we were thinking and hopefully pointers to full documentation which might give clues if it has been deprecated etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some more comments and a link for the windows.Token(0)
.
"OnFailureResetPeriod": 10, | ||
} | ||
if opts.Password != "" { | ||
option["Password"] = opts.Password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this password is stored encrypted in the Registry. We need to document how the user would go about changing it. It's not uncommon for password policies to require changing static passwords like this on a regular basis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if that is true in this case. The user cannot login at all, it can only be used as a service and the password is setup to never expire.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if that is true in this case.
See things like: https://www.stigviewer.com/stig/windows_server_2019/2020-06-15/finding/V-93209
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is interesting finding, but even in this case the installing administrator doesn't even know the password. Being the finding is speaking about an administrator knowing the password, and in this case the password is completely unknown.
We can definitely add documentation about it for unprivileged installation on Windows. If they choose to change the user account password they will also have to update the password for the service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, no major blockers.
Left a few comments that are mostly for readability/documentation, those don't fundamentally change the implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to use crypto/rand
not math/rand
for generating random passwords.
Other than that, LGTM.
@leehinman Okay I have updated to |
|
What can be tested is tested and additional tests will require this to be merged first. |
What does this PR do?
Enables the installation mode of
--unprivileged
for Windows. During installation theelastic-agent-user
user andelastic-agent
group is created, permissions are set correctly on the copied files, service is created running as theelastic-agent-user
. While running in unprivileged mode the daemon creates the vault with the correct permissions and gives users in theelastic-agent
group the ability to communicate with the running Elastic Agent daemon.Why is it important?
Allowing users to install the Elastic Agent with less permissions.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added tests that prove my fix is effective or that my feature works(cannot test with unit tests)[ ] I have added an entry in(skipped as we don't want to expose this feature until ready)./changelog/fragments
using the changelog toolAuthor's Checklist
elastic-agent-user
is createdelastic-agent
group is createdelastic-agent-user
is added toelastic-agent
groupelastic-agent-user
andelastic-agent
groupelastic-agent
runs correctlyHow to test this PR locally
Add your local user to
elastic-agent
group. Be sure to re-open command prompt. RunC:\Program Files\Elastic\Agent\elastic-agent.exe status
.Related issues
--unprivileged
on Windows #3868