Bug 173756. Partial fix

This commit is contained in:
Jim Norman 2006-06-05 21:40:27 +00:00
parent 43fa2efaf3
commit 1810666bca
3 changed files with 146 additions and 0 deletions

139
c_micasad/init/CredMgr.cs Normal file
View File

@ -0,0 +1,139 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System;
using System.IO;
using System.Diagnostics;
namespace sscs.init
{
/// <summary>
/// Summary description for RegCredMgr.
/// </summary>
public class CredMgr
{
public CredMgr()
{
}
public static void Install()
{
System.Diagnostics.Debug.WriteLine("CASA: attempting to register lcredmgr");
string sExePath = GetRegSvrPath();
if (sExePath != null)
{
string sCredMgrPath = GetCredMgrPath();
if (sCredMgrPath != null)
{
RunProcess(sExePath, "/i /n /s " + "\"" + sCredMgrPath + "\"");
}
}
}
public static void Uninstall()
{
System.Diagnostics.Debug.WriteLine("CASA: attempting to unregister lcredmgr");
string sExePath = GetRegSvrPath();
if (sExePath != null)
{
string sCredMgrPath = GetCredMgrPath();
if (sCredMgrPath != null)
{
RunProcess(sExePath, "/u /s " + "\"" + sCredMgrPath + "\"");
}
}
}
private static void RunProcess(string sProcess, string sArgs)
{
if (sProcess != null)
{
try
{
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(sProcess);
if (sArgs != null)
myProcessStartInfo.Arguments = sArgs;
myProcessStartInfo.UseShellExecute = false;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myProcess.WaitForExit();
System.Diagnostics.Debug.WriteLine("Completed " + myProcess.ExitCode.ToString());
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}
}
}
private static string GetRegSvrPath()
{
string sPath = Environment.GetEnvironmentVariable("SystemRoot");
if (sPath != null)
{
// look for regsvr32.exe
if (File.Exists(sPath + "\\system32\\regsvr32.exe"))
{
return (sPath + "\\system32\\regsvr32.exe");
}
else
{
System.Diagnostics.Debug.WriteLine("Did not find regsvr32.exe");
}
}
else
{
System.Diagnostics.Debug.WriteLine("Did not find System path");
}
return null;
}
private static string GetCredMgrPath()
{
string sPath = Environment.GetEnvironmentVariable("ProgramFiles");
if (sPath != null)
{
// look for regsvr32.exe
if (File.Exists(sPath + "\\Novell\\CASA\\bin\\lcredmgr.dll"))
{
return (sPath + "\\Novell\\CASA\\bin\\lcredmgr.dll");
}
else
{
System.Diagnostics.Debug.WriteLine("Did not find lcredmgr.dll");
}
}
else
{
System.Diagnostics.Debug.WriteLine("Did not find path to [ProgramFiles]");
}
return null;
}
}
}

View File

@ -99,12 +99,14 @@ namespace sscs.init
uninstallService();
installService();
startService();
CredMgr.Install();
return;
}
else if (opt != null && opt.ToLower () == "/uninstall")
{
stopService();
uninstallService();
CredMgr.Uninstall();
return;
}

View File

@ -253,6 +253,11 @@
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "init\CredMgr.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "init\ProjectInstaller.cs"
SubType = "Component"