Should have seen this coming - Where to write temp files?
-
What does the "real user" mean. I saw that in the docs but didn't understand the difference between the "effective user" and the "real user".
Also, another thing I am doing in my script. I find their ENV[temp] directory as I showed in my example script. And then I write my own subdir called temp_model and then I try to write files to that subdir. When I make my subdir, I am giving it 777 permissions
mkdir( mydir_string, 777 )
. That should in theory be alloweable right? My subdir should have all the right permissions for me to write to it? -
@unknownuser said:
(http://en.wikipedia.org/wiki/Chmod)":1q6nz2xj]The chmod command accepts up to four digits to represent an octal number. The octets refer to bits applied to the file owner, group and other users, respectively. Use of three digits is discouraged because it leaves the fourth as the default and this value is not fixed.
You can try:
"777".oct
see: String.octalso see: cacls for NT
-
777
is a decimal number.0o777
is an octal number.0xDEADBEEF
is a hexidecimal number. and0b111111111
is a binary.The file permission is a bit field - 3 sets of 3 bits.
If you want to set all 9 bits to 1, use 0o777 because:
0b111_111_111.to_s(8) 777
(You could just use 0b111111111 instead of 0o777, too)
Want to set just the owner to full rights, and deny eveyone else? Use 0700:
0b111000000.to_s(8) 700
-
@chris fullmer said:
What does the "real user" mean. I saw that in the docs but didn't understand the difference between the "effective user" and the "real user".
see the setuid link (below)
@unknownuser said:
(http://en.wikipedia.org/wiki/Chmod#Special_modes)":2b9d9a8z]Special modes
The chmod command is also capable of changing the additional permissions or special modes of a file or directory. The symbolic modes use s to represent the setuid and setgid modes,See also:
Ruby methods:
File.setuid? File.setgid?
At the console:
"%b" % "777".oct
111111111
-> rwxrwxrwx -
@jim said:
777
is a decimal number.0777
is an octal number.0xDEADBEEF
is a hexidecimal number. and0b111111111
is a binary. Enter these in the Ruby Console to see.I could not remember how to specify octals (which is why I went with the
String
method,) until you posted, reminding me of the "0x
" and "0b
" prefixes.0o777
511
so:
"%b" % 0o777
-
i tend to do write temp content next to the Sketchup file and in the end just delete it again.
that location should be writable for sure. -
Yeah, I'm writing a LOT of files and they are persistant while the model is open. So I could have a few thousand files xluttering up someone's desktop hehhe. Might not go over well.
I still can't figure out why my Mac tester's computer won't let me write to his temp folder. It lets me create my folder, but then won't let me write to it.....grr. Oh yes, though come to think of it, he has not tested my new version using the different permission settings the Jim and Dan suggested. I better get him to try that soon.
-
And you may have set the "special" bits, by accident, when you sent int(777) instead of int(511)...
.. I suggest having the tester, totally delete the folder manually, before trying the new version.
-
Ahh, good point.
Thanks so much everyone for all the help always. Its nice to be able to help people from time to and time, and even nicer when there are amazing people out there who are willing and able to help when needed. Very grateful, thanks Dan (et al)
Chris
-
Just noticed ANOTHER standard Ruby extension that bears on this subject.
With a path to the local standard Ruby lib dir pushed into the
$LOAD_PATH
array, you add the following to your module:
require('tmpdir.rb')
This standard extension adds the class methods:
Dir::tmpdir
andDir::mktmpdir
If you read the file, you'll recognize the
Dir::tmpdir
method as the 'progenitor' of the edition in the Google 'webtextures_loader.rb' file. (Google "lifted" it, and stripped out the Win32 specific part.)So (above) when we talked about whether to rely on the WebTextures plugin, my advice is, to instead rely on the Standard Ruby library.
Advertisement