2 * Copyright (c) 2005 Novell, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, contact Novell, Inc.
17 * To contact Novell about this file by physical or electronic mail,
18 * you may find current contact information at www.novell.com
20 * Author : Rohit Kumar
21 * Email ID : rokumar@novell.com
22 * Date : 14th July 2005
33 #include <sys/types.h>
37 #include "rfbtightproto.h"
38 #include "filetransfermsg.h"
39 #include "handlefiletransferrequest.h"
42 pthread_mutex_t fileDownloadMutex = PTHREAD_MUTEX_INITIALIZER;
44 rfbBool fileTransferEnabled = TRUE;
45 rfbBool fileTransferInitted = FALSE;
46 char ftproot[PATH_MAX];
49 /******************************************************************************
50 * File Transfer Init methods. These methods are called for initializating
51 * File Transfer and setting ftproot.
52 ******************************************************************************/
54 void InitFileTransfer();
55 int SetFtpRoot(char* path);
56 char* GetHomeDir(uid_t uid);
57 void FreeHomeDir(char *homedir);
60 * InitFileTransfer method is called before parsing the command-line options
61 * for Xvnc. This sets the ftproot to the Home dir of the user running the Xvnc
62 * server. In case of error ftproot is set to '\0' char.
68 char* userHome = NULL;
69 uid_t uid = geteuid();
71 if(fileTransferInitted)
74 rfbLog("tightvnc-filetransfer/InitFileTransfer\n");
76 memset(ftproot, 0, sizeof(ftproot));
78 userHome = GetHomeDir(uid);
80 if((userHome != NULL) && (strlen(userHome) != 0)) {
82 FreeHomeDir(userHome);
85 fileTransferEnabled = TRUE;
86 fileTransferInitted = TRUE;
90 #define __FUNCTION__ "unknown"
94 * This method is called from InitFileTransfer method and
95 * if the command line option for ftproot is provided.
98 SetFtpRoot(char* path)
100 struct stat stat_buf;
103 rfbLog("tightvnc-filetransfer/SetFtpRoot\n");
105 if((path == NULL) || (strlen(path) == 0) || (strlen(path) > (PATH_MAX - 1))) {
106 rfbLog("File [%s]: Method [%s]: parameter passed is improper, ftproot"
107 " not changed\n", __FILE__, __FUNCTION__);
111 if(stat(path, &stat_buf) < 0) {
112 rfbLog("File [%s]: Method [%s]: Reading stat for file %s failed\n",
113 __FILE__, __FUNCTION__, path);
117 if(S_ISDIR(stat_buf.st_mode) == 0) {
118 rfbLog("File [%s]: Method [%s]: path specified is not a directory\n",
119 __FILE__, __FUNCTION__);
123 if((dir = opendir(path)) == NULL) {
124 rfbLog("File [%s]: Method [%s]: Not able to open the directory\n",
125 __FILE__, __FUNCTION__);
134 memset(ftproot, 0, PATH_MAX);
135 if(path[strlen(path)-1] == '/') {
136 memcpy(ftproot, path, strlen(path)-1);
139 memcpy(ftproot, path, strlen(path));
147 * Get the home directory for the user name
148 * param: username - name of the user for whom the home directory is required.
149 * returns: returns the home directory for the user, or null in case the entry
150 * is not found or any error. The returned string must be freed by calling the
151 * freehomedir function.
154 GetHomeDir(uid_t uid)
156 struct passwd *pwEnt = NULL;
157 char *homedir = NULL;
159 pwEnt = getpwuid (uid);
163 if(pwEnt->pw_dir != NULL) {
164 homedir = strdup (pwEnt->pw_dir);
172 * Free the home directory allocated by a previous call to retrieve the home
173 * directory. param: homedir - the string returned by a previous call to
174 * retrieve home directory for a user.
177 FreeHomeDir(char *homedir)
183 /******************************************************************************
185 ******************************************************************************/
188 * When the console sends the File Transfer Request, it sends the file path with
189 * ftproot as "/". So on Agent, to get the absolute file path we need to prepend
193 ConvertPath(char* path)
196 memset(p, 0, PATH_MAX);
198 if( (path == NULL) ||
199 (strlen(path) == 0) ||
200 (strlen(path)+strlen(ftproot) > PATH_MAX - 1) ) {
202 rfbLog("File [%s]: Method [%s]: cannot create path for file transfer\n",
203 __FILE__, __FUNCTION__);
207 memcpy(p, path, strlen(path));
208 memset(path, 0, PATH_MAX);
209 sprintf(path, "%s%s", ftproot, p);
216 EnableFileTransfer(rfbBool enable)
218 fileTransferEnabled = enable;
223 IsFileTransferEnabled()
225 return fileTransferEnabled;
236 /******************************************************************************
237 * Methods to Handle File List Request.
238 ******************************************************************************/
241 * HandleFileListRequest method is called when the server receives
242 * FileListRequest. In case of success a file list is sent to the client.
243 * For File List Request there is no failure reason sent.So here in case of any
244 * "unexpected" error no information will be sent. As these conditions should
245 * never come. Lets hope it never arrives :)
246 * In case of dir open failure an empty list will be sent, just the header of
247 * the message filled up. So on console you will get an Empty listing.
250 HandleFileListRequest(rfbClientPtr cl, rfbTightClientRec* data)
252 rfbClientToServerTightMsg msg;
254 char path[PATH_MAX]; /* PATH_MAX has the value 4096 and is defined in limits.h */
255 FileTransferMsg fileListMsg;
257 memset(&msg, 0, sizeof(rfbClientToServerTightMsg));
258 memset(path, 0, PATH_MAX);
259 memset(&fileListMsg, 0, sizeof(FileTransferMsg));
262 rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n",
263 __FILE__, __FUNCTION__);
267 if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileListRequestMsg-1)) <= 0) {
270 rfbLog("File [%s]: Method [%s]: Socket error while reading dir name"
271 " length\n", __FILE__, __FUNCTION__);
277 msg.flr.dirNameSize = Swap16IfLE(msg.flr.dirNameSize);
278 if ((msg.flr.dirNameSize == 0) ||
279 (msg.flr.dirNameSize > (PATH_MAX - 1))) {
281 rfbLog("File [%s]: Method [%s]: Unexpected error:: path length is "
282 "greater that PATH_MAX\n", __FILE__, __FUNCTION__);
287 if((n = rfbReadExact(cl, path, msg.flr.dirNameSize)) <= 0) {
290 rfbLog("File [%s]: Method [%s]: Socket error while reading dir name\n",
291 __FILE__, __FUNCTION__);
297 if(ConvertPath(path) == NULL) {
299 /* The execution should never reach here */
300 rfbLog("File [%s]: Method [%s]: Unexpected error: path is NULL",
301 __FILE__, __FUNCTION__);
305 fileListMsg = GetFileListResponseMsg(path, (char) (msg.flr.flags));
307 if((fileListMsg.data == NULL) || (fileListMsg.length == 0)) {
309 rfbLog("File [%s]: Method [%s]: Unexpected error:: Data to be sent is "
310 "of Zero length\n", __FILE__, __FUNCTION__);
314 rfbWriteExact(cl, fileListMsg.data, fileListMsg.length);
316 FreeFileTransferMsg(fileListMsg);
320 /******************************************************************************
321 * Methods to Handle File Download Request.
322 ******************************************************************************/
324 void HandleFileDownloadLengthError(rfbClientPtr cl, short fNameSize);
325 void SendFileDownloadLengthErrMsg(rfbClientPtr cl);
326 void HandleFileDownload(rfbClientPtr cl, rfbTightClientPtr data);
328 void HandleFileDownloadRequest(rfbClientPtr cl);
329 void SendFileDownloadErrMsg(rfbClientPtr cl);
330 void* RunFileDownloadThread(void* client);
334 * HandleFileDownloadRequest method is called when the server receives
335 * rfbFileDownload request message.
338 HandleFileDownloadRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
341 char path[PATH_MAX]; /* PATH_MAX has the value 4096 and is defined in limits.h */
342 rfbClientToServerTightMsg msg;
344 memset(path, 0, sizeof(path));
345 memset(&msg, 0, sizeof(rfbClientToServerTightMsg));
349 rfbLog("File [%s]: Method [%s]: Unexpected error:: rfbClientPtr is null\n",
350 __FILE__, __FUNCTION__);
354 if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileDownloadRequestMsg-1)) <= 0) {
357 rfbLog("File [%s]: Method [%s]: Error while reading dir name length\n",
358 __FILE__, __FUNCTION__);
364 msg.fdr.fNameSize = Swap16IfLE(msg.fdr.fNameSize);
365 msg.fdr.position = Swap16IfLE(msg.fdr.position);
367 if ((msg.fdr.fNameSize == 0) ||
368 (msg.fdr.fNameSize > (PATH_MAX - 1))) {
370 rfbLog("File [%s]: Method [%s]: Error: path length is greater than"
371 " PATH_MAX\n", __FILE__, __FUNCTION__);
373 HandleFileDownloadLengthError(cl, msg.fdr.fNameSize);
377 if((n = rfbReadExact(cl, rtcp->rcft.rcfd.fName, msg.fdr.fNameSize)) <= 0) {
380 rfbLog("File [%s]: Method [%s]: Error while reading dir name length\n",
381 __FILE__, __FUNCTION__);
386 rtcp->rcft.rcfd.fName[msg.fdr.fNameSize] = '\0';
388 if(ConvertPath(rtcp->rcft.rcfd.fName) == NULL) {
390 rfbLog("File [%s]: Method [%s]: Unexpected error: path is NULL",
391 __FILE__, __FUNCTION__);
394 /* This condition can come only if the file path is greater than
395 PATH_MAX. So sending file path length error msg back to client.
398 SendFileDownloadLengthErrMsg(cl);
402 HandleFileDownload(cl, rtcp);
408 HandleFileDownloadLengthError(rfbClientPtr cl, short fNameSize)
413 if((path = (char*) calloc(fNameSize, sizeof(char))) == NULL) {
414 rfbLog("File [%s]: Method [%s]: Fatal Error: Alloc failed\n",
415 __FILE__, __FUNCTION__);
418 if((n = rfbReadExact(cl, path, fNameSize)) <= 0) {
421 rfbLog("File [%s]: Method [%s]: Error while reading dir name\n",
422 __FILE__, __FUNCTION__);
439 SendFileDownloadLengthErrMsg(cl);
444 SendFileDownloadLengthErrMsg(rfbClientPtr cl)
446 FileTransferMsg fileDownloadErrMsg;
448 memset(&fileDownloadErrMsg, 0 , sizeof(FileTransferMsg));
450 fileDownloadErrMsg = GetFileDownloadLengthErrResponseMsg();
452 if((fileDownloadErrMsg.data == NULL) || (fileDownloadErrMsg.length == 0)) {
453 rfbLog("File [%s]: Method [%s]: Unexpected error: fileDownloadErrMsg "
454 "is null\n", __FILE__, __FUNCTION__);
458 rfbWriteExact(cl, fileDownloadErrMsg.data, fileDownloadErrMsg.length);
460 FreeFileTransferMsg(fileDownloadErrMsg);
463 extern rfbTightClientPtr rfbGetTightClientData(rfbClientPtr cl);
466 RunFileDownloadThread(void* client)
468 rfbClientPtr cl = (rfbClientPtr) client;
469 rfbTightClientPtr rtcp = rfbGetTightClientData(cl);
470 FileTransferMsg fileDownloadMsg;
475 memset(&fileDownloadMsg, 0, sizeof(FileTransferMsg));
477 pthread_mutex_lock(&fileDownloadMutex);
478 fileDownloadMsg = GetFileDownloadResponseMsgInBlocks(cl, rtcp);
479 pthread_mutex_unlock(&fileDownloadMutex);
481 if((fileDownloadMsg.data != NULL) && (fileDownloadMsg.length != 0)) {
482 if(rfbWriteExact(cl, fileDownloadMsg.data, fileDownloadMsg.length) < 0) {
483 rfbLog("File [%s]: Method [%s]: Error while writing to socket \n"
484 , __FILE__, __FUNCTION__);
488 CloseUndoneFileTransfer(cl, rtcp);
491 FreeFileTransferMsg(fileDownloadMsg);
494 FreeFileTransferMsg(fileDownloadMsg);
496 } while(rtcp->rcft.rcfd.downloadInProgress == TRUE);
502 HandleFileDownload(rfbClientPtr cl, rfbTightClientPtr rtcp)
504 pthread_t fileDownloadThread;
505 FileTransferMsg fileDownloadMsg;
507 memset(&fileDownloadMsg, 0, sizeof(FileTransferMsg));
508 fileDownloadMsg = ChkFileDownloadErr(cl, rtcp);
509 if((fileDownloadMsg.data != NULL) && (fileDownloadMsg.length != 0)) {
510 rfbWriteExact(cl, fileDownloadMsg.data, fileDownloadMsg.length);
511 FreeFileTransferMsg(fileDownloadMsg);
514 rtcp->rcft.rcfd.downloadInProgress = FALSE;
515 rtcp->rcft.rcfd.downloadFD = -1;
517 if(pthread_create(&fileDownloadThread, NULL, RunFileDownloadThread, (void*)
519 FileTransferMsg ftm = GetFileDownLoadErrMsg();
521 rfbLog("File [%s]: Method [%s]: Download thread creation failed\n",
522 __FILE__, __FUNCTION__);
524 if((ftm.data != NULL) && (ftm.length != 0)) {
525 rfbWriteExact(cl, ftm.data, ftm.length);
526 FreeFileTransferMsg(ftm);
535 /******************************************************************************
536 * Methods to Handle File Download Cancel Request.
537 ******************************************************************************/
541 HandleFileDownloadCancelRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
545 rfbClientToServerTightMsg msg;
547 memset(&msg, 0, sizeof(rfbClientToServerTightMsg));
549 if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileDownloadCancelMsg-1)) <= 0) {
552 rfbLog("File [%s]: Method [%s]: Error while reading "
553 "FileDownloadCancelMsg\n", __FILE__, __FUNCTION__);
559 msg.fdc.reasonLen = Swap16IfLE(msg.fdc.reasonLen);
561 if(msg.fdc.reasonLen == 0) {
562 rfbLog("File [%s]: Method [%s]: reason length received is Zero\n",
563 __FILE__, __FUNCTION__);
567 reason = (char*) calloc(msg.fdc.reasonLen + 1, sizeof(char));
569 rfbLog("File [%s]: Method [%s]: Fatal Error: Memory alloc failed\n",
570 __FILE__, __FUNCTION__);
574 if((n = rfbReadExact(cl, reason, msg.fdc.reasonLen)) <= 0) {
577 rfbLog("File [%s]: Method [%s]: Error while reading "
578 "FileDownloadCancelMsg\n", __FILE__, __FUNCTION__);
583 rfbLog("File [%s]: Method [%s]: File Download Cancel Request received:"
584 " reason <%s>\n", __FILE__, __FUNCTION__, reason);
586 pthread_mutex_lock(&fileDownloadMutex);
587 CloseUndoneFileTransfer(cl, rtcp);
588 pthread_mutex_unlock(&fileDownloadMutex);
598 /******************************************************************************
599 * Methods to Handle File upload request
600 ******************************************************************************/
603 void HandleFileUploadRequest(rfbClientPtr cl);
605 void HandleFileUpload(rfbClientPtr cl, rfbTightClientPtr data);
606 void HandleFileUploadLengthError(rfbClientPtr cl, short fNameSize);
607 void SendFileUploadLengthErrMsg(rfbClientPtr cl);
611 HandleFileUploadRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
614 char path[PATH_MAX]; /* PATH_MAX has the value 4096 and is defined in limits.h */
615 rfbClientToServerTightMsg msg;
617 memset(path, 0, PATH_MAX);
618 memset(&msg, 0, sizeof(rfbClientToServerTightMsg));
621 rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n",
622 __FILE__, __FUNCTION__);
626 if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileUploadRequestMsg-1)) <= 0) {
629 rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n",
630 __FILE__, __FUNCTION__);
636 msg.fupr.fNameSize = Swap16IfLE(msg.fupr.fNameSize);
637 msg.fupr.position = Swap16IfLE(msg.fupr.position);
639 if ((msg.fupr.fNameSize == 0) ||
640 (msg.fupr.fNameSize > (PATH_MAX - 1))) {
642 rfbLog("File [%s]: Method [%s]: error: path length is greater than PATH_MAX\n",
643 __FILE__, __FUNCTION__);
644 HandleFileUploadLengthError(cl, msg.fupr.fNameSize);
648 if((n = rfbReadExact(cl, rtcp->rcft.rcfu.fName, msg.fupr.fNameSize)) <= 0) {
651 rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n"
652 __FILE__, __FUNCTION__);
657 rtcp->rcft.rcfu.fName[msg.fupr.fNameSize] = '\0';
659 if(ConvertPath(rtcp->rcft.rcfu.fName) == NULL) {
660 rfbLog("File [%s]: Method [%s]: Unexpected error: path is NULL\n",
661 __FILE__, __FUNCTION__);
663 /* This may come if the path length exceeds PATH_MAX.
664 So sending path length error to client
666 SendFileUploadLengthErrMsg(cl);
670 HandleFileUpload(cl, rtcp);
675 HandleFileUploadLengthError(rfbClientPtr cl, short fNameSize)
680 if((path = (char*) calloc(fNameSize, sizeof(char))) == NULL) {
681 rfbLog("File [%s]: Method [%s]: Fatal Error: Alloc failed\n",
682 __FILE__, __FUNCTION__);
685 if((n = rfbReadExact(cl, path, fNameSize)) <= 0) {
688 rfbLog("File [%s]: Method [%s]: Error while reading dir name\n",
689 __FILE__, __FUNCTION__);
701 rfbLog("File [%s]: Method [%s]: File Upload Length Error occured"
702 "file path requested is <%s>\n", __FILE__, __FUNCTION__, path);
709 SendFileUploadLengthErrMsg(cl);
713 SendFileUploadLengthErrMsg(rfbClientPtr cl)
716 FileTransferMsg fileUploadErrMsg;
718 memset(&fileUploadErrMsg, 0, sizeof(FileTransferMsg));
719 fileUploadErrMsg = GetFileUploadLengthErrResponseMsg();
721 if((fileUploadErrMsg.data == NULL) || (fileUploadErrMsg.length == 0)) {
722 rfbLog("File [%s]: Method [%s]: Unexpected error: fileUploadErrMsg is null\n",
723 __FILE__, __FUNCTION__);
727 rfbWriteExact(cl, fileUploadErrMsg.data, fileUploadErrMsg.length);
728 FreeFileTransferMsg(fileUploadErrMsg);
732 HandleFileUpload(rfbClientPtr cl, rfbTightClientPtr rtcp)
734 FileTransferMsg fileUploadErrMsg;
736 memset(&fileUploadErrMsg, 0, sizeof(FileTransferMsg));
738 rtcp->rcft.rcfu.uploadInProgress = FALSE;
739 rtcp->rcft.rcfu.uploadFD = -1;
741 fileUploadErrMsg = ChkFileUploadErr(cl, rtcp);
742 if((fileUploadErrMsg.data != NULL) && (fileUploadErrMsg.length != 0)) {
743 rfbWriteExact(cl, fileUploadErrMsg.data, fileUploadErrMsg.length);
744 FreeFileTransferMsg(fileUploadErrMsg);
749 /******************************************************************************
750 * Methods to Handle File Upload Data Request
751 *****************************************************************************/
753 void HandleFileUploadWrite(rfbClientPtr cl, rfbTightClientPtr rtcp, char* pBuf);
757 HandleFileUploadDataRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
761 rfbClientToServerTightMsg msg;
763 memset(&msg, 0, sizeof(rfbClientToServerTightMsg));
766 rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n",
767 __FILE__, __FUNCTION__);
771 if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileUploadDataMsg-1)) <= 0) {
774 rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n",
775 __FILE__, __FUNCTION__);
781 msg.fud.realSize = Swap16IfLE(msg.fud.realSize);
782 msg.fud.compressedSize = Swap16IfLE(msg.fud.compressedSize);
783 if((msg.fud.realSize == 0) && (msg.fud.compressedSize == 0)) {
784 if((n = rfbReadExact(cl, (char*)&(rtcp->rcft.rcfu.mTime), sizeof(unsigned
788 rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n",
789 __FILE__, __FUNCTION__);
795 FileUpdateComplete(cl, rtcp);
799 pBuf = (char*) calloc(msg.fud.compressedSize, sizeof(char));
801 rfbLog("File [%s]: Method [%s]: Memory alloc failed\n", __FILE__, __FUNCTION__);
804 if((n = rfbReadExact(cl, pBuf, msg.fud.compressedSize)) <= 0) {
807 rfbLog("File [%s]: Method [%s]: Error while reading FileUploadRequestMsg\n",
808 __FILE__, __FUNCTION__);
819 if(msg.fud.compressedLevel != 0) {
821 memset(&ftm, 0, sizeof(FileTransferMsg));
823 ftm = GetFileUploadCompressedLevelErrMsg();
825 if((ftm.data != NULL) && (ftm.length != 0)) {
826 rfbWriteExact(cl, ftm.data, ftm.length);
827 FreeFileTransferMsg(ftm);
830 CloseUndoneFileTransfer(cl, rtcp);
840 rtcp->rcft.rcfu.fSize = msg.fud.compressedSize;
842 HandleFileUploadWrite(cl, rtcp, pBuf);
853 HandleFileUploadWrite(rfbClientPtr cl, rfbTightClientPtr rtcp, char* pBuf)
856 memset(&ftm, 0, sizeof(FileTransferMsg));
858 ftm = ChkFileUploadWriteErr(cl, rtcp, pBuf);
860 if((ftm.data != NULL) && (ftm.length != 0)) {
861 rfbWriteExact(cl, ftm.data, ftm.length);
862 FreeFileTransferMsg(ftm);
867 /******************************************************************************
868 * Methods to Handle File Upload Failed Request.
869 ******************************************************************************/
873 HandleFileUploadFailedRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
877 rfbClientToServerTightMsg msg;
879 memset(&msg, 0, sizeof(rfbClientToServerTightMsg));
882 rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n",
883 __FILE__, __FUNCTION__);
887 if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileUploadFailedMsg-1)) <= 0) {
890 rfbLog("File [%s]: Method [%s]: Error while reading FileUploadFailedMsg\n",
891 __FILE__, __FUNCTION__);
897 msg.fuf.reasonLen = Swap16IfLE(msg.fuf.reasonLen);
898 if(msg.fuf.reasonLen == 0) {
899 rfbLog("File [%s]: Method [%s]: reason length received is Zero\n",
900 __FILE__, __FUNCTION__);
905 reason = (char*) calloc(msg.fuf.reasonLen + 1, sizeof(char));
907 rfbLog("File [%s]: Method [%s]: Memory alloc failed\n", __FILE__, __FUNCTION__);
911 if((n = rfbReadExact(cl, reason, msg.fuf.reasonLen)) <= 0) {
914 rfbLog("File [%s]: Method [%s]: Error while reading FileUploadFailedMsg\n",
915 __FILE__, __FUNCTION__);
927 rfbLog("File [%s]: Method [%s]: File Upload Failed Request received:"
928 " reason <%s>\n", __FILE__, __FUNCTION__, reason);
930 CloseUndoneFileTransfer(cl, rtcp);
940 /******************************************************************************
941 * Methods to Handle File Create Request.
942 ******************************************************************************/
946 HandleFileCreateDirRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
949 char dirName[PATH_MAX];
950 rfbClientToServerTightMsg msg;
952 memset(dirName, 0, PATH_MAX);
953 memset(&msg, 0, sizeof(rfbClientToServerTightMsg));
956 rfbLog("File [%s]: Method [%s]: Unexpected error: rfbClientPtr is null\n",
957 __FILE__, __FUNCTION__);
961 if((n = rfbReadExact(cl, ((char *)&msg)+1, sz_rfbFileCreateDirRequestMsg-1)) <= 0) {
964 rfbLog("File [%s]: Method [%s]: Error while reading FileCreateDirRequestMsg\n",
965 __FILE__, __FUNCTION__);
971 msg.fcdr.dNameLen = Swap16IfLE(msg.fcdr.dNameLen);
973 /* TODO :: chk if the dNameLen is greater than PATH_MAX */
975 if((n = rfbReadExact(cl, dirName, msg.fcdr.dNameLen)) <= 0) {
978 rfbLog("File [%s]: Method [%s]: Error while reading FileUploadFailedMsg\n",
979 __FILE__, __FUNCTION__);
985 if(ConvertPath(dirName) == NULL) {
986 rfbLog("File [%s]: Method [%s]: Unexpected error: path is NULL\n",
987 __FILE__, __FUNCTION__);
992 CreateDirectory(dirName);