473,378 Members | 1,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

file() and Win32 security attributes

Hi all, a quick question: how can I force file() to create files that
have "ALL ACCESS FOR EVERYONE" security attributes? Other than by a
major rewrite of my existing code modules replacing the existing
"native-python" code by win32file / win32security calls?

In case you're wondering what is happening here:

- user A with admin rights logs on to NT and uses python to create a
file
- user A logs off
- user B without admin rights logs on to NT and uses python to access
said file -> doesn't work, because B has no admin rights and cannot
access files created by an administrator.

Most feasible solution is AAFE, because a more finegrained ACL is a
nightmare to maintain :)
Jul 18 '05 #1
8 3778
You could avoid rewriting a lot of code by adding a call to
win32security.SetFileSecurity after the file is closed.
Alternately, you can change the default permissions for
new files using win32security.SetTokenInformation to modify
TokenDefaultDacl, but that gets more complicated. Also, it
doesn't apply if the directory it's created in has an inheritable
DACL.
hth
Roger

"Gerson Kurz" <ge*********@t-online.de> wrote in message
news:40**************@news.t-online.de...
Hi all, a quick question: how can I force file() to create files that
have "ALL ACCESS FOR EVERYONE" security attributes? Other than by a
major rewrite of my existing code modules replacing the existing
"native-python" code by win32file / win32security calls?

In case you're wondering what is happening here:

- user A with admin rights logs on to NT and uses python to create a
file
- user A logs off
- user B without admin rights logs on to NT and uses python to access
said file -> doesn't work, because B has no admin rights and cannot
access files created by an administrator.

Most feasible solution is AAFE, because a more finegrained ACL is a
nightmare to maintain :)

Jul 18 '05 #2
I'm running into a situation where the first call to PyCG_Collect during a
Py_Finalize, is dying a horrible death and throwing an exception. It is
after *MANY* iterations of the GC loop, so I haven't pinpointed where
exactly it is happening.

Some notes - this is with Python 2.3 BTW, on Windows.

1. this happens in some code where I'm initializing Python, doing some
script/module stuff, finalizing Python, and then doing the process again
2. it happens on the SECOND time, during the Py_Finalize
3. it only seems to happen if I've used the zip importer
4. it DOES NOT happen in a trivial test program I wrote that doesn't have
all the massive script baggage in my real program

My real program has all sorts of custom C types, dictionary mangles, etc.
I'm looking for clues as to what kinds of programming problems with my
custom types could cause PyGC_Collect to go nuts. I've tried to be very
careful about my reference counts.


Jul 18 '05 #3

"Paul Miller" <pa**@fxtech.com> wrote in message
news:6.*******************************@mail.fxtech .com...
I'm running into a situation where the first call to PyCG_Collect during a Py_Finalize, is dying a horrible death and throwing an exception. It is
after *MANY* iterations of the GC loop, so I haven't pinpointed where
exactly it is happening.

Some notes - this is with Python 2.3 BTW, on Windows.


The most recent one? I belive 2.3.3 had some bug fixes in this area.

tjr


Jul 18 '05 #4
Some notes - this is with Python 2.3 BTW, on Windows.


The most recent one? I belive 2.3.3 had some bug fixes in this area.


Really? I'm running 2.3.2. I'll check it out - thanks!


Jul 18 '05 #5
Some notes - this is with Python 2.3 BTW, on Windows.


The most recent one? I belive 2.3.3 had some bug fixes in this area.


Nope - didn't seem to make a difference.

Jul 18 '05 #6
In article <ma*************************************@python.or g>,
Paul Miller <pa**@fxtech.com> wrote:

I'm running into a situation where the first call to PyCG_Collect during a
Py_Finalize, is dying a horrible death and throwing an exception. It is
after *MANY* iterations of the GC loop, so I haven't pinpointed where
exactly it is happening.

Some notes - this is with Python 2.3 BTW, on Windows.

1. this happens in some code where I'm initializing Python, doing some
script/module stuff, finalizing Python, and then doing the process again
2. it happens on the SECOND time, during the Py_Finalize
3. it only seems to happen if I've used the zip importer
4. it DOES NOT happen in a trivial test program I wrote that doesn't have
all the massive script baggage in my real program


What's the exception and stack trace? Are you using weakrefs at all?
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python
Jul 18 '05 #7
Paul Miller <pa**@fxtech.com> writes:
My real program has all sorts of custom C types, dictionary mangles,
etc. I'm looking for clues as to what kinds of programming problems
with my custom types could cause PyGC_Collect to go nuts.


Unfortunately, almost any problem can cause PyGC_Collect to go nuts!
It rarely turns out to be a problem with the cycle collector itself.

A debug build of Python is always a good thing to try in these
circumstances.

Cheers,
mwh

--
This song is for anyone ... fuck it. Shut up and listen.
-- Eminem, "The Way I Am"
Jul 18 '05 #8
Gerson Kurz wrote:
Hi all, a quick question: how can I force file() to create files that
have "ALL ACCESS FOR EVERYONE" security attributes? Other than by a
major rewrite of my existing code modules replacing the existing
"native-python" code by win32file / win32security calls?

In case you're wondering what is happening here:

- user A with admin rights logs on to NT and uses python to create a
file
- user A logs off
- user B without admin rights logs on to NT and uses python to access
said file -> doesn't work, because B has no admin rights and cannot
access files created by an administrator.

Most feasible solution is AAFE, because a more finegrained ACL is a
nightmare to maintain :)


If you have win2k, install xcacls:
http://www.microsoft.com/windows2000...g/xcacls-o.asp

I believe XP and 2003 have it by default.

Play around with the command line version until you have it do what you
want, then perhaps subclass file, and insert permission alteration just
after closing.

- Josiah
Jul 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
3
by: Ben Kial | last post by:
I need to write a program to "copy" files and preserved the files' atime, mtime, ctime, file permissions. I also need to have this program working in Unix and Windows, where the "Archive"...
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
12
by: Mark | last post by:
Hello, in a simple console application I try to create a file with some code like: FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new...
2
by: EP | last post by:
I'm looking for a method by which to access Windows files metadata and have not been able to find anything in the standard modules or via Google - what is the standard approach? Shamefully I...
10
by: JJ | last post by:
How can I get a SiteMapNodeCollection to output as an XML file?
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
2
by: Viewer T. | last post by:
I am trying to write a script that deletes certain files based on certain criteria. What I am trying to do is to automate the process of deleting certain malware files that disguise themselves...
0
by: wolfsbane | last post by:
Alright, here it is I am trying to write a win32 app in VB 2005 to clean up user's profiles. everything works correctly except for the Delete("directory", True) statement. I get a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.