Prevent users from moving .miCASA files to directories

other than /home/... or /media/...
This commit is contained in:
Jim Norman 2006-09-27 21:13:35 +00:00
parent af925e58c1
commit e2db0e3ecc
5 changed files with 94 additions and 6 deletions

View File

@ -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 Wed Sep 27 11:57:09 MDT 2006 - jnorman@novell.com

View File

@ -2189,7 +2189,29 @@ namespace Novell.CASA.GUI
{ {
if (Directory.Exists(sDirectory)) 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 else
{ {

View File

@ -81,6 +81,8 @@ namespace Novell.CASA.GUI
//if (m_currentDirectory.EndsWith(m_pathSeparator)) //if (m_currentDirectory.EndsWith(m_pathSeparator))
// m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.Length - 1); // m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.Length - 1);
SetNewFolderButton();
DisplayDirectory(); DisplayDirectory();
} }
@ -204,12 +206,22 @@ namespace Novell.CASA.GUI
} }
#if LINUX
tsDrives.AppendValues("/home");
tsDrives.AppendValues("/media");
#else
// show logical drives // show logical drives
string[] drives = Directory.GetLogicalDrives(); string[] drives = Directory.GetLogicalDrives();
for (int i=0; i<drives.Length; i++) for (int i=0; i<drives.Length; i++)
{ {
tsDrives.AppendValues(drives[i]); tsDrives.AppendValues(drives[i]);
} }
#endif
SetNewFolderButton();
treeviewFavorites.AppendColumn("Drive", new CellRendererText(), "text", 0); treeviewFavorites.AppendColumn("Drive", new CellRendererText(), "text", 0);
treeviewFavorites.Model = tsDrives; treeviewFavorites.Model = tsDrives;
@ -259,8 +271,7 @@ namespace Novell.CASA.GUI
for (int i=0; i<dirs.Length; i++) 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"); 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) catch (Exception e)
{ {
Console.WriteLine(e.ToString()); Logger.DbgLog(e.ToString());
} }
@ -366,7 +377,7 @@ namespace Novell.CASA.GUI
} }
catch (Exception e) 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 // new folder handler
public void on_buttonNewFolder_clicked(object obj, EventArgs args) public void on_buttonNewFolder_clicked(object obj, EventArgs args)

View File

@ -82,7 +82,8 @@ CSFILES =$(srcdir)/AssemblyInfo.cs \
CSFILES_CSC := $(subst /,$(SEP),$(CSFILES)) CSFILES_CSC := $(subst /,$(SEP),$(CSFILES))
CS_FLAGS = -pkg:gtk-sharp -pkg:glade-sharp -d:LINUX -nowarn:169 CS_FLAGS = -pkg:gtk-sharp -pkg:glade-sharp -d:LINUX -nowarn:169
CS_RESOURCES = 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.miCASAWrapper.dll \
$(CASALIBDIR)/Novell.CASA.A-D.dll \ $(CASALIBDIR)/Novell.CASA.A-D.dll \
$(CASALIBDIR)/Novell.CASA.CASAPolicy.dll $(CASALIBDIR)/Novell.CASA.CASAPolicy.dll

View File

@ -269,6 +269,17 @@ namespace sscs.verbs
string sOldDir = cpd.GetOldDirectory(); string sOldDir = cpd.GetOldDirectory();
string sNewDir = cpd.GetNewDirectory(); 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 // copy all .miCASA* files to new location
string[] files = Directory.GetFiles(sOldDir, ".miCASA*"); string[] files = Directory.GetFiles(sOldDir, ".miCASA*");
if (files != null) if (files != null)