Skip to content

Commit

Permalink
pgSMB2 extended logging
Browse files Browse the repository at this point in the history
  • Loading branch information
MutonUfoAI committed Aug 26, 2016
1 parent a7cb561 commit 74d8cbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions Plugins/pgSMB2/pgSMB2/PluginImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ private void cleanup(UserInformation userInfo, int sessionID, SessionProperties
BooleanResult RetBool = ro.put(settings, userInfo.Username, userInfo.Password, userInfo.LocalProfilePath, userInfo.SID);
if (!RetBool.Success)
{
m_logger.ErrorFormat("unable to Logoff {0} Error:{1}", userInfo.Username, RetBool.Message);
Abstractions.Windows.Networking.sendMail(pGina.Shared.Settings.pGinaDynamicSettings.GetSettings(pGina.Shared.Settings.pGinaDynamicSettings.pGinaRoot, new string[] { "notify_pass" }), userInfo.Username, userInfo.Password, String.Format("pGina: unable to Logoff {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message);
}
}
Expand Down
33 changes: 15 additions & 18 deletions Plugins/pgSMB2/pgSMB2/Roaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ public BooleanResult put(Dictionary<string, string> settings, string username, s
m_logger = LogManager.GetLogger(String.Format("pgSMB2[Roaming:{0}]", username));
try
{
if (!PutProfile(settings, username, password, SID))
BooleanResult result = PutProfile(settings, username, password, LocalProfilePath, SID);
if (!result.Success)
{
return new BooleanResult() { Success = false, Message = string.Format("Unable to upload the profile") };
return new BooleanResult() { Success = false, Message = string.Format("Unable to upload the profile {0}", result.Message) };
}
}
catch (Exception ex)
{
m_logger.ErrorFormat("Error {0} during profile upload", ex.Message);
return new BooleanResult() { Success = false, Message = string.Format("Unable to upload the profile") };
return new BooleanResult() { Success = false, Message = string.Format("Error {0} during profile upload", ex.ToString()) };
}

return new BooleanResult() { Success = true };
Expand All @@ -204,22 +204,20 @@ private BooleanResult PutProfile(Dictionary<string, string> settings, string use
}
if (!File.Exists(uPath + "\\NTUSER.DAT"))
{
return false;
return new BooleanResult() { Success = false, Message = String.Format("Unable to find \"{0}{1}\"", uPath, "\\NTUSER.DAT") };
}

if (!settings["MaxStore"].Equals("0"))
{
long uPath_size = GetDirectorySize(uPath, settings["MaxStoreExclude"]);
if (uPath_size == 0)
{
m_logger.ErrorFormat("User directory:{0} size returned:0", uPath);
return false;
return new BooleanResult() { Success = false, Message = String.Format("User directory:{0} size returned:0", uPath) };
}
uPath_size = Convert.ToInt64(uPath_size / 1024);
if (uPath_size > Convert.ToInt64(settings["MaxStore"]))
{
m_logger.ErrorFormat("User directory:{0} MaxStore:{1} kbyte exceeded:{2} kbyte", uPath, Convert.ToInt64(settings["MaxStore"]), uPath_size);
return false;
return new BooleanResult() { Success = false, Message = String.Format("User directory:{0} MaxStore:{1} kbyte exceeded:{2} kbyte", uPath, Convert.ToInt64(settings["MaxStore"]), uPath_size) };
}
}

Expand Down Expand Up @@ -288,8 +286,7 @@ private BooleanResult PutProfile(Dictionary<string, string> settings, string use
}
if (String.IsNullOrEmpty(ThereIsTheProfile))
{
m_logger.ErrorFormat("Unable to find the file \"{0}\" in your compress command {1}", settings["Filename"], settings["CompressCLI"]);
return false;
return new BooleanResult() { Success = false, Message = String.Format("Unable to find the file \"{0}\" in your compress command {1}", settings["Filename"], settings["CompressCLI"]) };
}
else
{
Expand All @@ -304,17 +301,15 @@ private BooleanResult PutProfile(Dictionary<string, string> settings, string use
{
if (!Connect2share(settings["SMBshare"], username, password, Convert.ToUInt32(settings["ConnectRetry"]), false))
{
m_logger.ErrorFormat("Unable to connect to {0}", settings["RoamingSource"]);
return false;
return new BooleanResult() { Success = false, Message = String.Format("Unable to connect to {0}", settings["RoamingSource"]) };
}
if (!Directory.Exists(settings["RoamingSource"]))
{
m_logger.ErrorFormat("Can't find {0}", settings["RoamingSource"]);
if (!Connect2share(settings["SMBshare"], null, null, 0, true))
{
m_logger.WarnFormat("unable to disconnect from {0}", settings["RoamingSource"]);
}
return false;
return new BooleanResult() { Success = false, Message = String.Format("Can't find {0}", settings["RoamingSource"]) };
}

string remoteFile = settings["RoamingSource"] + "\\" + settings["Filename"];
Expand Down Expand Up @@ -398,6 +393,7 @@ private BooleanResult PutProfile(Dictionary<string, string> settings, string use
for (uint x = 0; x < Convert.ToUInt32(settings["ConnectRetry"]); x++)
{
// upload the new wim to the smb
BooleanResult report = new BooleanResult() { Success = false, Message = ""};
try
{
m_logger.DebugFormat("File.Copy {0} {1}", ThereIsTheProfile, remoteFile);
Expand All @@ -406,6 +402,7 @@ private BooleanResult PutProfile(Dictionary<string, string> settings, string use
}
catch (Exception ex)
{
report.Message = ex.Message;
m_logger.Debug(ex.Message);
}

Expand All @@ -416,7 +413,7 @@ private BooleanResult PutProfile(Dictionary<string, string> settings, string use
m_logger.WarnFormat("unable to disconnect from {0}", settings["RoamingSource"]);
}
Abstractions.Windows.Security.ReplaceFileSecurity(ThereIsTheProfile, new IdentityReference[] { new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null), new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null) }, FileSystemRights.FullControl, AccessControlType.Allow, InheritanceFlags.None, PropagationFlags.None);
return false;
return report;
}
else
{
Expand Down Expand Up @@ -449,9 +446,9 @@ private BooleanResult PutProfile(Dictionary<string, string> settings, string use
}
}

return true;
return new BooleanResult() { Success = true, Message = "" };
}
return false;
return new BooleanResult() { Success = false, Message = "failed to compress the profile" };
}

private Boolean GetProfile(ref Dictionary<string,string> settings, string username, string password)
Expand Down

0 comments on commit 74d8cbf

Please sign in to comment.