Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Why SQL Server sucked on Friday

Why SQL Server sucked on Friday

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasesysadminhelpsql-serversecurity
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gary R Wheeler
    wrote on last edited by
    #1

    Our application uses SQL Server 2005 Express for a couple small data bases. I was adding logic to our migration app (moves the product from one machine to another) to backup the data bases. The simplest way to do this was to spawn SQLCMD to execute a backup command:

    BACKUP DATABASE CPT TO DISK='C:\...\FILE.BAK'

    It worked fine at the command line, producing a nice backup file I could then include in the migration data. Spawning SQLCMD from my migration tool was another story however. The command created the backup file, which my app would then get an 'access denied' error. The file exists in the path I specified, and is the right size. Right-click, Properties, select the Security tab, and I get a message that I'm not allowed to view the security properties of the file unless I take ownership of it. What. The. Fuck. As closely as I can tell, when SQLCMD is run from a command window, it tells the SQL service to create the backup file with administrator access. If SQLCMD is run from another process, the SQL service creates the backup file under the account it's running under, usually Network Service. In other words, it creates a file for you that you can't use. After much cursing, Googling, a brief foray into the MSDN, and stifling the urge to e-mail a pocket nuke to Redmond, I discovered the solution. If you create the backup file yourself (with zero length), SQL Server will go ahead and 'append' to the existing file, leaving the file ownership and security settings alone. Adding two lines of code, a call to CreateFile() and one to CloseHandle() fixed the problem. What pisses me off about this is that, since they clearly know how to set the file ownership properly when the command is run interactively, why not do it all the time? Isn't is harder to screw this up than it is to do it right? :mad:

    Software Zen: delete this;

    OriginalGriffO 1 Reply Last reply
    0
    • G Gary R Wheeler

      Our application uses SQL Server 2005 Express for a couple small data bases. I was adding logic to our migration app (moves the product from one machine to another) to backup the data bases. The simplest way to do this was to spawn SQLCMD to execute a backup command:

      BACKUP DATABASE CPT TO DISK='C:\...\FILE.BAK'

      It worked fine at the command line, producing a nice backup file I could then include in the migration data. Spawning SQLCMD from my migration tool was another story however. The command created the backup file, which my app would then get an 'access denied' error. The file exists in the path I specified, and is the right size. Right-click, Properties, select the Security tab, and I get a message that I'm not allowed to view the security properties of the file unless I take ownership of it. What. The. Fuck. As closely as I can tell, when SQLCMD is run from a command window, it tells the SQL service to create the backup file with administrator access. If SQLCMD is run from another process, the SQL service creates the backup file under the account it's running under, usually Network Service. In other words, it creates a file for you that you can't use. After much cursing, Googling, a brief foray into the MSDN, and stifling the urge to e-mail a pocket nuke to Redmond, I discovered the solution. If you create the backup file yourself (with zero length), SQL Server will go ahead and 'append' to the existing file, leaving the file ownership and security settings alone. Adding two lines of code, a call to CreateFile() and one to CloseHandle() fixed the problem. What pisses me off about this is that, since they clearly know how to set the file ownership properly when the command is run interactively, why not do it all the time? Isn't is harder to screw this up than it is to do it right? :mad:

      Software Zen: delete this;

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      You are forgetting something: MS is "customer focussed". As in, MS likes to "foc" it's customers in the "uss" as much as it can...

      Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      G 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        You are forgetting something: MS is "customer focussed". As in, MS likes to "foc" it's customers in the "uss" as much as it can...

        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

        G Offline
        G Offline
        Gary R Wheeler
        wrote on last edited by
        #3

        The least they could do is take me out to dinner and a movie first.

        Software Zen: delete this;

        S 1 Reply Last reply
        0
        • G Gary R Wheeler

          The least they could do is take me out to dinner and a movie first.

          Software Zen: delete this;

          S Offline
          S Offline
          sucram
          wrote on last edited by
          #4

          I'd rather not have them "foc" me in the "uss" and they can keep their dinner.

          Ego non sum semper iustus tamen Ego sum nunquam nefas!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups