473,226 Members | 1,569 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,226 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 3767
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.