by thomthom » Wed Jun 13, 2012 3:30 pm
I started to look into what happens when you try to write to the plugins folder with SketchUp Ruby when the user doesn't have admin rights. Ruby will say that the files a writable so I was having a hard time finding out how I could detect if the folder was in the virtual store or not. Initial test indicate that this snippet is able to detect if a file or folder exist in the VirtualStore. (Hoping "VirtualStore" is not localized - I think MS stopped doing that from Vista and onwards and XP didn't have the virtualstore.) - Code: Select all
module FileHelper
def self.is_virtual?( file ) filename = File.basename( file ) filepath = File.dirname( file ) unless File.exist?( file ) raise IOError, "The file '#{file}' does not exist." end virtualstore = File.join( ENV['LOCALAPPDATA'], 'VirtualStore' ) path = filepath.split(':')[1] virtualfile = File.join( virtualstore, path, filename ) File.exist?( virtualfile ) end
def self.is_plugins_folder_virtual? plugins_path = Sketchup.find_support_file( 'Plugins' ) self.is_virtual?( plugins_path ) end
end
From what I remember of comments on this forum a non-admin user must give himself access to the plugin folder in order to allow Ruby to write to it. I guess there is no way to make Ruby set these permission - taking care of the problem for the user?
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by thomthom » Thu Jun 14, 2012 2:58 pm
Can you read folder permissions via SU Ruby? And can these permissions be used to determine if a file is truly writeable or if it'll end up in the virtual store.
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by thomthom » Thu Jun 14, 2012 3:06 pm
hm... if the file already exists it appear that Ruby avoids VirtualStore - so is there some system command one can issue to create a file?
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Dan Rathbun » Thu Jun 14, 2012 3:30 pm
thomthom wrote:Can you read folder permissions via SU Ruby?
You should be able to. A directory has always been treated as a "kind" of file. The mixin module FileTest can be mixed into your class, and is already mixed into class File. Also there is the File::Stat class. see the Ruby reference CHM. ADD: and do not forget about Kernel::test()
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5051
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by thomthom » Fri Jun 15, 2012 10:17 am
Permission appear to be identical even though creating a file on the Win8 machine will put it in VirtualStore... Win7 Admin - Code: Select all
#<File::Stat dev=0x2, ino=0, mode=040755, nlink=1, uid=0, gid=0, rdev=0x2, size=0, blksize=nil, blocks=nil, atime=Mon Jun 11 12:44:30 +0200 2012, mtime=Mon Jun 11 12:44:30 +0200 2012, ctime=Wed Aug 03 13:33:27 +0200 2011 >
Win8 - Code: Select all
#<File::Stat dev=0x2, no=0, mode=040755, nlink=1, uid=0, gid=0, rdev=0x2, size=0, blksize=nil, blocks=nil, atime=Thu Jun 14 16:02:35 +0200 2012, mtime=Thu Jun 14 16:02:35 +0200 2012, ctime=Fri Jun 01 10:44:03 +0200 2012 >
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by thomthom » Fri Jun 15, 2012 1:13 pm
thomthom wrote:I used "Run as Administrator" and SketchUp Ruby still wrote to VirtualStore... 
Seems that I didn't actually launch it as administrator - but when I actually did I found I could not drag and drop files from Explorer to a WebDialog. (I'm allowing drag and drop of files to a webdialog for easy installation of Ruby plugins etc.)
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Dan Rathbun » Fri Jun 15, 2012 8:05 pm
So did "Run as Administrator" allow you to write files where you wanted, rather than the VirtualStore ??
And.. are you saying that file writing is even more of a P.I.T.B on Win8, than it was in previous versions ??
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5051
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by thomthom » Sat Jun 16, 2012 1:44 am
Dan Rathbun wrote:So did "Run as Administrator" allow you to write files where you wanted, rather than the VirtualStore ??
Didn't try that - because my fileread was triggered by the drag and drop which was prevented. But it'd be worth testing. Dan Rathbun wrote:And.. are you saying that file writing is even more of a P.I.T.B on Win8, than it was in previous versions ??
I don't know - I've always used an administrator account on Vista and Win7 with UAC disabled. I cannot compare because Win8 is the first Windows OS I've tried with default user access. I suspect it's the same as Win7 and Vista, but I need to verify this.
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Developers' Forum
|