Prevent users from moving .miCASA files to directories
other than /home/... or /media/...
This commit is contained in:
parent
af925e58c1
commit
e2db0e3ecc
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 27 15:10:47 MDT 2006 - jnorman@novell.com
|
||||
|
||||
- Prevent users from moving .miCASA files to directories other
|
||||
/home/... and /media...
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 27 11:57:09 MDT 2006 - jnorman@novell.com
|
||||
|
||||
|
@ -2189,7 +2189,29 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
if (Directory.Exists(sDirectory))
|
||||
{
|
||||
entryStorageDirectory.Text = sDirectory;
|
||||
// make sure user as rights to read and write to this directory
|
||||
try
|
||||
{
|
||||
#if LINUX
|
||||
int rcode = Mono.Unix.Native.Syscall.access(sDirectory,
|
||||
Mono.Unix.Native.AccessModes.R_OK |
|
||||
Mono.Unix.Native.AccessModes.W_OK );
|
||||
|
||||
if (rcode == 0)
|
||||
{
|
||||
entryStorageDirectory.Text = sDirectory;
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Error, "Moving files to\r\n" + sDirectory + "\r\nis not allowed");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Error, "Not allowed\r\n" + sDirectory);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -81,6 +81,8 @@ namespace Novell.CASA.GUI
|
||||
//if (m_currentDirectory.EndsWith(m_pathSeparator))
|
||||
// m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.Length - 1);
|
||||
|
||||
SetNewFolderButton();
|
||||
|
||||
DisplayDirectory();
|
||||
}
|
||||
|
||||
@ -204,12 +206,22 @@ namespace Novell.CASA.GUI
|
||||
}
|
||||
|
||||
|
||||
#if LINUX
|
||||
tsDrives.AppendValues("/home");
|
||||
tsDrives.AppendValues("/media");
|
||||
|
||||
#else
|
||||
// show logical drives
|
||||
string[] drives = Directory.GetLogicalDrives();
|
||||
for (int i=0; i<drives.Length; i++)
|
||||
{
|
||||
tsDrives.AppendValues(drives[i]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SetNewFolderButton();
|
||||
|
||||
treeviewFavorites.AppendColumn("Drive", new CellRendererText(), "text", 0);
|
||||
treeviewFavorites.Model = tsDrives;
|
||||
|
||||
@ -259,8 +271,7 @@ namespace Novell.CASA.GUI
|
||||
|
||||
for (int i=0; i<dirs.Length; i++)
|
||||
{
|
||||
if (dirs[i].Name.StartsWith(".")) continue;
|
||||
|
||||
//if (dirs[i].Name.StartsWith(".")) continue;
|
||||
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "folder.png"), dirs[i].Name, "", "File folder");
|
||||
}
|
||||
|
||||
@ -342,7 +353,7 @@ namespace Novell.CASA.GUI
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
Logger.DbgLog(e.ToString());
|
||||
}
|
||||
|
||||
|
||||
@ -366,7 +377,7 @@ namespace Novell.CASA.GUI
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
Logger.DbgLog(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -504,6 +515,43 @@ namespace Novell.CASA.GUI
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetNewFolderButton()
|
||||
{
|
||||
if (buttonNewFolder != null)
|
||||
{
|
||||
if ((m_currentDirectory.Equals("/home/")) ||
|
||||
(m_currentDirectory.Equals("/home/.casa/")) ||
|
||||
(m_currentDirectory.Equals("/media/")))
|
||||
{
|
||||
buttonNewFolder.Sensitive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonNewFolder.Sensitive = true;
|
||||
}
|
||||
}
|
||||
|
||||
SetUPButton();
|
||||
}
|
||||
|
||||
private void SetUPButton()
|
||||
{
|
||||
if (buttonUP != null)
|
||||
{
|
||||
if ((m_currentDirectory.Equals("/home/")) ||
|
||||
(m_currentDirectory.Equals("/media/")))
|
||||
{
|
||||
buttonUP.Sensitive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonUP.Sensitive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// new folder handler
|
||||
public void on_buttonNewFolder_clicked(object obj, EventArgs args)
|
||||
|
@ -82,7 +82,8 @@ CSFILES =$(srcdir)/AssemblyInfo.cs \
|
||||
CSFILES_CSC := $(subst /,$(SEP),$(CSFILES))
|
||||
CS_FLAGS = -pkg:gtk-sharp -pkg:glade-sharp -d:LINUX -nowarn:169
|
||||
CS_RESOURCES =
|
||||
CS_LIBS =$(CASALIBDIR)/Novell.CASA.Common.dll \
|
||||
CS_LIBS = Mono.Posix.dll \
|
||||
$(CASALIBDIR)/Novell.CASA.Common.dll \
|
||||
$(CASALIBDIR)/Novell.CASA.miCASAWrapper.dll \
|
||||
$(CASALIBDIR)/Novell.CASA.A-D.dll \
|
||||
$(CASALIBDIR)/Novell.CASA.CASAPolicy.dll
|
||||
|
@ -269,6 +269,17 @@ namespace sscs.verbs
|
||||
string sOldDir = cpd.GetOldDirectory();
|
||||
string sNewDir = cpd.GetNewDirectory();
|
||||
|
||||
|
||||
#if LINUX
|
||||
// only allow /home and /media directories on linux
|
||||
if ((!sNewDir.StartsWith("/home")) && (!sNewDir.StartsWith("/media")))
|
||||
{
|
||||
cpd.SetErrorMessage("Directory not allowed");
|
||||
return wo;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// copy all .miCASA* files to new location
|
||||
string[] files = Directory.GetFiles(sOldDir, ".miCASA*");
|
||||
if (files != null)
|
||||
|
Loading…
Reference in New Issue
Block a user