static void
process_open(void)
{
	u_int32_t id, pflags;
	Attrib *a;
	char *name;
	int handle, fd, flags, mode, status = SSH2_FX_FAILURE;

	id = get_int();
	name = get_string(NULL);
	pflags = get_int();		/* portable flags */
	a = get_attrib();
	flags = flags_from_portable(pflags);
	mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666;
	TRACE("open id %u name %s flags %d mode 0%o", id, name, pflags, mode);
	fd = open(name, flags, mode);
	if (fd < 0) {
		status = errno_to_portable(errno);
	} else {
		handle = handle_new(HANDLE_FILE, xstrdup(name), fd, NULL);
		if (handle < 0) {
			close(fd);
		} else {
			send_handle(id, handle);
			status = SSH2_FX_OK;
		}
	}
	if (status != SSH2_FX_OK)
		send_status(id, status);
	xfree(name);
}
Exemplo n.º 2
0
static void
process_opendir(u_int32_t id)
{
	DIR *dirp = NULL;
	char *path;
	int handle, status = SSH2_FX_FAILURE;

	path = get_string(NULL);
	debug3("request %u: opendir", id);
	logit("opendir \"%s\"", path);
	dirp = opendir(path);
	if (dirp == NULL) {
		status = errno_to_portable(errno);
	} else {
		handle = handle_new(HANDLE_DIR, path, 0, 0, dirp);
		if (handle < 0) {
			closedir(dirp);
		} else {
			send_handle(id, handle);
			status = SSH2_FX_OK;
		}

	}
	if (status != SSH2_FX_OK)
		send_status(id, status);
	free(path);
}
static void
process_opendir(void)
{
	DIR *dirp = NULL;
	char *path;
	int handle, status = SSH2_FX_FAILURE;
	u_int32_t id;

	id = get_int();
	path = get_string(NULL);
	TRACE("opendir id %u path %s", id, path);
	dirp = opendir(path);
	if (dirp == NULL) {
		status = errno_to_portable(errno);
	} else {
		handle = handle_new(HANDLE_DIR, xstrdup(path), 0, dirp);
		if (handle < 0) {
			closedir(dirp);
		} else {
			send_handle(id, handle);
			status = SSH2_FX_OK;
		}

	}
	if (status != SSH2_FX_OK)
		send_status(id, status);
	xfree(path);
}
static void
process_opendir(u_int32_t id)
{
	DIR *dirp = NULL;
	char *path;
	int handle, status = SSH2_FX_FAILURE;

	path = get_string(NULL);
	debug3("request %u: opendir", id);
	logit("opendir \"%s\"", path);
	dirp = opendir(path);
	if (dirp == NULL) {
		status = errno_to_portable(errno);
	} else {
		handle = handle_new(HANDLE_DIR, path, 0, 0, dirp);
		if (handle < 0) {
			closedir(dirp);
		} else {
			send_handle(id, handle);
			status = SSH2_FX_OK;
		}

	}
	if (status != SSH2_FX_OK)
		send_status(id, status);

#ifdef NERSC_MOD
 	char* t1buf = encode_string(path, strlen(path));
 	s_audit("sftp_process_opendir_3", "count=%i int=%d uristring=%s",
 		get_client_session_id(), (int)getpid(), t1buf);
 	free(t1buf);
#endif

	free(path);
}
Exemplo n.º 5
0
static void
process_opendir(u_int32_t id)
{
	DIR *dirp = NULL;
	char *path;
	int r, handle, status = SSH2_FX_FAILURE;

	if ((r = sshbuf_get_cstring(iqueue, &path, NULL)) != 0)
		fatal("%s: buffer error: %s", __func__, ssh_err(r));

	debug3("request %u: opendir", id);
	logit("opendir \"%s\"", path);
	dirp = opendir(path);
	if (dirp == NULL) {
		status = errno_to_portable(errno);
	} else {
		handle = handle_new(HANDLE_DIR, path, 0, 0, dirp);
		if (handle < 0) {
			closedir(dirp);
		} else {
			send_handle(id, handle);
			status = SSH2_FX_OK;
		}

	}
	if (status != SSH2_FX_OK)
		send_status(id, status);
	free(path);
}
static void
process_open(u_int32_t id)
{
	u_int32_t pflags;
	Attrib *a;
	char *name;
	int handle, fd, flags, mode, status = SSH2_FX_FAILURE;

	name = get_string(NULL);
	pflags = get_int();		/* portable flags */
	debug3("request %u: open flags %d", id, pflags);
	a = get_attrib();
	flags = flags_from_portable(pflags);
	mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666;
	logit("open \"%s\" flags %s mode 0%o",
	    name, string_from_portable(pflags), mode);
	if (readonly &&
	    ((flags & O_ACCMODE) == O_WRONLY ||
	    (flags & O_ACCMODE) == O_RDWR)) {
		verbose("Refusing open request in read-only mode");
	  	status = SSH2_FX_PERMISSION_DENIED;
	} else {
		fd = open(name, flags, mode);
		if (fd < 0) {
			status = errno_to_portable(errno);
		} else {
			handle = handle_new(HANDLE_FILE, name, fd, flags, NULL);
			if (handle < 0) {
				close(fd);
			} else {
				send_handle(id, handle);
				status = SSH2_FX_OK;
			}
		}
	}
	if (status != SSH2_FX_OK)
		send_status(id, status);

#ifdef NERSC_MOD
        char* t1buf = encode_string( name, strlen(name));
        s_audit("sftp_process_open_3", "count=%i int=%d uristring=%s",
                get_client_session_id(), (int)getppid(), t1buf);
        free(t1buf);
#endif

	free(name);
}
Exemplo n.º 7
0
static void
process_open(u_int32_t id)
{
	u_int32_t pflags;
	Attrib a;
	char *name;
	int r, handle, fd, flags, mode, status = SSH2_FX_FAILURE;

	if ((r = sshbuf_get_cstring(iqueue, &name, NULL)) != 0 ||
	    (r = sshbuf_get_u32(iqueue, &pflags)) != 0 || /* portable flags */
	    (r = decode_attrib(iqueue, &a)) != 0)
		fatal("%s: buffer error: %s", __func__, ssh_err(r));

	debug3("request %u: open flags %d", id, pflags);
	flags = flags_from_portable(pflags);
	mode = (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a.perm : 0666;
	logit("open \"%s\" flags %s mode 0%o",
	    name, string_from_portable(pflags), mode);
	if (readonly &&
	    ((flags & O_ACCMODE) == O_WRONLY ||
	    (flags & O_ACCMODE) == O_RDWR)) {
		verbose("Refusing open request in read-only mode");
		status = SSH2_FX_PERMISSION_DENIED;
	} else {
		fd = open(name, flags, mode);
		if (fd < 0) {
			status = errno_to_portable(errno);
		} else {
			handle = handle_new(HANDLE_FILE, name, fd, flags, NULL);
			if (handle < 0) {
				close(fd);
			} else {
				send_handle(id, handle);
				status = SSH2_FX_OK;
			}
		}
	}
	if (status != SSH2_FX_OK)
		send_status(id, status);
	free(name);
}
static void
process_open(void)
{
	u_int32_t id, pflags;
	Attrib *a;
	char *name;
	int handle, fd, flags, mode, status = SSH2_FX_FAILURE;

	id = get_int();
	name = get_string(NULL);
	pflags = get_int();		/* portable flags */
	debug3("request %u: open flags %d", id, pflags);
	a = get_attrib();
	flags = flags_from_portable(pflags);
	mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666;
	logit("open \"%s\" flags %s mode 0%o",
	    name, string_from_portable(pflags), mode);
	if (readonly &&
	    ((flags & O_ACCMODE) == O_WRONLY || (flags & O_ACCMODE) == O_RDWR))
		status = SSH2_FX_PERMISSION_DENIED;
	else {
		fd = open(name, flags, mode);
		if (fd < 0) {
			status = errno_to_portable(errno);
		} else {
			handle = handle_new(HANDLE_FILE, name, fd, NULL);
			if (handle < 0) {
				close(fd);
			} else {
				send_handle(id, handle);
				status = SSH2_FX_OK;
			}
		}
	}
	if (status != SSH2_FX_OK)
		send_status(id, status);
	xfree(name);
}
Exemplo n.º 9
0
Arquivo: main.c Projeto: AndreRH/wine
DWORD WINAPI WlanOpenHandle(DWORD client_version, void *reserved, DWORD *negotiated_version, HANDLE *handle)
{
    struct wine_wlan *wlan;
    HANDLE ret_handle;

    TRACE("(%u, %p, %p, %p)\n", client_version, reserved, negotiated_version, handle);

    if (reserved || !negotiated_version || !handle)
        return ERROR_INVALID_PARAMETER;

    if (client_version != 1 && client_version != 2)
        return ERROR_NOT_SUPPORTED;

    ret_handle = handle_new(&wlan);
    if (!ret_handle)
        return ERROR_REMOTE_SESSION_LIMIT_EXCEEDED;

    wlan->magic = WLAN_MAGIC;
    wlan->cli_version = *negotiated_version = client_version;
    *handle = ret_handle;

    return ERROR_SUCCESS;
}
Exemplo n.º 10
0
// returns 0 if failed
// else returns handle
int pcm_out_sdl_open( int (*callback)(void *userdata, Uint8 *stream, int len), void *userdata)
{
	SDL_CHAN chan;
	SDL_CHAN *chan_new;
	
	pcm_out_sdl_lock();
	
	if (chan_list == 0)
		chan_list = list_new(sizeof(SDL_CHAN));

	chan.handle = handle_new();
	if (chan.handle == 0)
		return 0;

	chan.callback = callback;
	chan.userdata = userdata;
	chan.avail = 1;
	
	chan_new = list_add(chan_list);
	memcpy(chan_new, &chan, sizeof(SDL_CHAN) );
	
	pcm_out_sdl_unlock();
	return chan.handle;
}
Exemplo n.º 11
0
// test important
PRIVATE
gboolean _inotify_poll()
{
#define EVENT_SIZE  ( sizeof (struct inotify_event) )
#define EVENT_BUF_LEN     ( 1024 * ( EVENT_SIZE + 16 ) )

    if (_inotify_fd != -1) {
        char buffer[EVENT_BUF_LEN];
        int length = read(_inotify_fd, buffer, EVENT_BUF_LEN);

        struct inotify_event *move_out_event = NULL;
        GFile* old = NULL;// test : use real fileops to test it

        for (int i=0; i<length; ) {
            struct inotify_event *event = (struct inotify_event *) &buffer[i];
            i += EVENT_SIZE+event->len;
            if(desktop_file_filter(event->name))
                continue;
            if (event->len) {
                GFile* p = g_hash_table_lookup(_monitor_table, GINT_TO_POINTER(event->wd));

                if (g_file_equal(p, _desktop_file)) {
                    /* BEGIN MOVE EVENT HANDLE */
                    if ((event->mask & IN_MOVED_FROM) && (move_out_event == NULL)) {
                        move_out_event = event;
                        old = g_file_get_child(p, event->name);
                        continue;
                    } else if ((event->mask & IN_MOVED_FROM) && (move_out_event != NULL)) {
                        GFile* f = g_file_get_child(_desktop_file, event->name);
                        handle_delete(f);
                        g_object_unref(f);
                        continue;
                    } else if ((event->mask & IN_MOVED_TO) && (move_out_event != NULL)) {
                        move_out_event = NULL;
                        GFile* f = g_file_get_child(p, event->name);

                        handle_rename(old, f);
                        g_object_unref(f);
                        g_object_unref(old);
                        old = NULL;
                        continue;
                    /* END MVOE EVENT HANDLE */
                    } else if (event->mask & IN_DELETE) {
                        GFile* f = g_file_get_child(p, event->name);
                        handle_delete(f);
                        g_object_unref(f);
                    } else if (event->mask & IN_CREATE) {
                        GFile* f = g_file_get_child(p, event->name);
                        handle_new(f);
                        g_object_unref(f);
                    } else {
                        GFile* f = g_file_get_child(p, event->name);
                        _add_monitor_directory(f);
                        handle_update(f);
                        g_object_unref(f);
                    }

                } else {
                    if (event->mask & IN_MOVED_TO) {
                        GFile* f = g_file_get_child(_desktop_file, event->name);
                        handle_delete(f);
                        g_object_unref(f);
                    }
                    handle_update(p);
                }
            }
        }
        if (move_out_event != NULL) {
            handle_delete(old);
            move_out_event = NULL;
        }
        return TRUE;
    } else {
        return FALSE;
    }
}
Exemplo n.º 12
0
void SFTP::process_opendir(void)
{
	char *utf8_path = 0;
	int handle, status = SSH2_FX_FAILURE;
	u_int32_t id;

  try
  {
	  id = get_int();
	  utf8_path = (char*) get_string(NULL);
	  debug3("request %u: opendir", (unsigned) id);
	  logit("opendir \"%s\"", utf8_path);

    const SFTPFilePath path = pathFact.create_path (utf8_path);
    // TODO empty name as acurrent directory ?

    HANDLE fh = ::CreateFileW
      (path.get_for_call ().c_str (),
       GENERIC_READ | GENERIC_WRITE,
       FILE_SHARE_READ,
       NULL, //FIXME ACL
       // this request is for open only existing directory
       OPEN_EXISTING, 
       //names in different registry are different //UT
       FILE_FLAG_BACKUP_SEMANTICS, 
          // the last option is for obtain a directory handle ( MSDN )
       // TODO make performance experiments with FILE_FLAG_RANDOM_ACCESS , 
       // FILE_FLAG_SEQUENTIAL_SCAN
       NULL
       );

	  if (fh == INVALID_HANDLE_VALUE) {
		  status = errno_to_portable(::GetLastError ());
	  } 
    else 
    {
		  handle = handle_new(HANDLE_DIR, path, 0, fh);
		  if (handle < 0) 
      {
        ::CloseHandle (fh);
		  } 
      else 
      {
			  send_handle(id, handle);
			  status = SSH2_FX_OK;
		  }
	  }
  }
  catch (Path::InvalidPath&)
  {
    //logit 
    status = SSH2_FX_FAILURE; 
    // TODO return the reason
  }
  catch (...)
  {
    status = SSH2_FX_FAILURE; 
    error ("unhandled exception in %s", __FUNCTION__);
  }
	if (status != SSH2_FX_OK)
		send_status(id, status);
	if (utf8_path) xfree(utf8_path);
}
Exemplo n.º 13
0
int handle_event(struct task *task)
{
	int ret;

	if (!task)
		return 0;

	debug(DEBUG_EVENT, "+++ process pid=%d event: %d", task->pid, task->event.type);

	assert(task->stopped);

	if (task->defer_func) {
		ret = task->defer_func(task, task->defer_data);

		if (ret == RET_DELETED)
			return 1;

		task->defer_func = NULL;
		task->defer_data = NULL;
		goto out2;
	}

	struct event *event = &task->event;
	enum event_type type = event->type;

	switch (type) {
	case EVENT_NONE:
		ret = continue_task(task, task->event.e_un.signum);
		break;
	case EVENT_SIGNAL:
		ret = handle_signal(task);
		break;
	case EVENT_ABOUT_EXIT:
		ret = handle_about_exit(task);
		goto out1;
	case EVENT_EXIT:
		ret = handle_exit(task);
		break;
	case EVENT_EXIT_SIGNAL:
		ret = handle_exit_signal(task);
		break;
	case EVENT_FORK:
	case EVENT_VFORK:
	case EVENT_CLONE:
		ret = handle_child(task);
		break;
	case EVENT_EXEC:
		ret = handle_exec(task);
		break;
	case EVENT_BREAKPOINT:
		ret = handle_breakpoint(task);
		goto out2;
	case EVENT_NEW:
		ret = handle_new(task);
		break;
	default:
		fprintf(stderr, "fatal error, unknown event %d\n", type);
		abort();
	}

	if (ret == RET_DELETED)
		return 1;

	if (ret != RET_DEFERED) {
		assert(task->event.type == EVENT_NONE);
		assert(task->stopped == 0);
	}
out2:
	assert(task->is_new == 0);
out1:
	return (ret < 0) ? ret : 0;
}
Exemplo n.º 14
0
static void handle_key( LWPanelID panel, void *pdata, LWDualKey key )
{
   if ( !fp ) return;

   switch ( key )
   {
      case LWDK_SC_UP:     change_pos( pos, -linesize );         break;
      case LWDK_SC_DOWN:   change_pos( pos, linesize );          break;
      case LWDK_SC_LEFT:   change_pos( pos, -1 );                break;
      case LWDK_SC_RIGHT:  change_pos( pos, 1 );                 break;

      case LWDK_PAGEUP:
      case LWDK_PAD_9:     change_pos( pos, -pagesize );         break;
      case LWDK_PAGEDOWN:
      case LWDK_PAD_3:     change_pos( pos, pagesize );          break;
      case LWDK_HOME:
      case LWDK_PAD_7:     change_pos( 0, 0 );                   break;
      case LWDK_END:
      case LWDK_PAD_1:     change_pos( 0, filesize - pagesize ); break;

      case 'p':  handle_print();                  break;
      case 'n':  handle_new( ctl[ 16 ], NULL );   break;
      case 'j':  handle_jump( ctl[ 7 ], NULL );   break;
      case 's':  handle_search( ctl[ 8 ], NULL ); break;
      case '+':  SET_INT( ctl[ 12 ], 1 );         break;
      case '-':  SET_INT( ctl[ 12 ], 2 );         break;
      case '*':  SET_INT( ctl[ 12 ], 0 );         break;
      case 't':  SET_INT( ctl[ 14 ], 0 );         break;
      case 'h':  SET_INT( ctl[ 14 ], 1 );         break;
      case 'c':  SET_INT( ctl[ 14 ], 2 );         break;

      case 'b':
         SET_INT( ctl[ 3 ], 0 );
         handle_datatype( ctl[ 3 ], NULL );
         break;
      case 'w':
         SET_INT( ctl[ 3 ], 1 );
         handle_datatype( ctl[ 3 ], NULL );
         break;
      case 'l':
         SET_INT( ctl[ 3 ], 2 );
         handle_datatype( ctl[ 3 ], NULL );
         break;
      case 'f':
         SET_INT( ctl[ 3 ], 3 );
         handle_datatype( ctl[ 3 ], NULL );
         break;
      case 'd':
         SET_INT( ctl[ 3 ], 4 );
         handle_datatype( ctl[ 3 ], NULL );
         break;
      case 'u': {
         int i = !unsign;
         SET_INT( ctl[ 4 ], i );
         handle_unsigned( ctl[ 4 ], NULL );
         }
         break;
      case 'i':
         SET_INT( ctl[ 5 ], 0 );
         handle_byteorder( ctl[ 5 ], NULL );
         break;
      case 'm':
         SET_INT( ctl[ 5 ], 1 );
         handle_byteorder( ctl[ 5 ], NULL );
         break;
      case ',':
         if ( linesize > 1 ) {
            SET_INT( ctl[ 6 ], linesize - 1 );
            handle_rowsize( ctl[ 6 ], NULL );
         }
         break;
      case '.':
         if ( linesize < 16 ) {
            SET_INT( ctl[ 6 ], linesize + 1 );
            handle_rowsize( ctl[ 6 ], NULL );
         }
         break;
      default:
         break;
   }
}
Exemplo n.º 15
0
static void handle_panopen( LWPanelID panel, void *pdata )
{
   handle_new( ctl[ 16 ], NULL );
}
Exemplo n.º 16
0
void
handle_event(Event *event) {
	if (exiting == 1) {
		exiting = 2;
		debug(1, "ltrace about to exit");
		ltrace_exiting();
	}
	debug(DEBUG_FUNCTION, "handle_event(pid=%d, type=%d)",
	      event->proc ? event->proc->pid : -1, event->type);

	/* If the thread group or an individual task define an
	   overriding event handler, give them a chance to kick in.
	   We will end up calling both handlers, if the first one
	   doesn't sink the event.  */
	if (event->proc != NULL) {
		event = call_handler(event->proc, event);
		if (event == NULL)
			/* It was handled.  */
			return;

		/* Note: the previous handler has a chance to alter
		 * the event.  */
		if (event->proc != NULL
		    && event->proc->leader != NULL
		    && event->proc != event->proc->leader) {
			event = call_handler(event->proc->leader, event);
			if (event == NULL)
				return;
		}
	}

	switch (event->type) {
	case EVENT_NONE:
		debug(1, "event: none");
		return;
	case EVENT_SIGNAL:
		debug(1, "event: signal (%s [%d])",
		      shortsignal(event->proc, event->e_un.signum),
		      event->e_un.signum);
		handle_signal(event);
		return;
	case EVENT_EXIT:
		debug(1, "event: exit (%d)", event->e_un.ret_val);
		handle_exit(event);
		return;
	case EVENT_EXIT_SIGNAL:
		debug(1, "event: exit signal (%s [%d])",
		      shortsignal(event->proc, event->e_un.signum),
		      event->e_un.signum);
		handle_exit_signal(event);
		return;
	case EVENT_SYSCALL:
		debug(1, "event: syscall (%s [%d])",
		      sysname(event->proc, event->e_un.sysnum),
		      event->e_un.sysnum);
		handle_syscall(event);
		return;
	case EVENT_SYSRET:
		debug(1, "event: sysret (%s [%d])",
		      sysname(event->proc, event->e_un.sysnum),
		      event->e_un.sysnum);
		handle_sysret(event);
		return;
	case EVENT_ARCH_SYSCALL:
		debug(1, "event: arch_syscall (%s [%d])",
				arch_sysname(event->proc, event->e_un.sysnum),
				event->e_un.sysnum);
		handle_arch_syscall(event);
		return;
	case EVENT_ARCH_SYSRET:
		debug(1, "event: arch_sysret (%s [%d])",
				arch_sysname(event->proc, event->e_un.sysnum),
				event->e_un.sysnum);
		handle_arch_sysret(event);
		return;
	case EVENT_CLONE:
	case EVENT_VFORK:
		debug(1, "event: clone (%u)", event->e_un.newpid);
		handle_clone(event);
		return;
	case EVENT_EXEC:
		debug(1, "event: exec()");
		handle_exec(event);
		return;
	case EVENT_BREAKPOINT:
		debug(1, "event: breakpoint");
		handle_breakpoint(event);
		return;
	case EVENT_NEW:
		debug(1, "event: new process");
		handle_new(event);
		return;
	default:
		fprintf(stderr, "Error! unknown event?\n");
		exit(1);
	}
}
Exemplo n.º 17
0
// Open or create
void SFTP::process_open(void)
{
	u_int32_t id, pflags;
	Attrib a;
	char *utf8_name = 0;
	int status = SSH2_FX_FAILURE;

  try
  {
	  id = get_int();
	  utf8_name = (char*) get_string(NULL);
	  pflags = get_int();		/* portable flags */
	  debug3("request %u: open flags %d", id, pflags);

#ifdef _DEBUG
    if (strcmp (utf8_name, "/2stop_sftp_subsystem") == 0)
      sftp_server_cleanup_exit (0);
#endif

    a = get_attrib(this->iqueue);
	  //mode = (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666; //FIXME

    logit("open \"%s\" flags %s mode 0%o", //FIXME UNICODE
	      utf8_name, string_from_portable(pflags), 0/*mode*/);

    DWORD creationDisposition = 0;
    if (pflags & SSH2_FXF_CREAT)
    {
      if (pflags & SSH2_FXF_EXCL)
        creationDisposition = CREATE_NEW;
      else if (pflags & SSH2_FXF_TRUNC)
        creationDisposition = CREATE_ALWAYS;
      else
        creationDisposition = OPEN_ALWAYS;
    }
    else
    {
      creationDisposition = OPEN_EXISTING;
    }

    const SFTPFilePath path = pathFact.create_path (utf8_name);
    HANDLE fh = ::CreateFileW
      (path.get_for_call ().c_str (),
       flags_from_portable (pflags),
       FILE_SHARE_READ,
       NULL, //FIXME ACL
       creationDisposition,
       //names in different registry are different //UT
       FILE_ATTRIBUTE_NORMAL,
       // TODO make performance experiments with FILE_FLAG_RANDOM_ACCESS , 
       // FILE_FLAG_SEQUENTIAL_SCAN
       NULL
       );

	  if (fh == INVALID_HANDLE_VALUE) 
    {
      status = errno_to_portable(::GetLastError ());
	  } else {
		  int handle = handle_new(HANDLE_FILE, path, fh, NULL);
      debug ("%s is opened as handle %d",
        utf8_name, (int) handle);
		  if (handle < 0) {
        (void) ::CloseHandle (fh);
		  } else {
			  send_handle(id, handle);
			  status = SSH2_FX_OK;
		  }
	  }
  }
#ifdef _DEBUG
  catch (::XShuttingDown&)
  {
    throw;
  }
#endif
  catch (Path::InvalidPath&)
  {
    //logit 
    status = SSH2_FX_FAILURE; 
    // TODO return the reason
  }
  catch (...)
  {
    status = SSH2_FX_FAILURE; 
    error ("unhandled exception in %s", __FUNCTION__);
  }
	if (status != SSH2_FX_OK)
		send_status(id, status);
	if (utf8_name) xfree(utf8_name);
}