[Spice-devel,vdagent-win,2/6] file_xfer: create file with user privileges

Submitted by Uri Lublin on Nov. 7, 2013, 10:02 p.m.

Details

Message ID 1383861776-25959-3-git-send-email-uril@redhat.com
State Superseded
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin Nov. 7, 2013, 10:02 p.m.

Patch hide | download patch | download mbox

diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index 66b489a..2a6480a 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -21,6 +21,7 @@ 
 #include <inttypes.h>
 #include <stdio.h>
 #include "file_xfer.h"
+#include "as_user.h"

 FileXfer::~FileXfer()
 {
@@ -44,6 +45,7 @@  void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
     FileXferTask* task;
     uint64_t file_size;
     HANDLE handle;
+    AsUser as_user;

     status->id = start->id;
     status->result = VD_AGENT_FILE_XFER_STATUS_ERROR;
@@ -53,6 +55,11 @@  void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
         return;
     }
     vd_printf("%u %s (%" PRIu64 ")", start->id, file_name, file_size);
+    if (!as_user.begin()) {
+        vd_printf("as_user failed");
+        return;
+    }
+
     if (FAILED(SHGetFolderPathA(NULL, CSIDL_COMMON_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL,
             SHGFP_TYPE_CURRENT, file_path))) {
         vd_printf("failed getting desktop path");