From ba67b807db5caaf62721ca55b94cfd35af7b1f3b Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 24 Sep 2022 13:08:45 +0530 Subject: [PATCH] AuthManager: updated LoadConfigFileInternal() to implant the session as well as the user account into the newly restored system. --- DnsServerCore/Auth/AuthManager.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/DnsServerCore/Auth/AuthManager.cs b/DnsServerCore/Auth/AuthManager.cs index 9caa9120..8f40eb96 100644 --- a/DnsServerCore/Auth/AuthManager.cs +++ b/DnsServerCore/Auth/AuthManager.cs @@ -210,17 +210,27 @@ namespace DnsServerCore.Auth if (implantSession is not null) { - UserSession newSession; - using (MemoryStream mS = new MemoryStream()) { + //implant current user + implantSession.User.WriteTo(new BinaryWriter(mS)); + + mS.Position = 0; + User newUser = new User(new BinaryReader(mS), this); + newUser.AddToGroup(GetGroup(Group.ADMINISTRATORS)); + _users[newUser.Username] = newUser; + + //implant current session + mS.SetLength(0); implantSession.WriteTo(new BinaryWriter(mS)); mS.Position = 0; - newSession = new UserSession(new BinaryReader(mS), this); - } + UserSession newSession = new UserSession(new BinaryReader(mS), this); + _sessions.TryAdd(newSession.Token, newSession); - _sessions.TryAdd(newSession.Token, newSession); + //save config + SaveConfigFileInternal(); + } } _log.Write("DNS Server auth config file was loaded: " + configFile);