file() and Win32 security attributes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gerson Kurz

    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 :)


  • Roger Upole

    #2
    Re: file() and Win32 security attributes

    You could avoid rewriting a lot of code by adding a call to
    win32security.S etFileSecurity after the file is closed.
    Alternately, you can change the default permissions for
    new files using win32security.S etTokenInformat ion to modify
    TokenDefaultDac l, 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" <gerson.kurz@ t-online.de> wrote in message
    news:403e2bfd.9 144015@news.t-online.de...[color=blue]
    > 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 :)
    >
    >[/color]


    Comment

    • Paul Miller

      #3
      When things go badly in PyGC_Collect()

      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.




      Comment

      • Terry Reedy

        #4
        Re: When things go badly in PyGC_Collect()


        "Paul Miller" <paul@fxtech.co m> wrote in message
        news:6.0.1.1.2. 20040227102910. 02e02ec0@mail.f xtech.com...[color=blue]
        > I'm running into a situation where the first call to PyCG_Collect during[/color]
        a[color=blue]
        > 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.[/color]

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

        tjr




        Comment

        • Paul Miller

          #5
          Re: When things go badly in PyGC_Collect()

          [color=blue][color=green]
          > > Some notes - this is with Python 2.3 BTW, on Windows.[/color]
          >
          >The most recent one? I belive 2.3.3 had some bug fixes in this area.[/color]

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




          Comment

          • Paul Miller

            #6
            Re: When things go badly in PyGC_Collect()

            [color=blue][color=green]
            > > Some notes - this is with Python 2.3 BTW, on Windows.[/color]
            >
            >The most recent one? I belive 2.3.3 had some bug fixes in this area.[/color]

            Nope - didn't seem to make a difference.



            Comment

            • Aahz

              #7
              Re: When things go badly in PyGC_Collect()

              In article <mailman.202.10 77899652.8594.p ython-list@python.org >,
              Paul Miller <paul@fxtech.co m> wrote:[color=blue]
              >
              >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[/color]

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

              "Do not taunt happy fun for loops. Do not change lists you are looping over."
              --Remco Gerlich, comp.lang.pytho n

              Comment

              • Michael Hudson

                #8
                Re: When things go badly in PyGC_Collect()

                Paul Miller <paul@fxtech.co m> writes:
                [color=blue]
                > 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.[/color]

                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"

                Comment

                • Josiah Carlson

                  #9
                  Re: file() and Win32 security attributes

                  Gerson Kurz wrote:[color=blue]
                  > 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 :)[/color]

                  If you have win2k, install xcacls:


                  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

                  Comment

                  Working...